runeblog 0.3.18 → 0.3.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +77 -53
- data/data/global.lt3 +3 -3
- data/data/universal.lt3 +2 -0
- data/empty_view/data/GIT_IS_DUMB +0 -0
- data/empty_view/themes/standard/banner/top.lt3 +1 -1
- data/empty_view/themes/standard/blog/generate.lt3 +1 -1
- data/empty_view/themes/standard/etc/blog.css.lt3 +3 -1
- data/empty_view/themes/standard/etc/github.css +209 -0
- data/empty_view/themes/standard/post/generate.lt3 +8 -5
- data/empty_view/themes/standard/post/permalink.lt3 +1 -1
- data/lib/exceptions.rb +37 -0
- data/lib/helpers-blog.rb +6 -4
- data/lib/helpers-repl.rb +2 -6
- data/lib/liveblog.rb +108 -31
- data/lib/lowlevel.rb +23 -7
- data/lib/menus.rb +5 -3
- data/lib/newpost.rb +82 -0
- data/lib/post.rb +6 -5
- data/lib/processing.rb +23 -2
- data/lib/publish.rb +3 -1
- data/lib/repl.rb +68 -26
- data/lib/runeblog.rb +94 -57
- data/lib/runeblog_version.rb +2 -15
- data/lib/view.rb +22 -3
- data/runeblog.gemspec +2 -2
- metadata +13 -9
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"),
|
@@ -32,8 +33,9 @@ Menu.top_config = {
|
|
32
33
|
" HEAD info" => edit("#{std}/blog/head.lt3"),
|
33
34
|
" Layout " => edit("#{std}/blog/index.lt3"),
|
34
35
|
" Recent-posts entry" => edit("#{std}/blog/post_entry.lt3"),
|
35
|
-
" Banner: Description" => edit("#{std}/
|
36
|
-
"
|
36
|
+
" Banner: Description" => edit("#{std}/banner/banner.lt3"),
|
37
|
+
" Navbar" => edit("#{std}/navbar/navbar.lt3"),
|
38
|
+
# " Text portion" => edit("#{std}/banner/top.lt3"),
|
37
39
|
"Generator for a post" => edit("#{std}/post/generate.lt3"),
|
38
40
|
" HEAD info for post" => edit("#{std}/post/head.lt3"),
|
39
41
|
" Content for post" => edit("#{std}/post/index.lt3"),
|
data/lib/newpost.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rubytext'
|
2
|
+
|
3
|
+
RubyText.start
|
4
|
+
|
5
|
+
# Idea: A special sub-environment for creating a post
|
6
|
+
#
|
7
|
+
# 1. Display: view, post number, date
|
8
|
+
# 2. Menu?
|
9
|
+
# 3. - Edit/enter title
|
10
|
+
# 4. - Edit teaser
|
11
|
+
# 5. - Add views
|
12
|
+
# 6. - Add tags
|
13
|
+
# 7. - Import assets
|
14
|
+
# 8. - Save
|
15
|
+
# 9. - Quit
|
16
|
+
# Edit body after save/quit
|
17
|
+
|
18
|
+
def ask(prompt) # elsewhere?
|
19
|
+
print prompt
|
20
|
+
str = gets
|
21
|
+
str.chomp! if str
|
22
|
+
str
|
23
|
+
end
|
24
|
+
|
25
|
+
def enter_title
|
26
|
+
puts __method__
|
27
|
+
str = ask("Title: ")
|
28
|
+
puts str.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit_teaser
|
32
|
+
puts __method__
|
33
|
+
str = ask("Teaser: ")
|
34
|
+
puts str.inspect
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_views
|
38
|
+
puts __method__
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_tags
|
42
|
+
puts __method__
|
43
|
+
end
|
44
|
+
|
45
|
+
def import_assets
|
46
|
+
puts __method__
|
47
|
+
end
|
48
|
+
|
49
|
+
def save_post
|
50
|
+
puts __method__
|
51
|
+
end
|
52
|
+
|
53
|
+
def quit_post
|
54
|
+
puts __method__
|
55
|
+
end
|
56
|
+
|
57
|
+
items = {
|
58
|
+
"Enter title" => proc { enter_title },
|
59
|
+
"Edit teaser" => proc { edit_teaser },
|
60
|
+
"Add views" => proc { add_views },
|
61
|
+
"Add tags" => proc { add_tags },
|
62
|
+
"Import assets" => proc { import_assets },
|
63
|
+
"Save" => proc { save_post },
|
64
|
+
"Quit" => proc { quit_post }
|
65
|
+
}
|
66
|
+
|
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
@@ -11,7 +11,7 @@ class RuneBlog::Post
|
|
11
11
|
|
12
12
|
def self.load(post)
|
13
13
|
log!(enter: __method__, args: [post], level: 3)
|
14
|
-
raise
|
14
|
+
raise NotImplemented
|
15
15
|
raise NoBlogAccessor if RuneBlog.blog.nil?
|
16
16
|
# "post" is a slug?
|
17
17
|
pdir = RuneBlog.blog.root/:drafts/post
|
@@ -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
|
@@ -87,8 +87,8 @@ class RuneBlog::ViewPost
|
|
87
87
|
attr_accessor :path, :title, :date, :teaser_text
|
88
88
|
|
89
89
|
def self.make(blog:, view:, nslug:)
|
90
|
-
raise
|
91
|
-
raise
|
90
|
+
raise NoNumericPrefix(nslug) unless nslug =~ /^\d{4}-/
|
91
|
+
raise NoExtensionExpected(nslug) if nslug.end_with?(".lt3") || nslug.end_with?(".html")
|
92
92
|
view = view.to_s
|
93
93
|
view.define_singleton_method :path do |subdir = ""|
|
94
94
|
str = blog.root/:views/view
|
@@ -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
@@ -12,7 +12,7 @@ end
|
|
12
12
|
def stale?(src, dst, deps, force = false)
|
13
13
|
meh = File.new("/tmp/dammit-#{src.gsub(/\//, "-")}", "w")
|
14
14
|
log!(enter: __method__, args: [src, dst], level: 3)
|
15
|
-
raise "
|
15
|
+
raise FileNotFound("#{Dir.pwd}/#{src}") unless File.exist?(src)
|
16
16
|
return true if force
|
17
17
|
return true unless File.exist?(dst)
|
18
18
|
return true if newer?(src, dst)
|
@@ -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
@@ -2,35 +2,28 @@ require 'runeblog'
|
|
2
2
|
require 'ostruct'
|
3
3
|
require 'helpers-repl' # FIXME structure
|
4
4
|
require 'pathmagic'
|
5
|
+
require 'exceptions'
|
5
6
|
|
6
7
|
require 'menus'
|
7
8
|
|
8
|
-
make_exception(:PublishError, "Error during publishing")
|
9
|
-
make_exception(:EditorProblem, "Could not edit $1")
|
10
|
-
|
11
9
|
Signal.trap("INT") { puts "Don't :)" }
|
12
10
|
|
13
11
|
module RuneBlog::REPL
|
14
12
|
def edit_file(file, vim: "")
|
15
|
-
# STDSCR.saveback
|
16
13
|
ed = @blog.editor
|
17
14
|
params = vim if ed =~ /vim$/
|
18
15
|
result = system!("#{@blog.editor} #{file} #{params}")
|
19
16
|
raise EditorProblem(file) unless result
|
20
|
-
# STDSCR.restback
|
21
17
|
cmd_clear
|
22
18
|
end
|
23
19
|
|
24
20
|
def cmd_quit
|
25
21
|
STDSCR.rows.times { puts " "*(STDSCR.cols-1) }
|
26
|
-
# FIXME please?
|
27
|
-
# sleep 0.1
|
28
22
|
STDSCR.clear
|
29
23
|
sleep 0.1
|
30
24
|
RubyText.stop
|
31
25
|
sleep 0.1
|
32
26
|
system("clear")
|
33
|
-
# sleep 0.1
|
34
27
|
exit
|
35
28
|
end
|
36
29
|
|
@@ -213,13 +206,14 @@ module RuneBlog::REPL
|
|
213
206
|
|
214
207
|
def regen_posts
|
215
208
|
drafts = @blog.drafts # current view
|
216
|
-
|
209
|
+
log! str: "=== Regenerating posts..." unless drafts.empty?
|
217
210
|
drafts.each do |draft|
|
218
211
|
orig = @blog.root/:drafts/draft
|
219
212
|
postdir = @blog.root/:posts/draft.sub(/.lt3$/, "")
|
220
213
|
content = postdir/"/guts.html"
|
221
214
|
next if fresh?(orig, content)
|
222
215
|
|
216
|
+
log! str: "=== Calling generate_post(#{orig})"
|
223
217
|
@blog.generate_post(orig) # rebuild post
|
224
218
|
Dir.chdir(postdir) do
|
225
219
|
meta = @blog.read_metadata
|
@@ -231,28 +225,34 @@ module RuneBlog::REPL
|
|
231
225
|
end
|
232
226
|
|
233
227
|
def cmd_rebuild
|
234
|
-
|
228
|
+
log! str: "=== Starting cmd_rebuild..."
|
235
229
|
puts
|
236
230
|
regen_posts
|
237
|
-
|
231
|
+
log! str: "=== Generating view..."
|
238
232
|
@blog.generate_view(@blog.view)
|
239
|
-
|
233
|
+
log! str: "=== Generating index..."
|
240
234
|
@blog.generate_index(@blog.view)
|
241
|
-
|
235
|
+
log! str: "=== ...finished!"
|
242
236
|
rescue => err
|
243
237
|
_tmp_error(err)
|
244
238
|
end
|
245
239
|
|
246
240
|
def cmd_change_view(arg = nil)
|
247
241
|
if arg.nil?
|
248
|
-
viewnames =
|
249
|
-
|
242
|
+
viewnames = {}
|
243
|
+
@blog.views.each do |v|
|
244
|
+
name = v.to_s
|
245
|
+
title = view2title(name)
|
246
|
+
string = "#{'%-25s' % title} #{name}"
|
247
|
+
viewnames[string] = name
|
248
|
+
end
|
249
|
+
n = viewnames.values.find_index(@blog.view.name)
|
250
250
|
name = @blog.view.name
|
251
|
-
# TODO: Add view description
|
252
251
|
k, name = STDSCR.menu(title: "Views", items: viewnames, curr: n)
|
253
252
|
return if name.nil?
|
253
|
+
log! str: "cv Setting to #{name.inspect}"
|
254
254
|
@blog.view = name
|
255
|
-
|
255
|
+
# puts "\n ", fx(name, :bold), "\n"
|
256
256
|
return
|
257
257
|
else
|
258
258
|
if @blog.view?(arg)
|
@@ -262,17 +262,56 @@ module RuneBlog::REPL
|
|
262
262
|
end
|
263
263
|
end
|
264
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
|
+
|
265
290
|
def cmd_new_view(arg)
|
291
|
+
view_name = ask!(" Filename: ")
|
292
|
+
@blog.create_view(view_name) # call change_view??
|
293
|
+
title = ask!(" View title: ")
|
294
|
+
subtitle = ask!(" Subtitle : ")
|
295
|
+
domain = ask!(" Domain : ")
|
296
|
+
modify_view_global(view_name)
|
297
|
+
modify_view_settings(name: view_name, title: title, subtitle: subtitle,
|
298
|
+
domain: domain)
|
299
|
+
@blog.change_view(view_name)
|
300
|
+
end
|
301
|
+
|
302
|
+
def cmd_new_view_ORIG(arg)
|
266
303
|
if arg.nil?
|
267
304
|
arg = ask(fx("\nFilename: ", :bold))
|
268
305
|
puts
|
269
306
|
end
|
270
307
|
@blog.create_view(arg)
|
271
|
-
|
272
|
-
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",
|
273
311
|
text.gsub(/VIEW_NAME/, @blog.view.to_s))
|
274
312
|
vim_params = '-c ":set hlsearch" -c ":hi Search ctermfg=2 ctermbg=6" +/"\(VIEW_.*\|SITE.*\)"'
|
275
|
-
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)
|
276
315
|
@blog.change_view(arg)
|
277
316
|
rescue ViewAlreadyExists
|
278
317
|
puts 'Blog already exists'
|
@@ -313,22 +352,26 @@ module RuneBlog::REPL
|
|
313
352
|
tag = "#{'%04d' % id}"
|
314
353
|
files = ::Find.find(@blog.root/:drafts).to_a
|
315
354
|
files = files.grep(/#{tag}-.*lt3/)
|
316
|
-
draft = exactly_one(files)
|
355
|
+
draft = exactly_one(files, files.join("/"))
|
317
356
|
result = edit_file(draft, vim: '-c$')
|
318
357
|
@blog.generate_post(draft)
|
319
358
|
rescue => err
|
320
359
|
_tmp_error(err)
|
321
360
|
end
|
322
361
|
|
362
|
+
def view2title(name) # FIXME: crufty as hell
|
363
|
+
lines = File.readlines(@blog.root/"views/#{name}/settings/view.txt")
|
364
|
+
lines.map!(&:chomp)
|
365
|
+
lines = lines.select {|x| x =~ /^title / && x !~ /VIEW_/ }
|
366
|
+
title = lines.first.split(" ", 2)[1]
|
367
|
+
end
|
368
|
+
|
323
369
|
def cmd_list_views
|
324
370
|
puts
|
325
371
|
@blog.views.each do |v|
|
326
372
|
v = v.to_s
|
373
|
+
title = view2title(v)
|
327
374
|
v = fx(v, :bold) if v == @blog.view.name
|
328
|
-
# FIXME: next 3 lines are crufty as hell
|
329
|
-
lines = File.readlines(@blog.root/"views/#{v}/settings/view.txt")
|
330
|
-
lines = lines.select {|x| x =~ /^title / && x !~ /VIEW_/ }
|
331
|
-
title = lines.first.split(" ", 2)[1]
|
332
375
|
print " ", ('%15s' % v)
|
333
376
|
puts " ", fx(title, Black)
|
334
377
|
end
|
@@ -441,7 +484,6 @@ module RuneBlog::REPL
|
|
441
484
|
cmd = "cp #{name} #{@blog.root}/drafts/#@fname"
|
442
485
|
result = system!(cmd)
|
443
486
|
raise CantCopy(name, "#{@blog.root}/drafts/#@fname") unless result
|
444
|
-
# post = Post.load(@slug)
|
445
487
|
draft = "#{@blog.root}/drafts/#@fname"
|
446
488
|
@meta = @blog.generate_post(draft)
|
447
489
|
puts
|