Class: Rog::BlogUtils
- Inherits:
-
Object
- Object
- Rog::BlogUtils
- Defined in:
- lib/rog/blog.rb
Class Method Summary collapse
- .generate_month_archive(year, month) ⇒ Object
- .generate_post(postname, tags) ⇒ Object
- .generate_tag_archive(tag) ⇒ Object
- .stdout_redirect_to(conf_file) ⇒ Object
Class Method Details
.generate_month_archive(year, month) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/rog/blog.rb', line 249 def self.generate_month_archive(year,month) @year = year @month = month open("blog/templates/archive-month.rb.tpl") do |f| ark_rb = f.gets end open("blog/templates/archive-month.thtml.tpl") do |f| ark_thtml = f.gets end data_rb = ERB.new(ark_rb).result(binding) data_thtml = ERB.new(ark_thtml).result(binding) open("blog/pages/archives/archive-"+year+month+".rb", 'w') do |f| f.puts data_rb end open("blog/pages/archives/archive-"+year+month+".thtml", 'w') do |f| f.puts data_thtml end end |
.generate_post(postname, tags) ⇒ Object
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/rog/blog.rb', line 200 def self.generate_post(postname,) @postname = postname @tags = .split open("blog/templates/post.rb.tpl") do |f| ark_rb = f.gets end open("blog/templates/post.thtml.tpl") do |f| ark_thtml = f.gets end date = `date +%Y%m%d`.chomp data_rb = ERB.new(ark_rb).result(binding) data_thtml = ERB.new(ark_thtml).result(binding) open("blog/pages/posts/#{date}-#{postname}.rb", 'w') do |f| f.puts data_rb end open("blog/pages/posts/#{date}-#{postname}.thtml", 'w') do |f| f.puts data_thtml end end |
.generate_tag_archive(tag) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/rog/blog.rb', line 226 def self.generate_tag_archive(tag) @tag = tag open("blog/templates/archive-tag.rb.tpl") do |f| ark_rb = f.gets end open("blog/templates/archive-tag.thtml.tpl") do |f| ark_thtml = f.gets end data_rb = ERB.new(ark_rb).result(binding) data_thtml = ERB.new(ark_thtml).result(binding) open("blog/pages/archives/archive-"+tag+".rb", 'w') do |f| f.puts data_rb end open("blog/pages/archives/archive-"+tag+".thtml", 'w') do |f| f.puts data_thtml end end |
.stdout_redirect_to(conf_file) ⇒ Object
193 194 195 196 197 198 |
# File 'lib/rog/blog.rb', line 193 def self.stdout_redirect_to(conf_file) old_stdout = $stdout $stdout = conf_file yield $stdout = old_stdout end |