runeblog 0.2.56 → 0.2.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,3 @@
1
+ about About
2
+ contact Contact
3
+ faq FAQ
@@ -8,8 +8,8 @@
8
8
  .recent_posts
9
9
 
10
10
  .sidebar
11
- ad
12
11
  links
12
+ ad
13
13
  pinned
14
14
  pages
15
15
  news
@@ -4,30 +4,43 @@ require 'liveblog'
4
4
 
5
5
  class ::RuneBlog::Widget
6
6
  class Links
7
- Type = "links"
7
+ Type, Title = "links", "External links"
8
8
 
9
9
  def initialize(repo)
10
10
  @blog = repo
11
+ @datafile = input = "list.data"
12
+ @lines = File.readlines(input)
11
13
  end
12
14
 
13
15
  def build
14
- input = "list.data"
15
- @lines = File.readlines(input)
16
16
  write_main
17
17
  write_card
18
18
  end
19
19
 
20
+ def _html_body(file, css = nil)
21
+ file.puts "<html>"
22
+ if css
23
+ file.puts " <head>"
24
+ file.puts " <style>\n#{css}\n </style>"
25
+ file.puts " </head>"
26
+ end
27
+ file.puts " <body>"
28
+ yield
29
+ file.puts " </body>\n</html>"
30
+ end
31
+
20
32
  def write_main
21
33
  @data = @lines.map! {|x| x.chomp.split(/, */, 3) }
22
34
  css = "* { font-family: verdana }"
23
- card_title = "External Links" # FIXME
35
+ card_title = Title
24
36
  File.open("#{Type}-main.html", "w") do |f|
25
37
  _html_body(f, css) do
26
38
  f.puts "<h1>#{card_title}</h1><br><hr>"
27
39
  url_ref = nil
28
40
  @data.each do |url, frameable, title|
29
- url_ref = (frameable == "yes") ? "href = '#{url}'" : _blank(url)
30
- css = "color: #8888FF; text-decoration: none; font-size: 21px" # ; font-family: verdana"
41
+ url_ref = "href = '#{url}'"
42
+ url_ref << " target=blank" if frameable == "yes"
43
+ css = "color: #8888FF; text-decoration: none; font-size: 21px"
31
44
  f.puts %[<a style="#{css}" #{url_ref}>#{title}</a> <br>]
32
45
  end
33
46
  end
@@ -38,7 +51,7 @@ class ::RuneBlog::Widget
38
51
  tag = "links"
39
52
  url = :widgets/tag/tag+"-main.html"
40
53
  card_title = "External links" # FIXME
41
- cardfile = "#@self-card"
54
+ cardfile = "#{Type}-card"
42
55
  File.open("#{cardfile}.html", "w") do |f|
43
56
  f.puts <<-EOS
44
57
  <div class="card mb-3">
@@ -52,6 +65,7 @@ class ::RuneBlog::Widget
52
65
  <div class="collapse" id="#{tag}">
53
66
  EOS
54
67
  @data.each do |url2, frameable, title|
68
+ f.puts "<!-- #{[url2, frameable, title].inspect} -->"
55
69
  main_ref = %[href="javascript: void(0)" onclick="javascript:open_main('#{url2}')"]
56
70
  tab_ref = %[href="#{url2}"]
57
71
  url_ref = (frameable == "yes") ? main_ref : tab_ref
@@ -2,11 +2,81 @@
2
2
 
3
3
  class ::RuneBlog::Widget
4
4
  class News
5
+ Type, Title = "news", "News"
6
+
5
7
  def initialize(repo)
6
8
  @blog = repo
9
+ @datafile = "list.data"
10
+ lines = File.readlines(@datafile)
11
+ @data = lines.map {|line| line.chomp.split(/, */) }
7
12
  end
8
13
 
9
14
  def build
15
+ write_main
16
+ write_card
17
+ end
18
+
19
+ def _html_body(file, css = nil)
20
+ file.puts "<html>"
21
+ if css
22
+ file.puts " <head>"
23
+ file.puts " <style>\n#{css}\n </style>"
24
+ file.puts " </head>"
25
+ end
26
+ file.puts " <body>"
27
+ yield
28
+ file.puts " </body>\n</html>"
29
+ end
30
+
31
+ def write_main
32
+ mainfile = "#{Type}-main"
33
+ css = "* { font-family: verdana }"
34
+ File.open("#{mainfile}.html", "w") do |f|
35
+ _html_body(f, css) do
36
+ f.puts "<h1>#{Title}</h1><br><hr>"
37
+ @data.each do |file, frameable, title|
38
+ title = title.gsub(/\\/, "") # kludge
39
+ case frameable
40
+ when "yes"; url_ref = "href = '#{file}'"
41
+ when "no"; url_ref = %[href='#{file}' target='blank']
42
+ end
43
+ css = "color: #8888FF; text-decoration: none; font-size: 21px"
44
+ f.puts %[<a style="#{css}" #{url_ref}>#{title}</a> <br>]
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ def write_card
51
+ cardfile = "#{Type}-card"
52
+ url = "widgets/#{Type}/#{Type}-main.html"
53
+ File.open("#{cardfile}.html", "w") do |f|
54
+ f.puts <<-EOS
55
+ <div class="card mb-3">
56
+ <div class="card-body">
57
+ <h5 class="card-title">
58
+ <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="##{Type}">+</button>
59
+ <a href="javascript: void(0)"
60
+ onclick="javascript:open_main('#{url}')"
61
+ style="text-decoration: none; color: black"> #{Title}</a>
62
+ </h5>
63
+ <div class="collapse" id="#{Type}">
64
+ EOS
65
+ @data.each do |file, frameable, title|
66
+ case frameable
67
+ when "yes"; url_ref = _main(file) # remote, frameable
68
+ when "no"; url_ref = _blank(file) # remote, not frameable
69
+ end
70
+ anchor = %[<a #{url_ref}>#{title}</a>]
71
+ wrapper = %[<li class="list-group-item">#{anchor}</li>]
72
+ f.puts wrapper
73
+ end
74
+ f.puts <<-EOS
75
+ </div>
76
+ </div>
77
+ </div>
78
+ EOS
79
+ end
10
80
  end
11
81
 
12
82
  def edit_menu
@@ -4,8 +4,13 @@
4
4
 
5
5
  class ::RuneBlog::Widget
6
6
  class Pages
7
+ Type, Title = "pages", "Pages"
8
+
7
9
  def initialize(repo)
8
10
  @blog = repo
11
+ @datafile = "list.data"
12
+ @lines = File.readlines(@datafile)
13
+ @data = @lines.map {|x| x.chomp.split(/, */, 2) }
9
14
  end
10
15
 
11
16
  def build
@@ -13,10 +18,72 @@ class ::RuneBlog::Widget
13
18
  children = Dir["*.lt3"] - ["pages.lt3"]
14
19
  children.each do |child|
15
20
  dest = child.sub(/.lt3$/, ".html")
16
- xlate src: child, dst: dest # , debug: true
21
+ xlate src: child, dst: dest
22
+ end
23
+ write_main
24
+ write_card
25
+ end
26
+
27
+ def _html_body(file, css = nil)
28
+ file.puts "<html>"
29
+ if css
30
+ file.puts " <head>"
31
+ file.puts " <style>\n#{css}\n </style>"
32
+ file.puts " </head>"
33
+ end
34
+ file.puts " <body>"
35
+ yield
36
+ file.puts " </body>\n</html>"
37
+ end
38
+
39
+ def write_main
40
+ css = "* { font-family: verdana }"
41
+ card_title = Title
42
+ File.open("#{Type}-main.html", "w") do |f|
43
+ _html_body(f, css) do
44
+ f.puts "<h1>#{card_title}</h1><br><hr>"
45
+ url_ref = nil
46
+ @data.each do |url, title|
47
+ url_ref = "href = '#{url}'"
48
+ css = "color: #8888FF; text-decoration: none; font-size: 21px"
49
+ f.puts %[<a style="#{css}" #{url_ref}>#{title}</a> <br>]
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def write_card
56
+ tag = Type
57
+ url = :widgets/tag/tag+"-main.html"
58
+ card_title = "Pages" # FIXME
59
+ cardfile = "#{Type}-card"
60
+ File.open("#{cardfile}.html", "w") do |f|
61
+ f.puts <<-EOS
62
+ <div class="card mb-3">
63
+ <div class="card-body">
64
+ <h5 class="card-title">
65
+ <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="##{tag}">+</button>
66
+ <a href="javascript: void(0)"
67
+ onclick="javascript:open_main('#{url}')"
68
+ style="text-decoration: none; color: black">#{card_title}</a>
69
+ </h5>
70
+ <div class="collapse" id="#{tag}">
71
+ EOS
72
+ @data.each do |url2, title|
73
+ f.puts "<!-- #{[url2, title].inspect} -->"
74
+ url3 = :widgets/tag/url2
75
+ f.puts "<!-- url3 = #{url3.inspect} -->"
76
+ url_ref = %[href="javascript: void(0)" onclick="javascript:open_main('#{url3}')"]
77
+ anchor = %[<a #{url_ref}>#{title}</a>]
78
+ wrapper = %[<li class="list-group-item">#{anchor}</li>]
79
+ f.puts wrapper
80
+ end
81
+ f.puts <<-EOS
82
+ </div>
83
+ </div>
84
+ </div>
85
+ EOS
17
86
  end
18
- # build mainfile
19
- # build cardfile
20
87
  end
21
88
 
22
89
  def edit_menu
@@ -2,31 +2,35 @@
2
2
 
3
3
  class ::RuneBlog::Widget
4
4
  class Pinned
5
+ Type, Title = "pinned", "Pinned posts"
6
+
5
7
  def initialize(repo)
6
8
  @blog = repo
7
- @self = "pinned"
9
+ @datafile = "list.data"
10
+ # f = File.new("/tmp/mehhh", "w")
11
+ @lines = File.exist?(@datafile) ? File.readlines(@datafile) : []
12
+ # f.puts #{@lines.inspect} in #{Dir.pwd}"
13
+ File.open("/tmp/mehhh", "w") {|f| f.puts "#{@lines.inspect} in #{Dir.pwd}" }
8
14
  end
9
15
 
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
16
+ def _html_body(file, css = nil) # FIXME
17
+ file.puts "<html>"
18
+ if css
19
+ file.puts " <head>"
20
+ file.puts " <style>\n#{css}\n </style>"
21
+ file.puts " </head>"
22
+ end
23
+ file.puts " <body>"
24
+ yield
25
+ file.puts " </body>\n</html>"
26
+ end
21
27
 
22
28
  def build
23
- @tmp = File.new("/tmp/debug-out", "w")
24
29
  posts = nil
25
30
  Dir.chdir(@blog.root/:posts) { posts = Dir["*"] }
26
- lines = File.readlines("list.data")
27
31
  hash = {}
28
32
  @links = []
29
- lines.each do |x|
33
+ @lines.each do |x|
30
34
  num, title = x.chomp.split(" ", 2)
31
35
  hash[num] = title
32
36
  pre = '%04d' % num
@@ -40,13 +44,13 @@ end
40
44
  end
41
45
 
42
46
  def write_main
43
- tag = "pinned"
44
- card_title = "Pinned posts" # FIXME
45
- # setvar "card.title", card_title
47
+ tag = Type
48
+ card_title = Title
46
49
  css = "* { font-family: verdana }"
47
- mainfile = "#@self-main"
50
+ mainfile = "#{tag}-main"
48
51
  File.open("#{mainfile}.html", "w") do |f|
49
52
  _html_body(f, css) do
53
+ f.puts "<!-- #{@lines.inspect} in #{Dir.pwd} -->"
50
54
  f.puts "<h1>#{card_title}</h1><br><hr>"
51
55
  @links.each do |title, file|
52
56
  title = title.gsub(/\\/, "") # kludge
@@ -58,10 +62,10 @@ end
58
62
  end
59
63
 
60
64
  def write_card
61
- tag = "pinned"
65
+ tag = Type
62
66
  url = :widgets/tag/tag+"-main.html"
63
- card_title = "Pinned posts" # FIXME
64
- cardfile = "#@self-card"
67
+ card_title = Title
68
+ cardfile = "#{tag}-card"
65
69
  File.open("#{cardfile}.html", "w") do |f|
66
70
  f.puts <<-EOS
67
71
  <div class="card mb-3">
@@ -86,6 +86,12 @@ def backlink
86
86
  _out %[<br><a href="javascript:history.go(-1)">[Back]</a>]
87
87
  end
88
88
 
89
+ def _read_navbar_data
90
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner/"
91
+ datafile = dir/"list.data"
92
+ File.readlines(datafile)
93
+ end
94
+
89
95
  def banner # still experimental
90
96
  _out "<table width=100% bgcolor=#101035>"
91
97
  _out " <tr>"
@@ -98,31 +104,48 @@ def banner # still experimental
98
104
  case arg
99
105
  when "image"
100
106
  image = "banner/banner.jpg"
101
- _out " <td colspan=#{span}><img src=#{image} height=150></img></td>"
107
+ _out " <td colspan=#{span}><img src=#{image} height=150></img></td>" +
108
+ " <!-- #{arg} -->"
102
109
  when "image:"
103
110
  image = "banner/#{enum.next}"
104
- _out " <td colspan=#{span}><img src=#{image} height=150></img></td>"
111
+ _out " <td colspan=#{span}><img src=#{image} height=150></img></td>" +
112
+ " <!-- #{arg} -->"
105
113
  when "text"
106
- file = "banner/text.html"
107
- _out "<td colspan=#{span}>" + File.read(file) + "</td>"
114
+ file = "banner/top.html"
115
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>" +
116
+ " <!-- #{arg} -->"
108
117
  when "text:"
109
118
  file = "banner/#{enum.next}"
110
- _out "<td colspan=#{span}>" + File.read(file) + "</td>"
119
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>" +
120
+ " <!-- #{arg} -->"
111
121
  when "navbar"
112
- file = "navbar/navbar.html"
113
- _out "<td colspan=#{span}><div style='text-align: center'>" + File.read(file) + "</div></td>"
122
+ # STDERR.puts "-- navbar: pwd = #{Dir.pwd}: #{`ls`}"
123
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner/"
124
+ _make_navbar # horiz is default
125
+ # xlate cwd: dir, src: "navbar.lt3", dst: "navbar.html" # , debug: true
126
+ stuff = File.read("banner/navbar.html")
127
+ _out "<td colspan=#{span}><div style='text-align: center'>#{stuff}</div></td>" +
128
+ " <!-- #{arg} -->"
114
129
  when "vnavbar"
115
- file = "navbar/vnavbar.html"
116
- _out "<td colspan=#{span}>" + File.read(file) + "</td>"
130
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner/"
131
+ _make_navbar(:vert)
132
+ # xlate cwd: dir, src: "vnavbar.lt3", dst: "vnavbar.html" # , debug: true
133
+ file = "banner/vnavbar.html"
134
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>" +
135
+ "<!-- #{arg} -->"
117
136
  when "//"
118
137
  span = count - 1
119
- _out " </tr>\n <tr>"
138
+ _out " </tr>\n <tr>" + "<!-- #{arg} -->"
120
139
  else
121
140
  _out " '#{arg}' isn't known"
122
141
  end
123
142
  end
124
143
  _out " </tr>"
125
144
  _out "</table>"
145
+ rescue => err
146
+ STDERR.puts "err = #{err}"
147
+ STDERR.puts err.backtrace.join("\n")
148
+ gets
126
149
  end
127
150
 
128
151
  def quote
@@ -286,16 +309,15 @@ def pin
286
309
  end
287
310
  pins << "#{@meta.num} #{@meta.title}\n"
288
311
  pins.uniq!
289
- outfile = File.new(datafile, "w")
290
- pins.each do |pin|
291
- outfile.puts pin
312
+ File.open(datafile, "w") do |outfile|
313
+ pins.each {|pin| outfile.puts pin }
292
314
  end
293
- outfile.close
294
315
  end
295
316
  _optional_blank_line
317
+ pinned_rebuild # FIXME experimental
296
318
  rescue => err
297
- puts "err = #{err}"
298
- puts err.backtrace.join("\n")
319
+ STDERR.puts "err = #{err}"
320
+ STDERR.puts err.backtrace.join("\n")
299
321
  gets
300
322
  end
301
323
 
@@ -326,7 +348,8 @@ end
326
348
  def finalize
327
349
  # FIXME simplify this!
328
350
  unless @meta
329
- puts @live.body
351
+ STDERR.puts "META is nil: file = #{Livetext::Vars[:File]}"
352
+ # puts @live.body
330
353
  return
331
354
  end
332
355
  if @blog.nil?
@@ -446,6 +469,22 @@ rescue => err
446
469
  exit
447
470
  end
448
471
 
472
+ def pinned_rebuild
473
+ view = @blog.view
474
+ view = _args[0] unless _args.empty?
475
+ Dir.chdir(@blog.root/:views/view/"themes/standard/") do
476
+ wtag = "widgets/pinned"
477
+ code = _load_local("pinned")
478
+ if code
479
+ Dir.chdir(wtag) do
480
+ widget = code.new(@blog)
481
+ widget.build
482
+ end
483
+ _include_file wtag/"pinned-card.html"
484
+ end
485
+ end
486
+ end
487
+
449
488
  def sidebar
450
489
  _debug "--- handling sidebar\r"
451
490
  if _args.include? "off"
@@ -465,7 +504,7 @@ def sidebar
465
504
 
466
505
  code = _load_local(tag)
467
506
  if code
468
- if ["pages", "links", "pinned"].include? tag
507
+ if ["news", "pages", "links", "pinned"].include? tag
469
508
  Dir.chdir(wtag) do
470
509
  widget = code.new(@blog)
471
510
  widget.build
@@ -483,16 +522,16 @@ def sidebar
483
522
  File.open(wtag/"vars.lt3", "w") do |f|
484
523
  f.puts ".set ad.image = #{img}"
485
524
  end
525
+ xlate cwd: wtag, src: tag, dst: tcard, force: true # , deps: depend # , debug: true
486
526
  end
487
527
 
488
- depend = %w[card.css main.css custom.rb local.rb]
489
- depend += ["#{wtag}.lt3", "#{wtag}.rb"]
490
- depend += %w[pieces/card-head.lt3 pieces/card-tail.lt3]
491
- depend += %w[pieces/main-head.lt3 pieces/main-tail.lt3]
492
- depend.map! {|x| @blog.view.dir/"themes/standard/widgets"/wtag/x }
493
- _debug "--- call xlate #{tag} src = #{tag} dst = #{tcard}\r"
494
- xlate cwd: wtag, src: tag, dst: tcard, force: true, deps: depend # , debug: true
495
528
  _include_file wtag/tcard
529
+ # depend = %w[card.css main.css custom.rb local.rb]
530
+ # depend += ["#{wtag}.lt3", "#{wtag}.rb"]
531
+ # depend += %w[pieces/card-head.lt3 pieces/card-tail.lt3]
532
+ # depend += %w[pieces/main-head.lt3 pieces/main-tail.lt3]
533
+ # depend.map! {|x| @blog.view.dir/"themes/standard/widgets"/wtag/x }
534
+ # _debug "--- call xlate #{tag} src = #{tag} dst = #{tcard}\r"
496
535
  end
497
536
  _out %[</div>]
498
537
  rescue => err
@@ -646,96 +685,61 @@ def tag_cloud
646
685
  end
647
686
 
648
687
  def vnavbar
649
- _custom_navbar(:vert)
688
+ str = _make_navbar(:vert)
689
+ # _out str
650
690
  end
651
691
 
652
692
  def hnavbar
653
- _custom_navbar # horiz is default
693
+ str = _make_navbar # horiz is default
694
+ # _out str
654
695
  end
655
696
 
656
697
  def navbar
657
- _custom_navbar # horiz is default
698
+ str = _make_navbar # horiz is default
699
+ # _out str
658
700
  end
659
701
 
660
- def _custom_navbar(orient = :horiz)
702
+ def _make_navbar(orient = :horiz)
661
703
  vdir = @blog.view.dir
662
704
  title = _var(:blog)
663
705
 
664
706
  extra = ""
665
707
  extra = "navbar-expand-lg" if orient == :horiz
666
708
 
667
- open = <<-HTML
709
+ start = <<-HTML
710
+ <!-- FIXME weird bug here!!! -->
668
711
  <nav class="navbar #{extra} navbar-light bg-light">
669
712
  <ul class="navbar-nav mr-auto">
670
713
  HTML
671
- close = <<-HTML
714
+ finish = <<-HTML
672
715
  </ul>
673
716
  </nav>
674
717
  HTML
675
718
 
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
679
- lines = _body
680
- lines = [" index Home"] + lines unless _args.include?("nohome")
719
+ name = (orient == :horiz) ? "navbar.html" : "vnavbar.html"
720
+
721
+ html_file = @blog.root/:views/@blog.view/"themes/standard/banner"/name
722
+ output = File.new(html_file, "w")
723
+ output.puts start
724
+ lines = _read_navbar_data
725
+ lines = ["index Home"] + lines unless _args.include?("nohome")
681
726
  lines.each do |line|
682
727
  basename, cdata = line.chomp.strip.split(" ", 2)
683
- full = :navbar/basename+".html"
728
+ full = :banner/basename+".html"
684
729
  href_main = _main(full)
685
730
  if basename == "index" # special case
686
731
  output.puts %[<li class="nav-item active"> <a class="nav-link" href="index.html">#{cdata}<span class="sr-only">(current)</span></a> </li>]
687
732
  else
688
- xlate cwd: "navbar", src: basename, dst: vdir/"remote/navbar"/basename+".html" # , debug: true
733
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner"
734
+ xlate cwd: dir, src: basename, dst: vdir/"remote/banner"/basename+".html" # , debug: true
689
735
  output.puts %[<li class="nav-item"> <a class="nav-link" #{href_main}>#{cdata}</a> </li>]
690
736
  end
691
737
  end
692
- output.puts close
738
+ output.puts finish
739
+ output.close
740
+ return File.read(html_file)
693
741
  end
694
742
 
695
- def _old_navbar
696
- vdir = @blog.view.dir
697
- title = _var(:blog)
698
-
699
- open = <<-HTML
700
- <nav class="navbar navbar-expand-lg navbar-light bg-light">
701
- <a class="navbar-brand" href="index.html">#{title}</a>
702
- <button class="navbar-toggler"
703
- type="button"
704
- data-toggle="collapse"
705
- data-target="#navbarSupportedContent"
706
- aria-controls="navbarSupportedContent"
707
- aria-expanded="false"
708
- aria-label="Toggle navigation">
709
- <span class="navbar-toggler-icon"></span>
710
- </button>
711
- <div class="collapse navbar-collapse pull-right"
712
- id="navbarSupportedContent">
713
- <ul class="navbar-nav mr-auto">
714
- HTML
715
- close = <<-HTML
716
- </ul>
717
- </div>
718
- </nav>
719
- HTML
720
-
721
- first = true
722
- _out open
723
- lines = _body
724
- lines.each do |line|
725
- basename, cdata = line.chomp.strip.split(" ", 2)
726
- full = :navbar/basename+".html"
727
- href_main = _main(full)
728
- if first
729
- first = false # hardcode this part??
730
- _out %[<li class="nav-item active"> <a class="nav-link" href="index.html">#{cdata}<span class="sr-only">(current)</span></a> </li>]
731
- else
732
- depend = Find.find(@blog.root/:views/@blog.view.to_s/"themes/standard/navbar/").to_a
733
- xlate cwd: "navbar", src: basename, dst: vdir/"remote/navbar"/basename+".html", deps: depend # , debug: true
734
- _out %[<li class="nav-item"> <a class="nav-link" #{href_main}>#{cdata}</a> </li>]
735
- end
736
- end
737
- _out close
738
- end
739
743
 
740
744
  ##################
741
745
  # helper methods