runeblog 0.0.35 → 0.0.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/bin/blog +6 -0
  3. data/data/VERSION +1 -1
  4. data/lib/repl.rb +36 -18
  5. data/lib/runeblog.rb +1 -1
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20a50ba1851a59956f6e0a5f8e4e7336eb3d281d
4
- data.tar.gz: b8daf3b75311b8c994d1cd0c83ca1b2ef197f31b
3
+ metadata.gz: e19eec4f87d0fab4e7dd17b00fa111a2d172fdee
4
+ data.tar.gz: cebb305793b13c5cb6cf2bb7e86f6fc9f7d959a6
5
5
  SHA512:
6
- metadata.gz: c6799ffd887af0552c87aedfaedfda1109c38ddd106709b957000a8c42a410f0c8024cd391c1a41c0a48e046ffd9f8534e7af905abd89f56860d0eb572d22eb7
7
- data.tar.gz: 6a447ba64c6327f20bbdfde0421d5782575180ca80f2b0ea85ebbab3e65b2b6ac728859d84f281ed8673eda7040200d7200e8173afbce675d01d3ff3135f96b8
6
+ metadata.gz: 5d5280f1c281f3b374dbaa8faeb3a443a585b47dd9c9882b783f6f4271c8b360365204b7763331518512e17b6faa1245c768dc44c7741ae7a31d9a44e9668823
7
+ data.tar.gz: f3b7fe2f1f8b49a8b6e71db269e2577fba7ca08fa145ebda39224114ae49d9bb25d11aac2567b71a15e09c689205da0b14457f827480c86b7b886bf1b3c2636f
data/bin/blog CHANGED
@@ -107,6 +107,11 @@ def handle_change
107
107
  end
108
108
  end
109
109
 
110
+ def handle_multi_rm
111
+ raise "Need at least one arg" unless @words.size >= 2
112
+ @words[1..-1].each {|arg| remove_post(arg) }
113
+ end
114
+
110
115
  def parse_cmd
111
116
  @cmd = gets.chomp
112
117
  @arg = ""
@@ -129,6 +134,7 @@ def parse_cmd
129
134
  when "version"; expect_w(:version)
130
135
  when "cv"; expect_w_arg(:change_view, true)
131
136
  when "rm"; expect_w_arg(:remove_post)
137
+ when "kill"; handle_multi_rm
132
138
  when "e", "edit"; expect_w_arg(:edit_post)
133
139
  when "open"; handle_open
134
140
  when "list"; handle_list
data/data/VERSION CHANGED
@@ -1 +1 @@
1
- RuneBlog v 0.0.35 2017-05-15
1
+ RuneBlog v 0.0.36 2017-05-16
data/lib/repl.rb CHANGED
@@ -145,7 +145,7 @@ Remainder of post goes here.
145
145
  ### open_local
146
146
 
147
147
  def open_local
148
- system("open #{@config.viewdir(@view)}/index.html")
148
+ result = system("open #{@config.viewdir(@view)}/index.html")
149
149
  raise "Problem opening #{@config.viewdir(@view)}/index.html" unless result
150
150
  rescue => err
151
151
  puts red("\n Error: (line #{__LINE__} of #{File.basename(__FILE__)}) ") + err.to_s
@@ -164,6 +164,8 @@ Remainder of post goes here.
164
164
  files = ["#{vdir}/index.html"]
165
165
  files += Dir.entries(vdir).grep(/^\d\d\d\d/).map {|x| "#{vdir}/#{x}" }
166
166
  files.reject! {|f| File.mtime(f) < File.mtime("#{vdir}/last_deployed") }
167
+ return puts red("\n No files to deploy") if files.empty?
168
+
167
169
  puts "\n Files:"
168
170
  files.each {|f| puts " " + f }
169
171
  puts
@@ -258,9 +260,11 @@ Remainder of post goes here.
258
260
  # Create dir using slug (index.html, metadata?)
259
261
  vdir = @config.viewdir(view)
260
262
  dir = vdir + @meta.slug + "/"
261
- cmd = "mkdir -p #{dir}"
262
- result = system(cmd) unless File.exist?(dir) and File.directory?(dir)
263
- raise "Can't create #{dir}" unless result
263
+ unless File.exist?(dir) and File.directory?(dir)
264
+ cmd = "mkdir -p #{dir}"
265
+ result = system(cmd)
266
+ raise "Can't create #{dir}" unless result
267
+ end
264
268
 
265
269
  File.write("#{dir}/metadata.yaml", @meta.to_yaml)
266
270
  template = File.read(vdir + "custom/post_template.html")
@@ -347,10 +351,14 @@ Remainder of post goes here.
347
351
  def change_view(arg = nil)
348
352
  if arg.nil?
349
353
  puts "\n #@view"
350
- elsif @config.views.include?(arg)
351
- @view = arg
352
354
  else
353
- puts "view #{arg.inspect} does not exist"
355
+ list = @config.views.grep /^#{arg}/
356
+ if list.size == 1
357
+ @view = list.first
358
+ puts red("\n View: #{@view}") if arg != @view
359
+ else
360
+ puts "view #{arg.inspect} does not exist"
361
+ end
354
362
  end
355
363
  rescue => err
356
364
  puts red("\n Error: (line #{__LINE__} of #{File.basename(__FILE__)}) ") + err.to_s
@@ -421,28 +429,38 @@ Remainder of post goes here.
421
429
  puts red("\n Error: (line #{__LINE__} of #{File.basename(__FILE__)}) ") + err.to_s
422
430
  end
423
431
 
432
+ ### remove_multiple_posts
433
+
434
+ def remove_multiple_posts(*args)
435
+ args.each {|arg| remove_post(arg, false) }
436
+ end
437
+
424
438
  ### remove_post
425
439
 
426
440
  #-- FIXME affects linking, building, deployment...
427
441
 
428
- def remove_post(arg)
442
+ def remove_post(arg, safe=true)
429
443
  id = Integer(arg) rescue raise("'#{arg}' is not an integer")
430
444
  tag = "#{'%04d' % id}-"
431
445
  files = Find.find(@root).to_a
432
446
  files = files.grep(/#{tag}/)
433
447
  return puts red("\n No such post found") if files.empty?
434
448
 
435
- puts
436
- files.each {|f| puts " #{f}" }
437
- ques = files.size > 1 ? "\n Delete all these? " : "\n Delete? "
438
- yn = ask red(ques)
439
- if yn.downcase == "y" #-- maybe implement trash later?
440
- result = system("rm -rf #{files.join(' ')}")
441
- raise "Problem deleting file(s)" unless result
442
-
443
- puts red("\n Deleted")
449
+ if safe
450
+ puts
451
+ files.each {|f| puts " #{f}" }
452
+ ques = files.size > 1 ? "\n Delete all these? " : "\n Delete? "
453
+ yn = ask red(ques)
454
+ if yn.downcase == "y"
455
+ result = system("rm -rf #{files.join(' ')}")
456
+ raise "Problem deleting file(s)" unless result
457
+ puts red("\n Deleted")
458
+ else
459
+ puts red("\n No action taken")
460
+ end
444
461
  else
445
- puts red("\n No action taken")
462
+ result = system("rm -rf #{files.join(' ')}")
463
+ raise "Problem mass-deleting file(s)" unless result
446
464
  end
447
465
  rescue => err
448
466
  puts err
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.35"
6
+ VERSION = "0.0.36"
7
7
 
8
8
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
9
9
  DefaultData = Path + "/../data"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-15 00:00:00.000000000 Z
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext