rog 0.1.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/LICENSE +340 -0
- data/README +44 -0
- data/Rakefile +123 -0
- data/bin/rog +53 -0
- data/lib/rog.rb +66 -0
- data/lib/rog/app.rb +121 -0
- data/lib/rog/blog.rb +283 -0
- data/lib/rog/builtin.rf +67 -0
- data/lib/rog/page.rb +31 -0
- data/lib/rog/post.rb +80 -0
- data/lib/rog/project/README +49 -0
- data/lib/rog/project/Rakefile +26 -0
- data/lib/rog/project/blog/blog.yaml +20 -0
- data/lib/rog/project/blog/layouts/post_mini.thtml +14 -0
- data/lib/rog/project/blog/layouts/soft_green.thtml +80 -0
- data/lib/rog/project/blog/layouts/soft_green_archive.thtml +17 -0
- data/lib/rog/project/blog/layouts/soft_green_post.thtml +14 -0
- data/lib/rog/project/blog/layouts/soft_green_static.thtml +87 -0
- data/lib/rog/project/blog/pages/COMMON.rb +11 -0
- data/lib/rog/project/blog/pages/about.rb +7 -0
- data/lib/rog/project/blog/pages/about.thtml +3 -0
- data/lib/rog/project/blog/pages/archives/README +1 -0
- data/lib/rog/project/blog/pages/index.rb +12 -0
- data/lib/rog/project/blog/pages/index.thtml +0 -0
- data/lib/rog/project/blog/pages/posts/COMMON.rb +1 -0
- data/lib/rog/project/blog/pages/posts/README +1 -0
- data/lib/rog/project/blog/res/images/cc_powered.png +0 -0
- data/lib/rog/project/blog/res/images/copyleft_powered.png +0 -0
- data/lib/rog/project/blog/res/images/emacs_powered.png +0 -0
- data/lib/rog/project/blog/res/images/gnulinux_powered.png +0 -0
- data/lib/rog/project/blog/res/images/header.jpg +0 -0
- data/lib/rog/project/blog/res/images/rog_powered.png +0 -0
- data/lib/rog/project/blog/res/images/rote-tiny.png +0 -0
- data/lib/rog/project/blog/res/images/ruby_powered.png +0 -0
- data/lib/rog/project/blog/res/styles.css +171 -0
- data/lib/rog/project/blog/templates/archive-month.rb.tpl +9 -0
- data/lib/rog/project/blog/templates/archive-month.thtml.tpl +0 -0
- data/lib/rog/project/blog/templates/archive-tag.rb.tpl +9 -0
- data/lib/rog/project/blog/templates/archive-tag.thtml.tpl +0 -0
- data/lib/rog/project/blog/templates/post.rb.tpl +7 -0
- data/lib/rog/project/blog/templates/post.thtml.tpl +1 -0
- data/lib/rog/rogtasks.rb +143 -0
- data/tests/data/blog.yaml +21 -0
- data/tests/data/layouts/post_mini.thtml +14 -0
- data/tests/data/layouts/soft_green.thtml +87 -0
- data/tests/data/layouts/soft_green_archive.thtml +17 -0
- data/tests/data/layouts/soft_green_post.thtml +14 -0
- data/tests/data/layouts/soft_green_static.thtml +87 -0
- data/tests/data/pages/COMMON.rb +11 -0
- data/tests/data/pages/about.rb +7 -0
- data/tests/data/pages/about.thtml +3 -0
- data/tests/data/pages/index.rb +12 -0
- data/tests/data/pages/index.thtml +0 -0
- data/tests/data/pages/posts/20050603-prova123.rb +3 -0
- data/tests/data/pages/posts/20050603-prova123.thtml +0 -0
- data/tests/data/templates/archive-month.rb.tpl +9 -0
- data/tests/data/templates/archive-month.thtml.tpl +0 -0
- data/tests/data/templates/archive-tag.rb.tpl +9 -0
- data/tests/data/templates/archive-tag.thtml.tpl +0 -0
- data/tests/data/templates/post.rb.tpl +7 -0
- data/tests/data/templates/post.thtml.tpl +1 -0
- data/tests/tc_rogblog.rb +52 -0
- data/tests/tc_rogpost.rb +44 -0
- data/tests/tc_rogtasks.rb +35 -0
- data/tests/ts_rog.rb +9 -0
- metadata +142 -0
data/bin/rog
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Commandline launcher for Rote, (c)2005 Ross Bamford
|
3
|
+
#
|
4
|
+
# modified for Rog, (c)2006 Luca Greco
|
5
|
+
#
|
6
|
+
# Get set up with library paths, however we're installed.
|
7
|
+
|
8
|
+
def croak
|
9
|
+
puts "Cannot locate Rog libraries - Do you need to set $ROG_LIB ?"
|
10
|
+
exit(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'rubygems'
|
15
|
+
rescue LoadError
|
16
|
+
# just ignore, don't use gems
|
17
|
+
end
|
18
|
+
|
19
|
+
fail = false
|
20
|
+
rog_lib = nil
|
21
|
+
|
22
|
+
begin
|
23
|
+
require 'rog'
|
24
|
+
require 'rog/app'
|
25
|
+
|
26
|
+
# find this later
|
27
|
+
rog_lib = nil
|
28
|
+
rescue LoadError
|
29
|
+
unless fail || !(rog_lib = ENV['ROG_LIB'])
|
30
|
+
$: << rog_lib
|
31
|
+
# at least we can know this now...
|
32
|
+
builtin = File.join(rog_lib,'rog/builtin.rf')
|
33
|
+
fail = true # next time.
|
34
|
+
retry
|
35
|
+
else
|
36
|
+
croak
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# If we're loaded via RubyGems or some such we need to locate
|
41
|
+
# the builtin rakefile.
|
42
|
+
unless rog_lib
|
43
|
+
$:.each { |it|
|
44
|
+
if File.exists?(File.join(it,'rog/builtin.rf'))
|
45
|
+
rog_lib = it
|
46
|
+
break
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
croak unless rog_lib
|
52
|
+
|
53
|
+
Rog::Application.new(rog_lib).run
|
data/lib/rog.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Rog - Static Blog Engine.
|
2
|
+
#
|
3
|
+
# Copyright (C) 2006 Luca Greco a.k.a. "ripley"
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
#
|
19
|
+
####
|
20
|
+
# require these before gems, because we want to use them from
|
21
|
+
# lib/ , or from normal install, if that's how Rog was started.
|
22
|
+
#
|
23
|
+
# If rote has been loaded through Gems, this will automatically
|
24
|
+
# come from the right lib directory...
|
25
|
+
|
26
|
+
require 'rog/rogtasks'
|
27
|
+
require 'rog/blog'
|
28
|
+
require 'rog/post'
|
29
|
+
|
30
|
+
# Everything else should come first from Gems, if installed.
|
31
|
+
begin
|
32
|
+
require 'rubygems'
|
33
|
+
rescue LoadError
|
34
|
+
nil # just try without then...
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'rake'
|
38
|
+
|
39
|
+
# Master Rog version. Manage this from the Rake release support.
|
40
|
+
ROGVERSION = '0.1.0'
|
41
|
+
|
42
|
+
#####
|
43
|
+
## *Rog* is a Rake (http://rake.rubyforge.org) and Rote based build tool for static
|
44
|
+
## blog sites.
|
45
|
+
##
|
46
|
+
## *Rog* use (and permit you to use them too) all the features of *Rote* for
|
47
|
+
## create a blog-oriented website using text files formatted in one of the
|
48
|
+
## supported (by Rote) markup languages.
|
49
|
+
##
|
50
|
+
## I've developed *Rog* for put online my blogsite, so it's influenced
|
51
|
+
## by my purpose, but it's GPL licensed so feel free to extend or modify
|
52
|
+
## for your purpose (and send me your diff too :-P)
|
53
|
+
##
|
54
|
+
## *Rog* (as *Rote*) te can be used from the command-line, or in your own +Rakefile+.
|
55
|
+
## It supports both manual and automatic rendering of modified resources, and
|
56
|
+
## can be configured to monitor your source tree for changes.
|
57
|
+
##
|
58
|
+
## See +README+ for general usage information. Rog::DocTask documents the
|
59
|
+
## Rake task integration.
|
60
|
+
##
|
61
|
+
## Rog is (c)2006 Luca Greco (and contributors). See +LICENSE+ for details.
|
62
|
+
module Rog
|
63
|
+
|
64
|
+
# this space intentionally left blank
|
65
|
+
|
66
|
+
end
|
data/lib/rog/app.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# Rog application class
|
2
|
+
# (c)2006 Luca Greco
|
3
|
+
#
|
4
|
+
# See 'rog.rb' or LICENSE for licence information.
|
5
|
+
# $Id$
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
module Rog
|
9
|
+
|
10
|
+
# Command-line launcher for Rog.
|
11
|
+
class Application
|
12
|
+
attr_accessor :rog_lib
|
13
|
+
attr_accessor :debug
|
14
|
+
attr_accessor :tasks
|
15
|
+
attr_accessor :trace
|
16
|
+
attr_accessor :usage
|
17
|
+
attr_accessor :version
|
18
|
+
attr_accessor :rake
|
19
|
+
attr_accessor :rakefile
|
20
|
+
attr_accessor :rakeopts
|
21
|
+
|
22
|
+
# Create a new Application instance, processing command-line arguments,
|
23
|
+
# optionally passing +self+ to the supplied block for further
|
24
|
+
# configuration.
|
25
|
+
def initialize(rog_lib) # :yield: self if block_given?
|
26
|
+
# init vars
|
27
|
+
@rog_lib = rog_lib
|
28
|
+
@debug = false
|
29
|
+
@tasks = false
|
30
|
+
@trace = false
|
31
|
+
@usage = false
|
32
|
+
@version = false
|
33
|
+
|
34
|
+
@rakefile = "#{rog_lib}/rog/builtin.rf"
|
35
|
+
raise "Missing builtin.rf (expected at '#{@rakefile}')!" unless File.exists?(@rakefile)
|
36
|
+
|
37
|
+
@rakeopts = ENV['RAKE_OPTS'] || ''
|
38
|
+
@rake = ENV['RAKE_CMD'] || (PLATFORM =~ /mswin/ ? 'rake.cmd' : 'rake')
|
39
|
+
|
40
|
+
process_args
|
41
|
+
|
42
|
+
yield self if block_given?
|
43
|
+
end
|
44
|
+
|
45
|
+
# Run the application with the current options.
|
46
|
+
def run
|
47
|
+
if @version
|
48
|
+
print "rog, version #{ROGVERSION}\n"
|
49
|
+
|
50
|
+
elsif @tasks
|
51
|
+
print `#{rake} --rakefile=#{rakefile} --libdir=#{rog_lib} --tasks`.gsub(/^rake /,'rog ')
|
52
|
+
|
53
|
+
elsif @usage
|
54
|
+
show_usage()
|
55
|
+
|
56
|
+
else
|
57
|
+
if @trace
|
58
|
+
rakeopts << ' --trace'
|
59
|
+
elsif @debug
|
60
|
+
rakeopts << '--verbose'
|
61
|
+
end
|
62
|
+
|
63
|
+
exec("#{rake} --rakefile=#{rakefile} --libdir=#{rog_lib} #{rakeopts} #{$*.join(' ')}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
# Process commandline
|
70
|
+
def process_args
|
71
|
+
GetoptLong.new(
|
72
|
+
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
|
73
|
+
[ "--tasks", "-T", GetoptLong::NO_ARGUMENT ],
|
74
|
+
[ "--trace", "-t", GetoptLong::NO_ARGUMENT ],
|
75
|
+
[ "--usage", "-u", GetoptLong::NO_ARGUMENT ],
|
76
|
+
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
|
77
|
+
[ "--version", "-V", GetoptLong::NO_ARGUMENT ]
|
78
|
+
).each { |opt,arg|
|
79
|
+
@debug = true if opt == '--verbose'
|
80
|
+
@trace = true if opt == '--trace'
|
81
|
+
@tasks = true if opt == '--tasks'
|
82
|
+
@usage = true if opt == '--usage' || opt == '--help'
|
83
|
+
@version = true if opt == '--version'
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
# Display help text
|
88
|
+
def show_usage
|
89
|
+
print <<-EOM
|
90
|
+
Usage: rog [options] [task1] .. [taskN]
|
91
|
+
|
92
|
+
Where [taskN] is a valid task or target name for the current project.
|
93
|
+
Rite generates targets for each page source, and also defines a number
|
94
|
+
of top-level tasks for various things. Use the '--tasks' option to get
|
95
|
+
a list of valid tasks.
|
96
|
+
|
97
|
+
Recognised options are:
|
98
|
+
|
99
|
+
--tasks -T Display a list of tasks in this project.
|
100
|
+
--verbose -v Enable verbose output.
|
101
|
+
--trace -t Enables trace-level output (debugging).
|
102
|
+
--usage -u Display this help message and quit
|
103
|
+
--help -h Synonym for --usage
|
104
|
+
--version -V Display Rog's version and quit
|
105
|
+
|
106
|
+
In addition to the standard doc_XXX tasks and those provided by any
|
107
|
+
local configuration, the following 'special' tasks are recognised:
|
108
|
+
|
109
|
+
create <project> Create a blank project from the built-in template.
|
110
|
+
|
111
|
+
Note that these 'special' tasks are implemented as part of the command-
|
112
|
+
line wrapper for Rog, and will not be available from custom Rakefiles.
|
113
|
+
|
114
|
+
In non-standard environments, it may be necessary to set the ROTE_LIB
|
115
|
+
variable to point to the location of Rog's libraries.
|
116
|
+
|
117
|
+
EOM
|
118
|
+
end
|
119
|
+
|
120
|
+
end # Application
|
121
|
+
end # Rog
|
data/lib/rog/blog.rb
ADDED
@@ -0,0 +1,283 @@
|
|
1
|
+
# Rog - Static Blog Engine.
|
2
|
+
#
|
3
|
+
# Copyright (C) 2006 Luca Greco a.k.a. "ripley"
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
|
19
|
+
=begin
|
20
|
+
La classe Blog ha il compito di raccogliere tutte quelle informazioni globali da cui generare
|
21
|
+
la pagina di index e gli archivi mensili e annuali.
|
22
|
+
|
23
|
+
Esempio:
|
24
|
+
* raccolta tags
|
25
|
+
* collegamento tag -> pagine
|
26
|
+
* raccolta date dei post
|
27
|
+
* collegamento date dei post -> pagine
|
28
|
+
|
29
|
+
== Raccolta Tags ==
|
30
|
+
|
31
|
+
Allo scopo di raccogliere i tag si potrebbe caricare tutti i file .rb dei post
|
32
|
+
e riempire un'hash tag->pagine.
|
33
|
+
|
34
|
+
== Date ==
|
35
|
+
|
36
|
+
La data di un post potrebbere essere contenuta nel nome stesso del file.
|
37
|
+
Questa scelta implementativa permetterebbe di:
|
38
|
+
* differenziare immediatamente post del blog dalle pagine statiche
|
39
|
+
* ordinare i post sulla base del nome
|
40
|
+
=end
|
41
|
+
|
42
|
+
module Rog
|
43
|
+
|
44
|
+
class Blog
|
45
|
+
def initialize(blog_path='blog', pages_path="#{blog_path}/pages",
|
46
|
+
archives_path = "#{pages_path}/archives",
|
47
|
+
posts_path="#{pages_path}/posts")
|
48
|
+
@blog_path = blog_path
|
49
|
+
@pages_path = pages_path
|
50
|
+
@archives_path = archives_path
|
51
|
+
@posts_path = posts_path
|
52
|
+
|
53
|
+
@tags_hash = Hash.new
|
54
|
+
|
55
|
+
load_config
|
56
|
+
scan_for_posts
|
57
|
+
end
|
58
|
+
|
59
|
+
def tags
|
60
|
+
@tags_hash
|
61
|
+
end
|
62
|
+
|
63
|
+
def posts
|
64
|
+
@blog_posts
|
65
|
+
end
|
66
|
+
|
67
|
+
def links
|
68
|
+
@links
|
69
|
+
end
|
70
|
+
|
71
|
+
def buttons
|
72
|
+
@buttons
|
73
|
+
end
|
74
|
+
|
75
|
+
def pages
|
76
|
+
@pages
|
77
|
+
end
|
78
|
+
|
79
|
+
def projects
|
80
|
+
@projects
|
81
|
+
end
|
82
|
+
|
83
|
+
def url
|
84
|
+
@url
|
85
|
+
end
|
86
|
+
|
87
|
+
def publish_url
|
88
|
+
@publish_url
|
89
|
+
end
|
90
|
+
|
91
|
+
def posts?
|
92
|
+
@blog_posts.length >= 1
|
93
|
+
end
|
94
|
+
|
95
|
+
def each_post(&proc)
|
96
|
+
@blog_posts.each do |bpost|
|
97
|
+
yield bpost
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def each_month(&proc)
|
102
|
+
prev_year = @blog_posts[0].year
|
103
|
+
prev_month = @blog_posts[0].month
|
104
|
+
|
105
|
+
month_posts = Array.new
|
106
|
+
|
107
|
+
@blog_posts.each do |post|
|
108
|
+
if post.year == prev_year and post.month == prev_month then
|
109
|
+
month_posts.push post
|
110
|
+
else
|
111
|
+
yield month_posts
|
112
|
+
prev_year = post.year
|
113
|
+
prev_month = post.month
|
114
|
+
month_posts = [ post ]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
yield [ @blog_posts.last ] if @blog_posts.length >= 1
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_last_posts
|
122
|
+
last_posts = Array.new
|
123
|
+
|
124
|
+
(0...7).each do |i|
|
125
|
+
if not @blog_posts[i].nil?
|
126
|
+
last_posts.push @blog_posts[i]
|
127
|
+
else
|
128
|
+
break
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
last_posts
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
def scan_for_posts
|
137
|
+
@blog_posts = Array.new
|
138
|
+
|
139
|
+
Dir.foreach(@posts_path) do |filename|
|
140
|
+
# seleziona solo i file del tipo YYYYMMDD-nome.thtml
|
141
|
+
# ex. 20060607-prova123.thtml
|
142
|
+
|
143
|
+
if filename =~ /(\d\d\d\d)(\d\d)(\d\d)[-].*\.thtml$/ then
|
144
|
+
curr_blog = Post.new(filename, @blog_path, @pages_path, @posts_path)
|
145
|
+
|
146
|
+
@blog_posts.push curr_blog
|
147
|
+
|
148
|
+
curr_blog.tags.each do |tag|
|
149
|
+
@tags_hash[tag] = Array.new if @tags_hash[tag].nil?
|
150
|
+
@tags_hash[tag].push curr_blog
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
@blog_posts.sort!.reverse!
|
156
|
+
end
|
157
|
+
|
158
|
+
def load_config
|
159
|
+
require 'yaml'
|
160
|
+
|
161
|
+
begin
|
162
|
+
@config = YAML::load( File.open("#{@blog_path}/blog.yaml") )
|
163
|
+
|
164
|
+
@links = Hash.new
|
165
|
+
@pages = Hash.new
|
166
|
+
@buttons = Hash.new
|
167
|
+
@projects = Hash.new
|
168
|
+
|
169
|
+
@config["links"].each do |link|
|
170
|
+
link.each do |key,value|
|
171
|
+
@links[key] = value
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
@config["pages"].each do |link|
|
176
|
+
link.each do |key,value|
|
177
|
+
@pages[key] = value
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
@config["buttons"].each do |button|
|
182
|
+
button.each do |key,value|
|
183
|
+
@buttons[key] = value
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
@config["projects"].each do |project|
|
188
|
+
project.each do |key,value|
|
189
|
+
@projects[key] = value
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
@url = @config["blogurl"]
|
194
|
+
@publish_url = @config["publish_url"]
|
195
|
+
|
196
|
+
rescue Errno::ENOENT
|
197
|
+
STDERR.puts "Unable to open blog.yaml"
|
198
|
+
exit 1
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class BlogUtils
|
204
|
+
|
205
|
+
def self.stdout_redirect_to(conf_file)
|
206
|
+
old_stdout = $stdout
|
207
|
+
$stdout = conf_file
|
208
|
+
yield
|
209
|
+
$stdout = old_stdout
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.generate_post(postname,tags)
|
213
|
+
require 'eruby'
|
214
|
+
|
215
|
+
ark_rb = open("blog/templates/post.rb.tpl")
|
216
|
+
ark_thtml = open("blog/templates/post.thtml.tpl")
|
217
|
+
|
218
|
+
compiler = ERuby::Compiler.new
|
219
|
+
|
220
|
+
data_rb = compiler.compile_file(ark_rb)
|
221
|
+
data_thtml = compiler.compile_file(ark_thtml)
|
222
|
+
|
223
|
+
date = `date +%Y%m%d`.chomp
|
224
|
+
|
225
|
+
out_rb = File.open("blog/pages/posts/#{date}-#{postname}.rb", 'w')
|
226
|
+
out_thtml = File.open("blog/pages/posts/#{date}-#{postname}.thtml", 'w')
|
227
|
+
|
228
|
+
@postname = postname
|
229
|
+
@tags = tags.split
|
230
|
+
|
231
|
+
stdout_redirect_to(out_rb) { eval data_rb }
|
232
|
+
stdout_redirect_to(out_thtml) { eval data_thtml }
|
233
|
+
|
234
|
+
ark_rb.close; ark_thtml.close; out_rb.close; out_thtml.close
|
235
|
+
end
|
236
|
+
|
237
|
+
def self.generate_tag_archive(tag)
|
238
|
+
require 'eruby'
|
239
|
+
|
240
|
+
ark_rb = open("blog/templates/archive-tag.rb.tpl")
|
241
|
+
ark_thtml = open("blog/templates/archive-tag.thtml.tpl")
|
242
|
+
|
243
|
+
compiler = ERuby::Compiler.new
|
244
|
+
|
245
|
+
data_rb = compiler.compile_file(ark_rb)
|
246
|
+
data_thtml = compiler.compile_file(ark_thtml)
|
247
|
+
|
248
|
+
out_rb = File.open("blog/pages/archives/archive-"+tag+".rb", 'w')
|
249
|
+
out_thtml = File.open("blog/pages/archives/archive-"+tag+".thtml", 'w')
|
250
|
+
|
251
|
+
@tag = tag
|
252
|
+
|
253
|
+
stdout_redirect_to(out_rb) { eval data_rb }
|
254
|
+
stdout_redirect_to(out_thtml) { eval data_thtml }
|
255
|
+
|
256
|
+
ark_rb.close; ark_thtml.close; out_rb.close; out_thtml.close
|
257
|
+
end
|
258
|
+
|
259
|
+
def self.generate_month_archive(year,month)
|
260
|
+
require 'eruby'
|
261
|
+
|
262
|
+
ark_rb = open("blog/templates/archive-month.rb.tpl")
|
263
|
+
ark_thtml = open("blog/templates/archive-month.thtml.tpl")
|
264
|
+
|
265
|
+
compiler = ERuby::Compiler.new
|
266
|
+
|
267
|
+
data_rb = compiler.compile_file(ark_rb)
|
268
|
+
data_thtml = compiler.compile_file(ark_thtml)
|
269
|
+
|
270
|
+
out_rb = File.open("blog/pages/archives/archive-"+year+month+".rb", 'w')
|
271
|
+
out_thtml = File.open("blog/pages/archives/archive-"+year+month+".thtml", 'w')
|
272
|
+
|
273
|
+
@year = year
|
274
|
+
@month = month
|
275
|
+
|
276
|
+
stdout_redirect_to(out_rb) { eval data_rb }
|
277
|
+
stdout_redirect_to(out_thtml) { eval data_thtml }
|
278
|
+
|
279
|
+
ark_rb.close; ark_thtml.close; out_rb.close; out_thtml.close
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|