runeblog 0.3.21 → 0.3.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +80 -52
- 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 +1 -1
- data/empty_view/themes/standard/post/generate.lt3 +2 -2
- data/empty_view/themes/standard/post/permalink.lt3 +1 -1
- data/lib/helpers-blog.rb +5 -4
- data/lib/liveblog.rb +81 -17
- data/lib/lowlevel.rb +25 -8
- data/lib/menus.rb +9 -8
- data/lib/newpost.rb +35 -26
- data/lib/post.rb +3 -2
- data/lib/processing.rb +29 -3
- data/lib/publish.rb +3 -1
- data/lib/repl.rb +46 -19
- data/lib/runeblog.rb +81 -49
- data/lib/runeblog_version.rb +1 -1
- data/lib/view.rb +22 -3
- data/runeblog.gemspec +4 -2
- metadata +28 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 646006af4da125dc3a6d968d76078b017e3b88d109a566e9e6b58cf90b24f91e
|
4
|
+
data.tar.gz: 2c6de1ce325f0183ad07c72fd13f73464079c2939a0980d35aedaa339117b866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf8be383a0b54359dfc55da15f33008348039de26d6ce79806c49db682c4015e6239a6cc0614dd50cc630de4e2df8d403e75c6b6640cd750fdf6f91d6d96ebd
|
7
|
+
data.tar.gz: 551c4be7d6f9d3b89c4e9a681083fbb63598a8e885b2bf1fc86816cc469ae39319a08e68590a1740d30e234698f54e8ea4e8e54d03b477fccddbca4b45acbe26
|
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
|
-
|
31
|
-
|
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
|
-
|
52
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
ver
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
-
|
176
|
+
def reopen_stderr
|
177
|
+
errfile = File.new("stderr.out", "w")
|
178
|
+
STDERR.reopen(errfile)
|
179
|
+
end
|
174
180
|
|
175
|
-
|
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
|
-
|
178
|
-
|
188
|
+
RubyText.start(:_echo, :keypad, scroll: true, log: "binblog.txt", fg: @fg, bg: @bg)
|
189
|
+
end
|
179
190
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
198
|
-
|
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
|
-
|
201
|
-
|
221
|
+
def exit_repl
|
222
|
+
# RubyText.stop
|
223
|
+
sleep 0.2
|
224
|
+
puts
|
225
|
+
end
|
202
226
|
|
203
|
-
|
227
|
+
### Main
|
204
228
|
|
205
|
-
|
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
|
-
|
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
|
data/data/global.lt3
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
. <variable> <value>
|
4
4
|
. --------------------------------------------------
|
5
5
|
|
6
|
-
.variables view
|
6
|
+
.variables view ../settings/view.txt
|
7
7
|
|
8
|
-
.variables recent
|
8
|
+
.variables recent ../settings/recent.txt
|
9
9
|
|
10
|
-
.variables publish
|
10
|
+
.variables publish ../settings/publish.txt
|
11
11
|
|
12
12
|
.variables
|
13
13
|
host http://SITE
|
data/data/universal.lt3
CHANGED
File without changes
|
data/lib/helpers-blog.rb
CHANGED
@@ -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("
|
61
|
-
@current_view = File.read("
|
62
|
-
@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?
|
63
64
|
rescue => err
|
64
65
|
puts "Can't read config: #{err}"
|
65
66
|
puts err.backtrace.join("\n")
|
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,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
|
-
|
104
|
+
log! str: "post_trailer: num = #{num}"
|
95
105
|
vp = _post_lookup(num)
|
96
|
-
|
106
|
+
log! str: "post_trailer: lookup = #{vp.num} #{vp.title}"
|
97
107
|
dir = @blog.root/:posts/vp.nslug
|
98
|
-
|
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 "
|
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
|
@@ -182,6 +197,7 @@ def banner
|
|
182
197
|
count += 1
|
183
198
|
tag, *data = line.split
|
184
199
|
data ||= []
|
200
|
+
deps = [@blog.view.globals[:ViewDir]/:data/"global.lt3"]
|
185
201
|
case tag
|
186
202
|
when "width"; wide = data[0]
|
187
203
|
when "height"; high = data[0]
|
@@ -202,7 +218,7 @@ def banner
|
|
202
218
|
if ! File.exist?(file)
|
203
219
|
src = file.sub(/html$/, "lt3")
|
204
220
|
if File.exist?(src)
|
205
|
-
preprocess src: src, dst: file, call: ".nopara"
|
221
|
+
preprocess src: src, dst: file, deps: deps, call: ".nopara", vars: @blog.view.globals
|
206
222
|
else
|
207
223
|
raise FoundNeither(file, src)
|
208
224
|
end
|
@@ -228,11 +244,11 @@ def banner
|
|
228
244
|
_out navbar if navbar
|
229
245
|
rescue => err
|
230
246
|
STDERR.puts "err = #{err}"
|
231
|
-
STDERR.puts err.backtrace.join("\n")
|
232
|
-
gets
|
247
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
233
248
|
end
|
234
249
|
|
235
250
|
def _svg_title(*args)
|
251
|
+
log!(enter: __method__)
|
236
252
|
width = "95%"
|
237
253
|
height = 90
|
238
254
|
bgcolor = "black"
|
@@ -288,6 +304,7 @@ def _svg_title(*args)
|
|
288
304
|
end
|
289
305
|
|
290
306
|
def quote
|
307
|
+
log!(enter: __method__)
|
291
308
|
_passthru "<blockquote>"
|
292
309
|
_passthru _body.join(" ")
|
293
310
|
_passthru "</blockquote>"
|
@@ -295,9 +312,11 @@ def quote
|
|
295
312
|
end
|
296
313
|
|
297
314
|
def categories # does nothing right now
|
315
|
+
log!(enter: __method__)
|
298
316
|
end
|
299
317
|
|
300
318
|
def style
|
319
|
+
log!(enter: __method__)
|
301
320
|
fname = _args[0]
|
302
321
|
_passthru %[<link rel="stylesheet" href="???/etc/#{fname}')">]
|
303
322
|
end
|
@@ -314,6 +333,7 @@ def h6; _passthru "<h6>#{@_data}</h6>"; end
|
|
314
333
|
def hr; _passthru "<hr>"; end
|
315
334
|
|
316
335
|
def nlist
|
336
|
+
log!(enter: __method__)
|
317
337
|
_out "<ol>"
|
318
338
|
_body {|line| _out "<li>#{line}</li>" }
|
319
339
|
_out "</ol>"
|
@@ -321,6 +341,7 @@ def nlist
|
|
321
341
|
end
|
322
342
|
|
323
343
|
def list
|
344
|
+
log!(enter: __method__)
|
324
345
|
_out "<ul>"
|
325
346
|
_body {|line| _out "<li>#{line}</li>" }
|
326
347
|
_out "</ul>"
|
@@ -328,6 +349,7 @@ def list
|
|
328
349
|
end
|
329
350
|
|
330
351
|
def list!
|
352
|
+
log!(enter: __method__)
|
331
353
|
_out "<ul>"
|
332
354
|
lines = _body.each
|
333
355
|
loop do
|
@@ -346,6 +368,7 @@ end
|
|
346
368
|
### inset
|
347
369
|
|
348
370
|
def inset
|
371
|
+
log!(enter: __method__)
|
349
372
|
lines = _body
|
350
373
|
box = ""
|
351
374
|
output = []
|
@@ -377,6 +400,7 @@ def inset
|
|
377
400
|
end
|
378
401
|
|
379
402
|
def title
|
403
|
+
log!(enter: __method__)
|
380
404
|
raise NoPostCall unless @meta
|
381
405
|
title = @_data.chomp
|
382
406
|
@meta.title = title
|
@@ -386,6 +410,7 @@ def title
|
|
386
410
|
end
|
387
411
|
|
388
412
|
def pubdate
|
413
|
+
log!(enter: __method__)
|
389
414
|
raise NoPostCall unless @meta
|
390
415
|
_debug "data = #@_data"
|
391
416
|
# Check for discrepancy?
|
@@ -398,6 +423,7 @@ def pubdate
|
|
398
423
|
end
|
399
424
|
|
400
425
|
def tags
|
426
|
+
log!(enter: __method__)
|
401
427
|
raise NoPostCall unless @meta
|
402
428
|
_debug "args = #{_args}"
|
403
429
|
@meta.tags = _args.dup || []
|
@@ -405,6 +431,7 @@ def tags
|
|
405
431
|
end
|
406
432
|
|
407
433
|
def views
|
434
|
+
log!(enter: __method__)
|
408
435
|
raise NoPostCall unless @meta
|
409
436
|
_debug "data = #{_args}"
|
410
437
|
@meta.views = _args.dup
|
@@ -412,6 +439,7 @@ def views
|
|
412
439
|
end
|
413
440
|
|
414
441
|
def pin
|
442
|
+
log!(enter: __method__)
|
415
443
|
raise NoPostCall unless @meta
|
416
444
|
_debug "data = #{_args}" # verify only valid views?
|
417
445
|
pinned = @_args
|
@@ -427,21 +455,22 @@ def pin
|
|
427
455
|
_optional_blank_line
|
428
456
|
rescue => err
|
429
457
|
STDERR.puts "err = #{err}"
|
430
|
-
STDERR.puts err.backtrace.join("\n")
|
431
|
-
gets
|
458
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
432
459
|
end
|
433
460
|
|
434
461
|
def write_post
|
462
|
+
log!(enter: __method__)
|
435
463
|
raise NoPostCall unless @meta
|
436
464
|
@meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
|
437
465
|
@meta.tags = @meta.tags.join(" ") if @meta.tags.is_a? Array
|
438
466
|
_write_metadata
|
439
467
|
rescue => err
|
440
468
|
puts "err = #{err}"
|
441
|
-
puts err.backtrace.join("\n")
|
469
|
+
puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
442
470
|
end
|
443
471
|
|
444
472
|
def teaser
|
473
|
+
log!(enter: __method__)
|
445
474
|
raise NoPostCall unless @meta
|
446
475
|
text = _body.join("\n")
|
447
476
|
@meta.teaser = text
|
@@ -456,6 +485,7 @@ def teaser
|
|
456
485
|
end
|
457
486
|
|
458
487
|
def finalize
|
488
|
+
log!(str: "Now exiting livetext processing...")
|
459
489
|
return unless @meta
|
460
490
|
return @meta if @blog.nil?
|
461
491
|
|
@@ -467,6 +497,7 @@ def finalize
|
|
467
497
|
end
|
468
498
|
|
469
499
|
def head # Does NOT output <head> tags
|
500
|
+
log!(enter: __method__)
|
470
501
|
args = _args
|
471
502
|
args.each do |inc|
|
472
503
|
self.data = inc
|
@@ -522,6 +553,7 @@ end
|
|
522
553
|
########## newer stuff...
|
523
554
|
|
524
555
|
def meta
|
556
|
+
log!(enter: __method__)
|
525
557
|
args = _args
|
526
558
|
enum = args.each
|
527
559
|
str = "<meta"
|
@@ -541,6 +573,7 @@ def meta
|
|
541
573
|
end
|
542
574
|
|
543
575
|
def recent_posts # side-effect
|
576
|
+
log!(enter: __method__)
|
544
577
|
_out <<-HTML
|
545
578
|
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12">
|
546
579
|
<iframe id="main" style="width: 70vw; height: 100vh; position: relative;"
|
@@ -551,6 +584,7 @@ def recent_posts # side-effect
|
|
551
584
|
end
|
552
585
|
|
553
586
|
def _make_class_name(app)
|
587
|
+
log!(enter: __method__)
|
554
588
|
if app =~ /[-_]/
|
555
589
|
words = app.split(/[-_]/)
|
556
590
|
name = words.map(&:capitalize).join
|
@@ -561,6 +595,7 @@ def _make_class_name(app)
|
|
561
595
|
end
|
562
596
|
|
563
597
|
def _load_local(widget)
|
598
|
+
log!(enter: __method__)
|
564
599
|
Dir.chdir("../../widgets/#{widget}") do
|
565
600
|
rclass = _make_class_name(widget)
|
566
601
|
found = (require("./#{widget}") if File.exist?("#{widget}.rb"))
|
@@ -569,12 +604,13 @@ def _load_local(widget)
|
|
569
604
|
end
|
570
605
|
rescue => err
|
571
606
|
STDERR.puts err.to_s
|
572
|
-
STDERR.puts err.backtrace.join("\n")
|
607
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
573
608
|
sleep 6; RubyText.stop
|
574
609
|
exit
|
575
610
|
end
|
576
611
|
|
577
612
|
def _handle_standard_widget(tag)
|
613
|
+
log!(enter: __method__)
|
578
614
|
wtag = "../../widgets"/tag
|
579
615
|
code = _load_local(tag)
|
580
616
|
if code
|
@@ -586,6 +622,7 @@ def _handle_standard_widget(tag)
|
|
586
622
|
end
|
587
623
|
|
588
624
|
def sidebar
|
625
|
+
log!(enter: __method__)
|
589
626
|
_debug "--- handling sidebar\r"
|
590
627
|
if _args.include? "off"
|
591
628
|
_body { } # iterate, do nothing
|
@@ -613,12 +650,13 @@ def sidebar
|
|
613
650
|
_out %[</div>]
|
614
651
|
rescue => err
|
615
652
|
puts "err = #{err}"
|
616
|
-
puts err.backtrace.join("\n")
|
653
|
+
puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
617
654
|
sleep 6; RubyText.stop
|
618
655
|
exit
|
619
656
|
end
|
620
657
|
|
621
658
|
def stylesheet
|
659
|
+
log!(enter: __method__)
|
622
660
|
lines = _body
|
623
661
|
url = lines[0]
|
624
662
|
integ = lines[1]
|
@@ -627,6 +665,7 @@ def stylesheet
|
|
627
665
|
end
|
628
666
|
|
629
667
|
def script
|
668
|
+
log!(enter: __method__)
|
630
669
|
lines = _body
|
631
670
|
url = lines[0]
|
632
671
|
integ = lines[1]
|
@@ -676,6 +715,7 @@ end
|
|
676
715
|
|
677
716
|
|
678
717
|
def tag_cloud
|
718
|
+
log!(enter: __method__)
|
679
719
|
title = _data
|
680
720
|
title = "Tag Cloud" if title.empty?
|
681
721
|
open = <<-HTML
|
@@ -699,18 +739,22 @@ def tag_cloud
|
|
699
739
|
end
|
700
740
|
|
701
741
|
def vnavbar
|
742
|
+
log!(enter: __method__)
|
702
743
|
str = _make_navbar(:vert)
|
703
744
|
end
|
704
745
|
|
705
746
|
def hnavbar
|
747
|
+
log!(enter: __method__)
|
706
748
|
str = _make_navbar # horiz is default
|
707
749
|
end
|
708
750
|
|
709
751
|
def navbar
|
752
|
+
log!(enter: __method__)
|
710
753
|
str = _make_navbar # horiz is default
|
711
754
|
end
|
712
755
|
|
713
756
|
def _make_navbar(orient = :horiz)
|
757
|
+
log!(enter: __method__)
|
714
758
|
vdir = @root/:views/@blog.view
|
715
759
|
title = _var("view.title")
|
716
760
|
|
@@ -751,7 +795,7 @@ def _make_navbar(orient = :horiz)
|
|
751
795
|
else
|
752
796
|
dir = @blog.root/:views/@blog.view/"themes/standard/banner/navbar"
|
753
797
|
dest = vdir/"remote/banner/navbar"/basename+".html"
|
754
|
-
preprocess cwd: dir, src: basename, dst: dest, call: ".nopara" # , debug: true
|
798
|
+
preprocess cwd: dir, src: basename, dst: dest, call: ".nopara", vars: @blog.view.globals # , debug: true
|
755
799
|
output.puts %[#{li1} <a class="nav-link" #{href_main}>#{cdata}</a> #{li2}]
|
756
800
|
end
|
757
801
|
end
|
@@ -766,6 +810,7 @@ end
|
|
766
810
|
##################
|
767
811
|
|
768
812
|
def _html_body(file, css = nil)
|
813
|
+
log!(enter: __method__)
|
769
814
|
file.puts "<html>"
|
770
815
|
if css
|
771
816
|
file.puts " <head>"
|
@@ -778,10 +823,12 @@ def _html_body(file, css = nil)
|
|
778
823
|
end
|
779
824
|
|
780
825
|
def _errout(*args)
|
826
|
+
log!(enter: __method__)
|
781
827
|
::STDERR.puts *args
|
782
828
|
end
|
783
829
|
|
784
830
|
def _passthru(line)
|
831
|
+
log!(enter: __method__)
|
785
832
|
return if line.nil?
|
786
833
|
line = _format(line)
|
787
834
|
_out line + "\n"
|
@@ -789,6 +836,7 @@ def _passthru(line)
|
|
789
836
|
end
|
790
837
|
|
791
838
|
def _passthru_noline(line)
|
839
|
+
log!(enter: __method__)
|
792
840
|
return if line.nil?
|
793
841
|
line = _format(line)
|
794
842
|
_out line
|
@@ -796,6 +844,7 @@ def _passthru_noline(line)
|
|
796
844
|
end
|
797
845
|
|
798
846
|
def _write_metadata
|
847
|
+
log!(enter: __method__)
|
799
848
|
File.write("teaser.txt", @meta.teaser)
|
800
849
|
fields = [:num, :title, :date, :pubdate, :views, :tags, :pinned]
|
801
850
|
fname = "metadata.txt"
|
@@ -805,20 +854,32 @@ def _write_metadata
|
|
805
854
|
end
|
806
855
|
|
807
856
|
def _post_lookup(postid) # side-effect
|
857
|
+
log!(enter: __method__)
|
808
858
|
# .. = templates, ../.. = views/thisview
|
809
859
|
slug = title = date = teaser_text = nil
|
810
860
|
|
861
|
+
view = @blog.view
|
862
|
+
vdir = view.dir rescue "NONAME"
|
863
|
+
setvar("View", view.name)
|
864
|
+
setvar("ViewDir", @blog.root/:views/view.name)
|
865
|
+
tmp = File.new("/tmp/PL-#{Time.now.to_i}.txt", "w")
|
866
|
+
tmp.puts "_post_lookup: blog.view = #{@blog.view.inspect}"
|
867
|
+
tmp.puts "_post_lookup: vdir = #{vdir}"
|
811
868
|
dir_posts = @vdir/:posts
|
812
869
|
posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts/x }
|
813
870
|
posts.select! {|x| File.directory?(x) }
|
814
871
|
|
872
|
+
tmp.puts "_post_lookup: postid = #{postid}"
|
873
|
+
tmp.puts "_post_lookup: posts = \n#{posts.inspect}"
|
874
|
+
tmp.close
|
815
875
|
posts = posts.select {|x| File.basename(x).to_i == postid }
|
816
|
-
postdir = exactly_one(posts)
|
876
|
+
postdir = exactly_one(posts, posts.inspect)
|
817
877
|
vp = RuneBlog::ViewPost.new(@blog.view, postdir)
|
818
878
|
vp
|
819
879
|
end
|
820
880
|
|
821
881
|
def _card_generic(card_title:, middle:, extra: "")
|
882
|
+
log!(enter: __method__)
|
822
883
|
front = <<-HTML
|
823
884
|
<div class="card #{extra} mb-3">
|
824
885
|
<div class="card-body">
|
@@ -834,14 +895,17 @@ def _card_generic(card_title:, middle:, extra: "")
|
|
834
895
|
end
|
835
896
|
|
836
897
|
def _var(name) # FIXME scope issue!
|
898
|
+
log!(enter: __method__)
|
837
899
|
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
838
900
|
end
|
839
901
|
|
840
902
|
def _main(url)
|
903
|
+
log!(enter: __method__)
|
841
904
|
%[href="javascript: void(0)" onclick="javascript:open_main('#{url}')"]
|
842
905
|
end
|
843
906
|
|
844
907
|
def _blank(url)
|
908
|
+
log!(enter: __method__)
|
845
909
|
%[href='#{url}' target='blank']
|
846
910
|
end
|
847
911
|
|