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(