A lot of stuff related to parsing; index page input validation

This commit is contained in:
Simon Martens
2023-09-17 15:29:51 +02:00
parent d86d508786
commit b15ce8793c
23 changed files with 294 additions and 60 deletions

View File

@@ -6,10 +6,14 @@ using HaDocument.Models;
namespace HaDocument.Comparers {
public class CommentComparer : IComparer<Comment> {
public int Compare(Comment first, Comment second) {
if (first.Order != second.Order)
return first.Order.CompareTo(second.Order);
if (first.Order.HasValue && second.Order.HasValue)
return first.Order.Value.CompareTo(second.Order.Value);
else if (first.Order.HasValue)
return 1;
else if (second.Order.HasValue)
return -1;
else
return first.Index.CompareTo(second.Index);
return 0;
}
}
}

View File

@@ -5,6 +5,12 @@ VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HaDocumentV6", "HaDocumentV6.csproj", "{2D3B1B5C-5E0B-4050-A102-E44F025511BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaWeb", "..\HaWeb\HaWeb.csproj", "{73B7CCC1-3486-4F6C-807C-F74BF86EE42F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HamannPrinter", "..\HamannPrinter\HamannPrinter.csproj", "{2E4EB350-E88B-40FF-BF0F-E3C98D0C1590}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaXMLReaderV6", "..\HaXMLReaderV6\HaXMLReaderV6.csproj", "{68504F7C-8919-4F92-91AA-3D2952AE942F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +21,18 @@ Global
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D3B1B5C-5E0B-4050-A102-E44F025511BE}.Release|Any CPU.Build.0 = Release|Any CPU
{73B7CCC1-3486-4F6C-807C-F74BF86EE42F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73B7CCC1-3486-4F6C-807C-F74BF86EE42F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73B7CCC1-3486-4F6C-807C-F74BF86EE42F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73B7CCC1-3486-4F6C-807C-F74BF86EE42F}.Release|Any CPU.Build.0 = Release|Any CPU
{2E4EB350-E88B-40FF-BF0F-E3C98D0C1590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E4EB350-E88B-40FF-BF0F-E3C98D0C1590}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E4EB350-E88B-40FF-BF0F-E3C98D0C1590}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E4EB350-E88B-40FF-BF0F-E3C98D0C1590}.Release|Any CPU.Build.0 = Release|Any CPU
{68504F7C-8919-4F92-91AA-3D2952AE942F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68504F7C-8919-4F92-91AA-3D2952AE942F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68504F7C-8919-4F92-91AA-3D2952AE942F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68504F7C-8919-4F92-91AA-3D2952AE942F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -1,5 +1,10 @@
using System.Xml.Linq;
public interface IHaElement {
public interface IHaElement : IComparable {
abstract public string ElementName { get; }
abstract public string[] XPath { get; }
abstract public string ElementRules { get; }
abstract public XElement? XElement { get; }
abstract public bool Searchable { get; }
abstract public string GetKey();
}

View File

@@ -1,13 +1,20 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class App {
public class App : IHaElement {
public string ElementName { get; } = "appDef";
public string[] XPath { get; } = {
"/opus/data/definitions/appDefs/appDef",
"/opus/definitions/appDefs/appDef"
};
public string ElementRules { get; } = "Pfad: /opus/definitions/appDefs. Pflicht-Attribute: index (einmalig), name, category.";
public bool Searchable { get; } = false;
public XElement? XElement { get; }
public string Index { get; } = "";
public string Name { get; } = "";
public string Category { get; } = "";
public XElement? XElement { get; }
public App(
string index,
string name,
@@ -30,5 +37,15 @@ namespace HaDocument.Models {
element
);
}
public string GetKey() => this.Index;
public int CompareTo(object? obj) {
if (obj == null) return 1;
var other = (App)obj;
if (Int32.TryParse(Index, out var thisindex) && Int32.TryParse(other.Index, out var otherindex) )
return thisindex.CompareTo(otherindex);
return String.Compare(this.Index, other.Index);
}
}
}

View File

@@ -1,9 +1,21 @@
using System.Xml.Linq;
namespace HaDocument.Models {
public class Backlink {
public string Href { get; } = "";
public class Backlink : IHaElement {
public string ElementName { get; } = "link";
public string[] XPath { get; } = {
"/opus/data/marginalien/marginal//link",
"/opus/marginalien/marginal//link",
"/opus/kommentare/kommentar//link",
"/opus/data/kommentare/kommentar//link",
"/opus/traditions/letterTradition//link",
"/opus/data/traditions/letterTradition//link",
};
public string ElementRules { get; } = "Pfad: /opus/marginalien, /opus/kommentare, /opus/traditions. Pflicht-Attribute: letter.";
public bool Searchable { get; } = false;
public XElement? XElement { get; } = null;
public string Href { get; } = "";
public string? Letter { get; } = "";
public string? Page { get; } = "";
public string? Line { get; } = "";
@@ -14,13 +26,15 @@ namespace HaDocument.Models {
string? letter,
string? page,
string? line,
string? comment = null
string? comment = null,
XElement? xElement = null
) {
Href = href;
Letter = letter;
Page = page;
Line = line;
Comment = comment;
XElement = xElement;
}
public static Backlink? FromXElement(XElement element) {
@@ -34,7 +48,9 @@ namespace HaDocument.Models {
element.Attribute("subref")?.Value ?? element.Attribute("ref")!.Value,
marginal.Attribute("letter")!.Value,
marginal.Attribute("page")!.Value,
marginal.Attribute("line")!.Value
marginal.Attribute("line")!.Value,
null,
element
);
}
@@ -46,7 +62,8 @@ namespace HaDocument.Models {
null,
null,
null,
subsection.Attribute("id")!.Value
subsection.Attribute("id")!.Value,
element
);
}
@@ -58,11 +75,20 @@ namespace HaDocument.Models {
null,
null,
null,
kommentar.Attribute("id")!.Value
kommentar.Attribute("id")!.Value,
element
);
}
return null;
}
public string GetKey() {
return string.Empty;
}
public int CompareTo(object? obj) {
return 0;
}
}
}

View File

@@ -1,25 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Xml.Linq;
namespace HaDocument.Models {
public class Comment : IHaElement {
public string ElementName { get; } = "link";
public string[] XPath { get; } = {
"/opus/kommentare/kommentar/kommcat/kommentar",
"/opus/data/kommentare/kommentar/kommcat/kommentar",
};
public string ElementRules { get; } = "Pfad: /opus/kommentare/kommentar. Pflicht-Attribute: id (einmalig).";
public bool Searchable { get; } = true;
public XElement? XElement { get; }
namespace HaDocument.Models{
public class Comment {
public string Element { get; } = "";
public string Index { get; } = "";
public string Type { get; } = "";
public string Lemma { get; } = "";
public string Parent { get; } = "";
public int Order { get; } = -1;
public ImmutableSortedDictionary<string, Comment> Kommentare { get; }
public int? Order { get; } = null;
public ImmutableSortedDictionary<string, Comment>? Kommentare { get; }
public Comment(
string entry,
string index,
string type,
string lemma,
int order,
SortedDictionary<string, Comment> subComments,
string parent=""
string? type,
string? lemma,
int? order,
ImmutableSortedDictionary<string, Comment>? subComments,
string? parent = null,
XElement? xelement = null
) {
Element = entry;
Index = index;
@@ -27,10 +38,58 @@ namespace HaDocument.Models{
Lemma = lemma;
Order = order;
Parent = parent;
if (subComments != null)
Kommentare = ImmutableSortedDictionary.ToImmutableSortedDictionary(subComments);
XElement = xelement;
Kommentare = subComments;
}
public String GetKey() => Index;
public int CompareTo(object? obj) {
if (obj == null) return 1;
var other = (Comment)obj;
if (!String.IsNullOrWhiteSpace(Parent) && !String.IsNullOrWhiteSpace(other.Parent) &&
(Parent == other.Parent)) {
if (Order.HasValue && other.Order.HasValue)
return Order.Value!.CompareTo(other.Order.Value);
else if (Order.HasValue)
return 1;
else if (other.Order.HasValue)
return -1;
else
Kommentare = null;
return 0;
}
return String.Compare(Index, other.Index);
}
public Comment? FromXElement(XElement? element) {
if (element == null || !element.HasAttributes || element.IsEmpty) return null;
if (element.Attribute("id")?.Value == null) return null;
var cat = element.Ancestors("kommcat");
if (element.Name == "kommentar")
return new Comment(
element.ToString(),
element.Attribute("id")!.Value,
(cat.Any() ? cat.First().Attribute("value")?.Value : null) ?? element.Attribute("type")?.Value,
element.Element("lemma")?.Value,
element.Attribute("sort")?.Value != null ? (Int32.TryParse(element.Attribute("sort")!.Value, out var s) ? s : null) : null,
element.Elements("subsection").Any() ? element.Elements("subsection").Select(x => FromXElement(x)).ToImmutableSortedDictionary(x => x.Index, y => y) : null,
null,
element
);
else if (element.Name == "subsection") {
if (element.Ancestors("kommentar").Any() || element.Ancestors("kommentar")!.First().Attribute("id")?.Value == null) return null;
return new Comment(
element.ToString(),
element.Attribute("id")!.Value,
(cat.Any() ? cat.First().Attribute("value")?.Value : null) ?? element.Attribute("type")?.Value,
element.Element("lemma")?.Value,
element.Attribute("sort")?.Value != null ? (Int32.TryParse(element.Attribute("sort")!.Value, out var s) ? s : null) : null,
null,
element.Ancestors("kommentar")!.First().Attribute("id")!.Value,
element
);
}
return null;
}
}
}

View File

@@ -31,8 +31,9 @@ namespace HaDocument.Models {
Reference = reference;
}
public static Editreason? FromXElement(XElement element) {
throw new NotImplementedException("We need two Elements for editreason");
public static Editreason? FromXElement(XElement edit, XElement editreason) {
if (edit == null || editreason == null || !edit.HasAttributes || !editreason.HasAttributes) return null;
return null;
}
}
}

View File

@@ -4,6 +4,7 @@ using HaDocument.Models;
using System.Collections.Generic;
using System;
using HaDocument.Comparers;
using System.Collections.Immutable;
namespace HaDocument.Reactors {
class CommentReactor : Reactor {
@@ -149,7 +150,7 @@ namespace HaDocument.Reactors {
Type,
Lemma,
Order,
Subcomments
Subcomments == null ? null : ImmutableSortedDictionary.ToImmutableSortedDictionary(Subcomments, x => x.Key, y => y.Value)
));
Reset();
}

View File

@@ -7,6 +7,7 @@ using HaDocument.Models;
using HaXMLReader.Interfaces;
using System.Collections.Specialized;
using HaWeb.XMLParser;
using System.Collections.Immutable;
namespace HaWeb.Controllers;
@@ -144,8 +145,7 @@ public class IndexController : Controller {
.ThenBy(x => x.Meta.Order)
.ToList()))
.ToList();
List<(string Volume, List<string> Pages)>? availablePages = null;
availablePages = lib.Structure.Where(x => x.Key != "-1").Select(x => (x.Key, x.Value.Select(x => x.Key).ToList())).ToList();
var availablePages = lib.Structure.Where(x => x.Key != "-1").ToDictionary(x => x.Key, y => y.Value.Keys.ToList());
zhvolume = zhvolume == null ? "1" : zhvolume;
var lastletter = lib.MetasByDate.Last();
@@ -156,7 +156,8 @@ public class IndexController : Controller {
"ZH " + HTMLHelpers.ConversionHelpers.ToRoman(Int32.Parse(lastletter.ZH.Volume)) + ", S. " + lastletter.ZH.Page,
pages,
_getAvailablePersons(),
availablePages.OrderBy(x => x.Volume).ToList(),
availablePages,
lib.Letters.Keys.ToList(),
zhvolume,
zhpage,
person

View File

@@ -49,8 +49,14 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
if (doc == null) doc = XDocument.Load(path, LoadOptions.PreserveWhitespace);
// 1. Parse the Document, create search Index
var sw = new Stopwatch();
sw.Start();
if (_xmlService != null)
_xmlService.CreateSearchables(doc);
_xmlService.CreateCollections(doc);
sw.Stop();
Console.WriteLine("Parsed Collections, elapsed: " + sw.ElapsedMilliseconds);
sw.Restart();
// 2. Set ILibrary
try {
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = path, AvailableYearRange = (_startYear, _endYear) }, doc.Root);
@@ -58,6 +64,7 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
if (ModelState != null) ModelState.AddModelError("Error", "Das Dokument konnte nicht geparst werden: " + ex.Message);
return null;
}
Console.WriteLine("Parsed ILib, elapsed: " + sw.ElapsedMilliseconds);
// 3a. Set Available Persons
var persons = Library.Metas.SelectMany(x => x.Value.Senders.Union(x.Value.Receivers)).Distinct();

View File

@@ -1,4 +1,6 @@
namespace HaWeb.Models;
using System.Collections.Immutable;
using HaDocument.Models;
public class IndexViewModel {
@@ -8,15 +10,16 @@ public class IndexViewModel {
public List<(int StartYear, int EndYear)>? AvailableYears { get; private set; }
public string? ActivePerson { get; set; }
public CommentModel? PersonComment { get; set; }
public List<string>? AvailableLetters { get; private set; }
public List<(string Key, string Name)>? AvailablePersons { get; private set; }
public List<(string Volume, List<string> Pages)>? AvailablePages { get; private set; }
public Dictionary<string, List<string>>? AvailablePages { get; private set; }
public string? ActiveVolume { get; private set; }
public string? ActivePage { get; private set; }
public string EndYear { get; private set; }
public string EndPageString { get; private set; }
public IndexViewModel(
List<(int Year, List<BriefeMetaViewModel> LetterList)>? letters,
int activeYear,
@@ -24,7 +27,8 @@ public class IndexViewModel {
string endPageString,
List<(int StartYear, int EndYear)>? availableYears,
List<(string Key, string Name)>? availablePersons,
List<(string Volume, List<string> Pages)>? availablePages,
Dictionary<string, List<string>>? availablePages,
List<string>? availableLetters,
string? activeVolume,
string? activePage,
string? activePerson
@@ -34,6 +38,7 @@ public class IndexViewModel {
Count = letters.Select(x => x.LetterList.Count).Aggregate(0, (x, y) => { x += y; return x; });
else
Count = 0;
AvailableLetters = availableLetters;
ActiveYear = activeYear;
AvailableYears = availableYears;
AvailablePersons = availablePersons;

View File

@@ -5,7 +5,7 @@ using System.Xml.Linq;
public class BackLinkCollection : HaWeb.XMLParser.IXMLCollection {
private static readonly Random _random = new Random();
public string Key { get; } = "backlinks";
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal/link", "/opus/marginalien/marginal/link" };
public string[] xPath { get; } = new string[] { "/opus/data/marginalien/marginal//link", "/opus/marginalien/marginal//link", "/opus/kommentare/kommentar//link", "/opus/data/kommentare/kommentar//link" };
public Func<XElement, string?> GenerateKey { get; } = GetKey;
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = GetDataFields;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = GetLookups;

View File

@@ -1,10 +1,14 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
using HaWeb.Models;
public class EditCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "edits";
public string[] xPath { get; } = new string[] { "/opus/edits/editreason", "/opus/data/edits/editreason" };
public string[] xPath { get; } = new string[] {
"/opus/data/document/letterText//edit",
"/opus/document/letterText//edit",
"/opus/data/traditions/letterTradition//edit",
"/opus/traditions/letterTradition//edit"
};
public Func<XElement, string?> GenerateKey { get; } = GetKey;
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
@@ -13,7 +17,7 @@ public class EditCollection : HaWeb.XMLParser.IXMLCollection {
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
var index = elem.Attribute("ref");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;

View File

@@ -0,0 +1,21 @@
namespace HaWeb.Settings.XMLCollections;
using HaWeb.Models;
using System.Xml.Linq;
public class EditreasonCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "editreasons";
public string[] xPath { get; } = new string[] { "/opus/edits/editreason", "/opus/data/edits/editreason" };
public Func<XElement, string?> GenerateKey { get; } = GetKey;
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;
};
}

View File

@@ -0,0 +1,23 @@
using System.Xml.Linq;
using HaWeb.Models;
public class HandCollection : HaWeb.XMLParser.IXMLCollection {
public string Key { get; } = "hands";
public string[] xPath { get; } = new string[] {
"/opus/data/document/letterText//hand",
"/opus/document/letterText//hand",
"/opus/data/traditions/letterTradition//hand",
"/opus/traditions/letterTradition//hand"
};
public Func<XElement, string?> GenerateKey { get; } = GetKey;
public Func<XElement, IDictionary<string, string>?>? GenerateDataFields { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, ILookup<string, CollectedItem>>?>? GroupingsGeneration { get; } = null;
public Func<IEnumerable<CollectedItem>, IDictionary<string, IEnumerable<CollectedItem>>?>? SortingsGeneration { get; } = null;
public HaWeb.XMLParser.IXMLCollection[]? SubCollections { get; } = null;
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
// TODO IMPLEMENT
return null;
};
}

View File

@@ -5,7 +5,6 @@
ViewData["showCredits"] = "true";
}
<script defer src="/js/index.js" asp-append-version="true"></script>
<div class="ha-index">
@if (Model.Letters != null) {
@@ -77,6 +76,7 @@
<input name="id" type="text" id="ha-gotoletternumber" class="ha-gotoletternumber" />
<button type="submit" id="ha-gotoformsubmit">Nachschlagen</button>
</form>
<div class="mr-2 leading-snug text-base px-1 text-red-700 bg-red-50 text-left h-5 whitespace-nowrap overflow-hidden opacity-0" id="ha-gotoinfo"></div>
</div>
@* ZH Loopkup *@
@@ -97,15 +97,15 @@
<form class="ha-zhform" id="ha-zhform">
<span>Z&hairsp;H Band</span>
<select name="zhvolume" id="ha-zhformvolume">
@foreach (var volume in Model.AvailablePages) {
<option>@volume.Volume</option>
@foreach (var volume in Model.AvailablePages.OrderBy(x => x.Key)) {
<option>@volume.Key</option>
}
</select>
<span>/ </span>
<input name="zhpage" id="ha-zhformpage" type="text" value="@Model.ActivePage" placeholder="Seite"/>
<button id="ha-zhformsubmit" type="submit">Nachschlagen</button>
</form>
<div class="mr-2 leading-snug text-base px-1 text-red-700 bg-red-50 text-left h-5 whitespace-nowrap overflow-hidden opacity-0" id="ha-zhsearchinfo"></div>
</div>
}
@@ -151,3 +151,9 @@
</div>
}
</div>
<script>
var AvailableLetters = new Set(@Html.Raw(Json.Serialize(Model.AvailableLetters)))
var AvailablePages = @Html.Raw(Json.Serialize(Model.AvailablePages))
</script>
<script defer src="/js/index.js" asp-append-version="true"></script>

View File

@@ -18,16 +18,17 @@
<div class="ha-activefilterinfo">
@if (Model.SearchType == SearchType.Letters) {
<span><span class="">Briefe</span>@if(Model.IncludeComments == true) {<span> und Stellenkommentare</span>}, die »@Model.ActiveSearch« enthalten.&emsp;</span><br>
<a class="ha-reversefilter" asp-controller="Index" asp-action="Index">← Briefübersicht</a>
}
@if (Model.SearchType == SearchType.Register) {
<span><span class="">Registereinträge</span>, die »@Model.ActiveSearch« enthalten.&emsp;</span><br>
<a class="ha-reversefilter" asp-controller="Register" asp-action="Allgemein">← Registerübersicht</a><span> / </span>
<a class="ha-reversefilter" asp-controller="Register" asp-action="Allgemein">← Register</a><span></span>
}
@if (Model.SearchType == SearchType.Science) {
<span><span class="">Bibliografische Einträge</span>, die »@Model.ActiveSearch« enthalten.&emsp;</span><br>
<a class="ha-reversefilter" asp-controller="Register" asp-action="Forschung">← Forschungsbibliographie</a><span> / </span>
<a class="ha-reversefilter" asp-controller="Register" asp-action="Forschung">← Forschungsbibliographie</a><span></span>
}
<a class="ha-reversefilter" asp-controller="Index" asp-action="Index">← Briefübersicht</a>
</div>
}
@@ -47,17 +48,17 @@
<div class="ha-alternativesearches">
@if (Model.SearchType != SearchType.Letters) {
<a asp-controller="Suche" asp-action="Briefe" asp-route-search="@Model.ActiveSearch" asp-route-comments="true" >
Stattdessen Briefe / Stellenkommentare nach »@Model.ActiveSearch« durchsuchen&nbsp;→
Briefe & Stellenkommentare nach »@Model.ActiveSearch« durchsuchen&nbsp;→
</a>
}
@if (Model.SearchType != SearchType.Register) {
<a asp-controller="Suche" asp-action="Register" asp-route-search="@Model.ActiveSearch" >
Stattdessen Register nach »@Model.ActiveSearch« durchsuchen&nbsp;→
Register nach »@Model.ActiveSearch« durchsuchen&nbsp;→
</a>
}
@if (Model.SearchType != SearchType.Science) {
<a asp-controller="Suche" asp-action="Science" asp-route-search="@Model.ActiveSearch" >
Stattdessen Forschungsbibliographie nach »@Model.ActiveSearch« durchsuchen&nbsp;→
Forschungsbibliographie nach »@Model.ActiveSearch« durchsuchen&nbsp;→
</a>
}
</div>

View File

@@ -16,7 +16,7 @@ public interface IXMLInteractionService {
public Dictionary<string, SyntaxCheckModel>? GetSCCache();
public void SetSCCache(Dictionary<string, SyntaxCheckModel>? cache);
public XMLParsingState? Collect(List<IFileInfo> Files, Dictionary<string, IXMLRoot>? rootDefs); // XMLFileProvider
public void CreateSearchables(XDocument document); // XMLFileProvider
public void CreateCollections(XDocument document); // XMLFileProvider
public Dictionary<string, SyntaxCheckModel>? Test(XMLParsingState? state, string gitcommit); // XMLFileProvider (optimal), Controller (right now)
// Controller
public List<(CollectedItem Item, List<(string Page, string Line, string Preview, string? Identifier)> Results)>? SearchCollection(string collection, string searchword, IReaderService reader, ILibrary? lib);

View File

@@ -260,7 +260,7 @@ public class XMLInteractionService : IXMLInteractionService {
return res.ToList();
}
public void CreateSearchables(XDocument document) {
public void CreateCollections(XDocument document) {
if (document == null || _RootDefs == null) return;
int numProcs = Environment.ProcessorCount;
int concurrencyLevel = numProcs * 2;

View File

@@ -155,7 +155,7 @@
}
.ha-index .ha-indexbody .ha-filterlist {
@apply hidden md:flex flex-col gap-y-9 pb-4 float-right max-w-lg basis-1/3 min-w-0 shrink
@apply hidden md:flex flex-col gap-y-5 pb-4 float-right max-w-lg basis-1/3 min-w-0 shrink
}
.ha-index .ha-indexbody .ha-filterlist .ha-filtertitle {
@@ -194,6 +194,7 @@
@apply float-right inline-block px-2 border bg-slate-50 disabled:bg-gray-200 border-slate-200 hover:border-black disabled:hover:border-slate-200 disabled:text-gray-600
}
.ha-index .ha-indexbody .ha-filterlist .ha-zhsearchfilter .ha-zhform {
@apply py-1 pl-1 pr-2
}
@@ -214,6 +215,10 @@
@apply px-1
}
.ha-index .ha-indexbody .ha-filterlist .ha-searchfilter {
@apply mb-5
}
.ha-index .ha-indexbody .ha-filterlist .ha-searchfilter .ha-searchform {
@apply py-1 pl-1 pr-2 flex flex-row gap-x-2
}

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +1,49 @@
function encode(e){return e.replace(/[^]/g,function(e){return"&#"+e.charCodeAt(0)+";"})}
const ACTIVATEGOTOFILTER = function(filter, button) {
let f = filter.value;
let gotoinfo = document.getElementById("ha-gotoinfo");
if (f === "") {
if (gotoinfo != null && !gotoinfo.classList.contains("opacity-0")) gotoinfo.classList.add("opacity-0");
button.disabled = true;
return;
}
if (typeof AvailableLetters !== 'undefined' && AvailableLetters != null && !AvailableLetters.has(f)) {
if (gotoinfo != null) {
gotoinfo.classList.remove("opacity-0");
gotoinfo.innerHTML = "Brief Nr. " + encode(f) + " gibt es nicht.";
}
button.disabled = true;
return;
}
if (gotoinfo != null && !gotoinfo.classList.contains("opacity-0")) gotoinfo.classList.add("opacity-0");
button.disabled = false;
}
const ACTIVATEZHSEARCH = function(volume, page, button) {
let vol = volume.options[volume.selectedIndex].value;
let pg = page.value;
let gotoinfo = document.getElementById("ha-zhsearchinfo");
if (pg === "") {
if (gotoinfo != null && !gotoinfo.classList.contains("opacity-0")) gotoinfo.classList.add("opacity-0");
button.disabled = true;
return;
}
if (typeof AvailablePages !== 'undefined' && AvailablePages != null && AvailablePages[vol] != null && !(AvailablePages[vol].indexOf(pg) >= 0)) {
if (gotoinfo != null) {
gotoinfo.classList.remove("opacity-0");
gotoinfo.innerHTML = "ZH Bd. " + encode(vol) + ", S. " + encode(pg) + " gibt es nicht.";
}
button.disabled = true;
return;
}
if (gotoinfo != null && !gotoinfo.classList.contains("opacity-0")) gotoinfo.classList.add("opacity-0");
button.disabled = false;
}

View File

@@ -22,5 +22,5 @@ if (document.getElementById("ha-scrollbutton") !== null) {
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
})
// TODO: workaround, bc window does not recieve scroll events anymore
setInterval(() => scrollFunction(), 2500);
setInterval(() => scrollFunction(), 1500);
}