mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Person Pages
This commit is contained in:
@@ -4,17 +4,20 @@ namespace HaDocument.Models {
|
|||||||
public string Name { get; } = "";
|
public string Name { get; } = "";
|
||||||
public string Prename { get; } = "";
|
public string Prename { get; } = "";
|
||||||
public string Surname { get; } = "";
|
public string Surname { get; } = "";
|
||||||
|
public string? Komm { get; }
|
||||||
|
|
||||||
public Person(
|
public Person(
|
||||||
string index,
|
string index,
|
||||||
string name,
|
string name,
|
||||||
string prename,
|
string prename,
|
||||||
string surname
|
string surname,
|
||||||
|
string? komm
|
||||||
) {
|
) {
|
||||||
Index = index;
|
Index = index;
|
||||||
Name = name;
|
Name = name;
|
||||||
Prename = prename;
|
Prename = prename;
|
||||||
Surname = surname;
|
Surname = surname;
|
||||||
|
Komm = komm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ namespace HaDocument.Reactors {
|
|||||||
// State
|
// State
|
||||||
private string Index;
|
private string Index;
|
||||||
private string Name;
|
private string Name;
|
||||||
|
private string? Komm;
|
||||||
|
|
||||||
internal HandDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
internal HandDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
||||||
lib.HandPersons = new Dictionary<string, Person>();
|
lib.HandPersons = new Dictionary<string, Person>();
|
||||||
@@ -38,6 +39,7 @@ namespace HaDocument.Reactors {
|
|||||||
_active = true;
|
_active = true;
|
||||||
Index = tag["index"];
|
Index = tag["index"];
|
||||||
Name = tag["name"];
|
Name = tag["name"];
|
||||||
|
if (!String.IsNullOrWhiteSpace(tag["komm"])) Komm = tag["komm"];
|
||||||
Add();
|
Add();
|
||||||
_active = false;
|
_active = false;
|
||||||
}
|
}
|
||||||
@@ -49,7 +51,7 @@ namespace HaDocument.Reactors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void Add() {
|
protected void Add() {
|
||||||
CreatedInstances.Add(Index, new Person(Index, Name, "", ""));
|
CreatedInstances.Add(Index, new Person(Index, Name, "", "", Komm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ namespace HaDocument.Reactors {
|
|||||||
private string Name;
|
private string Name;
|
||||||
private string Prename = "";
|
private string Prename = "";
|
||||||
private string Surname = "";
|
private string Surname = "";
|
||||||
|
private string? Komm;
|
||||||
|
|
||||||
internal PersonDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
internal PersonDefsReactor(IReader reader, IntermediateLibrary lib) : base(reader, lib) {
|
||||||
lib.Persons = new Dictionary<string, Person>();
|
lib.Persons = new Dictionary<string, Person>();
|
||||||
@@ -41,6 +42,7 @@ namespace HaDocument.Reactors {
|
|||||||
Name = tag["name"];
|
Name = tag["name"];
|
||||||
Prename = tag["vorname"];
|
Prename = tag["vorname"];
|
||||||
Surname = tag["nachname"];
|
Surname = tag["nachname"];
|
||||||
|
if (!String.IsNullOrWhiteSpace(tag["komm"])) Komm = tag["komm"];
|
||||||
Add();
|
Add();
|
||||||
_active = false;
|
_active = false;
|
||||||
}
|
}
|
||||||
@@ -51,10 +53,11 @@ namespace HaDocument.Reactors {
|
|||||||
Name = "";
|
Name = "";
|
||||||
Prename = "";
|
Prename = "";
|
||||||
Surname = "";
|
Surname = "";
|
||||||
|
Komm = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add() {
|
public void Add() {
|
||||||
CreatedInstances.Add(Index, new Person(Index, Name, Prename, Surname));
|
CreatedInstances.Add(Index, new Person(Index, Name, Prename, Surname, Komm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,9 +58,9 @@ public class Briefecontroller : Controller {
|
|||||||
// Model creation
|
// Model creation
|
||||||
var hasMarginals = false;
|
var hasMarginals = false;
|
||||||
if (marginals != null && marginals.Any()) hasMarginals = true;
|
if (marginals != null && marginals.Any()) hasMarginals = true;
|
||||||
var model = new BriefeViewModel(id, index, GenerateMetaViewModel(lib, meta));
|
var model = new BriefeViewModel(id, index, GenerateMetaViewModel(lib, meta, true));
|
||||||
if (nextmeta != null) model.MetaData.Next = (GenerateMetaViewModel(lib, nextmeta), url + nextmeta.Autopsic);
|
if (nextmeta != null) model.MetaData.Next = (GenerateMetaViewModel(lib, nextmeta, false), url + nextmeta.Autopsic);
|
||||||
if (prevmeta != null) model.MetaData.Prev = (GenerateMetaViewModel(lib, prevmeta), url + prevmeta.Autopsic);
|
if (prevmeta != null) model.MetaData.Prev = (GenerateMetaViewModel(lib, prevmeta, false), url + prevmeta.Autopsic);
|
||||||
if (hands != null && hands.Any()) model.ParsedHands = HaWeb.HTMLHelpers.LetterHelpers.CreateHands(lib, hands);
|
if (hands != null && hands.Any()) model.ParsedHands = HaWeb.HTMLHelpers.LetterHelpers.CreateHands(lib, hands);
|
||||||
if (editreasons != null && editreasons.Any()) model.ParsedEdits = HaWeb.HTMLHelpers.LetterHelpers.CreateEdits(lib, _readerService, editreasons);
|
if (editreasons != null && editreasons.Any()) model.ParsedEdits = HaWeb.HTMLHelpers.LetterHelpers.CreateEdits(lib, _readerService, editreasons);
|
||||||
model.DefaultCategory = lib.Apps.ContainsKey("-1") ? lib.Apps["-1"].Category : null;
|
model.DefaultCategory = lib.Apps.ContainsKey("-1") ? lib.Apps["-1"].Category : null;
|
||||||
@@ -129,40 +129,68 @@ public class Briefecontroller : Controller {
|
|||||||
return Redirect("/Error404");
|
return Redirect("/Error404");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static BriefeMetaViewModel GenerateMetaViewModel(ILibrary lib, Meta meta) {
|
internal static BriefeMetaViewModel GenerateMetaViewModel(ILibrary lib, Meta meta, bool generatePersonLinks) {
|
||||||
var hasText = lib.Letters.ContainsKey(meta.Index) ? true : false;
|
var hasText = lib.Letters.ContainsKey(meta.Index) ? true : false;
|
||||||
var hasMarginals = lib.MarginalsByLetter.Contains(meta.Index) ? true : false;
|
var hasMarginals = lib.MarginalsByLetter.Contains(meta.Index) ? true : false;
|
||||||
var senders = meta.Senders.Select(x => lib.Persons[x].Name) ?? new List<string>();
|
var senders = meta.Senders.Select(x => lib.Persons[x]).ToList() ?? new List<Person>();
|
||||||
var recivers = meta.Receivers.Select(x => lib.Persons[x].Name) ?? new List<string>();
|
var receivers = meta.Receivers.Select(x => lib.Persons[x]).ToList() ?? new List<Person>();
|
||||||
var zhstring = meta.ZH != null ? HaWeb.HTMLHelpers.LetterHelpers.CreateZHString(meta) : null;
|
var zhstring = meta.ZH != null ? HaWeb.HTMLHelpers.LetterHelpers.CreateZHString(meta) : null;
|
||||||
return new BriefeMetaViewModel(meta, hasMarginals) {
|
return new BriefeMetaViewModel(meta, hasMarginals) {
|
||||||
ParsedZHString = zhstring,
|
ParsedZHString = zhstring,
|
||||||
SenderReceiver = generateSendersRecievers(senders, recivers),
|
SenderReceiver = generateSendersRecievers(senders, receivers, generatePersonLinks),
|
||||||
HasText = hasText,
|
HasText = hasText,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static List<(string Sender, string Receiver)> generateSendersRecievers(IEnumerable<string>? senders, IEnumerable<string>? receivers) {
|
private static List<(string Sender, string Receiver)> generateSendersRecievers(List<Person>? senders, List<Person>? receivers, bool generatePersonLinks) {
|
||||||
var res = new List<(string Sender, string Receiver)>();
|
var res = new List<(string Sender, string Receiver)>();
|
||||||
if (senders != null && receivers != null) {
|
if (senders == null || receivers == null) return null;
|
||||||
|
if (!generatePersonLinks) {
|
||||||
if (senders.Any(x => receivers.Contains(x))) {
|
if (senders.Any(x => receivers.Contains(x))) {
|
||||||
var s = senders.ToList();
|
for (var i = 0; i < receivers.Count || i < senders.Count; i++) {
|
||||||
var r = receivers.ToList();
|
|
||||||
for (var i = 0; i < r.Count || i < s.Count; i++) {
|
|
||||||
res.Add((
|
res.Add((
|
||||||
s[i],
|
senders[i].Name,
|
||||||
r[i]
|
receivers[i].Name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.Add((
|
res.Add((
|
||||||
HTMLHelpers.StringHelpers.GetEnumerationString(senders),
|
HTMLHelpers.StringHelpers.GetEnumerationString(senders.Select(x => x.Name)),
|
||||||
HTMLHelpers.StringHelpers.GetEnumerationString(receivers)
|
HTMLHelpers.StringHelpers.GetEnumerationString(receivers.Select(x => x.Name))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (senders.Any(x => receivers.Contains(x))) {
|
||||||
|
for (var i = 0; i < receivers.Count || i < senders.Count; i++) {
|
||||||
|
res.Add((
|
||||||
|
HTMLHelpers.TagHelpers.CreateElement("a", "", "/HKB/Person/" + senders[i].Index) + senders[i].Name + HTMLHelpers.TagHelpers.CreateEndElement("a"),
|
||||||
|
HTMLHelpers.TagHelpers.CreateElement("a", "", "/HKB/Person/" + receivers[i].Index) + receivers[i].Name + HTMLHelpers.TagHelpers.CreateEndElement("a")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.Add((
|
||||||
|
GetEnumerationStringLinks(senders),
|
||||||
|
GetEnumerationStringLinks(receivers)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetEnumerationStringLinks(IEnumerable<Person> strlist) {
|
||||||
|
var res = string.Empty;
|
||||||
|
foreach (var str in strlist) {
|
||||||
|
if (str != strlist.First())
|
||||||
|
if (str == strlist.Last())
|
||||||
|
res += " und " + HTMLHelpers.TagHelpers.CreateElement("a", "", "/HKB/Person/" + str.Index) + str.Name + HTMLHelpers.TagHelpers.CreateEndElement("a");
|
||||||
|
else
|
||||||
|
res += ", " + HTMLHelpers.TagHelpers.CreateElement("a", "", "/HKB/Person/" + str.Index) + str.Name + HTMLHelpers.TagHelpers.CreateEndElement("a");
|
||||||
|
else
|
||||||
|
res += HTMLHelpers.TagHelpers.CreateElement("a", "", "/HKB/Person/" + str.Index) + str.Name + HTMLHelpers.TagHelpers.CreateEndElement("a");
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public class IndexController : Controller {
|
|||||||
var metas = lib.Metas.Where(x => letters.Contains(x.Key)).Select(x => x.Value);
|
var metas = lib.Metas.Where(x => letters.Contains(x.Key)).Select(x => x.Value);
|
||||||
if (metas == null) return _error404();
|
if (metas == null) return _error404();
|
||||||
var metasbyyear = metas.ToLookup(x => x.Sort.Year).OrderBy(x => x.Key).ToList();
|
var metasbyyear = metas.ToLookup(x => x.Sort.Year).OrderBy(x => x.Key).ToList();
|
||||||
return _paginateSend(lib, 0, metasbyyear, null, zhvolume, zhpage);
|
return _paginateSend(lib, 0, metasbyyear, null, null, zhvolume, zhpage);
|
||||||
}
|
}
|
||||||
return _error404();
|
return _error404();
|
||||||
}
|
}
|
||||||
@@ -76,25 +76,27 @@ public class IndexController : Controller {
|
|||||||
|
|
||||||
[Route("/HKB/Person/{person}")]
|
[Route("/HKB/Person/{person}")]
|
||||||
public IActionResult Person(string person, int page = 0) {
|
public IActionResult Person(string person, int page = 0) {
|
||||||
|
var lib = _lib.GetLibrary();
|
||||||
if (String.IsNullOrWhiteSpace(person)) return _error404();
|
if (String.IsNullOrWhiteSpace(person)) return _error404();
|
||||||
person = person.Trim();
|
person = person.Trim();
|
||||||
var lib = _lib.GetLibrary();
|
if (!lib.Persons.ContainsKey(person)) return _error404();
|
||||||
List<IGrouping<int, Meta>>? metasbyyear = null;
|
List<IGrouping<int, Meta>>? metasbyyear = null;
|
||||||
|
Person p = lib.Persons[person];
|
||||||
|
CommentModel? comment = null;
|
||||||
|
if (p.Komm != null) comment = _getPersonComment(p.Komm);
|
||||||
var letters = lib.Metas
|
var letters = lib.Metas
|
||||||
.Where(x => x.Value.Senders.Contains(person) || x.Value.Receivers.Contains(person))
|
.Where(x => x.Value.Senders.Contains(person) || x.Value.Receivers.Contains(person))
|
||||||
.Select(x => x.Value);
|
.Select(x => x.Value);
|
||||||
if (letters == null) return _error404();
|
if (letters == null) return _error404();
|
||||||
metasbyyear = letters.ToLookup(x => x.Sort.Year).OrderBy(x => x.Key).ToList();
|
metasbyyear = letters.ToLookup(x => x.Sort.Year).OrderBy(x => x.Key).ToList();
|
||||||
return _paginateSend(lib, page, metasbyyear, person);
|
return _paginateSend(lib, page, metasbyyear, person, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<(string Key, string Person)>? _getAvailablePersons(ILibrary lib) {
|
private List<(string Key, string Person)>? _getAvailablePersons() {
|
||||||
if (!lib.Persons.Any()) return null;
|
if (_lib.GetAvailablePersons() == null || !_lib.GetAvailablePersons()!.Any()) return null;
|
||||||
return lib.Persons
|
return _lib.GetAvailablePersons()!
|
||||||
.OrderBy(x => x.Value.Surname)
|
.Select(x => (x.Index, x.Name))
|
||||||
.ThenBy(x => x.Value.Prename)
|
|
||||||
.Select(x => (x.Key, x.Value.Name))
|
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +128,7 @@ public class IndexController : Controller {
|
|||||||
int page,
|
int page,
|
||||||
List<IGrouping<int, Meta>> metasbyyear,
|
List<IGrouping<int, Meta>> metasbyyear,
|
||||||
string? person = null,
|
string? person = null,
|
||||||
|
CommentModel? personcomment = null,
|
||||||
string? zhvolume = null,
|
string? zhvolume = null,
|
||||||
string? zhpage = null) {
|
string? zhpage = null) {
|
||||||
var pages = Paginate(metasbyyear, _lettersForPage);
|
var pages = Paginate(metasbyyear, _lettersForPage);
|
||||||
@@ -136,7 +139,7 @@ public class IndexController : Controller {
|
|||||||
letters = metasbyyear
|
letters = metasbyyear
|
||||||
.Where(x => x.Key >= pages[page].StartYear && x.Key <= pages[page].EndYear)
|
.Where(x => x.Key >= pages[page].StartYear && x.Key <= pages[page].EndYear)
|
||||||
.Select(x => (x.Key, x
|
.Select(x => (x.Key, x
|
||||||
.Select(y => Briefecontroller.GenerateMetaViewModel(lib, y))
|
.Select(y => Briefecontroller.GenerateMetaViewModel(lib, y, false))
|
||||||
.OrderBy(x => x.Meta.Sort)
|
.OrderBy(x => x.Meta.Sort)
|
||||||
.ThenBy(x => x.Meta.Order)
|
.ThenBy(x => x.Meta.Order)
|
||||||
.ToList()))
|
.ToList()))
|
||||||
@@ -152,15 +155,31 @@ public class IndexController : Controller {
|
|||||||
_endYear.ToString(),
|
_endYear.ToString(),
|
||||||
"ZH " + HTMLHelpers.ConversionHelpers.ToRoman(Int32.Parse(lastletter.ZH.Volume)) + ", S. " + lastletter.ZH.Page,
|
"ZH " + HTMLHelpers.ConversionHelpers.ToRoman(Int32.Parse(lastletter.ZH.Volume)) + ", S. " + lastletter.ZH.Page,
|
||||||
pages,
|
pages,
|
||||||
_getAvailablePersons(lib),
|
_getAvailablePersons(),
|
||||||
availablePages.OrderBy(x => x.Volume).ToList(),
|
availablePages.OrderBy(x => x.Volume).ToList(),
|
||||||
zhvolume,
|
zhvolume,
|
||||||
zhpage,
|
zhpage,
|
||||||
person
|
person
|
||||||
);
|
);
|
||||||
|
model.PersonComment = personcomment;
|
||||||
return View("~/Views/HKB/Dynamic/Index.cshtml", model);
|
return View("~/Views/HKB/Dynamic/Index.cshtml", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CommentModel? _getPersonComment(string comment) {
|
||||||
|
var lib = _lib.GetLibrary();
|
||||||
|
if (!lib.Comments.ContainsKey(comment)) return null;
|
||||||
|
var comm = lib.Comments[comment];
|
||||||
|
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(lib, _readerService, comm, "neuzeit", Settings.ParsingState.CommentType.Comment, true); // Maybe true for Backlinks
|
||||||
|
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, "neuzeit", Settings.ParsingState.CommentType.Subcomment, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new CommentModel(parsedComment, parsedSubComments);
|
||||||
|
}
|
||||||
|
|
||||||
private IActionResult _error404() {
|
private IActionResult _error404() {
|
||||||
Response.StatusCode = 404;
|
Response.StatusCode = 404;
|
||||||
return Redirect("/Error404");
|
return Redirect("/Error404");
|
||||||
|
|||||||
@@ -1,27 +1,9 @@
|
|||||||
namespace HaWeb.Controllers;
|
namespace HaWeb.Controllers;
|
||||||
using System.Diagnostics;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using HaWeb.Models;
|
using HaWeb.Models;
|
||||||
using HaDocument.Interfaces;
|
|
||||||
using HaXMLReader.Interfaces;
|
using HaXMLReader.Interfaces;
|
||||||
using System.Text;
|
|
||||||
using HaXMLReader;
|
|
||||||
using HaXMLReader.EvArgs;
|
|
||||||
using HaDocument.Models;
|
using HaDocument.Models;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using HaWeb.FileHelpers;
|
using HaWeb.FileHelpers;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.WebUtilities;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Net.Http.Headers;
|
|
||||||
using HaWeb.Filters;
|
|
||||||
using HaWeb.XMLParser;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Text.Json;
|
|
||||||
using Microsoft.FeatureManagement.Mvc;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
|
|
||||||
[Route("/HKB/Register/[action]/{id?}")]
|
[Route("/HKB/Register/[action]/{id?}")]
|
||||||
public class RegisterController : Controller {
|
public class RegisterController : Controller {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class SucheController : Controller {
|
|||||||
letters = metasbyyear
|
letters = metasbyyear
|
||||||
.Where(x => x.Key >= pages[page].StartYear && x.Key <= pages[page].EndYear)
|
.Where(x => x.Key >= pages[page].StartYear && x.Key <= pages[page].EndYear)
|
||||||
.Select(x => (x.Key, x
|
.Select(x => (x.Key, x
|
||||||
.Select(y => Briefecontroller.GenerateMetaViewModel(lib, y))
|
.Select(y => Briefecontroller.GenerateMetaViewModel(lib, y, true))
|
||||||
.OrderBy(x => x.Meta.Sort)
|
.OrderBy(x => x.Meta.Sort)
|
||||||
.ThenBy(x => x.Meta.Order)
|
.ThenBy(x => x.Meta.Order)
|
||||||
.ToList()))
|
.ToList()))
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
namespace HaWeb.FileHelpers;
|
namespace HaWeb.FileHelpers;
|
||||||
using HaDocument.Interfaces;
|
using HaDocument.Interfaces;
|
||||||
|
using HaDocument.Models;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
@@ -13,19 +14,19 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
|
|||||||
private ILibrary Library;
|
private ILibrary Library;
|
||||||
private IXMLProvider _xmlProvider;
|
private IXMLProvider _xmlProvider;
|
||||||
private IXMLService _xmlService;
|
private IXMLService _xmlService;
|
||||||
|
|
||||||
private string _filepath;
|
private string _filepath;
|
||||||
|
private int _startYear;
|
||||||
public int StartYear { get; private set; }
|
private int _endYear;
|
||||||
public int EndYear { get; private set; }
|
private List<Person>? _availablePersons;
|
||||||
|
private Dictionary<string, Person>? _personsWithLetters;
|
||||||
|
|
||||||
// public List<SearchHelpers.CollectedItem>? SearchableLetters { get; private set; }
|
// public List<SearchHelpers.CollectedItem>? SearchableLetters { get; private set; }
|
||||||
|
|
||||||
public HaDocumentWrapper(IXMLProvider xmlProvider, IXMLService service, IConfiguration configuration) {
|
public HaDocumentWrapper(IXMLProvider xmlProvider, IXMLService service, IConfiguration configuration) {
|
||||||
_xmlProvider = xmlProvider;
|
_xmlProvider = xmlProvider;
|
||||||
_xmlService = service;
|
_xmlService = service;
|
||||||
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);
|
||||||
@@ -40,39 +41,47 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetStartYear() => StartYear;
|
public List<Person>? GetAvailablePersons() => _availablePersons;
|
||||||
|
|
||||||
public int GetEndYear() => EndYear;
|
public Dictionary<string, Person>? GetPersonsWithLetters() => _personsWithLetters;
|
||||||
|
|
||||||
|
public int GetStartYear() => _startYear;
|
||||||
|
|
||||||
|
public int GetEndYear() => _endYear;
|
||||||
|
|
||||||
public void SetEndYear(int end) {
|
public void SetEndYear(int end) {
|
||||||
this.EndYear = end;
|
this._endYear = end;
|
||||||
SetLibrary(_filepath);
|
SetLibrary(_filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILibrary ResetLibrary() {
|
|
||||||
var options = new HaWeb.Settings.HaDocumentOptions() { AvailableYearRange = (StartYear, EndYear )};
|
|
||||||
Library = HaDocument.Document.Create(options);
|
|
||||||
_filepath = options.HamannXMLFilePath;
|
|
||||||
return Library;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ILibrary? SetLibrary(string filepath, ModelStateDictionary? ModelState = null) {
|
public ILibrary? SetLibrary(string filepath, ModelStateDictionary? ModelState = null) {
|
||||||
var sw = new System.Diagnostics.Stopwatch();
|
// 1. Set ILibrary
|
||||||
sw.Start();
|
|
||||||
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);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
sw.Stop();
|
|
||||||
Console.WriteLine("ILIB: " + sw.ElapsedMilliseconds);
|
|
||||||
sw.Restart();
|
|
||||||
|
|
||||||
|
// 1a. Set Available Persons
|
||||||
|
var persons = Library.Metas.SelectMany(x => x.Value.Senders.Union(x.Value.Receivers)).Distinct();
|
||||||
|
_availablePersons = persons.Select(x => Library.Persons[x]).OrderBy(x => x.Surname).ThenBy(x => x.Prename).ToList();
|
||||||
|
|
||||||
|
// 1b. Setup a Dictionary with available Person ovierview Pages
|
||||||
|
|
||||||
|
_personsWithLetters = new Dictionary<string, Person>();
|
||||||
|
var availablePersonPages = Library.Persons.Where(x => !String.IsNullOrWhiteSpace(x.Value.Komm));
|
||||||
|
foreach (var p in availablePersonPages) {
|
||||||
|
if (!_personsWithLetters.ContainsKey(p.Value.Komm!)) {
|
||||||
|
_personsWithLetters.Add(p.Value.Komm, p.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Set Library in Production, collect some Objects
|
||||||
if (_xmlService != null)
|
if (_xmlService != null)
|
||||||
_xmlService.SetInProduction(System.Xml.Linq.XDocument.Load(filepath, System.Xml.Linq.LoadOptions.PreserveWhitespace));
|
_xmlService.SetInProduction(System.Xml.Linq.XDocument.Load(filepath, System.Xml.Linq.LoadOptions.PreserveWhitespace));
|
||||||
sw.Stop();
|
|
||||||
Console.WriteLine("COLLECTIONS: " + sw.ElapsedMilliseconds);
|
// 3. Set Filepath
|
||||||
_filepath = filepath;
|
_filepath = filepath;
|
||||||
return Library;
|
return Library;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
namespace HaWeb.FileHelpers;
|
namespace HaWeb.FileHelpers;
|
||||||
using HaDocument.Interfaces;
|
using HaDocument.Interfaces;
|
||||||
|
using HaDocument.Models;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using HaXMLReader.Interfaces;
|
using HaXMLReader.Interfaces;
|
||||||
|
|
||||||
public interface IHaDocumentWrappper {
|
public interface IHaDocumentWrappper {
|
||||||
public ILibrary ResetLibrary();
|
|
||||||
public ILibrary? SetLibrary(string filepath, ModelStateDictionary ModelState);
|
public ILibrary? SetLibrary(string filepath, ModelStateDictionary ModelState);
|
||||||
public ILibrary GetLibrary();
|
public ILibrary GetLibrary();
|
||||||
|
|
||||||
public int GetStartYear();
|
public int GetStartYear();
|
||||||
public int GetEndYear();
|
public int GetEndYear();
|
||||||
|
public List<Person>? GetAvailablePersons();
|
||||||
|
public Dictionary<string, Person>? GetPersonsWithLetters();
|
||||||
public void SetEndYear(int end);
|
public void SetEndYear(int end);
|
||||||
}
|
}
|
||||||
10647
HaWeb/Hamann.xml
10647
HaWeb/Hamann.xml
File diff suppressed because it is too large
Load Diff
211648
HaWeb/Hammannoindet.xml
211648
HaWeb/Hammannoindet.xml
File diff suppressed because one or more lines are too long
@@ -15,11 +15,7 @@ public class BriefeMetaViewModel {
|
|||||||
get => _SenderReceiver;
|
get => _SenderReceiver;
|
||||||
set {
|
set {
|
||||||
if (value != null)
|
if (value != null)
|
||||||
value.ForEach(x => {
|
_SenderReceiver = value;
|
||||||
HttpUtility.HtmlEncode(x.Sender);
|
|
||||||
HttpUtility.HtmlEncode(x.Receiver);
|
|
||||||
});
|
|
||||||
_SenderReceiver = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class IndexViewModel {
|
|||||||
public int ActiveYear { get; private set; }
|
public int ActiveYear { get; private set; }
|
||||||
public List<(int StartYear, int EndYear)>? AvailableYears { get; private set; }
|
public List<(int StartYear, int EndYear)>? AvailableYears { get; private set; }
|
||||||
public string? ActivePerson { get; set; }
|
public string? ActivePerson { get; set; }
|
||||||
|
public CommentModel? PersonComment { get; set; }
|
||||||
public List<(string Key, string Name)>? AvailablePersons { 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 List<(string Volume, List<string> Pages)>? AvailablePages { get; private set; }
|
||||||
public string? ActiveVolume { get; private set; }
|
public string? ActiveVolume { get; private set; }
|
||||||
|
|||||||
@@ -11,9 +11,22 @@
|
|||||||
@if (Model.Letters != null) {
|
@if (Model.Letters != null) {
|
||||||
|
|
||||||
<div class="ha-indexhead">
|
<div class="ha-indexhead">
|
||||||
<h1>Briefauswahl</h1>
|
@if (Model.PersonComment == null) {
|
||||||
<div class="ha-indexnav">
|
<h1>Briefauswahl</h1>
|
||||||
|
}
|
||||||
|
@if(Model.PersonComment != null) {
|
||||||
|
<div class="ha-comment">
|
||||||
|
<div class="ha-headcomment">
|
||||||
|
<div class="ha-commentmetatext">
|
||||||
|
Briefe von und an  
|
||||||
|
<a class="ha-reversefilter" asp-controller="Index" asp-action="Index">← Alle Briefe</a>
|
||||||
|
</div>
|
||||||
|
@Html.Raw(Model.PersonComment.ParsedComment)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
@if (Model.AvailableYears != null && Model.AvailableYears.Any() && Model.AvailableYears.Count > 1) {
|
@if (Model.AvailableYears != null && Model.AvailableYears.Any() && Model.AvailableYears.Count > 1) {
|
||||||
|
<div class="ha-indexnav">
|
||||||
@for(var i = 0; i < Model.AvailableYears.Count; i++) {
|
@for(var i = 0; i < Model.AvailableYears.Count; i++) {
|
||||||
<a class="@(Model.ActiveYear == i ? "active" : "")" asp-route-person="@Model.ActivePerson" asp-controller="Index" asp-route-page="@i">
|
<a class="@(Model.ActiveYear == i ? "active" : "")" asp-route-person="@Model.ActivePerson" asp-controller="Index" asp-route-page="@i">
|
||||||
@if (Model.AvailableYears[i].StartYear != Model.AvailableYears[i].EndYear) {
|
@if (Model.AvailableYears[i].StartYear != Model.AvailableYears[i].EndYear) {
|
||||||
@@ -28,8 +41,8 @@
|
|||||||
}
|
}
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ha-indexbody">
|
<div class="ha-indexbody">
|
||||||
|
|||||||
281525
HaWeb/attributes.txt
281525
HaWeb/attributes.txt
File diff suppressed because it is too large
Load Diff
@@ -38,15 +38,15 @@
|
|||||||
|
|
||||||
/* NON THEME RULES */
|
/* NON THEME RULES */
|
||||||
.ha-index .ha-indexhead {
|
.ha-index .ha-indexhead {
|
||||||
@apply pt-9 md:pt-12 px-9 md:px-16 border-b-2
|
@apply border-b-2
|
||||||
}
|
}
|
||||||
|
|
||||||
.ha-index .ha-indexhead h1 {
|
.ha-index .ha-indexhead h1 {
|
||||||
@apply font-bold text-2xl desktop:font-normal desktop:text-5xl mb-6 inline-block font-serif
|
@apply font-bold mt-9 md:mt-12 px-9 md:px-16 text-2xl desktop:font-normal desktop:text-5xl mb-7 inline-block font-serif
|
||||||
}
|
}
|
||||||
|
|
||||||
.ha-index .ha-indexhead .ha-indexnav {
|
.ha-index .ha-indexhead .ha-indexnav {
|
||||||
@apply font-sans oldstyle-nums
|
@apply font-sans oldstyle-nums px-9 md:px-16 mt-2
|
||||||
}
|
}
|
||||||
|
|
||||||
.ha-index .ha-indexhead .ha-indexnav a {
|
.ha-index .ha-indexhead .ha-indexnav a {
|
||||||
@@ -61,6 +61,38 @@
|
|||||||
@apply pt-6 clear-both flex flex-row gap-x-4
|
@apply pt-6 clear-both flex flex-row gap-x-4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment {
|
||||||
|
@apply font-serif hyphenate px-9 md:px-16 py-3 pb-12 border-l-2
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment .ha-commentmetatext {
|
||||||
|
@apply mt-9 md:mt-12
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment .ha-commentmetatext a {
|
||||||
|
@apply float-right bg-slate-200 text-sm inline-block px-2 rounded
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment .ha-lemma {
|
||||||
|
@apply font-bold font-bold text-2xl desktop:font-normal desktop:text-5xl mb-3 inline-block font-serif
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment .ha-entry {
|
||||||
|
@apply max-w-[calc(780px-4rem)]
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment a {
|
||||||
|
@apply underline decoration-dotted hover:decoration-solid
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment .ha-letlinks {
|
||||||
|
@apply hidden
|
||||||
|
}
|
||||||
|
|
||||||
|
.ha-index .ha-comment .ha-letlinks .ha-hkb {
|
||||||
|
@apply inline
|
||||||
|
}
|
||||||
|
|
||||||
.ha-index .ha-indexbody .ha-letterlist {
|
.ha-index .ha-indexbody .ha-letterlist {
|
||||||
@apply pb-4 basis-2/3 grow-0
|
@apply pb-4 basis-2/3 grow-0
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user