runeblog 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/liveblog.rb +5 -2
- data/lib/repl.rb +2 -1
- data/lib/runeblog.rb +53 -24
- data/lib/runeblog_version.rb +7 -7
- data/lib/view.rb +0 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73212927ead8c75fce2cb37c6aa6cb8494b9c6b72b43bf75536c91c00c0600e
|
4
|
+
data.tar.gz: f13337605c83dca1916cf942a2d9b572c64fabd8a6ef2a6a06274c793717ed2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b3f0b41497bc7046b785f8e96f2ba78c5865e459d762c408145cea38ca014c8671652336ceadc58c6892afdea0b68c933b8c216f0e1375ac103e92fac82510e
|
7
|
+
data.tar.gz: f5b43e1afef44c9a4e7f61a965ad538ab780de79bc61a3f66f215c7f9f7e26b3842077ca6f4411f1c692029330ecce4f50afc8ead4daea8ec71301cd82b946f8
|
data/lib/liveblog.rb
CHANGED
@@ -89,6 +89,9 @@ def post_trailer
|
|
89
89
|
perma = _var("publish.proto") + "://" + _var("publish.server") +
|
90
90
|
"/" + _var("publish.path") + "/" + _var("post.aslug") +
|
91
91
|
".html"
|
92
|
+
Livetext::Vars.each_pair do |k,v|
|
93
|
+
STDERR.puts "#{k}: #{v.inspect}" unless k.is_a? Symbol
|
94
|
+
end
|
92
95
|
tags = _var("post.tags")
|
93
96
|
taglist = tags.empty? ? "" : "Tags: #{tags}"
|
94
97
|
|
@@ -140,7 +143,7 @@ def backlink
|
|
140
143
|
end
|
141
144
|
|
142
145
|
def code
|
143
|
-
lines =
|
146
|
+
lines = _body # _text
|
144
147
|
_out "<font size=+1><pre>\n#{lines}\n</pre></font>"
|
145
148
|
end
|
146
149
|
|
@@ -434,7 +437,7 @@ end
|
|
434
437
|
|
435
438
|
def teaser
|
436
439
|
raise "'post' was not called" unless @meta
|
437
|
-
text =
|
440
|
+
text = _body.join("\n")
|
438
441
|
@meta.teaser = text
|
439
442
|
setvar :teaser, @meta.teaser
|
440
443
|
if _args[0] == "dropcap" # FIXME doesn't work yet!
|
data/lib/repl.rb
CHANGED
@@ -6,6 +6,8 @@ require 'pathmagic'
|
|
6
6
|
make_exception(:PublishError, "Error during publishing")
|
7
7
|
make_exception(:EditorProblem, "Could not edit $1")
|
8
8
|
|
9
|
+
Signal.trap("INT") { puts "Don't :)" }
|
10
|
+
|
9
11
|
module RuneBlog::REPL
|
10
12
|
def edit_file(file, vim: "")
|
11
13
|
# STDSCR.saveback
|
@@ -183,7 +185,6 @@ module RuneBlog::REPL
|
|
183
185
|
end
|
184
186
|
|
185
187
|
def cmd_publish
|
186
|
-
# Future Hal says please refactor this
|
187
188
|
puts
|
188
189
|
unless @blog.view.can_publish?
|
189
190
|
msg = "Can't publish... see global.lt3"
|
data/lib/runeblog.rb
CHANGED
@@ -18,6 +18,30 @@ require 'pathmagic'
|
|
18
18
|
|
19
19
|
###
|
20
20
|
|
21
|
+
module ErrorChecks
|
22
|
+
def check_nonempty_string(str)
|
23
|
+
confirm(ExpectedString, str.inspect, str.class) { str.is_a?(String) && ! str.empty? }
|
24
|
+
end
|
25
|
+
|
26
|
+
def check_view_parameter(view)
|
27
|
+
confirm(ExpectedView, view, view.class) { view.is_a?(String) || view.is_a?(RuneBlog::View) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def check_integer(num)
|
31
|
+
confirm(ExpectedInteger, num, num.class) { num.is_a? Integer }
|
32
|
+
end
|
33
|
+
|
34
|
+
def confirm(exception, *args, &block)
|
35
|
+
# raise if block is NOT true
|
36
|
+
raise send(exception.to_s, *args) if ! block.call
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_error(exception, *args, &block)
|
40
|
+
# raise if block IS true
|
41
|
+
raise send(exception.to_s, *args) if block.call
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
21
45
|
class RuneBlog
|
22
46
|
|
23
47
|
DotDir = ".blogs"
|
@@ -33,10 +57,16 @@ class RuneBlog
|
|
33
57
|
make_exception(:EditorProblem, "Could not edit $1")
|
34
58
|
make_exception(:NoSuchView, "No such view: $1")
|
35
59
|
make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
|
60
|
+
make_exception(:ExpectedString, "Expected nonempty string but got $1 ($2)")
|
61
|
+
make_exception(:ExpectedView, "Expected string or View object but got $1 ($2)")
|
62
|
+
make_exception(:ExpectedInteger, "Expected integer but got $1 ($2)")
|
63
|
+
|
64
|
+
include ErrorChecks
|
36
65
|
|
37
66
|
class << self
|
38
67
|
attr_accessor :blog
|
39
68
|
include Helpers
|
69
|
+
include ErrorChecks
|
40
70
|
end
|
41
71
|
|
42
72
|
attr_reader :views, :sequence
|
@@ -77,10 +107,11 @@ class RuneBlog
|
|
77
107
|
|
78
108
|
def self.create_new_blog_repo(root_rel = ".blogs")
|
79
109
|
log!(enter: __method__, args: [root_rel])
|
80
|
-
|
110
|
+
check_nonempty_string(root_rel)
|
81
111
|
self.blog = self # Weird. Like a singleton - dumbass circular dependency?
|
82
112
|
repo_root = Dir.pwd/root_rel
|
83
|
-
|
113
|
+
check_error(BlogRepoAlreadyExists) { Dir.exist?(repo_root) }
|
114
|
+
|
84
115
|
create_dirs(repo_root)
|
85
116
|
Dir.chdir(repo_root) do
|
86
117
|
create_dirs(:data, :config, :drafts, :views, :posts)
|
@@ -237,19 +268,21 @@ class RuneBlog
|
|
237
268
|
|
238
269
|
def view?(name)
|
239
270
|
log!(enter: __method__, args: [name], level: 3)
|
240
|
-
|
271
|
+
check_nonempty_string(name)
|
241
272
|
views.any? {|x| x.name == name }
|
242
273
|
end
|
243
274
|
|
244
275
|
def view(name = nil)
|
245
276
|
log!(enter: __method__, args: [name], level: 3)
|
246
|
-
|
247
|
-
|
277
|
+
return @view if name.nil?
|
278
|
+
|
279
|
+
check_nonempty_string(name)
|
280
|
+
return str2view(name)
|
248
281
|
end
|
249
282
|
|
250
283
|
def str2view(str)
|
251
284
|
log!(enter: __method__, args: [str], level: 3)
|
252
|
-
|
285
|
+
check_nonempty_string(str) # redundant?
|
253
286
|
@views.find {|x| x.name == str }
|
254
287
|
end
|
255
288
|
|
@@ -273,7 +306,7 @@ class RuneBlog
|
|
273
306
|
_set_publisher
|
274
307
|
when String
|
275
308
|
new_view = str2view(arg)
|
276
|
-
|
309
|
+
check_error(NoSuchView, arg) { new_view.nil? }
|
277
310
|
@view = new_view
|
278
311
|
read_features(@view)
|
279
312
|
@view.get_globals
|
@@ -299,9 +332,8 @@ class RuneBlog
|
|
299
332
|
|
300
333
|
def viewdir(v = nil) # delete?
|
301
334
|
log!(enter: __method__, args: [v], level: 3)
|
302
|
-
|
303
|
-
|
304
|
-
raise ArgumentError unless v.nil? || v.is_a?(RuneBlog::View)
|
335
|
+
return @view if v.nil?
|
336
|
+
check_nonempty_string(v)
|
305
337
|
return @root/:views/v
|
306
338
|
end
|
307
339
|
|
@@ -336,14 +368,11 @@ class RuneBlog
|
|
336
368
|
|
337
369
|
def check_valid_new_view(view_name)
|
338
370
|
log!(enter: __method__, args: [view_name], level: 3)
|
339
|
-
|
340
|
-
raise ArgumentError if view_name.empty?
|
341
|
-
names = self.views.map(&:to_s)
|
342
|
-
bad = names.include?(view_name)
|
343
|
-
raise ViewAlreadyExists(view_name) if bad
|
371
|
+
check_nonempty_string(view_name)
|
344
372
|
vdir = @root/:views/view_name
|
345
|
-
|
346
|
-
|
373
|
+
check_error(ViewAlreadyExists, view_name) { self.views.map(&:to_s).include?(view_name) }
|
374
|
+
check_error(DirAlreadyExists, view_name) { Dir.exist?(vdir) }
|
375
|
+
return true
|
347
376
|
end
|
348
377
|
|
349
378
|
def create_view(view_name)
|
@@ -359,7 +388,7 @@ class RuneBlog
|
|
359
388
|
|
360
389
|
def delete_view(name, force = false)
|
361
390
|
log!(enter: __method__, args: [name, force])
|
362
|
-
|
391
|
+
check_nonempty_string(name)
|
363
392
|
if force
|
364
393
|
vname = @root/:views/name
|
365
394
|
system!("rm -rf #{vname}")
|
@@ -521,7 +550,7 @@ class RuneBlog
|
|
521
550
|
|
522
551
|
def change_view(view)
|
523
552
|
log!(enter: __method__, args: [view], level: 3)
|
524
|
-
|
553
|
+
check_view_parameter(view)
|
525
554
|
File.write(@root/"data/VIEW", view)
|
526
555
|
# write_repo_config
|
527
556
|
self.view = view # error checking?
|
@@ -529,7 +558,7 @@ class RuneBlog
|
|
529
558
|
|
530
559
|
def generate_index(view)
|
531
560
|
log!(enter: __method__, args: [view], pwd: true, dir: true)
|
532
|
-
|
561
|
+
check_view_parameter(view)
|
533
562
|
@vdir = @root/:views/view
|
534
563
|
num = collect_recent_posts
|
535
564
|
return num
|
@@ -701,7 +730,7 @@ class RuneBlog
|
|
701
730
|
|
702
731
|
def remove_post(num)
|
703
732
|
log!(enter: __method__, args: [num], level: 1)
|
704
|
-
|
733
|
+
check_integer(num)
|
705
734
|
# FIXME update original draft .views
|
706
735
|
tag = prefix(num)
|
707
736
|
files = Find.find(self.view.dir).to_a
|
@@ -718,7 +747,7 @@ class RuneBlog
|
|
718
747
|
|
719
748
|
def undelete_post(num)
|
720
749
|
log!(enter: __method__, args: [num], level: 1)
|
721
|
-
|
750
|
+
check_integer(num)
|
722
751
|
files = Find.find(@root/:views).to_a
|
723
752
|
tag = prefix(num)
|
724
753
|
list = files.select {|x| File.directory?(x) and x =~ /_#{tag}/ }
|
@@ -734,14 +763,14 @@ class RuneBlog
|
|
734
763
|
|
735
764
|
def delete_draft(num)
|
736
765
|
log!(enter: __method__, args: [num], level: 1)
|
737
|
-
|
766
|
+
check_integer(num)
|
738
767
|
tag = prefix(num)
|
739
768
|
system!("rm -rf #@root/drafts/#{tag}-*")
|
740
769
|
end
|
741
770
|
|
742
771
|
def make_slug(meta)
|
743
772
|
log!(enter: __method__, args: [meta], level: 3)
|
744
|
-
|
773
|
+
check_nonempty_string(meta.title)
|
745
774
|
label = '%04d' % meta.num # FIXME can do better
|
746
775
|
slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
747
776
|
str = "#{label}-#{slug0}"
|
data/lib/runeblog_version.rb
CHANGED
@@ -3,7 +3,7 @@ if !defined?(RuneBlog::Path)
|
|
3
3
|
# if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
|
4
4
|
|
5
5
|
class RuneBlog
|
6
|
-
VERSION = "0.3.
|
6
|
+
VERSION = "0.3.11"
|
7
7
|
|
8
8
|
path = Gem.find_files("runeblog").grep(/runeblog-/).first
|
9
9
|
Path = File.dirname(path)
|
@@ -30,14 +30,14 @@ end
|
|
30
30
|
|
31
31
|
# Refactor, move stuff elsewhere?
|
32
32
|
|
33
|
-
def make_exception(sym, str)
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def make_exception(sym, str, target_class = Object)
|
34
|
+
return if target_class.constants.include?(sym)
|
35
|
+
|
36
|
+
target_class.const_set(sym, StandardError.dup)
|
37
37
|
define_method(sym) do |*args|
|
38
|
-
msg = str
|
38
|
+
msg = str.dup
|
39
39
|
args.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
|
40
|
-
|
40
|
+
target_class.class_eval(sym.to_s).new(msg)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/lib/view.rb
CHANGED
@@ -42,24 +42,6 @@ class RuneBlog::View
|
|
42
42
|
@name
|
43
43
|
end
|
44
44
|
|
45
|
-
def publishable_files
|
46
|
-
log!(enter: __method__, level: 2)
|
47
|
-
vdir = dir()
|
48
|
-
remote = local_index()
|
49
|
-
files = [remote]
|
50
|
-
others = Dir.entries(vdir/:remote) - %w[. ..]
|
51
|
-
others.map! {|x| "#{vdir}/remote/#{x}" }
|
52
|
-
|
53
|
-
assets = Dir.entries("#{vdir}/assets") - %w[. ..]
|
54
|
-
assets.map! {|x| "#{vdir}/assets/#{x}" }
|
55
|
-
assets.reject! {|x| File.directory?(x) }
|
56
|
-
# assets.reject! {|x| ! recent?(x) }
|
57
|
-
files = files + others
|
58
|
-
all = files.dup
|
59
|
-
dirty = files.reject {|f| ! recent?(f) }
|
60
|
-
[dirty, all, assets]
|
61
|
-
end
|
62
|
-
|
63
45
|
def can_publish?
|
64
46
|
@can_publish
|
65
47
|
end
|
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.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|