runeblog 0.3.18 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/exceptions.rb +37 -0
- data/lib/helpers-repl.rb +2 -6
- data/lib/liveblog.rb +9 -11
- data/lib/post.rb +3 -3
- data/lib/processing.rb +1 -1
- data/lib/repl.rb +1 -9
- data/lib/runeblog.rb +1 -13
- data/lib/runeblog_version.rb +2 -15
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cfbb99881fa66be7a0bcdc30c24851bf8994f3586cd3e888f90da64266f5452
|
4
|
+
data.tar.gz: 64040a6450cab790bb2a7db4552ac610a526ea1ccd6d94319ae64c6cc6e3728d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3df66c1d14c3ccd732949fda5a2b6e9b65bcd5121b2a1de6a60b8d7a8a6c05e38bf4660da4b175268c6f7e9292b1941f5dd1985328ccc9d6180261b5a1b844
|
7
|
+
data.tar.gz: 6d673eeaeca255e66db6442551b03dc17817bd2f889e6de3401fda42e47ab426620be21d1647f22382b779be17c739dc981bdde848bb65391bd3018132be2658
|
data/lib/exceptions.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
def make_exception(sym, str, target_class = Object)
|
3
|
+
return if target_class.constants.include?(sym)
|
4
|
+
|
5
|
+
target_class.const_set(sym, StandardError.dup)
|
6
|
+
define_method(sym) do |*args|
|
7
|
+
msg = str.dup
|
8
|
+
args.each.with_index {|arg, i| msg.sub!("%#{i+1}", arg) }
|
9
|
+
target_class.class_eval(sym.to_s).new(msg)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
make_exception(:NotImplemented, "Feature not yet implemented")
|
14
|
+
make_exception(:CantOpen, "Can't open '%1'")
|
15
|
+
make_exception(:CantDelete, "Can't open '%1'")
|
16
|
+
make_exception(:InternalError, "Glitch: %1 got arg '%2'")
|
17
|
+
make_exception(:CantCopy, "Can't copy %1 to %2")
|
18
|
+
|
19
|
+
make_exception(:FileNotFound, "File %1 was not found")
|
20
|
+
make_exception(:FoundNeither, "Found neither %1 nor %2")
|
21
|
+
make_exception(:BlogRepoAlreadyExists, "Blog repo %1 already exists")
|
22
|
+
make_exception(:CantAssignView, "%1 is not a view")
|
23
|
+
make_exception(:ViewAlreadyExists, "View %1 already exists")
|
24
|
+
make_exception(:DirAlreadyExists, "Directory %1 already exists")
|
25
|
+
make_exception(:CantCreateDir, "Can't create directory %1")
|
26
|
+
make_exception(:EditorProblem, "Could not edit %1")
|
27
|
+
make_exception(:NoSuchView, "No such view: %1")
|
28
|
+
make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
|
29
|
+
make_exception(:ExpectedString, "Expected nonempty string but got %1 (%2)")
|
30
|
+
make_exception(:ExpectedView, "Expected string or View object but got %1 (%2)")
|
31
|
+
make_exception(:ExpectedInteger, "Expected integer but got %1 (%2)")
|
32
|
+
make_exception(:NoPostCall, "Method #post not called (no metadata)")
|
33
|
+
make_exception(:CantFindWidgetDir, "Can't find widget dir '%1'")
|
34
|
+
make_exception(:PublishError, "Error during publishing")
|
35
|
+
make_exception(:NoNumericPrefix, "No numeric prefix on slug '%1'")
|
36
|
+
make_exception(:NoExtensionExpected, "No file extension expected on '%1'")
|
37
|
+
|
data/lib/helpers-repl.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
make_exception(:CantOpen, "Can't open '$1'")
|
5
|
-
make_exception(:CantDelete, "Can't open '$1'")
|
6
|
-
make_exception(:InternalError, "Glitch: $1 got arg '$2'")
|
7
|
-
make_exception(:CantCopy, "Can't copy $1 to $2")
|
2
|
+
require 'exceptions'
|
8
3
|
|
4
|
+
# Reopening...
|
9
5
|
|
10
6
|
module RuneBlog::REPL
|
11
7
|
Patterns =
|
data/lib/liveblog.rb
CHANGED
@@ -36,7 +36,6 @@ def init_liveblog # FIXME - a lot of this logic sucks
|
|
36
36
|
rescue => err
|
37
37
|
STDERR.puts "err = #{err}"
|
38
38
|
STDERR.puts err.backtrace.join("\n")
|
39
|
-
# raise "Only works inside a blog repo"
|
40
39
|
end
|
41
40
|
|
42
41
|
##################
|
@@ -189,7 +188,7 @@ def banner
|
|
189
188
|
if File.exist?(src)
|
190
189
|
preprocess src: src, dst: file, call: ".nopara" # , vars: @blog.view.globals
|
191
190
|
else
|
192
|
-
raise
|
191
|
+
raise FoundNeither(file, src)
|
193
192
|
end
|
194
193
|
end
|
195
194
|
str2 << "<td>" + File.read(file) + "</td>" + "\n"
|
@@ -362,7 +361,7 @@ def inset
|
|
362
361
|
end
|
363
362
|
|
364
363
|
def title
|
365
|
-
raise
|
364
|
+
raise NoPostCall unless @meta
|
366
365
|
title = @_data.chomp
|
367
366
|
@meta.title = title
|
368
367
|
setvar :title, title
|
@@ -371,7 +370,7 @@ def title
|
|
371
370
|
end
|
372
371
|
|
373
372
|
def pubdate
|
374
|
-
raise
|
373
|
+
raise NoPostCall unless @meta
|
375
374
|
_debug "data = #@_data"
|
376
375
|
# Check for discrepancy?
|
377
376
|
match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
|
@@ -383,21 +382,21 @@ def pubdate
|
|
383
382
|
end
|
384
383
|
|
385
384
|
def tags
|
386
|
-
raise
|
385
|
+
raise NoPostCall unless @meta
|
387
386
|
_debug "args = #{_args}"
|
388
387
|
@meta.tags = _args.dup || []
|
389
388
|
_optional_blank_line
|
390
389
|
end
|
391
390
|
|
392
391
|
def views
|
393
|
-
raise
|
392
|
+
raise NoPostCall unless @meta
|
394
393
|
_debug "data = #{_args}"
|
395
394
|
@meta.views = _args.dup
|
396
395
|
_optional_blank_line
|
397
396
|
end
|
398
397
|
|
399
398
|
def pin
|
400
|
-
raise
|
399
|
+
raise NoPostCall unless @meta
|
401
400
|
_debug "data = #{_args}" # verify only valid views?
|
402
401
|
pinned = @_args
|
403
402
|
@meta.pinned = pinned
|
@@ -417,7 +416,7 @@ rescue => err
|
|
417
416
|
end
|
418
417
|
|
419
418
|
def write_post
|
420
|
-
raise
|
419
|
+
raise NoPostCall unless @meta
|
421
420
|
@meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
|
422
421
|
@meta.tags = @meta.tags.join(" ") if @meta.tags.is_a? Array
|
423
422
|
_write_metadata
|
@@ -427,7 +426,7 @@ rescue => err
|
|
427
426
|
end
|
428
427
|
|
429
428
|
def teaser
|
430
|
-
raise
|
429
|
+
raise NoPostCall unless @meta
|
431
430
|
text = _body.join("\n")
|
432
431
|
@meta.teaser = text
|
433
432
|
setvar :teaser, @meta.teaser
|
@@ -584,9 +583,8 @@ def sidebar
|
|
584
583
|
_body do |token|
|
585
584
|
tag = token.chomp.strip.downcase
|
586
585
|
wtag = "../../widgets"/tag
|
587
|
-
raise
|
586
|
+
raise CantFindWidgetDir(wtag) unless Dir.exist?(wtag)
|
588
587
|
tcard = "#{tag}-card.html"
|
589
|
-
|
590
588
|
case
|
591
589
|
when standard.include?(tag)
|
592
590
|
_handle_standard_widget(tag)
|
data/lib/post.rb
CHANGED
@@ -11,7 +11,7 @@ class RuneBlog::Post
|
|
11
11
|
|
12
12
|
def self.load(post)
|
13
13
|
log!(enter: __method__, args: [post], level: 3)
|
14
|
-
raise
|
14
|
+
raise NotImplemented
|
15
15
|
raise NoBlogAccessor if RuneBlog.blog.nil?
|
16
16
|
# "post" is a slug?
|
17
17
|
pdir = RuneBlog.blog.root/:drafts/post
|
@@ -87,8 +87,8 @@ class RuneBlog::ViewPost
|
|
87
87
|
attr_accessor :path, :title, :date, :teaser_text
|
88
88
|
|
89
89
|
def self.make(blog:, view:, nslug:)
|
90
|
-
raise
|
91
|
-
raise
|
90
|
+
raise NoNumericPrefix(nslug) unless nslug =~ /^\d{4}-/
|
91
|
+
raise NoExtensionExpected(nslug) if nslug.end_with?(".lt3") || nslug.end_with?(".html")
|
92
92
|
view = view.to_s
|
93
93
|
view.define_singleton_method :path do |subdir = ""|
|
94
94
|
str = blog.root/:views/view
|
data/lib/processing.rb
CHANGED
@@ -12,7 +12,7 @@ end
|
|
12
12
|
def stale?(src, dst, deps, force = false)
|
13
13
|
meh = File.new("/tmp/dammit-#{src.gsub(/\//, "-")}", "w")
|
14
14
|
log!(enter: __method__, args: [src, dst], level: 3)
|
15
|
-
raise "
|
15
|
+
raise FileNotFound("#{Dir.pwd}/#{src}") unless File.exist?(src)
|
16
16
|
return true if force
|
17
17
|
return true unless File.exist?(dst)
|
18
18
|
return true if newer?(src, dst)
|
data/lib/repl.rb
CHANGED
@@ -2,35 +2,28 @@ require 'runeblog'
|
|
2
2
|
require 'ostruct'
|
3
3
|
require 'helpers-repl' # FIXME structure
|
4
4
|
require 'pathmagic'
|
5
|
+
require 'exceptions'
|
5
6
|
|
6
7
|
require 'menus'
|
7
8
|
|
8
|
-
make_exception(:PublishError, "Error during publishing")
|
9
|
-
make_exception(:EditorProblem, "Could not edit $1")
|
10
|
-
|
11
9
|
Signal.trap("INT") { puts "Don't :)" }
|
12
10
|
|
13
11
|
module RuneBlog::REPL
|
14
12
|
def edit_file(file, vim: "")
|
15
|
-
# STDSCR.saveback
|
16
13
|
ed = @blog.editor
|
17
14
|
params = vim if ed =~ /vim$/
|
18
15
|
result = system!("#{@blog.editor} #{file} #{params}")
|
19
16
|
raise EditorProblem(file) unless result
|
20
|
-
# STDSCR.restback
|
21
17
|
cmd_clear
|
22
18
|
end
|
23
19
|
|
24
20
|
def cmd_quit
|
25
21
|
STDSCR.rows.times { puts " "*(STDSCR.cols-1) }
|
26
|
-
# FIXME please?
|
27
|
-
# sleep 0.1
|
28
22
|
STDSCR.clear
|
29
23
|
sleep 0.1
|
30
24
|
RubyText.stop
|
31
25
|
sleep 0.1
|
32
26
|
system("clear")
|
33
|
-
# sleep 0.1
|
34
27
|
exit
|
35
28
|
end
|
36
29
|
|
@@ -441,7 +434,6 @@ module RuneBlog::REPL
|
|
441
434
|
cmd = "cp #{name} #{@blog.root}/drafts/#@fname"
|
442
435
|
result = system!(cmd)
|
443
436
|
raise CantCopy(name, "#{@blog.root}/drafts/#@fname") unless result
|
444
|
-
# post = Post.load(@slug)
|
445
437
|
draft = "#{@blog.root}/drafts/#@fname"
|
446
438
|
@meta = @blog.generate_post(draft)
|
447
439
|
puts
|
data/lib/runeblog.rb
CHANGED
@@ -15,6 +15,7 @@ require 'publish'
|
|
15
15
|
require 'post'
|
16
16
|
|
17
17
|
require 'pathmagic'
|
18
|
+
require 'exceptions'
|
18
19
|
|
19
20
|
###
|
20
21
|
|
@@ -48,19 +49,6 @@ class RuneBlog
|
|
48
49
|
ConfigFile = "config"
|
49
50
|
Themes = RuneBlog::Path/"../themes"
|
50
51
|
|
51
|
-
make_exception(:FileNotFound, "File $1 was not found")
|
52
|
-
make_exception(:BlogRepoAlreadyExists, "Blog repo $1 already exists")
|
53
|
-
make_exception(:CantAssignView, "$1 is not a view")
|
54
|
-
make_exception(:ViewAlreadyExists, "View $1 already exists")
|
55
|
-
make_exception(:DirAlreadyExists, "Directory $1 already exists")
|
56
|
-
make_exception(:CantCreateDir, "Can't create directory $1")
|
57
|
-
make_exception(:EditorProblem, "Could not edit $1")
|
58
|
-
make_exception(:NoSuchView, "No such view: $1")
|
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
52
|
include ErrorChecks
|
65
53
|
|
66
54
|
class << self
|
data/lib/runeblog_version.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
if !defined?(RuneBlog::Path)
|
2
2
|
|
3
|
-
# if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
|
4
|
-
|
5
3
|
class RuneBlog
|
6
|
-
VERSION = "0.3.
|
4
|
+
VERSION = "0.3.19"
|
7
5
|
|
8
6
|
path = Gem.find_files("runeblog").grep(/runeblog-/).first
|
9
7
|
Path = File.dirname(path)
|
@@ -28,18 +26,7 @@ class RuneBlog
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
|
-
# Refactor, move
|
32
|
-
|
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
|
-
define_method(sym) do |*args|
|
38
|
-
msg = str.dup
|
39
|
-
args.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
|
40
|
-
target_class.class_eval(sym.to_s).new(msg)
|
41
|
-
end
|
42
|
-
end
|
29
|
+
# Refactor, move elsewhere?
|
43
30
|
|
44
31
|
def prefix(num)
|
45
32
|
log!(enter: __method__, args: [num], level: 3)
|
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.19
|
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-02-
|
11
|
+
date: 2020-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- empty_view/themes/standard/post/index.lt3
|
144
144
|
- empty_view/themes/standard/post/permalink.lt3
|
145
145
|
- lib/Javascript.stuff
|
146
|
+
- lib/exceptions.rb
|
146
147
|
- lib/helpers-blog.rb
|
147
148
|
- lib/helpers-repl.rb
|
148
149
|
- lib/liveblog.rb
|