~sivers/sive.rs

sive.rs/script/interviews.rb -rwxr-xr-x 958 bytes
5fcf6634 — Derek Sivers cover and hardcover 18 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
30
31
32
33
34
#!/usr/bin/env ruby
require_relative 'init.rb'

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

def parse(fn)
  res = meta(fn)
  res[:body] = body(fn)
  res[:uri] = File.basename(fn)
  res[:year] = res[:date][0,4]
  if res[:downloads]
    res[:medialinks] = res[:downloads].map do |x|
      '<a href="https://m.sive.rs/%s">%s</a>' % [x, x[-3,3]]
    end.join(' or ')
  end
  res[:bodyid] = 'interview'
  res[:pagetitle] = res[:title].dup
  res[:pagedescription] = res[:subtitle].dup
  res
end

interviews = files.map {|fn| parse(fn)}.sort_by {|x| x[:date]}

interviews.each do |interview|
  wput(interview[:uri], page(template, interview))
end

vars = {}
vars[:bodyid] = 'interviews'
vars[:pagetitle] = 'interviews'
vars[:pagedescription] = 'Derek Sivers interviews'
vars[:interviews] = interviews.sort_by {|x| x[:date]}.reverse
wput('i', page(File.read(ROOT + 'templates/interviews.mustache'), vars))