forked from sachackerlab/sachackerlab.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inline_includes.rb
executable file
·40 lines (34 loc) · 947 Bytes
/
inline_includes.rb
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
#! /usr/bin/env ruby
header = File.read('./include/header.html')
footer = File.read('./include/footer.html')
Dir.glob('*.html') do |item|
next if item == '.' or item == '..'
puts "Processing #{item}..."
skipping = false
out = ""
File.open(item, 'r') do |f|
f.each_line do |line|
if line.include? "<!--header-->" then
out << line
skipping = true
elsif line.include? "<!--end header-->"
if item == "index.html"
out << header.gsub( "$CLASS$", "homepage" )
else
out << header.gsub( "$CLASS$", "" )
end
skipping = false
elsif line.include? "<!--footer-->" then
out << line
skipping = true
elsif line.include? "<!--end footer-->"
out << footer
skipping = false
end
if not skipping
out << line
end
end
end
File.open(item, 'w') { |file| file.write(out) }
end