rog 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -1
- data/lib/rog/blog.rb +19 -12
- data/lib/rog/rogtasks.rb +25 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -22,6 +22,15 @@ require 'rote/format/html'
|
|
22
22
|
|
23
23
|
include Rote
|
24
24
|
|
25
|
+
require 'rcov/rcovtask'
|
26
|
+
desc "Analyze code coverage of the unit tests."
|
27
|
+
Rcov::RcovTask.new do |t|
|
28
|
+
# change the glob pattern in the next line
|
29
|
+
t.test_files = FileList['tests/ts_*.rb']
|
30
|
+
t.rcov_opts << "--sort coverage" # sort by increasing coverage rate
|
31
|
+
end
|
32
|
+
|
33
|
+
|
25
34
|
# Create a set of tasks with the prefix 'doc' to build the
|
26
35
|
# documentation set. The directory layout is as for the
|
27
36
|
# command-line wrapper (but can be changed of course).
|
@@ -87,7 +96,7 @@ spec = Gem::Specification.new do |s|
|
|
87
96
|
s.platform = Gem::Platform::RUBY
|
88
97
|
s.summary = "Static Ruby Blog Engine."
|
89
98
|
s.name = 'rog'
|
90
|
-
s.version = '0.1.
|
99
|
+
s.version = '0.1.5'
|
91
100
|
|
92
101
|
s.add_dependency('rote', '>= 0.3.2.2')
|
93
102
|
s.add_dependency('rake')
|
data/lib/rog/blog.rb
CHANGED
@@ -44,6 +44,8 @@ we are able to easily:
|
|
44
44
|
require 'yaml'
|
45
45
|
require 'erb'
|
46
46
|
|
47
|
+
require 'time'
|
48
|
+
|
47
49
|
module Rog
|
48
50
|
|
49
51
|
class Blog
|
@@ -197,43 +199,47 @@ module Rog
|
|
197
199
|
$stdout = old_stdout
|
198
200
|
end
|
199
201
|
|
200
|
-
def self.generate_post(postname,tags)
|
202
|
+
def self.generate_post(postname, tags, posttime = Time.now)
|
201
203
|
@postname = postname
|
202
204
|
@tags = tags.split
|
205
|
+
ark_rb = ark_thtml = ""
|
203
206
|
|
204
207
|
open("blog/templates/post.rb.tpl") do |f|
|
205
|
-
ark_rb = f.
|
208
|
+
ark_rb = f.read
|
206
209
|
end
|
207
210
|
|
208
211
|
open("blog/templates/post.thtml.tpl") do |f|
|
209
|
-
ark_thtml = f.
|
212
|
+
ark_thtml = f.read
|
210
213
|
end
|
211
214
|
|
212
|
-
|
215
|
+
# Ricava la stringa 'date' componento l'anno e il mese (in formato 01, 02... 09, 10)
|
216
|
+
data = posttime.year.to_s + posttime.month.to_s.rjust(2).sub(' ','0') + posttime.day.to_s.rjust(2).sub(' ','0')
|
213
217
|
|
214
218
|
data_rb = ERB.new(ark_rb).result(binding)
|
215
219
|
data_thtml = ERB.new(ark_thtml).result(binding)
|
216
220
|
|
217
|
-
open("blog/pages/posts/#{
|
221
|
+
open("blog/pages/posts/#{data}-#{postname}.rb", 'w') do |f|
|
218
222
|
f.puts data_rb
|
219
223
|
end
|
220
224
|
|
221
|
-
open("blog/pages/posts/#{
|
225
|
+
open("blog/pages/posts/#{data}-#{postname}.thtml", 'w') do |f|
|
222
226
|
f.puts data_thtml
|
223
227
|
end
|
224
228
|
end
|
225
229
|
|
226
230
|
def self.generate_tag_archive(tag)
|
227
231
|
@tag = tag
|
232
|
+
ark_rb = ""
|
233
|
+
ark_thtml = ""
|
228
234
|
|
229
235
|
open("blog/templates/archive-tag.rb.tpl") do |f|
|
230
|
-
ark_rb = f.
|
236
|
+
ark_rb = f.read
|
231
237
|
end
|
232
238
|
|
233
239
|
open("blog/templates/archive-tag.thtml.tpl") do |f|
|
234
|
-
ark_thtml = f.
|
240
|
+
ark_thtml = f.read
|
235
241
|
end
|
236
|
-
|
242
|
+
|
237
243
|
data_rb = ERB.new(ark_rb).result(binding)
|
238
244
|
data_thtml = ERB.new(ark_thtml).result(binding)
|
239
245
|
|
@@ -249,14 +255,15 @@ module Rog
|
|
249
255
|
def self.generate_month_archive(year,month)
|
250
256
|
@year = year
|
251
257
|
@month = month
|
252
|
-
|
258
|
+
ark_rb = ""
|
259
|
+
ark_thtml = ""
|
253
260
|
|
254
261
|
open("blog/templates/archive-month.rb.tpl") do |f|
|
255
|
-
ark_rb = f.
|
262
|
+
ark_rb = f.read
|
256
263
|
end
|
257
264
|
|
258
265
|
open("blog/templates/archive-month.thtml.tpl") do |f|
|
259
|
-
ark_thtml = f.
|
266
|
+
ark_thtml = f.read
|
260
267
|
end
|
261
268
|
|
262
269
|
data_rb = ERB.new(ark_rb).result(binding)
|
data/lib/rog/rogtasks.rb
CHANGED
@@ -23,6 +23,8 @@ require 'rog/page'
|
|
23
23
|
require 'rote'
|
24
24
|
require 'rote/rotetasks'
|
25
25
|
|
26
|
+
require 'time'
|
27
|
+
|
26
28
|
module Rog
|
27
29
|
|
28
30
|
#####
|
@@ -108,8 +110,24 @@ module Rog
|
|
108
110
|
print "tags: "
|
109
111
|
post_tags = STDIN.gets.chomp
|
110
112
|
|
113
|
+
time = Time.now
|
114
|
+
|
115
|
+
# Ricava la stringa 'date' componento l'anno e il mese (in formato 01, 02... 09, 10)
|
116
|
+
year_s = time.year.to_s
|
117
|
+
month_s = time.month.to_s.rjust(2).sub(' ','0')
|
118
|
+
|
119
|
+
date = year_s + month_s
|
120
|
+
|
111
121
|
begin
|
112
|
-
BlogUtils.generate_post(post_name, post_tags)
|
122
|
+
BlogUtils.generate_post(post_name, post_tags, time)
|
123
|
+
if !File.exists?("#{archives_path}/archive-#{date}.rb")
|
124
|
+
BlogUtils.generate_month_archive(year_s, month_s)
|
125
|
+
end
|
126
|
+
post_tags.split.each do |singletag|
|
127
|
+
if !File.exists?("#{@archives_path}/archive-#{singletag}.rb")
|
128
|
+
BlogUtils.generate_tag_archive(singletag)
|
129
|
+
end
|
130
|
+
end
|
113
131
|
end if post_name.length > 0
|
114
132
|
end
|
115
133
|
|
@@ -134,6 +152,12 @@ module Rog
|
|
134
152
|
end
|
135
153
|
end
|
136
154
|
|
155
|
+
task :change_theme do
|
156
|
+
print "Insert the path to your new style sheet: "
|
157
|
+
style = STDIN.gets.chomp
|
158
|
+
puts `cp #{style} #{@blog_path}/res/styles.css`
|
159
|
+
end
|
160
|
+
|
137
161
|
task :publish do
|
138
162
|
puts `rsync -avr #{@output_dir + '/'} #{$blog.publish_url}`
|
139
163
|
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.5
|
7
|
+
date: 2006-05-29 00:00:00 +02:00
|
8
8
|
summary: Static Ruby Blog Engine.
|
9
9
|
require_paths:
|
10
10
|
- lib
|