runeblog 0.2.54 → 0.2.59

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,35 +86,66 @@ 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
- _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?("navbar")
100
- file = "navbar/navbar.html"
101
- _out File.read(file)
102
- when piece.start_with?("text")
103
- file = piece.split(":")[1]
104
- file ||= "banner/text.html"
105
- _out File.read(file)
106
- when piece.start_with?("image")
107
- image = piece.split(":")[1]
108
- image ||= "banner/banner.jpg"
109
- _out " <img src=#{image} height=100></img>"
110
- else
111
- _out " '#{piece}' isn't known"
112
- end
113
- _out " </td>"
96
+ _out "<table width=100% bgcolor=#101035>"
97
+ _out " <tr>"
98
+ enum = _args.each
99
+ count = 0
100
+ span = 1
101
+ loop do
102
+ count += 1
103
+ arg = enum.next
104
+ case arg
105
+ when "image"
106
+ image = "banner/banner.jpg"
107
+ _out " <td colspan=#{span}><img src=#{image} height=150></img></td>" +
108
+ " <!-- #{arg} -->"
109
+ when "image:"
110
+ image = "banner/#{enum.next}"
111
+ _out " <td colspan=#{span}><img src=#{image} height=150></img></td>" +
112
+ " <!-- #{arg} -->"
113
+ when "text"
114
+ file = "banner/top.html"
115
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>" +
116
+ " <!-- #{arg} -->"
117
+ when "text:"
118
+ file = "banner/#{enum.next}"
119
+ _out "<td colspan=#{span}>" + File.read(file) + "</td>" +
120
+ " <!-- #{arg} -->"
121
+ when "navbar"
122
+ # STDERR.puts "-- navbar: pwd = #{Dir.pwd}: #{`ls`}"
123
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner/"
124
+ hnavbar
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} -->"
129
+ when "vnavbar"
130
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner/"
131
+ vnavbar
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} -->"
136
+ when "//"
137
+ span = count - 1
138
+ _out " </tr>\n <tr>" + "<!-- #{arg} -->"
139
+ else
140
+ _out " '#{arg}' isn't known"
114
141
  end
115
- _out " </tr>"
116
142
  end
143
+ _out " </tr>"
117
144
  _out "</table>"
145
+ rescue => err
146
+ STDERR.puts "err = #{err}"
147
+ STDERR.puts err.backtrace.join("\n")
148
+ gets
118
149
  end
119
150
 
120
151
  def quote
@@ -278,16 +309,15 @@ def pin
278
309
  end
279
310
  pins << "#{@meta.num} #{@meta.title}\n"
280
311
  pins.uniq!
281
- outfile = File.new(datafile, "w")
282
- pins.each do |pin|
283
- outfile.puts pin
312
+ File.open(datafile, "w") do |outfile|
313
+ pins.each {|pin| outfile.puts pin }
284
314
  end
285
- outfile.close
286
315
  end
287
316
  _optional_blank_line
317
+ pinned_rebuild # FIXME experimental
288
318
  rescue => err
289
- puts "err = #{err}"
290
- puts err.backtrace.join("\n")
319
+ STDERR.puts "err = #{err}"
320
+ STDERR.puts err.backtrace.join("\n")
291
321
  gets
292
322
  end
293
323
 
@@ -426,6 +456,7 @@ def _make_class_name(app)
426
456
  end
427
457
 
428
458
  def _load_local(widget)
459
+ STDERR.puts "widget = #{widget} pwd = #{Dir.pwd}"
429
460
  Dir.chdir("widgets/#{widget}") do
430
461
  rclass = _make_class_name(widget)
431
462
  found = (require("./#{widget}") if File.exist?("#{widget}.rb"))
@@ -438,6 +469,20 @@ rescue => err
438
469
  exit
439
470
  end
440
471
 
472
+ def pinned_rebuild
473
+ Dir.chdir(@blog.root/:views/@blog.view/"themes/standard/") do
474
+ wtag = "widgets/pinned"
475
+ code = _load_local("pinned")
476
+ if code
477
+ Dir.chdir(wtag) do
478
+ widget = code.new(@blog)
479
+ widget.build
480
+ end
481
+ _include_file wtag/"pinned-card.html"
482
+ end
483
+ end
484
+ end
485
+
441
486
  def sidebar
442
487
  _debug "--- handling sidebar\r"
443
488
  if _args.include? "off"
@@ -457,7 +502,7 @@ def sidebar
457
502
 
458
503
  code = _load_local(tag)
459
504
  if code
460
- if ["pages", "links", "pinned"].include? tag
505
+ if ["news", "pages", "links", "pinned"].include? tag
461
506
  Dir.chdir(wtag) do
462
507
  widget = code.new(@blog)
463
508
  widget.build
@@ -475,16 +520,16 @@ def sidebar
475
520
  File.open(wtag/"vars.lt3", "w") do |f|
476
521
  f.puts ".set ad.image = #{img}"
477
522
  end
523
+ xlate cwd: wtag, src: tag, dst: tcard, force: true # , deps: depend # , debug: true
478
524
  end
479
525
 
480
- depend = %w[card.css main.css custom.rb local.rb]
481
- depend += ["#{wtag}.lt3", "#{wtag}.rb"]
482
- depend += %w[pieces/card-head.lt3 pieces/card-tail.lt3]
483
- depend += %w[pieces/main-head.lt3 pieces/main-tail.lt3]
484
- depend.map! {|x| @blog.view.dir/"themes/standard/widgets"/wtag/x }
485
- _debug "--- call xlate #{tag} src = #{tag} dst = #{tcard}\r"
486
- xlate cwd: wtag, src: tag, dst: tcard, force: true, deps: depend # , debug: true
487
526
  _include_file wtag/tcard
527
+ # depend = %w[card.css main.css custom.rb local.rb]
528
+ # depend += ["#{wtag}.lt3", "#{wtag}.rb"]
529
+ # depend += %w[pieces/card-head.lt3 pieces/card-tail.lt3]
530
+ # depend += %w[pieces/main-head.lt3 pieces/main-tail.lt3]
531
+ # depend.map! {|x| @blog.view.dir/"themes/standard/widgets"/wtag/x }
532
+ # _debug "--- call xlate #{tag} src = #{tag} dst = #{tcard}\r"
488
533
  end
489
534
  _out %[</div>]
490
535
  rescue => err
@@ -638,96 +683,66 @@ def tag_cloud
638
683
  end
639
684
 
640
685
  def vnavbar
641
- _custom_navbar(:vert)
686
+ str = _make_navbar(:vert)
687
+ _out str
642
688
  end
643
689
 
644
690
  def hnavbar
645
- _custom_navbar # horiz is default
691
+ str = _make_navbar # horiz is default
692
+ STDERR.puts "STR = #{str.inspect}"
693
+ _out str
646
694
  end
647
695
 
648
696
  def navbar
649
- _custom_navbar # horiz is default
697
+ str = _make_navbar # horiz is default
698
+ _out str
650
699
  end
651
700
 
652
- def _custom_navbar(orient = :horiz)
701
+ def _make_navbar(orient = :horiz)
653
702
  vdir = @blog.view.dir
654
703
  title = _var(:blog)
655
704
 
656
705
  extra = ""
657
706
  extra = "navbar-expand-lg" if orient == :horiz
658
707
 
659
- open = <<-HTML
708
+ start = <<-HTML
709
+ <!-- FIXME weird bug here!!! -->
660
710
  <nav class="navbar #{extra} navbar-light bg-light">
661
711
  <ul class="navbar-nav mr-auto">
662
712
  HTML
663
- close = <<-HTML
713
+ finish = <<-HTML
664
714
  </ul>
665
715
  </nav>
666
716
  HTML
667
717
 
668
- html_file = @blog.root/:views/@blog.view/:themes/:standard/:navbar/"navbar.html"
669
- output = File.new(@blog.root/:views/@blog.view/:themes/:standard/:navbar/"navbar.html", "w")
670
- output.puts open
671
- lines = _body
672
- lines = [" index Home"] + lines unless _args.include?("nohome")
718
+ name = (orient == :horiz) ? "navbar.html" : "vnavbar.html"
719
+
720
+ html_file = @blog.root/:views/@blog.view/"themes/standard/banner"/name
721
+ # STDERR.puts "html = #{html_file.inspect} pwd = #{Dir.pwd}"
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")
726
+ STDERR.puts " #{lines.size} lines"
673
727
  lines.each do |line|
728
+ STDERR.puts " handling: #{line.inspect}"
674
729
  basename, cdata = line.chomp.strip.split(" ", 2)
675
- full = :navbar/basename+".html"
730
+ full = :banner/basename+".html"
676
731
  href_main = _main(full)
677
732
  if basename == "index" # special case
678
733
  output.puts %[<li class="nav-item active"> <a class="nav-link" href="index.html">#{cdata}<span class="sr-only">(current)</span></a> </li>]
679
734
  else
680
- xlate cwd: "navbar", src: basename, dst: vdir/"remote/navbar"/basename+".html" # , debug: true
735
+ dir = @blog.root/:views/@blog.view/"themes/standard/banner"
736
+ xlate cwd: dir, src: basename, dst: vdir/"remote/banner"/basename+".html" # , debug: true
681
737
  output.puts %[<li class="nav-item"> <a class="nav-link" #{href_main}>#{cdata}</a> </li>]
682
738
  end
683
739
  end
684
- output.puts close
740
+ output.puts finish
741
+ output.close
742
+ STDERR.puts "-- html_file: #{`ls -l #{html_file}`}"
743
+ return File.read(html_file)
685
744
  end
686
745
 
687
- def _old_navbar
688
- vdir = @blog.view.dir
689
- title = _var(:blog)
690
-
691
- open = <<-HTML
692
- <nav class="navbar navbar-expand-lg navbar-light bg-light">
693
- <a class="navbar-brand" href="index.html">#{title}</a>
694
- <button class="navbar-toggler"
695
- type="button"
696
- data-toggle="collapse"
697
- data-target="#navbarSupportedContent"
698
- aria-controls="navbarSupportedContent"
699
- aria-expanded="false"
700
- aria-label="Toggle navigation">
701
- <span class="navbar-toggler-icon"></span>
702
- </button>
703
- <div class="collapse navbar-collapse pull-right"
704
- id="navbarSupportedContent">
705
- <ul class="navbar-nav mr-auto">
706
- HTML
707
- close = <<-HTML
708
- </ul>
709
- </div>
710
- </nav>
711
- HTML
712
-
713
- first = true
714
- _out open
715
- lines = _body
716
- lines.each do |line|
717
- basename, cdata = line.chomp.strip.split(" ", 2)
718
- full = :navbar/basename+".html"
719
- href_main = _main(full)
720
- if first
721
- first = false # hardcode this part??
722
- _out %[<li class="nav-item active"> <a class="nav-link" href="index.html">#{cdata}<span class="sr-only">(current)</span></a> </li>]
723
- else
724
- depend = Find.find(@blog.root/:views/@blog.view.to_s/"themes/standard/navbar/").to_a
725
- xlate cwd: "navbar", src: basename, dst: vdir/"remote/navbar"/basename+".html", deps: depend # , debug: true
726
- _out %[<li class="nav-item"> <a class="nav-link" #{href_main}>#{cdata}</a> </li>]
727
- end
728
- end
729
- _out close
730
- end
731
746
 
732
747
  ##################
733
748
  # helper methods
@@ -9,12 +9,12 @@ class RuneBlog::Post
9
9
 
10
10
  include RuneBlog::Helpers
11
11
 
12
- def self.files(num, root)
13
- log!(enter: __method__, args: [num, root], level: 3)
14
- files = ::Find.find(root).to_a
15
- result = files.grep(/#{prefix(num)}-/)
16
- result
17
- end
12
+ # def self.files(num, root)
13
+ # log!(enter: __method__, args: [num, root], level: 3)
14
+ # files = ::Find.find(root).to_a
15
+ # result = files.grep(/#{prefix(num)}-/)
16
+ # result
17
+ # end
18
18
 
19
19
  def self.load(post)
20
20
  log!(enter: __method__, args: [post], level: 3)
@@ -437,7 +437,8 @@ class RuneBlog
437
437
  vdir = @root/:views/view
438
438
  @theme = @root/:views/view/:themes/:standard
439
439
  depend = [vdir/"remote/etc/blog.css", @theme/"global.lt3",
440
- @theme/"blog/head.lt3", @theme/"navbar/navbar.lt3",
440
+ @theme/"blog/head.lt3",
441
+ # @theme/"navbar/navbar.lt3",
441
442
  @theme/"blog/index.lt3"] # FIXME what about assets?
442
443
  xlate cwd: vdir/"themes/standard/etc", deps: depend,
443
444
  src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
@@ -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.54"
5
+ VERSION = "0.2.59"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
@@ -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
@@ -78,7 +78,7 @@ x.generate_view("around_austin")
78
78
  debug("-- change_view: #{bold('around_austin')}")
79
79
  x.change_view("around_austin") # 1 2 7 8 9
80
80
 
81
- make_post(x, "What's at Stubbs...", <<-EXCERPT, <<-BODY, [])
81
+ make_post(x, "What's at Stubbs...", <<-EXCERPT, <<-BODY)
82
82
  Stubbs has been around for longer than civilization.
83
83
  EXCERPT
84
84
  That's a good thing. But their music isn't always the greatest.
@@ -87,6 +87,7 @@ BODY
87
87
  make_post(x, "The new amphitheatre is overrated", <<-EXCERPT, <<-BODY)
88
88
  It used to be that all major concerts played the Erwin Center.
89
89
  EXCERPT
90
+ .pin around_austin
90
91
  Now, depending on what you consider "major," blah blah blah...
91
92
  BODY
92
93
 
@@ -137,7 +138,7 @@ EXCERPT
137
138
  This is about Sabine St, blah blah lorem ipsum dolor...
138
139
  BODY
139
140
 
140
- make_post(x, "Remember Modest Mouse?", <<-EXCERPT, <<-BODY, [])
141
+ make_post(x, "Remember Modest Mouse?", <<-EXCERPT, <<-BODY)
141
142
  They date to the 90s or before.
142
143
  EXCERPT
143
144
  But I first heard of them
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.54
4
+ version: 0.2.59
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-28 00:00:00.000000000 Z
11
+ date: 2019-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -65,15 +65,18 @@ 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
- - empty_view/remote/navbar/GIT_IS_DUMB
70
71
  - empty_view/remote/permalink/GIT_IS_DUMB
71
72
  - empty_view/themes/standard/README
72
73
  - empty_view/themes/standard/banner/about.lt3
74
+ - empty_view/themes/standard/banner/austin-pano.jpg
73
75
  - empty_view/themes/standard/banner/blog-banner.jpg
74
76
  - empty_view/themes/standard/banner/contact.lt3
75
77
  - empty_view/themes/standard/banner/faq.lt3
76
- - empty_view/themes/standard/banner/navbar.lt3
78
+ - empty_view/themes/standard/banner/list.data
79
+ - empty_view/themes/standard/banner/top.html
77
80
  - empty_view/themes/standard/blog/generate.lt3
78
81
  - empty_view/themes/standard/blog/head.lt3
79
82
  - empty_view/themes/standard/blog/index.lt3
@@ -83,10 +86,6 @@ files:
83
86
  - empty_view/themes/standard/etc/favicon.ico
84
87
  - empty_view/themes/standard/etc/misc.js
85
88
  - empty_view/themes/standard/global.lt3
86
- - empty_view/themes/standard/navbar/about.lt3
87
- - empty_view/themes/standard/navbar/contact.lt3
88
- - empty_view/themes/standard/navbar/faq.lt3
89
- - empty_view/themes/standard/navbar/navbar.lt3
90
89
  - empty_view/themes/standard/post/generate.lt3
91
90
  - empty_view/themes/standard/post/head.lt3
92
91
  - empty_view/themes/standard/post/index.lt3
@@ -218,7 +217,7 @@ homepage: https://github.com/Hal9000/runeblog
218
217
  licenses:
219
218
  - Ruby
220
219
  metadata: {}
221
- post_install_message:
220
+ post_install_message: "\n Success! Run 'blog' command and type h for help.\n "
222
221
  rdoc_options: []
223
222
  require_paths:
224
223
  - lib
@@ -1,17 +0,0 @@
1
- . --------------------------------------------------
2
- . This defines the content of the navigation bar.
3
- . The first one is a special case.
4
- . The others are understood to refer to .lt3 files
5
- . such as navbar/about.lt3 (which is processed into
6
- . HTML).
7
- . The title may be more than one word. Quotes are
8
- . not needed.
9
- . --------------------------------------------------
10
-
11
- .navbar2
12
- index Home
13
- about About
14
- contact Contact
15
- faq FAQ
16
- .end
17
-