From: Zachary Vance Date: Sat, 3 Aug 2024 03:21:42 +0000 (-0400) Subject: Switch to final absolute URLs X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=e8528296b00bcac109910a3ce1be796e779b34fa;p=blog.git Switch to final absolute URLs --- diff --git a/blog b/blog index 92f2e5a..38d2a9f 100755 --- a/blog +++ b/blog @@ -179,7 +179,11 @@ class Templatable(PseudoMap): @property def url(self): - return self.blog.web_root + "/" + str(self.output_path.relative_to(Path(self.blog.destination))) + url_template = self.blog["{}_url".format(self.type)] + if url_template is None: + return self.blog.web_root + "/" + str(self.output_path.relative_to(Path(self.blog.destination))) + else: + return mustache.render(url_template, self.context) def render_template(source, blog, name, context, replace_links=True): template_path = blog["{}_template".format(name)] @@ -343,7 +347,7 @@ class Image(Templatable): class Blog(PseudoMap): def __init__(self, config="config.yaml", reload=False): - self.tags = {} + self.tags = {} # Tag -> str self.categories = {} self.authors = {} self._posts = [] @@ -366,6 +370,7 @@ class Blog(PseudoMap): if k.endswith("_dir") or k.endswith("_template") or k.endswith("_path"): v = os.path.join(self.source, os.path.expanduser(v)) self[k] = v + self.feed_url = mustache.render(self.feed_url, self) @property def deadlinks(self): @@ -487,10 +492,6 @@ class Blog(PseudoMap): return Templatable.render_template(Templatable, blog, "tagcloud", self) - @property - def feed_url(self): - return Page("feed", self, use_layout=False).url - def _update_happened(self, path): path = Path(path) reload_update = [ diff --git a/config.yaml b/config.yaml index 88d1a99..ea1ec32 100644 --- a/config.yaml +++ b/config.yaml @@ -1,9 +1,11 @@ # These two properties are always first, and always absolute paths source: "/home/zachary/blog" destination: "/home/zachary/blog/public" + web_root: "https://blog2.za3k.com" -domain: "blog2.za3k.com" title: 'blog of zachary "za3k" vance' +# For search bar +domain: "blog2.za3k.com" post_dir: "posts" comments_dir: "comments" @@ -13,26 +15,27 @@ static_dir: "static" author_template: "templates/author.mustache.html" category_template: "templates/category.mustache.html" -deadlinks_template: "templates/deadlinks.mustache.html" -links_template: "templates/links.mustache.html" index_template: "templates/index.mustache.html" feed_template: "templates/feed.mustache.html" layout_template: "templates/layout.mustache.html" post_template: "templates/post.mustache.html" -postcombined_template: "templates/postcombined.mustache.html" tag_template: "templates/tag.mustache.html" tagcloud_template: "templates/tagcloud.mustache.html" +# Non-local mode, preferred link address +author_url: "{{web_root}}/author/{{slug}}/" +category_url: "{{web_root}}/category/{{slug}}/" +tag_url: "{{web_root}}/tag/{{slug}}/" +index_url: "{{web_root}}" +post_url: "{{web_root}}/{{id}}/" +feed_url: "{{web_root}}/feed/" + author_destination: "{{destination}}/author/{{slug}}.html" category_destination: "{{destination}}/category/{{slug}}.html" -deadlinks_destination: "{{destination}}/page/deadlinks.html" -links_destination: "{{destination}}/page/links.html" index_destination: "{{destination}}/page/index.html" feed_destination: "{{destination}}/page/feed.xml" image_destination: "{{destination}}/images/{{image}}" page_destination: "{{destination}}/{{page}}" post_destination: "{{destination}}/posts/{{id}}.html" -post_md_destination: "{{destination}}/posts/{{id}}.md.html" -post_html_destination: "{{destination}}/posts/{{id}}.orig.html" static_destination: "{{destination}}/{{relative_path}}" tag_destination: "{{destination}}/tag/{{slug}}.html" diff --git a/static/style-wordpress.css b/static/css/style-wordpress.css similarity index 100% rename from static/style-wordpress.css rename to static/css/style-wordpress.css diff --git a/static/resources/images/RSS.png b/static/images/RSS.png similarity index 100% rename from static/resources/images/RSS.png rename to static/images/RSS.png diff --git a/static/resources/images/Twitter.png b/static/resources/images/Twitter.png deleted file mode 100644 index 8e2d0aa..0000000 Binary files a/static/resources/images/Twitter.png and /dev/null differ diff --git a/templates/author.mustache.html b/templates/author.mustache.html index ec6c322..c2b63f1 100644 --- a/templates/author.mustache.html +++ b/templates/author.mustache.html @@ -1,5 +1,5 @@ {{# posts.first10 }} diff --git a/templates/feed.mustache.html b/templates/feed.mustache.html index 22b7ce5..7ab22f9 100644 --- a/templates/feed.mustache.html +++ b/templates/feed.mustache.html @@ -19,7 +19,7 @@ {{# posts.first10 }} {{title}} - {{web_root}}/post/{{id}}.html + {{url}} {{date_rfc822}} {{# categories }} diff --git a/templates/layout.mustache.html b/templates/layout.mustache.html index 1576180..85dfdeb 100644 --- a/templates/layout.mustache.html +++ b/templates/layout.mustache.html @@ -7,7 +7,7 @@ - + @@ -24,10 +24,7 @@
blog of zachary "za3k" vance
@@ -37,8 +34,8 @@ diff --git a/templates/post.mustache.html b/templates/post.mustache.html index f0a6f18..a6309d7 100644 --- a/templates/post.mustache.html +++ b/templates/post.mustache.html @@ -7,7 +7,7 @@