runeblog 0.2.39 → 0.2.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mkwidget +209 -0
- data/empty_view/themes/standard/blog/index.lt3 +0 -1
- data/empty_view/themes/standard/etc/blog.css.lt3 +6 -1
- data/empty_view/themes/standard/navbar/faq.lt3 +1 -0
- data/empty_view/themes/standard/navbar/navbar.lt3 +1 -0
- data/empty_view/themes/standard/post/generate.lt3 +9 -4
- data/empty_view/themes/standard/widgets/ad/ad.lt3 +8 -1
- data/empty_view/themes/standard/widgets/ad/ad1.png +0 -0
- data/empty_view/themes/standard/widgets/ad/ad2.png +0 -0
- data/empty_view/themes/standard/widgets/ad/ad3.png +0 -0
- data/empty_view/themes/standard/widgets/ad/ad4.png +0 -0
- data/empty_view/themes/standard/widgets/bydates/README +2 -0
- data/empty_view/themes/standard/widgets/bydates/bydates.lt3 +2 -0
- data/empty_view/themes/standard/widgets/bydates/bydates.rb +14 -0
- data/empty_view/themes/standard/widgets/bydates/card.css +1 -0
- data/empty_view/themes/standard/widgets/bydates/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/bydates/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/bydates/main.css +2 -0
- data/empty_view/themes/standard/widgets/bydates/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/bydates/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/bydates/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/bydates/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/links/README +2 -0
- data/empty_view/themes/standard/widgets/links/card.css +1 -0
- data/empty_view/themes/standard/widgets/links/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/links/links.lt3 +1 -1
- data/empty_view/themes/standard/widgets/links/links.rb +14 -0
- data/empty_view/themes/standard/widgets/links/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/links/main.css +2 -0
- data/empty_view/themes/standard/widgets/links/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/links/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/links/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/links/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/news/README +2 -0
- data/empty_view/themes/standard/widgets/news/card.css +1 -0
- data/empty_view/themes/standard/widgets/news/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/news/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/news/main.css +2 -0
- data/empty_view/themes/standard/widgets/news/news.rb +14 -0
- data/empty_view/themes/standard/widgets/news/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/news/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/news/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/news/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/pages/{pieces/card.css → card.css} +0 -0
- data/empty_view/themes/standard/widgets/pages/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/pages/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/pages/main.css +2 -0
- data/empty_view/themes/standard/widgets/pages/pages.rb +4 -1
- data/empty_view/themes/standard/widgets/pages/pieces/main-head.lt3 +3 -1
- data/empty_view/themes/standard/widgets/pinned/README +2 -0
- data/empty_view/themes/standard/widgets/pinned/card.css +1 -0
- data/empty_view/themes/standard/widgets/pinned/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/pinned/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/pinned/main.css +2 -0
- data/empty_view/themes/standard/widgets/pinned/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/pinned/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/pinned/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/pinned/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/pinned/pinned.lt3 +2 -0
- data/empty_view/themes/standard/widgets/pinned/pinned.rb +14 -0
- data/empty_view/themes/standard/widgets/search/README +2 -0
- data/empty_view/themes/standard/widgets/search/card.css +1 -0
- data/empty_view/themes/standard/widgets/search/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/search/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/search/main.css +2 -0
- data/empty_view/themes/standard/widgets/search/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/search/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/search/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/search/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/search/search.lt3 +2 -0
- data/empty_view/themes/standard/widgets/search/search.rb +14 -0
- data/empty_view/themes/standard/widgets/sitemap/README +2 -0
- data/empty_view/themes/standard/widgets/sitemap/card.css +1 -0
- data/empty_view/themes/standard/widgets/sitemap/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/sitemap/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/sitemap/main.css +2 -0
- data/empty_view/themes/standard/widgets/sitemap/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/sitemap/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/sitemap/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/sitemap/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/sitemap/sitemap.lt3 +2 -0
- data/empty_view/themes/standard/widgets/sitemap/sitemap.rb +14 -0
- data/empty_view/themes/standard/widgets/tag-cloud/OLD-example.lt3 +12 -0
- data/empty_view/themes/standard/widgets/tag-cloud/README +2 -0
- data/empty_view/themes/standard/widgets/tag-cloud/card.css +1 -0
- data/empty_view/themes/standard/widgets/tag-cloud/custom.rb +1 -0
- data/empty_view/themes/standard/widgets/tag-cloud/local-vars.lt3 +12 -0
- data/empty_view/themes/standard/widgets/tag-cloud/main.css +2 -0
- data/empty_view/themes/standard/widgets/tag-cloud/pieces/card-head.lt3 +8 -0
- data/empty_view/themes/standard/widgets/tag-cloud/pieces/card-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/tag-cloud/pieces/main-head.lt3 +10 -0
- data/empty_view/themes/standard/widgets/tag-cloud/pieces/main-tail.lt3 +4 -0
- data/empty_view/themes/standard/widgets/tag-cloud/tag-cloud.lt3 +1 -10
- data/empty_view/themes/standard/widgets/tag-cloud/tag-cloud.rb +14 -0
- data/lib/default.rb +1 -4
- data/lib/global.rb +8 -7
- data/lib/helpers-blog.rb +15 -15
- data/lib/liveblog.rb +62 -28
- data/lib/logging.rb +17 -8
- data/lib/post.rb +6 -6
- data/lib/publish.rb +4 -4
- data/lib/runeblog.rb +79 -47
- data/lib/runeblog_version.rb +1 -1
- data/lib/view.rb +2 -8
- data/lib/xlate.rb +2 -2
- data/test/austin.rb +150 -0
- data/test/make_blog.rb +23 -2
- metadata +88 -8
- data/empty_view/remote/widgets/links/list.data +0 -3
- data/empty_view/remote/widgets/news/list.data +0 -4
- data/empty_view/remote/widgets/pages/list.data +0 -4
- data/empty_view/themes/standard/widgets/calendar/calendar.lt3 +0 -6
- data/empty_view/themes/standard/widgets/pages/pieces/main.css +0 -1
data/lib/logging.rb
CHANGED
@@ -2,8 +2,17 @@ unless self.respond_to?("log!")
|
|
2
2
|
$logging = true
|
3
3
|
$log = File.new("/tmp/runeblog.log","w")
|
4
4
|
|
5
|
-
def
|
5
|
+
def outlog(str = "", stderr: false)
|
6
|
+
$log.puts str
|
7
|
+
STDERR.puts str if stderr
|
8
|
+
end
|
9
|
+
|
10
|
+
def log!(str: "", enter: nil, args: [], pwd: false, dir: false, level: 0, stderr: false)
|
6
11
|
return unless $logging
|
12
|
+
@err_level ||= ENV['RUNEBLOG_ERROR_LEVEL']
|
13
|
+
@err_level ||= 0
|
14
|
+
return if level < @err_level
|
15
|
+
|
7
16
|
time = Time.now.strftime("%H:%M:%S")
|
8
17
|
|
9
18
|
meth = ""
|
@@ -17,16 +26,16 @@ unless self.respond_to?("log!")
|
|
17
26
|
str = " ... #{str}" unless str.empty?
|
18
27
|
indent = " "*12
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
outlog "#{time} #{meth}#{para}"
|
30
|
+
outlog "#{indent} #{str} " unless str.empty?
|
31
|
+
outlog "#{indent} #{source}"
|
32
|
+
outlog "#{indent} pwd = #{Dir.pwd} " if pwd
|
24
33
|
if dir
|
25
34
|
files = (Dir.entries('.') - %w[. ..]).join(" ")
|
26
|
-
|
35
|
+
outlog "#{indent} dir/* = #{files}"
|
27
36
|
end
|
28
|
-
#
|
29
|
-
|
37
|
+
# outlog "#{indent} livetext params = #{livedata.inpect} " unless livedata.nil?
|
38
|
+
outlog
|
30
39
|
$log.close
|
31
40
|
$log = File.new("/tmp/runeblog.log","a")
|
32
41
|
end
|
data/lib/post.rb
CHANGED
@@ -10,14 +10,14 @@ class RuneBlog::Post
|
|
10
10
|
include RuneBlog::Helpers
|
11
11
|
|
12
12
|
def self.files(num, root)
|
13
|
-
log!(enter: __method__, args: [num, root])
|
13
|
+
log!(enter: __method__, args: [num, root], level: 3)
|
14
14
|
files = Find.find(root).to_a
|
15
15
|
result = files.grep(/#{prefix(num)}-/)
|
16
16
|
result
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.load(post)
|
20
|
-
log!(enter: __method__, args: [post])
|
20
|
+
log!(enter: __method__, args: [post], level: 3)
|
21
21
|
raise "Doesn't work right now"
|
22
22
|
raise NoBlogAccessor if RuneBlog.blog.nil?
|
23
23
|
# "post" is a slug
|
@@ -36,7 +36,7 @@ class RuneBlog::Post
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def write_metadata(meta) # FIXME ???
|
39
|
-
log!(enter: __method__, args: [meta])
|
39
|
+
log!(enter: __method__, args: [meta], level: 3)
|
40
40
|
debug "=== write_metadata:"
|
41
41
|
debug "-----\n#{meta.inspect}\n-----"
|
42
42
|
fname2 = "metadata.txt"
|
@@ -57,7 +57,7 @@ class RuneBlog::Post
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def initialize
|
60
|
-
log!(enter: __method__)
|
60
|
+
log!(enter: __method__, level: 3)
|
61
61
|
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
62
62
|
@meta = OpenStruct.new
|
63
63
|
end
|
@@ -115,7 +115,7 @@ class RuneBlog::ViewPost
|
|
115
115
|
:teaser_text
|
116
116
|
|
117
117
|
def initialize(view, postdir)
|
118
|
-
log!(enter: __method__, args: [view, postdir])
|
118
|
+
log!(enter: __method__, args: [view, postdir], level: 3)
|
119
119
|
# Assumes already parsed/processed
|
120
120
|
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
121
121
|
@path = postdir.dup
|
@@ -131,7 +131,7 @@ class RuneBlog::ViewPost
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def get_dirs
|
134
|
-
log!(enter: __method__, args: [view, postdir])
|
134
|
+
log!(enter: __method__, args: [view, postdir], level: 3)
|
135
135
|
fname = File.basename(draft)
|
136
136
|
noext = fname.sub(/.lt3$/, "")
|
137
137
|
vdir = @root/:views/view
|
data/lib/publish.rb
CHANGED
@@ -21,25 +21,25 @@ class RuneBlog::Publishing
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_h
|
24
|
-
log!(enter: __method__)
|
24
|
+
log!(enter: __method__, level: 3)
|
25
25
|
{user: @user, server: @server, docroot: @docroot,
|
26
26
|
path: @path, proto: @proto}
|
27
27
|
end
|
28
28
|
|
29
29
|
def url
|
30
|
-
log!(enter: __method__)
|
30
|
+
log!(enter: __method__, level: 3)
|
31
31
|
vname = @blog.view.name # .gsub(/_/, "\\_")
|
32
32
|
url = "#@proto://#@server/#@path" # /#{vname}"
|
33
33
|
end
|
34
34
|
|
35
35
|
def system!(str)
|
36
|
-
log!(enter: __method__, args: [str])
|
36
|
+
log!(enter: __method__, args: [str], level: 1)
|
37
37
|
rc = system(str)
|
38
38
|
rc
|
39
39
|
end
|
40
40
|
|
41
41
|
def publish(files, assets=[])
|
42
|
-
log!(enter: __method__, args: [files, assets])
|
42
|
+
log!(enter: __method__, args: [files, assets], level: 1)
|
43
43
|
dir = @docroot/@path
|
44
44
|
view_name = @blog.view.name
|
45
45
|
viewpath = dir # /view_name
|
data/lib/runeblog.rb
CHANGED
@@ -53,7 +53,7 @@ class RuneBlog
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.create(root = ".blogs")
|
56
|
-
log!(enter: __method__, args: [root])
|
56
|
+
log!(enter: __method__, args: [root], level: 1)
|
57
57
|
# Crude - FIXME later - # What views are there? Publishing, etc.
|
58
58
|
self.blog = self # Weird. Like a singleton - dumbass circular dependency?
|
59
59
|
root = Dir.pwd/root
|
@@ -101,7 +101,7 @@ class RuneBlog
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def _deploy_local(dir)
|
104
|
-
log!(enter: __method__, args: [dir])
|
104
|
+
log!(enter: __method__, args: [dir], level: 1)
|
105
105
|
Dir.chdir(dir) do
|
106
106
|
views = _retrieve_metadata(:views)
|
107
107
|
views.each {|v| system!("cp *html #@root/views/#{v}/remote") }
|
@@ -132,7 +132,7 @@ class RuneBlog
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def process_post(sourcefile)
|
135
|
-
log!(enter: __method__, args: [dir])
|
135
|
+
log!(enter: __method__, args: [dir], level: 2)
|
136
136
|
nslug = sourcefile.sub(/.lt3/, "")
|
137
137
|
dir = @root/:posts/nslug
|
138
138
|
create_dir(dir)
|
@@ -141,7 +141,7 @@ class RuneBlog
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def inspect
|
144
|
-
log!(enter: __method__)
|
144
|
+
log!(enter: __method__, level: 3)
|
145
145
|
str = "blog: "
|
146
146
|
ivars = ["@root", "@sequence"] # self.instance_variables
|
147
147
|
ivars.each do |iv|
|
@@ -152,30 +152,30 @@ class RuneBlog
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def view?(name)
|
155
|
-
log!(enter: __method__, args: [name])
|
155
|
+
log!(enter: __method__, args: [name], level: 3)
|
156
156
|
raise ArgumentError unless name.is_a?(String) && ! name.empty?
|
157
157
|
views.any? {|x| x.name == name }
|
158
158
|
end
|
159
159
|
|
160
160
|
def view(name = nil)
|
161
|
-
log!(enter: __method__, args: [name])
|
161
|
+
log!(enter: __method__, args: [name], level: 3)
|
162
162
|
raise ArgumentError unless name.nil? || (name.is_a?(String) && ! name.empty?)
|
163
163
|
name.nil? ? @view : str2view(name)
|
164
164
|
end
|
165
165
|
|
166
166
|
def str2view(str)
|
167
|
-
log!(enter: __method__, args: [str])
|
167
|
+
log!(enter: __method__, args: [str], level: 3)
|
168
168
|
raise ArgumentError unless str.is_a?(String) && ! str.empty?
|
169
169
|
@views.find {|x| x.name == str }
|
170
170
|
end
|
171
171
|
|
172
172
|
def _set_publisher
|
173
|
-
log!(enter: __method__)
|
173
|
+
log!(enter: __method__, level: 3)
|
174
174
|
@view.publisher = RuneBlog::Publishing.new(@view.to_s) # FIXME refactor
|
175
175
|
end
|
176
176
|
|
177
177
|
def view=(arg)
|
178
|
-
log!(enter: __method__, args: [arg])
|
178
|
+
log!(enter: __method__, args: [arg], level: 2)
|
179
179
|
case arg
|
180
180
|
when RuneBlog::View
|
181
181
|
@view = arg
|
@@ -191,19 +191,19 @@ class RuneBlog
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def get_sequence
|
194
|
-
log!(enter: __method__)
|
194
|
+
log!(enter: __method__, level: 3)
|
195
195
|
File.read(@root/:sequence).to_i
|
196
196
|
end
|
197
197
|
|
198
198
|
def next_sequence
|
199
|
-
log!(enter: __method__)
|
199
|
+
log!(enter: __method__, level: 3)
|
200
200
|
@sequence += 1
|
201
201
|
dump(@sequence, @root/:sequence)
|
202
202
|
@sequence
|
203
203
|
end
|
204
204
|
|
205
205
|
def viewdir(v = nil) # delete?
|
206
|
-
log!(enter: __method__, args: [v])
|
206
|
+
log!(enter: __method__, args: [v], level: 3)
|
207
207
|
v = str2view(v) if v.is_a?(String)
|
208
208
|
raise ArgumentError unless v.nil? || v.is_a?(RuneBlog::View)
|
209
209
|
v ||= @view
|
@@ -211,17 +211,17 @@ class RuneBlog
|
|
211
211
|
end
|
212
212
|
|
213
213
|
def self.exist?
|
214
|
-
log!(enter: __method__)
|
214
|
+
log!(enter: __method__, level: 3)
|
215
215
|
Dir.exist?(DotDir) && File.exist?(DotDir/ConfigFile)
|
216
216
|
end
|
217
217
|
|
218
218
|
def mark_last_published(str)
|
219
|
-
log!(enter: __method__, args: [str])
|
219
|
+
log!(enter: __method__, args: [str], level: 2)
|
220
220
|
dump(str, "#{self.view.dir}/last_published")
|
221
221
|
end
|
222
222
|
|
223
223
|
def add_view(view_name)
|
224
|
-
log!(enter: __method__, args: [view_name])
|
224
|
+
log!(enter: __method__, args: [view_name], level: 2)
|
225
225
|
view = RuneBlog::View.new(view_name)
|
226
226
|
@view = view # current view
|
227
227
|
@views << view # all views
|
@@ -229,7 +229,7 @@ class RuneBlog
|
|
229
229
|
end
|
230
230
|
|
231
231
|
def make_empty_view_tree(view_name)
|
232
|
-
log!(enter: __method__, args: [view_name])
|
232
|
+
log!(enter: __method__, args: [view_name], level: 2)
|
233
233
|
Dir.chdir(@root) do
|
234
234
|
cmd = "cp -r #{RuneBlog::Path}/../empty_view views/#{view_name}"
|
235
235
|
system!(cmd)
|
@@ -237,7 +237,7 @@ class RuneBlog
|
|
237
237
|
end
|
238
238
|
|
239
239
|
def check_valid_new_view(view_name)
|
240
|
-
log!(enter: __method__, args: [view_name])
|
240
|
+
log!(enter: __method__, args: [view_name], level: 3)
|
241
241
|
raise ArgumentError unless view_name.is_a?(String)
|
242
242
|
raise ArgumentError if view_name.empty?
|
243
243
|
names = self.views.map(&:to_s)
|
@@ -249,9 +249,11 @@ class RuneBlog
|
|
249
249
|
end
|
250
250
|
|
251
251
|
def create_view(view_name)
|
252
|
-
log!(enter: __method__, args: [view_name])
|
252
|
+
log!(enter: __method__, args: [view_name], level: 2)
|
253
253
|
check_valid_new_view(view_name)
|
254
254
|
make_empty_view_tree(view_name)
|
255
|
+
# STDERR.puts "Made empty tree!"
|
256
|
+
# system("bash")
|
255
257
|
add_view(view_name)
|
256
258
|
mark_last_published("Initial creation")
|
257
259
|
end
|
@@ -267,7 +269,7 @@ class RuneBlog
|
|
267
269
|
end
|
268
270
|
|
269
271
|
def view_files
|
270
|
-
log!(enter: __method__)
|
272
|
+
log!(enter: __method__, level: 2)
|
271
273
|
vdir = self.view.dir
|
272
274
|
files = [vdir/"index.html"]
|
273
275
|
files += posts.map {|x| vdir/x }
|
@@ -275,7 +277,7 @@ class RuneBlog
|
|
275
277
|
end
|
276
278
|
|
277
279
|
def post_lookup(postid) # side-effect?
|
278
|
-
log!(enter: __method__, args: [postid])
|
280
|
+
log!(enter: __method__, args: [postid], level: 2)
|
279
281
|
slug = title = date = teaser_text = nil
|
280
282
|
|
281
283
|
dir_posts = @vdir/:posts
|
@@ -289,8 +291,8 @@ class RuneBlog
|
|
289
291
|
vp
|
290
292
|
end
|
291
293
|
|
292
|
-
def
|
293
|
-
log!(enter: __method__, args: [slug])
|
294
|
+
def index_entry(slug)
|
295
|
+
log!(enter: __method__, args: [slug], level: 2)
|
294
296
|
id = slug.to_i
|
295
297
|
text = nil
|
296
298
|
@theme = @view.dir/"themes/standard"
|
@@ -303,13 +305,13 @@ class RuneBlog
|
|
303
305
|
path = vp.path
|
304
306
|
url = aslug + ".html"
|
305
307
|
date = ::Date.parse(date)
|
306
|
-
date = date.strftime("%B %e<br>%Y")
|
308
|
+
date = date.strftime("%B %e<br><div style='float: right'>%Y</div>")
|
307
309
|
text = interpolate(@_post_entry, binding)
|
308
310
|
text
|
309
311
|
end
|
310
312
|
|
311
313
|
def collect_recent_posts(file)
|
312
|
-
log!(enter: __method__, args: [file])
|
314
|
+
log!(enter: __method__, args: [file], level: 3)
|
313
315
|
posts = nil
|
314
316
|
dir_posts = @vdir/:posts
|
315
317
|
entries = Dir.entries(dir_posts)
|
@@ -328,14 +330,14 @@ class RuneBlog
|
|
328
330
|
wanted.times do
|
329
331
|
postid = File.basename(enum.next)
|
330
332
|
postid = postid.to_i
|
331
|
-
text <<
|
333
|
+
text << index_entry(postid) # side effect! calls _out
|
332
334
|
end
|
333
335
|
text << "</body></html>"
|
334
336
|
File.write(@vdir/:remote/file, text)
|
335
337
|
end
|
336
338
|
|
337
339
|
def create_new_post(title, testing = false, teaser: nil, body: nil, views: [])
|
338
|
-
log!(enter: __method__, args: [title, testing, teaser, body, views])
|
340
|
+
log!(enter: __method__, args: [title, testing, teaser, body, views], level: 1)
|
339
341
|
meta = nil
|
340
342
|
views = views + [self.view.to_s]
|
341
343
|
Dir.chdir(@root/:posts) do
|
@@ -351,7 +353,7 @@ class RuneBlog
|
|
351
353
|
end
|
352
354
|
|
353
355
|
def edit_initial_post(file, testing = false)
|
354
|
-
log!(enter: __method__, args: [file, testing])
|
356
|
+
log!(enter: __method__, args: [file, testing], level: 3)
|
355
357
|
debug "=== edit_initial_post #{file.inspect} => #{sourcefile}"
|
356
358
|
sourcefile = @root/:drafts/file
|
357
359
|
result = system!("#@editor #{sourcefile} +8") unless testing
|
@@ -363,20 +365,20 @@ class RuneBlog
|
|
363
365
|
end
|
364
366
|
|
365
367
|
def posts
|
366
|
-
log!(enter: __method__)
|
368
|
+
log!(enter: __method__, level: 3)
|
367
369
|
dir = self.view.dir/:posts
|
368
370
|
posts = Dir.entries(dir).grep(/^\d{4}/)
|
369
371
|
posts
|
370
372
|
end
|
371
373
|
|
372
374
|
def drafts
|
373
|
-
log!(enter: __method__)
|
375
|
+
log!(enter: __method__, level: 3)
|
374
376
|
dir = @root/:drafts
|
375
377
|
drafts = Dir.entries(dir).grep(/^\d{4}.*/)
|
376
378
|
end
|
377
379
|
|
378
380
|
def change_view(view)
|
379
|
-
log!(enter: __method__, args: [view])
|
381
|
+
log!(enter: __method__, args: [view], level: 3)
|
380
382
|
raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
|
381
383
|
x = OpenStruct.new
|
382
384
|
x.root, x.current_view, x.editor = @root, view.to_s, @editor # dumb - FIXME later
|
@@ -393,13 +395,15 @@ class RuneBlog
|
|
393
395
|
|
394
396
|
def generate_view(view) # huh?
|
395
397
|
log!(enter: __method__, args: [view])
|
396
|
-
|
398
|
+
# generate_index(view) # recent posts (recent.html)
|
397
399
|
vdir = @root/:views/view
|
398
400
|
@theme = @root/:views/view/:themes/:standard
|
399
401
|
xlate cwd: vdir/"themes/standard/etc",
|
400
402
|
src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
|
401
403
|
xlate cwd: vdir/"themes/standard",
|
402
404
|
src: "blog/generate.lt3", dst: vdir/:remote/"index.html"
|
405
|
+
# generate_index(view) # recent posts (recent.html)
|
406
|
+
# ^ HERE
|
403
407
|
copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
|
404
408
|
rescue => err
|
405
409
|
puts err
|
@@ -409,7 +413,7 @@ class RuneBlog
|
|
409
413
|
end
|
410
414
|
|
411
415
|
def _get_views(draft)
|
412
|
-
log!(enter: __method__, args: [draft])
|
416
|
+
log!(enter: __method__, args: [draft], level: 2)
|
413
417
|
# FIXME dumb code
|
414
418
|
view_line = File.readlines(draft).grep(/^.views /)
|
415
419
|
raise "More than one .views call!" if view_line.size > 1
|
@@ -420,7 +424,7 @@ class RuneBlog
|
|
420
424
|
end
|
421
425
|
|
422
426
|
def _copy_get_dirs(draft, view)
|
423
|
-
log!(enter: __method__, args: [draft, view])
|
427
|
+
log!(enter: __method__, args: [draft, view], level: 2)
|
424
428
|
fname = File.basename(draft)
|
425
429
|
noext = fname.sub(/.lt3$/, "")
|
426
430
|
vdir = @root/:views/view
|
@@ -433,18 +437,42 @@ class RuneBlog
|
|
433
437
|
end
|
434
438
|
|
435
439
|
def _post_metadata(draft, pdraft)
|
436
|
-
log!(enter: __method__, args: [draft, pdraft])
|
440
|
+
log!(enter: __method__, args: [draft, pdraft], level: 2)
|
441
|
+
# FIXME store this somewhere
|
442
|
+
fname = File.basename(draft) # 0001-this-is-a-post.lt3
|
443
|
+
nslug = fname.sub(/.lt3$/, "") # 0001-this-is-a-post
|
444
|
+
aslug = nslug.sub(/\d\d\d\d-/, "") # this-is-a-post
|
445
|
+
pnum = nslug[0..3] # 0001
|
437
446
|
Dir.chdir(pdraft) do
|
438
447
|
excerpt = File.read("teaser.txt")
|
448
|
+
date = _retrieve_metadata(:date)
|
449
|
+
longdate = ::Date.parse(date).strftime("%B %e, %Y")
|
439
450
|
title = _retrieve_metadata(:title)
|
440
|
-
|
441
|
-
|
451
|
+
tags = _retrieve_metadata(:tags)
|
452
|
+
vars = <<~LIVE
|
453
|
+
.set post.num = #{pnum}
|
454
|
+
.heredoc post.aslug
|
455
|
+
#{aslug}
|
456
|
+
.end
|
457
|
+
.heredoc title
|
458
|
+
#{title.chomp}
|
459
|
+
.end
|
460
|
+
.heredoc post.tags
|
461
|
+
#{tags.join(" ")}
|
462
|
+
.end
|
463
|
+
.heredoc teaser
|
464
|
+
#{excerpt.chomp}
|
465
|
+
.end
|
466
|
+
.heredoc longdate
|
467
|
+
#{longdate}
|
468
|
+
.end
|
469
|
+
LIVE
|
442
470
|
File.open(pdraft/"vars.lt3", "w") {|f| f.puts vars }
|
443
471
|
end
|
444
472
|
end
|
445
473
|
|
446
474
|
def copy_widget_html(view)
|
447
|
-
log!(enter: __method__)
|
475
|
+
log!(enter: __method__, level: 2)
|
448
476
|
vdir = @root/:views/view
|
449
477
|
remote = vdir/:remote
|
450
478
|
wdir = vdir/:themes/:standard/:widgets
|
@@ -454,13 +482,16 @@ class RuneBlog
|
|
454
482
|
rem = w.sub(/themes.standard/, "remote")
|
455
483
|
create_dirs(rem)
|
456
484
|
files = Dir[w/"*"]
|
457
|
-
|
458
|
-
|
485
|
+
files = files.select {|x| x =~ /(html|css)$/ }
|
486
|
+
# files.each {|f| STDERR.puts " #{f.inspect}" }
|
487
|
+
tag = File.basename(w)
|
488
|
+
# STDERR.puts "--- tag: #{tag.inspect}"
|
489
|
+
files.each {|file| system!("cp #{file} #{rem}", show: (tag == "zzz")) }
|
459
490
|
end
|
460
491
|
end
|
461
492
|
|
462
493
|
def _handle_post(draft, view)
|
463
|
-
log!(enter: __method__, args: [draft, view])
|
494
|
+
log!(enter: __method__, args: [draft, view], level: 2)
|
464
495
|
# break into separate methods?
|
465
496
|
|
466
497
|
fname = File.basename(draft) # 0001-this-is-a-post.lt3
|
@@ -489,15 +520,16 @@ class RuneBlog
|
|
489
520
|
end
|
490
521
|
|
491
522
|
def generate_post(draft)
|
492
|
-
log!(enter: __method__, args: [draft])
|
523
|
+
log!(enter: __method__, args: [draft], level: 1)
|
493
524
|
views = _get_views(draft)
|
494
525
|
views.each do |view|
|
495
526
|
_handle_post(draft, view)
|
496
|
-
|
527
|
+
# generate_view(view) # FIXME leads to inefficiency?
|
528
|
+
# ^ HERE
|
497
529
|
end
|
498
530
|
end
|
499
531
|
|
500
|
-
def
|
532
|
+
def OLD_index_entry(view, meta)
|
501
533
|
log!(enter: __method__, args: [view, meta])
|
502
534
|
debug "=== index_entry #{view.to_s.inspect} #{meta.num} #{meta.title.inspect}"
|
503
535
|
check_meta(meta, "index_entry1")
|
@@ -534,7 +566,7 @@ class RuneBlog
|
|
534
566
|
end
|
535
567
|
|
536
568
|
def remove_post(num)
|
537
|
-
log!(enter: __method__, args: [num])
|
569
|
+
log!(enter: __method__, args: [num], level: 1)
|
538
570
|
raise ArgumentError unless num.is_a?(Integer)
|
539
571
|
# FIXME update original draft .views
|
540
572
|
tag = prefix(num)
|
@@ -551,7 +583,7 @@ class RuneBlog
|
|
551
583
|
end
|
552
584
|
|
553
585
|
def undelete_post(num)
|
554
|
-
log!(enter: __method__, args: [num])
|
586
|
+
log!(enter: __method__, args: [num], level: 1)
|
555
587
|
raise ArgumentError unless num.is_a?(Integer)
|
556
588
|
files = Find.find(@root/:views).to_a
|
557
589
|
tag = prefix(num)
|
@@ -567,14 +599,14 @@ class RuneBlog
|
|
567
599
|
end
|
568
600
|
|
569
601
|
def delete_draft(num)
|
570
|
-
log!(enter: __method__, args: [num])
|
602
|
+
log!(enter: __method__, args: [num], level: 1)
|
571
603
|
raise ArgumentError unless num.is_a?(Integer)
|
572
604
|
tag = prefix(num)
|
573
605
|
system!("rm -rf #@root/drafts/#{tag}-*")
|
574
606
|
end
|
575
607
|
|
576
608
|
def make_slug(meta)
|
577
|
-
log!(enter: __method__, args: [meta])
|
609
|
+
log!(enter: __method__, args: [meta], level: 3)
|
578
610
|
raise ArgumentError unless meta.title.is_a?(String)
|
579
611
|
label = '%04d' % meta.num # FIXME can do better
|
580
612
|
slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|