runeblog 0.2.41 → 0.2.46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/bin/blog +4 -7
  3. data/empty_view/themes/standard/blog/post_entry.lt3 +11 -10
  4. data/empty_view/themes/standard/etc/blog.css.lt3 +18 -1
  5. data/empty_view/themes/standard/navbar/faq.lt3 +1 -0
  6. data/empty_view/themes/standard/navbar/navbar.lt3 +1 -0
  7. data/empty_view/themes/standard/post/generate.lt3 +9 -4
  8. data/empty_view/themes/standard/widgets/ad/ad.lt3 +8 -1
  9. data/empty_view/themes/standard/widgets/ad/ad1.png +0 -0
  10. data/empty_view/themes/standard/widgets/ad/ad2.png +0 -0
  11. data/empty_view/themes/standard/widgets/ad/ad3.png +0 -0
  12. data/empty_view/themes/standard/widgets/ad/ad4.png +0 -0
  13. data/empty_view/themes/standard/widgets/bydates/bydates.rb +7 -3
  14. data/empty_view/themes/standard/widgets/links/links.rb +28 -3
  15. data/empty_view/themes/standard/widgets/news/news.rb +7 -3
  16. data/empty_view/themes/standard/widgets/pages/pages.rb +10 -3
  17. data/empty_view/themes/standard/widgets/pinned/pinned.rb +7 -3
  18. data/empty_view/themes/standard/widgets/search/search.rb +7 -3
  19. data/empty_view/themes/standard/widgets/sitemap/sitemap.rb +7 -3
  20. data/empty_view/themes/standard/widgets/tag-cloud/tag-cloud.rb +7 -3
  21. data/lib/default.rb +1 -4
  22. data/lib/global.rb +8 -7
  23. data/lib/helpers-blog.rb +15 -15
  24. data/lib/liveblog.rb +94 -57
  25. data/lib/logging.rb +17 -8
  26. data/lib/post.rb +6 -6
  27. data/lib/publish.rb +4 -4
  28. data/lib/repl.rb +1 -0
  29. data/lib/runeblog.rb +77 -47
  30. data/lib/runeblog_version.rb +1 -1
  31. data/lib/view.rb +2 -8
  32. data/lib/xlate.rb +2 -2
  33. data/test/austin.rb +159 -0
  34. metadata +8 -5
  35. data/empty_view/remote/widgets/links/list.data +0 -3
  36. data/empty_view/remote/widgets/news/list.data +0 -4
  37. data/empty_view/remote/widgets/pages/list.data +0 -4
@@ -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
@@ -144,6 +144,7 @@ module RuneBlog::REPL
144
144
  check_empty(arg)
145
145
  puts unless testing
146
146
  @blog.generate_view(@blog.view)
147
+ @blog.generate_index(@blog.view)
147
148
  @out
148
149
  end
149
150
 
@@ -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 teaser(slug)
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,18 +330,19 @@ class RuneBlog
328
330
  wanted.times do
329
331
  postid = File.basename(enum.next)
330
332
  postid = postid.to_i
331
- text << teaser(postid) # side effect! calls _out
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
- def create_new_post(title, testing = false, teaser: nil, body: nil, views: [])
338
- log!(enter: __method__, args: [title, testing, teaser, body, views])
339
+ def create_new_post(title, testing = false, teaser: nil, body: nil,
340
+ pubdate: Time.now.strftime("%Y-%m-%d"), views: [])
341
+ log!(enter: __method__, args: [title, testing, teaser, body, views], level: 1)
339
342
  meta = nil
340
343
  views = views + [self.view.to_s]
341
344
  Dir.chdir(@root/:posts) do
342
- post = Post.create(title: title, teaser: teaser, body: body, views: views)
345
+ post = Post.create(title: title, teaser: teaser, body: body, pubdate: pubdate, views: views)
343
346
  post.edit unless testing
344
347
  post.build
345
348
  meta = post.meta
@@ -351,7 +354,7 @@ class RuneBlog
351
354
  end
352
355
 
353
356
  def edit_initial_post(file, testing = false)
354
- log!(enter: __method__, args: [file, testing])
357
+ log!(enter: __method__, args: [file, testing], level: 3)
355
358
  debug "=== edit_initial_post #{file.inspect} => #{sourcefile}"
356
359
  sourcefile = @root/:drafts/file
357
360
  result = system!("#@editor #{sourcefile} +8") unless testing
@@ -363,20 +366,20 @@ class RuneBlog
363
366
  end
364
367
 
365
368
  def posts
366
- log!(enter: __method__)
369
+ log!(enter: __method__, level: 3)
367
370
  dir = self.view.dir/:posts
368
371
  posts = Dir.entries(dir).grep(/^\d{4}/)
369
372
  posts
370
373
  end
371
374
 
372
375
  def drafts
373
- log!(enter: __method__)
376
+ log!(enter: __method__, level: 3)
374
377
  dir = @root/:drafts
375
378
  drafts = Dir.entries(dir).grep(/^\d{4}.*/)
376
379
  end
377
380
 
378
381
  def change_view(view)
379
- log!(enter: __method__, args: [view])
382
+ log!(enter: __method__, args: [view], level: 3)
380
383
  raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
381
384
  x = OpenStruct.new
382
385
  x.root, x.current_view, x.editor = @root, view.to_s, @editor # dumb - FIXME later
@@ -400,7 +403,7 @@ class RuneBlog
400
403
  src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
401
404
  xlate cwd: vdir/"themes/standard",
402
405
  src: "blog/generate.lt3", dst: vdir/:remote/"index.html"
403
- generate_index(view) # recent posts (recent.html)
406
+ # generate_index(view) # recent posts (recent.html)
404
407
  # ^ HERE
405
408
  copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
406
409
  rescue => err
@@ -411,7 +414,7 @@ class RuneBlog
411
414
  end
412
415
 
413
416
  def _get_views(draft)
414
- log!(enter: __method__, args: [draft])
417
+ log!(enter: __method__, args: [draft], level: 2)
415
418
  # FIXME dumb code
416
419
  view_line = File.readlines(draft).grep(/^.views /)
417
420
  raise "More than one .views call!" if view_line.size > 1
@@ -422,7 +425,7 @@ class RuneBlog
422
425
  end
423
426
 
424
427
  def _copy_get_dirs(draft, view)
425
- log!(enter: __method__, args: [draft, view])
428
+ log!(enter: __method__, args: [draft, view], level: 2)
426
429
  fname = File.basename(draft)
427
430
  noext = fname.sub(/.lt3$/, "")
428
431
  vdir = @root/:views/view
@@ -435,18 +438,42 @@ class RuneBlog
435
438
  end
436
439
 
437
440
  def _post_metadata(draft, pdraft)
438
- log!(enter: __method__, args: [draft, pdraft])
441
+ log!(enter: __method__, args: [draft, pdraft], level: 2)
442
+ # FIXME store this somewhere
443
+ fname = File.basename(draft) # 0001-this-is-a-post.lt3
444
+ nslug = fname.sub(/.lt3$/, "") # 0001-this-is-a-post
445
+ aslug = nslug.sub(/\d\d\d\d-/, "") # this-is-a-post
446
+ pnum = nslug[0..3] # 0001
439
447
  Dir.chdir(pdraft) do
440
448
  excerpt = File.read("teaser.txt")
449
+ date = _retrieve_metadata(:date)
450
+ longdate = ::Date.parse(date).strftime("%B %e, %Y")
441
451
  title = _retrieve_metadata(:title)
442
- vars = %[.heredoc title\n#{title.chomp}\n.end\n] +
443
- %[.heredoc teaser\n#{excerpt.chomp}\n.end\n]
452
+ tags = _retrieve_metadata(:tags)
453
+ vars = <<~LIVE
454
+ .set post.num = #{pnum}
455
+ .heredoc post.aslug
456
+ #{aslug}
457
+ .end
458
+ .heredoc title
459
+ #{title.chomp}
460
+ .end
461
+ .heredoc post.tags
462
+ #{tags.join(" ")}
463
+ .end
464
+ .heredoc teaser
465
+ #{excerpt.chomp}
466
+ .end
467
+ .heredoc longdate
468
+ #{longdate}
469
+ .end
470
+ LIVE
444
471
  File.open(pdraft/"vars.lt3", "w") {|f| f.puts vars }
445
472
  end
446
473
  end
447
474
 
448
475
  def copy_widget_html(view)
449
- log!(enter: __method__)
476
+ log!(enter: __method__, level: 2)
450
477
  vdir = @root/:views/view
451
478
  remote = vdir/:remote
452
479
  wdir = vdir/:themes/:standard/:widgets
@@ -457,12 +484,15 @@ class RuneBlog
457
484
  create_dirs(rem)
458
485
  files = Dir[w/"*"]
459
486
  files = files.select {|x| x =~ /(html|css)$/ }
460
- files.each {|file| system!("cp #{file} #{rem}") }
487
+ # files.each {|f| STDERR.puts " #{f.inspect}" }
488
+ tag = File.basename(w)
489
+ # STDERR.puts "--- tag: #{tag.inspect}"
490
+ files.each {|file| system!("cp #{file} #{rem}", show: (tag == "zzz")) }
461
491
  end
462
492
  end
463
493
 
464
494
  def _handle_post(draft, view)
465
- log!(enter: __method__, args: [draft, view])
495
+ log!(enter: __method__, args: [draft, view], level: 2)
466
496
  # break into separate methods?
467
497
 
468
498
  fname = File.basename(draft) # 0001-this-is-a-post.lt3
@@ -491,7 +521,7 @@ class RuneBlog
491
521
  end
492
522
 
493
523
  def generate_post(draft)
494
- log!(enter: __method__, args: [draft])
524
+ log!(enter: __method__, args: [draft], level: 1)
495
525
  views = _get_views(draft)
496
526
  views.each do |view|
497
527
  _handle_post(draft, view)
@@ -500,7 +530,7 @@ class RuneBlog
500
530
  end
501
531
  end
502
532
 
503
- def index_entry(view, meta)
533
+ def OLD_index_entry(view, meta)
504
534
  log!(enter: __method__, args: [view, meta])
505
535
  debug "=== index_entry #{view.to_s.inspect} #{meta.num} #{meta.title.inspect}"
506
536
  check_meta(meta, "index_entry1")
@@ -537,7 +567,7 @@ class RuneBlog
537
567
  end
538
568
 
539
569
  def remove_post(num)
540
- log!(enter: __method__, args: [num])
570
+ log!(enter: __method__, args: [num], level: 1)
541
571
  raise ArgumentError unless num.is_a?(Integer)
542
572
  # FIXME update original draft .views
543
573
  tag = prefix(num)
@@ -554,7 +584,7 @@ class RuneBlog
554
584
  end
555
585
 
556
586
  def undelete_post(num)
557
- log!(enter: __method__, args: [num])
587
+ log!(enter: __method__, args: [num], level: 1)
558
588
  raise ArgumentError unless num.is_a?(Integer)
559
589
  files = Find.find(@root/:views).to_a
560
590
  tag = prefix(num)
@@ -570,14 +600,14 @@ class RuneBlog
570
600
  end
571
601
 
572
602
  def delete_draft(num)
573
- log!(enter: __method__, args: [num])
603
+ log!(enter: __method__, args: [num], level: 1)
574
604
  raise ArgumentError unless num.is_a?(Integer)
575
605
  tag = prefix(num)
576
606
  system!("rm -rf #@root/drafts/#{tag}-*")
577
607
  end
578
608
 
579
609
  def make_slug(meta)
580
- log!(enter: __method__, args: [meta])
610
+ log!(enter: __method__, args: [meta], level: 3)
581
611
  raise ArgumentError unless meta.title.is_a?(String)
582
612
  label = '%04d' % meta.num # FIXME can do better
583
613
  slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.2.41"
5
+ VERSION = "0.2.46"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
@@ -8,7 +8,7 @@ class RuneBlog::View
8
8
  include RuneBlog::Helpers
9
9
 
10
10
  def initialize(name)
11
- log!(enter: __method__, args: [name])
11
+ log!(enter: __method__, args: [name], level: 3)
12
12
  raise NoBlogAccessor if RuneBlog.blog.nil?
13
13
  @blog = RuneBlog.blog
14
14
  @name = name
@@ -17,27 +17,23 @@ class RuneBlog::View
17
17
  end
18
18
 
19
19
  def dir
20
- log!(enter: __method__)
21
20
  @blog.root + "/views/#@name/"
22
21
  end
23
22
 
24
23
  def local_index
25
- log!(enter: __method__)
26
24
  dir + "/remote/index.html"
27
25
  end
28
26
 
29
27
  def index
30
- log!(enter: __method__)
31
28
  dir + "index.html"
32
29
  end
33
30
 
34
31
  def to_s
35
- log!(enter: __method__)
36
32
  @name
37
33
  end
38
34
 
39
35
  def publishable_files
40
- log!(enter: __method__)
36
+ log!(enter: __method__, level: 2)
41
37
  vdir = dir()
42
38
  remote = local_index()
43
39
  files = [remote]
@@ -55,12 +51,10 @@ class RuneBlog::View
55
51
  end
56
52
 
57
53
  def can_publish?
58
- log!(enter: __method__)
59
54
  @can_publish
60
55
  end
61
56
 
62
57
  def recent?(file)
63
- log!(enter: __method__, args: [file])
64
58
  File.mtime(file) > File.mtime("#{self.dir()}/last_published")
65
59
  rescue
66
60
  true