From f0f54afd4f765e0547787f87b6ce8bc79387757d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCegg?= Date: Wed, 15 Mar 2023 14:39:49 +0100 Subject: [PATCH 1/3] [TASK] Support `menu.json` --- www/Default.aspx.vb | 208 ++++++++++++++---- www/Web.config | 32 +++ www/_aside.aspx | 5 - www/bin/System.Buffers.dll | Bin 0 -> 20856 bytes www/bin/System.Memory.dll | Bin 0 -> 142240 bytes www/bin/System.Numerics.Vectors.dll | Bin 0 -> 115856 bytes ...System.Runtime.CompilerServices.Unsafe.dll | Bin 0 -> 18024 bytes www/bin/System.Text.Json.dll | Bin 0 -> 582288 bytes 8 files changed, 198 insertions(+), 47 deletions(-) create mode 100644 www/bin/System.Buffers.dll create mode 100644 www/bin/System.Memory.dll create mode 100644 www/bin/System.Numerics.Vectors.dll create mode 100644 www/bin/System.Runtime.CompilerServices.Unsafe.dll create mode 100644 www/bin/System.Text.Json.dll diff --git a/www/Default.aspx.vb b/www/Default.aspx.vb index 740e7d8..08171c0 100644 --- a/www/Default.aspx.vb +++ b/www/Default.aspx.vb @@ -2,6 +2,7 @@ Option Strict On Imports System.IO Imports System.Globalization +Imports System.Text.Json Imports System.XML Imports System.XML.Linq @@ -192,6 +193,165 @@ End Function ''' This is used to automagically create the left-side navigation. It's not perfect, but does the job Protected function PrintNav(ByVal initial As DirectoryInfo) As XElement + ''' create return element + Dim xmlRoot As XElement = + Dim children As IEnumerable(Of XElement) + + Dim menuFile As FileInfo = New FileInfo(initial.FullName & "\menu.json") + + + If menuFile.Exists Then + PrintNavXmlAppendChildren(xmlRoot, PrintNavJson(menuFile)) + Else + PrintNavXmlAppendChildren(xmlRoot, PrintNavFS(initial)) + End If + + return xmlRoot + +End Function + +Protected Function PrintNavXmlMarkActive(ByRef html As XElement, ByVal link As String) As XElement + + ''' If it's the current page, mark it active + if link = "/" & requestUrl then + html.Descendants("a")(0).Attribute("class").Value = "is-active" + end if + + return html + +End Function + +Protected Function PrintNavXmlCreateDir(ByVal caption As String, ByVal link As String) As XElement + + Dim html As XElement + + ''' Create the html + html = _ +
  • + +
    + + <%= caption %> +
    +
    +
  • + + ''' Update the href attribute + html.Descendants("a")(0).Attribute("href").Value = link + + return PrintNavXmlMarkActive(html, link) + +End Function + +Protected function PrintNavXmlCreateFile(ByVal caption As String, ByVal link As String) As XElement + + Dim html As XElement + + ''' create the required html + html = _ +
  • + + <%= caption %> + +
  • + + ''' update the href property + html.Descendants("a")(0).Attribute("href").Value = link + + return PrintNavXmlMarkActive(html, link) + +End Function + +Protected function PrintNavXmlAppendChildren( + ByRef parentNode As XElement, + ByRef childNode As XElement + ) As Long + + Dim children As IEnumerable(Of XElement) + + ''' get files and sub-folders + children = childNode.Elements + + ''' if found any, append them + if children.count() > 0 then + + parentNode.add(