runeblog 0.0.73 → 0.0.74

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: df36ffbf2e13e9b19e379adc0fe5fc9f8f0fdc94
4
- data.tar.gz: b5d337e0d026cb90207b9b3964e5810096a4162a
3
+ metadata.gz: 17a13b9ee6fc708cd9ff07fb2a47c0766f3c9480
4
+ data.tar.gz: 5f44f9d028f5d9c1a6d17e3a91df6108a50c97ec
5
5
  SHA512:
6
- metadata.gz: 66ad68e17c7567b0d96cf5165085e8dd033e05d6ca76911f3347fd6c06b6a9cf9579e6209c4e4e7e3a848a31f8523b64118d08f1ae8a95a22d0d0b4386339e30
7
- data.tar.gz: 4a81d99c13294445924017eadd958a1c25d95408a065c8a850597b12384eec33e34917f6b260bd1577d0cf5508195f1ffa5003f503690dba451c668bd60378e4
6
+ metadata.gz: d0c8fc2fa446cb59168bbbc5dfbf632169a2324ead513603abd810ae7985843853c8a14422803073e868bc4bf0909023199264617fe54fbc9ec273f6c7ed618d
7
+ data.tar.gz: c4a0bb0d1d47a4bd67801755544af8d1b85701793119957c920f3170746a1f5a0397228d90168c95a894010bae6f69e6426183a9eb3fb89eee563cc514091e51
data/bin/blog CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  $: << "./lib"
4
4
 
5
+ require 'readline'
6
+
5
7
  require 'repl'
6
8
 
7
9
  trap("INT") { }
@@ -28,9 +30,11 @@ print red("\n RuneBlog v #{RuneBlog::VERSION}")
28
30
  if cmd.nil? # REPL
29
31
  puts
30
32
  loop do
31
- print red("\nblog> ")
32
- cmd = gets
33
- cmd_quit([]) if cmd.nil? # ^D
33
+ # print red("\nblog> ")
34
+ # cmd = gets
35
+ cmd = Readline.readline(red("\nblog> "), true)
36
+
37
+ cmd_quit(nil) if cmd.nil? # ^D
34
38
  cmd.chomp!
35
39
  next if cmd.empty? # CR does nothing
36
40
  meth, params = RuneBlog::REPL.choose_method(cmd)
@@ -1 +1 @@
1
- RuneBlog v 0.0.73 2018-10-02
1
+ RuneBlog v 0.0.74 2018-10-02
@@ -11,26 +11,25 @@ class RuneBlog::Post
11
11
  result
12
12
  end
13
13
 
14
- def initialize(title, view_name,
15
- teaser = "Teaser goes here.",
16
- remainder = "Remainder of post goes here.")
14
+ def initialize(meta, view_name)
15
+ # FIXME weird logic here
17
16
  raise "RuneBlog.blog is not set!" if RuneBlog.blog.nil?
18
17
  @blog = RuneBlog.blog
19
- @title = title
18
+ @title = meta.title
20
19
  @view = @blog.str2view(view_name)
21
20
  @num, @slug = make_slug
22
21
  date = Time.now.strftime("%Y-%m-%d")
23
22
  template = <<-EOS.gsub(/^ */, "")
24
23
  .mixin liveblog
25
24
 
26
- .title #{title}
25
+ .title #@title
27
26
  .pubdate #{date}
28
27
  .views #@view
29
28
 
30
29
  .teaser
31
- #{teaser}
30
+ #{meta.teaser}
32
31
  .end
33
- #{remainder}
32
+ #{meta.remainder}
34
33
  EOS
35
34
 
36
35
  @draft = "#{@blog.root}/src/#@slug.lt3"
@@ -71,6 +70,8 @@ class RuneBlog::Post
71
70
  def create_post_subtree(vdir)
72
71
  create_dir("assets")
73
72
  File.write("metadata.yaml", @meta.to_yaml)
73
+ File.write("teaser.txt", @meta.teaser)
74
+ File.write("remainder.txt", @meta.remainder)
74
75
  template = File.read(vdir + "/custom/post_template.html")
75
76
  text = interpolate(template)
76
77
  File.write("index.html", text)
@@ -137,12 +137,12 @@ module RuneBlog::REPL
137
137
  reset_output
138
138
  # Simplify this
139
139
  if arg.nil?
140
- output "#{@blog.view}"
140
+ output bold(@blog.view)
141
141
  return @out
142
142
  else
143
143
  if @blog.view?(arg)
144
144
  @blog.view = arg
145
- output! "View: #{@blog.view}"
145
+ output red("View: ") + bold(@blog.view)
146
146
  end
147
147
  end
148
148
  @out
@@ -163,7 +163,9 @@ module RuneBlog::REPL
163
163
  reset_output
164
164
  check_empty(arg)
165
165
  title = ask("\nTitle: ")
166
- @blog.create_new_post(title)
166
+ meta = OpenStruct.new
167
+ meta.title = title
168
+ @blog.create_new_post(meta)
167
169
  nil
168
170
  rescue => err
169
171
  error(err)
@@ -172,7 +174,10 @@ module RuneBlog::REPL
172
174
  def cmd_kill(arg)
173
175
  reset_output
174
176
  args = arg.split
175
- args.each {|x| cmd_remove_post(x, false) }
177
+ args.each do |x|
178
+ # FIXME
179
+ cmd_remove_post(x, false)
180
+ end
176
181
  nil
177
182
  rescue => err
178
183
  error(err)
@@ -182,32 +187,14 @@ module RuneBlog::REPL
182
187
  #-- FIXME affects linking, building, deployment...
183
188
 
184
189
  def cmd_remove_post(arg, safe=true)
190
+ # FIXME - 'safe' is no longer a thing
185
191
  reset_output
186
192
  id = get_integer(arg)
187
- files = @blog.post_exists?(id)
188
- if files.nil?
193
+ result = @blog.remove_post(id)
194
+ if result.nil?
189
195
  output! "No such post found (#{id})"
190
196
  return @out
191
197
  end
192
-
193
- if safe
194
- output_newline
195
- files.each {|f| outstr " #{f}\n" }
196
- reset_output
197
- ques = "\n Delete?\n "
198
- ques.sub!(/\?/, " all these?") if files.size > 1
199
- yes = yesno red(ques)
200
- if yes
201
- @blog.remove_post(id)
202
- output! "Deleted\n"
203
- else
204
- output! "No action taken\n"
205
- end
206
- else
207
- @blog.remove_post(id)
208
- output! "Deleted:\n"
209
- files.each {|f| output " #{f}\n" }
210
- end
211
198
  @out
212
199
  rescue ArgumentError => err
213
200
  puts err
@@ -136,16 +136,17 @@ class RuneBlog
136
136
  end
137
137
 
138
138
  def files_by_id(id)
139
- files = Find.find(self.root).to_a
139
+ files = Find.find(self.view.dir).to_a
140
140
  tag = "#{'%04d' % id}"
141
141
  result = files.grep(/#{tag}-/)
142
142
  result
143
143
  end
144
144
 
145
- def create_new_post(title, testing = false, teaser = nil, remainder = nil)
146
- teaser ||= "Teaser goes here."
147
- remainder ||= "Remainder of post goes here."
148
- post = RuneBlog::Post.new(title, @view.to_s, teaser, remainder)
145
+ # def create_new_post(title, testing = false, teaser = nil, remainder = nil)
146
+ def create_new_post(meta, testing = false)
147
+ meta.teaser ||= "Teaser goes here."
148
+ meta.remainder ||= "Remainder of post goes here."
149
+ post = RuneBlog::Post.new(meta, @view.to_s)
149
150
  post.edit unless testing
150
151
  post.publish
151
152
  post.num
@@ -263,6 +264,7 @@ class RuneBlog
263
264
 
264
265
  def remove_post(num)
265
266
  list = files_by_id(num)
267
+ return nil if list.empty?
266
268
  result = system("rm -rf #{list.join(' ')}")
267
269
  error_cant_delete(files) unless result
268
270
  # FIXME - update index/etc
@@ -1,6 +1,6 @@
1
1
 
2
2
  class RuneBlog
3
- VERSION = "0.0.73"
3
+ VERSION = "0.0.74"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
@@ -47,14 +47,14 @@ class TestREPL < Minitest::Test
47
47
  out = cmd_list_drafts(nil)
48
48
  assert out.is_a?(String), "Expected a string returned"
49
49
  lines = out.split("\n").length
50
- assert lines >= 2, "Expecting more lines; got: #{out.inspect}"
50
+ assert lines == 7, "Expecting more lines; got: #{out.inspect}"
51
51
  end
52
52
 
53
53
  def test_006_lsp!
54
54
  out = cmd_list_posts(nil)
55
55
  assert out.is_a?(String), "Expected a string returned; got: #{out.inspect}"
56
56
  lines = out.split("\n").length
57
- assert lines >= 2, "Expecting more lines; got: #{out.inspect}"
57
+ assert lines == 6, "Expecting more lines; got: #{out.inspect}"
58
58
  end
59
59
 
60
60
  def test_007_parser
@@ -129,14 +129,19 @@ class TestREPL < Minitest::Test
129
129
  "After delete: #{sorted_views.inspect}"
130
130
  end
131
131
 
132
- def test_012_create_remove_post! # FIXME - several problems here
132
+ def test_012_create_remove_post!
133
133
  @blog.change_view("beta_view")
134
134
  assert @blog.view.to_s == "beta_view", "Expected beta_view"
135
135
  before = @blog.posts.size
136
- num = @blog.create_new_post("Uninteresting title", true)
136
+ meta = OpenStruct.new
137
+ meta.title = "Uninteresting title"
138
+ num = @blog.create_new_post(meta, true)
137
139
  assert @blog.posts.size == before + 1, "Don't see new post"
138
140
  @blog.remove_post(num)
139
141
  assert @blog.posts.size == before, "Failed to delete post"
140
142
  end
143
+
144
+ def test_013_kill_posts!
145
+ end
141
146
  end
142
147
 
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.73
4
+ version: 0.0.74
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton