mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Chnaged README, worked on index strategy
This commit is contained in:
@@ -25,7 +25,7 @@ namespace HaDocument.Interfaces {
|
|||||||
Lookup<string, Marginal> MarginalsByLetter { get; }
|
Lookup<string, Marginal> MarginalsByLetter { get; }
|
||||||
Lookup<string, Editreason> EditreasonsByLetter { get; }
|
Lookup<string, Editreason> EditreasonsByLetter { get; }
|
||||||
ImmutableSortedSet<Meta> MetasByDate { get; }
|
ImmutableSortedSet<Meta> MetasByDate { get; }
|
||||||
ILookup<string, Meta> MetasByYear { get; }
|
ILookup<int, Meta> MetasByYear { get; }
|
||||||
ImmutableDictionary<string, Comment> SubCommentsByID { get; }
|
ImmutableDictionary<string, Comment> SubCommentsByID { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
using HaDocument.Models;
|
using HaDocument.Models;
|
||||||
using HaDocument.Comparers;
|
using HaDocument.Comparers;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Collections.Specialized;
|
||||||
namespace HaDocument.Models
|
namespace HaDocument.Models
|
||||||
{
|
{
|
||||||
public class Library : ILibrary
|
public class Library : ILibrary
|
||||||
@@ -40,7 +40,7 @@ namespace HaDocument.Models
|
|||||||
// Auswählen von Briefen nach autoptischer Numemr und in zeitlich sortierter Reihenfolge.
|
// Auswählen von Briefen nach autoptischer Numemr und in zeitlich sortierter Reihenfolge.
|
||||||
public ImmutableSortedSet<Meta> MetasByDate { get; }
|
public ImmutableSortedSet<Meta> MetasByDate { get; }
|
||||||
// Auswählen von Briefen nach dem Jahr, sortiert nach Datum
|
// Auswählen von Briefen nach dem Jahr, sortiert nach Datum
|
||||||
public ILookup<string, Meta> MetasByYear { get; }
|
public ILookup<int, Meta> MetasByYear { get; }
|
||||||
|
|
||||||
|
|
||||||
public Library(
|
public Library(
|
||||||
@@ -91,7 +91,7 @@ namespace HaDocument.Models
|
|||||||
MarginalsByLetter = (Lookup<string, Marginal>)Marginals.Values.ToLookup(x => x.Letter);
|
MarginalsByLetter = (Lookup<string, Marginal>)Marginals.Values.ToLookup(x => x.Letter);
|
||||||
EditreasonsByLetter = (Lookup<string, Editreason>)Editreasons.Values.ToLookup(x => x.Letter);
|
EditreasonsByLetter = (Lookup<string, Editreason>)Editreasons.Values.ToLookup(x => x.Letter);
|
||||||
MetasByDate = Metas.Values.ToImmutableSortedSet<Meta>(new DefaultComparer());
|
MetasByDate = Metas.Values.ToImmutableSortedSet<Meta>(new DefaultComparer());
|
||||||
MetasByYear = Metas.Values.ToLookup(x => x.Sort.Year.ToString());
|
MetasByYear = Metas.Values.ToLookup(x => x.Sort.Year);
|
||||||
|
|
||||||
var tempbuilder = ImmutableDictionary.CreateBuilder<string, Comment>();
|
var tempbuilder = ImmutableDictionary.CreateBuilder<string, Comment>();
|
||||||
foreach (var comm in Comments)
|
foreach (var comm in Comments)
|
||||||
|
|||||||
@@ -1,18 +1,58 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using HaWeb.Models;
|
using HaWeb.Models;
|
||||||
|
using HaWeb.FileHelpers;
|
||||||
|
using HaDocument.Interfaces;
|
||||||
|
using HaDocument.Models;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
|
||||||
namespace HaWeb.Controllers;
|
namespace HaWeb.Controllers;
|
||||||
|
|
||||||
public class SucheController : Controller {
|
public class SucheController : Controller {
|
||||||
|
private IHaDocumentWrappper _lib;
|
||||||
|
private int _lettersForPage;
|
||||||
|
|
||||||
|
public SucheController(IHaDocumentWrappper lib, IConfiguration config) {
|
||||||
|
_lib = lib;
|
||||||
|
_lettersForPage = config.GetValue<int>("LettersOnPage");
|
||||||
|
}
|
||||||
|
|
||||||
[Route("Suche")]
|
[Route("Suche")]
|
||||||
|
// Filter, Order By Year, Paginate, Order By Date and by Order, Parse
|
||||||
public IActionResult Index() {
|
public IActionResult Index() {
|
||||||
|
var lib = _lib.GetLibrary();
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
private BriefeMetaViewModel generateMetaViewModel(ILibrary lib, Meta meta) {
|
||||||
public IActionResult Error() {
|
var hasMarginals = lib.MarginalsByLetter.Contains(meta.Index) ? true : false;
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
var senders = meta.Senders.Select(x => lib.Persons[x].Name) ?? new List<string>();
|
||||||
|
var recivers = meta.Receivers.Select(x => lib.Persons[x].Name) ?? new List<string>();
|
||||||
|
var zhstring = meta.ZH != null ? HaWeb.HTMLHelpers.LetterHelpers.CreateZHString(meta) : null;
|
||||||
|
return new BriefeMetaViewModel(meta, hasMarginals, false) {
|
||||||
|
ParsedZHString = zhstring,
|
||||||
|
ParsedSenders = HTMLHelpers.StringHelpers.GetEnumerationString(senders),
|
||||||
|
ParsedReceivers = HTMLHelpers.StringHelpers.GetEnumerationString(recivers)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<(int StartYear, int EndYear)>? Paginate(ILookup<int, List<Meta>>? letters) {
|
||||||
|
if (letters == null || !letters.Any()) return null;
|
||||||
|
var orderedl = letters.OrderBy(x => x.Key);
|
||||||
|
List<(int StartYear, int EndYear)>? res = null;
|
||||||
|
int startyear = 0;
|
||||||
|
int count = 0;
|
||||||
|
foreach (var letterlist in orderedl) {
|
||||||
|
count += letterlist.Count();
|
||||||
|
if (count == 0) {
|
||||||
|
startyear = letterlist.Key;
|
||||||
|
}
|
||||||
|
if (count >= _lettersForPage) {
|
||||||
|
if (res == null) res = new List<(int StartYear, int EndYear)>();
|
||||||
|
res.Add((startyear, letterlist.Key));
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,32 +7,36 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
|
|||||||
private ILibrary Library;
|
private ILibrary Library;
|
||||||
private IXMLProvider _xmlProvider;
|
private IXMLProvider _xmlProvider;
|
||||||
|
|
||||||
private int _startYear;
|
public int StartYear { get; private set; }
|
||||||
private int _endYear;
|
public int EndYear { get; private set; }
|
||||||
|
|
||||||
public HaDocumentWrapper(IXMLProvider xmlProvider, IConfiguration configuration) {
|
public HaDocumentWrapper(IXMLProvider xmlProvider, IConfiguration configuration) {
|
||||||
_xmlProvider = xmlProvider;
|
_xmlProvider = xmlProvider;
|
||||||
|
StartYear = configuration.GetValue<int>("AvailableStartYear");
|
||||||
_startYear = configuration.GetValue<int>("AvailableStartYear");
|
EndYear = configuration.GetValue<int>("AvailableEndYear");
|
||||||
_endYear = configuration.GetValue<int>("AvailableEndYear");
|
|
||||||
var filelist = xmlProvider.GetHamannFiles();
|
var filelist = xmlProvider.GetHamannFiles();
|
||||||
if (filelist != null && filelist.Any()) {
|
if (filelist != null && filelist.Any()) {
|
||||||
_AutoLoad(filelist);
|
_AutoLoad(filelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use Fallback library
|
// Use Fallback library
|
||||||
if (Library == null)
|
if (Library == null) {
|
||||||
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { AvailableYearRange = (_startYear, _endYear) });
|
var options = new HaWeb.Settings.HaDocumentOptions();
|
||||||
|
if (SetLibrary(options.HamannXMLFilePath) == null) {
|
||||||
|
throw new Exception("Die Fallback Hamann.xml unter " + options.HamannXMLFilePath + " kann nicht geparst werden.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILibrary ResetLibrary() {
|
public ILibrary ResetLibrary() {
|
||||||
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { AvailableYearRange = (_startYear, _endYear) });
|
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { AvailableYearRange = (StartYear, EndYear) });
|
||||||
return Library;
|
return Library;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILibrary? SetLibrary(string filepath, ModelStateDictionary? ModelState = null) {
|
public ILibrary? SetLibrary(string filepath, ModelStateDictionary? ModelState = null) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = filepath, AvailableYearRange = (_startYear, _endYear) });
|
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = filepath, AvailableYearRange = (StartYear, EndYear) });
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
if (ModelState != null) ModelState.AddModelError("Error", "Das Dokument konnte nicht geparst werden: " + ex.Message);
|
if (ModelState != null) ModelState.AddModelError("Error", "Das Dokument konnte nicht geparst werden: " + ex.Message);
|
||||||
|
|||||||
15
HaWeb/Models/SucheViewModel.cs
Normal file
15
HaWeb/Models/SucheViewModel.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace HaWeb.Models;
|
||||||
|
|
||||||
|
public class SucheViewModel {
|
||||||
|
public List<(int Year, List<BriefeMetaViewModel> LetterList)> Letters { get; private set; }
|
||||||
|
public int Count { get; private set; }
|
||||||
|
public int ActiveYears { get; private set; }
|
||||||
|
public List<(int StartYear, int EndYear)> AvailableYears { get; private set; }
|
||||||
|
|
||||||
|
public SucheViewModel(List<(int Year, List<BriefeMetaViewModel> LetterList)> letters, int count, int activeYears, List<(int StartYear, int EndYear)> availableYears) {
|
||||||
|
Letters = letters;
|
||||||
|
Count = count;
|
||||||
|
ActiveYears = activeYears;
|
||||||
|
AvailableYears = availableYears;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,8 @@ Don't forget to place a valid `Hamann.xml`-File in the root of the build to prov
|
|||||||
|
|
||||||
Run
|
Run
|
||||||
|
|
||||||
`dotnet watch --project Tailwind.csproj build -- Tailwind.csproj` and
|
`dotnet watch --verbose --project Tailwind.csproj build -- Tailwind.csproj` and
|
||||||
`dotnet watch --project HaWeb.csproj -- run --project HaWeb.csproj`
|
`dotnet watch --verbose --project HaWeb.csproj -- run --project HaWeb.csproj`
|
||||||
|
|
||||||
in two terminal windows to watch for specific file changes in .css / .js / .cshtml / .json / .cs files and to rebuild the css-Files and the app automatically on change.
|
in two terminal windows to watch for specific file changes in .css / .js / .cshtml / .json / .cs files and to rebuild the css-Files and the app automatically on change.
|
||||||
Recommended vscode plugins include the XML Tools, Prettier, c#, Nuget Gallery, Tailwind CSS IntelliSense & TODO Tree.
|
Recommended vscode plugins include the XML Tools, Prettier, c#, Nuget Gallery, Tailwind CSS IntelliSense & TODO Tree.
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
@model UploadViewModel;
|
@model UploadViewModel;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Upload & Veröffentlichen";
|
||||||
|
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe, Hg. v. Leonard Keidel und Janina Reibold. Durchsuchbare Online-Ausgabe der Briefe von und an Johann Georg Hamann.";
|
||||||
|
ViewData["showCredits"] = "false";
|
||||||
|
}
|
||||||
|
|
||||||
<div class="ha-adminuploadfields" id="ha-adminuploadfields">
|
<div class="ha-adminuploadfields" id="ha-adminuploadfields">
|
||||||
@foreach (var item in Model.AvailableRoots!.OrderBy(x => x.Type)) {
|
@foreach (var item in Model.AvailableRoots!.OrderBy(x => x.Type)) {
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
if (Model.MinWidthTrad)
|
if (Model.MinWidthTrad)
|
||||||
minwidthtrads = "ha-minwidth";
|
minwidthtrads = "ha-minwidth";
|
||||||
}
|
}
|
||||||
|
@* No JavaScript Settings *@
|
||||||
|
<noscript>
|
||||||
|
@* TODO *@
|
||||||
|
</noscript>
|
||||||
|
|
||||||
<div class="ha-letterheader">
|
<div class="ha-letterheader">
|
||||||
@await Html.PartialAsync("/Views/Shared/_LetterHead.cshtml", Model.MetaData)
|
@await Html.PartialAsync("/Views/Shared/_LetterHead.cshtml", Model.MetaData)
|
||||||
<div class="ha-letterheadernav">
|
<div class="ha-letterheadernav">
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
<div class="ha-static">
|
<div class="ha-static">
|
||||||
<div class="md:pr-80">
|
<div class="md:pr-80">
|
||||||
<h1>Kontakt</h1>
|
<h1>Kontakt</h1>
|
||||||
<table>
|
<table class="!w-full">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Theodor Springmann Stiftung <br>
|
<td class="!pl-0">Theodor Springmann Stiftung <br>
|
||||||
Dr. Janina Reibold <br>
|
Dr. Janina Reibold <br>
|
||||||
Hirschgasse 2 <br>
|
Hirschgasse 2 <br>
|
||||||
69120 Heidelberg <br>
|
69120 Heidelberg <br>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
@{
|
@model SucheViewModel;
|
||||||
|
@{
|
||||||
ViewData["Title"] = "Briefauswahl & Suche";
|
ViewData["Title"] = "Briefauswahl & Suche";
|
||||||
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe, Hg. v. Leonard Keidel und Janina Reibold. Durchsuchbare Online-Ausgabe der Briefe von und an Johann Georg Hamann.";
|
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe, Hg. v. Leonard Keidel und Janina Reibold. Durchsuchbare Online-Ausgabe der Briefe von und an Johann Georg Hamann.";
|
||||||
ViewData["showCredits"] = "true";
|
ViewData["showCredits"] = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<div class="ha-search">
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -17,5 +17,6 @@
|
|||||||
"StoredFilePathWindows": "D:/test/",
|
"StoredFilePathWindows": "D:/test/",
|
||||||
"FileSizeLimit": 52428800,
|
"FileSizeLimit": 52428800,
|
||||||
"AvailableStartYear": 1700,
|
"AvailableStartYear": 1700,
|
||||||
"AvailableEndYear": 1800
|
"AvailableEndYear": 1800,
|
||||||
|
"LettersOnPage": 90
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ha-register .ha-register-head .ha-register-add a .ha-register-add-text {
|
.ha-register .ha-register-head .ha-register-add a .ha-register-add-text {
|
||||||
|
@apply ml-1
|
||||||
}
|
}
|
||||||
|
|
||||||
.ha-register .ha-register-head .ha-register-nav a {
|
.ha-register .ha-register-head .ha-register-nav a {
|
||||||
|
|||||||
3
HaWeb/wwwroot/css/search.css
Normal file
3
HaWeb/wwwroot/css/search.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@layer components {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
@import "./letterhead.css";
|
@import "./letterhead.css";
|
||||||
@import "./letter.css";
|
@import "./letter.css";
|
||||||
@import "./upload.css";
|
@import "./upload.css";
|
||||||
|
@import "./search.css";
|
||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
/* TODO: check what can be inlined (eg. used once in the code, has no double paths etc...) */
|
/* TODO: check what can be inlined (eg. used once in the code, has no double paths etc...) */
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.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-9
|
||||||
}
|
}
|
||||||
|
|
||||||
.ha-static h2 {
|
.ha-static h2 {
|
||||||
|
|||||||
Reference in New Issue
Block a user