~sivers/sive.rs

sive.rs/script/presentations.rb -rwxr-xr-x 885 bytes
5fcf6634 — Derek Sivers cover and hardcover 20 hours ago
                                                                                
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
#!/usr/bin/env ruby
require_relative 'init.rb'

files = Dir[ROOT + 'content/presentations/*']
template = File.read(ROOT + 'templates/presentation.mustache')

def parse(fn)
  res = meta(fn)
  res[:body] = body(fn)
  res[:uri] = File.basename(fn)
  res[:year] = res[:month][0,4]
  res[:bodyid] = 'presentation'
  res[:pagetitle] = res[:title].dup
  res[:pagedescription] = res[:subtitle].dup
  res
end

presentations = files.map {|fn| parse(fn)}

presentations.each do |presentation|
  wput(presentation[:uri], page(template, presentation))
end

vars = {}
vars[:bodyid] = 'presentations'
vars[:pagetitle] = 'TED talks, conference talks, and presentations'
vars[:pagedescription] = 'TED talks, conference talks, and presentations'
vars[:presentations] = presentations.sort_by {|x| x[:month]}.reverse
wput('presentations', page(File.read(ROOT + 'templates/presentations.mustache'), vars))