runeblog 0.2.52 → 0.2.57

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
  SHA256:
3
- metadata.gz: fab29a6bc9b27d8b8390c07288d63a8d27c4131a47ddcecf5291e92a7877d1fa
4
- data.tar.gz: 7a782cc946f7d541491755d6c592defaf58df51772b2815801fbc2a27af303d9
3
+ metadata.gz: 4bef2ece4e81cf77b6418ee5eec97c79a2bcffe8917da084759c96a079e84de7
4
+ data.tar.gz: 4f55658cc1592fb4af748286027c2b504160cd2c61a1c23e5260aa94e6ba1a22
5
5
  SHA512:
6
- metadata.gz: 56a454e863d21a642101e99de411f22cb2471b60d7f1575d1e6905d50273f3bbdf4ec1ac3a08bae55c5c41137588e0d4f12d388532cc61a369be232d5a2f226f
7
- data.tar.gz: 8a4598adc7ac76950e588890db7fbb62d7f024934df04f0c9aed44098296a7b6de5b1fe6f4de82289516eaba010d64554c46df4a711b272c87c9ed6d7ac55d78
6
+ metadata.gz: 2bc13f4c60be93ed5ecf215990b60140bb5c977a0bb130d06bd830b656d86c1103ab88a4e3037e108ef1502fd583ac816d0239040d50f06340eef48835fbd0d9
7
+ data.tar.gz: 5f2a2257355c259b769b6d2625bb8918fc4d538e416d38485a8a8fb0f649ad65ec5ac3af17f7701d76a1c472cee4aa1f7f5b626b9ff501a12383f27fbb480b24
data/bin/blog CHANGED
@@ -9,9 +9,6 @@ require 'repl'
9
9
 
10
10
  include RuneBlog::REPL
11
11
 
12
- errfile = File.new("stderr.out", "w")
13
- STDERR.reopen(errfile)
14
-
15
12
  def get_started
16
13
  puts
17
14
  puts fx(<<-TEXT, :bold)
@@ -35,7 +32,53 @@ rescue => err
35
32
  puts err
36
33
  end
37
34
 
38
- ###
35
+ def cmdline_preview
36
+ _need_view
37
+ local = @blog.view.local_index
38
+ result = system("open #{local}")
39
+ end
40
+
41
+ def cmdline_publish
42
+ abort "Nor implemented yet"
43
+ _need_view
44
+ end
45
+
46
+ def cmdline_browse
47
+ abort "Nor implemented yet"
48
+ _need_view
49
+ end
50
+
51
+ def _need_view
52
+ @view = ARGV[1]
53
+ abort "Need 'view' parameter" if @view.nil?
54
+ abort "No such view '#{view}'" unless @blog.view?(@view)
55
+ end
56
+
57
+ def cmdline_rebuild
58
+ _need_view
59
+ puts "Generating view..."
60
+ @blog.generate_view(@view)
61
+ puts "Generating index..."
62
+ @blog.generate_index(@view)
63
+ end
64
+
65
+ def handle_cmdline
66
+ cmd = ARGV[0]
67
+ @blog = RuneBlog.new
68
+ abort "No blog found" if @blog.nil?
69
+
70
+ case cmd
71
+ when "rebuild"; cmdline_rebuild
72
+ when "publish"; cmdline_publish
73
+ when "preview"; cmdline_preview
74
+ when "browse"; cmdline_browse
75
+ else
76
+ puts "Command '#{cmd}' is unknown"
77
+ end
78
+ exit
79
+ end
80
+
81
+ ### Main
39
82
 
40
83
  major, minor = RUBY_VERSION.split(".").values_at(0,1)
41
84
  ver = major.to_i*10 + minor.to_i
@@ -43,6 +86,11 @@ abort "Need Ruby 2.4 or greater" unless ver >= 24
43
86
 
44
87
  include RuneBlog::Helpers # for try_read_config
45
88
 
89
+ handle_cmdline unless ARGV.empty?
90
+
91
+ errfile = File.new("stderr.out", "w")
92
+ STDERR.reopen(errfile)
93
+
46
94
  # read a .rubytext file here?? Call it something else?
47
95
  home = ENV['HOME']
48
96
  @fg, @bg = try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
@@ -0,0 +1,4 @@
1
+ <div style="text-align: center; color: white; background: #101035">
2
+ <h1>Around Austin</h1><br>
3
+ The view from downtown...
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div style="text-align: center; color: white; background: #101035">
2
+ <h1>Around Austin</h1><br>
3
+ The view from downtown...
4
+ </div>
@@ -14,22 +14,7 @@
14
14
  .include blog/head.lt3
15
15
  <body>
16
16
 
17
- .set color = #101035
18
-
19
- . FIXME
20
- <table width=100% bgcolor=$color>
21
- <tr>
22
- <td width=30% bgcolor=$color>
23
- <div style="text-align: center; color: white">
24
- <h1>Around Austin</h1><br>
25
- The view from downtown...
26
- </div>
27
- </td>
28
- <td><img src=assets/austin-pano.jpg width=100%></img>
29
- </tr>
30
- </table>
31
-
32
- $.include navbar/navbar.lt3
17
+ $.banner text: top.html image: austin-pano.jpg // navbar
33
18
  <div class="content container-fluid mt-4">
34
19
  <div class="row">
35
20
  $.include blog/index.lt3
@@ -10,7 +10,8 @@
10
10
  .sidebar
11
11
  ad
12
12
  links
13
- news
13
+ pinned
14
14
  pages
15
+ news
15
16
  .end
16
17
 
@@ -8,8 +8,7 @@
8
8
  . not needed.
9
9
  . --------------------------------------------------
10
10
 
11
- .navbar2
12
- index Home
11
+ .navbar
13
12
  about About
14
13
  contact Contact
15
14
  faq FAQ
@@ -12,22 +12,59 @@ class ::RuneBlog::Widget
12
12
 
13
13
  def build
14
14
  input = "list.data"
15
- lines = File.readlines(input)
16
- data = lines.map! {|x| x.chomp.split(/, */, 3) }
15
+ @lines = File.readlines(input)
16
+ write_main
17
+ write_card
18
+ end
19
+
20
+ def write_main
21
+ @data = @lines.map! {|x| x.chomp.split(/, */, 3) }
17
22
  css = "* { font-family: verdana }"
18
23
  card_title = "External Links" # FIXME
19
24
  File.open("#{Type}-main.html", "w") do |f|
20
25
  _html_body(f, css) do
21
26
  f.puts "<h1>#{card_title}</h1><br><hr>"
22
27
  url_ref = nil
23
- data.each do |url, frameable, title|
28
+ @data.each do |url, frameable, title|
24
29
  url_ref = (frameable == "yes") ? "href = '#{url}'" : _blank(url)
25
30
  css = "color: #8888FF; text-decoration: none; font-size: 21px" # ; font-family: verdana"
26
31
  f.puts %[<a style="#{css}" #{url_ref}>#{title}</a> <br>]
27
32
  end
28
33
  end
29
34
  end
30
- # remember -card also
35
+ end
36
+
37
+ def write_card
38
+ tag = "links"
39
+ url = :widgets/tag/tag+"-main.html"
40
+ card_title = "External links" # FIXME
41
+ cardfile = "#@self-card"
42
+ File.open("#{cardfile}.html", "w") do |f|
43
+ f.puts <<-EOS
44
+ <div class="card mb-3">
45
+ <div class="card-body">
46
+ <h5 class="card-title">
47
+ <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="##{tag}">+</button>
48
+ <a href="javascript: void(0)"
49
+ onclick="javascript:open_main('#{url}')"
50
+ style="text-decoration: none; color: black"> #{card_title}</a>
51
+ </h5>
52
+ <div class="collapse" id="#{tag}">
53
+ EOS
54
+ @data.each do |url2, frameable, title|
55
+ main_ref = %[href="javascript: void(0)" onclick="javascript:open_main('#{url2}')"]
56
+ tab_ref = %[href="#{url2}"]
57
+ url_ref = (frameable == "yes") ? main_ref : tab_ref
58
+ anchor = %[<a #{url_ref}>#{title}</a>]
59
+ wrapper = %[<li class="list-group-item">#{anchor}</li>]
60
+ f.puts wrapper
61
+ end
62
+ f.puts <<-EOS
63
+ </div>
64
+ </div>
65
+ </div>
66
+ EOS
67
+ end
31
68
  end
32
69
 
33
70
  def edit_menu
@@ -4,9 +4,89 @@ class ::RuneBlog::Widget
4
4
  class Pinned
5
5
  def initialize(repo)
6
6
  @blog = repo
7
+ @self = "pinned"
7
8
  end
8
9
 
10
+ def _html_body(file, css = nil) # FIXME
11
+ file.puts "<html>"
12
+ if css
13
+ file.puts " <head>"
14
+ file.puts " <style>\n#{css}\n </style>"
15
+ file.puts " </head>"
16
+ end
17
+ file.puts " <body>"
18
+ yield
19
+ file.puts " </body>\n</html>"
20
+ end
21
+
9
22
  def build
23
+ @tmp = File.new("/tmp/debug-out", "w")
24
+ posts = nil
25
+ Dir.chdir(@blog.root/:posts) { posts = Dir["*"] }
26
+ lines = File.readlines("list.data")
27
+ hash = {}
28
+ @links = []
29
+ lines.each do |x|
30
+ num, title = x.chomp.split(" ", 2)
31
+ hash[num] = title
32
+ pre = '%04d' % num
33
+ nslug = posts.grep(/#{pre}-/).first
34
+ name = nslug[5..-1]
35
+ link = name+".html"
36
+ @links << [title, link]
37
+ end
38
+ write_main
39
+ write_card
40
+ end
41
+
42
+ def write_main
43
+ tag = "pinned"
44
+ card_title = "Pinned posts" # FIXME
45
+ # setvar "card.title", card_title
46
+ css = "* { font-family: verdana }"
47
+ mainfile = "#@self-main"
48
+ File.open("#{mainfile}.html", "w") do |f|
49
+ _html_body(f, css) do
50
+ f.puts "<h1>#{card_title}</h1><br><hr>"
51
+ @links.each do |title, file|
52
+ title = title.gsub(/\\/, "") # kludge
53
+ css = "color: #8888FF; text-decoration: none; font-size: 21px"
54
+ f.puts %[<a style="#{css}" href="../../#{file}">#{title}</a> <br>]
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ def write_card
61
+ tag = "pinned"
62
+ url = :widgets/tag/tag+"-main.html"
63
+ card_title = "Pinned posts" # FIXME
64
+ cardfile = "#@self-card"
65
+ File.open("#{cardfile}.html", "w") do |f|
66
+ f.puts <<-EOS
67
+ <div class="card mb-3">
68
+ <div class="card-body">
69
+ <h5 class="card-title">
70
+ <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="##{tag}">+</button>
71
+ <a href="javascript: void(0)"
72
+ onclick="javascript:open_main('#{url}')"
73
+ style="text-decoration: none; color: black"> #{card_title}</a>
74
+ </h5>
75
+ <div class="collapse" id="#{tag}">
76
+ EOS
77
+ @links.each do |title, file|
78
+ url2 = file
79
+ url_ref = %[href="javascript: void(0)" onclick="javascript:open_main('#{url2}')"]
80
+ anchor = %[<a #{url_ref}>#{title}</a>]
81
+ wrapper = %[<li class="list-group-item">#{anchor}</li>]
82
+ f.puts wrapper
83
+ end
84
+ f.puts <<-EOS
85
+ </div>
86
+ </div>
87
+ </div>
88
+ EOS
89
+ end
10
90
  end
11
91
 
12
92
  def edit_menu
@@ -15,6 +15,7 @@ module RuneBlog::REPL
15
15
  "v" => :cmd_version,
16
16
  "list views" => :cmd_list_views,
17
17
  "lsv" => :cmd_list_views,
18
+ "clear" => :cmd_clear,
18
19
 
19
20
  "new view $name" => :cmd_new_view,
20
21
 
@@ -19,7 +19,7 @@ def init_liveblog # FIXME - a lot of this logic sucks
19
19
  @root = @blog.root
20
20
  @view = @blog.view
21
21
  @view_name = @blog.view.name unless @view.nil?
22
- @vdir = @blog.view.dir
22
+ @vdir = @blog.view.dir rescue "NONAME"
23
23
  @version = RuneBlog::VERSION
24
24
  @theme = @vdir/:themes/:standard
25
25
  end
@@ -87,36 +87,41 @@ def backlink
87
87
  end
88
88
 
89
89
  def banner # still experimental
90
- _out "<table>"
91
- _body do |line|
92
- pieces = line.split
93
- cols = pieces.size
94
- span = cols == 2 ? 1 : 2 # whaaat?
95
- _out " <tr>"
96
- pieces.each do |piece|
97
- _out " <td colspan=#{span}>"
98
- case
99
- when piece.start_with?("hnav")
100
- # horizontal navbar
101
- # _out "<center>hnav1 hnav2 hnav3 hnav4</center>"
102
- when piece.start_with?("vnav")
103
- # vertical navbar
104
- # _out "vnav1<br>vnav2<br>vnav3<br>vnav4<br>"
105
- when piece.start_with?("text")
106
- file = piece.split(":")[1]
107
- file ||= "banner/text.html"
108
- _out File.read(file)
109
- when piece.start_with?("image")
110
- image = piece.split(":")[1]
111
- image ||= "banner/banner.jpg"
112
- _out " <img src=#{image} height=100></img>"
113
- else
114
- _out " '#{piece}' isn't known"
115
- end
116
- _out " </td>"
90
+ _out "<table width=100% bgcolor=#101035>"
91
+ _out " <tr>"
92
+ enum = _args.each
93
+ count = 0
94
+ span = 1
95
+ loop do
96
+ count += 1
97
+ arg = enum.next
98
+ case arg
99
+ when "image"
100
+ image = "banner/banner.jpg"
101
+ _out " <td colspan=#{span}><img src=#{image} height=150></img></td>"
102
+ when "image:"
103
+ image = "banner/#{enum.next}"
104
+ _out " <td colspan=#{span}><img src=#{image} height=150></img></td>"
105
+ when "text"
106
+ file = "banner/text.html"
107
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>"
108
+ when "text:"
109
+ file = "banner/#{enum.next}"
110
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>"
111
+ when "navbar"
112
+ file = "navbar/navbar.html"
113
+ _out "<td colspan=#{span}><div style='text-align: center'>" + File.read(file) + "</div></td>"
114
+ when "vnavbar"
115
+ file = "navbar/vnavbar.html"
116
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>"
117
+ when "//"
118
+ span = count - 1
119
+ _out " </tr>\n <tr>"
120
+ else
121
+ _out " '#{arg}' isn't known"
117
122
  end
118
- _out " </tr>"
119
123
  end
124
+ _out " </tr>"
120
125
  _out "</table>"
121
126
  end
122
127
 
@@ -268,22 +273,30 @@ end
268
273
 
269
274
  def pin
270
275
  raise "'post' was not called" unless @meta
271
- _debug "data = #{_args}"
272
- # verify only already-specified views?
273
- @meta.pinned = _args.dup
274
- dir = @blog.view.dir/"themes/standard/widgets/pinned/"
275
- datafile = dir/"list.data"
276
- pins = File.readlines(datafile) rescue []
277
- damn = File.new("/tmp/dammit", "w")
278
- pins << "#{@meta.num} #{@meta.title}\n"
279
- damn.puts pins
280
- pins.uniq!
281
- damn.puts pins
282
- damn.close
283
- File.open(datafile, "w") do
284
- pins.each {|pin| File.puts pin }
276
+ _debug "data = #{_args}" # verify only valid views?
277
+ pinned = @_args
278
+ @meta.pinned = pinned
279
+ pinned.each do |pinview|
280
+ dir = @blog.root/:views/pinview/"themes/standard/widgets/pinned/"
281
+ datafile = dir/"list.data"
282
+ if File.exist?(datafile)
283
+ pins = File.readlines(datafile)
284
+ else
285
+ pins = []
286
+ end
287
+ pins << "#{@meta.num} #{@meta.title}\n"
288
+ pins.uniq!
289
+ outfile = File.new(datafile, "w")
290
+ pins.each do |pin|
291
+ outfile.puts pin
292
+ end
293
+ outfile.close
285
294
  end
286
295
  _optional_blank_line
296
+ rescue => err
297
+ puts "err = #{err}"
298
+ puts err.backtrace.join("\n")
299
+ gets
287
300
  end
288
301
 
289
302
  def write_post
@@ -434,12 +447,16 @@ rescue => err
434
447
  end
435
448
 
436
449
  def sidebar
450
+ _debug "--- handling sidebar\r"
437
451
  if _args.include? "off"
438
452
  _body { } # iterate, do nothing
439
453
  return
440
454
  end
441
455
 
442
456
  _out %[<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">]
457
+
458
+ standard = %w[pinned pages links]
459
+
443
460
  _body do |token|
444
461
  tag = token.chomp.strip.downcase
445
462
  wtag = :widgets/tag
@@ -448,12 +465,14 @@ def sidebar
448
465
 
449
466
  code = _load_local(tag)
450
467
  if code
451
- if ["pages", "links"].include? tag
468
+ if ["pages", "links", "pinned"].include? tag
452
469
  Dir.chdir(wtag) do
453
470
  widget = code.new(@blog)
454
471
  widget.build
455
472
  end
456
473
  end
474
+ _include_file wtag/tcard
475
+ next
457
476
  end
458
477
 
459
478
  if tag == "ad"
@@ -471,7 +490,8 @@ def sidebar
471
490
  depend += %w[pieces/card-head.lt3 pieces/card-tail.lt3]
472
491
  depend += %w[pieces/main-head.lt3 pieces/main-tail.lt3]
473
492
  depend.map! {|x| @blog.view.dir/"themes/standard/widgets"/wtag/x }
474
- xlate cwd: wtag, src: tag, dst: tcard, force: true, deps: depend , debug: (tag == "ad")
493
+ _debug "--- call xlate #{tag} src = #{tag} dst = #{tcard}\r"
494
+ xlate cwd: wtag, src: tag, dst: tcard, force: true, deps: depend # , debug: true
475
495
  _include_file wtag/tcard
476
496
  end
477
497
  _out %[</div>]
@@ -481,26 +501,6 @@ rescue => err
481
501
  exit
482
502
  end
483
503
 
484
- =begin
485
- ets/widgets/pages//card.css
486
- ets/widgets/pages//custom.rb
487
- ets/widgets/pages//disclaim.lt3
488
- ets/widgets/pages//faq.lt3
489
- ets/widgets/pages//like-dislike.lt3
490
- ets/widgets/pages//list.data
491
- ets/widgets/pages//local-vars.lt3
492
- ets/widgets/pages//local.rb
493
- ets/widgets/pages//main.css
494
- ets/widgets/pages//other-stuff.lt3
495
- ets/widgets/pages//pages.lt3
496
- ets/widgets/pages//pages.rb
497
- ets/widgets/pages//pieces
498
- ets/widgets/pages//pieces/card-head.lt3
499
- ets/widgets/pages//pieces/card-tail.lt3
500
- ets/widgets/pages//pieces/main-head.lt3
501
- ets/widgets/pages//pieces/main-tail.lt3
502
- =end
503
-
504
504
  def stylesheet
505
505
  lines = _body
506
506
  url = lines[0]
@@ -646,42 +646,53 @@ def tag_cloud
646
646
  end
647
647
 
648
648
  def vnavbar
649
+ _custom_navbar(:vert)
650
+ end
651
+
652
+ def hnavbar
653
+ _custom_navbar # horiz is default
649
654
  end
650
655
 
651
- def navbar2
656
+ def navbar
657
+ _custom_navbar # horiz is default
658
+ end
659
+
660
+ def _custom_navbar(orient = :horiz)
652
661
  vdir = @blog.view.dir
653
662
  title = _var(:blog)
654
663
 
664
+ extra = ""
665
+ extra = "navbar-expand-lg" if orient == :horiz
666
+
655
667
  open = <<-HTML
656
- <nav class="navbar navbar-light bg-light">
657
- <a class="navbar-brand" href="index.html">#{title}</a>
658
- <ul class="navbar-nav mr-auto">
668
+ <nav class="navbar #{extra} navbar-light bg-light">
669
+ <ul class="navbar-nav mr-auto">
659
670
  HTML
660
671
  close = <<-HTML
661
- </ul>
662
- </div>
672
+ </ul>
663
673
  </nav>
664
674
  HTML
665
675
 
666
- first = true
667
- _out open
676
+ html_file = @blog.root/:views/@blog.view/:themes/:standard/:navbar/"navbar.html"
677
+ output = File.new(@blog.root/:views/@blog.view/:themes/:standard/:navbar/"navbar.html", "w")
678
+ output.puts open
668
679
  lines = _body
680
+ lines = [" index Home"] + lines unless _args.include?("nohome")
669
681
  lines.each do |line|
670
682
  basename, cdata = line.chomp.strip.split(" ", 2)
671
683
  full = :navbar/basename+".html"
672
684
  href_main = _main(full)
673
- if first
674
- first = false # hardcode this part??
675
- _out %[<li class="nav-item active"> <a class="nav-link" href="index.html">#{cdata}<span class="sr-only">(current)</span></a> </li>]
685
+ if basename == "index" # special case
686
+ output.puts %[<li class="nav-item active"> <a class="nav-link" href="index.html">#{cdata}<span class="sr-only">(current)</span></a> </li>]
676
687
  else
677
688
  xlate cwd: "navbar", src: basename, dst: vdir/"remote/navbar"/basename+".html" # , debug: true
678
- _out %[<li class="nav-item"> <a class="nav-link" #{href_main}>#{cdata}</a> </li>]
689
+ output.puts %[<li class="nav-item"> <a class="nav-link" #{href_main}>#{cdata}</a> </li>]
679
690
  end
680
691
  end
681
- _out close
692
+ output.puts close
682
693
  end
683
694
 
684
- def navbar
695
+ def _old_navbar
685
696
  vdir = @blog.view.dir
686
697
  title = _var(:blog)
687
698
 
@@ -772,7 +783,7 @@ def _write_card(cardfile, mainfile, pairs, card_title, tag)
772
783
  wrapper = %[<li class="list-group-item">#{anchor}</li>]
773
784
  f.puts wrapper
774
785
  end
775
- _include_file cardfile+".html"
786
+ _include_file cardfile+".html"
776
787
  f.puts <<-EOS
777
788
  </div>
778
789
  </div>
@@ -21,7 +21,8 @@ class RuneBlog::Post
21
21
  raise "Doesn't work right now"
22
22
  raise NoBlogAccessor if RuneBlog.blog.nil?
23
23
  # "post" is a slug
24
- pdir = RuneBlog.blog.view.dir/post
24
+ pdir = RuneBlog.blog.root/:drafts/post
25
+ puts "-- load: opening #{pdir}"
25
26
  meta = nil
26
27
  Dir.chdir(pdir) do
27
28
  meta = read_config("metadata.txt")
@@ -112,9 +113,76 @@ class RuneBlog::Post
112
113
  end
113
114
 
114
115
  class RuneBlog::ViewPost
115
- attr_reader :path, :nslug, :aslug, :title, :date,
116
- :teaser_text
116
+ attr_accessor :nslug, :aslug, :num, :view, :blog
117
+ attr_accessor :path, :title, :date, :teaser_text
118
+
119
+ def self.make(blog:, view:, nslug:)
120
+ raise "No numeric prefix on #{nslug}" unless nslug =~ /^\d{4}-/
121
+ raise "Not expecting an extension" if nslug.end_with?(".lt3") || nslug.end_with?(".html")
122
+ view = view.to_s
123
+ view.define_singleton_method :path do |subdir = ""|
124
+ str = blog.root/:views/view
125
+ str << "/#{subdir}" unless subdir.empty?
126
+ str
127
+ end
128
+ view.define_singleton_method :standard do |subdir = ""|
129
+ str = blog.root/:views/view/:themes/:standard
130
+ str << "/#{subdir}" unless subdir.empty?
131
+ str
132
+ end
133
+ view.define_singleton_method :postdir do |file = ""|
134
+ file = file.to_s
135
+ str = blog.root/:views/view/:posts/nslug
136
+ str = str/file unless file.empty?
137
+ str
138
+ end
139
+ view.define_singleton_method :remote do |dir: "", file: ""|
140
+ subdir = subdir.to_s
141
+ file = file.to_s
142
+ str = blog.root/:views/view/:remote
143
+ str = str/subdir unless subdir.empty?
144
+ str = str/file unless file.empty?
145
+ str
146
+ end
147
+ obj = RuneBlog::ViewPost.new(view, nslug)
148
+ obj.blog = blog
149
+ obj.view = view
150
+ obj.nslug = nslug
151
+ obj.aslug = nslug[5..-1]
152
+ obj.num = nslug[0..3]
153
+ obj
154
+ end
155
+
156
+ def repo(subdir = "")
157
+ subdir = subdir.to_s
158
+ unless subdir.empty?
159
+ raise "Expected 'posts' or 'drafts'" unless %w[posts drafts].include?(subdir)
160
+ end
161
+ str = blog.root
162
+ str = str/subdir unless subdir.empty?
163
+ str
164
+ end
165
+
166
+ alias root repo
167
+
168
+ def slug(num = true, ext = "")
169
+ ext = ext.to_s
170
+ str = ""
171
+ str << @num << "-" if num
172
+ str << @aslug
173
+ str << ext
174
+ str
175
+ end
117
176
 
177
+ =begin
178
+ aslug this-is-a-post
179
+ aslug_live this-is-a-post.lt3
180
+ aslug_html this-is-a-post.lt3
181
+ nslug 0001-this-is-a-post
182
+
183
+ slug(:num, ext = "")
184
+ =end
185
+
118
186
  def initialize(view, postdir)
119
187
  log!(enter: __method__, args: [view, postdir], level: 3)
120
188
  # Assumes already parsed/processed
@@ -122,7 +190,7 @@ class RuneBlog::ViewPost
122
190
  @path = postdir.dup
123
191
  @nslug = @path.split("/").last
124
192
  @aslug = @nslug[5..-1]
125
- fname = "#{postdir}/teaser.txt"
193
+ fname = "#{postdir}/teaser.txt" # ???
126
194
  @teaser_text = File.read(fname).chomp
127
195
  # FIXME dumb hacks...
128
196
  mdfile = postdir/"metadata.txt"
@@ -38,10 +38,10 @@ module RuneBlog::REPL
38
38
  end
39
39
 
40
40
  def cmd_config(arg, testing = false)
41
- list = ["global.lt3", "blog/generate.lt3", " head.lt3", " index.lt3",
42
- " post_entry.lt3", "etc/blog.css.lt3", " externals.lt3",
43
- "post/generate.lt3", " head.lt3", " index.lt3",
44
- " permalink.lt3"]
41
+ list = ["global.lt3", "blog/generate.lt3", ".... head.lt3", ".... index.lt3",
42
+ ".... post_entry.lt3", "etc/blog.css.lt3", "... externals.lt3",
43
+ "post/generate.lt3", ".... head.lt3", ".... index.lt3",
44
+ ".... permalink.lt3"]
45
45
  name = ["global.lt3", "blog/generate.lt3", "blog/head.lt3", "blog/index.lt3",
46
46
  "blog/post_entry.lt3", "etc/blog.css.lt3", "blog/externals.lt3",
47
47
  "post/generate.lt3", "post/head.lt3", "post/index.lt3",
@@ -54,7 +54,7 @@ module RuneBlog::REPL
54
54
 
55
55
  def cmd_manage(arg, testing = false)
56
56
  case arg
57
- when "pages"; _manage_pages(nil, testing = false)
57
+ when "pages"; _manage_pages(nil, testing = false)
58
58
  when "links"; _manage_links(nil, testing = false)
59
59
  when "navbar"; _manage_navbar(nil, testing = false)
60
60
  # when "pinned"; _manage_pinned(nil, testing = false) # ditch this??
@@ -71,7 +71,6 @@ module RuneBlog::REPL
71
71
  end
72
72
 
73
73
  def _manage_navbar(arg, testing = false) # cloned from manage_pages
74
- puts "Got to #{__method__}"
75
74
  check_empty(arg)
76
75
  dir = @blog.view.dir/"themes/standard/navbar"
77
76
  files = Dir.entries(dir) - %w[. .. navbar.lt3]
@@ -328,7 +327,7 @@ puts "Got to #{__method__}"
328
327
  id = get_integer(arg)
329
328
  # Simplify this
330
329
  tag = "#{'%04d' % id}"
331
- files = ::Find.find(@blog.root+"/drafts").to_a
330
+ files = ::Find.find(@blog.root/:drafts).to_a
332
331
  files = files.grep(/#{tag}-.*lt3/)
333
332
  files = files.map {|f| File.basename(f) }
334
333
  if files.size > 1
@@ -345,7 +344,7 @@ puts "Got to #{__method__}"
345
344
  end
346
345
 
347
346
  file = files.first
348
- draft = "#{@blog.root}/drafts/#{file}"
347
+ draft = @blog.root/:drafts/file
349
348
  result = edit_file(draft)
350
349
  @blog.generate_post(draft)
351
350
  rescue => err
@@ -478,11 +477,9 @@ puts "Got to #{__method__}"
478
477
  cmd = "cp #{name} #{@blog.root}/drafts/#@fname"
479
478
  result = system!(cmd)
480
479
  raise CantCopy(name, "#{@blog.root}/drafts/#@fname") unless result
481
- puts(`ls -l #{@blog.root}/drafts`)
482
- puts "@fname = #@fname"
483
- puts "Pause..."
484
- gets
485
- @meta = @blog.process_post(@fname)
480
+ # post = Post.load(@slug)
481
+ draft = "#{@blog.root}/drafts/#@fname"
482
+ @meta = @blog.generate_post(draft)
486
483
  puts
487
484
  sleep 2
488
485
  end
@@ -497,9 +494,10 @@ gets
497
494
  {h, help} This message {change view VIEW} Change current view
498
495
  {q, quit} Exit the program {cv VIEW} Change current view
499
496
  {v, version} Print version information {new view} Create a new view
500
- {list views} List all views available
497
+ {clear} Clear screen {list views} List all views available
501
498
  {lsv} Same as: list views
502
499
 
500
+
503
501
  {Posts:} {Advanced:}
504
502
  ------------------------------------------- -------------------------------------------
505
503
  {p, post} Create a new post {config} Edit various system files
@@ -1,5 +1,6 @@
1
1
  require 'date'
2
2
  require 'find'
3
+ require 'ostruct'
3
4
 
4
5
  require 'logging'
5
6
 
@@ -117,13 +118,10 @@ class RuneBlog
117
118
  Dir.chdir(dir) do
118
119
  views = _retrieve_metadata(:views)
119
120
  views.each do |v|
120
- puts "VIEW = #{v} dir = #{dir}"
121
121
  unless self.view?(v)
122
122
  puts "#{fx("Warning:", :red)} #{fx(v, :bold)} is not a view"
123
123
  next
124
124
  end
125
- puts "pwd = #{Dir.pwd}"
126
- puts "cp *html #@root/views/#{v}/remote"
127
125
  system!("cp *html #@root/views/#{v}/remote", show: true)
128
126
  end
129
127
  end
@@ -160,13 +158,9 @@ puts "cp *html #@root/views/#{v}/remote"
160
158
  log!(enter: __method__, args: [sourcefile], level: 2)
161
159
  nslug = sourcefile.sub(/.lt3/, "")
162
160
  dir = @root/:posts/nslug
163
- # puts "sourcefile = #{sourcefile}"
164
- puts "-- dir = #{dir}\n pwd = #{Dir.pwd}\n @root = #@root"
165
- gets
166
161
  create_dirs(dir)
167
162
  # FIXME dependencies?
168
- xlate cwd: dir, src: @root/:drafts/sourcefile, debug: true
169
- # puts `ls -l #{dir}`
163
+ xlate cwd: dir, src: @root/:drafts/sourcefile # , debug: true
170
164
  _deploy_local(dir)
171
165
  rescue => err
172
166
  _tmp_error(err)
@@ -345,7 +339,6 @@ gets
345
339
  vp.nslug, vp.aslug, vp.title, vp.date, vp.teaser_text
346
340
  path = vp.path
347
341
  url = aslug + ".html"
348
- # puts "--- vp = #{[vp.nslug, vp.aslug, vp.title, vp.date, vp.teaser_text].inspect}"; gets
349
342
  date = ::Date.parse(date)
350
343
  date = date.strftime("%B %e<br><div style='float: right'>%Y</div>")
351
344
  text = interpolate(@_post_entry, binding)
@@ -394,7 +387,7 @@ gets
394
387
  meta = nil
395
388
  views = views + [self.view.to_s]
396
389
  views.uniq!
397
- Dir.chdir(@root/:posts) do
390
+ Dir.chdir(@root/"posts") do
398
391
  post = Post.create(title: title, teaser: teaser, body: body, pubdate: pubdate, views: views)
399
392
  post.edit unless testing
400
393
  post.build
@@ -408,17 +401,6 @@ gets
408
401
  def import_legacy_post(file, oldfile, testing = false)
409
402
  end
410
403
 
411
- def edit_initial_post(file, testing = false)
412
- log!(enter: __method__, args: [file, testing], level: 3)
413
- debug "=== edit_initial_post #{file.inspect} => #{file}"
414
- result = system!("#@editor #{file} +8") unless testing
415
- raise EditorProblem(file) unless result
416
- process_post(file)
417
- nil
418
- rescue => err
419
- error(err)
420
- end
421
-
422
404
  def posts
423
405
  log!(enter: __method__, level: 3)
424
406
  dir = self.view.dir/:posts
@@ -457,11 +439,12 @@ gets
457
439
  depend = [vdir/"remote/etc/blog.css", @theme/"global.lt3",
458
440
  @theme/"blog/head.lt3", @theme/"navbar/navbar.lt3",
459
441
  @theme/"blog/index.lt3"] # FIXME what about assets?
460
- xlate cwd: vdir/"themes/standard/etc", deps: depend,
442
+ xlate cwd: vdir/"themes/standard/etc", deps: depend,
461
443
  src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
462
- xlate cwd: vdir/"themes/standard", deps: depend,
444
+ xlate cwd: vdir/"themes/standard", deps: depend, force: true,
463
445
  src: "blog/generate.lt3", dst: vdir/:remote/"index.html"
464
446
  copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
447
+ copy_widget_html(view)
465
448
  rescue => err
466
449
  _tmp_error(err)
467
450
  end
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.2.52"
5
+ VERSION = "0.2.57"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
@@ -24,19 +24,18 @@ def xlate(cwd: Dir.pwd, src:,
24
24
  indent = " "*12
25
25
  Dir.chdir(cwd) do
26
26
  if debug
27
- STDERR.puts "#{indent} -- xlate #{src} >#{dst}"
28
- STDERR.puts "#{indent} in: #{Dir.pwd}"
29
- STDERR.puts "#{indent} from: #{caller[0]}"
30
- STDERR.puts "#{indent} copy: #{copy}" if copy
27
+ puts "#{indent} -- xlate #{src} >#{dst}"
28
+ puts "#{indent} in: #{Dir.pwd}"
29
+ puts "#{indent} from: #{caller[0]}"
30
+ puts "#{indent} copy: #{copy}" if copy
31
31
  end
32
32
  stale = stale?(src, dst, deps, force)
33
- # puts "stale? src = #{src}\n dst = #{dst}\n #{stale}"
34
33
  if stale
35
34
  rc = system("livetext #{src} >#{dst}")
36
- STDERR.puts "...completed (shell returned #{rc})" if debug
35
+ puts "...completed (shell returned #{rc})" if debug
37
36
  system!("cp #{dst} #{copy}") if copy
38
37
  else
39
- STDERR.puts "#{indent} -- ^ Already up to date!" if debug
38
+ puts "#{indent} -- ^ Already up to date!" if debug
40
39
  return
41
40
  end
42
41
  end
@@ -34,6 +34,7 @@ spec = Gem::Specification.new do |s|
34
34
  s.files = main + misc + test + empty_view
35
35
  s.homepage = 'https://github.com/Hal9000/runeblog'
36
36
  s.license = "Ruby"
37
+ s.post_install_message = "\n Success! Run 'blog' command and type h for help.\n "
37
38
  end
38
39
 
39
40
  spec
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.2.52
4
+ version: 0.2.57
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-10-26 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -65,15 +65,19 @@ files:
65
65
  - empty_view/assets/austin-pano.jpg
66
66
  - empty_view/assets/sky2.jpg
67
67
  - empty_view/remote/assets/GIT_IS_DUMB
68
+ - empty_view/remote/banner/austin-pano.jpg
69
+ - empty_view/remote/banner/top.html
68
70
  - empty_view/remote/etc/GIT_IS_DUMB
69
71
  - empty_view/remote/navbar/GIT_IS_DUMB
70
72
  - empty_view/remote/permalink/GIT_IS_DUMB
71
73
  - empty_view/themes/standard/README
72
74
  - empty_view/themes/standard/banner/about.lt3
75
+ - empty_view/themes/standard/banner/austin-pano.jpg
73
76
  - empty_view/themes/standard/banner/blog-banner.jpg
74
77
  - empty_view/themes/standard/banner/contact.lt3
75
78
  - empty_view/themes/standard/banner/faq.lt3
76
79
  - empty_view/themes/standard/banner/navbar.lt3
80
+ - empty_view/themes/standard/banner/top.html
77
81
  - empty_view/themes/standard/blog/generate.lt3
78
82
  - empty_view/themes/standard/blog/head.lt3
79
83
  - empty_view/themes/standard/blog/index.lt3
@@ -218,7 +222,7 @@ homepage: https://github.com/Hal9000/runeblog
218
222
  licenses:
219
223
  - Ruby
220
224
  metadata: {}
221
- post_install_message:
225
+ post_install_message: "\n Success! Run 'blog' command and type h for help.\n "
222
226
  rdoc_options: []
223
227
  require_paths:
224
228
  - lib