summaryrefslogtreecommitdiff
path: root/bin/index
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-04 17:13:22 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-04 17:13:22 -0500
commit90e593e800e62b1605a8052a54e0ab3371dd3dde (patch)
tree35290948b249e6e756a3fdf6724fc8aa2bb4c6af /bin/index
parent5e257d407b4abf2be61c656dfb1d383396df35b1 (diff)
implement sections
Diffstat (limited to 'bin/index')
-rwxr-xr-xbin/index24
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/index b/bin/index
index 48968a3..c04618d 100755
--- a/bin/index
+++ b/bin/index
@@ -15,7 +15,7 @@ webpath = (@path+'/').sub(/^(src|out)\//, '/')
if type == 'atom'
webpath += 'index.atom'
end
-@url = URI::parse('https://www.andrewdm.me') + webpath
+@url = URI::parse('https://www.andrewdm.me/') + webpath
indexyaml = @path.sub('out', 'src')+'/index.yaml'
if File.exists?(indexyaml)
@@ -36,4 +36,26 @@ end
# main
@title = metadata['title'] || @path.sub('out', '')
+
+def guess_section(page)
+ for path in @sections.keys do
+ if @url.route_to(page.url).to_s.start_with?(path+'/')
+ return path
+ end
+ end
+ return ''
+end
+
+@sections = { '' => {'head' => '', 'body' => []} }
+(metadata['sections'] || []).each do |path, name|
+ @sections[path] = {
+ 'head' => name,
+ 'body' => []
+ }
+end
+for page in @pages do
+ section = page.section || guess_section(page)
+ @sections[section]['body'].push(page)
+end
+
erb.run()