aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-09 10:54:46 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-09 10:54:46 -0500
commite5bc198de105c366cacd48d1d4a9fae63b699225 (patch)
tree60567aba052de2ff681c09d0ba4b1c88859d34a4
parentf295c5e4f34eb1e4bc73617acebf0f16b2d7ac4a (diff)
downloadold-guff-e5bc198de105c366cacd48d1d4a9fae63b699225.tar.bz2
old-guff-e5bc198de105c366cacd48d1d4a9fae63b699225.zip
fix tag urls
-rw-r--r--src/guff/handlers/blog.cr9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/guff/handlers/blog.cr b/src/guff/handlers/blog.cr
index 21e7db7..b961955 100644
--- a/src/guff/handlers/blog.cr
+++ b/src/guff/handlers/blog.cr
@@ -227,7 +227,7 @@ class Guff::Handlers::BlogHandler < Guff::Handler
tag: "
<li class='tag'>
<a
- href='%{name}/'
+ href='%{p}%{name}/'
title='View posts matching tag %{name}.'
>
%{name} (%{num_posts} posts)
@@ -237,12 +237,17 @@ class Guff::Handlers::BlogHandler < Guff::Handler
})
private def draw_tags(context, tags)
+ # generate tag url prefix
+ p = (context.request.path || "").match(/\/$/) ? "" : "./tag/"
+
# create page
page = PageHTMLView.new(
title: "Tags",
body: TAG_TEMPLATES[:body].run({
"tags": tags.map { |row|
- TAG_TEMPLATES[:tag].run(row.reduce({} of String => String) do |r, k, v|
+ TAG_TEMPLATES[:tag].run(row.reduce({
+ "p": p
+ }) do |r, k, v|
r[k] = HTML.escape(v.to_s)
r
end)