runeblog 0.0.51 → 0.0.52
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +2 -1
- data/data/VERSION +1 -1
- data/lib/repl.rb +74 -53
- data/lib/runeblog.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 653084ec3ffb8c767d726dae8cc56bd87837845f
|
4
|
+
data.tar.gz: 4106abe54f01fd812c0f8fab6d6f1cfa0ddff9a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad3086f7ab28e4d28e1e6b1885276d10f23fee0a61314cebc1dac30f1d97438162557161e92033dd9122ff794413b1dddcf12cdfae5f0de2cc183c8b945239e9
|
7
|
+
data.tar.gz: 1db09ee9f124cbd2077e71860bfde2f9c06109c6d54948e33941cc72907c93db4935eaefa816c19bcce45def4a740518701dfa0d1a4ba5462d8579dbad8c9159
|
data/bin/blog
CHANGED
data/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RuneBlog v 0.0.
|
1
|
+
RuneBlog v 0.0.52 2018-09-01
|
data/lib/repl.rb
CHANGED
@@ -26,18 +26,18 @@ require 'helpers-repl' # FIXME structure
|
|
26
26
|
module RuneBlog::REPL
|
27
27
|
|
28
28
|
def cmd_quit(arg)
|
29
|
-
raise "Glitch: Got an argument" if arg != []
|
29
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
30
30
|
puts "\n "
|
31
31
|
exit
|
32
32
|
end
|
33
33
|
|
34
34
|
def cmd_version(arg)
|
35
|
-
raise "Glitch: Got an argument" if arg != []
|
36
|
-
|
35
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
36
|
+
return "\n " + RuneBlog::VERSION
|
37
37
|
end
|
38
38
|
|
39
39
|
def new_blog!(arg) # FIXME weird?
|
40
|
-
raise "Glitch: Got an argument" if arg != []
|
40
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
41
41
|
return if RuneBlog.exist?
|
42
42
|
yn = yesno(red(" No .blog found. Create new blog? "))
|
43
43
|
RuneBlog.create_new_blog if yn
|
@@ -59,12 +59,13 @@ module RuneBlog::REPL
|
|
59
59
|
def edit_initial_post(file)
|
60
60
|
result = system("vi #@root/src/#{file} +8 ")
|
61
61
|
raise "Problem editing #@root/src/#{file}" unless result
|
62
|
+
nil
|
62
63
|
rescue => err
|
63
64
|
error(err)
|
64
65
|
end
|
65
66
|
|
66
67
|
def cmd_browse
|
67
|
-
raise "Glitch: Got an argument" if arg != []
|
68
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
68
69
|
@deploy ||= {}
|
69
70
|
return puts red("\n Deploy first.") unless @deploy[@view]
|
70
71
|
|
@@ -72,6 +73,7 @@ module RuneBlog::REPL
|
|
72
73
|
user, server, sroot, spath = *lines
|
73
74
|
result = system("open 'http://#{server}/#{spath}'")
|
74
75
|
raise "Problem opening http://#{server}/#{spath}" unless result
|
76
|
+
nil
|
75
77
|
rescue => err
|
76
78
|
error(err)
|
77
79
|
end
|
@@ -79,13 +81,14 @@ module RuneBlog::REPL
|
|
79
81
|
def cmd_open_local
|
80
82
|
result = system("open #{@blog.viewdir(@view)}/index.html")
|
81
83
|
raise "Problem opening #{@blog.viewdir(@view)}/index.html" unless result
|
84
|
+
nil
|
82
85
|
rescue => err
|
83
86
|
error(err)
|
84
87
|
end
|
85
88
|
|
86
|
-
def cmd_deploy(arg)
|
89
|
+
def cmd_deploy(arg) # FIXME non-string return expected in caller?
|
87
90
|
# TBD clunky FIXME
|
88
|
-
raise "Glitch: Got an argument" if arg != []
|
91
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
89
92
|
@deploy ||= {}
|
90
93
|
deployment = @blog.viewdir(@view) + "deploy"
|
91
94
|
raise "File '#{deployment}' not found" unless File.exist?(deployment)
|
@@ -97,74 +100,79 @@ module RuneBlog::REPL
|
|
97
100
|
files = ["#{vdir}/index.html"]
|
98
101
|
files += Dir.entries(vdir).grep(/^\d\d\d\d/).map {|x| "#{vdir}/#{x}" }
|
99
102
|
files.reject! {|f| File.mtime(f) < File.mtime("#{vdir}/last_deployed") }
|
100
|
-
|
103
|
+
if files.empty?
|
104
|
+
puts red("\n No files to deploy")
|
105
|
+
return nil
|
106
|
+
end
|
101
107
|
|
102
|
-
|
103
|
-
files.each {|f|
|
104
|
-
|
108
|
+
out = "\n Files:"
|
109
|
+
files.each {|f| out << (" " + f + "\n") }
|
110
|
+
out << "\n"
|
105
111
|
dir = "#{sroot}/#{spath}"
|
106
112
|
# FIXME - may or may not already exist
|
107
113
|
result = system("ssh root@#{server} mkdir #{dir}")
|
108
114
|
|
109
115
|
cmd = "scp -r #{files.join(' ')} root@#{server}:#{dir} >/dev/null 2>&1"
|
110
|
-
|
116
|
+
out << red("\n Deploying #{files.size} files...\n")
|
111
117
|
result = system(cmd)
|
112
118
|
raise "Problem occurred in deployment" unless result
|
113
119
|
|
114
120
|
File.write("#{vdir}/last_deployed", files)
|
115
|
-
|
121
|
+
out << red("finished.\n")
|
122
|
+
out
|
116
123
|
rescue => err
|
117
124
|
error(err)
|
118
125
|
end
|
119
126
|
|
120
127
|
def cmd_rebuild(arg)
|
121
|
-
raise "Glitch: Got an argument" if arg != []
|
128
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
122
129
|
puts
|
123
130
|
files = Dir.entries("#@root/src/").grep /\d\d\d\d.*.lt3$/
|
124
131
|
files.map! {|f| File.basename(f) }
|
125
132
|
files = files.sort.reverse
|
126
133
|
files.each {|file| rebuild_post(file) }
|
134
|
+
nil
|
127
135
|
rescue => err
|
128
136
|
error(err)
|
129
137
|
end
|
130
138
|
|
131
139
|
def cmd_relink(arg)
|
132
|
-
raise "Glitch: Got an argument" if arg != []
|
140
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
133
141
|
@blog.views.each {|view| generate_index(view) }
|
142
|
+
nil
|
134
143
|
rescue => err
|
135
144
|
error(err)
|
136
145
|
end
|
137
146
|
|
138
147
|
def cmd_list_views(arg)
|
139
148
|
abort "Config file not read" unless @blog
|
140
|
-
raise "Glitch: Got an argument" if arg != []
|
141
|
-
|
142
|
-
@blog.views.each {|v|
|
149
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
150
|
+
out = "\n"
|
151
|
+
@blog.views.each {|v| out << " #{v}\n" }
|
152
|
+
out
|
143
153
|
rescue => err
|
144
154
|
error(err)
|
145
155
|
end
|
146
156
|
|
147
|
-
### change_view
|
148
|
-
|
149
157
|
def cmd_change_view(arg)
|
150
158
|
if arg.empty?
|
151
|
-
|
159
|
+
return "\n #@view"
|
152
160
|
else
|
161
|
+
out = ""
|
153
162
|
arg = arg.first
|
154
163
|
list = @blog.views.grep /^#{arg}/
|
155
164
|
if list.size == 1
|
156
165
|
@view = @blog.view = list.first
|
157
|
-
|
166
|
+
out << red("\n View: #{@view}\n") if arg != @view
|
158
167
|
else
|
159
|
-
|
168
|
+
out << "view #{arg.inspect} does not exist\n"
|
160
169
|
end
|
161
170
|
end
|
171
|
+
out
|
162
172
|
rescue => err
|
163
173
|
error(err)
|
164
174
|
end
|
165
175
|
|
166
|
-
### new_view
|
167
|
-
|
168
176
|
def cmd_new_view(arg)
|
169
177
|
arg = arg.first
|
170
178
|
@blog ||= open_blog
|
@@ -184,10 +192,8 @@ module RuneBlog::REPL
|
|
184
192
|
error(err)
|
185
193
|
end
|
186
194
|
|
187
|
-
### new_post
|
188
|
-
|
189
195
|
def cmd_new_post(arg)
|
190
|
-
raise "Glitch: Got an argument" if arg != []
|
196
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
191
197
|
open_blog unless @blog
|
192
198
|
@title = ask("Title: ")
|
193
199
|
@today = Time.now.strftime("%Y%m%d")
|
@@ -197,6 +203,7 @@ module RuneBlog::REPL
|
|
197
203
|
edit_initial_post(file)
|
198
204
|
process_post(file) #- FIXME handle each view
|
199
205
|
publish_post(@meta)
|
206
|
+
nil
|
200
207
|
rescue => err
|
201
208
|
error(err)
|
202
209
|
end
|
@@ -204,36 +211,46 @@ module RuneBlog::REPL
|
|
204
211
|
def cmd_kill(arg)
|
205
212
|
args = arg.first.split
|
206
213
|
args.each {|x| cmd_remove_post([x], false) }
|
214
|
+
nil
|
215
|
+
rescue => err
|
216
|
+
error(err)
|
207
217
|
end
|
208
218
|
|
209
219
|
#-- FIXME affects linking, building, deployment...
|
210
220
|
|
211
221
|
def cmd_remove_post(arg, safe=true)
|
222
|
+
out = ""
|
212
223
|
arg = arg.first
|
213
224
|
id = Integer(arg) rescue raise("'#{arg}' is not an integer")
|
214
225
|
tag = "#{'%04d' % id}"
|
215
226
|
files = Find.find(@root).to_a
|
216
227
|
files = files.grep(/#{tag}-/)
|
217
|
-
|
228
|
+
if files.empty?
|
229
|
+
out = red("\n No such post found (#{id})")
|
230
|
+
return out
|
231
|
+
end
|
218
232
|
|
219
233
|
if safe
|
220
|
-
|
221
|
-
files.each {|f|
|
222
|
-
|
234
|
+
out << "\n"
|
235
|
+
files.each {|f| out << " #{f}\n" }
|
236
|
+
puts out
|
237
|
+
out = ""
|
238
|
+
ques = files.size > 1 ? "\n Delete all these?\n " : "\n Delete?\n "
|
223
239
|
yn = ask red(ques)
|
224
240
|
if yn.downcase == "y"
|
225
241
|
result = system("rm -rf #{files.join(' ')}")
|
226
242
|
raise "Problem deleting file(s)" unless result
|
227
|
-
|
243
|
+
out << red("\n Deleted\n")
|
228
244
|
else
|
229
|
-
|
245
|
+
out << red("\n No action taken\n")
|
230
246
|
end
|
231
247
|
else
|
232
248
|
result = system("rm -rf #{files.join(' ')}")
|
233
|
-
|
234
|
-
files.each {|f|
|
249
|
+
out << red("\n Deleted:\n")
|
250
|
+
files.each {|f| out << " #{f}\n" }
|
235
251
|
raise "Problem mass-deleting file(s)" unless result
|
236
252
|
end
|
253
|
+
out
|
237
254
|
rescue => err
|
238
255
|
error(err)
|
239
256
|
end
|
@@ -247,59 +264,62 @@ module RuneBlog::REPL
|
|
247
264
|
files = Find.find(@root+"/src").to_a
|
248
265
|
files = files.grep(/#{tag}-/)
|
249
266
|
files = files.map {|f| File.basename(f) }
|
250
|
-
return
|
251
|
-
return
|
267
|
+
return red("Multiple files: #{files}") if files.size > 1
|
268
|
+
return red("\n No such post found (#{id})") if files.empty?
|
252
269
|
|
253
270
|
file = files.first
|
254
271
|
result = system("vi #@root/src/#{file}")
|
255
272
|
raise "Problem editing #{file}" unless result
|
256
273
|
|
257
274
|
rebuild_post(file)
|
275
|
+
nil
|
258
276
|
rescue => err
|
259
277
|
error(err)
|
260
278
|
end
|
261
279
|
|
262
280
|
def cmd_list_posts(arg)
|
263
|
-
raise "Glitch: Got an argument" if arg != []
|
281
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
282
|
+
out = ""
|
264
283
|
dir = @blog.viewdir(@view)
|
265
284
|
Dir.chdir(dir) do
|
266
285
|
posts = Dir.entries(".").grep(/^0.*/)
|
267
286
|
if posts.empty?
|
268
|
-
|
287
|
+
out << ("\n " + @view + ":" + red(" No posts\n"))
|
269
288
|
else
|
270
|
-
|
271
|
-
posts.each {|post|
|
289
|
+
out << ("\n " + @view + ":\n ")
|
290
|
+
posts.each {|post| out << " #{colored_slug(post)}\n" }
|
272
291
|
end
|
273
292
|
end
|
293
|
+
out
|
274
294
|
rescue => err
|
275
295
|
error(err)
|
276
296
|
end
|
277
297
|
|
278
298
|
def cmd_list_drafts(arg)
|
279
|
-
raise "Glitch: Got an argument" if arg != []
|
299
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
300
|
+
out = ""
|
280
301
|
dir = "#@root/src"
|
281
302
|
Dir.chdir(dir) do
|
282
303
|
posts = Dir.entries(".").grep(/^0.*.lt3/)
|
283
|
-
|
304
|
+
out << "\n"
|
284
305
|
if posts.empty?
|
285
|
-
|
306
|
+
return red(" No posts")
|
286
307
|
else
|
287
|
-
posts.each {|post|
|
308
|
+
posts.each {|post| out << " #{colored_slug(post.sub(/.lt3$/, ""))}\n" }
|
288
309
|
end
|
289
310
|
end
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
exit
|
311
|
+
out
|
312
|
+
rescue => err
|
313
|
+
error(err)
|
294
314
|
end
|
295
315
|
|
296
316
|
def cmd_INVALID(arg)
|
297
|
-
|
317
|
+
return "\n Command '#{red(arg)}' was not understood."
|
298
318
|
end
|
299
319
|
|
300
320
|
def cmd_help(arg)
|
301
|
-
raise "Glitch: Got an argument" if arg != []
|
302
|
-
|
321
|
+
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
322
|
+
out = <<-EOS
|
303
323
|
|
304
324
|
Commands:
|
305
325
|
|
@@ -327,6 +347,7 @@ module RuneBlog::REPL
|
|
327
347
|
#{red('rebuild ')} Regenerate all posts and relink
|
328
348
|
#{red('deploy ')} Deploy (current view)
|
329
349
|
EOS
|
350
|
+
out
|
330
351
|
end
|
331
352
|
|
332
353
|
end
|
data/lib/runeblog.rb
CHANGED