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

@@ -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;
};
}