-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_webpage_index_by_root.erb
69 lines (65 loc) · 1.74 KB
/
generate_webpage_index_by_root.erb
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'erb'
template = %{
<!-- This page was generated by ruby script -->
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="img/webster.ico" type="image/x-icon">
<meta charset="utf-8">
<title>Merriam-Webster's Vocabulary Builder Audio
</title>
<style>
table {
table-layout: fixed ;
}
th, td {
text-align: left;
width: 300px;
}
</style>
</head>
<body>
<%
for file_no in 1..30
# read one root file
$filename_html = "Unit"+file_no.to_s
filename_root = "root_Unit" + file_no.to_s + ".txt"
i = 0
$root = Array.new
File.open(filename_root, "r") do |file|
file.each_line{|line| $root[i] = line.chomp
i = i+1
}
end
%>
<h1><a href="Merriam-Webster's_Vocabulary_Builder/<%= $filename_html %>.txt.html"><%= $filename_html %></a></h1>
<table>
<% for ii in 0..4
if $root[ii*2] == "Number Words" or $root[ii*2] == "Medical Words"
%>
<tr>
<td><%= $root[ii*2] %></a></td>
<td><a href="Merriam-Webster's_Vocabulary_Builder/<%= $filename_html %>.txt.html#<%= $root[ii*2+1] %>"><%= $root[ii*2+1] %></a></td>
<td><a href="Merriam-Webster's_Vocabulary_Builder/<%= $filename_html %>.txt.html#<%= $root[ii*2+2] %>"><%= $root[ii*2+2] %></a></td>
</tr>
<% break
end
%>
<tr>
<td><a href="Merriam-Webster's_Vocabulary_Builder/<%= $filename_html %>.txt.html#<%= $root[ii*2] %>"><%= $root[ii*2] %></td>
<td><a href="Merriam-Webster's_Vocabulary_Builder/<%= $filename_html %>.txt.html#<%= $root[ii*2+1] %>"><%= $root[ii*2+1] %></a></td>
</tr>
<% end %>
</table>
<% end %>
</body>
</html>
}.gsub(/^ /, '')
rhtml = ERB.new(template)
aFile = File.new("Merriam-Webster's_Vocabulary_Builder_Audio.html", "w+")
if aFile
aFile.syswrite(rhtml.result(binding))
else
puts "Unable to open file!"
end
aFile.close