runeblog 0.2.23 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/empty_view.tgz +0 -0
- data/lib/liveblog.rb +241 -235
- data/lib/runeblog.rb +28 -3
- data/lib/runeblog_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 707ca8bf9834f7ed3bf831fa47189203ed2815a069051bd65bde6640a98b9828
|
4
|
+
data.tar.gz: 21ad77269fc5fe291cab102a71a252635b8be69b052b655a16820c2515f2e27b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e68f4e2d5865b12a6e2e384065e134ed13eb41f1136d4d4fd10f76f26ed695d3764ae7a9478b1b38bd753b44b453b9da2bd2215e02770ef1d5f01811aeb9e40
|
7
|
+
data.tar.gz: 8d9cb531a9adbf9607f5d116940817ca6488fc7dfc4eecb18ea98fb945ec2fe129dba1c1111213286d77f367a128d34e318201dfe69cc649756fdc113a26732c
|
data/empty_view.tgz
CHANGED
Binary file
|
data/lib/liveblog.rb
CHANGED
@@ -2,11 +2,8 @@ require 'ostruct'
|
|
2
2
|
require 'pp'
|
3
3
|
require 'date'
|
4
4
|
|
5
|
-
# require 'livetext'
|
6
5
|
require 'runeblog'
|
7
|
-
|
8
6
|
require 'pathmagic'
|
9
|
-
|
10
7
|
require 'xlate'
|
11
8
|
|
12
9
|
# errfile = File.new("/tmp/liveblog.out", "w")
|
@@ -26,20 +23,24 @@ def init_liveblog # FIXME - a lot of this logic sucks
|
|
26
23
|
@theme = @vdir/:themes/:standard
|
27
24
|
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
def livetext(src, dst=nil, cwd=Dir.pwd)
|
32
|
-
Dir.chdir(cwd) do
|
33
|
-
src += ".lt3" unless src.end_with?(".lt3")
|
34
|
-
if dst
|
35
|
-
dst += ".html" unless dst.end_with?(".html")
|
36
|
-
else
|
37
|
-
dst = src.sub(/.lt3$/, "")
|
38
|
-
end
|
39
|
-
return unless stale?(src, dst)
|
40
|
-
system("livetext #{src} >#{dst}")
|
41
|
-
end
|
42
|
-
end
|
26
|
+
## FIXME - livetext is duplicated from helpers-blog
|
27
|
+
#
|
28
|
+
# def livetext(src, dst=nil, cwd=Dir.pwd)
|
29
|
+
# Dir.chdir(cwd) do
|
30
|
+
# src += ".lt3" unless src.end_with?(".lt3")
|
31
|
+
# if dst
|
32
|
+
# dst += ".html" unless dst.end_with?(".html")
|
33
|
+
# else
|
34
|
+
# dst = src.sub(/.lt3$/, "")
|
35
|
+
# end
|
36
|
+
# return unless stale?(src, dst)
|
37
|
+
# system("livetext #{src} >#{dst}")
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
|
41
|
+
##################
|
42
|
+
# "dot" commands
|
43
|
+
##################
|
43
44
|
|
44
45
|
def post
|
45
46
|
@meta = OpenStruct.new
|
@@ -100,98 +101,6 @@ def list!
|
|
100
101
|
_optional_blank_line
|
101
102
|
end
|
102
103
|
|
103
|
-
def _html_body(file)
|
104
|
-
file.puts "<html>\n <body>"
|
105
|
-
yield
|
106
|
-
file.puts " </body>\n</html>"
|
107
|
-
end
|
108
|
-
|
109
|
-
def _write_card(cardfile, mainfile, pairs, card_title, tag, relative: true)
|
110
|
-
log!(str: "Creating #{cardfile}.html", pwd: true)
|
111
|
-
url = mainfile
|
112
|
-
url = :widgets/tag/mainfile + ".html"
|
113
|
-
File.open("#{cardfile}.html", "w") do |f|
|
114
|
-
f.puts <<-EOS
|
115
|
-
<div class="card mb-3">
|
116
|
-
<div class="card-body">
|
117
|
-
<h5 class="card-title">
|
118
|
-
<a href="javascript: void(0)"
|
119
|
-
onclick="javascript:open_main('#{url}')"
|
120
|
-
style="text-decoration: none; color: black">#{card_title}</a>
|
121
|
-
</h5>
|
122
|
-
EOS
|
123
|
-
log!(str: "Writing data pairs to #{cardfile}.html", pwd: true)
|
124
|
-
local = _local_tag?(tag)
|
125
|
-
pairs.each do |file, title|
|
126
|
-
url = file
|
127
|
-
yesno = "yes"
|
128
|
-
yesno, title = title.split(/, */) if title =~ /^[yes|no]/ # FIXME please!
|
129
|
-
|
130
|
-
case [yesno, local]
|
131
|
-
when ["yes", false] # can iframe, remote file
|
132
|
-
which = 1
|
133
|
-
url_ref = "href='#{file}'"
|
134
|
-
when ["yes", true] # can iframe, local file
|
135
|
-
which = 2
|
136
|
-
url_ref = _widget_card(file, tag)
|
137
|
-
when ["no", false] # CAN'T iframe, remote file
|
138
|
-
which = 3
|
139
|
-
url_ref = _blank(file)
|
140
|
-
when ["no", true] # CAN'T iframe, local file (possible?)
|
141
|
-
which = 4
|
142
|
-
url_ref = _blank(file)
|
143
|
-
end
|
144
|
-
|
145
|
-
anchor = %[<a #{url_ref}>#{title}</a>]
|
146
|
-
wrapper = %[<li class="list-group-item">#{anchor}</li>]
|
147
|
-
f.puts wrapper
|
148
|
-
end
|
149
|
-
f.puts <<-EOS
|
150
|
-
</div>
|
151
|
-
</div>
|
152
|
-
EOS
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def _local_tag?(tag)
|
157
|
-
case tag.to_sym
|
158
|
-
when :pages
|
159
|
-
true
|
160
|
-
when :news, :links
|
161
|
-
false
|
162
|
-
else
|
163
|
-
true # Hmmm...
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def _write_main(mainfile, pairs, card_title, tag)
|
168
|
-
log!(str: "Creating #{mainfile}.html", pwd: true)
|
169
|
-
local = _local_tag?(tag)
|
170
|
-
File.open("#{mainfile}.html", "w") do |f|
|
171
|
-
_html_body(f) do
|
172
|
-
f.puts "<h1>#{card_title}</h1>"
|
173
|
-
pairs.each do |file, title|
|
174
|
-
yesno = "yes"
|
175
|
-
yesno, title = title.split(/, */) if title =~ /^[yes|no]/ # FIXME please!
|
176
|
-
case [yesno, local]
|
177
|
-
when ["yes", false] # can iframe, remote file
|
178
|
-
which = 1
|
179
|
-
url_ref = "href='#{file}'"
|
180
|
-
when ["yes", true] # can iframe, local file
|
181
|
-
which = 2
|
182
|
-
url_ref = _widget_main(file, tag)
|
183
|
-
when ["no", false] # CAN'T iframe, remote file
|
184
|
-
which = 3
|
185
|
-
url_ref = _blank(file)
|
186
|
-
when ["no", true] # CAN'T iframe, local file (possible?)
|
187
|
-
which = 4
|
188
|
-
url_ref = _blank(file)
|
189
|
-
end
|
190
|
-
f.puts %[<a style="text-decoration: none; font-size: 24px" #{url_ref}>#{title}</a> <br>]
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
104
|
|
196
105
|
def make_main_links
|
197
106
|
log!(enter: __method__)
|
@@ -235,24 +144,6 @@ def inset
|
|
235
144
|
_optional_blank_line
|
236
145
|
end
|
237
146
|
|
238
|
-
def _errout(*args)
|
239
|
-
::STDERR.puts *args
|
240
|
-
end
|
241
|
-
|
242
|
-
def _passthru(line)
|
243
|
-
return if line.nil?
|
244
|
-
line = _format(line)
|
245
|
-
_out line + "\n"
|
246
|
-
_out "<p>" if line.empty? && ! @_nopara
|
247
|
-
end
|
248
|
-
|
249
|
-
def _passthru_noline(line)
|
250
|
-
return if line.nil?
|
251
|
-
line = _format(line)
|
252
|
-
_out line
|
253
|
-
_out "<p>" if line.empty? && ! @_nopara
|
254
|
-
end
|
255
|
-
|
256
147
|
def title
|
257
148
|
raise "'post' was not called" unless @meta
|
258
149
|
title = @_data.chomp
|
@@ -304,15 +195,6 @@ def pin
|
|
304
195
|
_optional_blank_line
|
305
196
|
end
|
306
197
|
|
307
|
-
def _write_metadata
|
308
|
-
File.write("teaser.txt", @meta.teaser)
|
309
|
-
fields = [:num, :title, :date, :pubdate, :views, :tags]
|
310
|
-
fname2 = "metadata.txt"
|
311
|
-
f2 = File.open(fname2, "w") do |f2|
|
312
|
-
fields.each {|fld| f2.puts "#{fld}: #{@meta.send(fld)}" }
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
198
|
def write_post
|
317
199
|
raise "'post' was not called" unless @meta
|
318
200
|
@meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
|
@@ -332,6 +214,7 @@ def teaser
|
|
332
214
|
end
|
333
215
|
|
334
216
|
def finalize
|
217
|
+
# FIXME simplify this!
|
335
218
|
unless @meta
|
336
219
|
puts @live.body
|
337
220
|
return
|
@@ -347,55 +230,6 @@ def finalize
|
|
347
230
|
@meta
|
348
231
|
end
|
349
232
|
|
350
|
-
$Dot = self # Clunky! for dot commands called from Functions class
|
351
|
-
|
352
|
-
# Find a better way to do this?
|
353
|
-
|
354
|
-
class Livetext::Functions
|
355
|
-
|
356
|
-
def br(n="1")
|
357
|
-
# Thought: Maybe make a way for functions to "simply" call the
|
358
|
-
# dot command of the same name?? Is this trivial??
|
359
|
-
n = n.empty? ? 1 : n.to_i
|
360
|
-
"<br>"*n
|
361
|
-
end
|
362
|
-
|
363
|
-
def h1(param); "<h1>#{param}</h1>"; end
|
364
|
-
def h2(param); "<h2>#{param}</h2>"; end
|
365
|
-
def h3(param); "<h3>#{param}</h3>"; end
|
366
|
-
def h4(param); "<h4>#{param}</h4>"; end
|
367
|
-
def h5(param); "<h5>#{param}</h5>"; end
|
368
|
-
def h6(param); "<h6>#{param}</h6>"; end
|
369
|
-
|
370
|
-
def hr(param=nil)
|
371
|
-
$Dot.hr
|
372
|
-
end
|
373
|
-
|
374
|
-
def image(param)
|
375
|
-
"<img src='#{param}'></img>"
|
376
|
-
end
|
377
|
-
|
378
|
-
end
|
379
|
-
|
380
|
-
###### experimental...
|
381
|
-
|
382
|
-
class Livetext::Functions
|
383
|
-
def _var(name)
|
384
|
-
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
385
|
-
end
|
386
|
-
|
387
|
-
def link
|
388
|
-
file, cdata = self.class.param.split("||", 2)
|
389
|
-
%[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}#{file}" title="#{_var(:title)}">]
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
###
|
394
|
-
|
395
|
-
def _var(name) # FIXME scope issue!
|
396
|
-
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
397
|
-
end
|
398
|
-
|
399
233
|
def head # Does NOT output <head> tags
|
400
234
|
args = _args
|
401
235
|
args.each do |inc|
|
@@ -496,10 +330,10 @@ def sidebar
|
|
496
330
|
children = Dir[wtag/"*.lt3"] - [wtag/tag+".lt3"]
|
497
331
|
children.each do |child|
|
498
332
|
dest = child.sub(/.lt3$/, ".html")
|
499
|
-
xlate src: child, dst: dest, debug: true
|
333
|
+
xlate src: child, dst: dest # , debug: true
|
500
334
|
end
|
501
335
|
end
|
502
|
-
xlate cwd: wtag, src: tag, dst: tcard, debug: true
|
336
|
+
xlate cwd: wtag, src: tag, dst: tcard # , debug: true
|
503
337
|
_include_file wtag/tcard
|
504
338
|
end
|
505
339
|
_out %[</div>]
|
@@ -521,41 +355,6 @@ def script
|
|
521
355
|
_out %[<script src="#{url}" integrity="#{integ}" crossorigin="#{cross}"></script>]
|
522
356
|
end
|
523
357
|
|
524
|
-
def _post_lookup(postid) # side-effect
|
525
|
-
# .. = templates, ../.. = views/thisview
|
526
|
-
slug = title = date = teaser_text = nil
|
527
|
-
|
528
|
-
dir_posts = @vdir/:posts
|
529
|
-
posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts/x }
|
530
|
-
posts.select! {|x| File.directory?(x) }
|
531
|
-
|
532
|
-
post = posts.select {|x| File.basename(x).to_i == postid }
|
533
|
-
raise "Error: More than one post #{postid}" if post.size > 1
|
534
|
-
postdir = post.first
|
535
|
-
vp = RuneBlog::ViewPost.new(@blog.view, postdir)
|
536
|
-
vp
|
537
|
-
end
|
538
|
-
|
539
|
-
def _interpolate(str, context) # FIXME move this later
|
540
|
-
wrapped = "%[" + str.dup + "]" # could fail...
|
541
|
-
eval(wrapped, context)
|
542
|
-
end
|
543
|
-
|
544
|
-
def _card_generic(card_title:, middle:, extra: "")
|
545
|
-
front = <<-HTML
|
546
|
-
<div class="card #{extra} mb-3">
|
547
|
-
<div class="card-body">
|
548
|
-
<h5 class="card-title">#{card_title}</h5>
|
549
|
-
HTML
|
550
|
-
|
551
|
-
tail = <<-HTML
|
552
|
-
</div>
|
553
|
-
</div>
|
554
|
-
HTML
|
555
|
-
text = front + middle + tail
|
556
|
-
_out text + "\n "
|
557
|
-
end
|
558
|
-
|
559
358
|
def card_iframe
|
560
359
|
title, lines = _data, _body
|
561
360
|
lines.map!(&:chomp)
|
@@ -571,23 +370,51 @@ def card_iframe
|
|
571
370
|
_card_generic(card_title: title, middle: middle, extra: "bg-dark text-white")
|
572
371
|
end
|
573
372
|
|
574
|
-
|
575
|
-
%[href="javascript: void(0)" onclick="javascript:open_main('#{url}')"]
|
576
|
-
end
|
373
|
+
$Dot = self # Clunky! for dot commands called from Functions class
|
577
374
|
|
578
|
-
|
579
|
-
|
580
|
-
|
375
|
+
# Find a better way to do this?
|
376
|
+
|
377
|
+
class Livetext::Functions
|
378
|
+
|
379
|
+
def br(n="1")
|
380
|
+
# Thought: Maybe make a way for functions to "simply" call the
|
381
|
+
# dot command of the same name?? Is this trivial??
|
382
|
+
n = n.empty? ? 1 : n.to_i
|
383
|
+
"<br>"*n
|
384
|
+
end
|
385
|
+
|
386
|
+
def h1(param); "<h1>#{param}</h1>"; end
|
387
|
+
def h2(param); "<h2>#{param}</h2>"; end
|
388
|
+
def h3(param); "<h3>#{param}</h3>"; end
|
389
|
+
def h4(param); "<h4>#{param}</h4>"; end
|
390
|
+
def h5(param); "<h5>#{param}</h5>"; end
|
391
|
+
def h6(param); "<h6>#{param}</h6>"; end
|
392
|
+
|
393
|
+
def hr(param=nil)
|
394
|
+
$Dot.hr
|
395
|
+
end
|
396
|
+
|
397
|
+
def image(param)
|
398
|
+
"<img src='#{param}'></img>"
|
399
|
+
end
|
581
400
|
|
582
|
-
def _widget_main(url, tag)
|
583
|
-
%[href="#{url}"]
|
584
401
|
end
|
585
402
|
|
586
|
-
|
587
|
-
|
588
|
-
|
403
|
+
###### experimental...
|
404
|
+
|
405
|
+
class Livetext::Functions
|
406
|
+
def _var(name)
|
407
|
+
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
408
|
+
end
|
409
|
+
|
410
|
+
def link
|
411
|
+
file, cdata = self.class.param.split("||", 2)
|
412
|
+
%[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}#{file}" title="#{_var(:title)}">]
|
413
|
+
end
|
589
414
|
end
|
590
415
|
|
416
|
+
###
|
417
|
+
|
591
418
|
def card1
|
592
419
|
title, lines = _data, _body
|
593
420
|
lines.map!(&:chomp)
|
@@ -633,7 +460,11 @@ def tag_cloud
|
|
633
460
|
open = <<-HTML
|
634
461
|
<div class="card mb-3">
|
635
462
|
<div class="card-body">
|
636
|
-
<h5 class="card-title"
|
463
|
+
<h5 class="card-title">
|
464
|
+
<button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#tag-cloud">+</button>
|
465
|
+
#{title}
|
466
|
+
</h5>
|
467
|
+
<div class="collapse" id="tag-cloud">
|
637
468
|
HTML
|
638
469
|
_out open
|
639
470
|
_body do |line|
|
@@ -642,7 +473,7 @@ def tag_cloud
|
|
642
473
|
main = _main(url)
|
643
474
|
_out %[<a #{main} class="#{classname}">#{cdata}</a>]
|
644
475
|
end
|
645
|
-
close = %[ </div>\n </div>]
|
476
|
+
close = %[ </div>\n </div>\n </div>]
|
646
477
|
_out close
|
647
478
|
end
|
648
479
|
|
@@ -690,3 +521,178 @@ def navbar
|
|
690
521
|
_out close
|
691
522
|
end
|
692
523
|
|
524
|
+
##################
|
525
|
+
# helper methods
|
526
|
+
##################
|
527
|
+
|
528
|
+
def _html_body(file)
|
529
|
+
file.puts "<html>\n <body>"
|
530
|
+
yield
|
531
|
+
file.puts " </body>\n</html>"
|
532
|
+
end
|
533
|
+
|
534
|
+
def _write_card(cardfile, mainfile, pairs, card_title, tag, relative: true)
|
535
|
+
log!(str: "Creating #{cardfile}.html", pwd: true)
|
536
|
+
url = mainfile
|
537
|
+
url = :widgets/tag/mainfile + ".html"
|
538
|
+
File.open("#{cardfile}.html", "w") do |f|
|
539
|
+
f.puts <<-EOS
|
540
|
+
<div class="card mb-3">
|
541
|
+
<div class="card-body">
|
542
|
+
<h5 class="card-title">
|
543
|
+
<button type="button" class="btn btn-primary" data-toggle="collapse" data-target="##{tag}">+</button>
|
544
|
+
<a href="javascript: void(0)"
|
545
|
+
onclick="javascript:open_main('#{url}')"
|
546
|
+
style="text-decoration: none; color: black"> #{card_title}</a>
|
547
|
+
</h5>
|
548
|
+
<div class="collapse" id="#{tag}">
|
549
|
+
EOS
|
550
|
+
log!(str: "Writing data pairs to #{cardfile}.html", pwd: true)
|
551
|
+
local = _local_tag?(tag)
|
552
|
+
pairs.each do |file, title|
|
553
|
+
url = file
|
554
|
+
yesno = "yes"
|
555
|
+
yesno, title = title.split(/, */) if title =~ /^[yes|no]/ # FIXME please!
|
556
|
+
|
557
|
+
case [yesno, local]
|
558
|
+
when ["yes", false] # can iframe, remote file
|
559
|
+
url_ref = "href='#{file}'"
|
560
|
+
when ["yes", true] # can iframe, local file
|
561
|
+
url_ref = _widget_card(file, tag)
|
562
|
+
when ["no", false] # CAN'T iframe, remote file
|
563
|
+
url_ref = _blank(file)
|
564
|
+
when ["no", true] # CAN'T iframe, local file (possible?)
|
565
|
+
url_ref = _blank(file)
|
566
|
+
end
|
567
|
+
|
568
|
+
anchor = %[<a #{url_ref}>#{title}</a>]
|
569
|
+
wrapper = %[<li class="list-group-item">#{anchor}</li>]
|
570
|
+
f.puts wrapper
|
571
|
+
end
|
572
|
+
f.puts <<-EOS
|
573
|
+
</div>
|
574
|
+
</div>
|
575
|
+
</div>
|
576
|
+
EOS
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
def _local_tag?(tag)
|
581
|
+
case tag.to_sym
|
582
|
+
when :pages
|
583
|
+
true
|
584
|
+
when :news, :links
|
585
|
+
false
|
586
|
+
else
|
587
|
+
true # Hmmm...
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
def _write_main(mainfile, pairs, card_title, tag)
|
592
|
+
log!(str: "Creating #{mainfile}.html", pwd: true)
|
593
|
+
local = _local_tag?(tag)
|
594
|
+
File.open("#{mainfile}.html", "w") do |f|
|
595
|
+
_html_body(f) do
|
596
|
+
f.puts "<h1>#{card_title}</h1>"
|
597
|
+
pairs.each do |file, title|
|
598
|
+
yesno = "yes"
|
599
|
+
yesno, title = title.split(/, */) if title =~ /^[yes|no]/ # FIXME please!
|
600
|
+
case [yesno, local]
|
601
|
+
when ["yes", false] # can iframe, remote file
|
602
|
+
url_ref = "href='#{file}'"
|
603
|
+
when ["yes", true] # can iframe, local file
|
604
|
+
url_ref = _widget_main(file, tag)
|
605
|
+
when ["no", false] # CAN'T iframe, remote file
|
606
|
+
url_ref = _blank(file)
|
607
|
+
when ["no", true] # CAN'T iframe, local file (possible?)
|
608
|
+
url_ref = _blank(file)
|
609
|
+
end
|
610
|
+
f.puts %[<a style="text-decoration: none; font-size: 24px" #{url_ref}>#{title}</a> <br>]
|
611
|
+
end
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
def _errout(*args)
|
617
|
+
::STDERR.puts *args
|
618
|
+
end
|
619
|
+
|
620
|
+
def _passthru(line)
|
621
|
+
return if line.nil?
|
622
|
+
line = _format(line)
|
623
|
+
_out line + "\n"
|
624
|
+
_out "<p>" if line.empty? && ! @_nopara
|
625
|
+
end
|
626
|
+
|
627
|
+
def _passthru_noline(line)
|
628
|
+
return if line.nil?
|
629
|
+
line = _format(line)
|
630
|
+
_out line
|
631
|
+
_out "<p>" if line.empty? && ! @_nopara
|
632
|
+
end
|
633
|
+
|
634
|
+
def _write_metadata
|
635
|
+
File.write("teaser.txt", @meta.teaser)
|
636
|
+
fields = [:num, :title, :date, :pubdate, :views, :tags]
|
637
|
+
fname2 = "metadata.txt"
|
638
|
+
f2 = File.open(fname2, "w") do |f2|
|
639
|
+
fields.each {|fld| f2.puts "#{fld}: #{@meta.send(fld)}" }
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
def _post_lookup(postid) # side-effect
|
644
|
+
# .. = templates, ../.. = views/thisview
|
645
|
+
slug = title = date = teaser_text = nil
|
646
|
+
|
647
|
+
dir_posts = @vdir/:posts
|
648
|
+
posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts/x }
|
649
|
+
posts.select! {|x| File.directory?(x) }
|
650
|
+
|
651
|
+
post = posts.select {|x| File.basename(x).to_i == postid }
|
652
|
+
raise "Error: More than one post #{postid}" if post.size > 1
|
653
|
+
postdir = post.first
|
654
|
+
vp = RuneBlog::ViewPost.new(@blog.view, postdir)
|
655
|
+
vp
|
656
|
+
end
|
657
|
+
|
658
|
+
def _interpolate(str, context) # FIXME move this later
|
659
|
+
wrapped = "%[" + str.dup + "]" # could fail...
|
660
|
+
eval(wrapped, context)
|
661
|
+
end
|
662
|
+
|
663
|
+
def _card_generic(card_title:, middle:, extra: "")
|
664
|
+
front = <<-HTML
|
665
|
+
<div class="card #{extra} mb-3">
|
666
|
+
<div class="card-body">
|
667
|
+
<h5 class="card-title">#{card_title}</h5>
|
668
|
+
HTML
|
669
|
+
|
670
|
+
tail = <<-HTML
|
671
|
+
</div>
|
672
|
+
</div>
|
673
|
+
HTML
|
674
|
+
text = front + middle + tail
|
675
|
+
_out text + "\n "
|
676
|
+
end
|
677
|
+
|
678
|
+
def _var(name) # FIXME scope issue!
|
679
|
+
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
680
|
+
end
|
681
|
+
|
682
|
+
def _main(url)
|
683
|
+
%[href="javascript: void(0)" onclick="javascript:open_main('#{url}')"]
|
684
|
+
end
|
685
|
+
|
686
|
+
def _blank(url)
|
687
|
+
%[href='#{url}' target='blank']
|
688
|
+
end
|
689
|
+
|
690
|
+
def _widget_main(url, tag)
|
691
|
+
%[href="#{url}"]
|
692
|
+
end
|
693
|
+
|
694
|
+
def _widget_card(url, tag)
|
695
|
+
url2 = :widgets/tag/url
|
696
|
+
%[href="#{url2}"]
|
697
|
+
end
|
698
|
+
|
data/lib/runeblog.rb
CHANGED
@@ -104,11 +104,37 @@ class RuneBlog
|
|
104
104
|
def _deploy_local(dir)
|
105
105
|
log!(enter: __method__, args: [dir])
|
106
106
|
Dir.chdir(dir) do
|
107
|
-
|
107
|
+
# views = File.readlines("metadata.txt").grep(/^views: /).first[7..-1].split
|
108
|
+
views = _retrieve_metadata(:views)
|
109
|
+
STDERR.puts "---- deploy: views = #{views.inspect}"
|
108
110
|
views.each {|v| system("cp *html #@root/views/#{v}/remote") }
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
114
|
+
def _retrieve_metadata(key)
|
115
|
+
key = key.to_s
|
116
|
+
STDERR.puts "--- retrieve: key = #{key.inspect}"
|
117
|
+
lines = File.readlines("metadata.txt")
|
118
|
+
lines = lines.grep(/^#{key}: /)
|
119
|
+
case lines.size
|
120
|
+
when 0
|
121
|
+
result = nil # not found
|
122
|
+
when 1
|
123
|
+
front = "#{key}: "
|
124
|
+
n = front.size + 1
|
125
|
+
str = lines.first.chomp[n..-1]
|
126
|
+
case key
|
127
|
+
when "views", "tags" # plurals
|
128
|
+
result = str.split
|
129
|
+
else
|
130
|
+
result = str
|
131
|
+
end
|
132
|
+
else
|
133
|
+
raise "Too many #{key} instances in metadata.txt!"
|
134
|
+
end
|
135
|
+
return result
|
136
|
+
end
|
137
|
+
|
112
138
|
def process_post(sourcefile)
|
113
139
|
log!(enter: __method__, args: [dir])
|
114
140
|
nslug = sourcefile.sub(/.lt3/, "")
|
@@ -417,10 +443,9 @@ class RuneBlog
|
|
417
443
|
|
418
444
|
def _post_metadata(draft, pdraft)
|
419
445
|
log!(enter: __method__, args: [draft, pdraft])
|
420
|
-
title_line = File.readlines(draft).grep(/^.title /).first
|
421
|
-
title = title_line.split(" ", 2)[1]
|
422
446
|
Dir.chdir(pdraft) do
|
423
447
|
excerpt = File.read("teaser.txt")
|
448
|
+
title = _retrieve_metadata(:title)
|
424
449
|
vars = %[.set title="#{title.chomp}"\n] +
|
425
450
|
%[.set teaser="#{excerpt.chomp}"]
|
426
451
|
File.open(pdraft/"vars.lt3", "w") {|f| f.puts vars }
|
data/lib/runeblog_version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runeblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|