runeblog 0.0.50 → 0.0.51

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3b39c7785709eb2bf8872755d2e4a78a243778e
4
- data.tar.gz: e1487a5a7159e43fae8259f2fd445095fa214d3a
3
+ metadata.gz: 68148eb4defbbdf649cc895e85c7812d499eb135
4
+ data.tar.gz: 134d702ca04162a0067d0a123fe3899eafa9547b
5
5
  SHA512:
6
- metadata.gz: 603def138fc3cb6b3257f35d8d24542bb4cc7b857667208d9268a4d328385448030aa4344f8867058f723fca93581d3ed33aca44a9f4208429e673828db2f49f
7
- data.tar.gz: 7ab37aaf0445c51cfc7fcefd0228b5ca9c55c355bd5c1b681fad39019952585c082eb05b181d68ea60d76d8f41407489d14564acf60ec703e905719886cff586
6
+ metadata.gz: 8a34474dd674facbb7f3c5d20ac9c0d22da3d71f622a1719ece79e199c9eda11b3b9f56b60e83f3e766ddd774125ea461aefcc45f53780a5c9c4312d42ad786c
7
+ data.tar.gz: a2b395583a84b4425336831cba39e31218bd49ecc56172193915662694190f291b62037967c76db290d9d9dffc2b880458f65c2f0b05233efd5481f7dc47d351
data/bin/blog CHANGED
@@ -3,7 +3,6 @@
3
3
  $: << "./lib"
4
4
 
5
5
  require 'repl'
6
- require 'blogcmds'
7
6
 
8
7
  trap("INT") { }
9
8
 
@@ -33,7 +32,7 @@ if cmd.nil? # REPL
33
32
  cmd = gets
34
33
  cmd_quit([]) if cmd.nil? # ^D
35
34
  cmd.chomp!
36
- meth, params = RuneBlog::Command.choose_method(cmd)
35
+ meth, params = RuneBlog::REPL.choose_method(cmd)
37
36
  send(meth, params)
38
37
  end
39
38
  else # one command
data/data/VERSION CHANGED
@@ -1 +1 @@
1
- RuneBlog v 0.0.50 2018-09-01
1
+ RuneBlog v 0.0.51 2018-09-01
@@ -0,0 +1,301 @@
1
+
2
+ # Reopening...
3
+
4
+ module RuneBlog::REPL
5
+ Patterns =
6
+ {"help" => :cmd_help,
7
+ "h" => :cmd_help,
8
+
9
+ "version" => :cmd_version,
10
+ "v" => :cmd_version,
11
+
12
+ "list views" => :cmd_list_views,
13
+ "lsv" => :cmd_list_views,
14
+
15
+ "new view $name" => :cmd_new_view,
16
+
17
+ "new post" => :cmd_new_post,
18
+ "p" => :cmd_new_post,
19
+ "post" => :cmd_new_post,
20
+
21
+ "change view $name" => :cmd_change_view,
22
+ "cv $name" => :cmd_change_view,
23
+ "cv" => :cmd_change_view, # 0-arity must come second
24
+
25
+ "list posts" => :cmd_list_posts,
26
+ "lsp" => :cmd_list_posts,
27
+
28
+ "list drafts" => :cmd_list_drafts,
29
+ "lsd" => :cmd_list_drafts,
30
+
31
+ "rm $postid" => :cmd_remove_post,
32
+
33
+ "kill >postid" => :cmd_kill,
34
+
35
+ "edit $postid" => :cmd_edit_post,
36
+ "ed $postid" => :cmd_edit_post,
37
+ "e $postid" => :cmd_edit_post,
38
+
39
+ "preview" => :cmd_preview,
40
+
41
+ "pre" => :cmd_preview,
42
+
43
+ "browse" => :cmd_browse,
44
+
45
+ "relink" => :cmd_relink,
46
+
47
+ "rebuild" => :cmd_rebuild,
48
+
49
+ "deploy" => :cmd_deploy,
50
+
51
+ "q" => :cmd_quit,
52
+ "quit" => :cmd_quit
53
+ }
54
+
55
+ Regexes = {}
56
+ Patterns.each_pair do |pat, meth|
57
+ rx = "^" + pat
58
+ rx.gsub!(/ /, " +")
59
+ rx.gsub!(/\$(\w+) */) { " *(?<#{$1}>\\w+)" }
60
+ # How to handle multiple optional args?
61
+ rx.sub!(/>(\w+)$/) { "(.+)" }
62
+ p rx if rx =~ /kill/
63
+ rx << "$"
64
+ rx = Regexp.new(rx)
65
+ Regexes[rx] = meth
66
+ end
67
+
68
+ def self.choose_method(cmd)
69
+ found = nil
70
+ params = []
71
+ Regexes.each_pair do |rx, meth|
72
+ m = cmd.match(rx)
73
+ # puts "#{rx} =~ #{cmd.inspect} --> #{m.to_a.inspect}"
74
+ result = m ? m.to_a : nil
75
+ next unless result
76
+ found = meth
77
+ params = m[1..-1]
78
+ end
79
+ meth = found || :cmd_INVALID
80
+ params = cmd if meth == :cmd_INVALID
81
+ [meth, params]
82
+ end
83
+ def error(err)
84
+ str = "\n Error: #{red(err)}"
85
+ puts str
86
+ puts err.backtrace
87
+ end
88
+
89
+ def ask(prompt, meth = :to_s)
90
+ print prompt
91
+ STDOUT.flush
92
+ STDIN.gets.chomp.send(meth)
93
+ end
94
+
95
+ def yesno(prompt, meth = :to_s)
96
+ print prompt
97
+ STDOUT.flush
98
+ STDIN.gets.chomp.upcase[0] == "Y"
99
+ end
100
+
101
+ def clear
102
+ puts "\e[H\e[2J" # clear screen
103
+ end
104
+
105
+ def red(text)
106
+ "\e[31m#{text}\e[0m"
107
+ end
108
+
109
+ def blue(text)
110
+ "\e[34m#{text}\e[0m"
111
+ end
112
+
113
+ def bold(str)
114
+ "\e[1m#{str}\e[22m"
115
+ end
116
+
117
+ def interpolate(str)
118
+ wrap = "<<-EOS\n#{str}\nEOS"
119
+ eval wrap
120
+ end
121
+
122
+ def colored_slug(slug)
123
+ red(slug[0..3])+blue(slug[4..-1])
124
+ end
125
+
126
+ ### process_post
127
+
128
+ def process_post(file)
129
+ @main ||= Livetext.new
130
+ @main.main.output = File.new("/tmp/WHOA","w")
131
+ path = @root + "/src/#{file}"
132
+ @meta = @main.process_file(path, binding)
133
+ raise "process_file returned nil" if @meta.nil?
134
+
135
+ slug = @blog.make_slug(@meta.title, @blog.sequence)
136
+ slug = file.sub(/.lt3$/, "")
137
+ @meta.slug = slug
138
+ @meta
139
+ rescue => err
140
+ error(err)
141
+ end
142
+
143
+ ### reload_post
144
+
145
+ def reload_post(file)
146
+ @main ||= Livetext.new
147
+ @main.main.output = File.new("/tmp/WHOA","w") # FIXME srsly?
148
+ @meta = process_post(file)
149
+ @meta.slug = file.sub(/.lt3$/, "")
150
+ @meta
151
+ rescue => err
152
+ error(err)
153
+ end
154
+
155
+ ### posting
156
+
157
+ def posting(view, meta)
158
+ # FIXME clean up and generalize
159
+ ref = "#{view}/#{meta.slug}/index.html"
160
+ <<-HTML
161
+ <br>
162
+ <font size=+1>#{meta.pubdate}&nbsp;&nbsp;</font>
163
+ <font size=+2 color=blue><a href=../#{ref} style="text-decoration: none">#{meta.title}</font></a>
164
+ <br>
165
+ #{meta.teaser}
166
+ <a href=../#{ref} style="text-decoration: none">Read more...</a>
167
+ <br><br>
168
+ <hr>
169
+ HTML
170
+ end
171
+
172
+ ### generate_index
173
+
174
+ def generate_index(view)
175
+ # Gather all posts, create list
176
+ vdir = "#@root/views/#{view}"
177
+ posts = Dir.entries(vdir).grep /^\d\d\d\d/
178
+ posts = posts.sort.reverse
179
+
180
+ # Add view header/trailer
181
+ head = File.read("#{vdir}/custom/blog_header.html") rescue RuneBlog::BlogHeader
182
+ tail = File.read("#{vdir}/custom/blog_trailer.html") rescue RuneBlog::BlogTrailer
183
+ @bloghead = interpolate(head)
184
+ @blogtail = interpolate(tail)
185
+
186
+ # Output view
187
+ posts.map! {|post| YAML.load(File.read("#{vdir}/#{post}/metadata.yaml")) }
188
+ File.open("#{vdir}/index.html", "w") do |f|
189
+ f.puts @bloghead
190
+ posts.each {|post| f.puts posting(view, post) }
191
+ f.puts @blogtail
192
+ end
193
+ rescue => err
194
+ error(err)
195
+ end
196
+
197
+ ### create_dir
198
+
199
+ def create_dir(dir)
200
+ cmd = "mkdir -p #{dir} >/dev/null 2>&1"
201
+ result = system(cmd)
202
+ raise "Can't create #{dir}" unless result
203
+ end
204
+
205
+ ### link_post_view
206
+
207
+ def link_post_view(view)
208
+ # Create dir using slug (index.html, metadata?)
209
+ vdir = @blog.viewdir(view)
210
+ dir = vdir + @meta.slug + "/"
211
+ create_dir(dir + "assets")
212
+ File.write("#{dir}/metadata.yaml", @meta.to_yaml)
213
+ template = File.read(vdir + "custom/post_template.html")
214
+ post = interpolate(template)
215
+ File.write(dir + "index.html", post)
216
+ generate_index(view)
217
+ rescue => err
218
+ error(err)
219
+ end
220
+
221
+ ### find_asset
222
+
223
+ # def find_asset(asset) # , views)
224
+ # # STDERR.puts "repl find_asset: @meta = #{@meta.inspect}"
225
+ # views = @meta.views
226
+ # views.each do |view|
227
+ # vdir = @config.viewdir(view)
228
+ # post_dir = "#{vdir}#{@meta.slug}/assets/"
229
+ # path = post_dir + asset
230
+ # STDERR.puts " Seeking #{path}"
231
+ # return path if File.exist?(path)
232
+ # end
233
+ # views.each do |view|
234
+ # dir = @config.viewdir(view) + "/assets/"
235
+ # path = dir + asset
236
+ # STDERR.puts " Seeking #{path}"
237
+ # return path if File.exist?(path)
238
+ # end
239
+ # top = @root + "/assets/"
240
+ # path = top + asset
241
+ # STDERR.puts " Seeking #{path}"
242
+ # return path if File.exist?(path)
243
+ #
244
+ # return nil
245
+ # end
246
+ #
247
+ # ### find_all_assets
248
+ #
249
+ # def find_all_assets(list, views)
250
+ # # STDERR.puts "\n Called find_all_assets with #{list.inspect}"
251
+ # list ||= []
252
+ # list.each {|asset| puts "#{asset} => #{find_asset(asset, views)}" }
253
+ # end
254
+
255
+ ### publish_post
256
+
257
+ def publish_post(meta)
258
+ puts " #{colored_slug(meta.slug)}"
259
+ # First gather the views
260
+ views = meta.views
261
+ print " Views: "
262
+ views.each do |view|
263
+ print "#{view} "
264
+ link_post_view(view)
265
+ end
266
+ # assets = find_all_assets(@meta.assets, views)
267
+ puts
268
+ rescue => err
269
+ error(err)
270
+ end
271
+
272
+ ### rebuild_post
273
+
274
+ def rebuild_post(file)
275
+ reload_post(file)
276
+ publish_post(@meta) # FIXME ??
277
+ rescue => err
278
+ error(err)
279
+ end
280
+
281
+ def import(arg = nil)
282
+ open_blog unless @blog
283
+
284
+ arg = nil if arg == ""
285
+ arg ||= ask("Filename: ") # check validity later
286
+ name = arg
287
+ grep = `grep ^.title #{name}`
288
+ @title = grep.sub(/^.title /, "")
289
+ @slug = @blog.make_slug(@title)
290
+ @fname = @slug + ".lt3"
291
+ result = system("cp #{name} #@root/src/#@fname")
292
+ raise "Could not copy #{name} to #@root/src/#@fname" unless result
293
+
294
+ edit_initial_post(@fname)
295
+ process_post(@fname)
296
+ publish_post(@meta) # if publish?
297
+ rescue => err
298
+ error(err)
299
+ end
300
+
301
+ end
data/lib/repl.rb CHANGED
@@ -21,50 +21,22 @@ require 'ostruct'
21
21
  @view
22
22
  =end
23
23
 
24
- require 'prettiness' # FIXME structure
24
+ require 'helpers-repl' # FIXME structure
25
25
 
26
26
  module RuneBlog::REPL
27
27
 
28
- ### error
29
-
30
- def error(err)
31
- str = "\n Error: #{red(err)}"
32
- puts str
33
- puts err.backtrace
34
- end
35
-
36
- ### ask
37
-
38
- def ask(prompt, meth = :to_s)
39
- print prompt
40
- STDOUT.flush
41
- STDIN.gets.chomp.send(meth)
42
- end
43
-
44
- def yesno(prompt, meth = :to_s)
45
- print prompt
46
- STDOUT.flush
47
- STDIN.gets.chomp.upcase[0] == "Y"
48
- end
49
-
50
- ### quit
51
-
52
28
  def cmd_quit(arg)
53
29
  raise "Glitch: Got an argument" if arg != []
54
30
  puts "\n "
55
31
  exit
56
32
  end
57
33
 
58
- ### version
59
-
60
34
  def cmd_version(arg)
61
35
  raise "Glitch: Got an argument" if arg != []
62
36
  puts "\n " + RuneBlog::VERSION
63
37
  end
64
38
 
65
- ### new_blog!
66
-
67
- def new_blog!(arg)
39
+ def new_blog!(arg) # FIXME weird?
68
40
  raise "Glitch: Got an argument" if arg != []
69
41
  return if RuneBlog.exist?
70
42
  yn = yesno(red(" No .blog found. Create new blog? "))
@@ -73,8 +45,6 @@ module RuneBlog::REPL
73
45
  error(err)
74
46
  end
75
47
 
76
- ### open_blog
77
-
78
48
  def open_blog # Crude - FIXME later
79
49
  # new_blog!([]) unless RuneBlog.exist?
80
50
  @blog = RuneBlog.new
@@ -86,8 +56,6 @@ module RuneBlog::REPL
86
56
  error(err)
87
57
  end
88
58
 
89
- ### edit_initial_post
90
-
91
59
  def edit_initial_post(file)
92
60
  result = system("vi #@root/src/#{file} +8 ")
93
61
  raise "Problem editing #@root/src/#{file}" unless result
@@ -95,8 +63,6 @@ module RuneBlog::REPL
95
63
  error(err)
96
64
  end
97
65
 
98
- ### browse
99
-
100
66
  def cmd_browse
101
67
  raise "Glitch: Got an argument" if arg != []
102
68
  @deploy ||= {}
@@ -110,9 +76,7 @@ module RuneBlog::REPL
110
76
  error(err)
111
77
  end
112
78
 
113
- ### open_local
114
-
115
- def open_local
79
+ def cmd_open_local
116
80
  result = system("open #{@blog.viewdir(@view)}/index.html")
117
81
  raise "Problem opening #{@blog.viewdir(@view)}/index.html" unless result
118
82
  rescue => err
@@ -153,163 +117,6 @@ module RuneBlog::REPL
153
117
  error(err)
154
118
  end
155
119
 
156
- ### process_post
157
-
158
- def process_post(file)
159
- @main ||= Livetext.new
160
- @main.main.output = File.new("/tmp/WHOA","w")
161
- path = @root + "/src/#{file}"
162
- @meta = @main.process_file(path, binding)
163
- raise "process_file returned nil" if @meta.nil?
164
-
165
- slug = @blog.make_slug(@meta.title, @blog.sequence)
166
- slug = file.sub(/.lt3$/, "")
167
- @meta.slug = slug
168
- @meta
169
- rescue => err
170
- error(err)
171
- end
172
-
173
- ### reload_post
174
-
175
- def reload_post(file)
176
- @main ||= Livetext.new
177
- @main.main.output = File.new("/tmp/WHOA","w") # FIXME srsly?
178
- @meta = process_post(file)
179
- @meta.slug = file.sub(/.lt3$/, "")
180
- @meta
181
- rescue => err
182
- error(err)
183
- end
184
-
185
- ### posting
186
-
187
- def posting(view, meta)
188
- # FIXME clean up and generalize
189
- ref = "#{view}/#{meta.slug}/index.html"
190
- <<-HTML
191
- <br>
192
- <font size=+1>#{meta.pubdate}&nbsp;&nbsp;</font>
193
- <font size=+2 color=blue><a href=../#{ref} style="text-decoration: none">#{meta.title}</font></a>
194
- <br>
195
- #{meta.teaser}
196
- <a href=../#{ref} style="text-decoration: none">Read more...</a>
197
- <br><br>
198
- <hr>
199
- HTML
200
- end
201
-
202
- ### generate_index
203
-
204
- def generate_index(view)
205
- # Gather all posts, create list
206
- vdir = "#@root/views/#{view}"
207
- posts = Dir.entries(vdir).grep /^\d\d\d\d/
208
- posts = posts.sort.reverse
209
-
210
- # Add view header/trailer
211
- head = File.read("#{vdir}/custom/blog_header.html") rescue RuneBlog::BlogHeader
212
- tail = File.read("#{vdir}/custom/blog_trailer.html") rescue RuneBlog::BlogTrailer
213
- @bloghead = interpolate(head)
214
- @blogtail = interpolate(tail)
215
-
216
- # Output view
217
- posts.map! {|post| YAML.load(File.read("#{vdir}/#{post}/metadata.yaml")) }
218
- File.open("#{vdir}/index.html", "w") do |f|
219
- f.puts @bloghead
220
- posts.each {|post| f.puts posting(view, post) }
221
- f.puts @blogtail
222
- end
223
- rescue => err
224
- error(err)
225
- end
226
-
227
- ### create_dir
228
-
229
- def create_dir(dir)
230
- cmd = "mkdir -p #{dir} >/dev/null 2>&1"
231
- result = system(cmd)
232
- raise "Can't create #{dir}" unless result
233
- end
234
-
235
- ### link_post_view
236
-
237
- def link_post_view(view)
238
- # Create dir using slug (index.html, metadata?)
239
- vdir = @blog.viewdir(view)
240
- dir = vdir + @meta.slug + "/"
241
- create_dir(dir + "assets")
242
- File.write("#{dir}/metadata.yaml", @meta.to_yaml)
243
- template = File.read(vdir + "custom/post_template.html")
244
- post = interpolate(template)
245
- File.write(dir + "index.html", post)
246
- generate_index(view)
247
- rescue => err
248
- error(err)
249
- end
250
-
251
- ### find_asset
252
-
253
- # def find_asset(asset) # , views)
254
- # # STDERR.puts "repl find_asset: @meta = #{@meta.inspect}"
255
- # views = @meta.views
256
- # views.each do |view|
257
- # vdir = @config.viewdir(view)
258
- # post_dir = "#{vdir}#{@meta.slug}/assets/"
259
- # path = post_dir + asset
260
- # STDERR.puts " Seeking #{path}"
261
- # return path if File.exist?(path)
262
- # end
263
- # views.each do |view|
264
- # dir = @config.viewdir(view) + "/assets/"
265
- # path = dir + asset
266
- # STDERR.puts " Seeking #{path}"
267
- # return path if File.exist?(path)
268
- # end
269
- # top = @root + "/assets/"
270
- # path = top + asset
271
- # STDERR.puts " Seeking #{path}"
272
- # return path if File.exist?(path)
273
- #
274
- # return nil
275
- # end
276
- #
277
- # ### find_all_assets
278
- #
279
- # def find_all_assets(list, views)
280
- # # STDERR.puts "\n Called find_all_assets with #{list.inspect}"
281
- # list ||= []
282
- # list.each {|asset| puts "#{asset} => #{find_asset(asset, views)}" }
283
- # end
284
-
285
- ### publish_post
286
-
287
- def publish_post(meta)
288
- puts " #{colored_slug(meta.slug)}"
289
- # First gather the views
290
- views = meta.views
291
- print " Views: "
292
- views.each do |view|
293
- print "#{view} "
294
- link_post_view(view)
295
- end
296
- # assets = find_all_assets(@meta.assets, views)
297
- puts
298
- rescue => err
299
- error(err)
300
- end
301
-
302
- ### rebuild_post
303
-
304
- def rebuild_post(file)
305
- reload_post(file)
306
- publish_post(@meta) # FIXME ??
307
- rescue => err
308
- error(err)
309
- end
310
-
311
- ### rebuild
312
-
313
120
  def cmd_rebuild(arg)
314
121
  raise "Glitch: Got an argument" if arg != []
315
122
  puts
@@ -321,8 +128,6 @@ module RuneBlog::REPL
321
128
  error(err)
322
129
  end
323
130
 
324
- ### relink
325
-
326
131
  def cmd_relink(arg)
327
132
  raise "Glitch: Got an argument" if arg != []
328
133
  @blog.views.each {|view| generate_index(view) }
@@ -330,15 +135,6 @@ module RuneBlog::REPL
330
135
  error(err)
331
136
  end
332
137
 
333
- # ### publish?
334
- #
335
- # def publish?
336
- # yn = ask(red(" Publish? y/n "))
337
- # yn.upcase == "Y"
338
- # end
339
-
340
- ### list_views
341
-
342
138
  def cmd_list_views(arg)
343
139
  abort "Config file not read" unless @blog
344
140
  raise "Glitch: Got an argument" if arg != []
@@ -388,28 +184,6 @@ module RuneBlog::REPL
388
184
  error(err)
389
185
  end
390
186
 
391
- ### import
392
-
393
- def import(arg = nil)
394
- open_blog unless @blog
395
-
396
- arg = nil if arg == ""
397
- arg ||= ask("Filename: ") # check validity later
398
- name = arg
399
- grep = `grep ^.title #{name}`
400
- @title = grep.sub(/^.title /, "")
401
- @slug = @blog.make_slug(@title)
402
- @fname = @slug + ".lt3"
403
- result = system("cp #{name} #@root/src/#@fname")
404
- raise "Could not copy #{name} to #@root/src/#@fname" unless result
405
-
406
- edit_initial_post(@fname)
407
- process_post(@fname)
408
- publish_post(@meta) # if publish?
409
- rescue => err
410
- error(err)
411
- end
412
-
413
187
  ### new_post
414
188
 
415
189
  def cmd_new_post(arg)
@@ -422,20 +196,16 @@ module RuneBlog::REPL
422
196
  file = @blog.create_new_post(@title, @date, @view)
423
197
  edit_initial_post(file)
424
198
  process_post(file) #- FIXME handle each view
425
- publish_post(@meta) # if publish?
199
+ publish_post(@meta)
426
200
  rescue => err
427
201
  error(err)
428
202
  end
429
203
 
430
- ### remove_multiple_posts
431
-
432
- def remove_multiple_posts(str)
433
- args = str.split
434
- args.each {|arg| remove_post(arg, false) }
204
+ def cmd_kill(arg)
205
+ args = arg.first.split
206
+ args.each {|x| cmd_remove_post([x], false) }
435
207
  end
436
208
 
437
- ### remove_post
438
-
439
209
  #-- FIXME affects linking, building, deployment...
440
210
 
441
211
  def cmd_remove_post(arg, safe=true)
@@ -465,13 +235,9 @@ module RuneBlog::REPL
465
235
  raise "Problem mass-deleting file(s)" unless result
466
236
  end
467
237
  rescue => err
468
- puts err
469
- puts err.backtrace
470
- puts
238
+ error(err)
471
239
  end
472
240
 
473
- ### edit_post
474
-
475
241
  #-- FIXME affects linking, building, deployment...
476
242
 
477
243
  def cmd_edit_post(arg)
@@ -490,13 +256,9 @@ module RuneBlog::REPL
490
256
 
491
257
  rebuild_post(file)
492
258
  rescue => err
493
- puts err
494
- puts err.backtrace
495
- puts
259
+ error(err)
496
260
  end
497
261
 
498
- ### list_posts
499
-
500
262
  def cmd_list_posts(arg)
501
263
  raise "Glitch: Got an argument" if arg != []
502
264
  dir = @blog.viewdir(@view)
@@ -509,14 +271,10 @@ module RuneBlog::REPL
509
271
  posts.each {|post| puts " #{colored_slug(post)}" }
510
272
  end
511
273
  end
512
- rescue
513
- puts "Oops? cwd = #{Dir.pwd} dir = #{dir}"
514
- puts err.backtrace
515
- exit
274
+ rescue => err
275
+ error(err)
516
276
  end
517
277
 
518
- ### list_drafts
519
-
520
278
  def cmd_list_drafts(arg)
521
279
  raise "Glitch: Got an argument" if arg != []
522
280
  dir = "#@root/src"
data/lib/runeblog.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'livetext'
4
4
 
5
5
  class RuneBlog
6
- VERSION = "0.0.50"
6
+ VERSION = "0.0.51"
7
7
 
8
8
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
9
9
  DefaultData = Path + "/../data"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
@@ -47,8 +47,7 @@ files:
47
47
  - data/views/_default/custom/post_template.html
48
48
  - data/views/_default/deploy
49
49
  - data/views/_default/last_deployed
50
- - lib/blogcmds.rb
51
- - lib/prettiness.rb
50
+ - lib/helpers-repl.rb
52
51
  - lib/repl.rb
53
52
  - lib/runeblog.rb
54
53
  - runeblog.gemspec
data/lib/blogcmds.rb DELETED
@@ -1,76 +0,0 @@
1
- class RuneBlog::Command
2
- Patterns =
3
- {"help" => :cmd_help,
4
- "h" => :cmd_help,
5
-
6
- "version" => :cmd_version,
7
- "v" => :cmd_version,
8
-
9
- "list views" => :cmd_list_views,
10
- "lsv" => :cmd_list_views,
11
-
12
- "new view $name" => :cmd_new_view,
13
-
14
- "new post" => :cmd_new_post,
15
- "p" => :cmd_new_post,
16
- "post" => :cmd_new_post,
17
-
18
- "change view $name" => :cmd_change_view,
19
- "cv $name" => :cmd_change_view,
20
- "cv" => :cmd_change_view, # 0-arity must come second
21
-
22
- "list posts" => :cmd_list_posts,
23
- "lsp" => :cmd_list_posts,
24
-
25
- "list drafts" => :cmd_list_drafts,
26
- "lsd" => :cmd_list_drafts,
27
-
28
- "rm $postid" => :cmd_remove_post,
29
-
30
- "edit $postid" => :cmd_edit_post,
31
- "ed $postid" => :cmd_edit_post,
32
- "e $postid" => :cmd_edit_post,
33
-
34
- "preview" => :cmd_preview,
35
-
36
- "pre" => :cmd_preview,
37
-
38
- "browse" => :cmd_browse,
39
-
40
- "relink" => :cmd_relink,
41
-
42
- "rebuild" => :cmd_rebuild,
43
-
44
- "deploy" => :cmd_deploy,
45
-
46
- "q" => :cmd_quit,
47
- "quit" => :cmd_quit
48
- }
49
-
50
- Regexes = {}
51
- Patterns.each_pair do |pat, meth|
52
- rx = "^" + pat
53
- rx.gsub!(/ /, " +")
54
- rx.gsub!(/\$(\w+) */) { " *(?<#{$1}>\\w+)" }
55
- rx << "$"
56
- rx = Regexp.new(rx)
57
- Regexes[rx] = meth
58
- end
59
-
60
- def self.choose_method(cmd)
61
- found = nil
62
- params = []
63
- Regexes.each_pair do |rx, meth|
64
- m = cmd.match(rx)
65
- # puts "#{rx} =~ #{cmd.inspect} --> #{m.to_a.inspect}"
66
- result = m ? m.to_a : nil
67
- next unless result
68
- found = meth
69
- params = m[1..-1]
70
- end
71
- meth = found || :cmd_INVALID
72
- params = cmd if meth == :cmd_INVALID
73
- [meth, params]
74
- end
75
- end
76
-
data/lib/prettiness.rb DELETED
@@ -1,29 +0,0 @@
1
-
2
- # Reopening...
3
-
4
- module RuneBlog::REPL
5
- def clear
6
- puts "\e[H\e[2J" # clear screen
7
- end
8
-
9
- def red(text)
10
- "\e[31m#{text}\e[0m"
11
- end
12
-
13
- def blue(text)
14
- "\e[34m#{text}\e[0m"
15
- end
16
-
17
- def bold(str)
18
- "\e[1m#{str}\e[22m"
19
- end
20
-
21
- def interpolate(str)
22
- wrap = "<<-EOS\n#{str}\nEOS"
23
- eval wrap
24
- end
25
-
26
- def colored_slug(slug)
27
- red(slug[0..3])+blue(slug[4..-1])
28
- end
29
- end