From 0555b2cd77986d916968f1443e375fad005c8d43 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 4 Mar 2024 23:13:40 +0100 Subject: html.rb separated, Makefile for website generation --- lib.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 lib.rb (limited to 'lib.rb') 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 = '' + html +end + +def file_html(basename) + path = File.join(SNIPPETS, basename + '.html') + html = File.read(File.join(SNIPPETS, 'head.html')) + html += nav basename + html += "
" + html += File.read(path) + html += '
' + 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 -- cgit v1.2.3