summaryrefslogtreecommitdiff
path: root/bin/index
blob: dc57798f779c6b1b3f008a24dd141c8d31037cca (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
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
load 'util.rb'
require 'yaml'

# ARGV[0]
type = ARGV.shift
template = "bin/index.#{type}.erb"
erb = ERB.new(File.read(template));
erb.filename = template

# ARGV[1]
@path = ARGV.shift
webpath = (@path+'/').sub(/^(src|out)\//, '/')
if type == 'atom'
	webpath += 'index.atom'
end
@url = URI::parse('https://www.andrewdm.me') + webpath

indexyaml = @path.sub('out', 'src')+'/index.yaml'
if File.exists?(indexyaml)
	metadata = YAML::load(File.read(indexyaml))
else
	metadata = {}
end

# ARGV[2..]
@pages = []
for filename in ARGV do
	@pages.push(Page.new(filename))
end

# main
@title = metadata['title'] || @path.sub('out', '')
erb.run()