require 'ostruct' require 'pp' require 'date' require 'runeblog' # Now depends explicitly def quote _puts "
" _puts _body _puts "" end class ::Livetext::Functions # do this differently?? def asset # FIXME this is baloney... raise "meh" param = ::Livetext::Functions.param context = ::Livetext::Functions.context main = context.eval("@main") rescue "NO MAIN?" @meta = main.instance_eval("@main.instance_eval { @meta }") @config = main.instance_eval("@main.instance_eval { @config }") @root = @config.root text, name = param.split("|") # FIXME how should this work? view = @blog.view url = find_asset(name) "#{text}" end end ### find_asset def find_asset(asset) raise "meh2" views = @config.views views.each do |view| vdir = @config.viewdir(view) post_dir = "#{vdir}#{@meta.slug}/assets/" path = post_dir + asset STDERR.puts " Seeking #{path}" return path if File.exist?(path) end views.each do |view| dir = @config.viewdir(view) + "/assets/" path = dir + asset STDERR.puts " Seeking #{path}" return path if File.exist?(path) end top = @root + "/assets/" path = top + asset STDERR.puts " Seeking #{path}" return path if File.exist?(path) return nil end ############# def init_liveblog # FIXME - a lot of this logic sucks @blog, @meta = Livetext.parameters puts "init: #{[@blog, @meta].inspect}" @root = @blog.root @view = @blog.view.name @vdir = @blog.view.dir @title, @teaser = @meta.title, @meta.teaser @body = "" @slug = @blog.make_slug(@meta) @postdir = @blog.view.dir + "/#@slug" # puts "postdir = #{@postdir.inspect}" # @publish ||= {} # @config.views.each do |view| # publish = @config.viewdir(view) + "publish" # raise "File '#{publish}' not found" unless File.exist?(publish) # lines = File.readlines(publish).map {|x| x.chomp } # @publish[view] = lines # end end def _errout(*args) ::STDERR.puts *args end def _passthru(line, context = nil) return if line.nil? @body << "
" if line == "\n" and ! @_nopara line = _formatting(line, context) @body << line + "\n" end def title title = @_data.chomp @body << "