runeblog 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/blog +24 -9
  3. data/data/VERSION +1 -1
  4. data/lib/runeblog.rb +57 -6
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5610e389e42975588026a817dbdccc04b202d9e
4
- data.tar.gz: 0f52e5f757a729bb01625ea05d88c23df5d7208c
3
+ metadata.gz: daf51824d3995af799d0e01ce97f9f83726f539b
4
+ data.tar.gz: a0bd0c5e7087b80a27f308d318343a8d174e2a8d
5
5
  SHA512:
6
- metadata.gz: d88699dbf12f1cc9d5efd0ef87b5866bb2f94ba27b35abc1b266403bc72d6cfffd5afee808dea7beb9d1bc19a27ff88138264b17bb81abc44586f85d62054b39
7
- data.tar.gz: 4ddad379e9c9eff2c0071aa1d6b8b14cef453c1d6c713abd056ce0ac2b87344543c9b11bc0950e3c871acaf22c0e6424e8ad909a48bc39a538f4c6cde96f1477
6
+ metadata.gz: ff8bb51ac1286a1a6d12501730024d47ac041ee078322d9c64c1f157688d66c7260b935982012c8d20dfac52eaae4febbc25fc1547f9416a3ac2c955e8795907
7
+ data.tar.gz: 6cf7e3c4eee1ada91f26439c470bb407f5d324399df5f827fe7fbefeb1b6e432563bb4bb43208b7c405815aa54a465910f3c6ef48342eb27a3664815fb182c36
data/bin/blog CHANGED
@@ -9,21 +9,14 @@ trap("INT") { }
9
9
  def execute_command
10
10
  case @meth
11
11
  when :help, :quit, :new_post, :list_views, :relink, :rebuild, :version,
12
- :list_posts, :do_nothing
12
+ :list_posts, :list_drafts, :do_nothing
13
13
  self.send(@meth)
14
- else
14
+ when Object
15
15
  self.send(@meth, @arg)
16
16
  end
17
17
  puts unless @meth == :do_nothing
18
18
  end
19
19
 
20
- def check(boolean, msg)
21
- save = @cmd
22
- @cmd = nil
23
- raise msg unless boolean
24
- @cmd = save
25
- end
26
-
27
20
  def expected(nw = 1)
28
21
  save = @cmd
29
22
  @cmd = nil
@@ -67,6 +60,9 @@ def parse_cmd
67
60
  when "lsp"
68
61
  @meth = :list_posts
69
62
  expected(1)
63
+ when "lsd"
64
+ @meth = :list_drafts
65
+ expected(1)
70
66
  when "relink"
71
67
  @meth = :relink
72
68
  expected(1)
@@ -77,7 +73,12 @@ def parse_cmd
77
73
  @meth = :version
78
74
  expected(1)
79
75
  when "cv"
76
+ raise "Too many arguments" if @words.size > 2
80
77
  @meth = :change_view
78
+ @arg = @words[1]
79
+ when "rm"
80
+ raise "Too many arguments" if @words.size > 2
81
+ @meth = :remove_post
81
82
  @arg = need_arg(1)
82
83
  when "list"
83
84
  case @words[1]
@@ -87,6 +88,9 @@ def parse_cmd
87
88
  when "posts"
88
89
  @meth = :list_posts
89
90
  expected(2)
91
+ when "drafts"
92
+ @meth = :list_drafts
93
+ expected(2)
90
94
  else
91
95
  @cmd = nil
92
96
  raise "Unknown #{@words[1]}"
@@ -104,6 +108,15 @@ def parse_cmd
104
108
  @cmd = nil
105
109
  raise "Unknown '#{@words[1]}'"
106
110
  end
111
+ when "change"
112
+ case @words[2]
113
+ when "view"
114
+ raise "Too many arguments" if @words.size > 3
115
+ @meth = :change_view
116
+ @arg = need_arg(2)
117
+ else
118
+ raise "Unknown '#{@words[1]}'"
119
+ end
107
120
  else
108
121
  @cmd = nil
109
122
  raise "Unknown '#{@words[0]}'"
@@ -134,6 +147,8 @@ def help
134
147
  p, post Create a new post
135
148
  new post Same as post (create a post)
136
149
  lsp, list posts List posts in current view
150
+ lsd, list drafts List all posts regardless of view
151
+ rm Remove a post
137
152
 
138
153
  relink Regenerate index for all views
139
154
  rebuild Regenerate all posts and relink
data/data/VERSION CHANGED
@@ -1 +1 @@
1
- RuneBlog v 0.0.16 2017-05-05 00:00:00 UTC
1
+ RuneBlog v 0.0.17 2017-05-06 00:00:00 UTC
data/lib/runeblog.rb CHANGED
@@ -1,6 +1,9 @@
1
+ require 'find'
2
+ require 'yaml'
3
+
1
4
 
2
5
  class RuneBlog
3
- VERSION = "0.0.16"
6
+ VERSION = "0.0.17"
4
7
 
5
8
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
9
  DefaultData = Path + "/../data"
@@ -30,8 +33,6 @@ end
30
33
 
31
34
  # FIXME lots of structure changes
32
35
 
33
- require 'yaml'
34
-
35
36
  =begin
36
37
 
37
38
  Post
@@ -81,7 +82,7 @@ end
81
82
 
82
83
  def new_blog!
83
84
  unless File.exist?(".blog")
84
- yn = ask("No .blog found. Create new blog?")
85
+ yn = ask(red(" No .blog found. Create new blog?"))
85
86
  if yn.upcase == "Y"
86
87
  #-- what if data already exists?
87
88
  system("cp -r #{RuneBlog::DefaultData} .")
@@ -270,7 +271,7 @@ end
270
271
  ### publish?
271
272
 
272
273
  def publish?
273
- yn = ask("Publish? y/n ")
274
+ yn = ask(red(" Publish? y/n "))
274
275
  yn.upcase == "Y"
275
276
  end
276
277
 
@@ -293,7 +294,9 @@ end
293
294
  ### change_view
294
295
 
295
296
  def change_view(arg = nil)
296
- if @config.views.include?(arg)
297
+ if arg.nil?
298
+ puts "\n #@view"
299
+ elsif @config.views.include?(arg)
297
300
  @view = arg
298
301
  else
299
302
  puts "view #{arg.inspect} does not exist"
@@ -307,6 +310,7 @@ def new_view(arg = nil)
307
310
  read_config unless @config
308
311
  arg ||= ask("New view: ") # check validity later
309
312
  raise "view #{arg} already exists" if @config.views.include?(arg)
313
+
310
314
  dir = @config.root + "/views/" + arg
311
315
  cmd = "mkdir -p #{dir}/custom"
312
316
  system(cmd)
@@ -354,6 +358,34 @@ def new_post
354
358
  end
355
359
  end
356
360
 
361
+ ### remove_post
362
+
363
+ #-- FIXME affects linking, building, deployment...
364
+
365
+ def remove_post(arg)
366
+ id = Integer(arg) rescue raise("'#{arg}' is not an integer")
367
+ tag = "#{'%04d' % id}-"
368
+ files = Find.find("#{@config.root}").to_a
369
+ files = files.grep(/#{tag}/)
370
+ if files.empty?
371
+ puts "\n No such post found"
372
+ return
373
+ end
374
+ puts
375
+ files.each {|f| puts " #{f}" }
376
+ yn = ask red("\n Delete all these? ")
377
+ if yn.downcase == "y"
378
+ #-- maybe implement trash later?
379
+ system("rm -rf #{files.join(' ')}")
380
+ puts red("\n Deleted")
381
+ else
382
+ puts red("\n No action taken")
383
+ end
384
+ rescue => err
385
+ puts err
386
+ puts
387
+ end
388
+
357
389
  ### list_posts
358
390
 
359
391
  def list_posts
@@ -372,4 +404,23 @@ rescue
372
404
  exit
373
405
  end
374
406
 
407
+ ### list_drafts
408
+
409
+ def list_drafts
410
+ dir = "#{@config.root}/src"
411
+ Dir.chdir(dir) do
412
+ posts = Dir.entries(".").grep(/^0.*.lt3/)
413
+ puts
414
+ if posts.empty?
415
+ puts "No posts"
416
+ else
417
+ posts.each {|post| puts " #{post.sub(/.lt3$/, "")}" }
418
+ end
419
+ end
420
+ rescue
421
+ puts "Oops? cwd = #{Dir.pwd} dir = #{dir}"
422
+ exit
423
+ end
424
+
425
+
375
426
 
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.16
4
+ version: 0.0.17
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-05 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A blog system based on Ruby and Livetext
14
14
  email: rubyhacker@gmail.com