-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_swf_index_page
More file actions
executable file
·47 lines (32 loc) · 997 Bytes
/
build_swf_index_page
File metadata and controls
executable file
·47 lines (32 loc) · 997 Bytes
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
41
42
43
#!/usr/bin/env ruby
files = Dir.glob('*.html') + Dir.glob('*.swf')
list = Hash.new {|h,k| h[k] = {}}
files.each do |file|
next if File.basename(file) == "index.html"
list[File.basename(file, File.extname(file))][File.extname(file)] = file
end
File.open("index.html", "w") do |file|
file.puts "list has #{list.size} items"
file.puts "<HTML><HEAD><TITLE>Index for folder</TITLE></HEAD><BODY>"
file.puts '<table border="0">'
list.keys.sort.each do |key|
item = " <tr><td><b>#{key}:</b></td>"
item += "<td>";
item += if list[key].has_key?(".html")
"<a href=\"#{list[key]['.html']}\">html</a>"
else
"html"
end
item += "</td>";
item += "<td>";
item += if list[key].has_key?(".swf")
"<a href=\"#{list[key]['.swf']}\">swf</a>"
else
"swf"
end
item += "</td>";
item += "</tr>"
file.puts item
end
file.puts "</table></BODY></HTML>"
end