runeblog 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helpers-blog.rb +7 -6
- data/lib/helpers-repl.rb +5 -79
- data/lib/post.rb +18 -24
- data/lib/runeblog_version.rb +1 -1
- 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: a7f74526fa315a736ee77fcc1bb3ca62a35dab08dea644e5d734239f2f285e14
|
4
|
+
data.tar.gz: 02bf784d0020ffd59e707cabc1fb4c1ff57c66d149405f3e83650ecaf836608d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4af84cc5d0c71b67c3d9aaf8ef76924057579193a08e516d3914e07bc1f99f8cc4689c7b4c0649290932d420fc1df84e4e918d8052dcff238ebd663119245a01
|
7
|
+
data.tar.gz: 72f5a4d0ac5cbaa68cf9e6df062d93485efb45735b501de8f89201880df1d6e1278aab4e4b41ae805e0bd7a73b3d5779a28a6507e885e95de0a9021dfd421385
|
data/lib/helpers-blog.rb
CHANGED
@@ -37,7 +37,9 @@ module RuneBlog::Helpers
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def get_views # read from filesystem
|
40
|
-
verify(
|
40
|
+
verify(@root => "#@root is nil",
|
41
|
+
Dir.exist?(@root) => "#@root doesn't exist",
|
42
|
+
Dir.exist?("#@root/views") => "#@root/views doesn't exist")
|
41
43
|
dirs = subdirs("#@root/views/").sort
|
42
44
|
dirs.map {|name| RuneBlog::View.new(name) }
|
43
45
|
end
|
@@ -57,17 +59,16 @@ module RuneBlog::Helpers
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def subdirs(dir)
|
62
|
+
verify(Dir.exist?(dir) => "Directory #{dir} not found")
|
60
63
|
dirs = Dir.entries(dir) - %w[. ..]
|
61
64
|
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
62
65
|
dirs
|
63
|
-
rescue => err
|
64
|
-
STDERR.puts "Can't find dir '#{dir}'"
|
65
|
-
puts err
|
66
|
-
puts err.backtrace
|
67
|
-
exit
|
68
66
|
end
|
69
67
|
|
70
68
|
def find_src_slugs
|
69
|
+
verify(@root => "#@root is nil",
|
70
|
+
Dir.exist?(@root) => "#@root doesn't exist",
|
71
|
+
Dir.exist?("#@root/src") => "#{@root/src} doesn't exist")
|
71
72
|
files = Dir.entries("#@root/src/").grep /\d{4}.*.lt3$/
|
72
73
|
files.map! {|f| File.basename(f) }
|
73
74
|
files = files.sort.reverse
|
data/lib/helpers-repl.rb
CHANGED
@@ -6,61 +6,8 @@ make_exception(:CantDelete, "Can't open '$1'")
|
|
6
6
|
make_exception(:InternalError, "Glitch: $1 got arg '$2'")
|
7
7
|
make_exception(:CantCopy, "Can't copy $1 to $2")
|
8
8
|
|
9
|
-
module WithANSI
|
10
|
-
def clear
|
11
|
-
puts "\e[H\e[2J" # clear screen # CHANGE_FOR_CURSES?
|
12
|
-
end
|
13
|
-
|
14
|
-
def red(text)
|
15
|
-
"\e[31m#{text}\e[0m" # CHANGE_FOR_CURSES?
|
16
|
-
end
|
17
|
-
|
18
|
-
def blue(text)
|
19
|
-
"\e[34m#{text}\e[0m" # CHANGE_FOR_CURSES?
|
20
|
-
end
|
21
|
-
|
22
|
-
def bold(str)
|
23
|
-
"\e[1m#{str}\e[22m" # CHANGE_FOR_CURSES?
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
module NoANSI
|
29
|
-
|
30
|
-
def gets
|
31
|
-
str = ""
|
32
|
-
loop do
|
33
|
-
ch = ::STDSCR.getch
|
34
|
-
if ch == 10
|
35
|
-
STDSCR.crlf
|
36
|
-
break
|
37
|
-
end
|
38
|
-
str << ch
|
39
|
-
end
|
40
|
-
str
|
41
|
-
end
|
42
|
-
|
43
|
-
def clear
|
44
|
-
# puts "\e[H\e[2J" # clear screen # CHANGE_FOR_CURSES?
|
45
|
-
end
|
46
|
-
|
47
|
-
def red(text)
|
48
|
-
text
|
49
|
-
end
|
50
|
-
|
51
|
-
def blue(text)
|
52
|
-
text
|
53
|
-
end
|
54
|
-
|
55
|
-
def bold(str)
|
56
|
-
str
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
9
|
|
61
10
|
module RuneBlog::REPL
|
62
|
-
include NoANSI
|
63
|
-
|
64
11
|
Patterns =
|
65
12
|
{"help" => :cmd_help,
|
66
13
|
"h" => :cmd_help,
|
@@ -130,7 +77,6 @@ module RuneBlog::REPL
|
|
130
77
|
params = nil
|
131
78
|
Regexes.each_pair do |rx, meth|
|
132
79
|
m = cmd.match(rx)
|
133
|
-
# puts "#{rx} =~ #{cmd.inspect} --> #{m.to_a.inspect}"
|
134
80
|
result = m ? m.to_a : nil
|
135
81
|
next unless result
|
136
82
|
found = meth
|
@@ -180,9 +126,9 @@ module RuneBlog::REPL
|
|
180
126
|
@out << str
|
181
127
|
end
|
182
128
|
|
183
|
-
def output!(str) #
|
129
|
+
def output!(str) # \n and indent
|
184
130
|
@out ||= ""
|
185
|
-
@out << " " +
|
131
|
+
@out << " " + str
|
186
132
|
end
|
187
133
|
|
188
134
|
def output_newline(n = 1)
|
@@ -215,11 +161,10 @@ module RuneBlog::REPL
|
|
215
161
|
end
|
216
162
|
|
217
163
|
def colored_slug(slug)
|
218
|
-
|
164
|
+
slug[0..3] + slug[4..-1]
|
219
165
|
end
|
220
166
|
|
221
167
|
def import(arg = nil)
|
222
|
-
# open_blog unless @blog
|
223
168
|
raise "Not implemented at present..."
|
224
169
|
arg = nil if arg == ""
|
225
170
|
arg ||= ask("Filename: ") # check validity later
|
@@ -239,6 +184,8 @@ module RuneBlog::REPL
|
|
239
184
|
end
|
240
185
|
|
241
186
|
def ask_publishing_info # returns Publishing object
|
187
|
+
verify(@blog => "@blog is nil",
|
188
|
+
@blog.view => "@blog.view is nil")
|
242
189
|
# user, server, root, path, protocol = "http"
|
243
190
|
puts "Please enter publishing data for view #{@blog.view}..."
|
244
191
|
user = ask("User: ")
|
@@ -251,27 +198,6 @@ module RuneBlog::REPL
|
|
251
198
|
RuneBlog::Publishing.new(user, server, root, path, proto)
|
252
199
|
end
|
253
200
|
|
254
|
-
def dumb_menu(array)
|
255
|
-
# { string => :meth, ... }
|
256
|
-
max = array.size
|
257
|
-
puts "\n Select from:" # CHANGE_FOR_CURSES?
|
258
|
-
array.each.with_index do |string, i|
|
259
|
-
puts " #{red('%2d' % (i+1))} #{string}" # CHANGE_FOR_CURSES?
|
260
|
-
end
|
261
|
-
picked = nil
|
262
|
-
loop do
|
263
|
-
print red("> ") # CHANGE_FOR_CURSES?
|
264
|
-
num = gets.to_i
|
265
|
-
if num.between?(1, max)
|
266
|
-
picked = array[num-1]
|
267
|
-
break
|
268
|
-
else
|
269
|
-
puts "Huh? Must be 1 to #{max}" # CHANGE_FOR_CURSES?
|
270
|
-
end
|
271
|
-
end
|
272
|
-
picked
|
273
|
-
end
|
274
|
-
|
275
201
|
### find_asset
|
276
202
|
|
277
203
|
# FIXME is this per-post?
|
data/lib/post.rb
CHANGED
@@ -19,15 +19,21 @@ class RuneBlog::Post
|
|
19
19
|
# FIXME weird logic here
|
20
20
|
raise NoBlogAccessor if RuneBlog.blog.nil?
|
21
21
|
pdir = RuneBlog.blog.view.dir + "/" + post
|
22
|
+
verify(Dir.exist?(pdir) => "Directory #{pdir} not found")
|
22
23
|
meta = nil
|
23
24
|
Dir.chdir(pdir) do
|
25
|
+
verify(File.exist?("metadata.txt") => "metadata.txt not found",
|
26
|
+
File.exist?("teaser.txt") => "teaser.txt not found",
|
27
|
+
File.exist?("body.txt") => "body.txt not found")
|
24
28
|
meta = read_config("metadata.txt")
|
29
|
+
verify(meta.date => "meta.date is nil",
|
30
|
+
meta.views => "meta.views is nil",
|
31
|
+
meta.tags => "meta.tags is nil")
|
25
32
|
meta.date = Date.parse(meta.date)
|
26
33
|
meta.views = meta.views.split
|
27
34
|
meta.tags = meta.tags.split
|
28
35
|
meta.teaser = File.read("teaser.txt")
|
29
36
|
meta.body = File.read("body.txt")
|
30
|
-
check_meta(meta, "Post.load")
|
31
37
|
end
|
32
38
|
meta
|
33
39
|
end
|
@@ -61,7 +67,6 @@ class RuneBlog::Post
|
|
61
67
|
end
|
62
68
|
|
63
69
|
def initialize
|
64
|
-
debug "=== Post#initialize"
|
65
70
|
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
66
71
|
end
|
67
72
|
|
@@ -70,12 +75,14 @@ class RuneBlog::Post
|
|
70
75
|
post = self.new
|
71
76
|
post.new_metadata(title)
|
72
77
|
post.create_draft
|
73
|
-
post.create_post_subtree
|
74
|
-
#
|
78
|
+
post.create_post_subtree
|
79
|
+
# post.build is not called here! It is called
|
80
|
+
# in runeblog.rb:create_new_post AFTER post.edit
|
75
81
|
post
|
76
82
|
end
|
77
83
|
|
78
84
|
def new_metadata(title)
|
85
|
+
verify(title.is_a?(String) => "Title #{title.inspect} is not a string")
|
79
86
|
meta = OpenStruct.new
|
80
87
|
meta.title = title
|
81
88
|
meta.teaser = "Teaser goes here."
|
@@ -83,8 +90,7 @@ class RuneBlog::Post
|
|
83
90
|
meta.pubdate = Time.now.strftime("%Y-%m-%d")
|
84
91
|
meta.date = meta.pubdate # fix later
|
85
92
|
meta.views = [@blog.view.to_s]
|
86
|
-
#
|
87
|
-
meta.num = @blog.next_sequence
|
93
|
+
meta.num = @blog.next_sequence # ONLY place next_sequence is called!
|
88
94
|
@blog.make_slug(meta) # adds to meta
|
89
95
|
@meta = meta
|
90
96
|
end
|
@@ -92,28 +98,16 @@ class RuneBlog::Post
|
|
92
98
|
def create_draft
|
93
99
|
html = RuneBlog.post_template(title: @meta.title, date: @meta.pubdate,
|
94
100
|
view: @meta.view, teaser: @meta.teaser, body: @meta.body)
|
95
|
-
|
101
|
+
srcdir = "#{@blog.root}/src/"
|
102
|
+
verify(Dir.exist?(srcdir) => "#{srcdir} not found",
|
103
|
+
@meta.slug.is_a?(String) => "slug #{@meta.slug.inspect} is invalid")
|
104
|
+
fname = @meta.slug + ".lt3"
|
105
|
+
@draft = srcdir + fname
|
96
106
|
dump(html, @draft)
|
97
107
|
end
|
98
108
|
|
99
|
-
def old_initialize(meta, view_name)
|
100
|
-
# FIXME weird logic here
|
101
|
-
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
102
|
-
@blog.make_slug(meta) # Post#initialize
|
103
|
-
check_meta(meta, "Post#initialize")
|
104
|
-
html = RuneBlog.post_template(title: meta.title, date: meta.pubdate,
|
105
|
-
view: meta.view, teaser: meta.teaser,
|
106
|
-
body: meta.body)
|
107
|
-
slug = meta.slug
|
108
|
-
@meta = meta
|
109
|
-
@draft = "#{@blog.root}/src/#{slug}.lt3"
|
110
|
-
dump(html, @draft)
|
111
|
-
rescue => err
|
112
|
-
puts err
|
113
|
-
puts err.backtrace
|
114
|
-
end
|
115
|
-
|
116
109
|
def edit
|
110
|
+
verify(File.exist?(@draft) => "File #{@draft} not found")
|
117
111
|
result = system("vi #@draft +8") # TODO improve this
|
118
112
|
raise EditorProblem(draft) unless result
|
119
113
|
nil
|
data/lib/runeblog_version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|