mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-06-05 22:09:23 +02:00
Some erformance optimizations (reduced Markdown calls)
This commit is contained in:
@ -70,16 +70,16 @@ def MakeContentHeader(Meta, Locale, Categories=''):
|
|||||||
Header = ''
|
Header = ''
|
||||||
for i in ['CreatedOn', 'EditedOn']:
|
for i in ['CreatedOn', 'EditedOn']:
|
||||||
if Meta[i]:
|
if Meta[i]:
|
||||||
Header += f"{Locale[i]}: {Meta[i]} \n"
|
Header += f'{Locale[i]}: {Meta[i]}<br>'
|
||||||
if Categories:
|
if Categories:
|
||||||
Header += f"{Locale['Categories']}: {Categories} \n"
|
Header += f"{Locale['Categories']}:{Categories.removesuffix(' ')}<br>"
|
||||||
return markdown(Header.rstrip())
|
return f'<p>{Header}</p>'
|
||||||
|
|
||||||
def MakeCategoryLine(File, Meta):
|
def MakeCategoryLine(File, Meta):
|
||||||
Categories = ''
|
Categories = ''
|
||||||
if Meta['Categories']:
|
if Meta['Categories']:
|
||||||
for i in Meta['Categories']:
|
for Cat in Meta['Categories']:
|
||||||
Categories += f" [{i}]({GetPathLevels(File)}Categories/{i}.html) "
|
Categories += f' <a href="{GetPathLevels(File)}Categories/{Cat}.html">{html.escape(Cat)}</a> '
|
||||||
return Categories
|
return Categories
|
||||||
|
|
||||||
def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, Unite=[], Type='Page', Category=None, For='Menu', MarkdownExts=(), MenuStyle='Default'):
|
def GetHTMLPagesList(Pages, BlogName, SiteRoot, PathPrefix, Unite=[], Type='Page', Category=None, For='Menu', MarkdownExts=(), MenuStyle='Default'):
|
||||||
@ -265,16 +265,16 @@ def MakeListTitle(File, Meta, Titles, Prefer, SiteRoot, BlogName, PathPrefix='')
|
|||||||
|
|
||||||
def FormatTitles(Titles, Flatten=False):
|
def FormatTitles(Titles, Flatten=False):
|
||||||
# TODO: Somehow titles written in Pug can end up here and don't work, they should be handled
|
# TODO: Somehow titles written in Pug can end up here and don't work, they should be handled
|
||||||
MDTitles, DashyTitles = '', []
|
HTMLTitles, DashyTitles = '', []
|
||||||
for t in Titles:
|
for t in Titles:
|
||||||
n = t.split(' ')[0].count('#')
|
n = 0 if Flatten else t.split(' ')[0].count('#')
|
||||||
Heading = '- ' * (n if not Flatten else 1)
|
|
||||||
Title = MkSoup(t.lstrip('#')).get_text()
|
Title = MkSoup(t.lstrip('#')).get_text()
|
||||||
DashyTitle = DashifyTitle(Title, DashyTitles)
|
DashyTitle = DashifyTitle(Title, DashyTitles)
|
||||||
DashyTitles += [DashyTitle]
|
DashyTitles += [DashyTitle]
|
||||||
Title = f"[{Title}](#{DashyTitle})"
|
Start = '<ul><li>' * (n - 1)
|
||||||
MDTitles += Heading + Title + '\n'
|
End = '</li></ul>' * (n - 1)
|
||||||
return markdown(MDTitles)
|
HTMLTitles += f'<li>{Start}<a href="#{DashyTitle}">{html.escape(Title)}</a>{End}</li>'
|
||||||
|
return f'<ul>{HTMLTitles}</ul>'
|
||||||
|
|
||||||
def OrderPages(Old):
|
def OrderPages(Old):
|
||||||
New, NoOrder, Max = [], [], 0
|
New, NoOrder, Max = [], [], 0
|
||||||
@ -314,6 +314,7 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
|
|||||||
BodyImage = Soup.img['src']
|
BodyImage = Soup.img['src']
|
||||||
|
|
||||||
#Content = SquareFnrefs(Content)
|
#Content = SquareFnrefs(Content)
|
||||||
|
if '<a class="footnote-ref"' in Content:
|
||||||
Content = AddToTagStartEnd(Content, '<a class="footnote-ref"', '</a>', '[', ']')
|
Content = AddToTagStartEnd(Content, '<a class="footnote-ref"', '</a>', '[', ']')
|
||||||
|
|
||||||
Title = GetTitle(File.split('/')[-1], Meta, Titles, 'MetaTitle', BlogName)
|
Title = GetTitle(File.split('/')[-1], Meta, Titles, 'MetaTitle', BlogName)
|
||||||
|
Reference in New Issue
Block a user