runeblog 0.0.57 → 0.0.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +1 -0
- data/data/VERSION +1 -1
- data/lib/helpers-repl.rb +58 -0
- data/lib/repl.rb +110 -85
- data/lib/runeblog.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d32821f8f0c5a59dd18a91b23edbb0927ca5bcb3
|
4
|
+
data.tar.gz: e5cb288cad3ac1781b09ea671b44c22d6c022281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ef8da1f243feda7aae4b2c3dd75dacd7aa6de42ced265b1c016f6a2ed2f8adf971a2a381c295cc3183ad45dd185d56323c4b7549faf867da3c82cbb789b4a2
|
7
|
+
data.tar.gz: 3f85f7fdcb768c77c34a0d92b3dd10a8c2917601e1fc6226edad0214887b3e1ccf2398d27a4cdb4dece15d9645eb9c510a9a61ca682feb1e30bd4afc09ebccc3
|
data/bin/blog
CHANGED
data/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RuneBlog v 0.0.
|
1
|
+
RuneBlog v 0.0.58 2018-09-13
|
data/lib/helpers-repl.rb
CHANGED
@@ -99,6 +99,64 @@ module RuneBlog::REPL
|
|
99
99
|
STDIN.gets.chomp.upcase[0] == "Y"
|
100
100
|
end
|
101
101
|
|
102
|
+
def reset_output(initial = "")
|
103
|
+
@out ||= ""
|
104
|
+
@out.replace initial
|
105
|
+
end
|
106
|
+
|
107
|
+
def flush_output(initial = "")
|
108
|
+
@out ||= ""
|
109
|
+
puts @out
|
110
|
+
reset_output
|
111
|
+
end
|
112
|
+
|
113
|
+
def output(str) # \n and indent
|
114
|
+
@out ||= ""
|
115
|
+
@out << "\n " + str
|
116
|
+
end
|
117
|
+
|
118
|
+
def outstr(str) # \n and indent
|
119
|
+
@out ||= ""
|
120
|
+
@out << str
|
121
|
+
end
|
122
|
+
|
123
|
+
def output!(str) # red, \n and indent
|
124
|
+
@out ||= ""
|
125
|
+
@out << "\n " + red(str)
|
126
|
+
end
|
127
|
+
|
128
|
+
def output_newline(n = 1)
|
129
|
+
@out ||= ""
|
130
|
+
n.times { @out << "\n" }
|
131
|
+
end
|
132
|
+
|
133
|
+
FileNotFound = StandardError.dup
|
134
|
+
CantOpen = StandardError.dup
|
135
|
+
CantDelete = StandardError.dup
|
136
|
+
|
137
|
+
def check_empty(arg)
|
138
|
+
raise "Glitch: #{caller[0]} got arg #{arg.inspect}" unless arg.nil?
|
139
|
+
end
|
140
|
+
|
141
|
+
def get_integer(arg)
|
142
|
+
Integer(arg)
|
143
|
+
rescue
|
144
|
+
raise ArgumentError, "'#{arg}' is not an integer"
|
145
|
+
end
|
146
|
+
|
147
|
+
def check_file_exists(file)
|
148
|
+
raise FileNotFound, file unless File.exist?(file)
|
149
|
+
end
|
150
|
+
|
151
|
+
def error_cant_delete(files)
|
152
|
+
case files
|
153
|
+
when String
|
154
|
+
raise CantDelete, "Error deleting #{files}"
|
155
|
+
when Array
|
156
|
+
raise CantDelete, "Error deleting: \n#{files.join("\n")}"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
102
160
|
def clear
|
103
161
|
puts "\e[H\e[2J" # clear screen
|
104
162
|
end
|
data/lib/repl.rb
CHANGED
@@ -5,63 +5,49 @@ require 'helpers-repl' # FIXME structure
|
|
5
5
|
module RuneBlog::REPL
|
6
6
|
|
7
7
|
def cmd_quit(arg)
|
8
|
-
|
9
|
-
|
10
|
-
exit
|
8
|
+
check_empty(arg)
|
9
|
+
abort "\n "
|
11
10
|
end
|
12
11
|
|
13
12
|
def cmd_version(arg)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def new_blog!(arg) # FIXME weird?
|
19
|
-
raise "Glitch: #{__callee__} got arg #{arg.inspect}" unless arg.nil?
|
20
|
-
return if RuneBlog.exist?
|
21
|
-
yn = yesno(red(" No .blog found. Create new blog? "))
|
22
|
-
RuneBlog.create_new_blog if yn
|
23
|
-
rescue => err
|
24
|
-
error(err)
|
25
|
-
end
|
26
|
-
|
27
|
-
def open_blog # Crude - FIXME later
|
28
|
-
@blog = RuneBlog.new
|
29
|
-
@view = @blog.view # current view
|
30
|
-
@sequence = @blog.sequence
|
31
|
-
@root = @blog.root
|
32
|
-
@blog
|
33
|
-
rescue => err
|
34
|
-
error(err)
|
13
|
+
reset_output
|
14
|
+
check_empty(arg)
|
15
|
+
output RuneBlog::VERSION
|
16
|
+
return @out
|
35
17
|
end
|
36
18
|
|
37
19
|
def cmd_browse
|
38
|
-
|
20
|
+
reset_output
|
21
|
+
check_empty(arg)
|
39
22
|
@deploy ||= {}
|
40
23
|
return puts red("\n Deploy first.") unless @deploy[@view]
|
41
24
|
|
42
25
|
lines = @deploy[@view]
|
43
26
|
user, server, sroot, spath = *lines
|
44
|
-
|
45
|
-
|
27
|
+
url = "http://#{server}/#{spath}"
|
28
|
+
result = system("open '#{url}'")
|
29
|
+
raise CantOpen, url unless result
|
46
30
|
nil
|
47
31
|
rescue => err
|
48
32
|
error(err)
|
49
33
|
end
|
50
34
|
|
51
35
|
def cmd_open_local
|
52
|
-
|
53
|
-
|
54
|
-
|
36
|
+
reset_output
|
37
|
+
local = @blog.viewdir(@view) + "/index.html"
|
38
|
+
result = system("open #{local}")
|
39
|
+
raise CantOpen, local unless result
|
55
40
|
rescue => err
|
56
41
|
error(err)
|
57
42
|
end
|
58
43
|
|
59
44
|
def cmd_deploy(arg) # FIXME non-string return expected in caller?
|
60
45
|
# TBD clunky FIXME
|
61
|
-
|
46
|
+
reset_output
|
47
|
+
check_empty(arg)
|
62
48
|
@deploy ||= {}
|
63
49
|
deployment = @blog.viewdir(@view) + "deploy"
|
64
|
-
|
50
|
+
check_file_exists(deployment)
|
65
51
|
|
66
52
|
lines = File.readlines(deployment).map {|x| x.chomp }
|
67
53
|
@deploy[@view] = lines
|
@@ -75,27 +61,28 @@ module RuneBlog::REPL
|
|
75
61
|
return nil
|
76
62
|
end
|
77
63
|
|
78
|
-
|
79
|
-
files.each {|f|
|
80
|
-
|
64
|
+
output "Files:"
|
65
|
+
files.each {|f| output " #{f}\n" }
|
66
|
+
output_newline
|
81
67
|
dir = "#{sroot}/#{spath}"
|
82
68
|
# FIXME - may or may not already exist
|
83
69
|
result = system("ssh root@#{server} mkdir #{dir}")
|
84
70
|
|
85
71
|
cmd = "scp -r #{files.join(' ')} root@#{server}:#{dir} >/dev/null 2>&1"
|
86
|
-
|
72
|
+
output! "Deploying #{files.size} files...\n"
|
87
73
|
result = system(cmd)
|
88
74
|
raise "Problem occurred in deployment" unless result
|
89
75
|
|
90
76
|
File.write("#{vdir}/last_deployed", files)
|
91
|
-
|
92
|
-
out
|
77
|
+
output! "...finished.\n"
|
78
|
+
@out
|
93
79
|
rescue => err
|
94
80
|
error(err)
|
95
81
|
end
|
96
82
|
|
97
83
|
def cmd_rebuild(arg)
|
98
|
-
|
84
|
+
reset_output
|
85
|
+
check_empty(arg)
|
99
86
|
puts
|
100
87
|
files = Dir.entries("#@root/src/").grep /\d\d\d\d.*.lt3$/
|
101
88
|
files.map! {|f| File.basename(f) }
|
@@ -107,7 +94,8 @@ module RuneBlog::REPL
|
|
107
94
|
end
|
108
95
|
|
109
96
|
def cmd_relink(arg)
|
110
|
-
|
97
|
+
reset_output
|
98
|
+
check_empty(arg)
|
111
99
|
@blog.views.each {|view| generate_index(view) }
|
112
100
|
nil
|
113
101
|
rescue => err
|
@@ -115,34 +103,36 @@ module RuneBlog::REPL
|
|
115
103
|
end
|
116
104
|
|
117
105
|
def cmd_list_views(arg)
|
106
|
+
reset_output("\n")
|
107
|
+
check_empty(arg)
|
118
108
|
abort "Config file not read" unless @blog
|
119
|
-
|
120
|
-
out
|
121
|
-
@blog.views.each {|v| out << " #{v}\n" }
|
122
|
-
out
|
109
|
+
@blog.views.each {|v| outstr " #{v}\n" }
|
110
|
+
@out
|
123
111
|
rescue => err
|
124
112
|
error(err)
|
125
113
|
end
|
126
114
|
|
127
115
|
def cmd_change_view(arg)
|
116
|
+
reset_output
|
128
117
|
if arg.nil?
|
129
|
-
|
118
|
+
output "#{@blog.view}"
|
119
|
+
return @out
|
130
120
|
else
|
131
|
-
out = ""
|
132
121
|
list = @blog.views.grep /^#{arg}/
|
133
122
|
if list.size == 1
|
134
123
|
@view = @blog.view = list.first
|
135
|
-
|
124
|
+
output! "View: #{@view}\n" if arg != @view
|
136
125
|
else
|
137
|
-
|
126
|
+
output! "view #{arg.inspect} does not exist\n"
|
138
127
|
end
|
139
128
|
end
|
140
|
-
out
|
129
|
+
@out
|
141
130
|
rescue => err
|
142
131
|
error(err)
|
143
132
|
end
|
144
133
|
|
145
134
|
def cmd_new_view(arg)
|
135
|
+
reset_output
|
146
136
|
@blog ||= open_blog
|
147
137
|
arg ||= ask("New view: ") # check validity later
|
148
138
|
raise "view #{arg} already exists" if @blog.views.include?(arg)
|
@@ -162,7 +152,8 @@ module RuneBlog::REPL
|
|
162
152
|
end
|
163
153
|
|
164
154
|
def cmd_new_post(arg)
|
165
|
-
|
155
|
+
reset_output
|
156
|
+
check_empty(arg)
|
166
157
|
open_blog unless @blog # duh?
|
167
158
|
@title = ask("Title: ")
|
168
159
|
@blog.create_new_post(@title)
|
@@ -171,6 +162,7 @@ module RuneBlog::REPL
|
|
171
162
|
end
|
172
163
|
|
173
164
|
def cmd_kill(arg)
|
165
|
+
reset_output
|
174
166
|
args = arg.split
|
175
167
|
args.each {|x| cmd_remove_post([x], false) }
|
176
168
|
nil
|
@@ -181,37 +173,43 @@ module RuneBlog::REPL
|
|
181
173
|
#-- FIXME affects linking, building, deployment...
|
182
174
|
|
183
175
|
def cmd_remove_post(arg, safe=true)
|
184
|
-
|
185
|
-
|
176
|
+
reset_output
|
177
|
+
err = "'#{arg}' is not an integer"
|
178
|
+
id = get_integer(arg)
|
186
179
|
tag = "#{'%04d' % id}"
|
187
180
|
files = Find.find(@root).to_a
|
188
181
|
files = files.grep(/#{tag}-/)
|
189
182
|
if files.empty?
|
190
|
-
|
191
|
-
return out
|
183
|
+
output! "No such post found (#{id})"
|
184
|
+
return @out
|
192
185
|
end
|
193
186
|
|
194
187
|
if safe
|
195
|
-
|
196
|
-
files.each {|f|
|
197
|
-
puts out
|
198
|
-
|
199
|
-
ques =
|
188
|
+
output_newline
|
189
|
+
files.each {|f| outstr " #{f}\n" }
|
190
|
+
puts @out # ??
|
191
|
+
reset_output
|
192
|
+
ques = "\n Delete?\n "
|
193
|
+
ques.sub!(/\?/, " all these?") if files.size > 1
|
200
194
|
yn = ask red(ques)
|
201
195
|
if yn.downcase == "y"
|
202
196
|
result = system("rm -rf #{files.join(' ')}")
|
203
|
-
|
204
|
-
|
197
|
+
error_cant_delete(files) unless result
|
198
|
+
output! "Deleted\n"
|
205
199
|
else
|
206
|
-
|
200
|
+
output! "No action taken\n"
|
207
201
|
end
|
208
202
|
else
|
209
203
|
result = system("rm -rf #{files.join(' ')}")
|
210
|
-
|
211
|
-
|
212
|
-
|
204
|
+
error_cant_delete(files) unless result
|
205
|
+
output! "Deleted:\n"
|
206
|
+
files.each {|f| output " #{f}\n" }
|
213
207
|
end
|
214
|
-
out
|
208
|
+
@out
|
209
|
+
rescue ArgumentError => err
|
210
|
+
puts err
|
211
|
+
rescue CantDelete => err
|
212
|
+
puts err
|
215
213
|
rescue => err
|
216
214
|
error(err)
|
217
215
|
end
|
@@ -219,7 +217,8 @@ module RuneBlog::REPL
|
|
219
217
|
#-- FIXME affects linking, building, deployment...
|
220
218
|
|
221
219
|
def cmd_edit_post(arg)
|
222
|
-
|
220
|
+
reset_output
|
221
|
+
id = get_integer(arg)
|
223
222
|
tag = "#{'%04d' % id}"
|
224
223
|
files = Find.find(@root+"/src").to_a
|
225
224
|
files = files.grep(/#{tag}-/)
|
@@ -238,51 +237,56 @@ module RuneBlog::REPL
|
|
238
237
|
end
|
239
238
|
|
240
239
|
def cmd_list_posts(arg)
|
241
|
-
|
242
|
-
|
240
|
+
check_empty(arg)
|
241
|
+
reset_output
|
243
242
|
@view = @blog.view
|
244
243
|
dir = @blog.viewdir(@view)
|
245
244
|
Dir.chdir(dir) do
|
246
245
|
posts = Dir.entries(".").grep(/^0.*/)
|
246
|
+
output @view + ":\n"
|
247
247
|
if posts.empty?
|
248
|
-
|
248
|
+
output! "No posts\n"
|
249
249
|
else
|
250
|
-
|
251
|
-
posts.each {|post| out << " #{colored_slug(post)}\n" }
|
250
|
+
posts.each {|post| outstr " #{colored_slug(post)}\n" }
|
252
251
|
end
|
253
252
|
end
|
254
|
-
out
|
253
|
+
@out
|
255
254
|
rescue => err
|
256
255
|
error(err)
|
257
256
|
end
|
258
257
|
|
259
258
|
def cmd_list_drafts(arg)
|
260
|
-
|
261
|
-
|
259
|
+
check_empty(arg)
|
260
|
+
reset_output
|
262
261
|
dir = "#@root/src"
|
263
262
|
Dir.chdir(dir) do
|
264
263
|
posts = Dir.entries(".").grep(/^0.*.lt3/)
|
265
|
-
|
264
|
+
output_newline
|
266
265
|
if posts.empty?
|
267
|
-
|
266
|
+
output! "No posts"
|
267
|
+
return @out
|
268
268
|
else
|
269
|
-
posts.each
|
269
|
+
posts.each do |post|
|
270
|
+
str = " #{colored_slug(post.sub(/.lt3$/, ""))}\n"
|
271
|
+
outstr str
|
272
|
+
end
|
270
273
|
end
|
271
274
|
end
|
272
|
-
out
|
275
|
+
@out
|
273
276
|
rescue => err
|
274
277
|
error(err)
|
275
278
|
end
|
276
279
|
|
277
280
|
def cmd_INVALID(arg)
|
278
|
-
|
281
|
+
reset_output "\n Command '#{red(arg)}' was not understood."
|
282
|
+
return @out
|
279
283
|
end
|
280
284
|
|
281
285
|
def cmd_help(arg)
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
+
reset_output
|
287
|
+
check_empty(arg)
|
288
|
+
output(<<-EOS)
|
289
|
+
Commands:
|
286
290
|
|
287
291
|
#{red('h, help ')} This message
|
288
292
|
#{red('q, quit ')} Exit the program
|
@@ -308,7 +312,28 @@ module RuneBlog::REPL
|
|
308
312
|
#{red('rebuild ')} Regenerate all posts and relink
|
309
313
|
#{red('deploy ')} Deploy (current view)
|
310
314
|
EOS
|
311
|
-
out
|
315
|
+
@out
|
316
|
+
end
|
317
|
+
|
318
|
+
## Funky stuff -- needs to move?
|
319
|
+
|
320
|
+
def new_blog!(arg) # FIXME weird?
|
321
|
+
check_empty(arg)
|
322
|
+
return if RuneBlog.exist?
|
323
|
+
yn = yesno(red(" No .blog found. Create new blog? "))
|
324
|
+
RuneBlog.create_new_blog if yn
|
325
|
+
rescue => err
|
326
|
+
error(err)
|
327
|
+
end
|
328
|
+
|
329
|
+
def open_blog # Crude - FIXME later
|
330
|
+
@blog = RuneBlog.new
|
331
|
+
@view = @blog.view # current view
|
332
|
+
@sequence = @blog.sequence
|
333
|
+
@root = @blog.root
|
334
|
+
@blog
|
335
|
+
rescue => err
|
336
|
+
error(err)
|
312
337
|
end
|
313
338
|
|
314
339
|
end
|
data/lib/runeblog.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.0.
|
4
|
+
version: 0.0.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|