mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Fixed a few bugs; fixed marginals; fixed google indexing
This commit is contained in:
1
HaWeb/.gitignore
vendored
1
HaWeb/.gitignore
vendored
@@ -23,3 +23,4 @@ bin/*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
testdata/
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Xml.Linq;
|
||||
using System.Diagnostics;
|
||||
|
||||
public class HaDocumentWrapper : IHaDocumentWrappper {
|
||||
private IFileInfo _ActiveFile;
|
||||
private IFileInfo? _ActiveFile;
|
||||
private ILibrary? Library;
|
||||
private IXMLInteractionService _xmlService;
|
||||
private int _startYear;
|
||||
@@ -60,7 +60,8 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
|
||||
// 2. Set ILibrary
|
||||
try {
|
||||
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = path, AvailableYearRange = (_startYear, _endYear) }, doc.Root);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ModelState != null) ModelState.AddModelError("Error", "Das Dokument konnte nicht geparst werden: " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using HaWeb.Models;
|
||||
using HaWeb.XMLParser;
|
||||
using HaWeb.XMLTests;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
// XMLProvider provides a wrapper around the available XML data on a FILE basis
|
||||
@@ -165,7 +163,7 @@ public class XMLFileProvider : IXMLFileProvider {
|
||||
|
||||
public IFileInfo? SaveHamannFile(XElement element, string basefilepath, ModelStateDictionary? ModelState) {
|
||||
if (_GitState == null) return null;
|
||||
var filename = "hamann_" + _GitState.PullTime.Year + "-" + _GitState.PullTime.Month + "-" + _GitState.PullTime.Day + "_" + _GitState.PullTime.Hour + "-" + _GitState.PullTime.Minute + "." + _GitState.Commit.Substring(0,7) + ".xml";
|
||||
var filename = "hamann_" + _GitState.PullTime.Year + "-" + _GitState.PullTime.Month + "-" + _GitState.PullTime.Day + "_" + _GitState.PullTime.Hour + "-" + _GitState.PullTime.Minute + "." + _GitState.Commit.Substring(0, 7) + ".xml";
|
||||
var path = Path.Combine(basefilepath, filename);
|
||||
|
||||
try {
|
||||
@@ -173,7 +171,8 @@ public class XMLFileProvider : IXMLFileProvider {
|
||||
Directory.CreateDirectory(basefilepath);
|
||||
using (var targetStream = System.IO.File.Create(path))
|
||||
element.Save(targetStream, SaveOptions.DisableFormatting);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ModelState != null) ModelState.AddModelError("Error", "Die Datei konnte nicht gespeichert werden: " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
@@ -237,7 +236,7 @@ public class XMLFileProvider : IXMLFileProvider {
|
||||
private bool _IsAlreadyParsed() {
|
||||
if (_HamannFiles == null || !_HamannFiles.Any() || _GitState == null) return false;
|
||||
var fhash = _GetHashFromHamannFilename(_HamannFiles.First().Name);
|
||||
var ghash = _GitState.Commit.Substring(0,7);
|
||||
var ghash = _GitState.Commit.Substring(0, 7);
|
||||
return fhash == ghash;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ var app = builder.Build();
|
||||
|
||||
// // Websockets for realtime notification of changes
|
||||
app.UseWebSockets(new WebSocketOptions {
|
||||
KeepAliveInterval = TimeSpan.FromMinutes(180),
|
||||
KeepAliveInterval = TimeSpan.FromMinutes(30),
|
||||
});
|
||||
app.UseMiddleware<WebSocketMiddleware>();
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
},
|
||||
"AllowedWebSocketConnections": "*",
|
||||
"AllowedHosts": "*",
|
||||
"HamannFileStoreLinux": "/home/simon/test/",
|
||||
"HamannFileStoreLinux": "/home/simon/source/hamann-ausgabe-core/HaWeb/testdata/",
|
||||
"HamannFileStoreWindows": "C:/Users/simon/Downloads/test/",
|
||||
"BareRepositoryPathLinux": "/home/simon/source/hamann-xml/.git/",
|
||||
"BareRepositoryPathWindows": "D:/Simon/source/hamann-xml/.git/",
|
||||
"WorkingTreePathLinux": "/home/simon/source/hamann-xml/",
|
||||
"WorkingTreePathWindows": "D:/Simon/source/hamann-xml/",
|
||||
"RepositoryBranch": "Release",
|
||||
"RepositoryBranch": "Main",
|
||||
"RepositoryURL": "https://github.com/Theodor-Springmann-Stiftung/hamann-xml",
|
||||
"StoredPDFPathWindows": "",
|
||||
"StoredPDFPathLinux": "",
|
||||
|
||||
@@ -21,15 +21,22 @@ const startup_marginals = function () {
|
||||
setTimeout(function () {
|
||||
element.classList.remove("transition-all");
|
||||
}, 130);
|
||||
element.style.bottom = "unset";
|
||||
};
|
||||
|
||||
const uncollapsebox = function (element) {
|
||||
const uncollapsebox = function (element, topmove = false) {
|
||||
element.classList.add("transition-all");
|
||||
element.classList.remove("ha-collapsed-box");
|
||||
element.classList.add("ha-expanded-box");
|
||||
if (topmove > 0) element.style.bottom = "5px";
|
||||
};
|
||||
|
||||
const addbuttoncaollapsebox = function (element, height, hoverfunction, topmove) {
|
||||
const addbuttoncaollapsebox = function (
|
||||
element,
|
||||
height,
|
||||
hoverfunction,
|
||||
topmove = false,
|
||||
) {
|
||||
let btn = document.createElement("div");
|
||||
btn.classList.add("ha-btn-collapsed-box");
|
||||
|
||||
@@ -42,13 +49,11 @@ const startup_marginals = function () {
|
||||
btn.addEventListener("click", function (ev) {
|
||||
ev.stopPropagation();
|
||||
if (element.classList.contains("ha-collapsed-box")) {
|
||||
uncollapsebox(element);
|
||||
if (topmove > 0) element.style.bottom = "5px";
|
||||
uncollapsebox(element, topmove);
|
||||
btn.classList.add("ha-close-btn-collapsed-box");
|
||||
btn.classList.add("ha-collapsed-box-manually-toggled");
|
||||
} else {
|
||||
collapsebox(element, height, 0);
|
||||
|
||||
btn.classList.remove("ha-close-btn-collapsed-box");
|
||||
btn.classList.remove("ha-collapsed-box-manually-toggled");
|
||||
}
|
||||
@@ -59,20 +64,18 @@ const startup_marginals = function () {
|
||||
|
||||
element.addEventListener("mouseenter", function (ev) {
|
||||
ev.stopPropagation();
|
||||
timer = setTimeout(function () {
|
||||
if (timer != null) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
if (element.classList.contains("ha-collapsed-box")) {
|
||||
uncollapsebox(element);
|
||||
if (topmove > 0) element.style.bottom = "5px";
|
||||
uncollapsebox(element, topmove);
|
||||
btn.classList.add("ha-close-btn-collapsed-box");
|
||||
}
|
||||
}, 80);
|
||||
});
|
||||
|
||||
element.addEventListener("mouseleave", function (ev) {
|
||||
ev.stopPropagation();
|
||||
if (timer != null) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
timer = setTimeout(function () {
|
||||
if (
|
||||
element.classList.contains("ha-expanded-box") &&
|
||||
!btn.classList.contains("ha-collapsed-box-manually-toggled")
|
||||
@@ -80,16 +83,22 @@ const startup_marginals = function () {
|
||||
collapsebox(element, height, 0);
|
||||
btn.classList.remove("ha-close-btn-collapsed-box");
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
}
|
||||
element.parentNode.insertBefore(btn, element);
|
||||
};
|
||||
|
||||
const overlappingcollapsebox = function (selector, hoverfunction, containerid) {
|
||||
const overlappingcollapsebox = function (
|
||||
selector,
|
||||
hoverfunction,
|
||||
containerid,
|
||||
) {
|
||||
let container = document.getElementById(containerid);
|
||||
if (!container) return;
|
||||
container.classList.add("overflow-hidden");
|
||||
let containerrect = document.getElementById(containerid).getBoundingClientRect();;
|
||||
let containerrect = document
|
||||
.getElementById(containerid)
|
||||
.getBoundingClientRect();
|
||||
let boxes = document.querySelectorAll(selector);
|
||||
let lineheight = 1;
|
||||
|
||||
@@ -101,27 +110,29 @@ const startup_marginals = function () {
|
||||
let element = boxes[i];
|
||||
let thisrect = element.getBoundingClientRect();
|
||||
let overlap = -2;
|
||||
let topmove = 0;
|
||||
if (thisrect.bottom > containerrect.bottom) {
|
||||
overlap = thisrect.bottom - containerrect.bottom;
|
||||
topmove = thisrect.bottom - containerrect.bottom;
|
||||
console.log("topmove", topmove);
|
||||
} else if (i < boxes.length - 1) {
|
||||
let topmove = false;
|
||||
// Check if this works
|
||||
|
||||
if (i < boxes.length - 1) {
|
||||
let nextrect = boxes[i + 1].getBoundingClientRect();
|
||||
overlap = thisrect.bottom - nextrect.top;
|
||||
} else if (thisrect.bottom > containerrect.bottom) {
|
||||
overlap = thisrect.bottom - containerrect.bottom;
|
||||
}
|
||||
|
||||
if (thisrect.bottom > containerrect.bottom) {
|
||||
topmove = true;
|
||||
}
|
||||
|
||||
if (
|
||||
// -1 for catching lines that perfectly close up on each other
|
||||
overlap >= -1 &&
|
||||
!(window.getComputedStyle(element).display === "none")
|
||||
) {
|
||||
let newlength = 0;
|
||||
if (overlap >= 0)
|
||||
newlength = thisrect.height - overlap;
|
||||
else
|
||||
newlength = thisrect.height - lineheight;
|
||||
if (newlength % (lineheight * 3) <= 2)
|
||||
newlength -= lineheight;
|
||||
if (overlap >= 0) newlength = thisrect.height - overlap;
|
||||
else newlength = thisrect.height - lineheight;
|
||||
if (newlength % (lineheight * 3) <= 2) newlength -= lineheight;
|
||||
let remainder = newlength % lineheight;
|
||||
newlength = newlength - remainder;
|
||||
|
||||
@@ -136,7 +147,8 @@ const startup_marginals = function () {
|
||||
if (h >= newlength) {
|
||||
let lines = Math.floor(eh / lineheight);
|
||||
let cutoff = Math.floor((h - newlength) / lineheight);
|
||||
m.style.cssText += "-webkit-line-clamp: " + (lines - cutoff) + ";";
|
||||
m.style.cssText +=
|
||||
"-webkit-line-clamp: " + (lines - cutoff) + ";";
|
||||
m.style.cssText += "line-clamp: " + (lines - cutoff) + ";";
|
||||
}
|
||||
}
|
||||
@@ -147,7 +159,6 @@ const startup_marginals = function () {
|
||||
collapsebox(element, newlength, lineheight);
|
||||
addbuttoncaollapsebox(element, newlength, hoverfunction, topmove);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -170,17 +181,17 @@ const startup_marginals = function () {
|
||||
|
||||
const clearcollapsedboxes = function () {
|
||||
let elements = document.querySelectorAll(".ha-marginalbox");
|
||||
elements.forEach(element => {
|
||||
elements.forEach((element) => {
|
||||
element.removeAttribute("style");
|
||||
});
|
||||
collapsedboxes.forEach(element => {
|
||||
collapsedboxes.forEach((element) => {
|
||||
element.classList.remove("ha-expanded-box");
|
||||
element.classList.remove("ha-collapsed-box");
|
||||
element.outerHTML = element.outerHTML;
|
||||
});
|
||||
collapsedboxes = [];
|
||||
elements = document.querySelectorAll(".ha-btn-collapsed-box");
|
||||
elements.forEach(element => {
|
||||
elements.forEach((element) => {
|
||||
element.remove();
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user