require 'ostruct' require 'yaml' require 'pp' require 'runeblog' # Now depends explicitly class ::Livetext::Functions # do this differently?? def asset # FIXME this is baloney... 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 = ThisConfig.view url = find_asset(name) "#{text}" end end begin ThisBlog rescue ThisBlog = RuneBlog.new ThisConfig = ThisBlog.read_config end ### find_asset def find_asset(asset) 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 @blog = ThisBlog @config = ThisConfig @root = @config.root @teaser = "" @body = "" @body = "" @meta = ::OpenStruct.new @deploy ||= {} @config.views.each do |view| deployment = @config.viewdir(view) + "deploy" raise "File '#{deployment}' not found" unless File.exist?(deployment) lines = File.readlines(deployment).map {|x| x.chomp } @deploy[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 @meta.title = @_data @body << "