fix harp compilation & DRY things up

This commit is contained in:
Sami Samhuri 2014-02-15 18:55:40 -08:00
parent 4e991d461e
commit 9558ee8f91
4 changed files with 18 additions and 11 deletions

View file

@ -1,12 +1,13 @@
#!/bin/bash
bin/rss.rb public
# bail on errors
set -e
mkdir -p www
harp compile public www
bin/rss.rb public
harp compile . www
for FILENAME in www/*.html www/posts/*.html www/projects/*.html; do
[[ "$FILENAME" = "index.html" ]] && continue
[[ "${FILENAME##*/}" = "index.html" ]] && continue
DIRNAME="${FILENAME%.html}"
mkdir -p "$DIRNAME"

View file

@ -59,13 +59,18 @@ class Blag
posts.first
end
def find_post dir, slug
# technically should look for slug.md, slug.html.md, etc.
File.join dir, slug + '.html.md'
end
def posts
@posts ||= begin
prefix = @dir + '/posts/'
json = File.read File.join(prefix, '_data.json')
data = JSON.parse json
data.map do |slug, post|
filename = File.join prefix, slug + '.md'
filename = find_post prefix, slug
content = File.read filename
post['slug'] = slug
post['type'] = post['link'] ? :link : :post
@ -124,7 +129,7 @@ private
def feed_xml
xml = Builder::XmlMarkup.new
xml.instruct! :xml, version: '1.0'
xml.instruct! 'xml-stylesheet', href: 'http://samhuri.net/css/style.css', type: 'text/css'
xml.instruct! 'xml-stylesheet', href: root_url + '/css/style.css', type: 'text/css'
xml.rss version: '2.0' do
xml.channel do

View file

@ -2,6 +2,7 @@
"globals": {
"site": "samhuri.net",
"author": "Sami Samhuri",
"email": "sami@samhuri.net",
"url": "http://samhuri.net",
"styles": [],
"scripts": []

View file

@ -16,26 +16,26 @@
<% for (var i in styles) { %>
<link rel="stylesheet" href="/css/<%= styles[i] %>.css">
<% } %>
<link rel="alternate" type="application/rss+xml" href="http://samhuri.net/feed.xml" title="samhuri.net">
<link rel="alternate" type="application/rss+xml" href="/feed.xml" title="<%= site %>">
</head>
<body>
<header>
<h1><a href="/">samhuri.net</a></h1>
<h4>by Sami Samhuri</h4>
<h1><a href="/"><%= site %></a></h1>
<h4>by <%= author %></h4>
</header>
<nav>
<a href="/archive">posts</a>
<a href="/projects">projects</a>
<a href="https://twitter.com/_sjs">twitter</a>
<a href="mailto:sami@samhuri.net">sami@samhuri.net</a>
<a href="mailto:<%= email %>"><%= email %></a>
</nav>
<%- yield %>
<footer>
Copyright &copy; 2006 - <%= new Date().getFullYear() %> <a href="mailto:sami@samhuri.net">Sami Samhuri</a>
Copyright &copy; 2006 - <%= new Date().getFullYear() %> <a href="mailto:<%= email %>"><%= author %></a>
</footer>
<% for (var i in scripts) { %>