Added settings classes for CSS; added Register parsing

This commit is contained in:
schnulller
2022-05-18 04:38:57 +02:00
parent 2ffd46cd62
commit f1743fcf39
14 changed files with 882 additions and 258 deletions

View File

@@ -14,10 +14,6 @@ namespace HaWeb.Controllers;
[Route("Register/[action]/{id?}")] [Route("Register/[action]/{id?}")]
public class RegisterController : Controller public class RegisterController : Controller
{ {
private static HashSet<string> _permittedRegister;
private static HashSet<string> _permittedBibelstellen;
private static HashSet<string> _permittedForschung;
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public string? search { get; set; } public string? search { get; set; }
@@ -32,88 +28,161 @@ public class RegisterController : Controller
{ {
_lib = lib; _lib = lib;
_readerService = readerService; _readerService = readerService;
_permittedRegister = new HashSet<string>();
_lib.CommentsByCategoryLetter["neuzeit"].Select(x => _permittedRegister.Add(x.Key));
_permittedForschung = new HashSet<string>();
_lib.CommentsByCategoryLetter["forschung"].Select(x => _permittedForschung.Add(x.Key));
_permittedForschung.Add("Editionen");
_permittedBibelstellen = new HashSet<string>();
_permittedBibelstellen.Add("NT");
_permittedBibelstellen.Add("AP");
_permittedBibelstellen.Add("AT");
} }
public IActionResult Register(string? id) public IActionResult Register(string? id)
{ {
// Setup settings and variables
var url = "/Register/Register/";
var category = "neuzeit"; var category = "neuzeit";
var defaultLetter = "A"; var defaultLetter = "A";
normalizeID(id, defaultLetter); var title = "Allgemeines Register";
ViewData["Title"] = "Allgemeines Register"; ViewData["Title"] = "Allgemeines Register";
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Personen-, Sach- und Ortsregister."; ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Personen-, Sach- und Ortsregister.";
return standardModel(category, id, defaultLetter, new RegisterViewModel(), _permittedRegister);
// Normalisation and validation
if (id == null) return Redirect(url + defaultLetter);
normalizeID(id, defaultLetter);
if (!_lib.CommentsByCategoryLetter[category].Contains(this.id)) return error404();
// Data aquisition and validation
var comments = _lib.CommentsByCategoryLetter[category][this.id].OrderBy(x => x.Index);
var availableCategories = _lib.CommentsByCategoryLetter[category].Select(x => (x.Key.ToUpper(), url + x.Key.ToUpper())).OrderBy(x => x.Item1).ToList();
if (comments == null) return error404();
// Parsing
var res = new List<CommentModel>();
foreach (var comm in comments)
{
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, comm);
List<string>? parsedSubComments = null;
if (comm.Kommentare != null)
{
parsedSubComments = new List<string>();
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order))
{
parsedSubComments.Add(HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, subcomm.Value));
}
}
res.Add(new CommentModel(parsedComment, parsedSubComments));
}
// Model instantiation
var model = new RegisterViewModel(category, this.id, res, title)
{
AvailableCategories = availableCategories,
};
// Return
return View("Index", model);
} }
public IActionResult Bibelstellen(string? id) public IActionResult Bibelstellen(string? id)
{ {
// Setup settings and variables
var url = "/Register/Bibelstellen/";
var category = "bibel"; var category = "bibel";
var defaultLetter = "AT"; var defaultLetter = "AT";
normalizeID(id, defaultLetter); var title = "Bibelstellenregister";
ViewData["Title"] = "Bibelstellenregister"; ViewData["Title"] = "Bibelstellenregister";
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Bibelstellenregister."; ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Bibelstellenregister.";
var model = new RegisterViewModel() {
AvailableCategories = new List<(string, string)>() { ("Altes Testament", "AT"), ("Apogryphen", "AP"), ("Neues Testament", "NT") }, // Normalisation and Validation
Comments = _lib.CommentsByCategory["bibel"].ToLookup(x => x.Index.Substring(0, 2).ToUpper()).Contains(id) ? if (id == null) return Redirect(url + defaultLetter);
_lib.CommentsByCategory["bibel"].ToLookup(x => x.Index.Substring(0, 2).ToUpper())[id].Select(x => new CommentModel(x)).OrderBy(x => x.Comment.Order).ToList() : null, normalizeID(id, defaultLetter);
if (this.id != "AT" && this.id != "AP" && this.id != "NT") return error404();
// Data aquisition and validation
var comments = _lib.CommentsByCategory[category].ToLookup(x => x.Index.Substring(0, 2).ToUpper())[this.id].OrderBy(x => x.Order);
var availableCategories = new List<(string, string)>() { ("Altes Testament", url + "AT"), ("Apogryphen", url + "AP"), ("Neues Testament", url + "NT") };
if (comments == null) return error404();
// Parsing
var res = new List<CommentModel>();
foreach (var comm in comments)
{
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, comm);
List<string>? parsedSubComments = null;
if (comm.Kommentare != null)
{
parsedSubComments = new List<string>();
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Lemma.Length).ThenBy(x => x.Value.Lemma))
{
parsedSubComments.Add(HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, subcomm.Value));
}
}
res.Add(new CommentModel(parsedComment, parsedSubComments));
}
// Model instantiation
var model = new RegisterViewModel(category, this.id, res, title)
{
AvailableCategories = availableCategories,
}; };
return standardModel(category, id, defaultLetter, new RegisterViewModel(), _permittedBibelstellen);
// Return
return View("Index", model);
} }
public IActionResult Forschung(string? id) public IActionResult Forschung(string? id)
{ {
// Setup settings and variables
var url = "/Register/Forschung/";
var category = "forschung"; var category = "forschung";
var defaultLetter = "A"; var defaultLetter = "A";
normalizeID(id, defaultLetter); var title = "Forschungsbibliographie";
if (id != null && id.ToUpper() == "EDITIONEN") category = "editionen";
var model = new RegisterViewModel()
{
AvailableSideCategories = new List<(string, string)>() { ("Editionen", "Editionen") },
};
ViewData["Title"] = "Forschungsbibliographie"; ViewData["Title"] = "Forschungsbibliographie";
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Forschungsbibliographie."; ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Forschungsbibliographie.";
return standardModel(category, id, defaultLetter, new RegisterViewModel(), _permittedForschung);
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] // Normalisation and Validation
public IActionResult Error() if (id == null) return Redirect(url + defaultLetter);
{ normalizeID(id, defaultLetter);
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); if (this.id != "EDITIONEN" && !_lib.CommentsByCategoryLetter[category].Contains(this.id)) return error404();
} if (this.id == "EDITIONEN" && !_lib.CommentsByCategoryLetter.Keys.Contains(this.id.ToLower())) return error404();
private IActionResult standardModel(string category, string? id, string defaultid, HaWeb.Models.RegisterViewModel model, HashSet<string> permitted) // Data aquisition and validation
{ IOrderedEnumerable<Comment>? comments = null;
if (!validationCheck(permitted)) { if (this.id == "EDITIONEN") {
Response.StatusCode = 404; comments = _lib.CommentsByCategory[this.id.ToLower()].OrderBy(x => x.Index);
return Redirect("/Error404"); }
else {
comments = _lib.CommentsByCategoryLetter[category][this.id].OrderBy(x => x.Index);
} }
model.Category = category; var availableCategories = _lib.CommentsByCategoryLetter[category].Select(x => (x.Key.ToUpper(), url + x.Key.ToUpper())).OrderBy(x => x.Item1).ToList();
model.Id = id; var AvailableSideCategories = new List<(string, string)>() { ("Editionen", "Editionen") };
model.Search = search ?? ""; if (comments == null) return error404();
model.Comments = model.Comments ?? _lib.CommentsByCategoryLetter[category][id].Select(x => new CommentModel(x)).OrderBy(x => x.Comment.Index).ToList();
model.AvailableCategories = model.AvailableCategories ?? _lib.CommentsByCategoryLetter[category].Select(x => (x.Key.ToUpper(), x.Key.ToUpper())).ToList();
model.AvailableCategories.Sort();
foreach (var k in model.Comments) // Parsing
k.SetHTML(_lib, _readerService); var res = new List<CommentModel>();
foreach (var comm in comments)
{
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, comm);
List<string>? parsedSubComments = null;
if (comm.Kommentare != null)
{
parsedSubComments = new List<string>();
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order))
{
parsedSubComments.Add(HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, subcomm.Value));
}
}
res.Add(new CommentModel(parsedComment, parsedSubComments));
}
// Model instantiation
var model = new RegisterViewModel(category, this.id, res, title)
{
AvailableCategories = availableCategories,
AvailableSideCategories = AvailableSideCategories
};
// Return
return View("Index", model); return View("Index", model);
} }
private void normalizeID(string? id, string defaultid) { private void normalizeID(string? id, string defaultid)
id = id ?? defaultid; {
id = id.ToUpper(); this.id = this.id.ToUpper();
} }
private bool validationCheck(HashSet<string> permitted) private bool validationCheck(HashSet<string> permitted)
@@ -125,6 +194,12 @@ public class RegisterController : Controller
return true; return true;
} }
private IActionResult error404()
{
Response.StatusCode = 404;
return Redirect("/Error404");
}
// private IEnumerable<Comment> Search(IEnumerable<Comment> all) { // private IEnumerable<Comment> Search(IEnumerable<Comment> all) {
// var ret = new ConcurrentBag<Comment>(); // var ret = new ConcurrentBag<Comment>();
// var cnt = 0; // var cnt = 0;

View File

@@ -0,0 +1,92 @@
namespace HaWeb.HTMLHelpers;
using HaDocument.Interfaces;
using HaXMLReader.Interfaces;
using HaXMLReader.EvArgs;
using HaDocument.Models;
using System.Text;
public static class CommentHelpers
{
private static readonly string DEFAULTELEMENT = HaWeb.Settings.ParsingSettings.DEFAULTELEMENT;
private static readonly string LEMMACLASS = HaWeb.Settings.CSSClasses.LEMMACLASS;
private static readonly string TITLECLASS = HaWeb.Settings.CSSClasses.TITLECLASS;
private static readonly string BACKLINKSCLASS = HaWeb.Settings.CSSClasses.BACKLINKSCLASS;
private static readonly string LETLINKCLASS = HaWeb.Settings.CSSClasses.LETLINKCLASS;
private static readonly string COMMENTHEADCLASS = HaWeb.Settings.CSSClasses.COMMENTHEADCLASS;
private static readonly string COMMENTBODYCLASS = HaWeb.Settings.CSSClasses.COMMENTBODYCLASS;
// Parsing Rules
private static readonly List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _OTagFuncs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, LEMMACLASS))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, TITLECLASS))),
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, TITLECLASS)))
};
private static readonly List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _CTagFuncs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT))),
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT)))
};
private static readonly List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _STagFuncs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "line", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement("br")) )
};
private static readonly List<(Func<Text, bool>, Action<StringBuilder, Text>)> _TextFuncs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
private static readonly List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> _WhitespaceFuncs = new List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
public static string CreateHTML(ILibrary lib, IReaderService readerService, Comment comment)
{
StringBuilder sb = new StringBuilder();
var rd = readerService.RequestStringReader(comment.Lemma);
new HTMLHelpers.XMLHelper(rd, sb, _OTagFuncs, _STagFuncs, _CTagFuncs, _TextFuncs, _WhitespaceFuncs);
sb.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, COMMENTHEADCLASS, comment.Index));
new HTMLHelpers.LinkHelper(lib, rd, sb);
rd.Read();
var backlinks = lib.Backlinks.ContainsKey(comment.Index) ? lib.Backlinks[comment.Index]
.Where(x => lib.Metas.ContainsKey(x.Letter))
.OrderBy(x => lib.Metas[x.Letter].Sort)
.ThenBy(x => lib.Metas[x.Letter].Order) : null;
if (backlinks != null)
{
sb.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, BACKLINKSCLASS));
var arrow = false;
foreach (var blk in backlinks)
{
var let = lib.Metas.ContainsKey(blk.Letter) ? lib.Metas[blk.Letter] : null;
if (let != null)
{
if (!arrow)
{
sb.Append("HKB&nbsp;");
arrow = true;
}
sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", LETLINKCLASS, "/Briefe/" + let.Autopsic + "#" + blk.Page + "-" + blk.Line));
var linkstring = "";
var pglnstring = "";
linkstring += let.Autopsic;
pglnstring += "&nbsp;(&#8239;" + blk.Page + "/" + blk.Line + "&#8239;)";
linkstring += pglnstring;
sb.Append(linkstring);
if (blk != backlinks.Last())
sb.Append(", ");
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("a"));
}
}
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT));
}
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT));
sb.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, COMMENTBODYCLASS));
rd = readerService.RequestStringReader(comment.Entry);
new HTMLHelpers.XMLHelper(rd, sb, _OTagFuncs, _STagFuncs, _CTagFuncs, _TextFuncs, _WhitespaceFuncs);
new HTMLHelpers.LinkHelper(lib, rd, sb);
rd.Read();
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT));
return sb.ToString();
}
}

View File

@@ -14,9 +14,32 @@ public class LinkHelper {
private StringBuilder _sb; private StringBuilder _sb;
private bool _followlinksinchildren; private bool _followlinksinchildren;
private bool _followlinksinthis; private bool _followlinksinthis;
private static readonly string DEFAULTELEMENT = HaWeb.Settings.ParsingSettings.DEFAULTELEMENT;
private static readonly string LETLINKCLASS = HaWeb.Settings.CSSClasses.LETLINKCLASS;
private static readonly string REFLINKCLASS = HaWeb.Settings.CSSClasses.REFLINKCLASS;
private static readonly string WWWLINKCLASS = HaWeb.Settings.CSSClasses.WWWLINKCLASS;
private static readonly string INSERTEDLEMMACLASS = HaWeb.Settings.CSSClasses.INSERTEDLEMMACLASS;
private static readonly string TITLECLASS = HaWeb.Settings.CSSClasses.TITLECLASS;
// Parsing Rules for inserting lemmas
private static readonly List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> OTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, INSERTEDLEMMACLASS)) ),
( x => x.Name == "titel", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, TITLECLASS)) ),
( x => x.Name == "title", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, TITLECLASS)) )
};
private static readonly List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> CTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT)) ),
( x => x.Name == "titel", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT)) ),
( x => x.Name == "title", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT)) )
};
private static readonly List<(Func<Text, bool>, Action<StringBuilder, Text>)> Text_Funcs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, (strbd, txt) => strbd.Append(txt.Value))
};
public LinkHelper(ILibrary lib, IReader reader, StringBuilder stringBuilder, bool followlinksinchildren = true, bool followlinksinthis = true) { public LinkHelper(ILibrary lib, IReader reader, StringBuilder stringBuilder, bool followlinksinchildren = true, bool followlinksinthis = true) {
if (lib == null || reader == null || stringBuilder == null) throw new ArgumentNullException(); if (lib == null || reader == null || stringBuilder == null) throw new ArgumentNullException();
_lib = lib; _lib = lib;
@@ -35,13 +58,13 @@ public class LinkHelper {
else { else {
if (tag.Name == "wwwlink" && tag.Values.ContainsKey("address") && _followlinksinthis) if (tag.Name == "wwwlink" && tag.Values.ContainsKey("address") && _followlinksinthis)
_sb.Append(HTMLHelpers.TagHelpers.CreateCustomElement("a", _sb.Append(HTMLHelpers.TagHelpers.CreateCustomElement("a",
new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "class", Value = "hlink wwwlink invlink" }, new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "class", Value = WWWLINKCLASS },
new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "href", Value = tag["address"]}, new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "href", Value = tag["address"]},
new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "target", Value = "_blank"}, new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "target", Value = "_blank"},
new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "rel", Value = "noopener noreferrer"})); new HaWeb.HTMLHelpers.TagHelpers.Attribute() { Name = "rel", Value = "noopener noreferrer"}));
if (tag.Name == "intlink" && tag.Values.ContainsKey("letter") && _lib.Metas.ContainsKey(tag["letter"])) { if (tag.Name == "intlink" && tag.Values.ContainsKey("letter") && _lib.Metas.ContainsKey(tag["letter"])) {
var letter = _lib.Metas[tag["letter"]]; var letter = _lib.Metas[tag["letter"]];
_sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", "hlink intlink invlink", "/Briefe/" + letter.Autopsic + "#" + tag["page"] + "-" + tag["line"])); _sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", LETLINKCLASS, "/Briefe/" + letter.Autopsic + "#" + tag["page"] + "-" + tag["line"]));
if (!tag.Values.ContainsKey("linktext") || tag.Values["linktext"] == "true") { if (!tag.Values.ContainsKey("linktext") || tag.Values["linktext"] == "true") {
var linkstring = ""; var linkstring = "";
var ZHstring = ""; var ZHstring = "";
@@ -75,11 +98,11 @@ public class LinkHelper {
var linkloc = String.IsNullOrWhiteSpace(comment.Parent) ? comment.Index : comment.Parent; var linkloc = String.IsNullOrWhiteSpace(comment.Parent) ? comment.Index : comment.Parent;
if (_followlinksinthis) if (_followlinksinthis)
if (comment.Type == "neuzeit") if (comment.Type == "neuzeit")
_sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", "hlink link invlink", "/Supplementa/Register/" + linkloc[0] + "#" + comment.Index)); _sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", REFLINKCLASS, "/Register/Register/" + linkloc[0] + "#" + comment.Index));
else if (comment.Type == "bibel") else if (comment.Type == "bibel")
_sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", "hlink link invlink", "/Supplementa/Bibelstellen/" + linkloc[0] + linkloc[1] + "#" + comment.Index)); _sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", REFLINKCLASS, "/Register/Bibelstellen/" + linkloc[0] + linkloc[1] + "#" + comment.Index));
else if (comment.Type == "forschung") else if (comment.Type == "forschung")
_sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", "hlink link invlink", "/Supplementa/Forschung/" + linkloc[0] + "#" + comment.Index)); _sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", REFLINKCLASS, "/Register/Forschung/" + linkloc[0] + "#" + comment.Index));
_sb.Append(GetLemmaString(tag, comment)); _sb.Append(GetLemmaString(tag, comment));
} }
} }
@@ -93,17 +116,6 @@ public class LinkHelper {
var sb = new StringBuilder(); var sb = new StringBuilder();
var subreader = new UTF8StringReader(comment.Lemma); var subreader = new UTF8StringReader(comment.Lemma);
new LinkHelper(_lib, subreader, sb, _followlinksinchildren, _followlinksinchildren); new LinkHelper(_lib, subreader, sb, _followlinksinchildren, _followlinksinchildren);
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> OTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateElement("div", "reference")) ),
( x => x.Name == "titel", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateElement("span", "title")) )
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> CTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateEndElement("div")) ),
( x => x.Name == "titel", (strbd, x) => strbd.Append(HTMLHelpers.TagHelpers.CreateEndElement("span")) )
};
List<(Func<Text, bool>, Action<StringBuilder, Text>)> Text_Funcs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, (strbd, txt) => strbd.Append(txt.Value))
};
new XMLHelper(subreader, sb, OTag_Funcs, null, CTag_Funcs, Text_Funcs, null); new XMLHelper(subreader, sb, OTag_Funcs, null, CTag_Funcs, Text_Funcs, null);
subreader.Read(); subreader.Read();
return sb.ToString(); return sb.ToString();

View File

@@ -5,28 +5,30 @@ using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
public class XMLHelper { public class XMLHelper
{
private IReader _in; private IReader _in;
private StringBuilder _target; private StringBuilder _target;
private List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _OTag_Funcs; private List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>? _OTag_Funcs;
private List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _STag_Funcs; private List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>? _STag_Funcs;
private List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _CTag_Funcs; private List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>? _CTag_Funcs;
private List<(Func<Text, bool>, Action<StringBuilder, Text>)> _Text_Funcs; private List<(Func<Text, bool>, Action<StringBuilder, Text>)>? _Text_Funcs;
private List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> _WS_Funcs; private List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>? _WS_Funcs;
private bool _deleteLeadingWS; private bool _deleteLeadingWS;
private bool _deleteTrailingWS; private bool _deleteTrailingWS;
public XMLHelper( public XMLHelper(
IReader input, IReader input,
StringBuilder target, StringBuilder target,
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> OTag_Funcs = null, List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>? OTag_Funcs = null,
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> STag_Funcs = null, List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>? STag_Funcs = null,
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> CTag_Funcs = null, List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>? CTag_Funcs = null,
List<(Func<Text, bool>, Action<StringBuilder, Text>)> Text_Funcs = null, List<(Func<Text, bool>, Action<StringBuilder, Text>)>? Text_Funcs = null,
List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> WS_Funcs = null, List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>? WS_Funcs = null,
bool deleteLeadingWS = false, bool deleteLeadingWS = false,
bool deleteTrailingWS = false bool deleteTrailingWS = false
) { )
{
if (input == null || target == null) throw new ArgumentNullException(); if (input == null || target == null) throw new ArgumentNullException();
_in = input; _in = input;
@@ -52,36 +54,45 @@ public class XMLHelper {
_in.Whitespace += OnWS; _in.Whitespace += OnWS;
} }
void OnOTag(object _, Tag tag) { void OnOTag(object _, Tag tag)
foreach(var entry in _OTag_Funcs) {
if (entry.Item1(tag)) entry.Item2(_target, tag); if (_OTag_Funcs != null)
foreach (var entry in _OTag_Funcs)
if (entry.Item1(tag)) entry.Item2(_target, tag);
} }
void OnText(object _, Text text) { void OnText(object _, Text text)
{
if (_deleteLeadingWS) text.Value = text.Value.TrimStart(); if (_deleteLeadingWS) text.Value = text.Value.TrimStart();
if (_deleteTrailingWS) text.Value = text.Value.TrimEnd(); if (_deleteTrailingWS) text.Value = text.Value.TrimEnd();
foreach(var entry in _Text_Funcs) foreach (var entry in _Text_Funcs)
if (entry.Item1(text)) entry.Item2(_target, text); if (entry.Item1(text)) entry.Item2(_target, text);
} }
void OnSTag(object _, Tag tag) { void OnSTag(object _, Tag tag)
foreach(var entry in _STag_Funcs) {
foreach (var entry in _STag_Funcs)
if (entry.Item1(tag)) entry.Item2(_target, tag); if (entry.Item1(tag)) entry.Item2(_target, tag);
} }
void OnCTag (object _, Tag tag) { void OnCTag(object _, Tag tag)
{
foreach (var entry in _CTag_Funcs) foreach (var entry in _CTag_Funcs)
if (entry.Item1(tag)) entry.Item2(_target, tag); if (entry.Item1(tag)) entry.Item2(_target, tag);
} }
void OnWS (object _, Whitespace ws) { void OnWS(object _, Whitespace ws)
foreach (var entry in _WS_Funcs) { {
foreach (var entry in _WS_Funcs)
{
if (entry.Item1(ws)) entry.Item2(_target, ws); if (entry.Item1(ws)) entry.Item2(_target, ws);
} }
} }
internal void Dispose() { internal void Dispose()
if (_in != null) { {
if (_in != null)
{
if (_OTag_Funcs != null) if (_OTag_Funcs != null)
_in.OpenTag -= OnOTag; _in.OpenTag -= OnOTag;
if (_STag_Funcs != null) if (_STag_Funcs != null)
@@ -95,7 +106,8 @@ public class XMLHelper {
} }
} }
~XMLHelper() { ~XMLHelper()
{
Dispose(); Dispose();
} }
} }

View File

@@ -7,102 +7,12 @@ using HaXMLReader.EvArgs;
public class CommentModel public class CommentModel
{ {
public Comment Comment { get; private set; } public string ParsedComment { get; private set; }
public string? ParsedComment { get; private set; } public List<string>? ParsedSubComments { get; private set; }
public List<CommentModel>? SubComments { get; private set; }
// Parsing Rules public CommentModel(string parsedComment, List<string>? parsedSubComments)
private static List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _OTagFuncs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement("div", "lemma"))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement("div", "title"))),
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement("div", "title")))
};
private static List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _CTagFuncs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("div"))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("div"))),
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("div")))
};
private static List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> _STagFuncs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "line", (sb, tag) => sb.Append(HTMLHelpers.TagHelpers.CreateElement("br")) )
};
private static List<(Func<Text, bool>, Action<StringBuilder, Text>)> _TextFuncs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
private static List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> _WhitespaceFuncs = new List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
public CommentModel(Comment comment)
{ {
this.Comment = comment; this.ParsedComment = parsedComment;
if (comment.Kommentare != null && comment.Kommentare.Any()) this.ParsedSubComments = parsedSubComments;
{
SubComments = comment.Kommentare.Select(x => new CommentModel(x.Value)).OrderBy(x => x.Comment.Order).ToList();
}
}
public string returnHTML(ILibrary _lib, IReaderService _readerService)
{
StringBuilder sb = new StringBuilder();
var rd = _readerService.RequestStringReader(Comment.Lemma);
new HTMLHelpers.XMLHelper(rd, sb, _OTagFuncs, _STagFuncs, _CTagFuncs, _TextFuncs, _WhitespaceFuncs);
sb.Append(HTMLHelpers.TagHelpers.CreateElement("div", "lemma", Comment.Index));
new HTMLHelpers.LinkHelper(_lib, rd, sb);
rd.Read();
var backlinks = _lib.Backlinks.ContainsKey(Comment.Index) ? _lib.Backlinks[Comment.Index]
.Where(x => _lib.Metas.ContainsKey(x.Letter))
.OrderBy(x => _lib.Metas[x.Letter].Sort)
.ThenBy(x => _lib.Metas[x.Letter].Order) : null;
if (backlinks != null)
{
sb.Append(HTMLHelpers.TagHelpers.CreateElement("div", "backlinks"));
var arrow = false;
foreach (var blk in backlinks)
{
var let = _lib.Metas.ContainsKey(blk.Letter) ? _lib.Metas[blk.Letter] : null;
if (let != null)
{
if (!arrow)
{
sb.Append("&emsp;&rarr;&nbsp;");
sb.Append("HKB&nbsp;");
arrow = true;
}
sb.Append(HTMLHelpers.TagHelpers.CreateElement("a", "backlink", "/Briefe/" + let.Autopsic + "#" + blk.Page + "-" + blk.Line));
var linkstring = "";
var pglnstring = "";
linkstring += let.Autopsic;
pglnstring += "&nbsp;(&#8239;" + blk.Page + "/" + blk.Line + "&#8239;)";
linkstring += pglnstring;
sb.Append(linkstring);
if (blk != backlinks.Last())
sb.Append(",&emsp;");
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("a"));
}
}
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("div"));
}
sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("div"));
rd = _readerService.RequestStringReader(Comment.Entry);
new HTMLHelpers.XMLHelper(rd, sb, _OTagFuncs, _STagFuncs, _CTagFuncs, _TextFuncs, _WhitespaceFuncs);
new HTMLHelpers.LinkHelper(_lib, rd, sb);
rd.Read();
if (SubComments != null && SubComments.Any())
{
foreach (var k in SubComments)
{
k.SetHTML(_lib, _readerService);
}
}
return sb.ToString();
}
public void SetHTML(ILibrary _lib, IReaderService _readerService) {
ParsedComment = returnHTML(_lib, _readerService);
} }
} }

View File

@@ -2,12 +2,21 @@ namespace HaWeb.Models;
using HaDocument.Models; using HaDocument.Models;
public class RegisterViewModel { public class RegisterViewModel {
public string Category { get; set; } = ""; public string Category { get; private set; }
public string Id { get; set; } = ""; public string Id { get; private set; }
public string Search { get; set; } = ""; public string Title { get; private set; }
public bool MaxSearch { get; set; } = false;
public string? Search { get; set; } = null;
public bool? MaxSearch { get; set; } = null;
// TODO: no null-checks in the Page Logic // TODO: no null-checks in the Page Logic
public List<CommentModel>? Comments { get; set; } = null; public List<CommentModel> ParsedComments { get; private set; }
public List<(string, string)>? AvailableCategories { get; set; } = null; public List<(string, string)>? AvailableCategories { get; set; } = null;
public List<(string, string)>? AvailableSideCategories { get; set; } = null; public List<(string, string)>? AvailableSideCategories { get; set; } = null;
public RegisterViewModel(string category, string id, List<CommentModel> parsedComments, string title) {
this.Category = category;
this.Id = id;
this.ParsedComments = parsedComments;
this.Title = title;
}
} }

View File

@@ -0,0 +1,16 @@
namespace HaWeb.Settings;
public static class CSSClasses {
public const string LEMMACLASS = "ha-lemma"; // XML: <lemma>
public const string TITLECLASS = "ha-title"; // XML: <title>
public const string BACKLINKSCLASS = "ha-letlinks"; // Collection containing links to references in letters
public const string COMMENTHEADCLASS = "ha-commenthead"; // Head of a comment, containing lemma and backlinks
public const string COMMENTBODYCLASS = "ha-commentbody"; // Body of a comment, contasining the text
public const string LETLINKCLASS = "ha-letlink"; // XML: <link>
public const string REFLINKCLASS = "ha-reflink"; // XML <intlink>
public const string WWWLINKCLASS = "ha-wwwlink"; // XML: <wwwlink>
public const string INSERTEDLEMMACLASS = "ha-insertedlemma"; // XML <link linktext="true"></link>
}

View File

@@ -0,0 +1,5 @@
namespace HaWeb.Settings;
public static class ParsingSettings {
public const string DEFAULTELEMENT = "div"; // Every tag gets replaced by a div, except fpr link or wwwlink
}

View File

@@ -1,11 +1,56 @@
@model RegisterViewModel; @model RegisterViewModel;
@using System.Diagnostics; @using System.Diagnostics;
@foreach (var k in Model.Comments) { @* Generated classes by CommentHelper.cs:
<div>@Html.Raw(k.ParsedComment)</div> - .ha-letlink .ha-wwwlink .ha-reflink: Links to letters, the web, the reference
@if (k.SubComments != null ) { - .ha-lemma: The lemma
@foreach (var sk in k.SubComments) { - .ha-title: Name of something
<div>@Html.Raw(sk.ParsedComment)</div> - .ha-reference: Automatically inserted linktext
- .ha-commenthead: Class containing the head of a comment, lemma and backlinks
- .ha-commentbody: Body of a comment, containing the comments text
- .ha-letlinks: Collection of references in the comment within the marginals
- .ha-insertedlemma: automatically generated and inserted lemma
*@
@{
var commentClass = Model.Category == "neuzeit" ? "ha-neuzeit"
: Model.Category == "forschung" ? "ha-forschung"
: "ha-bibel";
}
<div class="ha-register">
<div class="@commentClass">
<div class="ha-register-head">
<h1>@Model.Title</h1>
<div class="ha-register-nav" id="ha-register-nav">
<div class="ha-register-left-nav">
@if (Model.AvailableCategories != null) {
@foreach (var l in Model.AvailableCategories) {
<a href="@l.Item2">@l.Item1</a>
}
}
</div>
<div class="ha-register-right-nav">
@if (Model.AvailableSideCategories != null) {
foreach (var l in Model.AvailableSideCategories) {
<a href="@l.Item2">@l.Item1</a>
}
}
</div>
</div>
</div>
<div class="ha-register-body">
@foreach (var k in Model.ParsedComments) {
<div class="ha-comment">
<div class="ha-headcomment">@Html.Raw(k.ParsedComment)</div>
@if (k.ParsedSubComments != null ) {
@foreach (var sk in k.ParsedSubComments) {
<div class="ha-subcomment">@Html.Raw(sk)</div>
}
}
</div>
} }
} </div>
} </div>
</div>

View File

@@ -66,43 +66,4 @@
<a href="/Edition/Mitwirkende">Hg. v. Leonard Keidel und Janina Reibold, auf Grundlage der Vorarbeiten Arthur Henkels, unter Mitarbeit von G. Babelotzky, K. Bucher, Ch. Großmann, C.F. Haak, L. Klopfer, J. Knüchel, I. Langkabel und S. Martens (Heidelberg 2020ff.)</a> <a href="/Edition/Mitwirkende">Hg. v. Leonard Keidel und Janina Reibold, auf Grundlage der Vorarbeiten Arthur Henkels, unter Mitarbeit von G. Babelotzky, K. Bucher, Ch. Großmann, C.F. Haak, L. Klopfer, J. Knüchel, I. Langkabel und S. Martens (Heidelberg 2020ff.)</a>
</div> </div>
} }
</header> </header>
<script>
const _openmenu = function () {
var x = document.getElementById("ha-topnav");
if (x !== null) x.className += " ha-topnav-collapsed";
let oldbutton = document.getElementById("openmenubutton");
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
let newbutton = document.getElementById("closemenubutton");
if (newbutton !== null) newbutton.setAttribute('class', '');
}
const _closemenu = function () {
var x = document.getElementById("ha-topnav");
if (x !== null) x.className = "ha-topnav";
let oldbutton = document.getElementById("closemenubutton");
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
let newbutton = document.getElementById("openmenubutton");
if (newbutton !== null) newbutton.setAttribute('class', '');
}
const _markactive = function (element) {
// Marks links as active which target URL starts with the current URL
var all_links = element.getElementsByTagName("a"),
i = 0, len = all_links.length,
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
for (; i < len; i++) {
if (full_path.startsWith(all_links[i].href.toLowerCase())) {
console.log(all_links[i].href.split("#")[0]);
all_links[i].className += " active";
}
}
}
document.getElementById("openmenubutton").addEventListener('click', _openmenu);
document.getElementById("closemenubutton").addEventListener('click', _closemenu);
_markactive(document.getElementById("ha-topnav"));
</script>

View File

@@ -2,6 +2,7 @@ module.exports = {
content: [ content: [
"./wwwroot/**/*.{html,js}", "./wwwroot/**/*.{html,js}",
"./Views/**/*.{cshtml,html,js}", "./Views/**/*.{cshtml,html,js}",
"./Settings/CSSClasses.cs"
], ],
theme: { theme: {
fontFamily: { fontFamily: {

View File

@@ -640,11 +640,7 @@ body {
text-decoration-style: solid; text-decoration-style: solid;
} }
/* TODO INLINE /* Classes for static pages */
.ha-maincolumn {
@apply bg-slate-50 mx-auto p-2 md:p-4 desktop:px-16 desktop:py-12 xl:pr-80 text-lg font-serif
} */
.ha-static { .ha-static {
width: 100%; width: 100%;
@@ -786,8 +782,246 @@ body {
text-align: right; text-align: right;
} }
/* Classes for register pages */
.ha-register {
width: 100%;
font-family: Libertine, serif;
font-variant-numeric: oldstyle-nums;
}
.ha-register .ha-register-head, .ha-register .ha-register-body {
--tw-bg-opacity: 1;
background-color: rgb(248 250 252 / var(--tw-bg-opacity));
padding-left: 2.25rem;
padding-right: 2.25rem;
padding-top: 2.25rem;
}
@media (min-width: 1024px) {
.ha-register .ha-register-head, .ha-register .ha-register-body {
padding-left: 4rem;
padding-right: 4rem;
padding-top: 3rem;
}
}
.ha-register .ha-register-head {
border-bottom-width: 2px;
}
.ha-register .ha-register-head h1 {
margin-bottom: 1.5rem;
font-size: 1.25rem;
line-height: 1.75rem;
font-weight: 700;
}
@media (min-width: 1190px) {
.ha-register .ha-register-head h1 {
font-size: 2.25rem;
line-height: 2.5rem;
font-weight: 400;
}
}
.ha-register .ha-register-head .ha-register-nav {
font-family: Biolinum, sans-serif;
}
.ha-register .ha-register-head .ha-register-nav a {
margin-right: 0.25rem;
display: inline-block;
padding-left: 0.25rem;
padding-right: 0.25rem;
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity));
}
.ha-register .ha-register-head .ha-register-nav a:hover {
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity));
}
@media (min-width: 1024px) {
.ha-register .ha-register-head .ha-register-nav a {
margin-right: 0.75rem;
}
}
.ha-register .ha-register-head .ha-register-nav a:first {
padding-left: 0px;
}
.ha-register .ha-register-head .ha-register-nav a.active {
border-bottom-width: 2px;
}
.ha-register .ha-register-head .ha-register-nav .ha-register-left-nav {
display: inline-block;
}
.ha-register .ha-register-head .ha-register-nav .ha-register-right-nav {
display: inline-block;
}
.ha-register .ha-register-body {
padding-bottom: 2.25rem;
}
@media (min-width: 1024px) {
.ha-register .ha-register-body {
padding-right: 24rem;
padding-bottom: 3rem;
}
}
.ha-register .ha-register-body .ha-comment {
margin-bottom: 2.25rem;
display: block;
}
@media (min-width: 1024px) {
.ha-register .ha-register-body .ha-comment {
margin-bottom: 3rem;
}
}
.ha-register .ha-register-body .ha-comment a {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
-webkit-text-decoration-style: dotted;
text-decoration-style: dotted;
}
.ha-register .ha-register-body .ha-comment a:hover {
-webkit-text-decoration-style: solid;
text-decoration-style: solid;
}
.ha-register .ha-register-body .ha-comment .ha-headcomment {
display: block;
}
@media (min-width: 1190px) {
.ha-register .ha-register-body .ha-comment .ha-headcomment {
position: relative;
}
}
.ha-register .ha-register-body .ha-comment .ha-subcomment {
margin-left: 2rem;
margin-top: 0.5rem;
display: block;
}
@media (min-width: 1190px) {
.ha-register .ha-register-body .ha-comment .ha-subcomment {
position: relative;
}
}
.ha-register .ha-register-body .ha-comment .ha-commenthead {
display: block;
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-lemma {
display: inline;
font-weight: 700;
}
.ha-register .ha-forschung .ha-register-body .ha-comment .ha-commenthead .ha-lemma {
display: inline;
font-weight: 400;
}
.ha-register .ha-forschung .ha-register-body .ha-comment {
margin-bottom: 1rem;
padding-left: 1rem;
text-indent: -1rem;
}
@media (min-width: 1024px) {
.ha-register .ha-forschung .ha-register-body .ha-comment {
margin-bottom: 1.5rem;
}
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-letlinks {
margin-left: 0.5rem;
display: inline-block;
font-family: Biolinum, sans-serif;
font-size: 0.75rem;
line-height: 1rem;
font-weight: 400;
line-height: 1.375;
--tw-text-opacity: 1;
color: rgb(75 85 99 / var(--tw-text-opacity));
font-variant-caps: all-petite-caps;
}
@media (min-width: 1024px) {
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-letlinks {
font-size: 0.875rem;
line-height: 1.25rem;
}
}
.ha-register .ha-neuzeit .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks, .ha-register .ha-forschung .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks {
padding-left: 0.5rem;
}
@media (min-width: 1190px) {
.ha-register .ha-neuzeit .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks, .ha-register .ha-forschung .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks {
position: absolute;
left: 48rem;
top: 0px;
display: block;
width: 20rem;
border-left-width: 2px;
text-indent: 0px;
}
}
.ha-register .ha-neuzeit .ha-register-body .ha-subcomment .ha-commenthead .ha-letlinks, .ha-register .ha-forschung .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks {
padding-left: 0.5rem;
}
@media (min-width: 1190px) {
.ha-register .ha-neuzeit .ha-register-body .ha-subcomment .ha-commenthead .ha-letlinks, .ha-register .ha-forschung .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks {
position: absolute;
left: 46rem;
top: 0px;
display: block;
width: 20rem;
border-left-width: 2px;
--tw-bg-opacity: 1;
background-color: rgb(248 250 252 / var(--tw-bg-opacity));
text-indent: 0px;
}
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-letlinks a {
-webkit-text-decoration-line: none;
text-decoration-line: none;
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-letlinks a:hover {
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity));
}
/* Classes from .NET */ /* Classes from .NET */
.ha-title {
display: inline;
font-style: italic;
}
.ha-insertedlemma {
display: inline;
}
.ha-serif { .ha-serif {
font-family: Libertine, serif; font-family: Libertine, serif;
} }
@@ -1288,6 +1522,27 @@ body {
hyphens: none; hyphens: none;
} }
.numeric-mediaeval {
font-variant-numeric: oldstyle-nums;
}
.numeric-normal {
font-variant-numeric: normal;
}
.caps-small {
font-variant-caps: all-petite-caps;
}
.caps-normal {
font-variant-caps: normal;
}
.break-inside-avoid {
-moz-column-break-inside: avoid;
break-inside: avoid;
}
.ha-menu-arrowsymbol::after { .ha-menu-arrowsymbol::after {
display: inline-block; display: inline-block;
margin-left: 0.2em; margin-left: 0.2em;
@@ -1315,6 +1570,15 @@ body {
color:#000000; color:#000000;
} }
/* Not possible otherwise, overwrites javascript set style values, which cant be defined before render */
@media (max-width: 1190px) {
.ha-register .ha-neuzeit .ha-register-body .ha-subcomment .ha-commenthead .ha-letlinks {
height: auto !important;
overflow: unset !important;
}
}
.hover\:text-black:hover { .hover\:text-black:hover {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(0 0 0 / var(--tw-text-opacity)); color: rgb(0 0 0 / var(--tw-text-opacity));

View File

@@ -132,15 +132,12 @@
@apply underline decoration-solid @apply underline decoration-solid
} }
/* TODO INLINE /* Classes for static pages */
.ha-maincolumn {
@apply bg-slate-50 mx-auto p-2 md:p-4 desktop:px-16 desktop:py-12 xl:pr-80 text-lg font-serif
} */
.ha-static { .ha-static {
@apply w-full bg-slate-50 py-12 px-12 md:px-16 hyphenate font-serif @apply w-full bg-slate-50 py-12 px-12 md:px-16 hyphenate font-serif
} }
.ha-static h1 { .ha-static h1 {
@apply font-bold text-xl desktop:font-normal desktop:text-4xl mb-6 @apply font-bold text-xl desktop:font-normal desktop:text-4xl mb-6
} }
@@ -193,7 +190,112 @@
@apply inline-block absolute text-right w-8 -left-10 @apply inline-block absolute text-right w-8 -left-10
} }
/* Classes for register pages */
.ha-register {
@apply w-full font-serif numeric-mediaeval
}
.ha-register .ha-register-head,
.ha-register .ha-register-body {
@apply bg-slate-50 pt-9 md:pt-12 px-9 md:px-16
}
.ha-register .ha-register-head {
@apply border-b-2
}
.ha-register .ha-register-head h1 {
@apply font-bold text-xl desktop:font-normal desktop:text-4xl mb-6
}
.ha-register .ha-register-head .ha-register-nav {
@apply font-sans
}
.ha-register .ha-register-head .ha-register-nav a {
@apply inline-block px-1 mr-1 md:mr-3 text-gray-700 hover:text-gray-900
}
.ha-register .ha-register-head .ha-register-nav a:first {
@apply pl-0
}
.ha-register .ha-register-head .ha-register-nav a.active {
@apply border-b-2
}
.ha-register .ha-register-head .ha-register-nav .ha-register-left-nav {
@apply inline-block
}
.ha-register .ha-register-head .ha-register-nav .ha-register-right-nav {
@apply inline-block
}
.ha-register .ha-register-body {
@apply md:pr-96 pb-9 md:pb-12
}
.ha-register .ha-register-body .ha-comment {
@apply block mb-9 md:mb-12
}
.ha-register .ha-register-body .ha-comment a {
@apply underline decoration-dotted hover:decoration-solid
}
.ha-register .ha-register-body .ha-comment .ha-headcomment {
@apply desktop:relative block
}
.ha-register .ha-register-body .ha-comment .ha-subcomment {
@apply desktop:relative block ml-8 mt-2
}
.ha-register .ha-register-body .ha-comment .ha-commenthead {
@apply block
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-lemma {
@apply inline font-bold
}
.ha-register .ha-forschung .ha-register-body .ha-comment .ha-commenthead .ha-lemma {
@apply inline font-normal
}
.ha-register .ha-forschung .ha-register-body .ha-comment {
@apply mb-4 md:mb-6 -indent-4 pl-4
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-letlinks {
@apply inline-block font-normal text-xs md:text-sm leading-snug font-sans text-gray-600 caps-small ml-2
}
.ha-register .ha-neuzeit .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks,
.ha-register .ha-forschung .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks {
@apply desktop:indent-0 desktop:left-[48rem] desktop:top-0 desktop:w-80 desktop:block desktop:absolute desktop:border-l-2 pl-2
}
.ha-register .ha-neuzeit .ha-register-body .ha-subcomment .ha-commenthead .ha-letlinks,
.ha-register .ha-forschung .ha-register-body .ha-headcomment .ha-commenthead .ha-letlinks {
@apply desktop:indent-0 desktop:block desktop:absolute desktop:border-l-2 pl-2 desktop:bg-slate-50 desktop:left-[46rem] desktop:top-0 desktop:w-80
}
.ha-register .ha-register-body .ha-comment .ha-commenthead .ha-letlinks a {
@apply hover:text-gray-900 no-underline
}
/* Classes from .NET */ /* Classes from .NET */
.ha-title {
@apply inline italic
}
.ha-insertedlemma {
@apply inline
}
.ha-serif { .ha-serif {
@apply font-serif @apply font-serif
} }
@@ -286,6 +388,26 @@ body {
hyphens: none; hyphens: none;
} }
.numeric-mediaeval {
font-variant-numeric: oldstyle-nums;
}
.numeric-normal {
font-variant-numeric: normal;
}
.caps-small {
font-variant-caps: all-petite-caps;
}
.caps-normal {
font-variant-caps: normal;
}
.break-inside-avoid {
break-inside: avoid;
}
.ha-menu-arrowsymbol::after { .ha-menu-arrowsymbol::after {
display: inline-block; display: inline-block;
margin-left: 0.2em; margin-left: 0.2em;
@@ -311,4 +433,12 @@ body {
stroke-linejoin:miter; stroke-linejoin:miter;
fill:none; fill:none;
color:#000000; color:#000000;
}
/* Not possible otherwise, overwrites javascript set style values, which cant be defined before render */
@media (max-width: 1190px) {
.ha-register .ha-neuzeit .ha-register-body .ha-subcomment .ha-commenthead .ha-letlinks {
height: auto !important;
overflow: unset !important;
}
} }

View File

@@ -1,4 +1,96 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification const openmenu = function () {
// for details on configuring this project to bundle and minify static web assets. var x = document.getElementById("ha-topnav");
if (x !== null) x.className += " ha-topnav-collapsed";
let oldbutton = document.getElementById("openmenubutton");
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
let newbutton = document.getElementById("closemenubutton");
if (newbutton !== null) newbutton.setAttribute('class', '');
}
const closemenu = function () {
var x = document.getElementById("ha-topnav");
if (x !== null) x.className = "ha-topnav";
let oldbutton = document.getElementById("closemenubutton");
if (oldbutton !== null) oldbutton.setAttribute('class', 'hidden');
let newbutton = document.getElementById("openmenubutton");
if (newbutton !== null) newbutton.setAttribute('class', '');
}
const markactive_startswith = function (element) {
// Marks links as active which target URL starts with the current URL
var all_links = element.getElementsByTagName("a"),
i = 0, len = all_links.length,
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
for (; i < len; i++) {
if (full_path.startsWith(all_links[i].href.toLowerCase())) {
all_links[i].className += " active";
}
}
}
const markactive_exact = function (element) {
var all_links = element.getElementsByTagName("a"),
i = 0, len = all_links.length,
full_path = location.href.split('#')[0].toLowerCase(); //Ignore hashes
for (; i < len; i++) {
if (full_path == all_links[i].href.toLowerCase()) {
all_links[i].className += " active";
}
}
}
const getLineHeight = function (element) {
var temp = document.createElement(element.nodeName), ret;
temp.setAttribute("class", element.className);
temp.innerHTML = "A";
element.parentNode.appendChild(temp);
ret = temp.clientHeight;
temp.parentNode.removeChild(temp);
return ret;
}
const sidebarcollapse = function (selector) {
let backlinkboxes = document.querySelectorAll(selector);
let clientrects = [];
for (element of backlinkboxes) {
clientrects.push([element, element.getBoundingClientRect()]);
}
let lineheight = 1;
if (backlinkboxes.length >= 1) {
lineheight = getLineHeight(backlinkboxes[0]);
}
for (var i = 0; i < clientrects.length; i++) {
if (i < clientrects.length-1) {
if (clientrects[i][1].bottom >= clientrects[i+1][1].top) {
let overlap = clientrects[i][1].bottom - clientrects[i+1][1].top;
let newlength = clientrects[i][1].height - overlap;
let remainder = newlength % lineheight;
newlength = newlength - remainder;
clientrects[i][0].style.height = newlength + 'px';
clientrects[i][0].style.overflowX = "hidden";
clientrects[i][0].style.overflowY = "scroll";
}
}
}
}
window.addEventListener('load', function() {
document.getElementById("openmenubutton").addEventListener('click', openmenu);
document.getElementById("closemenubutton").addEventListener('click', closemenu);
markactive_startswith(document.getElementById("ha-topnav"));
markactive_exact(document.getElementById("ha-register-nav"));
sidebarcollapse(".ha-neuzeit .ha-letlinks");
sidebarcollapse(".ha-forschung .ha-letlinks");
})
// Write your JavaScript code.