runeblog 0.0.45 → 0.0.48
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +7 -10
- data/data/VERSION +1 -1
- data/data/views/_default/deploy +0 -0
- data/lib/blogcmds.rb +9 -28
- data/lib/newruneblog.rb +106 -0
- data/lib/oldrepl.rb +628 -0
- data/lib/oldruneblog.rb +106 -0
- data/lib/repl.rb +131 -118
- data/lib/runeblog.rb +45 -8
- metadata +6 -2
data/lib/oldruneblog.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'find'
|
2
|
+
require 'yaml'
|
3
|
+
require 'livetext'
|
4
|
+
|
5
|
+
class RuneBlog
|
6
|
+
VERSION = "0.0.45"
|
7
|
+
|
8
|
+
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
9
|
+
DefaultData = Path + "/../data"
|
10
|
+
|
11
|
+
BlogHeaderPath = DefaultData + "/custom/blog_header.html"
|
12
|
+
BlogTrailerPath = DefaultData + "/custom/blog_trailer.html"
|
13
|
+
|
14
|
+
BlogHeader = File.read(BlogHeaderPath) rescue "not found"
|
15
|
+
BlogTrailer = File.read(BlogTrailerPath) rescue "not found"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Continued below...
|
19
|
+
|
20
|
+
class RuneBlog::Config
|
21
|
+
attr_reader :root, :views, :view, :sequence
|
22
|
+
attr_writer :view # FIXME
|
23
|
+
|
24
|
+
def self.create(cfg_file = ".blog")
|
25
|
+
RuneBlog.create_new_blog
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(cfg_file = ".blog")
|
29
|
+
# What views are there? Deployment, etc.
|
30
|
+
# Crude - FIXME later
|
31
|
+
|
32
|
+
lines = File.readlines(cfg_file).map {|x| x.chomp }
|
33
|
+
@root = lines[0]
|
34
|
+
@view = lines[1]
|
35
|
+
dirs = Dir.entries("#@root/views/") - %w[. ..]
|
36
|
+
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
37
|
+
@root = root
|
38
|
+
@views = dirs
|
39
|
+
@sequence = File.read(root + "/sequence").to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
def next_sequence
|
43
|
+
@sequence += 1
|
44
|
+
File.open("#@root/sequence", "w") {|f| f.puts @sequence }
|
45
|
+
@sequence
|
46
|
+
end
|
47
|
+
|
48
|
+
def viewdir(v)
|
49
|
+
@root + "/views/#{v}/"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# Reopening...
|
55
|
+
|
56
|
+
class RuneBlog
|
57
|
+
|
58
|
+
def self.exist?
|
59
|
+
File.exist?(".blog")
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_config
|
63
|
+
end
|
64
|
+
|
65
|
+
# def initialize
|
66
|
+
# # ?
|
67
|
+
# end
|
68
|
+
|
69
|
+
def self.create_new_blog
|
70
|
+
#-- what if data already exists?
|
71
|
+
result = system("cp -r #{RuneBlog::DefaultData} .")
|
72
|
+
raise "Error copying default data" unless result
|
73
|
+
|
74
|
+
File.open(".blog", "w") do |f|
|
75
|
+
f.puts "data"
|
76
|
+
f.puts "no_default"
|
77
|
+
end
|
78
|
+
File.open("data/VERSION", "a") {|f| f.puts "\nBlog created: " + Time.now.to_s }
|
79
|
+
end
|
80
|
+
|
81
|
+
# def self.open_blog
|
82
|
+
# end
|
83
|
+
|
84
|
+
# def self.create_new_post(title, date, view)
|
85
|
+
# @template = <<-EOS
|
86
|
+
# .mixin liveblog
|
87
|
+
#
|
88
|
+
# .title #{title}
|
89
|
+
# .pubdate #{date}
|
90
|
+
# .views #{view}
|
91
|
+
#
|
92
|
+
# .teaser
|
93
|
+
# Teaser goes here.
|
94
|
+
# .end
|
95
|
+
# Remainder of post goes here.
|
96
|
+
# EOS
|
97
|
+
#
|
98
|
+
# @slug = make_slug(title)
|
99
|
+
# @fname = @slug + ".lt3"
|
100
|
+
# File.open("#@root/src/#@fname", "w") {|f| f.puts @template }
|
101
|
+
# @fname
|
102
|
+
# rescue => err
|
103
|
+
# error(err, __LINE__, __FILE__)
|
104
|
+
# end
|
105
|
+
|
106
|
+
end
|
data/lib/repl.rb
CHANGED
@@ -2,39 +2,31 @@ require 'runeblog'
|
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def interpolate(str)
|
24
|
-
wrap = "<<-EOS\n#{str}\nEOS"
|
25
|
-
eval wrap
|
26
|
-
end
|
5
|
+
=begin
|
6
|
+
Instance vars in original code:
|
7
|
+
@bloghead
|
8
|
+
@blogtail
|
9
|
+
@config
|
10
|
+
@date
|
11
|
+
@deploy
|
12
|
+
@fname
|
13
|
+
@main
|
14
|
+
@meta
|
15
|
+
@root
|
16
|
+
@sequence
|
17
|
+
@slug
|
18
|
+
@template
|
19
|
+
@title
|
20
|
+
@today
|
21
|
+
@view
|
22
|
+
=end
|
27
23
|
|
28
|
-
|
29
|
-
red(slug[0..3])+blue(slug[4..-1])
|
30
|
-
end
|
24
|
+
module RuneBlog::REPL
|
31
25
|
|
32
26
|
### error
|
33
27
|
|
34
|
-
def error(err
|
35
|
-
str = "\n Error:
|
36
|
-
str << err.to_s
|
37
|
-
puts red(str)
|
28
|
+
def error(err)
|
29
|
+
str = "\n Error: #{red(err)}"
|
38
30
|
puts err.backtrace
|
39
31
|
end
|
40
32
|
|
@@ -46,11 +38,17 @@ module RuneBlog::REPL
|
|
46
38
|
STDIN.gets.chomp.send(meth)
|
47
39
|
end
|
48
40
|
|
41
|
+
def yesno(prompt, meth = :to_s)
|
42
|
+
print prompt
|
43
|
+
STDOUT.flush
|
44
|
+
STDIN.gets.chomp.upcase[0] == "Y"
|
45
|
+
end
|
46
|
+
|
49
47
|
### quit
|
50
48
|
|
51
49
|
def cmd_quit(arg)
|
52
50
|
raise "Glitch: Got an argument" if arg != []
|
53
|
-
puts
|
51
|
+
puts "\n "
|
54
52
|
exit
|
55
53
|
end
|
56
54
|
|
@@ -63,48 +61,36 @@ module RuneBlog::REPL
|
|
63
61
|
|
64
62
|
### new_blog!
|
65
63
|
|
66
|
-
def
|
64
|
+
def new_blog!(arg)
|
67
65
|
raise "Glitch: Got an argument" if arg != []
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
#-- what if data already exists?
|
72
|
-
result = system("cp -r #{RuneBlog::DefaultData} .")
|
73
|
-
raise "Error copying default data" unless result
|
74
|
-
|
75
|
-
File.open(".blog", "w") do |f|
|
76
|
-
f.puts "data"
|
77
|
-
f.puts "no_default"
|
78
|
-
end
|
79
|
-
File.open("data/VERSION", "a") {|f| f.puts "\nBlog created: " + Time.now.to_s }
|
80
|
-
end
|
81
|
-
end
|
66
|
+
return if RuneBlog.exist?
|
67
|
+
yn = yesno(red(" No .blog found. Create new blog? "))
|
68
|
+
RuneBlog.create_new_blog if yn
|
82
69
|
rescue => err
|
83
|
-
error(err
|
70
|
+
error(err)
|
84
71
|
end
|
85
72
|
|
86
73
|
### make_slug
|
87
74
|
|
75
|
+
# What to do with this?
|
76
|
+
|
88
77
|
def make_slug(title, seq=nil)
|
89
|
-
num = '%04d' % (seq || @
|
78
|
+
num = '%04d' % (seq || @blog.next_sequence) # FIXME can do better
|
90
79
|
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
91
80
|
"#{num}-#{slug}"
|
92
81
|
end
|
93
82
|
|
94
|
-
###
|
95
|
-
|
96
|
-
def read_config
|
97
|
-
# Crude - FIXME later
|
98
|
-
cfg_file = ".blog"
|
99
|
-
new_blog! unless File.exist?(cfg_file)
|
100
|
-
@config = RuneBlog::Config.new(cfg_file)
|
83
|
+
### open_blog
|
101
84
|
|
102
|
-
|
103
|
-
|
104
|
-
@
|
105
|
-
@
|
85
|
+
def open_blog # Crude - FIXME later
|
86
|
+
# new_blog!([]) unless RuneBlog.exist?
|
87
|
+
@blog = RuneBlog.new
|
88
|
+
@view = @blog.view # current view
|
89
|
+
@sequence = @blog.sequence
|
90
|
+
@root = @blog.root
|
91
|
+
@blog
|
106
92
|
rescue => err
|
107
|
-
error(err
|
93
|
+
error(err)
|
108
94
|
end
|
109
95
|
|
110
96
|
### create_empty_post
|
@@ -128,7 +114,7 @@ Remainder of post goes here.
|
|
128
114
|
File.open("#@root/src/#@fname", "w") {|f| f.puts @template }
|
129
115
|
@fname
|
130
116
|
rescue => err
|
131
|
-
error(err
|
117
|
+
error(err)
|
132
118
|
end
|
133
119
|
|
134
120
|
### edit_initial_post
|
@@ -152,29 +138,29 @@ Remainder of post goes here.
|
|
152
138
|
result = system("open 'http://#{server}/#{spath}'")
|
153
139
|
raise "Problem opening http://#{server}/#{spath}" unless result
|
154
140
|
rescue => err
|
155
|
-
error(err
|
141
|
+
error(err)
|
156
142
|
end
|
157
143
|
|
158
144
|
### open_local
|
159
145
|
|
160
146
|
def open_local
|
161
|
-
result = system("open #{@
|
162
|
-
raise "Problem opening #{@
|
147
|
+
result = system("open #{@blog.viewdir(@view)}/index.html")
|
148
|
+
raise "Problem opening #{@blog.viewdir(@view)}/index.html" unless result
|
163
149
|
rescue => err
|
164
|
-
error(err
|
150
|
+
error(err)
|
165
151
|
end
|
166
152
|
|
167
153
|
def cmd_deploy(arg)
|
168
154
|
# TBD clunky FIXME
|
169
155
|
raise "Glitch: Got an argument" if arg != []
|
170
156
|
@deploy ||= {}
|
171
|
-
deployment = @
|
157
|
+
deployment = @blog.viewdir(@view) + "deploy"
|
172
158
|
raise "File '#{deployment}' not found" unless File.exist?(deployment)
|
173
159
|
|
174
160
|
lines = File.readlines(deployment).map {|x| x.chomp }
|
175
161
|
@deploy[@view] = lines
|
176
162
|
user, server, sroot, spath = *lines
|
177
|
-
vdir = @
|
163
|
+
vdir = @blog.viewdir(@view)
|
178
164
|
files = ["#{vdir}/index.html"]
|
179
165
|
files += Dir.entries(vdir).grep(/^\d\d\d\d/).map {|x| "#{vdir}/#{x}" }
|
180
166
|
files.reject! {|f| File.mtime(f) < File.mtime("#{vdir}/last_deployed") }
|
@@ -195,7 +181,7 @@ Remainder of post goes here.
|
|
195
181
|
File.write("#{vdir}/last_deployed", files)
|
196
182
|
puts red("finished.")
|
197
183
|
rescue => err
|
198
|
-
error(err
|
184
|
+
error(err)
|
199
185
|
end
|
200
186
|
|
201
187
|
### process_post
|
@@ -207,11 +193,11 @@ Remainder of post goes here.
|
|
207
193
|
@meta = @main.process_file(path, binding)
|
208
194
|
raise "process_file returned nil" if @meta.nil?
|
209
195
|
|
210
|
-
@meta.slug = make_slug(@meta.title, @
|
196
|
+
@meta.slug = make_slug(@meta.title, @blog.sequence)
|
211
197
|
@meta.slug = file.sub(/.lt3$/, "")
|
212
198
|
@meta
|
213
199
|
rescue => err
|
214
|
-
error(err
|
200
|
+
error(err)
|
215
201
|
end
|
216
202
|
|
217
203
|
### reload_post
|
@@ -223,7 +209,7 @@ Remainder of post goes here.
|
|
223
209
|
@meta.slug = file.sub(/.lt3$/, "")
|
224
210
|
@meta
|
225
211
|
rescue => err
|
226
|
-
error(err
|
212
|
+
error(err)
|
227
213
|
end
|
228
214
|
|
229
215
|
### posting
|
@@ -264,7 +250,7 @@ Remainder of post goes here.
|
|
264
250
|
f.puts @blogtail
|
265
251
|
end
|
266
252
|
rescue => err
|
267
|
-
error(err
|
253
|
+
error(err)
|
268
254
|
end
|
269
255
|
|
270
256
|
### create_dir
|
@@ -279,7 +265,7 @@ Remainder of post goes here.
|
|
279
265
|
|
280
266
|
def link_post_view(view)
|
281
267
|
# Create dir using slug (index.html, metadata?)
|
282
|
-
vdir = @
|
268
|
+
vdir = @blog.viewdir(view)
|
283
269
|
dir = vdir + @meta.slug + "/"
|
284
270
|
create_dir(dir + "assets")
|
285
271
|
File.write("#{dir}/metadata.yaml", @meta.to_yaml)
|
@@ -288,7 +274,7 @@ Remainder of post goes here.
|
|
288
274
|
File.write(dir + "index.html", post)
|
289
275
|
generate_index(view)
|
290
276
|
rescue => err
|
291
|
-
error(err
|
277
|
+
error(err)
|
292
278
|
end
|
293
279
|
|
294
280
|
### find_asset
|
@@ -339,7 +325,7 @@ Remainder of post goes here.
|
|
339
325
|
# assets = find_all_assets(@meta.assets, views)
|
340
326
|
puts
|
341
327
|
rescue => err
|
342
|
-
error(err
|
328
|
+
error(err)
|
343
329
|
end
|
344
330
|
|
345
331
|
### rebuild_post
|
@@ -348,7 +334,7 @@ Remainder of post goes here.
|
|
348
334
|
reload_post(file)
|
349
335
|
publish_post(@meta) # FIXME ??
|
350
336
|
rescue => err
|
351
|
-
error(err
|
337
|
+
error(err)
|
352
338
|
end
|
353
339
|
|
354
340
|
### rebuild
|
@@ -361,16 +347,16 @@ Remainder of post goes here.
|
|
361
347
|
files = files.sort.reverse
|
362
348
|
files.each {|file| rebuild_post(file) }
|
363
349
|
rescue => err
|
364
|
-
error(err
|
350
|
+
error(err)
|
365
351
|
end
|
366
352
|
|
367
353
|
### relink
|
368
354
|
|
369
355
|
def cmd_relink(arg)
|
370
356
|
raise "Glitch: Got an argument" if arg != []
|
371
|
-
@
|
357
|
+
@blog.views.each {|view| generate_index(view) }
|
372
358
|
rescue => err
|
373
|
-
|
359
|
+
error(err)
|
374
360
|
end
|
375
361
|
|
376
362
|
# ### publish?
|
@@ -383,12 +369,12 @@ Remainder of post goes here.
|
|
383
369
|
### list_views
|
384
370
|
|
385
371
|
def cmd_list_views(arg)
|
386
|
-
abort "Config file not read" unless @
|
372
|
+
abort "Config file not read" unless @blog
|
387
373
|
raise "Glitch: Got an argument" if arg != []
|
388
374
|
puts
|
389
|
-
@
|
375
|
+
@blog.views.each {|v| puts " #{v}" }
|
390
376
|
rescue => err
|
391
|
-
error(err
|
377
|
+
error(err)
|
392
378
|
end
|
393
379
|
|
394
380
|
### change_view
|
@@ -398,25 +384,25 @@ Remainder of post goes here.
|
|
398
384
|
puts "\n #@view"
|
399
385
|
else
|
400
386
|
arg = arg.first
|
401
|
-
list = @
|
387
|
+
list = @blog.views.grep /^#{arg}/
|
402
388
|
if list.size == 1
|
403
|
-
@view = @
|
389
|
+
@view = @blog.view = list.first
|
404
390
|
puts red("\n View: #{@view}") if arg != @view
|
405
391
|
else
|
406
392
|
puts "view #{arg.inspect} does not exist"
|
407
393
|
end
|
408
394
|
end
|
409
395
|
rescue => err
|
410
|
-
error(err
|
396
|
+
error(err)
|
411
397
|
end
|
412
398
|
|
413
399
|
### new_view
|
414
400
|
|
415
401
|
def cmd_new_view(arg)
|
416
402
|
arg = arg.first
|
417
|
-
|
403
|
+
@blog ||= open_blog
|
418
404
|
arg ||= ask("New view: ") # check validity later
|
419
|
-
raise "view #{arg} already exists" if @
|
405
|
+
raise "view #{arg} already exists" if @blog.views.include?(arg)
|
420
406
|
|
421
407
|
dir = @root + "/views/" + arg + "/"
|
422
408
|
create_dir(dir + 'custom')
|
@@ -426,15 +412,16 @@ Remainder of post goes here.
|
|
426
412
|
File.write(dir + "custom/blog_header.html", RuneBlog::BlogHeader)
|
427
413
|
File.write(dir + "custom/blog_trailer.html", RuneBlog::BlogTrailer)
|
428
414
|
File.write(dir + "last_deployed", "Initial creation")
|
429
|
-
@
|
415
|
+
@blog.views << arg
|
430
416
|
rescue => err
|
431
|
-
error(err
|
417
|
+
error(err)
|
432
418
|
end
|
433
419
|
|
434
420
|
### import
|
435
421
|
|
436
422
|
def import(arg = nil)
|
437
|
-
|
423
|
+
open_blog unless @blog
|
424
|
+
|
438
425
|
arg = nil if arg == ""
|
439
426
|
arg ||= ask("Filename: ") # check validity later
|
440
427
|
name = arg
|
@@ -449,14 +436,14 @@ Remainder of post goes here.
|
|
449
436
|
process_post(@fname)
|
450
437
|
publish_post(@meta) # if publish?
|
451
438
|
rescue => err
|
452
|
-
error(err
|
439
|
+
error(err)
|
453
440
|
end
|
454
441
|
|
455
442
|
### new_post
|
456
443
|
|
457
444
|
def cmd_new_post(arg)
|
458
445
|
raise "Glitch: Got an argument" if arg != []
|
459
|
-
|
446
|
+
open_blog unless @blog
|
460
447
|
@title = ask("Title: ")
|
461
448
|
@today = Time.now.strftime("%Y%m%d")
|
462
449
|
@date = Time.now.strftime("%Y-%m-%d")
|
@@ -467,7 +454,7 @@ Remainder of post goes here.
|
|
467
454
|
process_post(file) #- FIXME handle each view
|
468
455
|
publish_post(@meta) # if publish?
|
469
456
|
rescue => err
|
470
|
-
error(err
|
457
|
+
error(err)
|
471
458
|
end
|
472
459
|
|
473
460
|
### remove_multiple_posts
|
@@ -484,10 +471,10 @@ Remainder of post goes here.
|
|
484
471
|
def cmd_remove_post(arg, safe=true)
|
485
472
|
arg = arg.first
|
486
473
|
id = Integer(arg) rescue raise("'#{arg}' is not an integer")
|
487
|
-
tag = "#{'%04d' % id}
|
474
|
+
tag = "#{'%04d' % id}"
|
488
475
|
files = Find.find(@root).to_a
|
489
|
-
files = files.grep(/#{tag}
|
490
|
-
return puts red("\n No such post found (#{
|
476
|
+
files = files.grep(/#{tag}-/)
|
477
|
+
return puts red("\n No such post found (#{id})") if files.empty?
|
491
478
|
|
492
479
|
if safe
|
493
480
|
puts
|
@@ -520,12 +507,12 @@ Remainder of post goes here.
|
|
520
507
|
def cmd_edit_post(arg)
|
521
508
|
arg = arg.first
|
522
509
|
id = Integer(arg) rescue raise("'#{arg}' is not an integer")
|
523
|
-
tag = "#{'%04d' % id}
|
510
|
+
tag = "#{'%04d' % id}"
|
524
511
|
files = Find.find(@root+"/src").to_a
|
525
|
-
files = files.grep(/#{tag}
|
512
|
+
files = files.grep(/#{tag}-/)
|
526
513
|
files = files.map {|f| File.basename(f) }
|
527
514
|
return puts red("Multiple files: #{files}") if files.size > 1
|
528
|
-
return puts red("\n No such post found (#{
|
515
|
+
return puts red("\n No such post found (#{id})") if files.empty?
|
529
516
|
|
530
517
|
file = files.first
|
531
518
|
result = system("vi #@root/src/#{file}")
|
@@ -542,7 +529,7 @@ Remainder of post goes here.
|
|
542
529
|
|
543
530
|
def cmd_list_posts(arg)
|
544
531
|
raise "Glitch: Got an argument" if arg != []
|
545
|
-
dir = @
|
532
|
+
dir = @blog.viewdir(@view)
|
546
533
|
Dir.chdir(dir) do
|
547
534
|
posts = Dir.entries(".").grep(/^0.*/)
|
548
535
|
if posts.empty?
|
@@ -579,7 +566,7 @@ Remainder of post goes here.
|
|
579
566
|
end
|
580
567
|
|
581
568
|
def cmd_INVALID(arg)
|
582
|
-
puts "\n Command '#{red(arg)}' not understood
|
569
|
+
puts "\n Command '#{red(arg)}' was not understood."
|
583
570
|
end
|
584
571
|
|
585
572
|
def cmd_help(arg)
|
@@ -588,29 +575,55 @@ Remainder of post goes here.
|
|
588
575
|
|
589
576
|
Commands:
|
590
577
|
|
591
|
-
h, help
|
592
|
-
q, quit
|
578
|
+
#{red('h, help ')} This message
|
579
|
+
#{red('q, quit ')} Exit the program
|
580
|
+
#{red('v, version ')} Print version information
|
593
581
|
|
594
|
-
change view VIEW
|
595
|
-
cv VIEW
|
596
|
-
new view
|
597
|
-
list views
|
598
|
-
lsv
|
582
|
+
#{red('change view VIEW ')} Change current view
|
583
|
+
#{red('cv VIEW ')} Change current view
|
584
|
+
#{red('new view ')} Create a new view
|
585
|
+
#{red('list views ')} List all views available
|
586
|
+
#{red('lsv ')} Same as: list views
|
599
587
|
|
600
|
-
p, post
|
601
|
-
new post
|
602
|
-
lsp, list posts
|
603
|
-
lsd, list drafts
|
588
|
+
#{red('p, post ')} Create a new post
|
589
|
+
#{red('new post ')} Same as post (create a post)
|
590
|
+
#{red('lsp, list posts ')} List posts in current view
|
591
|
+
#{red('lsd, list drafts ')} List all posts regardless of view
|
604
592
|
|
605
|
-
rm ID
|
606
|
-
edit ID
|
593
|
+
#{red('rm ID ')} Remove a post
|
594
|
+
#{red('edit ID ')} Edit a post
|
607
595
|
|
608
|
-
preview
|
609
|
-
browse
|
610
|
-
relink
|
611
|
-
rebuild
|
612
|
-
deploy
|
596
|
+
#{red('preview ')} Look at current (local) view in browser
|
597
|
+
#{red('browse ')} Look at current (deployed) view in browser
|
598
|
+
#{red('relink ')} Regenerate index for all views
|
599
|
+
#{red('rebuild ')} Regenerate all posts and relink
|
600
|
+
#{red('deploy ')} Deploy (current view)
|
613
601
|
EOS
|
614
602
|
end
|
615
603
|
|
604
|
+
def clear
|
605
|
+
puts "\e[H\e[2J" # clear screen
|
606
|
+
end
|
607
|
+
|
608
|
+
def red(text)
|
609
|
+
"\e[31m#{text}\e[0m"
|
610
|
+
end
|
611
|
+
|
612
|
+
def blue(text)
|
613
|
+
"\e[34m#{text}\e[0m"
|
614
|
+
end
|
615
|
+
|
616
|
+
def bold(str)
|
617
|
+
"\e[1m#{str}\e[22m"
|
618
|
+
end
|
619
|
+
|
620
|
+
def interpolate(str)
|
621
|
+
wrap = "<<-EOS\n#{str}\nEOS"
|
622
|
+
eval wrap
|
623
|
+
end
|
624
|
+
|
625
|
+
def colored_slug(slug)
|
626
|
+
red(slug[0..3])+blue(slug[4..-1])
|
627
|
+
end
|
628
|
+
|
616
629
|
end
|