mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
fix harp compilation & DRY things up
This commit is contained in:
parent
4e991d461e
commit
9558ee8f91
4 changed files with 18 additions and 11 deletions
|
|
@ -1,12 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
bin/rss.rb public
|
# bail on errors
|
||||||
|
set -e
|
||||||
|
|
||||||
mkdir -p www
|
bin/rss.rb public
|
||||||
harp compile public www
|
harp compile . www
|
||||||
|
|
||||||
for FILENAME in www/*.html www/posts/*.html www/projects/*.html; do
|
for FILENAME in www/*.html www/posts/*.html www/projects/*.html; do
|
||||||
[[ "$FILENAME" = "index.html" ]] && continue
|
[[ "${FILENAME##*/}" = "index.html" ]] && continue
|
||||||
|
|
||||||
DIRNAME="${FILENAME%.html}"
|
DIRNAME="${FILENAME%.html}"
|
||||||
mkdir -p "$DIRNAME"
|
mkdir -p "$DIRNAME"
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,18 @@ class Blag
|
||||||
posts.first
|
posts.first
|
||||||
end
|
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
|
def posts
|
||||||
@posts ||= begin
|
@posts ||= begin
|
||||||
prefix = @dir + '/posts/'
|
prefix = @dir + '/posts/'
|
||||||
json = File.read File.join(prefix, '_data.json')
|
json = File.read File.join(prefix, '_data.json')
|
||||||
data = JSON.parse json
|
data = JSON.parse json
|
||||||
data.map do |slug, post|
|
data.map do |slug, post|
|
||||||
filename = File.join prefix, slug + '.md'
|
filename = find_post prefix, slug
|
||||||
content = File.read filename
|
content = File.read filename
|
||||||
post['slug'] = slug
|
post['slug'] = slug
|
||||||
post['type'] = post['link'] ? :link : :post
|
post['type'] = post['link'] ? :link : :post
|
||||||
|
|
@ -124,7 +129,7 @@ private
|
||||||
def feed_xml
|
def feed_xml
|
||||||
xml = Builder::XmlMarkup.new
|
xml = Builder::XmlMarkup.new
|
||||||
xml.instruct! :xml, version: '1.0'
|
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.rss version: '2.0' do
|
||||||
xml.channel do
|
xml.channel do
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"globals": {
|
"globals": {
|
||||||
"site": "samhuri.net",
|
"site": "samhuri.net",
|
||||||
"author": "Sami Samhuri",
|
"author": "Sami Samhuri",
|
||||||
|
"email": "sami@samhuri.net",
|
||||||
"url": "http://samhuri.net",
|
"url": "http://samhuri.net",
|
||||||
"styles": [],
|
"styles": [],
|
||||||
"scripts": []
|
"scripts": []
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,26 @@
|
||||||
<% for (var i in styles) { %>
|
<% for (var i in styles) { %>
|
||||||
<link rel="stylesheet" href="/css/<%= styles[i] %>.css">
|
<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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1><a href="/">samhuri.net</a></h1>
|
<h1><a href="/"><%= site %></a></h1>
|
||||||
<h4>by Sami Samhuri</h4>
|
<h4>by <%= author %></h4>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<a href="/archive">posts</a>
|
<a href="/archive">posts</a>
|
||||||
<a href="/projects">projects</a>
|
<a href="/projects">projects</a>
|
||||||
<a href="https://twitter.com/_sjs">twitter</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>
|
</nav>
|
||||||
|
|
||||||
<%- yield %>
|
<%- yield %>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Copyright © 2006 - <%= new Date().getFullYear() %> <a href="mailto:sami@samhuri.net">Sami Samhuri</a>
|
Copyright © 2006 - <%= new Date().getFullYear() %> <a href="mailto:<%= email %>"><%= author %></a>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<% for (var i in scripts) { %>
|
<% for (var i in scripts) { %>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue