require 'ostruct' require 'pp' require 'date' require 'livetext' require 'runeblog' errfile = File.new("/tmp/liveblog.out", "w") STDERR.reopen(errfile) 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) @blog = $_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 # FIXME - stale? and livetext are duplicated from helpers-blog def stale?(src, dst) return true unless File.exist?(dst) return true if File.mtime(src) > File.mtime(dst) return false end def livetext(src, dst=nil) src += ".lt3" unless src.end_with?(".lt3") if dst dst += ".html" unless dst.end_with?(".html") else dst = src.sub(/.lt3$/, "") end return unless stale?(src, dst) system("livetext #{src} >#{dst}") end def post @meta = OpenStruct.new @meta.num = _args[0] _out " \n " end def quote _passthru "
" _passthru _body _passthru "" _optional_blank_line end def categories # does nothing right now end def style fname = _args[0] _passthru %[] end # Move elsewhere later! def h1; _passthru "
" if line.empty? && ! @_nopara end def _passthru_noline(line) return if line.nil? line = _format(line) _out line _out "
" if line.empty? && ! @_nopara end def title raise "'post' was not called" unless @meta title = @_data.chomp @meta.title = title setvar :title, title _out %[
#{card_text}
#{cdata} HTML _card_generic(card_title: title, middle: middle, extra: "bg-dark text-white") end def card2 str = _data file, card_title = str.chomp.split(" ", 2) card_title = %[#{card_title}] # FIXME is this wrong?? open = <<-HTML