summaryrefslogtreecommitdiff
path: root/html.rb
blob: da736600c0e64557768b96c855fe8fb10771ef17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env ruby
ROOT = ARGV[0]
SNIPPETS = File.join(File.dirname(__FILE__), "snippets")
tree = {
  "music" => Dir[File.join(ROOT, "music", "*")],
  "videos" => Dir[File.join(ROOT, "videos", "*")],
}

def html src
  cat = File.basename(src, ".html")
  html = File.read(File.join(SNIPPETS, "head.html"))
  html += "<nav>\n"
  html += "<a href='/about.html'><img src='/pdp8.png' id='logo' alt='pdp8'></a>\n"
  ["music", "pictures", "videos", "code", "newsletter"].each do |c|
    c == cat ? cl = 'item current' : cl = 'item'
    html += "<a class='#{cl}' href='/#{c}.html'>#{c}</a>\n"
  end
  html += "<a id='menu' href='#' onclick='show_vertical_menu()'>\n"
  html += "<div class='fa fa-bars' aria-hidden='true'></div>\n"
  html += "</a>\n"
  html += "</nav>\n"
  case cat
  when "music"
    html += music src
  when "videos"
    html += videos src
  else
    html += File.read(src)
  end
  html += File.read(File.join(SNIPPETS, "tail.html"))
  out = File.join(ROOT, cat + ".html")
  puts out
  File.open(out, "w+") { |f| f.puts html }
  puts `tidy -iqm -w 80 #{out} 2>&1`
  # puts `echo "#{html}" > #{out} `
end

["about", "code", "pictures", "info", "newsletter"].each do |cat|
  html File.join(SNIPPETS, cat + ".html")
end

["pdp8.png", "style.css", "distances.js", "images.js"].each { |f| `cp "#{File.join(SNIPPETS, f)}" "#{ROOT}"` }
# rss