From e136b97746a85cf1e127e535d7bd7e67f4d86c66 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Thu, 7 May 2020 16:35:24 +0200 Subject: [PATCH] Now that we have conditional static templating, get rid of redundant templating variables (allTaggedPage + latestTaggedPage) --- share/defaultWording.conf | 6 ++---- share/js/domRenderer.js | 7 +------ src/ArticlesList.hs | 9 +++------ src/Blog/Wording.hs | 6 ++---- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/share/defaultWording.conf b/share/defaultWording.conf index 3c21d86..21b431b 100644 --- a/share/defaultWording.conf +++ b/share/defaultWording.conf @@ -1,12 +1,10 @@ allLink = See all -allPage = All articles -allTaggedPage = All articles tagged ${tag} +allPage = All articles{? tagged ${tag}?} commentsLink = Comment on the fediverse commentsSection = Comments dateFormat = en-US latestLink = See only latest -latestPage = Latest articles -latestTaggedPage = Latest articles tagged ${tag} +latestPage = Latest articles{? tagged ${tag}?} metadata = {?by ${author} ?}on ${date}{? tagged ${tags}?} rssLink = Subscribe rssTitle = Follow all articles{? tagged ${tag}?} diff --git a/share/js/domRenderer.js b/share/js/domRenderer.js index 1a28d36..bafa9aa 100644 --- a/share/js/domRenderer.js +++ b/share/js/domRenderer.js @@ -66,12 +66,7 @@ function DomRenderer(modules) { } function pageTitle(tag, all) { - if(tag != undefined) { - var template = all ? 'allTaggedPage' : 'latestTaggedPage'; - return modules.template.render(template, {tag: tag}); - } else { - return blog.wording[all ? 'allPage' : 'latestPage']; - } + return modules.template.render(all ? 'allPage' : 'latestPage', {tag: tag}); } function otherUrl(tag, all) { diff --git a/src/ArticlesList.hs b/src/ArticlesList.hs index 489aa35..c111be0 100644 --- a/src/ArticlesList.hs +++ b/src/ArticlesList.hs @@ -34,13 +34,10 @@ otherURL (ArticlesList {full, collection}) = absoluteLink $ description :: Renderer m => ArticlesList -> m Text description (ArticlesList {full, collection}) = - getDescription (full, tag collection) + template page . environment $ tag collection where - getDescription (True, Nothing) = template "allPage" [] - getDescription (True, Just tag) = template "allTaggedPage" [("tag", pack tag)] - getDescription (False, Nothing) = template "latestPage" [] - getDescription (False, Just tag) = - template "latestTaggedPage" [("tag", pack tag)] + page = if full then "allPage" else "latestPage" + environment = maybe [] $ \value -> [("tag", pack value)] rssLinkTexts :: Renderer m => ArticlesList -> m (Text, Text) rssLinkTexts (ArticlesList {collection}) = do diff --git a/src/Blog/Wording.hs b/src/Blog/Wording.hs index 9caec83..e393db8 100644 --- a/src/Blog/Wording.hs +++ b/src/Blog/Wording.hs @@ -25,14 +25,12 @@ newtype Wording = Wording (Map String Text) variables :: Map String [Text] variables = Map.fromList [ ("allLink", []) - , ("allPage", []) - , ("allTaggedPage", ["tag"]) + , ("allPage", ["tag"]) , ("commentsLink", []) , ("commentsSection", []) , ("dateFormat", []) , ("latestLink", []) - , ("latestPage", []) - , ("latestTaggedPage", ["tag"]) + , ("latestPage", ["tag"]) , ("metadata", ["author", "date", "tags"]) , ("rssLink", []) , ("rssTitle", ["tag"])