Moved unused code into Achive

This commit is contained in:
Simon Martens
2022-11-25 19:15:23 +01:00
parent 5cc684550b
commit 02abfb111a
239 changed files with 51948 additions and 1673 deletions

View File

@@ -0,0 +1,180 @@
@page "{id=AT}"
@model HaLive.Pages.BibelstellenModel
@inject IReaderService readerservice;
@inject ILibrary lib;
@functions{
string setAct(string s)
{
if (Model.id.ToString().ToLower() == s.ToLower())
return "is-active";
else
return "";
}
}
@{
// Acquire data
ViewData["Title"] = "Bibelstellenregister";
var at = "AT";
var ap = "AP";
var nt = "NT";
var id = Model.id.ToUpper();
var comments = lib.CommentsByCategory["bibel"].ToLookup(x => x.Index.Substring(0, 2).ToUpper()).Contains(id) ?
lib.CommentsByCategory["bibel"].ToLookup(x => x.Index.Substring(0, 2).ToUpper())[id] : null;
var availableletters = lib.CommentsByCategory["bibel"].ToLookup(x => x.Index.Substring(0, 2).ToUpper());
// Parsing Rules
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> OTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("div", "lemma"))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("div", "title")))
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> CTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.CreateEndElement("div"))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.CreateEndElement("div")))
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> STag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "line", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("br")) )
};
List<(Func<Text, bool>, Action<StringBuilder, Text>)> Text_Funcs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> Whitespace_Funcs = new List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
string handleComment(Comment comm)
{
StringBuilder sb = new StringBuilder();
var rd = readerservice.RequestStringReader(comm.Lemma);
new StandardSubscriber(rd, sb, OTag_Funcs, STag_Funcs, CTag_Funcs, Text_Funcs, Whitespace_Funcs);
sb.Append(HTMLHelpers.CreateElement("div", "lemma", comm.Index));
new LinkBuilder(lib, rd, sb);
rd.Read();
var backlinks = lib.Backlinks.ContainsKey(comm.Index) ? lib.Backlinks[comm.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.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.CreateElement("a", "backlink", "/Briefe/" + let.Autopsic + "#" + blk.Page + "-" + blk.Line));
@* sb.Append(" "); *@
var linkstring = "";
var ZHstring = "";
if (let.ZH != null)
{
ZHstring += HTMLHelpers.ToRoman(Int32.Parse(let.ZH.Volume)) + "&nbsp;";
}
var pglnstring = "";
@* linkstring += "HKB&nbsp;"; *@
linkstring += let.Autopsic;
pglnstring += "&nbsp;(&#8239;" + ZHstring + blk.Page + "/" + blk.Line + "&#8239;)";
linkstring += pglnstring;
sb.Append(linkstring);
if (blk != backlinks.Last())
sb.Append(",&emsp;");
sb.Append(HTMLHelpers.CreateEndElement("a"));
}
}
sb.Append(HTMLHelpers.CreateEndElement("div"));
}
sb.Append(HTMLHelpers.CreateEndElement("div"));
rd = readerservice.RequestStringReader(comm.Entry);
new StandardSubscriber(rd, sb, OTag_Funcs, STag_Funcs, CTag_Funcs, Text_Funcs, Whitespace_Funcs);
new LinkBuilder(lib, rd, sb);
rd.Read();
return sb.ToString();
}
}
<div class="mainhead row">
<!-- + sticky-top if sticky -->
<!--Sticky grey space on top of header -->
<div class="col">
<div class="widehead">
<div class="flexcol">
<div style="align-self: flex-end" class="printbutton">
<a class="" href="/pdf/HKB_Bibelstellen-Register.pdf">
PDF
</a>
</div>
<div class="flexrow" style="margin-bottom:-10px; align-items: last baseline;">
<div class="heading">
@ViewData["Title"]
</div>
</div>
<div class="alphabet">
<span><a class="invlink @setAct(at)" href="/Supplementa/Bibelstellen/AT">Altes Testament</a> &emsp;</span>
<span><a class="invlink @setAct(ap)" href="/Supplementa/Bibelstellen/AP">Apogryphen</a> &emsp;</span>
<span><a class="invlink @setAct(nt)" href="/Supplementa/Bibelstellen/NT">Neues Testament</a> &emsp;</span>
</div>
</div>
</div>
</div>
</div>
<div class="row no-gutters">
<div class="col">
<div class="registerbox">
<div class="text">
@foreach (var comm in comments.OrderBy(x => x.Order))
{
<div class="comment">
@Html.Raw(handleComment(comm))
@if (comm.Kommentare != null)
{
@foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Lemma.Length).ThenBy(x => x.Value.Lemma))
{
<div class="subsection">
@Html.Raw(handleComment(subcomm.Value))
</div>
}
}
</div>
}
</div>
</div>
</div>
</div>
@section Scripts {
<script>
// The function actually applying the offset
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 280);
}
}
// Captures click events of all <a> elements with href starting with #
$(document).on('click', 'a[href^="#"]', function (event) {
// Click events are captured before hashchanges. Timeout
// causes offsetAnchor to be called after the page jump.
window.setTimeout(function () {
offsetAnchor();
}, 0);
});
// Set the offset when entering page with hash present in the url
window.setTimeout(offsetAnchor, 0);
$("#" + window.location.hash.substr(1)).prepend("<div class=\"selected\">☛</div> ");
</script>
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using HaDocument.Interfaces;
namespace HaLive.Pages
{
public class BibelstellenModel : PageModel
{
private ILibrary _lib;
[BindProperty(SupportsGet = true)]
public string id { get; set; }
public BibelstellenModel(ILibrary lib) {
_lib = lib;
}
public IActionResult OnGet()
{
if (!_lib.CommentsByCategory["bibel"].ToLookup(x => x.Index.Substring(0,2).ToUpper()).Contains(id.ToUpper())) {
Response.StatusCode = 404;
return RedirectToPage("/Error");
}
return Page();
}
}
}

View File

@@ -0,0 +1,210 @@
@page "{id=A}"
@model HaLive.Pages.ForschungModel
@inject IReaderService readerservice;
@inject ILibrary lib;
@functions{
string setAct(string s) {
if (Model.id.ToString().ToLower() == s.ToLower())
return "is-active";
else
return "";
}
}
@{
// Acquire data
ViewData["Title"] = "Forschungsbibliographie";
var id = Model.id.ToUpper();
var comments = Model.SelectComments();
var availableletters = lib.CommentsByCategoryLetter["forschung"].OrderBy(x => x.Key);
// Parsing Rules
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> OTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("div", "lemma"))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("div", "title"))),
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("div", "title")))
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> CTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "lemma", (sb, tag) => sb.Append(HTMLHelpers.CreateEndElement("div"))),
( x => x.Name == "title", (sb, tag) => sb.Append(HTMLHelpers.CreateEndElement("div"))),
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.CreateEndElement("div")))
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> STag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "line", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("br")) )
};
List<(Func<Text, bool>, Action<StringBuilder, Text>)> Text_Funcs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> Whitespace_Funcs = new List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
string handleComment(Comment comm) {
StringBuilder sb = new StringBuilder();
var rd = readerservice.RequestStringReader(comm.Lemma);
new StandardSubscriber(rd, sb, OTag_Funcs, STag_Funcs, CTag_Funcs, Text_Funcs, Whitespace_Funcs);
sb.Append(HTMLHelpers.CreateElement("div", "lemma", comm.Index));
new LinkBuilder(lib, rd, sb);
rd.Read();
var backlinks = lib.Backlinks.ContainsKey(comm.Index) ? lib.Backlinks[comm.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.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.CreateElement("a", "backlink", "/Briefe/" + let.Autopsic + "#" + blk.Page + "-" + blk.Line));
@* sb.Append(" "); *@
var linkstring = "";
var ZHstring = "";
var pglnstring= "";
@* linkstring += "HKB&nbsp;"; *@
linkstring += let.Autopsic;
pglnstring += "&nbsp;(&#8239;" + blk.Page + "/" + blk.Line + "&#8239;)";
linkstring += pglnstring;
@* if (let.ZH != null) {
ZHstring += HTMLHelpers.CreateElement("span", "autopsic", "");
ZHstring += "ZH&nbsp;" + HTMLHelpers.ToRoman(Int32.Parse(let.ZH.Volume)) ;
ZHstring += HTMLHelpers.CreateEndElement("span");
linkstring += "&nbsp;" + ZHstring;
} *@
sb.Append(linkstring);
@* sb.Append("ZH" + "&nbsp;" +
HTMLHelpers.ToRoman(Int32.Parse(let.Volume)) +
"&nbsp;" +
blk.Page +
"/" +
blk.Line +
"&nbsp;(" +
let.Autopsic +
")"
); *@
if (blk != backlinks.Last())
sb.Append(",&emsp;");
sb.Append(HTMLHelpers.CreateEndElement("a"));
}
}
sb.Append(HTMLHelpers.CreateEndElement("div"));
}
sb.Append(HTMLHelpers.CreateEndElement("div"));
rd = readerservice.RequestStringReader(comm.Entry);
new StandardSubscriber(rd, sb, OTag_Funcs, STag_Funcs, CTag_Funcs, Text_Funcs, Whitespace_Funcs);
new LinkBuilder(lib, rd, sb);
rd.Read();
return sb.ToString();
}
}
<div class="mainhead row"><!-- + sticky-top if sticky -->
<!--Sticky grey space on top of header -->
<div class="col">
<div class="widehead">
<div class="flexcol">
<div style="align-self: flex-end" class="printbutton">
<a class="" href="/pdf/HKB_Forschungsbibliographie.pdf">
PDF
</a>
</div>
<div class="flexrow" style="margin-bottom:-30px; align-items: last baseline;">
<div class="heading">
@ViewData["Title"]
</div>
<form>
<div class="form-inline hformbox">
<input type="search" class="form-control hform" asp-for="search" placeholder="Suchbegriff" />
<input type="submit" class="form-control hform" value="Suche in der Bibliographie" />
</div>
</form>
</div>
<div class="alphabet">
@if (String.IsNullOrWhiteSpace(Model.search))
{
<br/>
@foreach (var entry in availableletters)
{
<span><a class="invlink @setAct(entry.Key)" href="/Supplementa/Forschung/@entry.Key">@entry.Key</a> &emsp;</span>
}
<span class="caps">&emsp;<a class="@setAct("editionen")" href="/Supplementa/Forschung/editionen">Editionen</a></span>
}
else
{
<br/>
<span>Einträge, die &#x00BB;@Model.search&#x00AB; enthalten. <a href="/Supplementa/Forschung/A" class="hlink">&emsp;&emsp;&#x2190;&nbsp;Zurück</a></span>
@if (Model.maxSearch)
{
<br/><br/>
<span class="searchwarning">Zu viele Treffer. Die Anzeige wurde auf die ersten 150 Suchergebnisse beschränkt.</span>
}
}
</div>
</div>
</div>
</div>
</div>
<div class="row no-gutters">
<div class="col">
<div class="registerbox research">
<div class="text">
@if(comments == null || comments.Count() == 0)
{
@if(!String.IsNullOrWhiteSpace(Model.search))
{
<span class="searchwarning">Keine Einträge gefunden.</span>
}
}
@foreach (var comm in comments)
{
<div class="comment hangingindent">
@Html.Raw(handleComment(comm))
@if(comm.Kommentare != null)
{
@foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order))
{
<div class="subsection hangingindent">
@Html.Raw(handleComment(subcomm.Value))
</div>
}
}
</div>
}
</div>
</div>
</div>
</div>
@section Scripts {
<script>
// The function actually applying the offset
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 240);
}
}
// Captures click events of all <a> elements with href starting with #
$(document).on('click', 'a[href^="#"]', function(event) {
// Click events are captured before hashchanges. Timeout
// causes offsetAnchor to be called after the page jump.
window.setTimeout(function() {
offsetAnchor();
}, 0);
});
// Set the offset when entering page with hash present in the url
window.setTimeout(offsetAnchor, 0);
$( "#" + window.location.hash.substr(1) ).prepend("<div class=\"selected\">☛</div> ");
</script>
}

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using HaDocument.Interfaces;
using HaDocument.Models;
using System.Collections.Concurrent;
using HaXMLReader.Interfaces;
namespace HaLive.Pages
{
public class ForschungModel : PageModel
{
private ILibrary _lib;
private IReaderService _readerService;
[BindProperty(SupportsGet = true)]
public string search { get; set; } = "";
public bool maxSearch = false;
[BindProperty(SupportsGet = true)]
public string id { get; set; }
public ForschungModel(ILibrary lib, IReaderService readerService) {
_lib = lib;
_readerService = readerService;
}
public IActionResult OnGet()
{
id = id.ToUpper();
if (!_lib.CommentsByCategoryLetter["forschung"].Contains(id) && id != "EDITIONEN") {
Response.StatusCode = 404;
return RedirectToPage("/Error");
}
return Page();
}
public IOrderedEnumerable<Comment> SelectComments() {
if (!String.IsNullOrWhiteSpace(search))
return Search(_lib.CommentsByCategory["forschung"]).OrderBy(x => x.Index);
if (id == "EDITIONEN")
return _lib.CommentsByCategory["editionen"].OrderBy(x => x.Index);
return _lib.CommentsByCategoryLetter["forschung"][id].OrderBy(x => x.Index);
}
private IEnumerable<Comment> Search(IEnumerable<Comment> all) {
var ret = new ConcurrentBag<Comment>();
var cnt = 0;
Parallel.ForEach (all, (comm, state) => {
if (cnt > 150) {
maxSearch = true;
state.Break();
}
if (SearchInComm(comm)) {
ret.Add(comm);
cnt++;
}
});
return ret;
}
private bool SearchInComm(Comment comment) {
var found = false;
var x = new RegisterSearch(comment, _readerService.RequestStringReader(comment.Entry), search);
found = x.Act();
if (!found) {
x = new RegisterSearch(comment, _readerService.RequestStringReader(comment.Lemma), search);
found = x.Act();
}
if (comment.Kommentare != null)
foreach (var sub in comment.Kommentare) {
if (!found) {
found = SearchInComm(sub.Value);
}
else break;
}
return found;
}
}
}

View File

@@ -0,0 +1,203 @@
@page "{id=A}"
@model HaLive.Pages.RegisterModel
@inject IReaderService readerservice;
@inject ILibrary lib;
@functions{
string setAct(string s) {
if (Model.id.ToString().ToLower() == s.ToLower())
return "is-active";
else
return "";
}
}
@{
// Acquire data
ViewData["Title"] = "Register";
var id = Model.id.ToUpper();
var comments = Model.SelectComments(lib);
var availableletters = lib.CommentsByCategoryLetter["neuzeit"].OrderBy(x => x.Key);
// Parsing Rules
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> OTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("div", "titel")))
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> CTag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "titel", (sb, tag) => sb.Append(HTMLHelpers.CreateEndElement("div")))
};
List<(Func<Tag, bool>, Action<StringBuilder, Tag>)> STag_Funcs = new List<(Func<Tag, bool>, Action<StringBuilder, Tag>)>() {
( x => x.Name == "line", (sb, tag) => sb.Append(HTMLHelpers.CreateElement("br")) )
};
List<(Func<Text, bool>, Action<StringBuilder, Text>)> Text_Funcs = new List<(Func<Text, bool>, Action<StringBuilder, Text>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)> Whitespace_Funcs = new List<(Func<Whitespace, bool>, Action<StringBuilder, Whitespace>)>() {
( x => true, ( sb, txt ) => sb.Append(txt.Value) )
};
string handleComment(Comment comm) {
StringBuilder sb = new StringBuilder();
var rd = readerservice.RequestStringReader(comm.Lemma);
new StandardSubscriber(rd, sb, OTag_Funcs, STag_Funcs, CTag_Funcs, Text_Funcs, Whitespace_Funcs);
sb.Append(HTMLHelpers.CreateElement("div", "lemma", comm.Index));
new LinkBuilder(lib, rd, sb);
rd.Read();
var backlinks = lib.Backlinks.ContainsKey(comm.Index) ? lib.Backlinks[comm.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.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.CreateElement("a", "backlink", "/Briefe/" + let.Autopsic + "#" + blk.Page + "-" + blk.Line));
@* sb.Append(" "); *@
var linkstring = "";
var ZHstring = "";
if (let.ZH != null)
{
ZHstring += HTMLHelpers.ToRoman(Int32.Parse(let.ZH.Volume)) + "&nbsp;";
}
var pglnstring= "";
@* linkstring += "HKB&nbsp;"; *@
linkstring += let.Autopsic;
pglnstring += "&nbsp;(&#8239;" + ZHstring + blk.Page + "/" + blk.Line + "&#8239;)";
linkstring += pglnstring;
sb.Append(linkstring);
@* sb.Append("ZH" + "&nbsp;" +
HTMLHelpers.ToRoman(Int32.Parse(let.Volume)) +
"&nbsp;" +
blk.Page +
"/" +
blk.Line +
"&nbsp;(" +
let.Autopsic +
")"
); *@
if (blk != backlinks.Last())
sb.Append(",&emsp;");
sb.Append(HTMLHelpers.CreateEndElement("a"));
}
}
sb.Append(HTMLHelpers.CreateEndElement("div"));
}
sb.Append(HTMLHelpers.CreateEndElement("div"));
rd = readerservice.RequestStringReader(comm.Entry);
new StandardSubscriber(rd, sb, OTag_Funcs, STag_Funcs, CTag_Funcs, Text_Funcs, Whitespace_Funcs);
new LinkBuilder(lib, rd, sb);
rd.Read();
return sb.ToString();
}
}
<div class="mainhead row no-gutters"><!-- + sticky-top if sticky -->
<!--Sticky grey space on top of header -->
<div class="col">
<div class="widehead">
<div class="flexcol">
<div style="align-self: flex-end" class="printbutton">
<a class="" href="/pdf/HKB_Register.pdf">
PDF
</a>
</div>
<div class="flexrow" style="margin-bottom:-30px; align-items: last baseline;">
<div class="heading">
Register
</div>
<form>
<div class="form-inline hformbox">
<input type="search" class="form-control hform" asp-for="search" placeholder="Suchbegriff" />
<input type="submit" class="form-control hform" value="Suche im Register" />
</div>
</form>
</div>
<div class="alphabet">
@if (String.IsNullOrWhiteSpace(Model.search))
{
<br/>
@foreach (var entry in availableletters)
{
<span><a class="invlink @setAct(entry.Key)" href="/Supplementa/Register/@entry.Key">@entry.Key</a> &emsp;</span>
}
}
else
{
<br/>
<span>Einträge, die &#x00BB;@Model.search&#x00AB; enthalten. <a href="/Supplementa/Register/A" class="hlink">&emsp;&emsp;&#x2190;&nbsp;Zurück</a></span>
@if (Model.maxSearch)
{
<br/><br/>
<span class="searchwarning">Zu viele Treffer. Die Anzeige wurde auf die ersten 150 Suchergebnisse beschränkt.</span>
}
}
</div>
</div>
</div>
</div>
</div>
<div class="row no-gutters">
<div class="col">
<div class="registerbox">
<div class="text">
@if(comments == null || comments.Count() == 0)
{
@if(!String.IsNullOrWhiteSpace(Model.search))
{
<span class="searchwarning">Keine Einträge gefunden.</span>
}
}
@foreach (var comm in comments)
{
<div class="comment">
@Html.Raw(handleComment(comm))
@if(comm.Kommentare != null)
{
@foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order))
{
<div class="subsection">
@Html.Raw(handleComment(subcomm.Value))
</div>
}
}
</div>
}
</div>
</div>
</div>
</div>
@section Scripts {
<script>
// The function actually applying the offset
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 280);
}
}
// Captures click events of all <a> elements with href starting with #
$(document).on('click', 'a[href^="#"]', function(event) {
// Click events are captured before hashchanges. Timeout
// causes offsetAnchor to be called after the page jump.
window.setTimeout(function() {
offsetAnchor();
}, 0);
});
// Set the offset when entering page with hash present in the url
window.setTimeout(offsetAnchor, 0);
$( "#" + window.location.hash.substr(1) ).prepend("<div class=\"selected\">☛</div> ");
</script>
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using HaDocument.Interfaces;
using HaDocument.Models;
using System.Collections.Concurrent;
using HaXMLReader.Interfaces;
namespace HaLive.Pages
{
public class RegisterModel : PageModel
{
private ILibrary _lib;
private IReaderService _readerService;
[BindProperty(SupportsGet = true)]
public string search { get; set; } = "";
public bool maxSearch = false;
[BindProperty(SupportsGet = true)]
public string id { get; set; }
public RegisterModel(ILibrary lib, IReaderService readerservice) {
_lib = lib;
_readerService = readerservice;
}
public IActionResult OnGet()
{
id = id.ToUpper();
if (!_lib.CommentsByCategoryLetter["neuzeit"].Contains(id)) {
Response.StatusCode = 404;
return RedirectToPage("/Error");
}
return Page();
}
public IOrderedEnumerable<Comment> SelectComments(ILibrary lib) {
if (!String.IsNullOrWhiteSpace(search))
return Search(lib.CommentsByCategoryLetter["neuzeit"].SelectMany(x => x)).OrderBy(x => x.Index);
return lib.CommentsByCategoryLetter["neuzeit"].Contains(id) ? lib.CommentsByCategoryLetter["neuzeit"][id].OrderBy(x => x.Index) : null;
}
private IEnumerable<Comment> Search(IEnumerable<Comment> all) {
var ret = new ConcurrentBag<Comment>();
var cnt = 0;
Parallel.ForEach (all, (comm, state) => {
if (cnt > 150) {
maxSearch = true;
state.Break();
}
if (SearchInComm(comm)) {
ret.Add(comm);
cnt++;
}
});
return ret;
}
private bool SearchInComm(Comment comment) {
var found = false;
var x = new RegisterSearch(comment, _readerService.RequestStringReader(comment.Entry), search);
found = x.Act();
if (!found) {
x = new RegisterSearch(comment, _readerService.RequestStringReader(comment.Lemma), search);
found = x.Act();
}
if (comment.Kommentare != null)
foreach (var sub in comment.Kommentare) {
if (!found) {
found = SearchInComm(sub.Value);
}
else break;
}
return found;
}
}
}

View File

@@ -0,0 +1,18 @@
<environment include="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment exclude="Development">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha256-F6h55Qw6sweK+t7SiOJX+2bpSAa3b/fnlrVCJvmEj1A=">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha256-9GycpJnliUjJDVDqP0UEu/bsm9U+3dnQUH8+3W10vkY=">
</script>
</environment>