rog 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/rog/blog.rb +111 -127
- data/lib/rog/post.rb +1 -14
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/rog/blog.rb
CHANGED
@@ -17,32 +17,38 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
=begin
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
The Blog class has the task of gathering all required global
|
21
|
+
informations nedeed to generate the index page and the yearly and
|
22
|
+
monthly archives.
|
23
|
+
|
24
|
+
Examples:
|
25
|
+
* tags gathering
|
26
|
+
* linking between tags and pages
|
27
|
+
* posts' date gathering
|
28
|
+
* linking between posts' date and pages
|
29
|
+
|
30
|
+
== Tags Gathering ==
|
31
|
+
|
32
|
+
In order to gather all tags we could proceed loading all .rb file of
|
33
|
+
the post, so we can obtain an hash tag->pages.
|
34
|
+
|
35
|
+
== Dates ==
|
36
|
+
|
37
|
+
We can choose to put the post's date in the same filename, by this way
|
38
|
+
we are able to easily:
|
39
|
+
|
40
|
+
* discriminate between blog's posts and static pages;
|
41
|
+
* order posts by name.
|
40
42
|
=end
|
41
43
|
|
44
|
+
require 'yaml'
|
45
|
+
require 'erb'
|
46
|
+
|
42
47
|
module Rog
|
43
48
|
|
44
49
|
class Blog
|
45
|
-
attr_reader :blog_title, :blog_subtitle
|
50
|
+
attr_reader :blog_title, :blog_subtitle, :links, :pages, :buttons,
|
51
|
+
:projects, :url, :publish_url
|
46
52
|
|
47
53
|
def initialize(blog_path='blog', pages_path="#{blog_path}/pages",
|
48
54
|
archives_path = "#{pages_path}/archives",
|
@@ -66,30 +72,6 @@ module Rog
|
|
66
72
|
@blog_posts
|
67
73
|
end
|
68
74
|
|
69
|
-
def links
|
70
|
-
@links
|
71
|
-
end
|
72
|
-
|
73
|
-
def buttons
|
74
|
-
@buttons
|
75
|
-
end
|
76
|
-
|
77
|
-
def pages
|
78
|
-
@pages
|
79
|
-
end
|
80
|
-
|
81
|
-
def projects
|
82
|
-
@projects
|
83
|
-
end
|
84
|
-
|
85
|
-
def url
|
86
|
-
@url
|
87
|
-
end
|
88
|
-
|
89
|
-
def publish_url
|
90
|
-
@publish_url
|
91
|
-
end
|
92
|
-
|
93
75
|
def posts?
|
94
76
|
@blog_posts.length >= 1
|
95
77
|
end
|
@@ -148,13 +130,13 @@ module Rog
|
|
148
130
|
# ex. 20060607-prova123.thtml
|
149
131
|
|
150
132
|
if filename =~ /(\d\d\d\d)(\d\d)(\d\d)[-].*\.thtml$/ then
|
151
|
-
|
133
|
+
curr_post = Post.new(filename, @blog_path, @pages_path, @posts_path)
|
152
134
|
|
153
|
-
@blog_posts.push
|
135
|
+
@blog_posts.push curr_post
|
154
136
|
|
155
|
-
|
137
|
+
curr_post.tags.each do |tag|
|
156
138
|
@tags_hash[tag] = Array.new if @tags_hash[tag].nil?
|
157
|
-
@tags_hash[tag].push
|
139
|
+
@tags_hash[tag].push curr_post
|
158
140
|
end
|
159
141
|
end
|
160
142
|
end
|
@@ -163,50 +145,47 @@ module Rog
|
|
163
145
|
end
|
164
146
|
|
165
147
|
def load_config
|
166
|
-
|
167
|
-
|
168
|
-
begin
|
169
|
-
@config = YAML::load( File.open("#{@blog_path}/blog.yaml") )
|
148
|
+
@config = YAML::load( File.open("#{@blog_path}/blog.yaml") )
|
170
149
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
150
|
+
@links = Hash.new
|
151
|
+
@pages = Hash.new
|
152
|
+
@buttons = Hash.new
|
153
|
+
@projects = Hash.new
|
175
154
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
155
|
+
@config["links"].each do |link|
|
156
|
+
link.each do |key,value|
|
157
|
+
@links[key] = value
|
180
158
|
end
|
159
|
+
end
|
181
160
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
161
|
+
@config["pages"].each do |link|
|
162
|
+
link.each do |key,value|
|
163
|
+
@pages[key] = value
|
186
164
|
end
|
165
|
+
end
|
187
166
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
end
|
167
|
+
@config["buttons"].each do |button|
|
168
|
+
button.each do |key,value|
|
169
|
+
@buttons[key] = value
|
192
170
|
end
|
171
|
+
end
|
193
172
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
end
|
173
|
+
@config["projects"].each do |project|
|
174
|
+
project.each do |key,value|
|
175
|
+
@projects[key] = value
|
198
176
|
end
|
177
|
+
end
|
199
178
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
179
|
+
@url = @config["blogurl"]
|
180
|
+
@publish_url = @config["publish_url"]
|
181
|
+
@blog_title = @config["blog_title"]
|
182
|
+
@blog_subtitle = @config["blog_subtitle"]
|
204
183
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
end
|
184
|
+
rescue Errno::ENOENT
|
185
|
+
STDERR.puts "Unable to open blog.yaml"
|
186
|
+
exit 1
|
209
187
|
end
|
188
|
+
|
210
189
|
end
|
211
190
|
|
212
191
|
class BlogUtils
|
@@ -219,74 +198,79 @@ module Rog
|
|
219
198
|
end
|
220
199
|
|
221
200
|
def self.generate_post(postname,tags)
|
222
|
-
|
201
|
+
@postname = postname
|
202
|
+
@tags = tags.split
|
223
203
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
204
|
+
open("blog/templates/post.rb.tpl") do |f|
|
205
|
+
ark_rb = f.gets
|
206
|
+
end
|
207
|
+
|
208
|
+
open("blog/templates/post.thtml.tpl") do |f|
|
209
|
+
ark_thtml = f.gets
|
210
|
+
end
|
231
211
|
|
232
212
|
date = `date +%Y%m%d`.chomp
|
233
213
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
@postname = postname
|
238
|
-
@tags = tags.split
|
214
|
+
data_rb = ERB.new(ark_rb).result(binding)
|
215
|
+
data_thtml = ERB.new(ark_thtml).result(binding)
|
239
216
|
|
240
|
-
|
241
|
-
|
217
|
+
open("blog/pages/posts/#{date}-#{postname}.rb", 'w') do |f|
|
218
|
+
f.puts data_rb
|
219
|
+
end
|
242
220
|
|
243
|
-
|
221
|
+
open("blog/pages/posts/#{date}-#{postname}.thtml", 'w') do |f|
|
222
|
+
f.puts data_thtml
|
223
|
+
end
|
244
224
|
end
|
245
225
|
|
246
226
|
def self.generate_tag_archive(tag)
|
247
|
-
|
248
|
-
|
249
|
-
ark_rb = open("blog/templates/archive-tag.rb.tpl")
|
250
|
-
ark_thtml = open("blog/templates/archive-tag.thtml.tpl")
|
251
|
-
|
252
|
-
compiler = ERuby::Compiler.new
|
227
|
+
@tag = tag
|
253
228
|
|
254
|
-
|
255
|
-
|
229
|
+
open("blog/templates/archive-tag.rb.tpl") do |f|
|
230
|
+
ark_rb = f.gets
|
231
|
+
end
|
256
232
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
233
|
+
open("blog/templates/archive-tag.thtml.tpl") do |f|
|
234
|
+
ark_thtml = f.gets
|
235
|
+
end
|
236
|
+
|
237
|
+
data_rb = ERB.new(ark_rb).result(binding)
|
238
|
+
data_thtml = ERB.new(ark_thtml).result(binding)
|
261
239
|
|
262
|
-
|
263
|
-
|
240
|
+
open("blog/pages/archives/archive-"+tag+".rb", 'w') do |f|
|
241
|
+
f.puts data_rb
|
242
|
+
end
|
264
243
|
|
265
|
-
|
244
|
+
open("blog/pages/archives/archive-"+tag+".thtml", 'w') do |f|
|
245
|
+
f.puts data_thtml
|
246
|
+
end
|
266
247
|
end
|
267
248
|
|
268
249
|
def self.generate_month_archive(year,month)
|
269
|
-
|
250
|
+
@year = year
|
251
|
+
@month = month
|
270
252
|
|
271
|
-
ark_rb = open("blog/templates/archive-month.rb.tpl")
|
272
|
-
ark_thtml = open("blog/templates/archive-month.thtml.tpl")
|
273
|
-
|
274
|
-
compiler = ERuby::Compiler.new
|
275
253
|
|
276
|
-
|
277
|
-
|
254
|
+
open("blog/templates/archive-month.rb.tpl") do |f|
|
255
|
+
ark_rb = f.gets
|
256
|
+
end
|
278
257
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
258
|
+
open("blog/templates/archive-month.thtml.tpl") do |f|
|
259
|
+
ark_thtml = f.gets
|
260
|
+
end
|
261
|
+
|
262
|
+
data_rb = ERB.new(ark_rb).result(binding)
|
263
|
+
data_thtml = ERB.new(ark_thtml).result(binding)
|
284
264
|
|
285
|
-
|
286
|
-
|
265
|
+
open("blog/pages/archives/archive-"+year+month+".rb", 'w') do |f|
|
266
|
+
f.puts data_rb
|
267
|
+
end
|
287
268
|
|
288
|
-
|
269
|
+
open("blog/pages/archives/archive-"+year+month+".thtml", 'w') do |f|
|
270
|
+
f.puts data_thtml
|
271
|
+
end
|
289
272
|
end
|
273
|
+
|
290
274
|
end
|
291
275
|
|
292
276
|
end
|
data/lib/rog/post.rb
CHANGED
@@ -59,20 +59,7 @@ module Rog
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def <=>(other)
|
62
|
-
|
63
|
-
year_compare
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
if (month_compare = @month <=> other.month) != 0 then
|
68
|
-
month_compare
|
69
|
-
end
|
70
|
-
|
71
|
-
if (day_compare = @day <=> other.day) != 0 then
|
72
|
-
day_compare
|
73
|
-
end
|
74
|
-
|
75
|
-
return 0
|
62
|
+
[@year, @month, @day] <=> [other.year, other.month, other.day]
|
76
63
|
end
|
77
64
|
|
78
65
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rog
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-05-
|
6
|
+
version: 0.1.4
|
7
|
+
date: 2006-05-22 00:00:00 +02:00
|
8
8
|
summary: Static Ruby Blog Engine.
|
9
9
|
require_paths:
|
10
10
|
- lib
|