Top Level Namespace
Defined Under Namespace
Modules: PathSep Classes: RuneBlog
Constant Summary collapse
- LEXT =
".lt3"
Instance Method Summary collapse
- #_blank(url) ⇒ Object
- #_card_generic(card_title:, middle:, extra: "") ⇒ Object
- #_errout(*args) ⇒ Object
-
#_html_body(file, css = nil) ⇒ Object
helper methods.
-
#_interpolate(str, context) ⇒ Object
FIXME move this later.
- #_local_tag?(tag) ⇒ Boolean
- #_main(url) ⇒ Object
- #_passthru(line) ⇒ Object
- #_passthru_noline(line) ⇒ Object
-
#_post_lookup(postid) ⇒ Object
side-effect.
-
#_var(name) ⇒ Object
FIXME scope issue!.
- #_widget_card(url, tag) ⇒ Object
- #_widget_main(url, tag) ⇒ Object
- #_write_card(cardfile, mainfile, pairs, card_title, tag) ⇒ Object
- #_write_main(mainfile, pairs, card_title, tag) ⇒ Object
- #_write_metadata ⇒ Object
-
#assure(hash) ⇒ Object
really the same as verify for now…
- #backlink ⇒ Object
- #card1 ⇒ Object
- #card2 ⇒ Object
- #card_iframe ⇒ Object
-
#categories ⇒ Object
does nothing right now.
- #check_meta(meta, where = "") ⇒ Object
- #dropcap ⇒ Object
-
#dump(obj, name) ⇒ Object
FIXME scope.
- #finalize ⇒ Object
-
#h1 ⇒ Object
Move elsewhere later!.
- #h2 ⇒ Object
- #h3 ⇒ Object
- #h4 ⇒ Object
- #h5 ⇒ Object
- #h6 ⇒ Object
-
#head ⇒ Object
Does NOT output <head> tags.
- #hr ⇒ Object
-
#image ⇒ Object
primitive so far.
-
#init_liveblog ⇒ Object
errfile = File.new(“/tmp/liveblog.out”, “w”) STDERR.reopen(errfile).
-
#inset ⇒ Object
inset.
- #list ⇒ Object
- #list! ⇒ Object
- #log!(str: "", enter: nil, args: [], pwd: false, dir: false) ⇒ Object
-
#make_exception(sym, str) ⇒ Object
Refactor, move stuff elsewhere?.
- #make_main_links ⇒ Object
-
#meta ⇒ Object
newer stuff…
- #navbar ⇒ Object
- #page_type(tag, title) ⇒ Object
- #pin ⇒ Object
-
#post ⇒ Object
“dot” commands.
- #prefix(num) ⇒ Object
- #pubdate ⇒ Object
- #quote ⇒ Object
-
#recent_posts ⇒ Object
side-effect.
- #script ⇒ Object
- #sidebar ⇒ Object
- #stale?(src, dst, force = false) ⇒ Boolean
- #style ⇒ Object
- #stylesheet ⇒ Object
- #system!(str) ⇒ Object
- #tag_cloud ⇒ Object
- #tags ⇒ Object
- #teaser ⇒ Object
- #title ⇒ Object
- #verify(hash) ⇒ Object
- #views ⇒ Object
- #write_post ⇒ Object
- #xlate(cwd: Dir.pwd, src:, dst: (strip = true; src.sub(/.lt3$/,"")), copy: nil, debug: false, force: false) ⇒ Object
Instance Method Details
#_blank(url) ⇒ Object
700 701 702 |
# File 'lib/liveblog.rb', line 700 def _blank(url) %[href='#{url}' target='blank'] end |
#_card_generic(card_title:, middle:, extra: "") ⇒ Object
677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
# File 'lib/liveblog.rb', line 677 def _card_generic(card_title:, middle:, extra: "") front = " <div class=\"card \#{extra} mb-3\">\n <div class=\"card-body\">\n <h5 class=\"card-title\">\#{card_title}</h5>\n HTML\n\n tail = <<-HTML\n </div>\n </div>\n HTML\n text = front + middle + tail\n _out text + \"\\n \"\nend\n" |
#_errout(*args) ⇒ Object
630 631 632 |
# File 'lib/liveblog.rb', line 630 def _errout(*args) ::STDERR.puts *args end |
#_html_body(file, css = nil) ⇒ Object
helper methods
533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/liveblog.rb', line 533 def _html_body(file, css = nil) file.puts "<html>" if css file.puts " <head>" file.puts " <style>\n#{css}\n </style>" file.puts " </head>" end file.puts " <body>" yield file.puts " </body>\n</html>" end |
#_interpolate(str, context) ⇒ Object
FIXME move this later
672 673 674 675 |
# File 'lib/liveblog.rb', line 672 def _interpolate(str, context) # FIXME move this later wrapped = "%[" + str.dup + "]" # could fail... eval(wrapped, context) end |
#_local_tag?(tag) ⇒ Boolean
584 585 586 587 588 589 590 591 592 593 |
# File 'lib/liveblog.rb', line 584 def _local_tag?(tag) case tag.to_sym when :pages true when :news, :links false else true # Hmmm... end end |
#_main(url) ⇒ Object
696 697 698 |
# File 'lib/liveblog.rb', line 696 def _main(url) %[href="javascript: void(0)" onclick="javascript:open_main('#{url}')"] end |
#_passthru(line) ⇒ Object
634 635 636 637 638 639 |
# File 'lib/liveblog.rb', line 634 def _passthru(line) return if line.nil? line = _format(line) _out line + "\n" _out "<p>" if line.empty? && ! @_nopara end |
#_passthru_noline(line) ⇒ Object
641 642 643 644 645 646 |
# File 'lib/liveblog.rb', line 641 def _passthru_noline(line) return if line.nil? line = _format(line) _out line _out "<p>" if line.empty? && ! @_nopara end |
#_post_lookup(postid) ⇒ Object
side-effect
657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/liveblog.rb', line 657 def _post_lookup(postid) # side-effect # .. = templates, ../.. = views/thisview slug = title = date = = nil dir_posts = @vdir/:posts posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts/x } posts.select! {|x| File.directory?(x) } post = posts.select {|x| File.basename(x).to_i == postid } raise "Error: More than one post #{postid}" if post.size > 1 postdir = post.first vp = RuneBlog::ViewPost.new(@blog.view, postdir) vp end |
#_var(name) ⇒ Object
FIXME scope issue!
692 693 694 |
# File 'lib/liveblog.rb', line 692 def _var(name) # FIXME scope issue! ::Livetext::Vars[name] || "[:#{name} is undefined]" end |
#_widget_card(url, tag) ⇒ Object
708 709 710 711 |
# File 'lib/liveblog.rb', line 708 def (url, tag) url2 = :widgets/tag/url %[href="javascript: void(0)" onclick="javascript:open_main('#{url2}')"] end |
#_widget_main(url, tag) ⇒ Object
704 705 706 |
# File 'lib/liveblog.rb', line 704 def (url, tag) %[href="#{url}"] end |
#_write_card(cardfile, mainfile, pairs, card_title, tag) ⇒ Object
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/liveblog.rb', line 545 def _write_card(cardfile, mainfile, pairs, card_title, tag) log!(str: "Creating #{cardfile}.html", pwd: true) url = mainfile url = :widgets/tag/mainfile + ".html" File.open("#{cardfile}.html", "w") do |f| f.puts " <div class=\"card mb-3\">\n <div class=\"card-body\">\n <h5 class=\"card-title\">\n <button type=\"button\" class=\"btn btn-primary\" data-toggle=\"collapse\" data-target=\"#\#{tag}\">+</button>\n <a href=\"javascript: void(0)\" \n onclick=\"javascript:open_main('\#{url}')\" \n style=\"text-decoration: none; color: black\"> \#{card_title}</a>\n </h5>\n <div class=\"collapse\" id=\"\#{tag}\">\n EOS\n log!(str: \"Writing data pairs to \#{cardfile}.html\", pwd: true)\n local = _local_tag?(tag)\n pairs.each do |file, title| \n url = file\n type, title = page_type(tag, title)\n case type\n when :local; url_ref = _widget_card(file, tag) # local always frameable\n when :frame; url_ref = _main(file) # remote, frameable\n when :noframe; url_ref = _blank(file) # remote, not frameable\n end\n anchor = %[<a \#{url_ref}>\#{title}</a>]\n wrapper = %[<li class=\"list-group-item\">\#{anchor}</li>]\n f.puts wrapper\n end\n _include_file cardfile+\".html\"\n f.puts <<-EOS\n </div>\n </div>\n </div>\n EOS\n end\nend\n" |
#_write_main(mainfile, pairs, card_title, tag) ⇒ Object
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
# File 'lib/liveblog.rb', line 609 def _write_main(mainfile, pairs, card_title, tag) log!(str: "Creating #{mainfile}.html", pwd: true) local = _local_tag?(tag) File.open("#{mainfile}.html", "w") do |f| _html_body(f) do f.puts "<h1>#{card_title}</h1>" pairs.each do |file, title| type, title = page_type(tag, title) title = title.gsub(/\\/, "") # kludge case type when :local; url_ref = (file, tag) # local always frameable when :frame; url_ref = "href = '#{file}'" # local always frameable when :noframe; url_ref = _blank(file) # local always frameable end css = "color: #8888FF; text-decoration: none; font-size: 24px; font-family: verdana" f.puts %[<a style="#{css}" #{url_ref}>#{title}</a> <br>] end end end end |
#_write_metadata ⇒ Object
648 649 650 651 652 653 654 655 |
# File 'lib/liveblog.rb', line 648 def File.write("teaser.txt", .) fields = [:num, :title, :date, :pubdate, :views, :tags] fname2 = "metadata.txt" f2 = File.open(fname2, "w") do |f2| fields.each {|fld| f2.puts "#{fld}: #{@meta.send(fld)}" } end end |
#assure(hash) ⇒ Object
really the same as verify for now…
71 72 73 74 75 76 |
# File 'lib/global.rb', line 71 def assure(hash) # really the same as verify for now... log!(enter: __method__, args: [hash]) hash.each_pair do |expr, msg| puts "<< #{msg}" unless expr end end |
#backlink ⇒ Object
36 37 38 |
# File 'lib/liveblog.rb', line 36 def backlink _out %[<br><a href="javascript:history.go(-1)">[Back]</a>] end |
#card1 ⇒ Object
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/liveblog.rb', line 423 def card1 title, lines = _data, _body lines.map!(&:chomp) card_text = lines[0] url, classname, cdata = lines[1].split(",", 4) main = _main(url) middle = " <p class=\"card-text\">\#{card_text}</p>\n <a \#{main} class=\"\#{classname}\">\#{cdata}</a>\n HTML\n\n _card_generic(card_title: title, middle: middle, extra: \"bg-dark text-white\")\nend\n" |
#card2 ⇒ Object
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/liveblog.rb', line 439 def card2 str = _data file, card_title = str.chomp.split(" ", 2) card_title = %[<a #{_main(file)} style="text-decoration: none; color: black">#{card_title}</a>] # FIXME is this wrong?? open = " <div class=\"card mb-3\">\n <div class=\"card-body\">\n <h5 class=\"card-title\">\#{card_title}</h5>\n <ul class=\"list-group list-group-flush\">\n HTML\n _out open\n _body do |line|\n url, cdata = line.chomp.split(\",\", 3)\n main = _main(url)\n _out %[<li class=\"list-group-item\"><a \#{main}}\">\#{cdata}</a> </li>]\n end\n close = %[ </ul>\\n </div>\\n </div>]\n _out close\nend\n" |
#card_iframe ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/liveblog.rb', line 363 def card_iframe title, lines = _data, _body lines.map!(&:chomp) url = lines[0].chomp stuff = lines[1..-1].join(" ") # FIXME later middle = " <iframe src=\"\#{url}\" \#{stuff} \n style=\"border: 0\" \#{stuff}\n frameborder=\"0\" scrolling=\"no\">\n </iframe>\n HTML\n\n _card_generic(card_title: title, middle: middle, extra: \"bg-dark text-white\")\nend\n" |
#categories ⇒ Object
does nothing right now
68 69 |
# File 'lib/liveblog.rb', line 68 def categories # does nothing right now end |
#check_meta(meta, where = "") ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/global.rb', line 51 def (, where = "") log!(enter: __method__, args: [, where]) str = "--- #{where}\n" str << "\ncheck_meta: \n" + caller.join("\n") + "\n meta = #{meta.inspect}\n" str << " title missing!\n" unless .title str << " title missing! (empty)" if .title && .title.empty? str << " num missing!\n" unless .num if str =~ /missing!/ debug str raise str end end |
#dropcap ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/liveblog.rb', line 40 def dropcap # Bad form: adds another HEAD _out "<head>\n<style>\np:first-child:first-letter {\n color: #0000ff;\n float: left;\n font-family: Georgia;\n font-size: 75px;\n line-height: 60px;\n padding-top: 4px;\n padding-right: 8px;\n padding-left: 3px;\n}\n</style>\n</head>\n" _out " " end |
#dump(obj, name) ⇒ Object
FIXME scope
161 162 163 164 |
# File 'lib/helpers-blog.rb', line 161 def dump(obj, name) # FIXME scope log!(str: "scope problem", enter: __method__, args: [obj, name]) File.write(name, obj) end |
#finalize ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/liveblog.rb', line 221 def finalize # FIXME simplify this! unless puts @live.body return end if @blog.nil? return end @slug = @blog.make_slug() slug_dir = @slug @postdir = @blog.view.dir/:posts/slug_dir write_post end |
#h1 ⇒ Object
Move elsewhere later!
78 |
# File 'lib/liveblog.rb', line 78 def h1; _passthru "<h1>#{@_data}</h1>"; end |
#h2 ⇒ Object
79 |
# File 'lib/liveblog.rb', line 79 def h2; _passthru "<h2>#{@_data}</h2>"; end |
#h3 ⇒ Object
80 |
# File 'lib/liveblog.rb', line 80 def h3; _passthru "<h3>#{@_data}</h3>"; end |
#h4 ⇒ Object
81 |
# File 'lib/liveblog.rb', line 81 def h4; _passthru "<h4>#{@_data}</h4>"; end |
#h5 ⇒ Object
82 |
# File 'lib/liveblog.rb', line 82 def h5; _passthru "<h5>#{@_data}</h5>"; end |
#h6 ⇒ Object
83 |
# File 'lib/liveblog.rb', line 83 def h6; _passthru "<h6>#{@_data}</h6>"; end |
#head ⇒ Object
Does NOT output <head> tags
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/liveblog.rb', line 238 def head # Does NOT output <head> tags args = _args args.each do |inc| self.data = inc _include end # Depends on vars: title, desc, host defaults = {} defaults = { "charset" => %[<meta charset="utf-8">], "http-equiv" => %[<meta http-equiv="X-UA-Compatible" content="IE=edge">], "title" => %[<title>\n #{_var(:blog)} | #{_var("blog.desc")}\n </title>], "generator" => %[<meta name="generator" content="Runeblog v #@version">], "og:title" => %[<meta property="og:title" content="#{_var(:blog)}">], "og:locale" => %[<meta property="og:locale" content="#{_var(:locale)}">], "description" => %[<meta name="description" content="#{_var("blog.desc")}">], "og:description" => %[<meta property="og:description" content="#{_var("blog.desc")}">], "linkc" => %[<link rel="canonical" href="#{_var(:host)}">], "og:url" => %[<meta property="og:url" content="#{_var(:host)}">], "og:site_name" => %[<meta property="og:site_name" content="#{_var(:blog)}">], "style" => %[<link rel="stylesheet" href="etc/blog.css">], "feed" => %[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}/feed.xml" title="#{_var(:blog)}">], "favicon" => %[<link rel="shortcut icon" type="image/x-icon" href="../etc/favicon.ico">\n <link rel="apple-touch-icon" href="../etc/favicon.ico">] } result = {} lines = _body lines.each do |line| line.chomp word, remain = line.split(" ", 2) case word when "viewport" result["viewport"] = %[<meta name="viewport" content="#{remain}">] when "script" # FIXME this is broken file = remain text = File.read(file) result["script"] = Livetext.new.transform(text) when "style" result["style"] = %[<link rel="stylesheet" href="('/etc/#{remain}')">] # Later: allow other overrides when ""; break else if defaults[word] result[word] = %[<meta property="#{word}" content="#{remain}">] else puts "Unknown tag '#{word}'" end end end hash = defaults.dup.update(result) # FIXME collisions? hash.each_value {|x| _out " " + x } _out "<body>" end |
#hr ⇒ Object
85 |
# File 'lib/liveblog.rb', line 85 def hr; _passthru "<hr>"; end |
#image ⇒ Object
primitive so far
173 174 175 176 177 178 179 |
# File 'lib/liveblog.rb', line 173 def image # primitive so far _debug "img: huh? <img src=#{_args.first}></img>" fname = _args.first path = :assets/fname _out "<img src=#{path}></img>" _optional_blank_line end |
#init_liveblog ⇒ Object
errfile = File.new(“/tmp/liveblog.out”, “w”) STDERR.reopen(errfile)
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/liveblog.rb', line 12 def init_liveblog # FIXME - a lot of this logic sucks here = Dir.pwd dir = here loop { dir = Dir.pwd; break if File.exist?("config"); Dir.chdir("..") } Dir.chdir(here) # here??? or dir?? @blog = RuneBlog.new(dir) @root = @blog.root @view = @blog.view @view_name = @blog.view.name @vdir = @blog.view.dir @version = RuneBlog::VERSION @theme = @vdir/:themes/:standard end |
#inset ⇒ Object
inset
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/liveblog.rb', line 127 def inset lines = _body box = "" lines.each do |line| line = line.dup if line[0] == "/" # Only into inset line[0] = ' ' box << line.dup + " " line.replace(" ") end if line[0] == "|" # Into inset and body line[0] = ' ' box << line.dup + " " end _passthru(line) end lr = _args.first wide = _args[1] || "25" _passthru "<div style='float:#{lr}; width: #{wide}%; padding:8px; padding-right:12px; font-family:verdana'>" _passthru '<b><i>' _passthru box _passthru_noline '</i></b></div>' _optional_blank_line end |
#list ⇒ Object
87 88 89 90 91 92 |
# File 'lib/liveblog.rb', line 87 def list _out "<ul>" _body {|line| _out "<li>#{line}</li>" } _out "</ul>" _optional_blank_line end |
#list! ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/liveblog.rb', line 94 def list! _out "<ul>" lines = _body.each loop do line = lines.next line = _format(line) if line[0] == " " _out line else _out "<li>#{line}</li>" end end _out "</ul>" _optional_blank_line end |
#log!(str: "", enter: nil, args: [], pwd: false, dir: false) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/logging.rb', line 5 def log!(str: "", enter: nil, args: [], pwd: false, dir: false) return unless $logging time = Time.now.strftime("%H:%M:%S") meth = "" meth = "#{enter}" if enter para = "(#{args.inspect[1..-2]})" source = caller[0].sub(/.*\//, " in ").sub(/:/, " line ").sub(/:.*/, "") source = "in #{source} (probably liveblog.rb)" if source.include? "(eval)" str = " ... #{str}" unless str.empty? indent = " "*12 $log.puts "#{time} #{meth}#{para}" $log.puts "#{indent} #{str} " unless str.empty? $log.puts "#{indent} #{source}" $log.puts "#{indent} pwd = #{Dir.pwd} " if pwd if dir files = (Dir.entries('.') - %w[. ..]).join(" ") $log.puts "#{indent} dir/* = #{files}" end # $log.puts "#{indent} livetext params = #{livedata.inpect} " unless livedata.nil? $log.puts $log.close $log = File.new("/tmp/runeblog.log","a") end |
#make_exception(sym, str) ⇒ Object
Refactor, move stuff elsewhere?
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/global.rb', line 22 def make_exception(sym, str) log!(enter: __method__, args: [sym, str]) return if Object.constants.include?(sym) Object.const_set(sym, StandardError.dup) define_method(sym) do |*args| msg = str args.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) } Object.class_eval(sym.to_s).new(msg) end end |
#make_main_links ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/liveblog.rb', line 111 def make_main_links log!(enter: __method__) # FIXME remember strings may not be safe line = _data.chomp tag, card_title = *line.split(" ", 2) cardfile, mainfile = "#{tag}-card", "#{tag}-main" input = "list.data" log!(str: "Reading #{input}", pwd: true) pairs = File.readlines(input).map {|line| line.chomp.split(/, */, 2) } _write_main(mainfile, pairs, card_title, tag) _write_card(cardfile, mainfile, pairs, card_title, tag) log!(str: "...returning from method", pwd: true) end |
#meta ⇒ Object
newer stuff…
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/liveblog.rb', line 293 def args = _args enum = args.each str = "<meta" arg = enum.next loop do if arg.end_with?(":") str << " " << arg[0..-2] << "=" a2 = enum.next str << %["#{a2}"] else STDERR.puts "=== meta error?" end arg = enum.next end str << ">" _out str end |
#navbar ⇒ Object
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/liveblog.rb', line 485 def vdir = @blog.view.dir title = _var(:blog) open = " <nav class=\"navbar navbar-expand-lg navbar-light bg-light\">\n <a class=\"navbar-brand\" href=\"index.html\">\#{title}</a>\n <button class=\"navbar-toggler\" \n type=\"button\" \n data-toggle=\"collapse\" \n data-target=\"#navbarSupportedContent\"\n aria-controls=\"navbarSupportedContent\" \n aria-expanded=\"false\" \n aria-label=\"Toggle navigation\">\n <span class=\"navbar-toggler-icon\"></span>\n </button>\n <div class=\"collapse navbar-collapse pull-right\" \n id=\"navbarSupportedContent\">\n <ul class=\"navbar-nav mr-auto\">\n HTML\n close = <<-HTML\n </ul>\n </div>\n </nav>\n HTML\n\n first = true\n _out open\n lines = _body\n lines.each do |line|\n basename, cdata = line.chomp.strip.split(\" \", 2)\n full = :navbar/basename+\".html\"\n href_main = _main(full)\n if first\n first = false # hardcode this part??\n _out %[<li class=\"nav-item active\"> <a class=\"nav-link\" href=\"index.html\">\#{cdata}<span class=\"sr-only\">(current)</span></a> </li>]\n else\n xlate cwd: \"navbar\", src: basename, dst: vdir/\"remote/navbar\"/basename+\".html\" # , debug: true\n _out %[<li class=\"nav-item\"> <a class=\"nav-link\" \#{href_main}>\#{cdata}</a> </li>]\n end\n end\n _out close\nend\n" |
#page_type(tag, title) ⇒ Object
595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/liveblog.rb', line 595 def page_type(tag, title) yesno = "yes" yesno, title = title.split(/, */) if title =~ /^[yes|no]/ local = _local_tag?(tag) frameable = (yesno == "yes") if local return [:local, title] elsif frameable return [:frame, title] else return [:noframe, title] end end |
#pin ⇒ Object
195 196 197 198 199 200 201 |
# File 'lib/liveblog.rb', line 195 def pin raise "'post' was not called" unless _debug "data = #{_args}" # verify only already-specified views? .pinned = _args.dup _optional_blank_line end |
#post ⇒ Object
“dot” commands
30 31 32 33 34 |
# File 'lib/liveblog.rb', line 30 def post = OpenStruct.new .num = _args[0] _out " <!-- Post number #{@meta.num} -->\n " end |
#prefix(num) ⇒ Object
46 47 48 49 |
# File 'lib/global.rb', line 46 def prefix(num) log!(enter: __method__, args: [num]) "#{'%04d' % num.to_i}" end |
#pubdate ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/liveblog.rb', line 161 def pubdate raise "'post' was not called" unless _debug "data = #@_data" # Check for discrepancy? match = /(\d{4}).(\d{2}).(\d{2})/.match @_data junk, y, m, d = match.to_a y, m, d = y.to_i, m.to_i, d.to_i .date = ::Date.new(y, m, d) .pubdate = "%04d-%02d-%02d" % [y, m, d] _optional_blank_line end |
#quote ⇒ Object
61 62 63 64 65 66 |
# File 'lib/liveblog.rb', line 61 def quote _passthru "<blockquote>" _passthru _body _passthru "</blockquote>" _optional_blank_line end |
#recent_posts ⇒ Object
side-effect
312 313 314 315 316 317 318 319 320 |
# File 'lib/liveblog.rb', line 312 def recent_posts # side-effect _out " <div class=\"col-lg-9 col-md-9 col-sm-9 col-xs-12\">\n <iframe id=\"main\" style=\"width: 70vw; height: 100vh; position: relative;\" \n src='recent.html' width=100% frameborder=\"0\" allowfullscreen>\n </iframe>\n </div>\n HTML\nend\n" |
#script ⇒ Object
355 356 357 358 359 360 361 |
# File 'lib/liveblog.rb', line 355 def script lines = _body url = lines[0] integ = lines[1] cross = lines[2] || "anonymous" _out %[<script src="#{url}" integrity="#{integ}" crossorigin="#{cross}"></script>] end |
#sidebar ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/liveblog.rb', line 322 def if _args.include? "off" _body { } # iterate, do nothing return end _out %[<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">] _body do |token| tag = token.chomp.strip.downcase wtag = :widgets/tag raise "Can't find #{wtag}" unless Dir.exist?(wtag) tcard = "#{tag}-card.html" if File.exist?(wtag/"SUBFILES") children = Dir[wtag/"*.lt3"] - [wtag/tag+".lt3"] children.each do |child| dest = child.sub(/.lt3$/, ".html") xlate src: child, dst: dest # , debug: true end end xlate cwd: wtag, src: tag, dst: tcard # , debug: true _include_file wtag/tcard end _out %[</div>] end |
#stale?(src, dst, force = false) ⇒ Boolean
4 5 6 7 8 9 10 11 |
# File 'lib/xlate.rb', line 4 def stale?(src, dst, force = false) log!(enter: __method__, args: [src, dst]) raise "Source #{src} not found in #{Dir.pwd}" unless File.exist?(src) return true if force return true unless File.exist?(dst) return true if File.mtime(src) > File.mtime(dst) return false end |
#style ⇒ Object
71 72 73 74 |
# File 'lib/liveblog.rb', line 71 def style fname = _args[0] _passthru %[<link rel="stylesheet" href="???/etc/#{fname}')">] end |
#stylesheet ⇒ Object
347 348 349 350 351 352 353 |
# File 'lib/liveblog.rb', line 347 def stylesheet lines = _body url = lines[0] integ = lines[1] cross = lines[2] || "anonymous" _out %[<link rel="stylesheet" href="#{url}" integrity="#{integ}" crossorigin="#{cross}"></link>] end |
#system!(str) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/global.rb', line 33 def system!(str) log!(enter: __method__, args: [str]) rc = system(str) if rc return rc else STDERR.puts "FAILED: #{str.inspect}" STDERR.puts "\ncaller = \n#{caller.join("\n ")}\n" return rc end rc end |
#tag_cloud ⇒ Object
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/liveblog.rb', line 462 def tag_cloud title = _data title = "Tag Cloud" if title.empty? open = " <div class=\"card mb-3\">\n <div class=\"card-body\">\n <h5 class=\"card-title\">\n <button type=\"button\" class=\"btn btn-primary\" data-toggle=\"collapse\" data-target=\"#tag-cloud\">+</button>\n \#{title}\n </h5>\n <div class=\"collapse\" id=\"tag-cloud\">\n HTML\n _out open\n _body do |line|\n line.chomp!\n url, classname, cdata = line.split(\",\", 3)\n main = _main(url)\n _out %[<a \#{main} class=\"\#{classname}\">\#{cdata}</a>]\n end\n close = %[ </div>\\n </div>\\n </div>]\n _out close\nend\n" |
#tags ⇒ Object
181 182 183 184 185 186 |
# File 'lib/liveblog.rb', line 181 def raise "'post' was not called" unless _debug "args = #{_args}" . = _args.dup || [] _optional_blank_line end |
#teaser ⇒ Object
213 214 215 216 217 218 219 |
# File 'lib/liveblog.rb', line 213 def raise "'post' was not called" unless . = _body_text setvar :teaser, . _out . + "\n" # FIXME end |
#title ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/liveblog.rb', line 152 def title raise "'post' was not called" unless title = @_data.chomp .title = title setvar :title, title _out %[<h1 class="post-title">#{title}</h1><br>] _optional_blank_line end |
#verify(hash) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/global.rb', line 64 def verify(hash) log!(enter: __method__, args: [hash]) hash.each_pair do |expr, msg| puts "<< #{msg}" unless expr end end |
#views ⇒ Object
188 189 190 191 192 193 |
# File 'lib/liveblog.rb', line 188 def views raise "'post' was not called" unless _debug "data = #{_args}" .views = _args.dup _optional_blank_line end |
#write_post ⇒ Object
203 204 205 206 207 208 209 210 211 |
# File 'lib/liveblog.rb', line 203 def write_post raise "'post' was not called" unless .views = .views.join(" ") if .views.is_a? Array . = ..join(" ") if ..is_a? Array rescue => err puts "err = #{err}" puts err.backtrace.join("\n") end |
#xlate(cwd: Dir.pwd, src:, dst: (strip = true; src.sub(/.lt3$/,"")), copy: nil, debug: false, force: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/xlate.rb', line 13 def xlate(cwd: Dir.pwd, src:, dst: (strip = true; src.sub(/.lt3$/,"")), copy: nil, debug: false, force: false) src += LEXT unless src.end_with?(LEXT) dst += ".html" unless dst.end_with?(".html") || strip indent = " "*12 Dir.chdir(cwd) do if debug STDERR.puts "#{indent} -- xlate #{src} >#{dst}" STDERR.puts "#{indent} in: #{Dir.pwd}" STDERR.puts "#{indent} from: #{caller[0]}" STDERR.puts "#{indent} copy: #{copy}" if copy end if stale?(src, dst, force) # do nothing else STDERR.puts "#{indent} -- ^ Already up to date!" if debug return end rc = system!("livetext #{src} >#{dst}") STDERR.puts "...completed (shell returned #{rc})" if debug system!("cp #{dst} #{copy}") if copy end end |