runeblog 0.3.20 → 0.3.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 564da6b288bef18302dfeea653099fa7fe119d09f83a53d17203a36fc84c56fa
4
- data.tar.gz: e58a5ef46811db88820a7c8436e59511bdc89e38145e5d8516dfa7ac8878dfae
3
+ metadata.gz: 1634f68d28af34445954bd9850f55772966c33f8d2f007527b26eecc032f1b53
4
+ data.tar.gz: 11c6fdeddde23b4fed649723f3ad922f9ed7315caa611136e5f1918ef8c9e281
5
5
  SHA512:
6
- metadata.gz: d15663f8d0f14e58276cddb83f898cd08db8014d5939b1bab27b8328765545c55a619a4d034a3848956839db1f21765a6cfac4a681136a4c3ada5c0fb223121e
7
- data.tar.gz: 2eb21595baf1cb03dceb7a6d039fa31a473ae54243b6768771a08c7b49de55897bdc391e22386d236bc7d7ee067184e0849645259adf73643ece3e1d9ae369e1
6
+ metadata.gz: 88fe3e00659520d8f2374e083bb244a1d8dfb93db05d035191d669f4b0a73c74f248cba790680a90d52e4dcafc63dc3c0c27f7d8968771b9536b19aab49b6d66
7
+ data.tar.gz: 0e33bd019f9a7b2278543291779a46234db6b845a4a7f282c8b7fdad0548f0af5dce5ccac2b9315d61636d44a51f6183b8ef1ee41befbaccd9708d383aa42851
data/bin/blog CHANGED
@@ -27,8 +27,12 @@ end
27
27
  def get_universal
28
28
  univ = "#{@blog.root}/data/universal.lt3"
29
29
  if yesno("Faster initial setup? (no: edit universal.lt3)")
30
- author = ask!(" Author name: ")
31
- site = ask!(" Site/domain: ")
30
+ # author = ask!(" Author name: ")
31
+ # site = ask!(" Site/domain: ")
32
+ # Temporarily, for speed:
33
+ author, site = "Hal Fulton", "somedomain.com"
34
+ puts " Author name: #{author}"
35
+ puts " Site/domain: #{site}"
32
36
  # Now stash it...
33
37
  str = File.read(univ)
34
38
  str = str.gsub(/AUTHOR/, author)
@@ -41,22 +45,16 @@ def get_universal
41
45
  end
42
46
 
43
47
  def get_global
48
+ view_name = ask!(" Filename: ")
49
+ @blog.create_view(view_name) # call change_view??
44
50
  if yesno("Faster view setup? (no: edit global.lt3)")
45
- view_name = ask!(" Filename: ")
46
- @blog.create_view(view_name) # call change_view??
47
51
  title = ask!(" View title: ")
48
52
  subtitle = ask!(" Subtitle : ")
49
53
  domain = ask!(" Domain : ")
50
-
51
- vfile = "#{@blog.root}/views/#{view_name}/settings/view.txt"
52
- hash = {/VIEW_NAME/ => view_name,
53
- /VIEW_TITLE/ => title,
54
- /VIEW_SUBTITLE/ => subtitle,
55
- /VIEW_DOMAIN/ => domain}
56
- @blog.complete_file(vfile, nil, hash)
54
+ modify_view_global(view_name)
55
+ modify_view_settings(name: view_name, title: title, subtitle: subtitle,
56
+ domain: domain)
57
57
  else
58
- view_name = ask!(" Filename: ")
59
- @blog.create_view(view_name) # call change_view??
60
58
  vim_params = '-c ":set hlsearch" -c ":hi Search ctermfg=2 ctermbg=6" +/"\(VIEW_.*\|SITE.*\)"'
61
59
  edit_file(@blog.view.dir/"themes/standard/global.lt3", vim: vim_params)
62
60
  end
@@ -109,7 +107,12 @@ def mainloop
109
107
  puts "Don't understand '#{cmd.inspect}'\n "
110
108
  end
111
109
  rescue => err
110
+ log!(str: err.to_s)
111
+ log!(str: err.backtrace.join("\n")) if err.respond_to?(:backtrace)
112
+ puts "Current dir = #{Dir.pwd}"
112
113
  puts err
114
+ puts err.backtrace.join("\n")
115
+ puts "Pausing..."; gets
113
116
  end
114
117
 
115
118
  def cmdline_preview
@@ -159,57 +162,82 @@ def handle_cmdline
159
162
  exit
160
163
  end
161
164
 
162
- ### Main
163
-
164
- major, minor = RUBY_VERSION.split(".").values_at(0,1)
165
- ver = major.to_i*10 + minor.to_i
166
- unless ver >= 24
167
- RubyText.stop
168
- sleep 0.2
169
- puts "Needs Ruby 2.4 or greater"
170
- exit
165
+ def check_ruby_version
166
+ major, minor = RUBY_VERSION.split(".").values_at(0,1)
167
+ ver = major.to_i*10 + minor.to_i
168
+ unless ver >= 24
169
+ RubyText.stop
170
+ sleep 0.2
171
+ puts "Needs Ruby 2.4 or greater"
172
+ exit
173
+ end
171
174
  end
172
175
 
173
- include RuneBlog::Helpers # for try_read_config
176
+ def reopen_stderr
177
+ errfile = File.new("stderr.out", "w")
178
+ STDERR.reopen(errfile)
179
+ end
174
180
 
175
- handle_cmdline unless ARGV.empty?
181
+ def set_fgbg
182
+ # read a .rubytext file here?? Call it something else?
183
+ home = ENV['HOME']
184
+ @fg, @bg = Blue, White ## FIXME!! try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
185
+ @fg = @fg.downcase.to_sym
186
+ @bg = @bg.downcase.to_sym
176
187
 
177
- errfile = File.new("stderr.out", "w")
178
- STDERR.reopen(errfile)
188
+ RubyText.start(:_echo, :keypad, scroll: true, log: "binblog.txt", fg: @fg, bg: @bg)
189
+ end
179
190
 
180
- # read a .rubytext file here?? Call it something else?
181
- home = ENV['HOME']
182
- @fg, @bg = Blue, White ## FIXME!! try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
183
- @fg = @fg.downcase.to_sym
184
- @bg = @bg.downcase.to_sym
191
+ def create_new_repo?
192
+ new_repo = false
193
+ if ! RuneBlog.exist?
194
+ exit unless yesno("No blog repo found. Create new one?")
195
+ RuneBlog.create_new_blog_repo
196
+ puts fx(" Blog repo successfully created.", :bold)
197
+ new_repo = true
198
+ end
185
199
 
186
- RubyText.start(:_echo, :keypad, scroll: true, log: "binblog.txt", fg: @fg, bg: @bg)
200
+ @blog = RuneBlog.new
201
+ get_started if new_repo
202
+ rescue => err
203
+ STDERR.puts "Error - #{err.to_s}"
204
+ STDERR.puts err.backtrace if err.respond_to?(:backtrace)
205
+ end
187
206
 
207
+ def print_intro
208
+ print fx(" For help", :bold)
209
+ puts " type h or help.\n "
188
210
 
189
- new_repo = false
190
- if ! RuneBlog.exist?
191
- exit unless yesno("No blog repo found. Create new one?")
192
- RuneBlog.create_new_blog_repo
193
- puts fx(" Blog repo successfully created.", :bold)
194
- new_repo = true
211
+ puts fx("\n RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red)
195
212
  end
196
213
 
197
- @blog = RuneBlog.new
198
- get_started if new_repo
214
+ def cmd_history_etc
215
+ @cmdhist = []
216
+ @tabcom = RuneBlog::REPL::Patterns.keys.uniq - RuneBlog::REPL::Abbr.keys
217
+ @tabcom.map! {|x| x.sub(/ [\$\>].*/, "") + " " }
218
+ @tabcom.sort!
219
+ end
199
220
 
200
- print fx(" For help", :bold)
201
- puts " type h or help.\n "
221
+ def exit_repl
222
+ # RubyText.stop
223
+ sleep 0.2
224
+ puts
225
+ end
202
226
 
203
- puts fx("\n RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red)
227
+ ### Main
204
228
 
205
- @cmdhist = []
206
- @tabcom = RuneBlog::REPL::Patterns.keys.uniq - RuneBlog::REPL::Abbr.keys
207
- @tabcom.map! {|x| x.sub(/ [\$\>].*/, "") + " " }
208
- @tabcom.sort!
209
-
210
- loop { mainloop }
229
+ include RuneBlog::Helpers # for try_read_config
211
230
 
212
- # system("tput clear")
213
- sleep 0.2
214
- puts
231
+ reopen_stderr
215
232
 
233
+ check_ruby_version
234
+ handle_cmdline unless ARGV.empty?
235
+ set_fgbg
236
+ print_intro
237
+ # STDERR.puts "cp 6 - pause"; gets
238
+ create_new_repo?
239
+ # STDERR.puts "cp 7 - pause"; gets
240
+ cmd_history_etc
241
+ # STDERR.puts "cp 8 - pause"; gets
242
+ loop { mainloop }
243
+ exit_repl
@@ -3,11 +3,11 @@
3
3
  . <variable> <value>
4
4
  . --------------------------------------------------
5
5
 
6
- .variables view ../../settings/view.txt
6
+ .variables view ../settings/view.txt
7
7
 
8
- .variables recent ../../settings/recent.txt
8
+ .variables recent ../settings/recent.txt
9
9
 
10
- .variables publish ../../settings/publish.txt
10
+ .variables publish ../settings/publish.txt
11
11
 
12
12
  .variables
13
13
  host http://SITE
@@ -7,6 +7,8 @@
7
7
  . --------------------------------------------------
8
8
  .nopara
9
9
 
10
+ .set Root=REPO_ROOT
11
+
10
12
  .variables
11
13
  univ.author AUTHOR
12
14
  univ.site SITE_DOMAIN
File without changes
@@ -1,4 +1,4 @@
1
- .seek global.lt3 # FIXME this is a hack!
1
+ .include $ViewDir/data/global.lt3
2
2
 
3
3
  <svg width="98%" height="120"
4
4
  viewBox="0 0 98% 100">
@@ -8,7 +8,7 @@
8
8
  <html>
9
9
  <!-- Generated from $File on $$date.
10
10
  Editing not recommended. -->
11
- $.seek global.lt3
11
+ $.include $ViewDir/data/global.lt3
12
12
  $.include blog/head.lt3
13
13
  <body>
14
14
  $.include banner/banner.lt3
@@ -3,7 +3,7 @@
3
3
  . Most of the global CSS goes here
4
4
  . --------------------------------------------------
5
5
 
6
- .seek global.lt3
6
+ .include $ViewDir/data/global.lt3
7
7
 
8
8
  body { font-family: $font.family }
9
9
 
@@ -8,9 +8,9 @@
8
8
  <html>
9
9
  <!-- Generated from $File on $$date; editing not recommended. -->
10
10
 
11
- .seek global.lt3
11
+ .include $ViewDir/data/global.lt3
12
12
 
13
- .variables post metadata.txt
13
+ .variables! post metadata.txt
14
14
 
15
15
  . FIXME
16
16
  .head
@@ -12,7 +12,7 @@
12
12
  <!-- Editing this file is not recommended. -->
13
13
  <!-- It was generated from $File on $$date. -->
14
14
 
15
- .seek global.lt3
15
+ .include $ViewDir/data/global.lt3
16
16
 
17
17
  .head
18
18
  og:title $title
@@ -55,11 +55,12 @@ module RuneBlog::Helpers
55
55
  puts
56
56
  end
57
57
 
58
- def get_repo_config
58
+ def get_repo_config(root = ".blogs")
59
59
  log!(enter: __method__, level: 3)
60
- @editor = File.read(".blogs/data/EDITOR").chomp
61
- @current_view = File.read(".blogs/data/VIEW").chomp
62
- @root = File.read(".blogs/data/ROOT").chomp
60
+ @editor = File.read("#{root}/data/EDITOR").chomp
61
+ @current_view = File.read("#{root}/data/VIEW").chomp
62
+ @root = File.read("#{root}/data/ROOT").chomp
63
+ # Huh? Why not just @root = root? Hal.wtf?
63
64
  rescue => err
64
65
  puts "Can't read config: #{err}"
65
66
  puts err.backtrace.join("\n")
@@ -12,6 +12,7 @@ require 'processing'
12
12
 
13
13
 
14
14
  def init_liveblog # FIXME - a lot of this logic sucks
15
+ log!(enter: __method__)
15
16
  dir = Dir.pwd.sub(/\.blogs.*/, "")
16
17
  @blog = nil
17
18
  Dir.chdir(dir) { @blog = RuneBlog.new }
@@ -19,6 +20,8 @@ def init_liveblog # FIXME - a lot of this logic sucks
19
20
  @view = @blog.view
20
21
  @view_name = @blog.view.name unless @view.nil?
21
22
  @vdir = @blog.view.dir rescue "NONAME"
23
+ setvar("View", @view_name)
24
+ setvar("ViewDir", @blog.root/:views/@view_name)
22
25
  @version = RuneBlog::VERSION
23
26
  @theme = @vdir/:themes/:standard
24
27
 
@@ -33,9 +36,10 @@ def init_liveblog # FIXME - a lot of this logic sucks
33
36
  </a>
34
37
  HTML
35
38
  end
39
+ log!(str: "End of init_liveblog")
36
40
  rescue => err
37
41
  STDERR.puts "err = #{err}"
38
- STDERR.puts err.backtrace.join("\n")
42
+ STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
39
43
  end
40
44
 
41
45
  ##################
@@ -43,6 +47,7 @@ end
43
47
  ##################
44
48
 
45
49
  def dropcap
50
+ log!(enter: __method__)
46
51
  # Bad form: adds another HEAD
47
52
  text = _data
48
53
  _out " "
@@ -53,6 +58,7 @@ def dropcap
53
58
  end
54
59
 
55
60
  def post
61
+ log!(enter: __method__)
56
62
  @meta = OpenStruct.new
57
63
  @meta.num = _args[0]
58
64
  setvar("post.num", @meta.num.to_i)
@@ -60,6 +66,7 @@ def post
60
66
  end
61
67
 
62
68
  def _got_python?
69
+ log!(enter: __method__)
63
70
  # Dumb - fix later - check up front as needed
64
71
  # Should also check for praw lib
65
72
  str = `which python3`
@@ -67,6 +74,7 @@ end
67
74
  end
68
75
 
69
76
  def _reddit_post_url(vdir, date, title, url)
77
+ log!(enter: __method__)
70
78
  _got_python?
71
79
  tmpfile = "/tmp/reddit-post-url.txt"
72
80
  File.open(tmpfile, "w") do |tmp|
@@ -80,6 +88,7 @@ end
80
88
  end
81
89
 
82
90
  def post_toolbar
91
+ log!(enter: __method__)
83
92
  back_icon = %[<img src="assets/back-icon.png" width=24 height=24 alt="Go back"></img>]
84
93
  back = %[<a style="text-decoration: none" href="javascript:history.go(-1)">#{back_icon}</a>]
85
94
  _out <<~HTML
@@ -88,14 +97,15 @@ def post_toolbar
88
97
  end
89
98
 
90
99
  def post_trailer
100
+ log!(enter: __method__)
91
101
  # Not called from *inside* a post, therefore no @meta --
92
102
  # can/must call read_metadata
93
103
  num = _var("post.num").to_i
94
- puts "post_trailer: num = #{num}"
104
+ log! str: "post_trailer: num = #{num}"
95
105
  vp = _post_lookup(num)
96
- puts "post_trailer: lookup = #{vp.num} #{vp.title}"
106
+ log! str: "post_trailer: lookup = #{vp.num} #{vp.title}"
97
107
  dir = @blog.root/:posts/vp.nslug
98
- puts " -- dir = #{dir}"
108
+ log! str: " -- dir = #{dir}"
99
109
  meta = Dir.chdir(dir) { @blog.read_metadata }
100
110
  nslug = @blog.make_slug(meta)
101
111
  aslug = nslug[5..-1]
@@ -112,10 +122,10 @@ puts " -- dir = #{dir}"
112
122
  date = meta.date
113
123
  rid_file = vdir/:posts/nslug/"reddit.id"
114
124
  if File.exist?(rid_file)
115
- puts " reading #{rid_file}"
125
+ STDERR.puts " reading #{rid_file}"
116
126
  rid = File.read(rid_file).chomp
117
127
  else
118
- puts " creating #{rid_file}"
128
+ STDERR.puts " creating #{rid_file}"
119
129
  title = meta.title
120
130
  rid = _reddit_post_url(vdir, date, title, perma)
121
131
  dump(rid, rid_file)
@@ -127,7 +137,7 @@ puts " -- dir = #{dir}"
127
137
  HTML
128
138
  # damned syntax highlighting </>
129
139
  end
130
- print "Pause... "; getch
140
+ # STDERR.print "Pausing... "; getch
131
141
  _out <<~HTML
132
142
  #{reddit_txt}
133
143
  <hr>
@@ -139,6 +149,7 @@ print "Pause... "; getch
139
149
  end
140
150
 
141
151
  def faq
152
+ log!(enter: __method__)
142
153
  @faq_count ||= 0
143
154
  _out "<br>" if @faq_count == 0
144
155
  @faq_count += 1
@@ -153,15 +164,18 @@ def faq
153
164
  end
154
165
 
155
166
  def backlink
167
+ log!(enter: __method__)
156
168
  _out %[<br><a href="javascript:history.go(-1)">[Back]</a>]
157
169
  end
158
170
 
159
171
  def code
172
+ log!(enter: __method__)
160
173
  lines = _body # _text
161
174
  _out "<font size=+1><pre>\n#{lines}\n</pre></font>"
162
175
  end
163
176
 
164
177
  def _read_navbar_data
178
+ log!(enter: __method__)
165
179
  vdir = @blog.root/:views/@blog.view
166
180
  dir = vdir/"themes/standard/banner/navbar/"
167
181
  datafile = dir/"list.data"
@@ -169,6 +183,7 @@ def _read_navbar_data
169
183
  end
170
184
 
171
185
  def banner
186
+ log!(enter: __method__)
172
187
  count = 0
173
188
  bg = "white" # outside loop
174
189
  wide = nil
@@ -202,7 +217,7 @@ def banner
202
217
  if ! File.exist?(file)
203
218
  src = file.sub(/html$/, "lt3")
204
219
  if File.exist?(src)
205
- preprocess src: src, dst: file, call: ".nopara" # , vars: @blog.view.globals
220
+ preprocess src: src, dst: file, call: ".nopara", vars: @blog.view.globals
206
221
  else
207
222
  raise FoundNeither(file, src)
208
223
  end
@@ -228,11 +243,11 @@ def banner
228
243
  _out navbar if navbar
229
244
  rescue => err
230
245
  STDERR.puts "err = #{err}"
231
- STDERR.puts err.backtrace.join("\n")
232
- gets
246
+ STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
233
247
  end
234
248
 
235
249
  def _svg_title(*args)
250
+ log!(enter: __method__)
236
251
  width = "95%"
237
252
  height = 90
238
253
  bgcolor = "black"
@@ -288,6 +303,7 @@ def _svg_title(*args)
288
303
  end
289
304
 
290
305
  def quote
306
+ log!(enter: __method__)
291
307
  _passthru "<blockquote>"
292
308
  _passthru _body.join(" ")
293
309
  _passthru "</blockquote>"
@@ -295,9 +311,11 @@ def quote
295
311
  end
296
312
 
297
313
  def categories # does nothing right now
314
+ log!(enter: __method__)
298
315
  end
299
316
 
300
317
  def style
318
+ log!(enter: __method__)
301
319
  fname = _args[0]
302
320
  _passthru %[<link rel="stylesheet" href="???/etc/#{fname}')">]
303
321
  end
@@ -314,6 +332,7 @@ def h6; _passthru "<h6>#{@_data}</h6>"; end
314
332
  def hr; _passthru "<hr>"; end
315
333
 
316
334
  def nlist
335
+ log!(enter: __method__)
317
336
  _out "<ol>"
318
337
  _body {|line| _out "<li>#{line}</li>" }
319
338
  _out "</ol>"
@@ -321,6 +340,7 @@ def nlist
321
340
  end
322
341
 
323
342
  def list
343
+ log!(enter: __method__)
324
344
  _out "<ul>"
325
345
  _body {|line| _out "<li>#{line}</li>" }
326
346
  _out "</ul>"
@@ -328,6 +348,7 @@ def list
328
348
  end
329
349
 
330
350
  def list!
351
+ log!(enter: __method__)
331
352
  _out "<ul>"
332
353
  lines = _body.each
333
354
  loop do
@@ -346,6 +367,7 @@ end
346
367
  ### inset
347
368
 
348
369
  def inset
370
+ log!(enter: __method__)
349
371
  lines = _body
350
372
  box = ""
351
373
  output = []
@@ -377,6 +399,7 @@ def inset
377
399
  end
378
400
 
379
401
  def title
402
+ log!(enter: __method__)
380
403
  raise NoPostCall unless @meta
381
404
  title = @_data.chomp
382
405
  @meta.title = title
@@ -386,6 +409,7 @@ def title
386
409
  end
387
410
 
388
411
  def pubdate
412
+ log!(enter: __method__)
389
413
  raise NoPostCall unless @meta
390
414
  _debug "data = #@_data"
391
415
  # Check for discrepancy?
@@ -398,6 +422,7 @@ def pubdate
398
422
  end
399
423
 
400
424
  def tags
425
+ log!(enter: __method__)
401
426
  raise NoPostCall unless @meta
402
427
  _debug "args = #{_args}"
403
428
  @meta.tags = _args.dup || []
@@ -405,6 +430,7 @@ def tags
405
430
  end
406
431
 
407
432
  def views
433
+ log!(enter: __method__)
408
434
  raise NoPostCall unless @meta
409
435
  _debug "data = #{_args}"
410
436
  @meta.views = _args.dup
@@ -412,6 +438,7 @@ def views
412
438
  end
413
439
 
414
440
  def pin
441
+ log!(enter: __method__)
415
442
  raise NoPostCall unless @meta
416
443
  _debug "data = #{_args}" # verify only valid views?
417
444
  pinned = @_args
@@ -427,21 +454,22 @@ def pin
427
454
  _optional_blank_line
428
455
  rescue => err
429
456
  STDERR.puts "err = #{err}"
430
- STDERR.puts err.backtrace.join("\n")
431
- gets
457
+ STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
432
458
  end
433
459
 
434
460
  def write_post
461
+ log!(enter: __method__)
435
462
  raise NoPostCall unless @meta
436
463
  @meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
437
464
  @meta.tags = @meta.tags.join(" ") if @meta.tags.is_a? Array
438
465
  _write_metadata
439
466
  rescue => err
440
467
  puts "err = #{err}"
441
- puts err.backtrace.join("\n")
468
+ puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
442
469
  end
443
470
 
444
471
  def teaser
472
+ log!(enter: __method__)
445
473
  raise NoPostCall unless @meta
446
474
  text = _body.join("\n")
447
475
  @meta.teaser = text
@@ -456,6 +484,7 @@ def teaser
456
484
  end
457
485
 
458
486
  def finalize
487
+ log!(str: "Now exiting livetext processing...")
459
488
  return unless @meta
460
489
  return @meta if @blog.nil?
461
490
 
@@ -467,6 +496,7 @@ def finalize
467
496
  end
468
497
 
469
498
  def head # Does NOT output <head> tags
499
+ log!(enter: __method__)
470
500
  args = _args
471
501
  args.each do |inc|
472
502
  self.data = inc
@@ -522,6 +552,7 @@ end
522
552
  ########## newer stuff...
523
553
 
524
554
  def meta
555
+ log!(enter: __method__)
525
556
  args = _args
526
557
  enum = args.each
527
558
  str = "<meta"
@@ -541,6 +572,7 @@ def meta
541
572
  end
542
573
 
543
574
  def recent_posts # side-effect
575
+ log!(enter: __method__)
544
576
  _out <<-HTML
545
577
  <div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
546
578
  <iframe id="main" style="width: 70vw; height: 100vh; position: relative;"
@@ -551,6 +583,7 @@ def recent_posts # side-effect
551
583
  end
552
584
 
553
585
  def _make_class_name(app)
586
+ log!(enter: __method__)
554
587
  if app =~ /[-_]/
555
588
  words = app.split(/[-_]/)
556
589
  name = words.map(&:capitalize).join
@@ -561,6 +594,7 @@ def _make_class_name(app)
561
594
  end
562
595
 
563
596
  def _load_local(widget)
597
+ log!(enter: __method__)
564
598
  Dir.chdir("../../widgets/#{widget}") do
565
599
  rclass = _make_class_name(widget)
566
600
  found = (require("./#{widget}") if File.exist?("#{widget}.rb"))
@@ -569,12 +603,13 @@ def _load_local(widget)
569
603
  end
570
604
  rescue => err
571
605
  STDERR.puts err.to_s
572
- STDERR.puts err.backtrace.join("\n")
606
+ STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
573
607
  sleep 6; RubyText.stop
574
608
  exit
575
609
  end
576
610
 
577
611
  def _handle_standard_widget(tag)
612
+ log!(enter: __method__)
578
613
  wtag = "../../widgets"/tag
579
614
  code = _load_local(tag)
580
615
  if code
@@ -586,6 +621,7 @@ def _handle_standard_widget(tag)
586
621
  end
587
622
 
588
623
  def sidebar
624
+ log!(enter: __method__)
589
625
  _debug "--- handling sidebar\r"
590
626
  if _args.include? "off"
591
627
  _body { } # iterate, do nothing
@@ -613,12 +649,13 @@ def sidebar
613
649
  _out %[</div>]
614
650
  rescue => err
615
651
  puts "err = #{err}"
616
- puts err.backtrace.join("\n")
652
+ puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
617
653
  sleep 6; RubyText.stop
618
654
  exit
619
655
  end
620
656
 
621
657
  def stylesheet
658
+ log!(enter: __method__)
622
659
  lines = _body
623
660
  url = lines[0]
624
661
  integ = lines[1]
@@ -627,6 +664,7 @@ def stylesheet
627
664
  end
628
665
 
629
666
  def script
667
+ log!(enter: __method__)
630
668
  lines = _body
631
669
  url = lines[0]
632
670
  integ = lines[1]
@@ -676,6 +714,7 @@ end
676
714
 
677
715
 
678
716
  def tag_cloud
717
+ log!(enter: __method__)
679
718
  title = _data
680
719
  title = "Tag Cloud" if title.empty?
681
720
  open = <<-HTML
@@ -699,18 +738,22 @@ def tag_cloud
699
738
  end
700
739
 
701
740
  def vnavbar
741
+ log!(enter: __method__)
702
742
  str = _make_navbar(:vert)
703
743
  end
704
744
 
705
745
  def hnavbar
746
+ log!(enter: __method__)
706
747
  str = _make_navbar # horiz is default
707
748
  end
708
749
 
709
750
  def navbar
751
+ log!(enter: __method__)
710
752
  str = _make_navbar # horiz is default
711
753
  end
712
754
 
713
755
  def _make_navbar(orient = :horiz)
756
+ log!(enter: __method__)
714
757
  vdir = @root/:views/@blog.view
715
758
  title = _var("view.title")
716
759
 
@@ -751,7 +794,7 @@ def _make_navbar(orient = :horiz)
751
794
  else
752
795
  dir = @blog.root/:views/@blog.view/"themes/standard/banner/navbar"
753
796
  dest = vdir/"remote/banner/navbar"/basename+".html"
754
- preprocess cwd: dir, src: basename, dst: dest, call: ".nopara" # , debug: true
797
+ preprocess cwd: dir, src: basename, dst: dest, call: ".nopara", vars: @blog.view.globals # , debug: true
755
798
  output.puts %[#{li1} <a class="nav-link" #{href_main}>#{cdata}</a> #{li2}]
756
799
  end
757
800
  end
@@ -766,6 +809,7 @@ end
766
809
  ##################
767
810
 
768
811
  def _html_body(file, css = nil)
812
+ log!(enter: __method__)
769
813
  file.puts "<html>"
770
814
  if css
771
815
  file.puts " <head>"
@@ -778,10 +822,12 @@ def _html_body(file, css = nil)
778
822
  end
779
823
 
780
824
  def _errout(*args)
825
+ log!(enter: __method__)
781
826
  ::STDERR.puts *args
782
827
  end
783
828
 
784
829
  def _passthru(line)
830
+ log!(enter: __method__)
785
831
  return if line.nil?
786
832
  line = _format(line)
787
833
  _out line + "\n"
@@ -789,6 +835,7 @@ def _passthru(line)
789
835
  end
790
836
 
791
837
  def _passthru_noline(line)
838
+ log!(enter: __method__)
792
839
  return if line.nil?
793
840
  line = _format(line)
794
841
  _out line
@@ -796,6 +843,7 @@ def _passthru_noline(line)
796
843
  end
797
844
 
798
845
  def _write_metadata
846
+ log!(enter: __method__)
799
847
  File.write("teaser.txt", @meta.teaser)
800
848
  fields = [:num, :title, :date, :pubdate, :views, :tags, :pinned]
801
849
  fname = "metadata.txt"
@@ -805,20 +853,32 @@ def _write_metadata
805
853
  end
806
854
 
807
855
  def _post_lookup(postid) # side-effect
856
+ log!(enter: __method__)
808
857
  # .. = templates, ../.. = views/thisview
809
858
  slug = title = date = teaser_text = nil
810
859
 
860
+ view = @blog.view
861
+ vdir = view.dir rescue "NONAME"
862
+ setvar("View", view.name)
863
+ setvar("ViewDir", @blog.root/:views/view.name)
864
+ tmp = File.new("/tmp/PL-#{Time.now.to_i}.txt", "w")
865
+ tmp.puts "_post_lookup: blog.view = #{@blog.view.inspect}"
866
+ tmp.puts "_post_lookup: vdir = #{vdir}"
811
867
  dir_posts = @vdir/:posts
812
868
  posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts/x }
813
869
  posts.select! {|x| File.directory?(x) }
814
870
 
871
+ tmp.puts "_post_lookup: postid = #{postid}"
872
+ tmp.puts "_post_lookup: posts = \n#{posts.inspect}"
873
+ tmp.close
815
874
  posts = posts.select {|x| File.basename(x).to_i == postid }
816
- postdir = exactly_one(posts)
875
+ postdir = exactly_one(posts, posts.inspect)
817
876
  vp = RuneBlog::ViewPost.new(@blog.view, postdir)
818
877
  vp
819
878
  end
820
879
 
821
880
  def _card_generic(card_title:, middle:, extra: "")
881
+ log!(enter: __method__)
822
882
  front = <<-HTML
823
883
  <div class="card #{extra} mb-3">
824
884
  <div class="card-body">
@@ -834,14 +894,17 @@ def _card_generic(card_title:, middle:, extra: "")
834
894
  end
835
895
 
836
896
  def _var(name) # FIXME scope issue!
897
+ log!(enter: __method__)
837
898
  ::Livetext::Vars[name] || "[:#{name} is undefined]"
838
899
  end
839
900
 
840
901
  def _main(url)
902
+ log!(enter: __method__)
841
903
  %[href="javascript: void(0)" onclick="javascript:open_main('#{url}')"]
842
904
  end
843
905
 
844
906
  def _blank(url)
907
+ log!(enter: __method__)
845
908
  %[href='#{url}' target='blank']
846
909
  end
847
910