diff options
Diffstat (limited to 'lib.rb')
-rwxr-xr-x | lib.rb | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +MEDIA_DIR = '/srv/media' +MEDIA_URL = 'https://media.pdp8.info' +WWW_DIR = '/srv/www/pdp8-test' +SNIPPETS = File.join(File.dirname(__FILE__), 'html') + +def nav(cat) + html = '<nav>' + html += "<a id='logo' href='/about.html'><img src='/pdp8.png' alt='pdp8'></a>" + %w[music pictures videos climbing code contact].each do |c| + cl = c == cat ? 'item current' : 'item' + html += " <a class='#{cl}' href='/#{c}.html'>#{c}</a>" + end + html += " <a class='item' href='/social/create.html'>social</a>" + html += " <a class='item' href='/rss.xml'>rss</a>" + html += " <a id='menu' href='#' onclick='show_vertical_menu()'>≡</a>" + html += '</nav>' + html +end + +def file_html(basename) + path = File.join(SNIPPETS, basename + '.html') + html = File.read(File.join(SNIPPETS, 'head.html')) + html += nav basename + html += "<div class='post'>" + html += File.read(path) + html += '</div>' + html += File.read(File.join(SNIPPETS, 'tail.html')) + print_html basename, html +end + +def print_html(basename, html) + out = File.join(WWW_DIR, basename + '.html') + puts out + File.open(out, 'w+') { |f| f.puts html } + puts `tidy -iqm -w 0 #{out} 2>&1` +end |