staticweb 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/staticweb +6 -0
- data/bin/staticweb-seed +15 -0
- data/lib/staticweb-seed.rb +237 -0
- data/lib/staticweb.rb +342 -0
- metadata +40 -0
data/bin/staticweb
ADDED
data/bin/staticweb-seed
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'staticweb-seed'
|
4
|
+
|
5
|
+
working_directory = `pwd`
|
6
|
+
static = Staticwebseed.new(working_directory.to_s.chomp)
|
7
|
+
|
8
|
+
static.make_src_directory
|
9
|
+
static.make_index_web
|
10
|
+
static.make_index_template
|
11
|
+
static.make_index_keyword
|
12
|
+
static.make_index_config
|
13
|
+
static.make_index_dynamic
|
14
|
+
static.make_css
|
15
|
+
static.make_project_mapping
|
@@ -0,0 +1,237 @@
|
|
1
|
+
class Staticwebseed
|
2
|
+
|
3
|
+
def initialize(working_directory)
|
4
|
+
@working_directory = working_directory
|
5
|
+
end
|
6
|
+
|
7
|
+
def make_src_directory
|
8
|
+
Dir.mkdir(@working_directory + "/src")
|
9
|
+
end
|
10
|
+
|
11
|
+
def make_index_web
|
12
|
+
f = File.open("src/index.web", "w")
|
13
|
+
f. puts "<p>Welcome to StaticWeb - This is the default index page</p>"
|
14
|
+
f.close
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_index_template
|
18
|
+
data = <<-EOF
|
19
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
|
20
|
+
<html>
|
21
|
+
<head>
|
22
|
+
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
23
|
+
<title>[BROWSERTITLE]</title>
|
24
|
+
<link type="text/css" href="default.css" rel="stylesheet">
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
<div id="pagecontainer">
|
28
|
+
<div id="banner">[SITEBANNER]</div>
|
29
|
+
<div id="underbannerstrip"></div>
|
30
|
+
<div id="leftcontent">
|
31
|
+
<div id="menu">
|
32
|
+
[MENUCONTENT]
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<div id="rightcontent">[CONTENT]</div>
|
36
|
+
</div>
|
37
|
+
<div id="pagefooter">
|
38
|
+
<div id="pagefootercontent">
|
39
|
+
[COPYRIGHT] [PUBLISHED]
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
</body>
|
43
|
+
</html>
|
44
|
+
EOF
|
45
|
+
f = File.open("src/index.template","w")
|
46
|
+
f.puts data
|
47
|
+
f.close
|
48
|
+
end
|
49
|
+
|
50
|
+
def make_index_keyword
|
51
|
+
data = <<-EOF
|
52
|
+
CONTENT:index.web
|
53
|
+
EOF
|
54
|
+
f = File.open("src/index.keyword","w")
|
55
|
+
f.puts data
|
56
|
+
f.close
|
57
|
+
end
|
58
|
+
|
59
|
+
def make_index_config
|
60
|
+
data = <<-EOF
|
61
|
+
SITEBANNER:StaticWeb
|
62
|
+
BROWSERTITLE:StaticWeb
|
63
|
+
COPYRIGHT:Copyright © 2004 Kingsley Hendrickse. All rights reserved.
|
64
|
+
EOF
|
65
|
+
f = File.open("src/index.config","w")
|
66
|
+
f.puts data
|
67
|
+
f.close
|
68
|
+
end
|
69
|
+
|
70
|
+
def make_index_dynamic
|
71
|
+
data = <<-EOF
|
72
|
+
def menu_MENUCONTENT
|
73
|
+
list = []
|
74
|
+
home = []
|
75
|
+
ordered_list = []
|
76
|
+
Dir.entries(@working_directory).each do |file|
|
77
|
+
if file.match("index.web") then home << '<a href="' + file.split(".")[0].to_s + '.html">' + "Home" + '</a><br>'
|
78
|
+
elsif file.match(".web") then list << '<a href="' + file.split(".")[0].to_s + '.html">' + file.split(".")[0].to_s.gsub("_"," ") + '</a><br>'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
ordered_list << home.to_s
|
82
|
+
ordered_list << list.to_s
|
83
|
+
return ordered_list.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
def published_PUBLISHED
|
87
|
+
return "-last published #\{Time.now\}"
|
88
|
+
end
|
89
|
+
EOF
|
90
|
+
f = File.open("src/index.dynamic.rb","w")
|
91
|
+
f.puts data
|
92
|
+
f.close
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
def make_css
|
97
|
+
data = <<-EOF
|
98
|
+
body {
|
99
|
+
margin:0px 5px 5px 5px;
|
100
|
+
background-color:lightgrey;
|
101
|
+
}
|
102
|
+
|
103
|
+
a:link {
|
104
|
+
font-weight: bold;
|
105
|
+
text-decoration: none;
|
106
|
+
color: black;
|
107
|
+
}
|
108
|
+
a:visited {
|
109
|
+
font-weight: bold;
|
110
|
+
text-decoration: none;
|
111
|
+
color: black;
|
112
|
+
}
|
113
|
+
a:hover, a:active {
|
114
|
+
text-decoration: underline;
|
115
|
+
color: darkblue;
|
116
|
+
}
|
117
|
+
li {
|
118
|
+
padding-left:25px;
|
119
|
+
border-left:2px solid #e4f3d3;
|
120
|
+
}
|
121
|
+
|
122
|
+
#pagecontainer {
|
123
|
+
margin-left:10%;
|
124
|
+
margin-right:10%;
|
125
|
+
margin-top:1%;
|
126
|
+
border-left:2px solid #c6c8c3;
|
127
|
+
border-right:2px solid #c6c8c3;
|
128
|
+
border-bottom:2px solid #c6c8c3;
|
129
|
+
border-top:2px solid #c6c8c3;
|
130
|
+
height:500px;
|
131
|
+
background:#ffffff;
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
#banner {
|
136
|
+
font-size:50px;
|
137
|
+
font-family:arial,helvetica;
|
138
|
+
font-weight:bold;
|
139
|
+
font-style:italic;
|
140
|
+
background-color:#e4f3d3;
|
141
|
+
color:white;
|
142
|
+
padding: 2% 2% 2% 25%;
|
143
|
+
border-bottom:2px solid #ffffff;
|
144
|
+
}
|
145
|
+
|
146
|
+
#underbannerstrip {
|
147
|
+
background:#d7dff3;
|
148
|
+
height:10px;
|
149
|
+
|
150
|
+
}
|
151
|
+
|
152
|
+
#menu{
|
153
|
+
font-size:14px;
|
154
|
+
font-family:arial,helvetica;
|
155
|
+
color:#000000;
|
156
|
+
padding-top:3px;
|
157
|
+
padding-bottom:3px;
|
158
|
+
padding-left:5px;
|
159
|
+
}
|
160
|
+
|
161
|
+
#leftcontent {
|
162
|
+
float:left;
|
163
|
+
width:20%;
|
164
|
+
background:#d7dff3;
|
165
|
+
margin-right:15px;
|
166
|
+
margin-left:10px;
|
167
|
+
margin-bottom:15px;
|
168
|
+
padding-bottom:20px;
|
169
|
+
padding-left:5px;
|
170
|
+
color:#ffffff;
|
171
|
+
}
|
172
|
+
|
173
|
+
#rightcontent {
|
174
|
+
float:right;
|
175
|
+
width:75%;
|
176
|
+
padding-right:5px;
|
177
|
+
background:white;
|
178
|
+
}
|
179
|
+
|
180
|
+
#pagefooter {
|
181
|
+
font-size:12px;
|
182
|
+
font-family:arial,helvetica;
|
183
|
+
margin-left:10%;
|
184
|
+
margin-top:3px;
|
185
|
+
margin-right:10%;
|
186
|
+
padding-top:2px;
|
187
|
+
padding-bottom:5px;
|
188
|
+
padding-left:10px;
|
189
|
+
background:#e4f3d3;
|
190
|
+
height:10px;
|
191
|
+
border-left:2px solid #c6c8c3;
|
192
|
+
border-right:2px solid #c6c8c3;
|
193
|
+
border-bottom:2px solid #c6c8c3;
|
194
|
+
border-top:2px solid #c6c8c3;
|
195
|
+
color:#000000;
|
196
|
+
}
|
197
|
+
|
198
|
+
#pagefootercontent {
|
199
|
+
margin-left:20%;
|
200
|
+
margin-right:20%;
|
201
|
+
}
|
202
|
+
|
203
|
+
#normaltext {
|
204
|
+
font-size:14px;
|
205
|
+
font-family:arial,helvetica;
|
206
|
+
}
|
207
|
+
|
208
|
+
#heading1 {
|
209
|
+
font-size:28px;
|
210
|
+
font-weight:bold;
|
211
|
+
font-family:arial,helvetica;
|
212
|
+
}
|
213
|
+
|
214
|
+
#heading2 {
|
215
|
+
font-size:16px;
|
216
|
+
font-weight:bold;
|
217
|
+
font-family:arial,helvetica;
|
218
|
+
|
219
|
+
}
|
220
|
+
EOF
|
221
|
+
f = File.open("src/default.css","w")
|
222
|
+
f.puts data
|
223
|
+
f.close
|
224
|
+
end
|
225
|
+
|
226
|
+
def make_project_mapping
|
227
|
+
data = <<-EOF
|
228
|
+
[content_file]\t\t[template_file]\t\t[config_file]\t\t[keyword_file]
|
229
|
+
index.web\t\tindex.template\t\tindex.config\t\tindex.keyword
|
230
|
+
EOF
|
231
|
+
f = File.open("src/project.mapping","w")
|
232
|
+
f.puts data
|
233
|
+
f.close
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
|
data/lib/staticweb.rb
ADDED
@@ -0,0 +1,342 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class MissingWorkingDirectory < ArgumentError ; end
|
4
|
+
class MissingFileType < RuntimeError ; end
|
5
|
+
|
6
|
+
# Jeremy's role in life is to read the .web files
|
7
|
+
class Jeremy
|
8
|
+
|
9
|
+
WebFileInitial = Struct.new("WebFileInitial", :file_name, :file_path)
|
10
|
+
WebFile = Struct.new("WebFile", :file_name, :file_path, :file_content)
|
11
|
+
|
12
|
+
def initialize(working_directory)
|
13
|
+
if !File.exists?(working_directory) then raise MissingWorkingDirectory, "Folder containing required files doesn't seem to exist"
|
14
|
+
else @working_directory = working_directory end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def list_of_web_files
|
19
|
+
list = []
|
20
|
+
Dir.entries(@working_directory).each do |file|
|
21
|
+
if file.match(".web") then list << WebFileInitial.new(file, @working_directory + "/" + file) end
|
22
|
+
end
|
23
|
+
if list.size != 0 then return list else raise MissingFileType, "The Directory contains no files with extension .web" end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def webfile
|
28
|
+
list = []
|
29
|
+
list_of_web_files.each do |web|
|
30
|
+
list << WebFile.new(web.file_name, web.file_path, File.readlines(web.file_path))
|
31
|
+
end
|
32
|
+
return list
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# Issac's role in life is to read the config files
|
38
|
+
class Isaac < Jeremy
|
39
|
+
|
40
|
+
ConfigFileInitial = Struct.new("ConfigFileInitial", :file_name, :file_path)
|
41
|
+
ConfigFile = Struct.new("ConfigFile", :file_name, :file_path, :config_setting_name, :config_setting_value)
|
42
|
+
|
43
|
+
def list_of_config_files
|
44
|
+
list = []
|
45
|
+
Dir.entries(@working_directory).each do |file|
|
46
|
+
if file.match(".config") then list << ConfigFileInitial.new(file, @working_directory + "/" + file) end
|
47
|
+
end
|
48
|
+
if list.size != 0 then return list else raise MissingFileType, "The Directory contains no files with extension .config" end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def configfile
|
53
|
+
list = []
|
54
|
+
list_of_config_files.each do |config|
|
55
|
+
File.readlines(config.file_path).each do |line|
|
56
|
+
list << ConfigFile.new(config.file_name, config.file_path, line.split(":")[0], line.split(":")[1].chomp)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
return list
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# Montgomery's role in life is to read the template files
|
65
|
+
class Montgomery < Jeremy
|
66
|
+
|
67
|
+
TemplateFileInitial = Struct.new("TemplateFileInitial", :file_name, :file_path)
|
68
|
+
TemplateFile = Struct.new("TemplateFile", :file_name, :file_path, :file_content)
|
69
|
+
|
70
|
+
def list_of_template_files
|
71
|
+
list = []
|
72
|
+
Dir.entries(@working_directory).each do |file|
|
73
|
+
if file.match(".template") then list << TemplateFileInitial.new(file, @working_directory + "/" + file) end
|
74
|
+
end
|
75
|
+
if list.size != 0 then return list else raise MissingFileType, "The Directory contains no files with extension .template" end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def templatefile
|
80
|
+
list = []
|
81
|
+
list_of_template_files.each do |template|
|
82
|
+
list << TemplateFile.new(template.file_name, template.file_path, File.readlines(template.file_path))
|
83
|
+
end
|
84
|
+
return list
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
# Jenny's role in life is to find the dynamic files
|
91
|
+
class Jenny < Jeremy
|
92
|
+
|
93
|
+
DynamicFileInitial = Struct.new("DynamicFileInitial", :file_name, :file_path)
|
94
|
+
DynamicFile = Struct.new("DynamicFile", :file_name, :file_path, :method_name, :keyword_name)
|
95
|
+
|
96
|
+
def list_of_dynamic_files
|
97
|
+
list = []
|
98
|
+
Dir.entries(@working_directory).each do |file|
|
99
|
+
if file.match(".dynamic.rb") then list << DynamicFileInitial.new(file, @working_directory + "/" + file) end
|
100
|
+
end
|
101
|
+
if list.size != 0 then return list else raise MissingFileType, "The Directory contains no files with extension .dynamic" end
|
102
|
+
end
|
103
|
+
|
104
|
+
def dynamicfile
|
105
|
+
list = []
|
106
|
+
list_of_dynamic_files.each do |dynamic|
|
107
|
+
File.readlines(dynamic.file_path).each do |line|
|
108
|
+
if line.match(/def.+_/) then list << DynamicFile.new(dynamic.file_name, dynamic.file_path, line.split[1], line.split[1].split("_")[1]) end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
return list
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
# Egbert's role in life is to read the keywords files
|
117
|
+
class Egbert < Jeremy
|
118
|
+
|
119
|
+
KeywordFileInitial = Struct.new("KeywordFileInitial", :file_name, :file_path)
|
120
|
+
KeywordFile = Struct.new("KeywordFile", :file_name, :file_path, :keyword_name, :keyword_value, :keyword_file_content)
|
121
|
+
|
122
|
+
def list_of_keyword_files
|
123
|
+
list = []
|
124
|
+
Dir.entries(@working_directory).each do |file|
|
125
|
+
if file.match(".keyword") then list << KeywordFileInitial.new(file, @working_directory + "/" + file) end
|
126
|
+
end
|
127
|
+
if list.size != 0 then return list else raise MissingFileType, "The Directory contains no files with extension .keyword" end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
def keywordfile
|
132
|
+
list = []
|
133
|
+
list_of_keyword_files.each do |keyword|
|
134
|
+
File.readlines(keyword.file_path).each do |line|
|
135
|
+
content_file = line.split(":")[1].chomp
|
136
|
+
removal_file = keyword.file_path.split("/")[-1]
|
137
|
+
content_path = keyword.file_path.gsub(removal_file, content_file)
|
138
|
+
list << KeywordFile.new(keyword.file_name, keyword.file_path, line.split(":")[0], line.split(":")[1].chomp, File.readlines(content_path))
|
139
|
+
end
|
140
|
+
end
|
141
|
+
return list
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
# Samantha's role in life is to read the mapping file
|
147
|
+
class Samantha < Jeremy
|
148
|
+
|
149
|
+
MappingFileInitial = Struct.new("MappingFileInitial", :file_name, :file_path)
|
150
|
+
MappingFile = Struct.new("MappingFile", :file_name, :file_path, :mapping_web, :mapping_template,
|
151
|
+
:mapping_config, :mapping_keyword)
|
152
|
+
|
153
|
+
def list_of_mapping_files
|
154
|
+
list = []
|
155
|
+
Dir.entries(@working_directory).each do |file|
|
156
|
+
if file.match(".mapping") then list << MappingFileInitial.new(file, @working_directory + "/" + file) end
|
157
|
+
end
|
158
|
+
if list.size != 0 then return list else raise MissingFileType, "The Directory contains no files with extension .mapping" end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
def mappingfile
|
163
|
+
list = []
|
164
|
+
list_of_mapping_files.each do |mapping|
|
165
|
+
|
166
|
+
File.readlines(mapping.file_path).each do |line|
|
167
|
+
unless line.match(/\[/)
|
168
|
+
if line.match(/d+/) then list << MappingFile.new(mapping.file_name, mapping.file_path, line.split[0],line.split[1],
|
169
|
+
line.split[2],line.split[3]) end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
return list
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
# Amy's role in life is to map and build html pages
|
179
|
+
class Amy < Jeremy
|
180
|
+
|
181
|
+
PageBuilder = Struct.new("PageBuilder", :file_name, :file_path, :html)
|
182
|
+
|
183
|
+
def initialize(working_directory)
|
184
|
+
if !File.exists?(working_directory) then raise MissingWorkingDirectory, "Folder containing required files doesn't seem to exist"
|
185
|
+
else @working_directory = working_directory end
|
186
|
+
|
187
|
+
@jeremy = Jeremy.new(@working_directory)
|
188
|
+
@isaac = Isaac.new(@working_directory)
|
189
|
+
@montgomery = Montgomery.new(@working_directory)
|
190
|
+
@jenny = Jenny.new(@working_directory)
|
191
|
+
@egbert = Egbert.new(@working_directory)
|
192
|
+
@samantha = Samantha.new(@working_directory)
|
193
|
+
end
|
194
|
+
|
195
|
+
def find_web_files_that_match_mapping
|
196
|
+
list = []
|
197
|
+
@samantha.mappingfile.each do |mapping|
|
198
|
+
@jeremy.webfile.each{|web| if web.file_name == mapping.mapping_web then list << web end}
|
199
|
+
end
|
200
|
+
return list
|
201
|
+
end
|
202
|
+
|
203
|
+
def find_config_files_that_match_mapping
|
204
|
+
list = []
|
205
|
+
@samantha.mappingfile.each do |mapping|
|
206
|
+
sub_list = []
|
207
|
+
@isaac.configfile.each{|config| if mapping.mapping_config == config.file_name then sub_list << config end}
|
208
|
+
list << sub_list
|
209
|
+
end
|
210
|
+
return list
|
211
|
+
end
|
212
|
+
|
213
|
+
def find_template_files_that_match_mapping
|
214
|
+
list = []
|
215
|
+
@samantha.mappingfile.each do |mapping|
|
216
|
+
|
217
|
+
@montgomery.templatefile.each{|template| if mapping.mapping_template == template.file_name then list << template end}
|
218
|
+
|
219
|
+
end
|
220
|
+
return list
|
221
|
+
end
|
222
|
+
|
223
|
+
def make_keyword_file_if_web_exists_but_keyword_doesnt
|
224
|
+
web_array = []
|
225
|
+
keyword_array = []
|
226
|
+
@jeremy.webfile.each{|web| web_array << web.file_name }
|
227
|
+
@egbert.keywordfile.each{|keyword| keyword_array << keyword.file_name}
|
228
|
+
keyword_array.uniq!
|
229
|
+
|
230
|
+
test_array = []
|
231
|
+
web_array.each{|web| test_array << web.split(".")[0].to_s + ".keyword"}
|
232
|
+
|
233
|
+
missing_keywords = test_array - keyword_array
|
234
|
+
unless missing_keywords.empty?
|
235
|
+
missing_keywords.each{|missing_keyword|
|
236
|
+
if !missing_keyword.empty?
|
237
|
+
puts "missing: #{missing_keyword}"
|
238
|
+
puts "Auto-creating #{missing_keyword}"
|
239
|
+
web_word = missing_keyword.to_s.split(".")[0].to_s + ".web"
|
240
|
+
data = <<-EOF
|
241
|
+
CONTENT:#{web_word}
|
242
|
+
EOF
|
243
|
+
f = File.open("src/#{missing_keyword}","w")
|
244
|
+
f.puts data
|
245
|
+
f.close
|
246
|
+
project_file = @samantha.mappingfile[0].file_name.to_s
|
247
|
+
puts "Adding entry to #{project_file}"
|
248
|
+
f = File.open("src/#{project_file}", "a")
|
249
|
+
f.puts "#{web_word}\t\tindex.template\t\tindex.config\t\t#{missing_keyword}"
|
250
|
+
f.close
|
251
|
+
end
|
252
|
+
}
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
def find_keyword_files_that_match_mapping
|
258
|
+
list = []
|
259
|
+
@samantha.mappingfile.each do |mapping|
|
260
|
+
sub_list = []
|
261
|
+
@egbert.keywordfile.each{|keyword| if mapping.mapping_keyword == keyword.file_name then sub_list << keyword end}
|
262
|
+
list << sub_list
|
263
|
+
end
|
264
|
+
return list
|
265
|
+
end
|
266
|
+
|
267
|
+
#~ def apply_keywords_to_template
|
268
|
+
#~ make_keyword_file_if_web_exists_but_keyword_doesnt
|
269
|
+
#~ list = []
|
270
|
+
#~ find_template_files_that_match_mapping.each_with_index do |template,i|
|
271
|
+
#~ txt = template.file_content.to_s.clone
|
272
|
+
|
273
|
+
#~ find_keyword_files_that_match_mapping[i].each do |keyword|
|
274
|
+
#~ if find_web_files_that_match_mapping[i].file_name == keyword.keyword_value then
|
275
|
+
#~ txt.gsub!(/\[#{keyword.keyword_name}\]/, find_web_files_that_match_mapping[i].file_content.to_s) end
|
276
|
+
#~ end
|
277
|
+
#~ list << PageBuilder.new(find_web_files_that_match_mapping[i].file_name, find_web_files_that_match_mapping[i].file_path, txt)
|
278
|
+
#~ end
|
279
|
+
#~ return list
|
280
|
+
#~ end
|
281
|
+
|
282
|
+
def apply_keywords_to_template
|
283
|
+
make_keyword_file_if_web_exists_but_keyword_doesnt
|
284
|
+
list = []
|
285
|
+
find_template_files_that_match_mapping.each_with_index do |template,i|
|
286
|
+
txt = template.file_content.to_s.clone
|
287
|
+
|
288
|
+
find_keyword_files_that_match_mapping[i].each do |keyword|
|
289
|
+
|
290
|
+
txt.gsub!(/\[#{keyword.keyword_name}\]/, keyword.keyword_file_content.to_s)
|
291
|
+
|
292
|
+
end
|
293
|
+
list << PageBuilder.new(find_web_files_that_match_mapping[i].file_name, find_web_files_that_match_mapping[i].file_path, txt)
|
294
|
+
end
|
295
|
+
return list
|
296
|
+
end
|
297
|
+
|
298
|
+
|
299
|
+
def apply_config_to_template
|
300
|
+
list = []
|
301
|
+
apply_keywords_to_template.each_with_index do |template,i|
|
302
|
+
txt = template.html.clone
|
303
|
+
find_config_files_that_match_mapping[i].each do |config|
|
304
|
+
txt.gsub!(/\[#{config.config_setting_name}\]/, config.config_setting_value)
|
305
|
+
end
|
306
|
+
list << PageBuilder.new(template.file_name, template.file_path, txt)
|
307
|
+
end
|
308
|
+
return list
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
def apply_dynamic_to_template
|
314
|
+
list = []
|
315
|
+
apply_config_to_template.each_with_index do |template,i|
|
316
|
+
txt = template.html.clone
|
317
|
+
@jenny.dynamicfile.each do |dynamic|
|
318
|
+
require dynamic.file_path
|
319
|
+
txt.gsub!(/\[#{dynamic.keyword_name}\]/, eval(dynamic.method_name))
|
320
|
+
end
|
321
|
+
list << PageBuilder.new(template.file_name, template.file_path, txt)
|
322
|
+
end
|
323
|
+
return list
|
324
|
+
end
|
325
|
+
|
326
|
+
def build_html
|
327
|
+
if File.exists?("output") then @target_dir = "output"
|
328
|
+
else Dir.mkdir("output") ; @target_dir = "output" end
|
329
|
+
|
330
|
+
Dir.entries(@working_directory).each{|file| if file.match(".css") then
|
331
|
+
FileUtils.cp_r(@working_directory + "/" + file, @target_dir) end}
|
332
|
+
|
333
|
+
|
334
|
+
apply_dynamic_to_template.each_with_index do |file,i|
|
335
|
+
f = File.open(@target_dir + "/" + file.file_name.split(".")[0].to_s + ".html", "w")
|
336
|
+
f.puts file.html
|
337
|
+
f.close
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
|
342
|
+
end
|
metadata
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.1
|
3
|
+
specification_version: 1
|
4
|
+
name: staticweb
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2005-05-21
|
8
|
+
summary: Staticweb is a command line static webpage generation tool
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
author: Kingsley Hendrickse
|
12
|
+
email: kingsley@icecode.org
|
13
|
+
homepage: http://staticweb.rubyforge.org
|
14
|
+
rubyforge_project: staticweb
|
15
|
+
description:
|
16
|
+
autorequire: staticweb
|
17
|
+
default_executable:
|
18
|
+
bindir: bin
|
19
|
+
has_rdoc: false
|
20
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
21
|
+
requirements:
|
22
|
+
-
|
23
|
+
- ">"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.0.0
|
26
|
+
version:
|
27
|
+
platform: ruby
|
28
|
+
files:
|
29
|
+
- lib/staticweb.rb
|
30
|
+
- lib/staticweb-seed.rb
|
31
|
+
test_files: []
|
32
|
+
rdoc_options: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
executables:
|
35
|
+
- staticweb
|
36
|
+
- staticweb-seed
|
37
|
+
extensions: []
|
38
|
+
requirements:
|
39
|
+
- none
|
40
|
+
dependencies: []
|