Revision 3102,
826 bytes
checked in by daisuke, 13 years ago
(diff) |
HTMLヘッダの<title>にページタイトルを埋め込むように変更
|
Rev | Line | |
---|
[1284] | 1 | #!/usr/bin/ruby |
---|
| 2 | require 'erb' |
---|
| 3 | |
---|
| 4 | contentsdir = 'contents.d/' |
---|
| 5 | tmpdir = 'template/' |
---|
| 6 | |
---|
| 7 | class Layout |
---|
| 8 | extend ERB::DefMethod |
---|
| 9 | def_erb_method('layout', 'template/layout.html.erb') |
---|
| 10 | def_erb_method('layout_top', 'template/layout-top.html.erb') |
---|
| 11 | end |
---|
| 12 | |
---|
| 13 | Dir.foreach(contentsdir).grep(/.html$/) do |filename| |
---|
| 14 | template = ERB.new(IO.read(contentsdir+filename),nil,'<>') |
---|
| 15 | newfile = open(filename, "w") |
---|
[3102] | 16 | header_title_base = 'Vine Linux' |
---|
[1284] | 17 | if filename == "index.html" |
---|
| 18 | newfile.puts Layout.new.layout_top { template.result } |
---|
| 19 | else |
---|
[3102] | 20 | title=File.read(contentsdir+filename).grep(/h1 class=\"title/) |
---|
| 21 | if title[0] |
---|
| 22 | $header_title = header_title_base+' - '+title[0].gsub(/.*>(.*)<.*/,"\\1").chomp |
---|
| 23 | else |
---|
| 24 | $header_title = header_title_base |
---|
| 25 | end |
---|
[1284] | 26 | newfile.puts Layout.new.layout { template.result } |
---|
| 27 | end |
---|
| 28 | newfile.close |
---|
| 29 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.