summaryrefslogtreecommitdiff
path: root/lib.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib.rb')
-rwxr-xr-xlib.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib.rb b/lib.rb
new file mode 100755
index 0000000..3a94d39
--- /dev/null
+++ b/lib.rb
@@ -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 += "&nbsp;<a class='#{cl}' href='/#{c}.html'>#{c}</a>"
+ end
+ html += "&nbsp;<a class='item' href='/social/create.html'>social</a>"
+ html += "&nbsp;<a class='item' href='/rss.xml'>rss</a>"
+ html += "&nbsp;<a id='menu' href='#' onclick='show_vertical_menu()'>&equiv;</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