summaryrefslogtreecommitdiff
path: root/bin/util.rb
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-12-31 18:21:44 -0700
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-12-31 18:21:44 -0700
commit7445ea9d56071cfca247689e22c6fded65c3f968 (patch)
treefecb17db0eb37368c052e26d4e38a83d1ad5cb2b /bin/util.rb
parent7b11decd6a4b7f484ad35ae623941f21af7d31ec (diff)
fix breadcrumbs
Diffstat (limited to 'bin/util.rb')
-rw-r--r--bin/util.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/bin/util.rb b/bin/util.rb
index ce91007..d95ddba 100644
--- a/bin/util.rb
+++ b/bin/util.rb
@@ -98,8 +98,23 @@ class Page
"<p>This page is licensed under the #{license.html} license.</p>"
end
+ def src
+ @src ||= infile.sub(/^(src|out)\//, '/')
+ end
+
def breadcrumbs
- @breadcrumbs ||= '<a href="/">Andrew Murrell</a> » ' + ( (slug == 'index') ? "blog" : "<a href=/blog>blog</a> » #{slug}" )
+ if @breadcrumbs.nil?
+ bc = []
+ url = src.sub(/\.[^\/.]*$/, '.html').sub(/\/index[.]html$/, '')
+ url = '/' if url == ''
+ while url != "/"
+ bc.unshift("<a href=\"#{url}\">#{File.basename(url, File.extname(url))}</a>")
+ url = File.dirname(url)
+ end
+ bc.unshift("<a href=\"#{url}\">Andrew D. Murrell</a>")
+ @breadcrumbs = bc.join(' » ')
+ end
+ @breadcrumbs
end
end