runeblog 0.3.22 → 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/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 +80 -17
- data/lib/lowlevel.rb +23 -7
- data/lib/menus.rb +2 -1
- data/lib/newpost.rb +35 -26
- data/lib/post.rb +3 -2
- data/lib/processing.rb +22 -1
- data/lib/publish.rb +3 -1
- data/lib/repl.rb +41 -17
- data/lib/runeblog.rb +88 -47
- data/lib/runeblog_version.rb +1 -1
- data/lib/view.rb +22 -3
- data/runeblog.gemspec +1 -1
- metadata +8 -7
data/lib/lowlevel.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
|
2
2
|
def _tmp_error(err)
|
3
|
+
STDERR.puts err
|
4
|
+
STDERR.puts err.backtrace.join("\n") if err.respond_to?(:backtrace)
|
5
|
+
log!(str: "#{err} - see also stderr.out")
|
6
|
+
return
|
7
|
+
|
3
8
|
out = "/tmp/blog#{rand(100)}.txt"
|
4
9
|
File.open(out, "w") do |f|
|
5
10
|
f.puts err.to_s + "\n--------"
|
6
11
|
f.puts err.backtrace.join("\n")
|
7
12
|
end
|
8
13
|
puts "Error: See #{out}"
|
14
|
+
# sleep 3
|
9
15
|
end
|
10
16
|
|
11
17
|
def dump(obj, name)
|
@@ -20,6 +26,7 @@
|
|
20
26
|
log!(enter: __method__, args: [str], level: 2)
|
21
27
|
STDERR.puts str if show
|
22
28
|
rc = system(str)
|
29
|
+
STDERR.puts " rc = #{rc.inspect}" if show
|
23
30
|
return rc if rc
|
24
31
|
STDERR.puts "FAILED: #{str.inspect}"
|
25
32
|
STDERR.puts "\ncaller = \n#{caller.join("\n ")}\n"
|
@@ -32,10 +39,12 @@
|
|
32
39
|
end
|
33
40
|
|
34
41
|
def _get_data?(file) # File need not exist
|
42
|
+
log!(enter: __method__, args: [file], level: 2)
|
35
43
|
File.exist?(file) ? _get_data(file) : []
|
36
44
|
end
|
37
45
|
|
38
46
|
def _get_data(file)
|
47
|
+
log!(enter: __method__, args: [file], level: 2)
|
39
48
|
lines = File.readlines(file)
|
40
49
|
lines = lines.map do |line|
|
41
50
|
line = line.chomp.strip
|
@@ -46,6 +55,7 @@
|
|
46
55
|
end
|
47
56
|
|
48
57
|
def read_pairs(file) # returns a hash
|
58
|
+
log!(enter: __method__, args: [file], level: 2)
|
49
59
|
lines = _get_data(file)
|
50
60
|
hash = {}
|
51
61
|
lines.each do |line|
|
@@ -57,6 +67,7 @@
|
|
57
67
|
end
|
58
68
|
|
59
69
|
def read_pairs!(file) # returns an openstruct
|
70
|
+
log!(enter: __method__, args: [file], level: 2)
|
60
71
|
lines = _get_data(file)
|
61
72
|
obj = OpenStruct.new
|
62
73
|
lines.each do |line|
|
@@ -97,27 +108,32 @@
|
|
97
108
|
end
|
98
109
|
|
99
110
|
def error(err)
|
100
|
-
|
101
|
-
str = "\n Error
|
111
|
+
log!(str: err, enter: __method__, args: [err], level: 2)
|
112
|
+
str = "\n Error... #{err}"
|
102
113
|
puts str
|
103
114
|
puts err.backtrace.join("\n")
|
104
115
|
end
|
105
116
|
|
106
117
|
def find_item(list)
|
118
|
+
log!(enter: __method__, args: [list], level: 2)
|
107
119
|
list2 = list.select(&block)
|
108
|
-
exactly_one(list2)
|
120
|
+
exactly_one(list2, list.join("/"))
|
109
121
|
end
|
110
122
|
|
111
123
|
def find_item!(list, &block)
|
124
|
+
log!(enter: __method__, args: [list], level: 2)
|
125
|
+
list2 = list.select(&block)
|
112
126
|
list2 = list.select(&block)
|
113
|
-
item = exactly_one(list2)
|
127
|
+
item = exactly_one(list2, list.join("/"))
|
114
128
|
n = list.index(&block)
|
115
129
|
[n, item]
|
116
130
|
end
|
117
131
|
|
118
|
-
def exactly_one(list)
|
119
|
-
|
120
|
-
|
132
|
+
def exactly_one(list, tag = nil)
|
133
|
+
log!(enter: __method__, args: [list], level: 2)
|
134
|
+
list2 = list.select(&block)
|
135
|
+
raise "List: Zero instances #{"- #{tag}" if tag}" if list.empty?
|
136
|
+
raise "List: More than one instance #{"- #{tag}" if tag}" if list.size > 1
|
121
137
|
list.first
|
122
138
|
end
|
123
139
|
|
data/lib/menus.rb
CHANGED
@@ -18,9 +18,10 @@ top_help = proc { RubyText.splash(RuneBlog::REPL::Help.gsub(/[{}]/, " ")) }
|
|
18
18
|
# dir = @blog.view.dir/"themes/standard/"
|
19
19
|
|
20
20
|
std = "themes/standard"
|
21
|
+
data = "." # CHANGED
|
21
22
|
|
22
23
|
Menu.top_config = {
|
23
|
-
"Variables (general)" => edit("#{
|
24
|
+
"Variables (general)" => edit("#{data}/global.lt3"),
|
24
25
|
" View-specific" => edit("settings/view.txt"),
|
25
26
|
" Recent posts" => edit("settings/recent.txt"),
|
26
27
|
" Publishing" => edit("settings/publish.txt"),
|
data/lib/newpost.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rubytext'
|
|
2
2
|
|
3
3
|
RubyText.start
|
4
4
|
|
5
|
-
#
|
5
|
+
# Idea: A special sub-environment for creating a post
|
6
6
|
#
|
7
7
|
# 1. Display: view, post number, date
|
8
8
|
# 2. Menu?
|
@@ -15,44 +15,43 @@ RubyText.start
|
|
15
15
|
# 9. - Quit
|
16
16
|
# Edit body after save/quit
|
17
17
|
|
18
|
+
def ask(prompt) # elsewhere?
|
19
|
+
print prompt
|
20
|
+
str = gets
|
21
|
+
str.chomp! if str
|
22
|
+
str
|
23
|
+
end
|
24
|
+
|
18
25
|
def enter_title
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@win.home
|
23
|
-
str = @win.gets
|
24
|
-
STDSCR.puts str.inspect
|
25
|
-
[__method__, 0]
|
26
|
+
puts __method__
|
27
|
+
str = ask("Title: ")
|
28
|
+
puts str.inspect
|
26
29
|
end
|
27
30
|
|
28
31
|
def edit_teaser
|
29
|
-
|
30
|
-
|
32
|
+
puts __method__
|
33
|
+
str = ask("Teaser: ")
|
34
|
+
puts str.inspect
|
31
35
|
end
|
32
36
|
|
33
37
|
def add_views
|
34
|
-
|
35
|
-
[__method__, 2]
|
38
|
+
puts __method__
|
36
39
|
end
|
37
40
|
|
38
41
|
def add_tags
|
39
|
-
|
40
|
-
[__method__, 3]
|
42
|
+
puts __method__
|
41
43
|
end
|
42
44
|
|
43
45
|
def import_assets
|
44
|
-
|
45
|
-
[__method__, 4]
|
46
|
+
puts __method__
|
46
47
|
end
|
47
48
|
|
48
49
|
def save_post
|
49
|
-
|
50
|
-
[__method__, 5]
|
50
|
+
puts __method__
|
51
51
|
end
|
52
52
|
|
53
53
|
def quit_post
|
54
|
-
|
55
|
-
[__method__, 6]
|
54
|
+
puts __method__
|
56
55
|
end
|
57
56
|
|
58
57
|
items = {
|
@@ -65,9 +64,19 @@ items = {
|
|
65
64
|
"Quit" => proc { quit_post }
|
66
65
|
}
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
enter_title
|
68
|
+
edit_teaser
|
69
|
+
add_views
|
70
|
+
add_tags
|
71
|
+
import_assets
|
72
|
+
save_post
|
73
|
+
quit_post
|
74
|
+
|
75
|
+
# getch
|
76
|
+
|
77
|
+
# curr = 0
|
78
|
+
# loop do
|
79
|
+
# str, curr = menu(c: 10, items: items, curr: curr, sticky: true)
|
80
|
+
# break if curr.nil?
|
81
|
+
# puts "str = #{str} curr = #{curr}"
|
82
|
+
# end
|
data/lib/post.rb
CHANGED
@@ -66,7 +66,7 @@ class RuneBlog::Post
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def edit
|
69
|
-
|
69
|
+
log!(enter: __method__)
|
70
70
|
edit_file(@draft, vim: "+8")
|
71
71
|
build
|
72
72
|
rescue => err
|
@@ -169,7 +169,8 @@ class RuneBlog::ViewPost
|
|
169
169
|
@date = meta.pubdate
|
170
170
|
end
|
171
171
|
rescue => err
|
172
|
-
STDERR.puts "--- #{err}
|
172
|
+
STDERR.puts "--- #{err}"
|
173
|
+
STDERR.puts " #{err.backtrace.join("\n ")}" if err.respond_to?(:backtrace)
|
173
174
|
end
|
174
175
|
|
175
176
|
def get_dirs
|
data/lib/processing.rb
CHANGED
@@ -23,7 +23,8 @@ end
|
|
23
23
|
def preprocess(cwd: Dir.pwd, src:,
|
24
24
|
dst: nil, strip: false,
|
25
25
|
deps: [], copy: nil, debug: false, force: false,
|
26
|
-
mix: [], call: [],
|
26
|
+
mix: [], call: [],
|
27
|
+
vars: {})
|
27
28
|
src += LEXT unless src.end_with?(LEXT)
|
28
29
|
if strip
|
29
30
|
dst = File.basename(src).sub(/.lt3$/,"")
|
@@ -31,6 +32,10 @@ def preprocess(cwd: Dir.pwd, src:,
|
|
31
32
|
dst += ".html" unless dst.end_with?(".html")
|
32
33
|
end
|
33
34
|
sp = " "*12
|
35
|
+
# STDERR.puts "=== ls -l #{cwd} = "
|
36
|
+
# STDERR.puts `ls -l #{cwd}`
|
37
|
+
# STDERR.puts "=== going into #{cwd}"
|
38
|
+
|
34
39
|
Dir.chdir(cwd) do
|
35
40
|
if debug
|
36
41
|
STDERR.puts "#{sp} -- preprocess "
|
@@ -44,6 +49,20 @@ def preprocess(cwd: Dir.pwd, src:,
|
|
44
49
|
stale = stale?(src, dst, deps, force)
|
45
50
|
if stale
|
46
51
|
live = Livetext.customize(mix: "liveblog", call: call, vars: vars)
|
52
|
+
STDERR.puts <<~EOF
|
53
|
+
cwd = #{cwd.inspect}
|
54
|
+
src = #{src.inspect}
|
55
|
+
dst = #{dst.inspect}
|
56
|
+
strip = #{strip.inspect}
|
57
|
+
deps = #{deps.inspect}
|
58
|
+
copy = #{copy.inspect}
|
59
|
+
debug = #{debug.inspect}
|
60
|
+
force = #{force.inspect}
|
61
|
+
mix = #{mix.inspect}
|
62
|
+
call = #{call.inspect}
|
63
|
+
vars = #{vars.inspect}
|
64
|
+
EOF
|
65
|
+
log!(str: "Calling xform_file... src = #{src} pwd = #{Dir.pwd}")
|
47
66
|
out = live.xform_file(src)
|
48
67
|
File.write(dst, out)
|
49
68
|
system!("cp #{dst} #{copy}") if copy
|
@@ -54,6 +73,8 @@ end
|
|
54
73
|
|
55
74
|
def get_live_vars(src)
|
56
75
|
live = Livetext.customize(call: [".nopara"])
|
76
|
+
# puts "glv: src = #{src.inspect}"
|
77
|
+
# STDERR.puts "glv: src = #{src.inspect}"
|
57
78
|
live.xform_file(src)
|
58
79
|
live
|
59
80
|
end
|
data/lib/publish.rb
CHANGED
@@ -14,7 +14,9 @@ class RuneBlog::Publishing
|
|
14
14
|
def initialize(view)
|
15
15
|
log!(enter: __method__, args: [view.to_s])
|
16
16
|
@blog = RuneBlog.blog
|
17
|
-
|
17
|
+
dir0 = @blog.root/:views/view/"themes/standard/"
|
18
|
+
# CHANGED
|
19
|
+
dir = @blog.root/:views/view/:data
|
18
20
|
gfile = dir/"global.lt3"
|
19
21
|
return unless File.exist?(gfile) # FIXME Hackish as hell
|
20
22
|
|
data/lib/repl.rb
CHANGED
@@ -206,14 +206,14 @@ module RuneBlog::REPL
|
|
206
206
|
|
207
207
|
def regen_posts
|
208
208
|
drafts = @blog.drafts # current view
|
209
|
-
|
209
|
+
log! str: "=== Regenerating posts..." unless drafts.empty?
|
210
210
|
drafts.each do |draft|
|
211
211
|
orig = @blog.root/:drafts/draft
|
212
212
|
postdir = @blog.root/:posts/draft.sub(/.lt3$/, "")
|
213
213
|
content = postdir/"/guts.html"
|
214
214
|
next if fresh?(orig, content)
|
215
215
|
|
216
|
-
|
216
|
+
log! str: "=== Calling generate_post(#{orig})"
|
217
217
|
@blog.generate_post(orig) # rebuild post
|
218
218
|
Dir.chdir(postdir) do
|
219
219
|
meta = @blog.read_metadata
|
@@ -225,14 +225,14 @@ module RuneBlog::REPL
|
|
225
225
|
end
|
226
226
|
|
227
227
|
def cmd_rebuild
|
228
|
-
|
228
|
+
log! str: "=== Starting cmd_rebuild..."
|
229
229
|
puts
|
230
230
|
regen_posts
|
231
|
-
|
231
|
+
log! str: "=== Generating view..."
|
232
232
|
@blog.generate_view(@blog.view)
|
233
|
-
|
233
|
+
log! str: "=== Generating index..."
|
234
234
|
@blog.generate_index(@blog.view)
|
235
|
-
|
235
|
+
log! str: "=== ...finished!"
|
236
236
|
rescue => err
|
237
237
|
_tmp_error(err)
|
238
238
|
end
|
@@ -250,6 +250,7 @@ module RuneBlog::REPL
|
|
250
250
|
name = @blog.view.name
|
251
251
|
k, name = STDSCR.menu(title: "Views", items: viewnames, curr: n)
|
252
252
|
return if name.nil?
|
253
|
+
log! str: "cv Setting to #{name.inspect}"
|
253
254
|
@blog.view = name
|
254
255
|
# puts "\n ", fx(name, :bold), "\n"
|
255
256
|
return
|
@@ -261,19 +262,40 @@ module RuneBlog::REPL
|
|
261
262
|
end
|
262
263
|
end
|
263
264
|
|
265
|
+
# move to helpers
|
266
|
+
def modify_view_global(view_name)
|
267
|
+
gfile = "#{@blog.root}/views/#{view_name}/data/global.lt3"
|
268
|
+
lines = File.readlines(gfile).map(&:chomp)
|
269
|
+
vars = <<~EOF
|
270
|
+
.variables
|
271
|
+
View #{view_name}
|
272
|
+
ViewDir #{@blog.root}/views/#{view_name}
|
273
|
+
.end
|
274
|
+
|
275
|
+
EOF
|
276
|
+
# lines.insert(5, vars)
|
277
|
+
text = lines.join("\n")
|
278
|
+
File.write(gfile, text)
|
279
|
+
end
|
280
|
+
|
281
|
+
def modify_view_settings(name:, title:, subtitle:, domain:)
|
282
|
+
vfile = "#{@blog.root}/views/#{name}/settings/view.txt"
|
283
|
+
hash = {/VIEW_NAME/ => name,
|
284
|
+
/VIEW_TITLE/ => title,
|
285
|
+
/VIEW_SUBTITLE/ => subtitle,
|
286
|
+
/VIEW_DOMAIN/ => domain}
|
287
|
+
@blog.complete_file(vfile, nil, hash)
|
288
|
+
end
|
289
|
+
|
264
290
|
def cmd_new_view(arg)
|
265
291
|
view_name = ask!(" Filename: ")
|
266
292
|
@blog.create_view(view_name) # call change_view??
|
267
293
|
title = ask!(" View title: ")
|
268
294
|
subtitle = ask!(" Subtitle : ")
|
269
295
|
domain = ask!(" Domain : ")
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
/VIEW_TITLE/ => title,
|
274
|
-
/VIEW_SUBTITLE/ => subtitle,
|
275
|
-
/VIEW_DOMAIN/ => domain}
|
276
|
-
@blog.complete_file(vfile, nil, hash)
|
296
|
+
modify_view_global(view_name)
|
297
|
+
modify_view_settings(name: view_name, title: title, subtitle: subtitle,
|
298
|
+
domain: domain)
|
277
299
|
@blog.change_view(view_name)
|
278
300
|
end
|
279
301
|
|
@@ -283,11 +305,13 @@ module RuneBlog::REPL
|
|
283
305
|
puts
|
284
306
|
end
|
285
307
|
@blog.create_view(arg)
|
286
|
-
|
287
|
-
File.write("#{@blog.root}/views/#{@blog.view}/themes/standard/global.lt3",
|
308
|
+
lines = File.read("#{@blog.root}/data/global.lt3")
|
309
|
+
# File.write("#{@blog.root}/views/#{@blog.view}/themes/standard/global.lt3",
|
310
|
+
File.write("#{@blog.root}/views/#{@blog.view}/data/global.lt3",
|
288
311
|
text.gsub(/VIEW_NAME/, @blog.view.to_s))
|
289
312
|
vim_params = '-c ":set hlsearch" -c ":hi Search ctermfg=2 ctermbg=6" +/"\(VIEW_.*\|SITE.*\)"'
|
290
|
-
edit_file(@blog.view.dir/"themes/standard/global.lt3", vim: vim_params)
|
313
|
+
# edit_file(@blog.view.dir/"themes/standard/global.lt3", vim: vim_params)
|
314
|
+
edit_file(@blog.view.dir/"data/global.lt3", vim: vim_params)
|
291
315
|
@blog.change_view(arg)
|
292
316
|
rescue ViewAlreadyExists
|
293
317
|
puts 'Blog already exists'
|
@@ -328,7 +352,7 @@ module RuneBlog::REPL
|
|
328
352
|
tag = "#{'%04d' % id}"
|
329
353
|
files = ::Find.find(@blog.root/:drafts).to_a
|
330
354
|
files = files.grep(/#{tag}-.*lt3/)
|
331
|
-
draft = exactly_one(files)
|
355
|
+
draft = exactly_one(files, files.join("/"))
|
332
356
|
result = edit_file(draft, vim: '-c$')
|
333
357
|
@blog.generate_post(draft)
|
334
358
|
rescue => err
|
data/lib/runeblog.rb
CHANGED
@@ -97,7 +97,6 @@ class RuneBlog
|
|
97
97
|
def self.create_new_blog_repo(root_rel = ".blogs")
|
98
98
|
log!(enter: __method__, args: [root_rel])
|
99
99
|
check_nonempty_string(root_rel)
|
100
|
-
self.blog = self # Weird. Like a singleton - dumbass circular dependency?
|
101
100
|
repo_root = Dir.pwd/root_rel
|
102
101
|
check_error(BlogRepoAlreadyExists) { Dir.exist?(repo_root) }
|
103
102
|
|
@@ -113,16 +112,17 @@ class RuneBlog
|
|
113
112
|
end
|
114
113
|
# copy_data(:extra, repo_root/:config)
|
115
114
|
write_repo_config(root: repo_root)
|
116
|
-
|
117
|
-
|
115
|
+
# Weird. Like a singleton - dumbass circular dependency?
|
116
|
+
self.blog = blog = self.new
|
117
|
+
blog
|
118
118
|
rescue => err
|
119
119
|
puts "Can't create blog repo: '#{repo_root}' - #{err}"
|
120
120
|
puts err.backtrace.join("\n")
|
121
121
|
end
|
122
122
|
|
123
123
|
def self.open(root_rel = ".blogs")
|
124
|
+
raise "Not impl"
|
124
125
|
log!(enter: __method__, args: [root_rel])
|
125
|
-
self.blog = self # Weird. Like a singleton - dumbass circular dependency?
|
126
126
|
blog = self.new(root_rel)
|
127
127
|
rescue => err
|
128
128
|
_tmp_error(err)
|
@@ -130,10 +130,11 @@ class RuneBlog
|
|
130
130
|
|
131
131
|
def initialize(root_rel = ".blogs") # always assumes existing blog
|
132
132
|
log!(enter: "initialize", args: [root_rel])
|
133
|
-
|
133
|
+
# Weird. Like a singleton - dumbass circular dependency?
|
134
|
+
self.class.blog = self
|
134
135
|
|
135
136
|
@root = Dir.pwd/root_rel
|
136
|
-
write_repo_config(root: @root) # ?? FIXME
|
137
|
+
# write_repo_config(root: @root) # ?? FIXME
|
137
138
|
get_repo_config
|
138
139
|
read_features # top level
|
139
140
|
@views = retrieve_views
|
@@ -146,6 +147,11 @@ class RuneBlog
|
|
146
147
|
@sequence = get_sequence
|
147
148
|
@post_views = []
|
148
149
|
@post_tags = []
|
150
|
+
rescue => err
|
151
|
+
puts "Error - see stdout.txt"
|
152
|
+
STDERR.puts err.inspect
|
153
|
+
STDERR.puts err.backtrace
|
154
|
+
sleep 3
|
149
155
|
end
|
150
156
|
|
151
157
|
def complete_file(name, vars, hash)
|
@@ -241,7 +247,7 @@ class RuneBlog
|
|
241
247
|
create_dirs(dir)
|
242
248
|
# FIXME dependencies?
|
243
249
|
preprocess cwd: dir, src: @root/:drafts/sourcefile, dst: @root/:posts/sourcefile.sub(/.lt3/, ".html"), # ZZZ
|
244
|
-
mix: "liveblog" # , debug: true
|
250
|
+
mix: "liveblog", vars: @view.globals # , debug: true
|
245
251
|
_deploy_local(dir)
|
246
252
|
rescue => err
|
247
253
|
_tmp_error(err)
|
@@ -264,13 +270,13 @@ class RuneBlog
|
|
264
270
|
views.any? {|x| x.name == name }
|
265
271
|
end
|
266
272
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
273
|
+
# def view(name = nil)
|
274
|
+
# log!(enter: __method__, args: [name], level: 3)
|
275
|
+
# return @view if name.nil?
|
276
|
+
#
|
277
|
+
# check_nonempty_string(name)
|
278
|
+
# return str2view(name)
|
279
|
+
# end
|
274
280
|
|
275
281
|
def str2view(str)
|
276
282
|
log!(enter: __method__, args: [str], level: 3)
|
@@ -287,26 +293,28 @@ class RuneBlog
|
|
287
293
|
|
288
294
|
def view=(arg)
|
289
295
|
log!(enter: __method__, args: [arg], level: 2)
|
296
|
+
if arg == "[no view]"
|
297
|
+
@view = nil
|
298
|
+
return
|
299
|
+
end
|
300
|
+
# STDERR.puts "view= #{arg.inspect}"
|
301
|
+
|
290
302
|
case arg
|
291
|
-
when "[no view]"
|
292
|
-
# puts "Warning: No current view set"
|
293
|
-
@view = nil
|
294
303
|
when RuneBlog::View
|
295
304
|
@view = arg
|
296
|
-
|
297
|
-
@view.get_globals
|
298
|
-
_set_publisher
|
305
|
+
@view.get_globals(true)
|
299
306
|
when String
|
300
307
|
new_view = str2view(arg)
|
301
|
-
# puts "
|
308
|
+
# STDERR.puts "view= new view #{new_view.inspect}"
|
302
309
|
check_error(NoSuchView, arg) { new_view.nil? }
|
303
310
|
@view = new_view
|
304
|
-
read_features(@view)
|
305
|
-
@view.get_globals
|
306
|
-
_set_publisher
|
307
311
|
else
|
308
312
|
raise CantAssignView(arg.class.to_s)
|
309
313
|
end
|
314
|
+
read_features(@view)
|
315
|
+
@view.get_globals(true)
|
316
|
+
_set_publisher
|
317
|
+
File.write(@root/"data/VIEW", @view.to_s)
|
310
318
|
rescue => err
|
311
319
|
_tmp_error(err)
|
312
320
|
end
|
@@ -327,7 +335,9 @@ class RuneBlog
|
|
327
335
|
log!(enter: __method__, args: [v], level: 3)
|
328
336
|
return @view if v.nil?
|
329
337
|
check_nonempty_string(v)
|
330
|
-
|
338
|
+
dir = @root/:views/v
|
339
|
+
puts "Dir = #{dir}" # ; sleep 5
|
340
|
+
return dir
|
331
341
|
end
|
332
342
|
|
333
343
|
def self.exist?
|
@@ -375,8 +385,9 @@ class RuneBlog
|
|
375
385
|
make_empty_view_tree(view_name)
|
376
386
|
add_view(view_name)
|
377
387
|
mark_last_published("Initial creation")
|
378
|
-
system("cp #@root/data/global.lt3 #@root/views/#{view_name}/themes/standard/global.lt3")
|
379
|
-
|
388
|
+
# system("cp #@root/data/global.lt3 #@root/views/#{view_name}/themes/standard/global.lt3")
|
389
|
+
system("cp #@root/data/global.lt3 #@root/views/#{view_name}/data/global.lt3")
|
390
|
+
@view.get_globals(true)
|
380
391
|
rescue => err
|
381
392
|
_tmp_error(err)
|
382
393
|
end
|
@@ -408,7 +419,7 @@ class RuneBlog
|
|
408
419
|
posts.select! {|x| File.directory?(x) }
|
409
420
|
|
410
421
|
posts = posts.select {|x| File.basename(x).to_i == postid }
|
411
|
-
postdir = exactly_one(posts)
|
422
|
+
postdir = exactly_one(posts, posts.join("/"))
|
412
423
|
vp = RuneBlog::ViewPost.new(self.view, postdir)
|
413
424
|
vp
|
414
425
|
rescue => err
|
@@ -424,7 +435,7 @@ class RuneBlog
|
|
424
435
|
depend = [post_entry_name]
|
425
436
|
html = "/tmp/post_entry.html"
|
426
437
|
preprocess src: post_entry_name, dst: html,
|
427
|
-
call: ".nopara"
|
438
|
+
call: ".nopara", vars: @view.globals # , deps: depend # , debug: true
|
428
439
|
@_post_entry = File.read(html)
|
429
440
|
vp = post_lookup(id)
|
430
441
|
nslug, aslug, title, date, teaser_text =
|
@@ -566,15 +577,16 @@ class RuneBlog
|
|
566
577
|
log!(enter: __method__, args: [view])
|
567
578
|
vdir = @root/:views/view
|
568
579
|
@theme = @root/:views/view/:themes/:standard
|
569
|
-
|
580
|
+
@data = @root/:views/view/:data
|
581
|
+
depend = [vdir/"remote/etc/blog.css.lt3", @data/"global.lt3",
|
570
582
|
@theme/"blog/head.lt3",
|
571
583
|
# @theme/"navbar/navbar.lt3",
|
572
584
|
@theme/"blog/index.lt3"] # FIXME what about assets?
|
573
585
|
preprocess cwd: vdir/"themes/standard/etc", src: "blog.css.lt3",
|
574
|
-
copy: vdir/"remote/etc/", call: [".nopara"], strip: true
|
586
|
+
copy: vdir/"remote/etc/", call: [".nopara"], strip: true , vars: @view.globals
|
575
587
|
preprocess cwd: vdir/"themes/standard", deps: depend, force: true,
|
576
588
|
src: "blog/generate.lt3", dst: vdir/:remote/"index.html",
|
577
|
-
call: ".nopara"
|
589
|
+
call: ".nopara" , vars: @view.globals
|
578
590
|
copy!("#{vdir}/themes/standard/banner/*", "#{vdir}/remote/banner/") # includes navbar/
|
579
591
|
copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
|
580
592
|
# rebuild widgets?
|
@@ -588,7 +600,7 @@ class RuneBlog
|
|
588
600
|
def _get_views(draft)
|
589
601
|
log!(enter: __method__, args: [draft], level: 2)
|
590
602
|
# FIXME dumb code
|
591
|
-
view_line = exactly_one(File.readlines(draft).grep(/^.views /))
|
603
|
+
view_line = exactly_one(File.readlines(draft).grep(/^.views /), ".view line")
|
592
604
|
views = view_line[7..-1].split
|
593
605
|
views.uniq
|
594
606
|
rescue => err
|
@@ -626,11 +638,14 @@ class RuneBlog
|
|
626
638
|
title = meta.title
|
627
639
|
tags = meta.tags
|
628
640
|
# FIXME simplify
|
629
|
-
addvar(hash, "post.num" => pnum,
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
641
|
+
addvar(hash, "post.num" => pnum,
|
642
|
+
"post.aslug" => aslug,
|
643
|
+
"post.date" => date,
|
644
|
+
title: title.chomp,
|
645
|
+
teaser: excerpt.chomp,
|
646
|
+
longdate: longdate,
|
647
|
+
"post.nslug" => pnum + "-" + aslug,
|
648
|
+
"post.tags" => tags.join(" "))
|
634
649
|
end
|
635
650
|
hash
|
636
651
|
rescue => err
|
@@ -639,19 +654,25 @@ class RuneBlog
|
|
639
654
|
|
640
655
|
def copy_widget_html(view)
|
641
656
|
log!(enter: __method__, level: 2)
|
657
|
+
log! str: "=== cwh cp 1"
|
642
658
|
vdir = @root/:views/view
|
643
659
|
remote = vdir/:remote
|
644
660
|
wdir = vdir/:widgets
|
645
661
|
widgets = Dir[wdir/"*"].select {|w| File.directory?(w) }
|
662
|
+
log! str: "=== cwh cp 2"
|
646
663
|
widgets.each do |w|
|
647
664
|
dir = File.basename(w)
|
648
665
|
rem = w.sub(/widgets/, "remote/widgets")
|
666
|
+
log! str: "=== cwh cp 3 w = #{w.inspect}"
|
649
667
|
create_dirs(rem)
|
650
668
|
files = Dir[w/"*"]
|
651
669
|
# files = files.select {|x| x =~ /(html|css)$/ }
|
652
670
|
tag = File.basename(w)
|
653
|
-
|
671
|
+
log! str: "=== cwh cp 4 tag = #{tag.inspect}"
|
672
|
+
files.each {|file| system!("cp #{file} #{rem}", show: true) }
|
673
|
+
log! str: "=== cwh cp 5 tag was #{tag.inspect}"
|
654
674
|
end
|
675
|
+
log! str: "=== cwh cp 6"
|
655
676
|
rescue => err
|
656
677
|
_tmp_error(err)
|
657
678
|
end
|
@@ -667,25 +688,42 @@ class RuneBlog
|
|
667
688
|
pdraft = @root/:posts/nslug
|
668
689
|
remote = @root/:views/view_name/:remote
|
669
690
|
@theme = @root/:views/view_name/:themes/:standard
|
691
|
+
pmeta = @root/:views/view_name/:posts/nslug
|
692
|
+
|
693
|
+
log! str: "=== hpost cp 1"
|
670
694
|
|
671
695
|
create_dirs(pdraft) # Step 1...
|
696
|
+
log! str: "=== hpost cp 2"
|
672
697
|
preprocess cwd: pdraft, src: draft, # FIXME dependencies?
|
673
|
-
dst: "guts.html", mix: "liveblog"
|
698
|
+
dst: "guts.html", mix: "liveblog", vars: (@view.globals || {})
|
699
|
+
log! str: "=== hpost cp 3"
|
674
700
|
hash = _post_metadata(draft, pdraft)
|
701
|
+
log! str: "=== hpost cp 4"
|
702
|
+
hash[:CurrentPost] = pmeta
|
675
703
|
vposts = @root/:views/view_name/:posts # Step 2...
|
676
|
-
puts
|
677
|
-
|
678
|
-
puts
|
704
|
+
# 5.times { STDERR.puts }
|
705
|
+
# STDERR.puts "-- hpost:"
|
706
|
+
# hash.each_pair {|k,v| STDERR.puts " #{k}: #{v}" if k.is_a? Symbol }
|
707
|
+
# 5.times { STDERR.puts }
|
679
708
|
copy!(pdraft, vposts) # ??
|
680
|
-
copy(pdraft/"guts.html",
|
681
|
-
|
682
|
-
|
683
|
-
|
709
|
+
copy(pdraft/"guts.html", vposts/nslug) # Step 3...
|
710
|
+
# Step 4...
|
711
|
+
# preprocess cwd: @theme/:post, src: "generate.lt3",
|
712
|
+
log! str: "=== hpost cp 5"
|
713
|
+
# @view.dump_globals_stderr
|
714
|
+
preprocess cwd: pmeta, src: "../../themes/standard/post/generate.lt3",
|
715
|
+
force: true, vars: hash, debug: true,
|
716
|
+
dst: remote/ahtml, call: ".nopara"
|
717
|
+
log! str: "=== hpost cp 6"
|
684
718
|
FileUtils.rm_f(remote/"published")
|
719
|
+
log! str: "=== hpost cp 7"
|
685
720
|
timelog("Generated", remote/"history")
|
686
721
|
copy_widget_html(view_name)
|
722
|
+
log! str: "=== hpost cp 8"
|
687
723
|
rescue => err
|
724
|
+
log! str: "=== hpost cp 9"
|
688
725
|
_tmp_error(err)
|
726
|
+
# puts err.backtrace.join("\n")
|
689
727
|
end
|
690
728
|
|
691
729
|
def _check_view?(view)
|
@@ -696,8 +734,11 @@ puts
|
|
696
734
|
|
697
735
|
def generate_post(draft, force = false)
|
698
736
|
log!(enter: __method__, args: [draft], level: 1)
|
737
|
+
log! str: "=== gpost cp 1"
|
699
738
|
views = _get_views(draft)
|
739
|
+
log! str: "=== gpost cp 2"
|
700
740
|
views.each {|view| _handle_post(draft, view) }
|
741
|
+
log! str: "=== gpost cp 3"
|
701
742
|
# For current view:
|
702
743
|
slug = File.basename(draft).sub(/.lt3$/, "")
|
703
744
|
postdir = self.view.dir/"remote/post/"/slug
|