runeblog 0.3.18 → 0.3.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +77 -53
- data/data/global.lt3 +3 -3
- data/data/universal.lt3 +2 -0
- data/empty_view/data/GIT_IS_DUMB +0 -0
- data/empty_view/themes/standard/banner/top.lt3 +1 -1
- data/empty_view/themes/standard/blog/generate.lt3 +1 -1
- data/empty_view/themes/standard/etc/blog.css.lt3 +3 -1
- data/empty_view/themes/standard/etc/github.css +209 -0
- data/empty_view/themes/standard/post/generate.lt3 +8 -5
- data/empty_view/themes/standard/post/permalink.lt3 +1 -1
- data/lib/exceptions.rb +37 -0
- data/lib/helpers-blog.rb +6 -4
- data/lib/helpers-repl.rb +2 -6
- data/lib/liveblog.rb +108 -31
- data/lib/lowlevel.rb +23 -7
- data/lib/menus.rb +5 -3
- data/lib/newpost.rb +82 -0
- data/lib/post.rb +6 -5
- data/lib/processing.rb +23 -2
- data/lib/publish.rb +3 -1
- data/lib/repl.rb +68 -26
- data/lib/runeblog.rb +94 -57
- data/lib/runeblog_version.rb +2 -15
- data/lib/view.rb +22 -3
- data/runeblog.gemspec +2 -2
- metadata +13 -9
@@ -8,12 +8,14 @@
|
|
8
8
|
<html>
|
9
9
|
<!-- Generated from $File on $$date; editing not recommended. -->
|
10
10
|
|
11
|
-
.
|
11
|
+
.include $ViewDir/data/global.lt3
|
12
|
+
|
13
|
+
.variables! post metadata.txt
|
12
14
|
|
13
15
|
. FIXME
|
14
16
|
.head
|
15
|
-
og:title $title
|
16
|
-
description $teaser
|
17
|
+
og:title $post.title
|
18
|
+
description $post.teaser
|
17
19
|
style blog.css
|
18
20
|
.end
|
19
21
|
|
@@ -23,7 +25,8 @@ style blog.css
|
|
23
25
|
<div class="recent-content">
|
24
26
|
$.post_toolbar
|
25
27
|
<table border=0 width=100%><tr>
|
26
|
-
<td align=left valign=bottom><h2 class="recent-title">$title</h2></td>
|
28
|
+
<td align=left valign=bottom><h2 class="recent-title">$post.title</h2></td>
|
29
|
+
. FIXME - longdate is passed in from outside
|
27
30
|
<td align=right valign=top><font size=-5><br></font>$longdate</td>
|
28
31
|
</tr></table><hr>
|
29
32
|
$.copy guts.html
|
@@ -31,6 +34,6 @@ style blog.css
|
|
31
34
|
</section>
|
32
35
|
|
33
36
|
<br>
|
34
|
-
.post_trailer
|
37
|
+
.post_trailer $post.num
|
35
38
|
</body>
|
36
39
|
</html>
|
data/lib/exceptions.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
def make_exception(sym, str, target_class = Object)
|
3
|
+
return if target_class.constants.include?(sym)
|
4
|
+
|
5
|
+
target_class.const_set(sym, StandardError.dup)
|
6
|
+
define_method(sym) do |*args|
|
7
|
+
msg = str.dup
|
8
|
+
args.each.with_index {|arg, i| msg.sub!("%#{i+1}", arg) }
|
9
|
+
target_class.class_eval(sym.to_s).new(msg)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
make_exception(:NotImplemented, "Feature not yet implemented")
|
14
|
+
make_exception(:CantOpen, "Can't open '%1'")
|
15
|
+
make_exception(:CantDelete, "Can't delete '%1'")
|
16
|
+
make_exception(:InternalError, "Glitch: %1 got arg '%2'")
|
17
|
+
make_exception(:CantCopy, "Can't copy %1 to %2")
|
18
|
+
|
19
|
+
make_exception(:FileNotFound, "File %1 was not found")
|
20
|
+
make_exception(:FoundNeither, "Found neither %1 nor %2")
|
21
|
+
make_exception(:BlogRepoAlreadyExists, "Blog repo %1 already exists")
|
22
|
+
make_exception(:CantAssignView, "%1 is not a view")
|
23
|
+
make_exception(:ViewAlreadyExists, "View %1 already exists")
|
24
|
+
make_exception(:DirAlreadyExists, "Directory %1 already exists")
|
25
|
+
make_exception(:CantCreateDir, "Can't create directory %1")
|
26
|
+
make_exception(:EditorProblem, "Could not edit %1")
|
27
|
+
make_exception(:NoSuchView, "No such view: %1")
|
28
|
+
make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
|
29
|
+
make_exception(:ExpectedString, "Expected nonempty string but got %1 (%2)")
|
30
|
+
make_exception(:ExpectedView, "Expected string or View object but got %1 (%2)")
|
31
|
+
make_exception(:ExpectedInteger, "Expected integer but got %1 (%2)")
|
32
|
+
make_exception(:NoPostCall, "Method #post not called (no metadata)")
|
33
|
+
make_exception(:CantFindWidgetDir, "Can't find widget dir '%1'")
|
34
|
+
make_exception(:PublishError, "Error during publishing")
|
35
|
+
make_exception(:NoNumericPrefix, "No numeric prefix on slug '%1'")
|
36
|
+
make_exception(:NoExtensionExpected, "No file extension expected on '%1'")
|
37
|
+
|
data/lib/helpers-blog.rb
CHANGED
@@ -24,6 +24,7 @@ module RuneBlog::Helpers
|
|
24
24
|
dir = root/:views/view/:settings
|
25
25
|
end
|
26
26
|
file = dir/"features.txt"
|
27
|
+
# puts "-- in #{Dir.pwd} trying to read #{file}"
|
27
28
|
pairs = read_pairs(file)
|
28
29
|
enabled = {}
|
29
30
|
pairs.each {|k,v| enabled[k] = (v == "1") }
|
@@ -54,11 +55,12 @@ module RuneBlog::Helpers
|
|
54
55
|
puts
|
55
56
|
end
|
56
57
|
|
57
|
-
def get_repo_config
|
58
|
+
def get_repo_config(root = ".blogs")
|
58
59
|
log!(enter: __method__, level: 3)
|
59
|
-
@editor = File.read("
|
60
|
-
@current_view = File.read("
|
61
|
-
@root = File.read("
|
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?
|
62
64
|
rescue => err
|
63
65
|
puts "Can't read config: #{err}"
|
64
66
|
puts err.backtrace.join("\n")
|
data/lib/helpers-repl.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
make_exception(:CantOpen, "Can't open '$1'")
|
5
|
-
make_exception(:CantDelete, "Can't open '$1'")
|
6
|
-
make_exception(:InternalError, "Glitch: $1 got arg '$2'")
|
7
|
-
make_exception(:CantCopy, "Can't copy $1 to $2")
|
2
|
+
require 'exceptions'
|
8
3
|
|
4
|
+
# Reopening...
|
9
5
|
|
10
6
|
module RuneBlog::REPL
|
11
7
|
Patterns =
|
data/lib/liveblog.rb
CHANGED
@@ -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,10 +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")
|
39
|
-
# raise "Only works inside a blog repo"
|
42
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
40
43
|
end
|
41
44
|
|
42
45
|
##################
|
@@ -44,6 +47,7 @@ end
|
|
44
47
|
##################
|
45
48
|
|
46
49
|
def dropcap
|
50
|
+
log!(enter: __method__)
|
47
51
|
# Bad form: adds another HEAD
|
48
52
|
text = _data
|
49
53
|
_out " "
|
@@ -54,12 +58,15 @@ def dropcap
|
|
54
58
|
end
|
55
59
|
|
56
60
|
def post
|
61
|
+
log!(enter: __method__)
|
57
62
|
@meta = OpenStruct.new
|
58
63
|
@meta.num = _args[0]
|
64
|
+
setvar("post.num", @meta.num.to_i)
|
59
65
|
_out " <!-- Post number #{@meta.num} -->\n "
|
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,21 +97,36 @@ def post_toolbar
|
|
88
97
|
end
|
89
98
|
|
90
99
|
def post_trailer
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
100
|
+
log!(enter: __method__)
|
101
|
+
# Not called from *inside* a post, therefore no @meta --
|
102
|
+
# can/must call read_metadata
|
103
|
+
num = _var("post.num").to_i
|
104
|
+
log! str: "post_trailer: num = #{num}"
|
105
|
+
vp = _post_lookup(num)
|
106
|
+
log! str: "post_trailer: lookup = #{vp.num} #{vp.title}"
|
107
|
+
dir = @blog.root/:posts/vp.nslug
|
108
|
+
log! str: " -- dir = #{dir}"
|
109
|
+
meta = Dir.chdir(dir) { @blog.read_metadata }
|
110
|
+
nslug = @blog.make_slug(meta)
|
111
|
+
aslug = nslug[5..-1]
|
112
|
+
proto = _var("publish.proto")
|
113
|
+
server = _var("publish.server")
|
114
|
+
path = _var("publish.path")
|
115
|
+
perma = "#{proto}://#{server}/#{path}/#{aslug}.html"
|
116
|
+
tags = meta.tags
|
95
117
|
taglist = tags.empty? ? "" : "Tags: #{tags}"
|
96
118
|
|
97
119
|
reddit_txt = ""
|
98
120
|
if @reddit_enabled
|
99
121
|
vdir = @blog.root/:views/@blog.view
|
100
|
-
|
101
|
-
date = _var("post.date")
|
122
|
+
date = meta.date
|
102
123
|
rid_file = vdir/:posts/nslug/"reddit.id"
|
103
|
-
|
104
|
-
|
105
|
-
|
124
|
+
if File.exist?(rid_file)
|
125
|
+
STDERR.puts " reading #{rid_file}"
|
126
|
+
rid = File.read(rid_file).chomp
|
127
|
+
else
|
128
|
+
STDERR.puts " creating #{rid_file}"
|
129
|
+
title = meta.title
|
106
130
|
rid = _reddit_post_url(vdir, date, title, perma)
|
107
131
|
dump(rid, rid_file)
|
108
132
|
end
|
@@ -113,6 +137,7 @@ def post_trailer
|
|
113
137
|
HTML
|
114
138
|
# damned syntax highlighting </>
|
115
139
|
end
|
140
|
+
# STDERR.print "Pausing... "; getch
|
116
141
|
_out <<~HTML
|
117
142
|
#{reddit_txt}
|
118
143
|
<hr>
|
@@ -124,6 +149,7 @@ def post_trailer
|
|
124
149
|
end
|
125
150
|
|
126
151
|
def faq
|
152
|
+
log!(enter: __method__)
|
127
153
|
@faq_count ||= 0
|
128
154
|
_out "<br>" if @faq_count == 0
|
129
155
|
@faq_count += 1
|
@@ -138,15 +164,18 @@ def faq
|
|
138
164
|
end
|
139
165
|
|
140
166
|
def backlink
|
167
|
+
log!(enter: __method__)
|
141
168
|
_out %[<br><a href="javascript:history.go(-1)">[Back]</a>]
|
142
169
|
end
|
143
170
|
|
144
171
|
def code
|
172
|
+
log!(enter: __method__)
|
145
173
|
lines = _body # _text
|
146
174
|
_out "<font size=+1><pre>\n#{lines}\n</pre></font>"
|
147
175
|
end
|
148
176
|
|
149
177
|
def _read_navbar_data
|
178
|
+
log!(enter: __method__)
|
150
179
|
vdir = @blog.root/:views/@blog.view
|
151
180
|
dir = vdir/"themes/standard/banner/navbar/"
|
152
181
|
datafile = dir/"list.data"
|
@@ -154,6 +183,7 @@ def _read_navbar_data
|
|
154
183
|
end
|
155
184
|
|
156
185
|
def banner
|
186
|
+
log!(enter: __method__)
|
157
187
|
count = 0
|
158
188
|
bg = "white" # outside loop
|
159
189
|
wide = nil
|
@@ -187,9 +217,9 @@ def banner
|
|
187
217
|
if ! File.exist?(file)
|
188
218
|
src = file.sub(/html$/, "lt3")
|
189
219
|
if File.exist?(src)
|
190
|
-
preprocess src: src, dst: file, call: ".nopara"
|
220
|
+
preprocess src: src, dst: file, call: ".nopara", vars: @blog.view.globals
|
191
221
|
else
|
192
|
-
raise
|
222
|
+
raise FoundNeither(file, src)
|
193
223
|
end
|
194
224
|
end
|
195
225
|
str2 << "<td>" + File.read(file) + "</td>" + "\n"
|
@@ -213,11 +243,11 @@ def banner
|
|
213
243
|
_out navbar if navbar
|
214
244
|
rescue => err
|
215
245
|
STDERR.puts "err = #{err}"
|
216
|
-
STDERR.puts err.backtrace.join("\n")
|
217
|
-
gets
|
246
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
218
247
|
end
|
219
248
|
|
220
249
|
def _svg_title(*args)
|
250
|
+
log!(enter: __method__)
|
221
251
|
width = "95%"
|
222
252
|
height = 90
|
223
253
|
bgcolor = "black"
|
@@ -273,6 +303,7 @@ def _svg_title(*args)
|
|
273
303
|
end
|
274
304
|
|
275
305
|
def quote
|
306
|
+
log!(enter: __method__)
|
276
307
|
_passthru "<blockquote>"
|
277
308
|
_passthru _body.join(" ")
|
278
309
|
_passthru "</blockquote>"
|
@@ -280,9 +311,11 @@ def quote
|
|
280
311
|
end
|
281
312
|
|
282
313
|
def categories # does nothing right now
|
314
|
+
log!(enter: __method__)
|
283
315
|
end
|
284
316
|
|
285
317
|
def style
|
318
|
+
log!(enter: __method__)
|
286
319
|
fname = _args[0]
|
287
320
|
_passthru %[<link rel="stylesheet" href="???/etc/#{fname}')">]
|
288
321
|
end
|
@@ -299,6 +332,7 @@ def h6; _passthru "<h6>#{@_data}</h6>"; end
|
|
299
332
|
def hr; _passthru "<hr>"; end
|
300
333
|
|
301
334
|
def nlist
|
335
|
+
log!(enter: __method__)
|
302
336
|
_out "<ol>"
|
303
337
|
_body {|line| _out "<li>#{line}</li>" }
|
304
338
|
_out "</ol>"
|
@@ -306,6 +340,7 @@ def nlist
|
|
306
340
|
end
|
307
341
|
|
308
342
|
def list
|
343
|
+
log!(enter: __method__)
|
309
344
|
_out "<ul>"
|
310
345
|
_body {|line| _out "<li>#{line}</li>" }
|
311
346
|
_out "</ul>"
|
@@ -313,6 +348,7 @@ def list
|
|
313
348
|
end
|
314
349
|
|
315
350
|
def list!
|
351
|
+
log!(enter: __method__)
|
316
352
|
_out "<ul>"
|
317
353
|
lines = _body.each
|
318
354
|
loop do
|
@@ -331,6 +367,7 @@ end
|
|
331
367
|
### inset
|
332
368
|
|
333
369
|
def inset
|
370
|
+
log!(enter: __method__)
|
334
371
|
lines = _body
|
335
372
|
box = ""
|
336
373
|
output = []
|
@@ -362,7 +399,8 @@ def inset
|
|
362
399
|
end
|
363
400
|
|
364
401
|
def title
|
365
|
-
|
402
|
+
log!(enter: __method__)
|
403
|
+
raise NoPostCall unless @meta
|
366
404
|
title = @_data.chomp
|
367
405
|
@meta.title = title
|
368
406
|
setvar :title, title
|
@@ -371,7 +409,8 @@ def title
|
|
371
409
|
end
|
372
410
|
|
373
411
|
def pubdate
|
374
|
-
|
412
|
+
log!(enter: __method__)
|
413
|
+
raise NoPostCall unless @meta
|
375
414
|
_debug "data = #@_data"
|
376
415
|
# Check for discrepancy?
|
377
416
|
match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
|
@@ -383,21 +422,24 @@ def pubdate
|
|
383
422
|
end
|
384
423
|
|
385
424
|
def tags
|
386
|
-
|
425
|
+
log!(enter: __method__)
|
426
|
+
raise NoPostCall unless @meta
|
387
427
|
_debug "args = #{_args}"
|
388
428
|
@meta.tags = _args.dup || []
|
389
429
|
_optional_blank_line
|
390
430
|
end
|
391
431
|
|
392
432
|
def views
|
393
|
-
|
433
|
+
log!(enter: __method__)
|
434
|
+
raise NoPostCall unless @meta
|
394
435
|
_debug "data = #{_args}"
|
395
436
|
@meta.views = _args.dup
|
396
437
|
_optional_blank_line
|
397
438
|
end
|
398
439
|
|
399
440
|
def pin
|
400
|
-
|
441
|
+
log!(enter: __method__)
|
442
|
+
raise NoPostCall unless @meta
|
401
443
|
_debug "data = #{_args}" # verify only valid views?
|
402
444
|
pinned = @_args
|
403
445
|
@meta.pinned = pinned
|
@@ -412,22 +454,23 @@ def pin
|
|
412
454
|
_optional_blank_line
|
413
455
|
rescue => err
|
414
456
|
STDERR.puts "err = #{err}"
|
415
|
-
STDERR.puts err.backtrace.join("\n")
|
416
|
-
gets
|
457
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
417
458
|
end
|
418
459
|
|
419
460
|
def write_post
|
420
|
-
|
461
|
+
log!(enter: __method__)
|
462
|
+
raise NoPostCall unless @meta
|
421
463
|
@meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
|
422
464
|
@meta.tags = @meta.tags.join(" ") if @meta.tags.is_a? Array
|
423
465
|
_write_metadata
|
424
466
|
rescue => err
|
425
467
|
puts "err = #{err}"
|
426
|
-
puts err.backtrace.join("\n")
|
468
|
+
puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
427
469
|
end
|
428
470
|
|
429
471
|
def teaser
|
430
|
-
|
472
|
+
log!(enter: __method__)
|
473
|
+
raise NoPostCall unless @meta
|
431
474
|
text = _body.join("\n")
|
432
475
|
@meta.teaser = text
|
433
476
|
setvar :teaser, @meta.teaser
|
@@ -441,6 +484,7 @@ def teaser
|
|
441
484
|
end
|
442
485
|
|
443
486
|
def finalize
|
487
|
+
log!(str: "Now exiting livetext processing...")
|
444
488
|
return unless @meta
|
445
489
|
return @meta if @blog.nil?
|
446
490
|
|
@@ -452,6 +496,7 @@ def finalize
|
|
452
496
|
end
|
453
497
|
|
454
498
|
def head # Does NOT output <head> tags
|
499
|
+
log!(enter: __method__)
|
455
500
|
args = _args
|
456
501
|
args.each do |inc|
|
457
502
|
self.data = inc
|
@@ -507,6 +552,7 @@ end
|
|
507
552
|
########## newer stuff...
|
508
553
|
|
509
554
|
def meta
|
555
|
+
log!(enter: __method__)
|
510
556
|
args = _args
|
511
557
|
enum = args.each
|
512
558
|
str = "<meta"
|
@@ -526,6 +572,7 @@ def meta
|
|
526
572
|
end
|
527
573
|
|
528
574
|
def recent_posts # side-effect
|
575
|
+
log!(enter: __method__)
|
529
576
|
_out <<-HTML
|
530
577
|
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
|
531
578
|
<iframe id="main" style="width: 70vw; height: 100vh; position: relative;"
|
@@ -536,6 +583,7 @@ def recent_posts # side-effect
|
|
536
583
|
end
|
537
584
|
|
538
585
|
def _make_class_name(app)
|
586
|
+
log!(enter: __method__)
|
539
587
|
if app =~ /[-_]/
|
540
588
|
words = app.split(/[-_]/)
|
541
589
|
name = words.map(&:capitalize).join
|
@@ -546,6 +594,7 @@ def _make_class_name(app)
|
|
546
594
|
end
|
547
595
|
|
548
596
|
def _load_local(widget)
|
597
|
+
log!(enter: __method__)
|
549
598
|
Dir.chdir("../../widgets/#{widget}") do
|
550
599
|
rclass = _make_class_name(widget)
|
551
600
|
found = (require("./#{widget}") if File.exist?("#{widget}.rb"))
|
@@ -554,12 +603,13 @@ def _load_local(widget)
|
|
554
603
|
end
|
555
604
|
rescue => err
|
556
605
|
STDERR.puts err.to_s
|
557
|
-
STDERR.puts err.backtrace.join("\n")
|
606
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
558
607
|
sleep 6; RubyText.stop
|
559
608
|
exit
|
560
609
|
end
|
561
610
|
|
562
611
|
def _handle_standard_widget(tag)
|
612
|
+
log!(enter: __method__)
|
563
613
|
wtag = "../../widgets"/tag
|
564
614
|
code = _load_local(tag)
|
565
615
|
if code
|
@@ -571,6 +621,7 @@ def _handle_standard_widget(tag)
|
|
571
621
|
end
|
572
622
|
|
573
623
|
def sidebar
|
624
|
+
log!(enter: __method__)
|
574
625
|
_debug "--- handling sidebar\r"
|
575
626
|
if _args.include? "off"
|
576
627
|
_body { } # iterate, do nothing
|
@@ -584,9 +635,8 @@ def sidebar
|
|
584
635
|
_body do |token|
|
585
636
|
tag = token.chomp.strip.downcase
|
586
637
|
wtag = "../../widgets"/tag
|
587
|
-
raise
|
638
|
+
raise CantFindWidgetDir(wtag) unless Dir.exist?(wtag)
|
588
639
|
tcard = "#{tag}-card.html"
|
589
|
-
|
590
640
|
case
|
591
641
|
when standard.include?(tag)
|
592
642
|
_handle_standard_widget(tag)
|
@@ -599,12 +649,13 @@ def sidebar
|
|
599
649
|
_out %[</div>]
|
600
650
|
rescue => err
|
601
651
|
puts "err = #{err}"
|
602
|
-
puts err.backtrace.join("\n")
|
652
|
+
puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
603
653
|
sleep 6; RubyText.stop
|
604
654
|
exit
|
605
655
|
end
|
606
656
|
|
607
657
|
def stylesheet
|
658
|
+
log!(enter: __method__)
|
608
659
|
lines = _body
|
609
660
|
url = lines[0]
|
610
661
|
integ = lines[1]
|
@@ -613,6 +664,7 @@ def stylesheet
|
|
613
664
|
end
|
614
665
|
|
615
666
|
def script
|
667
|
+
log!(enter: __method__)
|
616
668
|
lines = _body
|
617
669
|
url = lines[0]
|
618
670
|
integ = lines[1]
|
@@ -662,6 +714,7 @@ end
|
|
662
714
|
|
663
715
|
|
664
716
|
def tag_cloud
|
717
|
+
log!(enter: __method__)
|
665
718
|
title = _data
|
666
719
|
title = "Tag Cloud" if title.empty?
|
667
720
|
open = <<-HTML
|
@@ -685,18 +738,22 @@ def tag_cloud
|
|
685
738
|
end
|
686
739
|
|
687
740
|
def vnavbar
|
741
|
+
log!(enter: __method__)
|
688
742
|
str = _make_navbar(:vert)
|
689
743
|
end
|
690
744
|
|
691
745
|
def hnavbar
|
746
|
+
log!(enter: __method__)
|
692
747
|
str = _make_navbar # horiz is default
|
693
748
|
end
|
694
749
|
|
695
750
|
def navbar
|
751
|
+
log!(enter: __method__)
|
696
752
|
str = _make_navbar # horiz is default
|
697
753
|
end
|
698
754
|
|
699
755
|
def _make_navbar(orient = :horiz)
|
756
|
+
log!(enter: __method__)
|
700
757
|
vdir = @root/:views/@blog.view
|
701
758
|
title = _var("view.title")
|
702
759
|
|
@@ -737,7 +794,7 @@ def _make_navbar(orient = :horiz)
|
|
737
794
|
else
|
738
795
|
dir = @blog.root/:views/@blog.view/"themes/standard/banner/navbar"
|
739
796
|
dest = vdir/"remote/banner/navbar"/basename+".html"
|
740
|
-
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
|
741
798
|
output.puts %[#{li1} <a class="nav-link" #{href_main}>#{cdata}</a> #{li2}]
|
742
799
|
end
|
743
800
|
end
|
@@ -752,6 +809,7 @@ end
|
|
752
809
|
##################
|
753
810
|
|
754
811
|
def _html_body(file, css = nil)
|
812
|
+
log!(enter: __method__)
|
755
813
|
file.puts "<html>"
|
756
814
|
if css
|
757
815
|
file.puts " <head>"
|
@@ -764,10 +822,12 @@ def _html_body(file, css = nil)
|
|
764
822
|
end
|
765
823
|
|
766
824
|
def _errout(*args)
|
825
|
+
log!(enter: __method__)
|
767
826
|
::STDERR.puts *args
|
768
827
|
end
|
769
828
|
|
770
829
|
def _passthru(line)
|
830
|
+
log!(enter: __method__)
|
771
831
|
return if line.nil?
|
772
832
|
line = _format(line)
|
773
833
|
_out line + "\n"
|
@@ -775,6 +835,7 @@ def _passthru(line)
|
|
775
835
|
end
|
776
836
|
|
777
837
|
def _passthru_noline(line)
|
838
|
+
log!(enter: __method__)
|
778
839
|
return if line.nil?
|
779
840
|
line = _format(line)
|
780
841
|
_out line
|
@@ -782,6 +843,7 @@ def _passthru_noline(line)
|
|
782
843
|
end
|
783
844
|
|
784
845
|
def _write_metadata
|
846
|
+
log!(enter: __method__)
|
785
847
|
File.write("teaser.txt", @meta.teaser)
|
786
848
|
fields = [:num, :title, :date, :pubdate, :views, :tags, :pinned]
|
787
849
|
fname = "metadata.txt"
|
@@ -791,20 +853,32 @@ def _write_metadata
|
|
791
853
|
end
|
792
854
|
|
793
855
|
def _post_lookup(postid) # side-effect
|
856
|
+
log!(enter: __method__)
|
794
857
|
# .. = templates, ../.. = views/thisview
|
795
858
|
slug = title = date = teaser_text = nil
|
796
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}"
|
797
867
|
dir_posts = @vdir/:posts
|
798
868
|
posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts/x }
|
799
869
|
posts.select! {|x| File.directory?(x) }
|
800
870
|
|
871
|
+
tmp.puts "_post_lookup: postid = #{postid}"
|
872
|
+
tmp.puts "_post_lookup: posts = \n#{posts.inspect}"
|
873
|
+
tmp.close
|
801
874
|
posts = posts.select {|x| File.basename(x).to_i == postid }
|
802
|
-
postdir = exactly_one(posts)
|
875
|
+
postdir = exactly_one(posts, posts.inspect)
|
803
876
|
vp = RuneBlog::ViewPost.new(@blog.view, postdir)
|
804
877
|
vp
|
805
878
|
end
|
806
879
|
|
807
880
|
def _card_generic(card_title:, middle:, extra: "")
|
881
|
+
log!(enter: __method__)
|
808
882
|
front = <<-HTML
|
809
883
|
<div class="card #{extra} mb-3">
|
810
884
|
<div class="card-body">
|
@@ -820,14 +894,17 @@ def _card_generic(card_title:, middle:, extra: "")
|
|
820
894
|
end
|
821
895
|
|
822
896
|
def _var(name) # FIXME scope issue!
|
897
|
+
log!(enter: __method__)
|
823
898
|
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
824
899
|
end
|
825
900
|
|
826
901
|
def _main(url)
|
902
|
+
log!(enter: __method__)
|
827
903
|
%[href="javascript: void(0)" onclick="javascript:open_main('#{url}')"]
|
828
904
|
end
|
829
905
|
|
830
906
|
def _blank(url)
|
907
|
+
log!(enter: __method__)
|
831
908
|
%[href='#{url}' target='blank']
|
832
909
|
end
|
833
910
|
|