Class: Staticwebseed
- Inherits:
-
Object
- Object
- Staticwebseed
- Defined in:
- lib/staticweb-seed.rb
Instance Method Summary collapse
-
#initialize(working_directory) ⇒ Staticwebseed
constructor
A new instance of Staticwebseed.
- #make_css ⇒ Object
- #make_index_config ⇒ Object
- #make_index_dynamic ⇒ Object
- #make_index_keyword ⇒ Object
- #make_index_template ⇒ Object
- #make_index_web ⇒ Object
- #make_project_mapping ⇒ Object
- #make_src_directory ⇒ Object
Constructor Details
#initialize(working_directory) ⇒ Staticwebseed
Returns a new instance of Staticwebseed.
3 4 5 |
# File 'lib/staticweb-seed.rb', line 3 def initialize(working_directory) @working_directory = working_directory end |
Instance Method Details
#make_css ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/staticweb-seed.rb', line 96 def make_css data = <<-EOF body { margin:0px 5px 5px 5px; background-color:lightgrey; } a:link { font-weight: bold; text-decoration: none; color: black; } a:visited { font-weight: bold; text-decoration: none; color: black; } a:hover, a:active { text-decoration: underline; color: darkblue; } li { padding-left:25px; border-left:2px solid #e4f3d3; } #pagecontainer { margin-left:10%; margin-right:10%; margin-top:1%; border-left:2px solid #c6c8c3; border-right:2px solid #c6c8c3; border-bottom:2px solid #c6c8c3; border-top:2px solid #c6c8c3; height:500px; background:#ffffff; } #banner { font-size:50px; font-family:arial,helvetica; font-weight:bold; font-style:italic; background-color:#e4f3d3; color:white; padding: 2% 2% 2% 25%; border-bottom:2px solid #ffffff; } #underbannerstrip { background:#d7dff3; height:10px; } #menu{ font-size:14px; font-family:arial,helvetica; color:#000000; padding-top:3px; padding-bottom:3px; padding-left:5px; } #leftcontent { float:left; width:20%; background:#d7dff3; margin-right:15px; margin-left:10px; margin-bottom:15px; padding-bottom:20px; padding-left:5px; color:#ffffff; } #rightcontent { float:right; width:75%; padding-right:5px; background:white; } #pagefooter { font-size:12px; font-family:arial,helvetica; margin-left:10%; margin-top:3px; margin-right:10%; padding-top:2px; padding-bottom:5px; padding-left:10px; background:#e4f3d3; height:10px; border-left:2px solid #c6c8c3; border-right:2px solid #c6c8c3; border-bottom:2px solid #c6c8c3; border-top:2px solid #c6c8c3; color:#000000; } #pagefootercontent { margin-left:20%; margin-right:20%; } #normaltext { font-size:14px; font-family:arial,helvetica; } #heading1 { font-size:28px; font-weight:bold; font-family:arial,helvetica; } #heading2 { font-size:16px; font-weight:bold; font-family:arial,helvetica; } EOF f = File.open("src/default.css","w") f.puts data f.close end |
#make_index_config ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/staticweb-seed.rb', line 59 def make_index_config data = <<-EOF SITEBANNER:StaticWeb BROWSERTITLE:StaticWeb COPYRIGHT:Copyright © 2004 Kingsley Hendrickse. All rights reserved. EOF f = File.open("src/index.config","w") f.puts data f.close end |
#make_index_dynamic ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/staticweb-seed.rb', line 70 def make_index_dynamic data = <<-EOF def menu_MENUCONTENT list = [] home = [] ordered_list = [] Dir.entries(@working_directory).each do |file| if file.match("index.web") then home << '<a href="' + file.split(".")[0].to_s + '.html">' + "Home" + '</a><br>' elsif file.match(".web") then list << '<a href="' + file.split(".")[0].to_s + '.html">' + file.split(".")[0].to_s.gsub("_"," ") + '</a><br>' end end ordered_list << home.to_s ordered_list << list.to_s return ordered_list.to_s end def published_PUBLISHED return "-last published #\{Time.now\}" end EOF f = File.open("src/index.dynamic.rb","w") f.puts data f.close end |
#make_index_keyword ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/staticweb-seed.rb', line 50 def make_index_keyword data = <<-EOF CONTENT:index.web EOF f = File.open("src/index.keyword","w") f.puts data f.close end |
#make_index_template ⇒ Object
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 |
# File 'lib/staticweb-seed.rb', line 17 def make_index_template data = <<-EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>[BROWSERTITLE]</title> <link type="text/css" href="default.css" rel="stylesheet"> </head> <body> <div id="pagecontainer"> <div id="banner">[SITEBANNER]</div> <div id="underbannerstrip"></div> <div id="leftcontent"> <div id="menu"> [MENUCONTENT] </div> </div> <div id="rightcontent">[CONTENT]</div> </div> <div id="pagefooter"> <div id="pagefootercontent"> [COPYRIGHT] [PUBLISHED] </div> </div> </body> </html> EOF f = File.open("src/index.template","w") f.puts data f.close end |
#make_index_web ⇒ Object
11 12 13 14 15 |
# File 'lib/staticweb-seed.rb', line 11 def make_index_web f = File.open("src/index.web", "w") f. puts "<p>Welcome to StaticWeb - This is the default index page</p>" f.close end |
#make_project_mapping ⇒ Object
226 227 228 229 230 231 232 233 234 |
# File 'lib/staticweb-seed.rb', line 226 def make_project_mapping data = <<-EOF [content_file]\t\t[template_file]\t\t[config_file]\t\t[keyword_file] index.web\t\tindex.template\t\tindex.config\t\tindex.keyword EOF f = File.open("src/project.mapping","w") f.puts data f.close end |
#make_src_directory ⇒ Object
7 8 9 |
# File 'lib/staticweb-seed.rb', line 7 def make_src_directory Dir.mkdir(@working_directory + "/src") end |