Add rel.canonical to redirects; Added alias for internal macros

This commit is contained in:
2022-11-02 00:17:36 +01:00
parent f7773ea226
commit 4187e0647d
5 changed files with 14 additions and 5 deletions

View File

@ -40,7 +40,7 @@ Needed for Gemtext output support:
## Features roadmap ## Features roadmap
- [ ] HTML feeds (pages with list of N most recent posts) - [x] HTML feeds (pages with list of N most recent posts)
- [x] Lists of all pages in a site directory - [x] Lists of all pages in a site directory
- [x] Page redirects / Alt URLs (+ ActivityPub URL overrides) - [x] Page redirects / Alt URLs (+ ActivityPub URL overrides)
- [x] Progress bars for the build process! - [x] Progress bars for the build process!

View File

@ -248,6 +248,7 @@ def Main(Args, FeedEntries):
WriteFile( WriteFile(
DestFile, DestFile,
RedirectPageTemplate.format( RedirectPageTemplate.format(
SiteDomain=SiteDomain,
DestURL=DestURL, DestURL=DestURL,
TitlePrefix=f"{SiteName} - " if SiteName else '', TitlePrefix=f"{SiteName} - " if SiteName else '',
StrClick=Locale['ClickHere'], StrClick=Locale['ClickHere'],

View File

@ -25,11 +25,12 @@ RedirectPageTemplate = """\
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>{TitlePrefix}Redirect</title> <title>{TitlePrefix}Redirect</title>
<meta http-equiv="refresh" content="0; url='{DestURL}'" /> <link rel="canonical" href="{SiteDomain}/{DestURL}">
<meta http-equiv="refresh" content="0; url='{DestURL}'">
</head> </head>
<body> <body>
<p><a href="{DestURL}">{StrClick}</a> {StrRedirect}.</p> <p><a href="{DestURL}">{StrClick}</a> {StrRedirect}.</p>
</body> </body>
</html> </html>
""" """

View File

@ -347,6 +347,7 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
for e in Meta['Macros']: for e in Meta['Macros']:
HTML = ReplWithEsc(HTML, f"[:{e}:]", Meta['Macros'][e]) HTML = ReplWithEsc(HTML, f"[:{e}:]", Meta['Macros'][e])
for e in FolderRoots: for e in FolderRoots:
HTML = ReplWithEsc(HTML, f"<staticoso:CustomPath:{e}>", FolderRoots[e])
HTML = ReplWithEsc(HTML, f"[staticoso:Folder:{e}:AbsoluteRoot]", FolderRoots[e]) HTML = ReplWithEsc(HTML, f"[staticoso:Folder:{e}:AbsoluteRoot]", FolderRoots[e])
HTML = ReplWithEsc(HTML, f"<staticoso:Folder:{e}:AbsoluteRoot>", FolderRoots[e]) HTML = ReplWithEsc(HTML, f"<staticoso:Folder:{e}:AbsoluteRoot>", FolderRoots[e])
for e in Categories: for e in Categories:
@ -362,6 +363,7 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
'<staticoso:PageTitle>': Title, '<staticoso:PageTitle>': Title,
'[staticoso:Page:Description]': Description, '[staticoso:Page:Description]': Description,
'<staticoso:PageDescription>': Description, '<staticoso:PageDescription>': Description,
'<staticoso:SiteDomain>': SiteDomain,
'[staticoso:Site:Name]': SiteName, '[staticoso:Site:Name]': SiteName,
'<staticoso:SiteName>': SiteName, '<staticoso:SiteName>': SiteName,
'[staticoso:Site:AbsoluteRoot]': SiteRoot, '[staticoso:Site:AbsoluteRoot]': SiteRoot,
@ -372,6 +374,7 @@ def PatchHTML(File, HTML, StaticPartsText, DynamicParts, DynamicPartsText, HTMLP
for e in Meta['Macros']: for e in Meta['Macros']:
ContentHTML = ReplWithEsc(ContentHTML, f"[:{e}:]", Meta['Macros'][e]) ContentHTML = ReplWithEsc(ContentHTML, f"[:{e}:]", Meta['Macros'][e])
for e in FolderRoots: for e in FolderRoots:
ContentHTML = ReplWithEsc(ContentHTML, f"<staticoso:CustomPath:{e}>", FolderRoots[e])
ContentHTML = ReplWithEsc(ContentHTML, f"[staticoso:Folder:{e}:AbsoluteRoot]", FolderRoots[e]) ContentHTML = ReplWithEsc(ContentHTML, f"[staticoso:Folder:{e}:AbsoluteRoot]", FolderRoots[e])
ContentHTML = ReplWithEsc(ContentHTML, f"<staticoso:Folder:{e}:AbsoluteRoot>", FolderRoots[e]) ContentHTML = ReplWithEsc(ContentHTML, f"<staticoso:Folder:{e}:AbsoluteRoot>", FolderRoots[e])
for e in Categories: for e in Categories:

6
TODO
View File

@ -1,5 +1,9 @@
- Release on pip
- Alert for deprecated features
- WriteFreely/Wordpress/Blogger integration for reposting+comments
- Fix comment box not appearing in pages with changed URL
- Set categories for all files in a folder and subfolder - Set categories for all files in a folder and subfolder
- Pages with lists of all posts and all pages (? the folder categories thing might make it redundant?) - Pages with lists of all posts and all pages (? the folder lists thing might make it redundant?)
- Fix title detection: - Fix title detection:
- Don't consider titles in code/comment blocks - Don't consider titles in code/comment blocks
- Consider titles in lists (title marker preceded by chars) - Consider titles in lists (title marker preceded by chars)