runeblog 0.2.43 → 0.2.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +8 -10
- data/empty_view/assets/austin-pano.jpg +0 -0
- data/empty_view/themes/standard/blog/generate.lt3 +5 -3
- data/empty_view/themes/standard/blog/post_entry.lt3 +14 -10
- data/empty_view/themes/standard/etc/blog.css.lt3 +18 -0
- data/empty_view/themes/standard/navbar/faq.lt3 +1 -0
- data/empty_view/themes/standard/navbar/navbar.lt3 +1 -0
- data/empty_view/themes/standard/widgets/ad/ad.lt3 +8 -1
- data/empty_view/themes/standard/widgets/ad/ad1.png +0 -0
- data/empty_view/themes/standard/widgets/ad/ad2.png +0 -0
- data/empty_view/themes/standard/widgets/ad/ad3.png +0 -0
- data/empty_view/themes/standard/widgets/ad/ad4.png +0 -0
- data/empty_view/themes/standard/widgets/bydates/bydates.rb +7 -3
- data/empty_view/themes/standard/widgets/links/links.rb +28 -3
- data/empty_view/themes/standard/widgets/news/news.rb +7 -3
- data/empty_view/themes/standard/widgets/pages/pages.rb +10 -3
- data/empty_view/themes/standard/widgets/pinned/pinned.rb +7 -3
- data/empty_view/themes/standard/widgets/search/search.rb +7 -3
- data/empty_view/themes/standard/widgets/sitemap/sitemap.rb +7 -3
- data/empty_view/themes/standard/widgets/tag-cloud/tag-cloud.rb +7 -3
- data/lib/default.rb +1 -1
- data/lib/global.rb +15 -40
- data/lib/helpers-blog.rb +15 -44
- data/lib/liveblog.rb +86 -62
- data/lib/logging.rb +17 -8
- data/lib/post.rb +24 -20
- data/lib/publish.rb +4 -5
- data/lib/repl.rb +52 -11
- data/lib/runeblog.rb +115 -93
- data/lib/runeblog_version.rb +1 -1
- data/lib/view.rb +2 -9
- data/lib/xlate.rb +34 -33
- data/test/austin.rb +31 -20
- metadata +8 -5
- data/empty_view/remote/widgets/links/list.data +0 -3
- data/empty_view/remote/widgets/news/list.data +0 -4
- data/empty_view/remote/widgets/pages/list.data +0 -4
data/lib/helpers-blog.rb
CHANGED
@@ -6,37 +6,21 @@ require 'xlate'
|
|
6
6
|
module RuneBlog::Helpers
|
7
7
|
|
8
8
|
def copy(src, dst)
|
9
|
-
log!(enter: __method__, args: [src, dst])
|
9
|
+
log!(enter: __method__, args: [src, dst], level: 2)
|
10
10
|
cmd = "cp #{src} #{dst} 2>/dev/null"
|
11
11
|
rc = system!(cmd)
|
12
12
|
puts " Failed: #{cmd} - from #{caller[0]}" unless rc
|
13
13
|
end
|
14
14
|
|
15
15
|
def copy!(src, dst)
|
16
|
-
log!(enter: __method__, args: [src, dst])
|
16
|
+
log!(enter: __method__, args: [src, dst], level: 2)
|
17
17
|
cmd = "cp -r #{src} #{dst} 2>/dev/null"
|
18
18
|
rc = system!(cmd)
|
19
19
|
puts " Failed: #{cmd} - from #{caller[0]}" unless rc
|
20
20
|
end
|
21
21
|
|
22
|
-
# def get_root
|
23
|
-
# log!(enter: __method__)
|
24
|
-
# if $_blog
|
25
|
-
# if $_blog.root
|
26
|
-
# puts "0. Returned: #{$_blog.root}/"
|
27
|
-
# return $_blog.root + "/"
|
28
|
-
# else
|
29
|
-
# puts "1. Returned: ./"
|
30
|
-
# return "./"
|
31
|
-
# end
|
32
|
-
# else
|
33
|
-
# puts "2. Returned: ./"
|
34
|
-
# return "./"
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
|
38
22
|
def read_config(file, *syms)
|
39
|
-
log!(enter: __method__, args: [file, *syms])
|
23
|
+
log!(enter: __method__, args: [file, *syms], level: 3)
|
40
24
|
lines = File.readlines(file).map(&:chomp)
|
41
25
|
obj = ::OpenStruct.new
|
42
26
|
lines.each do |line|
|
@@ -61,26 +45,14 @@ module RuneBlog::Helpers
|
|
61
45
|
end
|
62
46
|
|
63
47
|
def try_read_config(file, hash)
|
64
|
-
log!(enter: __method__, args: [file, hash])
|
48
|
+
log!(enter: __method__, args: [file, hash], level: 3)
|
65
49
|
return hash.values unless File.exist?(file)
|
66
50
|
vals = read_config(file, *hash.keys)
|
67
51
|
vals
|
68
52
|
end
|
69
53
|
|
70
|
-
# def put_config(root:, view:"test_view", editor: "/usr/local/bin/vim")
|
71
|
-
# log!(enter: __method__, args: [root, view, editor])
|
72
|
-
# Dir.mkdir(root) unless Dir.exist?(root)
|
73
|
-
# Dir.chdir(root) do
|
74
|
-
# File.open("config", "w") do |cfg|
|
75
|
-
# cfg.puts "root: #{root}"
|
76
|
-
# cfg.puts "current_view: #{view}"
|
77
|
-
# cfg.puts "editor: #{editor}"
|
78
|
-
# end
|
79
|
-
# end
|
80
|
-
# end
|
81
|
-
|
82
54
|
def write_config(obj, file)
|
83
|
-
log!(enter: __method__, args: [obj, file])
|
55
|
+
log!(enter: __method__, args: [obj, file], level: 2)
|
84
56
|
hash = obj.to_h
|
85
57
|
File.open(file, "w") do |out|
|
86
58
|
hash.each_pair {|key, val| out.puts "#{key}: #{val}" }
|
@@ -88,13 +60,13 @@ module RuneBlog::Helpers
|
|
88
60
|
end
|
89
61
|
|
90
62
|
def get_views # read from filesystem
|
91
|
-
log!(enter: __method__)
|
63
|
+
log!(enter: __method__, level: 3)
|
92
64
|
dirs = subdirs("#@root/views/").sort
|
93
65
|
dirs.map {|name| RuneBlog::View.new(name) }
|
94
66
|
end
|
95
67
|
|
96
68
|
def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
|
97
|
-
log!(enter: __method__, args: [root, current_view, editor])
|
69
|
+
log!(enter: __method__, args: [root, current_view, editor], level: 3)
|
98
70
|
root = Dir.pwd/root
|
99
71
|
x = OpenStruct.new
|
100
72
|
x.root, x.current_view, x.editor = root, current_view, editor
|
@@ -102,21 +74,21 @@ module RuneBlog::Helpers
|
|
102
74
|
end
|
103
75
|
|
104
76
|
def new_sequence
|
105
|
-
log!(enter: __method__)
|
77
|
+
log!(enter: __method__, level: 3)
|
106
78
|
dump(0, "sequence")
|
107
79
|
version_info = "#{RuneBlog::VERSION}\nBlog created: #{Time.now.to_s}"
|
108
80
|
dump(version_info, "VERSION")
|
109
81
|
end
|
110
82
|
|
111
83
|
def subdirs(dir)
|
112
|
-
log!(enter: __method__, args: [dir])
|
84
|
+
log!(enter: __method__, args: [dir], level: 3)
|
113
85
|
dirs = Dir.entries(dir) - %w[. ..]
|
114
86
|
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
115
87
|
dirs
|
116
88
|
end
|
117
89
|
|
118
90
|
def find_draft_slugs
|
119
|
-
log!(enter: __method__)
|
91
|
+
log!(enter: __method__, level: 3)
|
120
92
|
files = Dir["#@root/drafts/**"].grep /\d{4}.*.lt3$/
|
121
93
|
flagfile = "#@root/drafts/last_rebuild"
|
122
94
|
last = File.exist?(flagfile) ? File.mtime(flagfile) : (Time.now - 86_400)
|
@@ -128,7 +100,7 @@ module RuneBlog::Helpers
|
|
128
100
|
end
|
129
101
|
|
130
102
|
def create_dirs(*dirs)
|
131
|
-
log!(enter: __method__, args: [*dirs])
|
103
|
+
log!(enter: __method__, args: [*dirs], level: 3)
|
132
104
|
dirs.each do |dir|
|
133
105
|
dir = dir.to_s # symbols allowed
|
134
106
|
next if Dir.exist?(dir)
|
@@ -139,27 +111,26 @@ module RuneBlog::Helpers
|
|
139
111
|
end
|
140
112
|
|
141
113
|
def interpolate(str, bind)
|
142
|
-
log!(enter: __method__, args: [str, bind])
|
114
|
+
log!(enter: __method__, args: [str, bind], level: 3)
|
143
115
|
wrap = "<<-EOS\n#{str}\nEOS"
|
144
116
|
eval wrap, bind
|
145
117
|
end
|
146
118
|
|
147
119
|
def error(err) # Hmm, this is duplicated
|
148
|
-
log!(str: "duplicated method", enter: __method__, args: [err])
|
120
|
+
log!(str: "duplicated method", enter: __method__, args: [err], level: 2)
|
149
121
|
str = "\n Error: #{err}"
|
150
122
|
puts str
|
151
123
|
puts err.backtrace.join("\n")
|
152
124
|
end
|
153
125
|
|
154
126
|
def dump(obj, name)
|
155
|
-
log!(enter: __method__, args: [obj, name])
|
127
|
+
log!(enter: __method__, args: [obj, name], level: 3)
|
156
128
|
File.write(name, obj)
|
157
129
|
end
|
158
|
-
|
159
130
|
end
|
160
131
|
|
161
132
|
def dump(obj, name) # FIXME scope
|
162
|
-
log!(str: "scope problem", enter: __method__, args: [obj, name])
|
133
|
+
log!(str: "scope problem", enter: __method__, args: [obj, name], level: 3)
|
163
134
|
File.write(name, obj)
|
164
135
|
end
|
165
136
|
|
data/lib/liveblog.rb
CHANGED
@@ -17,7 +17,7 @@ def init_liveblog # FIXME - a lot of this logic sucks
|
|
17
17
|
@blog = RuneBlog.new(dir)
|
18
18
|
@root = @blog.root
|
19
19
|
@view = @blog.view
|
20
|
-
@view_name = @blog.view.name
|
20
|
+
@view_name = @blog.view.name unless @view.nil?
|
21
21
|
@vdir = @blog.view.dir
|
22
22
|
@version = RuneBlog::VERSION
|
23
23
|
@theme = @vdir/:themes/:standard
|
@@ -27,6 +27,18 @@ end
|
|
27
27
|
# "dot" commands
|
28
28
|
##################
|
29
29
|
|
30
|
+
|
31
|
+
|
32
|
+
def dropcap
|
33
|
+
# Bad form: adds another HEAD
|
34
|
+
text = _data
|
35
|
+
_out " "
|
36
|
+
letter = text[0]
|
37
|
+
remain = text[1..-1]
|
38
|
+
_out %[<div class='mydrop'>#{letter}</div>]
|
39
|
+
_out %[<div style="padding-top: 1px">#{remain}]
|
40
|
+
end
|
41
|
+
|
30
42
|
def post
|
31
43
|
@meta = OpenStruct.new
|
32
44
|
@meta.num = _args[0]
|
@@ -56,30 +68,9 @@ def backlink
|
|
56
68
|
_out %[<br><a href="javascript:history.go(-1)">[Back]</a>]
|
57
69
|
end
|
58
70
|
|
59
|
-
def dropcap
|
60
|
-
# Bad form: adds another HEAD
|
61
|
-
_out <<-HTML
|
62
|
-
<head>
|
63
|
-
<style>
|
64
|
-
p:first-child:first-letter {
|
65
|
-
color: #0000ff;
|
66
|
-
float: left;
|
67
|
-
font-family: Verdana;
|
68
|
-
font-size: 75px;
|
69
|
-
line-height: 60px;
|
70
|
-
padding-top: 4px;
|
71
|
-
padding-right: 8px;
|
72
|
-
padding-left: 3px;
|
73
|
-
}
|
74
|
-
</style>
|
75
|
-
</head>
|
76
|
-
HTML
|
77
|
-
_out " "
|
78
|
-
end
|
79
|
-
|
80
71
|
def quote
|
81
72
|
_passthru "<blockquote>"
|
82
|
-
_passthru _body
|
73
|
+
_passthru _body.join(" ")
|
83
74
|
_passthru "</blockquote>"
|
84
75
|
_optional_blank_line
|
85
76
|
end
|
@@ -128,17 +119,17 @@ end
|
|
128
119
|
|
129
120
|
|
130
121
|
def make_main_links
|
131
|
-
log!(enter: __method__)
|
122
|
+
log!(enter: __method__, level: 1)
|
132
123
|
# FIXME remember strings may not be safe
|
133
124
|
line = _data.chomp
|
134
125
|
tag, card_title = *line.split(" ", 2)
|
135
126
|
cardfile, mainfile = "#{tag}-card", "#{tag}-main"
|
136
127
|
input = "list.data"
|
137
|
-
log!(str: "Reading #{input}", pwd: true)
|
128
|
+
log!(str: "Reading #{input}", pwd: true, level: 3)
|
138
129
|
pairs = File.readlines(input).map {|line| line.chomp.split(/, */, 2) }
|
139
130
|
_write_main(mainfile, pairs, card_title, tag)
|
140
131
|
_write_card(cardfile, mainfile, pairs, card_title, tag)
|
141
|
-
log!(str: "...returning from method", pwd: true)
|
132
|
+
log!(str: "...returning from method", pwd: true, level: 3)
|
142
133
|
end
|
143
134
|
|
144
135
|
### inset
|
@@ -146,25 +137,36 @@ end
|
|
146
137
|
def inset
|
147
138
|
lines = _body
|
148
139
|
box = ""
|
140
|
+
output = []
|
149
141
|
lines.each do |line|
|
150
|
-
line = line
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
142
|
+
line = line
|
143
|
+
case line[0]
|
144
|
+
when "/" # Only into inset
|
145
|
+
line[0] = ' '
|
146
|
+
box << line
|
147
|
+
line.replace(" ")
|
148
|
+
when "|" # Into inset and body
|
149
|
+
line[0] = ' '
|
150
|
+
box << line
|
151
|
+
output << line
|
152
|
+
else # Only into body
|
153
|
+
output << line
|
159
154
|
end
|
160
|
-
|
155
|
+
# _passthru(line)
|
161
156
|
end
|
162
157
|
lr = _args.first
|
163
158
|
wide = _args[1] || "25"
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
159
|
+
stuff = "<div style='float:#{lr}; width: #{wide}%; padding:8px; padding-right:12px'>"
|
160
|
+
stuff << '<b><i>' + box + '</i></b></div>'
|
161
|
+
_out "</p>" # kludge!! nopara
|
162
|
+
0.upto(2) {|i| _passthru output[i] }
|
163
|
+
_passthru stuff
|
164
|
+
# _passthru "<div style='float:#{lr}; width: #{wide}%; padding:8px; padding-right:12px'>" # ; font-family:verdana'>"
|
165
|
+
# _passthru '<b><i>'
|
166
|
+
# _passthru box
|
167
|
+
# _passthru_noline '</i></b></div>'
|
168
|
+
3.upto(output.length-1) {|i| _passthru output[i] }
|
169
|
+
_out "<p>" # kludge!! para
|
168
170
|
_optional_blank_line
|
169
171
|
end
|
170
172
|
|
@@ -232,10 +234,16 @@ end
|
|
232
234
|
|
233
235
|
def teaser
|
234
236
|
raise "'post' was not called" unless @meta
|
235
|
-
|
237
|
+
text = _body_text
|
238
|
+
@meta.teaser = text
|
236
239
|
setvar :teaser, @meta.teaser
|
237
|
-
|
238
|
-
|
240
|
+
if _args[0] == "dropcap" # FIXME doesn't work yet!
|
241
|
+
letter, remain = text[0], text[1..-1]
|
242
|
+
_out %[<div class='mydrop'>#{letter}</div>]
|
243
|
+
_out %[<div style="padding-top: 1px">#{remain}] + "\n"
|
244
|
+
else
|
245
|
+
_out @meta.teaser + "\n"
|
246
|
+
end
|
239
247
|
end
|
240
248
|
|
241
249
|
def finalize
|
@@ -356,8 +364,8 @@ def _load_local(widget)
|
|
356
364
|
code
|
357
365
|
end
|
358
366
|
rescue => err
|
359
|
-
|
360
|
-
|
367
|
+
STDERR.puts err.to_s
|
368
|
+
STDERR.puts err.backtrace.join("\n")
|
361
369
|
exit
|
362
370
|
end
|
363
371
|
|
@@ -375,16 +383,26 @@ def sidebar
|
|
375
383
|
tcard = "#{tag}-card.html"
|
376
384
|
|
377
385
|
code = _load_local(tag)
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
386
|
+
if code
|
387
|
+
if ["pages", "links"].include? tag
|
388
|
+
Dir.chdir(wtag) do
|
389
|
+
widget = code.new(@blog)
|
390
|
+
widget.build
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
if tag == "ad"
|
396
|
+
num = rand(1..4)
|
397
|
+
img = "widgets/ad/ad#{num}.png"
|
398
|
+
src, dst = img, @root/:views/@view_name/"remote/widgets/ad/"
|
399
|
+
system!("cp #{src} #{dst}") # , show: true)
|
400
|
+
File.open(wtag/"vars.lt3", "w") do |f|
|
401
|
+
f.puts ".set ad.image = #{img}"
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
xlate cwd: wtag, src: tag, dst: tcard # , debug: (tag == "ad")
|
388
406
|
_include_file wtag/tcard
|
389
407
|
end
|
390
408
|
_out %[</div>]
|
@@ -462,10 +480,16 @@ class Livetext::Functions
|
|
462
480
|
::Livetext::Vars[name] || "[:#{name} is undefined]"
|
463
481
|
end
|
464
482
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
483
|
+
# def link(param = nil)
|
484
|
+
# puts "--- WTF?? param = #{param.inspect}"; gets
|
485
|
+
# file, cdata = param.split("||", 2)
|
486
|
+
# %[<a href="assets/#{file}">#{cdata}</a>]
|
487
|
+
# end
|
488
|
+
#
|
489
|
+
# def link(param = nil)
|
490
|
+
# file, cdata = param.split("||", 2)
|
491
|
+
# %[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}#{file}" title="#{_var(:title)}">]
|
492
|
+
# end
|
469
493
|
end
|
470
494
|
|
471
495
|
###
|
@@ -593,7 +617,7 @@ def _html_body(file, css = nil)
|
|
593
617
|
end
|
594
618
|
|
595
619
|
def _write_card(cardfile, mainfile, pairs, card_title, tag)
|
596
|
-
log!(str: "Creating #{cardfile}.html", pwd: true)
|
620
|
+
log!(str: "Creating #{cardfile}.html", pwd: true, level: 2)
|
597
621
|
url = mainfile
|
598
622
|
url = :widgets/tag/mainfile + ".html"
|
599
623
|
File.open("#{cardfile}.html", "w") do |f|
|
@@ -608,7 +632,7 @@ def _write_card(cardfile, mainfile, pairs, card_title, tag)
|
|
608
632
|
</h5>
|
609
633
|
<div class="collapse" id="#{tag}">
|
610
634
|
EOS
|
611
|
-
log!(str: "Writing data pairs to #{cardfile}.html", pwd: true)
|
635
|
+
log!(str: "Writing data pairs to #{cardfile}.html", pwd: true, level: 2)
|
612
636
|
local = _local_tag?(tag)
|
613
637
|
pairs.each do |file, title|
|
614
638
|
url = file
|
@@ -681,7 +705,7 @@ def _write_main_pages(mainfile, pairs, card_title, tag)
|
|
681
705
|
end
|
682
706
|
|
683
707
|
def _write_main(mainfile, pairs, card_title, tag)
|
684
|
-
log!(str: "Creating #{mainfile}.html", pwd: true)
|
708
|
+
log!(str: "Creating #{mainfile}.html", pwd: true, level: 2)
|
685
709
|
|
686
710
|
if tag == "pages" # temporary experiment
|
687
711
|
_write_main_pages(mainfile, pairs, card_title, tag)
|
data/lib/logging.rb
CHANGED
@@ -2,8 +2,17 @@ unless self.respond_to?("log!")
|
|
2
2
|
$logging = true
|
3
3
|
$log = File.new("/tmp/runeblog.log","w")
|
4
4
|
|
5
|
-
def
|
5
|
+
def outlog(str = "", stderr: false)
|
6
|
+
$log.puts str
|
7
|
+
STDERR.puts str if stderr
|
8
|
+
end
|
9
|
+
|
10
|
+
def log!(str: "", enter: nil, args: [], pwd: false, dir: false, level: 0, stderr: false)
|
6
11
|
return unless $logging
|
12
|
+
@err_level ||= ENV['RUNEBLOG_ERROR_LEVEL']
|
13
|
+
@err_level ||= 0
|
14
|
+
return if level < @err_level
|
15
|
+
|
7
16
|
time = Time.now.strftime("%H:%M:%S")
|
8
17
|
|
9
18
|
meth = ""
|
@@ -17,16 +26,16 @@ unless self.respond_to?("log!")
|
|
17
26
|
str = " ... #{str}" unless str.empty?
|
18
27
|
indent = " "*12
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
outlog "#{time} #{meth}#{para}"
|
30
|
+
outlog "#{indent} #{str} " unless str.empty?
|
31
|
+
outlog "#{indent} #{source}"
|
32
|
+
outlog "#{indent} pwd = #{Dir.pwd} " if pwd
|
24
33
|
if dir
|
25
34
|
files = (Dir.entries('.') - %w[. ..]).join(" ")
|
26
|
-
|
35
|
+
outlog "#{indent} dir/* = #{files}"
|
27
36
|
end
|
28
|
-
#
|
29
|
-
|
37
|
+
# outlog "#{indent} livetext params = #{livedata.inpect} " unless livedata.nil?
|
38
|
+
outlog
|
30
39
|
$log.close
|
31
40
|
$log = File.new("/tmp/runeblog.log","a")
|
32
41
|
end
|
data/lib/post.rb
CHANGED
@@ -10,19 +10,18 @@ class RuneBlog::Post
|
|
10
10
|
include RuneBlog::Helpers
|
11
11
|
|
12
12
|
def self.files(num, root)
|
13
|
-
log!(enter: __method__, args: [num, root])
|
14
|
-
files = Find.find(root).to_a
|
13
|
+
log!(enter: __method__, args: [num, root], level: 3)
|
14
|
+
files = ::Find.find(root).to_a
|
15
15
|
result = files.grep(/#{prefix(num)}-/)
|
16
16
|
result
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.load(post)
|
20
|
-
log!(enter: __method__, args: [post])
|
20
|
+
log!(enter: __method__, args: [post], level: 3)
|
21
21
|
raise "Doesn't work right now"
|
22
22
|
raise NoBlogAccessor if RuneBlog.blog.nil?
|
23
23
|
# "post" is a slug
|
24
24
|
pdir = RuneBlog.blog.view.dir/post
|
25
|
-
verify(Dir.exist?(pdir) => "Directory #{pdir} not found")
|
26
25
|
meta = nil
|
27
26
|
Dir.chdir(pdir) do
|
28
27
|
meta = read_config("metadata.txt")
|
@@ -36,7 +35,7 @@ class RuneBlog::Post
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def write_metadata(meta) # FIXME ???
|
39
|
-
log!(enter: __method__, args: [meta])
|
38
|
+
log!(enter: __method__, args: [meta], level: 3)
|
40
39
|
debug "=== write_metadata:"
|
41
40
|
debug "-----\n#{meta.inspect}\n-----"
|
42
41
|
fname2 = "metadata.txt"
|
@@ -57,14 +56,14 @@ class RuneBlog::Post
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def initialize
|
60
|
-
log!(enter: __method__)
|
59
|
+
log!(enter: __method__, level: 3)
|
61
60
|
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
62
61
|
@meta = OpenStruct.new
|
63
62
|
end
|
64
63
|
|
65
64
|
def self.create(title:, teaser:, body:, pubdate: Time.now.strftime("%Y-%m-%d"),
|
66
|
-
views:[])
|
67
|
-
log!(enter: __method__, args: [title, teaser, body, pubdate, views])
|
65
|
+
views:[], file: nil)
|
66
|
+
log!(enter: __method__, args: [title, teaser, body, pubdate, views], stderr: true)
|
68
67
|
post = self.new
|
69
68
|
# NOTE: This is the ONLY place next_sequence is called!
|
70
69
|
num = post.meta.num = post.blog.next_sequence
|
@@ -73,27 +72,29 @@ class RuneBlog::Post
|
|
73
72
|
post.meta.title, post.meta.teaser, post.meta.body, post.meta.pubdate =
|
74
73
|
title, teaser, body, pubdate
|
75
74
|
post.meta.views = [post.blog.view.to_s] + views
|
76
|
-
# STDERR.puts "Post.create: views = #{views.inspect}"
|
77
75
|
post.meta.tags = []
|
78
76
|
post.blog.make_slug(post.meta) # adds to meta
|
79
77
|
|
80
78
|
# create_draft
|
81
79
|
viewhome = post.blog.view.publisher.url
|
82
80
|
meta = post.meta
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
if file.nil?
|
82
|
+
text = RuneBlog.post_template(num: meta.num, title: meta.title, date: meta.pubdate,
|
83
|
+
view: meta.view, teaser: meta.teaser, body: meta.body,
|
84
|
+
views: meta.views, tags: meta.tags, home: viewhome)
|
85
|
+
srcdir = post.blog.root/:drafts + "/"
|
86
|
+
vpdir = post.blog.root/:drafts + "/"
|
87
|
+
fname = meta.slug + ".lt3"
|
88
|
+
post.draft = srcdir + fname
|
89
|
+
dump(text, post.draft)
|
90
|
+
else
|
91
|
+
dump(File.read(file), post.draft)
|
92
|
+
end
|
91
93
|
return post
|
92
94
|
end
|
93
95
|
|
94
96
|
def edit
|
95
97
|
log!(enter: __method__)
|
96
|
-
verify(File.exist?(@draft) => "File #{@draft} not found")
|
97
98
|
result = system!("vi #@draft +8") # TODO improve this
|
98
99
|
raise EditorProblem(draft) unless result
|
99
100
|
nil
|
@@ -115,7 +116,7 @@ class RuneBlog::ViewPost
|
|
115
116
|
:teaser_text
|
116
117
|
|
117
118
|
def initialize(view, postdir)
|
118
|
-
log!(enter: __method__, args: [view, postdir])
|
119
|
+
log!(enter: __method__, args: [view, postdir], level: 3)
|
119
120
|
# Assumes already parsed/processed
|
120
121
|
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
121
122
|
@path = postdir.dup
|
@@ -128,10 +129,13 @@ class RuneBlog::ViewPost
|
|
128
129
|
lines = File.readlines(mdfile)
|
129
130
|
@title = lines.grep(/title:/).first[7..-1].chomp
|
130
131
|
@date = lines.grep(/pubdate:/).first[9..-1].chomp
|
132
|
+
# print "-- date = #{@date.inspect} "; gets
|
133
|
+
rescue => err
|
134
|
+
STDERR.puts "--- #{err}\n #{err.backtrace.join("\n ")}"
|
131
135
|
end
|
132
136
|
|
133
137
|
def get_dirs
|
134
|
-
log!(enter: __method__, args: [view, postdir])
|
138
|
+
log!(enter: __method__, args: [view, postdir], level: 3)
|
135
139
|
fname = File.basename(draft)
|
136
140
|
noext = fname.sub(/.lt3$/, "")
|
137
141
|
vdir = @root/:views/view
|