summaryrefslogtreecommitdiff
path: root/bin
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
parent7b11decd6a4b7f484ad35ae623941f21af7d31ec (diff)
fix breadcrumbs
Diffstat (limited to 'bin')
-rw-r--r--bin/page.html.erb3
-rw-r--r--bin/util.rb17
2 files changed, 18 insertions, 2 deletions
diff --git a/bin/page.html.erb b/bin/page.html.erb
index 6f56573..a8e5154 100644
--- a/bin/page.html.erb
+++ b/bin/page.html.erb
@@ -10,7 +10,8 @@
<body>
<header>
<h1>Andrew D. Murrell</h1>
- <p><%= @page.breadcrumbs %></p>
+ <p><%= @page.breadcrumbs %>
+ (<a href="<%= File.basename(@page.src) %>"><%= File.extname(@page.src).upcase %></a>)</p>
<nav>
<ul>
<li><a href="/">Projects</a>
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