summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-03 20:18:45 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-03 20:18:45 -0500
commit5449dca686d7bdbd5f09acd4e9fd8647535acde9 (patch)
tree2e1b459c517974d9f57c0b52924d49e0ba86afca /bin
parent877491a97c2ac140003c6416dbd33630148bb860 (diff)
index.yaml partial support
Diffstat (limited to 'bin')
-rwxr-xr-xbin/index19
-rw-r--r--bin/index.atom.erb8
-rw-r--r--bin/index.md.erb2
-rw-r--r--bin/util.rb1
4 files changed, 21 insertions, 9 deletions
diff --git a/bin/index b/bin/index
index 4f41c5d..2443380 100755
--- a/bin/index
+++ b/bin/index
@@ -1,16 +1,29 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
load 'util.rb'
+require 'yaml'
+# ARGV[0]
template = "bin/index.#{ARGV.shift}.erb"
+erb = ERB.new(File.read(template));
+erb.filename = template
+
+# ARGV[1]
@path = ARGV.shift
+indexyaml = @path.sub('out', 'src')+'/index.yaml'
+if File.exists?(indexyaml)
+ metadata = YAML::load(File.read(indexyaml))
+else
+ metadata = {}
+end
+
+# ARGV[2..]
@pages = []
for filename in ARGV do
@pages.push(Page.new(filename))
end
-
-erb = ERB.new(File.read(template));
-erb.filename = template
+# main
+@title = metadata['title'] || @path.sub('out', '')
erb.run()
diff --git a/bin/index.atom.erb b/bin/index.atom.erb
index 0667088..1afbf8c 100644
--- a/bin/index.atom.erb
+++ b/bin/index.atom.erb
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
- <title>AndrewDM.me <%= @path %></title>
+ <title>AndrewDM.me <%= @title %></title>
<link rel="self" type="application/atom+xml" href="./index.atom"/>
<link rel="alternate" type="text/html" href="./"/>
<link rel="alternate" type="text/markdown" href="./index.md"/>
@@ -11,9 +11,9 @@
<% @pages.sort_by{|p| p.updated}.reverse.each do |page| %>
<entry xmlns="http://www.w3.org/2005/Atom">
- <link rel="alternate" type="text/html" href="./<%= page.slug %>.html"/>
- <link rel="alternate" type="text/markdown" href="./<%= page.slug %>.md"/>
- <id>https://lukeshu.com/blog/<%= page.slug %>.html</id>
+ <link rel="alternate" type="text/html" href="<%= page.url %>.html"/>
+ <link rel="alternate" type="text/markdown" href="<%= page.url %>.md"/>
+ <id>https://andrewdm.me/<%= page.url %></id>
<updated><%= page.updated.rfc3339 %></updated>
<published><%= page.published.rfc3339 %></published>
<title><%= page.title %></title>
diff --git a/bin/index.md.erb b/bin/index.md.erb
index 621a323..ce5e030 100644
--- a/bin/index.md.erb
+++ b/bin/index.md.erb
@@ -1,5 +1,5 @@
---
-title: "<%= @path %>"
+title: "<%= @title %>"
class: "index"
---
diff --git a/bin/util.rb b/bin/util.rb
index 1318f28..05808b7 100644
--- a/bin/util.rb
+++ b/bin/util.rb
@@ -115,7 +115,6 @@ class Page
def author ; @author ||= Person.new( pandoc['author'] || "Andrew Murrell") ; end
def license ; @license ||= License.new(pandoc['license'] || "CC BY-SA-3.0") ; end
- def slug ; @slug ||= infile.sub(/\..*$/,'').sub(/^.*\//,'') ; end
def content ; @content ||= pandoc.to('html5 '+(pandoc['pandoc_flags']||'')) ; end
def head ; @head ||= pandoc['html_head_extra'] ; end
def class ; @class ||= pandoc['class'] ; end