runeblog 0.0.67 → 0.0.69

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 312d4bc3515cf60d3bf2ae0f1531297e7929e44d
4
- data.tar.gz: 94d91c4536bff9751544d93cd5b0a3e0292de8ce
3
+ metadata.gz: 3dc3e2a34a12ed3f1e937d24cc1b8fa96a723bf2
4
+ data.tar.gz: 1dc3be8dce26862daf1a8e56c8e9ddbf30a55577
5
5
  SHA512:
6
- metadata.gz: 50df528cc615999d15e5e1875ac754c4443ce53ea8271a2eb8b834a3a50f796d3be7d485f0388462a41149c126424e2ac80da73104ab5939d2ad0213d7770dfb
7
- data.tar.gz: 501a13eb07d84d70f85dd73dfe399d9a55d8de8369b5030d99545fe605fb68a7c5c4461c2f06154e3ba2b71093d036b66f9051ff70d26a4fe934545a580f3222
6
+ metadata.gz: e05a643f97da28a3866c4fef0c979f74287893c7f6c6be5a0accbbf10cec9a7a2a584386672141a5cc45494810af317e4087164a77bca7d67eb39af1850ec4fb
7
+ data.tar.gz: ad207fc6af4e429e12a6917ff55fe1d73eacf4384f8bc5ce7af6c275582b5f057e49388f56fa3055400ffb341bae689a6c5c2734723ac4f1061fc1f1fba645d5
data/data/VERSION CHANGED
@@ -1 +1 @@
1
- RuneBlog v 0.0.67 2018-09-29
1
+ RuneBlog v 0.0.69 2018-09-29
data/lib/deploy.rb ADDED
@@ -0,0 +1,33 @@
1
+ require 'helpers-blog'
2
+ require 'runeblog'
3
+
4
+ class RuneBlog::Deployment
5
+ attr_reader :user, :server, :root, :path
6
+
7
+ def initialize(user, server, root, path, protocol = "http")
8
+ @blog = RuneBlog.blog
9
+ @user, @server, @root, @path =
10
+ user, server, root, path
11
+ end
12
+
13
+ def url
14
+ url = "#{protocol}://#{@server}/#{@path}"
15
+ end
16
+
17
+ def deploy(files)
18
+ reset_output
19
+ dir = "#@root/#@path"
20
+ result = system("ssh -c #@user@#@server mkdir #{dir}")
21
+ list = files.join(' ')
22
+ cmd = "scp -r #{list} root@#{server}:#{dir} >/dev/null 2>&1"
23
+ output! "Deploying #{files.size} files...\n"
24
+ result = system(cmd)
25
+ raise "Problem occurred in deployment" unless result
26
+
27
+ File.write("#{@blog.view.dir}/last_deployed", files)
28
+ output! "...finished.\n"
29
+ @out
30
+ end
31
+ end
32
+
33
+
@@ -0,0 +1,17 @@
1
+ def create_dir(dir) # FIXME move later
2
+ cmd = "mkdir -p #{dir} >/dev/null 2>&1"
3
+ result = system(cmd)
4
+ raise "Can't create #{dir}" unless result
5
+ end
6
+
7
+ def interpolate(str)
8
+ wrap = "<<-EOS\n#{str}\nEOS"
9
+ eval wrap
10
+ end
11
+
12
+ def error(err) # FIXME - this is duplicated
13
+ str = "\n Error: #{err}"
14
+ puts str
15
+ puts err.backtrace # [0]
16
+ end
17
+
data/lib/hmm ADDED
@@ -0,0 +1,102 @@
1
+ helpers-repl.rb
2
+ 67: def self.choose_method(cmd)
3
+ 84: def error(err)
4
+ 90: def ask(prompt, meth = :to_s)
5
+ 96: def yesno(prompt, meth = :to_s)
6
+ 102: def reset_output(initial = "")
7
+ 107: def flush_output(initial = "")
8
+ 113: def output(str) # \n and indent
9
+ 118: def outstr(str) # \n and indent
10
+ 123: def output!(str) # red, \n and indent
11
+ 128: def output_newline(n = 1)
12
+ 137: def check_empty(arg)
13
+ 141: def get_integer(arg)
14
+ 147: def check_file_exists(file)
15
+ 151: def error_cant_delete(files)
16
+ 160: def clear
17
+ 164: def red(text)
18
+ 168: def blue(text)
19
+ 172: def bold(str)
20
+ 176: def colored_slug(slug)
21
+ 180: def import(arg = nil)
22
+ 200: def ask_deployment_info # returns Deployment object
23
+ 215:# def find_asset(asset) # , views)
24
+ 241:# def find_all_assets(list, views)
25
+
26
+ repl.rb
27
+ 7: def cmd_quit(arg)
28
+ 12: def cmd_version(arg)
29
+ 19: def cmd_browse
30
+ 34: def cmd_preview(arg)
31
+ 44: def cmd_deploy(arg) # FIXME non-string return expected in caller?
32
+ 74: def old_cmd_deploy(arg) # FIXME non-string return expected in caller?
33
+ 104: def cmd_rebuild(arg)
34
+ 115: def cmd_relink(arg)
35
+ 124: def cmd_list_views(arg)
36
+ 136: def cmd_change_view(arg)
37
+ 153: def cmd_new_view(arg)
38
+ 163: def cmd_new_post(arg)
39
+ 173: def cmd_kill(arg)
40
+ 185: def cmd_remove_post(arg, safe=true)
41
+ 226: def cmd_edit_post(arg)
42
+ 247: def cmd_list_posts(arg)
43
+ 262: def cmd_list_drafts(arg)
44
+ 280: def cmd_INVALID(arg)
45
+ 285: def cmd_help(arg)
46
+
47
+ runeblog.rb
48
+ 5:def create_dir(dir) # FIXME move later
49
+ 11:def interpolate(str)
50
+ 16:def error(err) # FIXME - this is duplicated
51
+ 43: def self.create_new_blog
52
+ 55: def get_config(file)
53
+ 60: def initialize(cfg_file = ".blog") # assumes existing blog
54
+ 69: def view?(name)
55
+ 73: def view(name = nil)
56
+ 77: def str2view(str)
57
+ 81: def view=(arg)
58
+ 94: def get_sequence
59
+ 98: def next_sequence
60
+ 103: def viewdir(v)
61
+ 107: def self.exist?
62
+ 111: def create_view(arg)
63
+ 127: def delete_view(name, force = false)
64
+ 134: def deployment_url
65
+ 141: def view_files
66
+ 150: def files_by_id(id)
67
+ 157: def create_new_post(title, testing = false)
68
+ 166: def edit_initial_post(file)
69
+ 174: def posts
70
+ 180: def drafts
71
+ 185: def change_view(view)
72
+ 189: def process_post(file)
73
+ 203: def publish_post(meta)
74
+ 211: def link_post_view(view)
75
+ 225: def generate_index(view)
76
+ 248: def relink
77
+ 252: def index_entry(view, meta)
78
+ 267: def rebuild_post(file)
79
+ 274: def remove_post(num)
80
+ 281: def post_exists?(num)
81
+ 286: def make_slug(title, postnum = nil)
82
+ 293: def subdirs(dir)
83
+ 299: def find_src_slugs
84
+ 313: def initialize(user, server, root, path, protocol = "http")
85
+ 319: def url
86
+ 323: def deploy(files)
87
+ 345: def initialize(name)
88
+ 352: def dir
89
+ 356: def index
90
+ 360: def to_s
91
+ 364: def files(recent = false)
92
+ 373: def deploy
93
+ 384: def recent?(file)
94
+ 388: def read_config
95
+ 395: def write_config
96
+ 408: def self.files(num, root)
97
+ 414: def initialize(title, view_name)
98
+ 438: def edit
99
+ 446: def publish
100
+ 469: def create_post_subtree(vdir)
101
+ 477: def make_slug(postnum = nil)
102
+ 484: def tag(num)
data/lib/post.rb ADDED
@@ -0,0 +1,87 @@
1
+ require 'helpers-blog'
2
+ require 'runeblog'
3
+
4
+ class RuneBlog::Post
5
+
6
+ attr_reader :id, :title, :date, :views, :num, :slug
7
+
8
+ def self.files(num, root)
9
+ files = Find.find(root).to_a
10
+ result = files.grep(/#{tag(num)}-/)
11
+ result
12
+ end
13
+
14
+ def initialize(title, view_name)
15
+ raise "RuneBlog.blog is not set!" if RuneBlog.blog.nil?
16
+ @blog = RuneBlog.blog
17
+ @title = title
18
+ @view = @blog.str2view(view_name)
19
+ @num, @slug = make_slug
20
+ date = Time.now.strftime("%Y-%m-%d")
21
+ template = <<-EOS.gsub(/^ */, "")
22
+ .mixin liveblog
23
+
24
+ .title #{title}
25
+ .pubdate #{date}
26
+ .views #@view
27
+
28
+ .teaser
29
+ Teaser goes here.
30
+ .end
31
+ Remainder of post goes here.
32
+ EOS
33
+
34
+ @draft = "#{@blog.root}/src/#@slug.lt3"
35
+ File.write(@draft, template)
36
+ end
37
+
38
+ def edit
39
+ result = system("vi #@draft +8")
40
+ raise "Problem editing #@draft" unless result
41
+ nil
42
+ rescue => err
43
+ error(err)
44
+ end
45
+
46
+ def publish
47
+ livetext = Livetext.new(STDOUT)
48
+ @meta = livetext.process_file(@draft, binding)
49
+ raise "process_file returned nil" if @meta.nil?
50
+
51
+ @meta.views.each do |view_name| # Create dir using slug (index.html, metadata?)
52
+ view = @blog.str2view(view_name)
53
+ vdir = view.dir
54
+ dir = vdir + @slug + "/"
55
+ Dir.mkdir(dir)
56
+ Dir.chdir(dir) do
57
+ create_post_subtree(vdir)
58
+ @blog.generate_index(view)
59
+ end
60
+ end
61
+ rescue => err
62
+ p err
63
+ err.backtrace.each {|x| puts x }
64
+ # error(err)
65
+ end
66
+
67
+ private
68
+
69
+ def create_post_subtree(vdir)
70
+ create_dir("assets")
71
+ File.write("metadata.yaml", @meta.to_yaml)
72
+ template = File.read(vdir + "/custom/post_template.html")
73
+ text = interpolate(template)
74
+ File.write("index.html", text)
75
+ end
76
+
77
+ def make_slug(postnum = nil)
78
+ postnum ||= @blog.next_sequence
79
+ num = tag(postnum) # FIXME can do better
80
+ slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
81
+ [postnum, "#{num}-#{slug}"]
82
+ end
83
+
84
+ def tag(num)
85
+ "#{'%04d' % num}"
86
+ end
87
+ end
data/lib/runeblog.rb CHANGED
@@ -1,32 +1,21 @@
1
1
  require 'find'
2
2
  require 'yaml'
3
3
  require 'livetext'
4
+ require 'skeleton'
5
+ require 'view'
6
+ require 'deploy'
7
+ require 'post'
8
+ require 'helpers-blog'
9
+ require 'version'
4
10
 
5
- def create_dir(dir) # FIXME move later
6
- cmd = "mkdir -p #{dir} >/dev/null 2>&1"
7
- result = system(cmd)
8
- raise "Can't create #{dir}" unless result
9
- end
10
-
11
- def interpolate(str)
12
- wrap = "<<-EOS\n#{str}\nEOS"
13
- eval wrap
14
- end
15
-
16
- def error(err) # FIXME - this is duplicated
17
- str = "\n Error: #{err}"
18
- puts str
19
- puts err.backtrace # [0]
20
- end
11
+ ###
21
12
 
22
13
  class RuneBlog
23
- VERSION = "0.0.67"
24
14
 
25
15
  class << self
26
16
  attr_accessor :blog
27
17
  end
28
18
 
29
- Path = File.expand_path(File.join(File.dirname(__FILE__)))
30
19
  DefaultData = Path + "/../data/views/_default"
31
20
 
32
21
  BlogHeaderPath = DefaultData + "/custom/blog_header.html"
@@ -305,183 +294,3 @@ class RuneBlog
305
294
 
306
295
  end
307
296
 
308
- #######
309
-
310
- class RuneBlog::Deployment
311
- attr_reader :user, :server, :root, :path
312
-
313
- def initialize(user, server, root, path, protocol = "http")
314
- @blog = RuneBlog.blog
315
- @user, @server, @root, @path =
316
- user, server, root, path
317
- end
318
-
319
- def url
320
- url = "#{protocol}://#{@server}/#{@path}"
321
- end
322
-
323
- def deploy(files)
324
- reset_output
325
- dir = "#@root/#@path"
326
- result = system("ssh -c #@user@#@server mkdir #{dir}")
327
- list = files.join(' ')
328
- cmd = "scp -r #{list} root@#{server}:#{dir} >/dev/null 2>&1"
329
- output! "Deploying #{files.size} files...\n"
330
- result = system(cmd)
331
- raise "Problem occurred in deployment" unless result
332
-
333
- File.write("#{@blog.view.dir}/last_deployed", files)
334
- output! "...finished.\n"
335
- @out
336
- end
337
- end
338
-
339
- #######
340
-
341
- class RuneBlog::View
342
- attr_reader :name, :state
343
- attr_accessor :deploy
344
-
345
- def initialize(name)
346
- raise "RuneBlog.blog is not set!" if RuneBlog.blog.nil?
347
- @blog = RuneBlog.blog
348
- @name = name
349
- @deploy = read_config
350
- end
351
-
352
- def dir
353
- @blog.root + "/views/#@name/"
354
- end
355
-
356
- def index
357
- dir + "index.html"
358
- end
359
-
360
- def to_s
361
- @name
362
- end
363
-
364
- def files(recent = false)
365
- vdir = dir()
366
- files = [index()]
367
- others = Dir.entries(vdir).grep(/^\d\d\d\d/)
368
- files += others.map {|x| "#{vdir}/#{x}" }
369
- files.reject! {|f| recent?(f) } if recent
370
- files
371
- end
372
-
373
- def deploy
374
- # ?? @blog.view.deployment.deploy
375
- # output "Files:"
376
- # files.each {|f| output " #{f}\n" }
377
- output_newline
378
- list = files(true)
379
- @deployer.deploy(list)
380
- rescue => err
381
- error(err)
382
- end
383
-
384
- def recent?(file)
385
- File.mtime(file) < File.mtime("#{dir()}/last_deployed")
386
- end
387
-
388
- def read_config
389
- file = self.dir + "/deploy"
390
- lines = File.readlines(file).map(&:chomp)
391
- user, server, root, path, proto = *lines
392
- @deploy = RuneBlog::Deployment.new(user, server, root, path, proto)
393
- end
394
-
395
- def write_config
396
- file = @blog.view.dir + "/deploy"
397
- File.open(file) {|f| f.puts [@user, @server, @root, @path, @proto] }
398
- end
399
- end
400
-
401
- #######
402
-
403
-
404
- class RuneBlog::Post
405
-
406
- attr_reader :id, :title, :date, :views, :num, :slug
407
-
408
- def self.files(num, root)
409
- files = Find.find(root).to_a
410
- result = files.grep(/#{tag(num)}-/)
411
- result
412
- end
413
-
414
- def initialize(title, view_name)
415
- raise "RuneBlog.blog is not set!" if RuneBlog.blog.nil?
416
- @blog = RuneBlog.blog
417
- @title = title
418
- @view = @blog.str2view(view_name)
419
- @num, @slug = make_slug
420
- date = Time.now.strftime("%Y-%m-%d")
421
- template = <<-EOS.gsub(/^ */, "")
422
- .mixin liveblog
423
-
424
- .title #{title}
425
- .pubdate #{date}
426
- .views #@view
427
-
428
- .teaser
429
- Teaser goes here.
430
- .end
431
- Remainder of post goes here.
432
- EOS
433
-
434
- @draft = "#{@blog.root}/src/#@slug.lt3"
435
- File.write(@draft, template)
436
- end
437
-
438
- def edit
439
- result = system("vi #@draft +8")
440
- raise "Problem editing #@draft" unless result
441
- nil
442
- rescue => err
443
- error(err)
444
- end
445
-
446
- def publish
447
- livetext = Livetext.new(STDOUT)
448
- @meta = livetext.process_file(@draft, binding)
449
- raise "process_file returned nil" if @meta.nil?
450
-
451
- @meta.views.each do |view_name| # Create dir using slug (index.html, metadata?)
452
- view = @blog.str2view(view_name)
453
- vdir = view.dir
454
- dir = vdir + @slug + "/"
455
- Dir.mkdir(dir)
456
- Dir.chdir(dir) do
457
- create_post_subtree(vdir)
458
- @blog.generate_index(view)
459
- end
460
- end
461
- rescue => err
462
- p err
463
- err.backtrace.each {|x| puts x }
464
- # error(err)
465
- end
466
-
467
- private
468
-
469
- def create_post_subtree(vdir)
470
- create_dir("assets")
471
- File.write("metadata.yaml", @meta.to_yaml)
472
- template = File.read(vdir + "/custom/post_template.html")
473
- text = interpolate(template)
474
- File.write("index.html", text)
475
- end
476
-
477
- def make_slug(postnum = nil)
478
- postnum ||= @blog.next_sequence
479
- num = tag(postnum) # FIXME can do better
480
- slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
481
- [postnum, "#{num}-#{slug}"]
482
- end
483
-
484
- def tag(num)
485
- "#{'%04d' % num}"
486
- end
487
- end
data/lib/skeleton.rb ADDED
@@ -0,0 +1,13 @@
1
+ # skeleton
2
+
3
+ class RuneBlog
4
+ class View
5
+ end
6
+
7
+ class Deployment
8
+ end
9
+
10
+ class Post
11
+ end
12
+ end
13
+
data/lib/version.rb ADDED
@@ -0,0 +1,6 @@
1
+
2
+ class RuneBlog
3
+ VERSION = "0.0.69"
4
+
5
+ Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
+ end
data/lib/view.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'helpers-blog'
2
+ require 'runeblog'
3
+
4
+ class RuneBlog::View
5
+ attr_reader :name, :state
6
+ attr_accessor :deploy
7
+
8
+ def initialize(name)
9
+ raise "RuneBlog.blog is not set!" if RuneBlog.blog.nil?
10
+ @blog = RuneBlog.blog
11
+ @name = name
12
+ @deploy = read_config
13
+ end
14
+
15
+ def dir
16
+ @blog.root + "/views/#@name/"
17
+ end
18
+
19
+ def index
20
+ dir + "index.html"
21
+ end
22
+
23
+ def to_s
24
+ @name
25
+ end
26
+
27
+ def files(recent = false)
28
+ vdir = dir()
29
+ files = [index()]
30
+ others = Dir.entries(vdir).grep(/^\d\d\d\d/)
31
+ files += others.map {|x| "#{vdir}/#{x}" }
32
+ files.reject! {|f| recent?(f) } if recent
33
+ files
34
+ end
35
+
36
+ def deploy
37
+ # ?? @blog.view.deployment.deploy
38
+ # output "Files:"
39
+ # files.each {|f| output " #{f}\n" }
40
+ output_newline
41
+ list = files(true)
42
+ @deployer.deploy(list)
43
+ rescue => err
44
+ error(err)
45
+ end
46
+
47
+ def recent?(file)
48
+ File.mtime(file) < File.mtime("#{dir()}/last_deployed")
49
+ end
50
+
51
+ def read_config
52
+ file = self.dir + "/deploy"
53
+ lines = File.readlines(file).map(&:chomp)
54
+ user, server, root, path, proto = *lines
55
+ @deploy = RuneBlog::Deployment.new(user, server, root, path, proto)
56
+ end
57
+
58
+ def write_config
59
+ file = @blog.view.dir + "/deploy"
60
+ File.open(file) {|f| f.puts [@user, @server, @root, @path, @proto] }
61
+ end
62
+ end
63
+
data/runeblog.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'date'
2
2
  require 'find'
3
3
 
4
4
  $: << "."
5
- require "lib/runeblog"
5
+ require "lib/version"
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  system("rm -f *.gem")
@@ -25,6 +25,9 @@ Gem::Specification.new do |s|
25
25
  test = Find.find("test").to_a
26
26
 
27
27
  s.files = main + misc + test
28
+ STDERR.puts "Files are:"
29
+ s.files.each {|fn| STDERR.puts " " + fn }
30
+ STDERR.puts
28
31
  s.homepage = 'https://github.com/Hal9000/runeblog'
29
32
  s.license = "Ruby's license"
30
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.67
4
+ version: 0.0.69
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
@@ -47,9 +47,16 @@ files:
47
47
  - data/views/_default/custom/post_template.html
48
48
  - data/views/_default/deploy
49
49
  - data/views/_default/last_deployed
50
+ - lib/deploy.rb
51
+ - lib/helpers-blog.rb
50
52
  - lib/helpers-repl.rb
53
+ - lib/hmm
54
+ - lib/post.rb
51
55
  - lib/repl.rb
52
56
  - lib/runeblog.rb
57
+ - lib/skeleton.rb
58
+ - lib/version.rb
59
+ - lib/view.rb
53
60
  - runeblog.gemspec
54
61
  - test/repl.rb
55
62
  homepage: https://github.com/Hal9000/runeblog
@@ -72,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
79
  version: '0'
73
80
  requirements: []
74
81
  rubyforge_project:
75
- rubygems_version: 2.2.2
82
+ rubygems_version: 2.6.13
76
83
  signing_key:
77
84
  specification_version: 4
78
85
  summary: A command-line blogging system