Sha256: 08a917a504e9dfacb416b7a02f4eac27db8c8b2a32642a874c340fb844582e73

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

require 'logging'

class RuneBlog::View
  attr_reader :name, :state, :globals
  attr_accessor :publisher

  include RuneBlog::Helpers

  def initialize(name)
    log!(enter: __method__, args: [name], level: 3)
    raise NoBlogAccessor if RuneBlog.blog.nil?
    @blog = RuneBlog.blog
    @name = name
    @publisher = RuneBlog::Publishing.new(name)
    @can_publish = true  # FIXME
    @blog.view = self
    get_globals
  end

  def get_globals
    gfile = @blog.root/"views/#{name}/themes/standard/global.lt3"
    return unless File.exist?(gfile)  # Hackish!! how is View.new called from create_view??

    live = Livetext.customize(call: ".nopara")
    live.xform_file(gfile)
    @globals = live.vars
  end

  def dir
    @blog.root + "/views/#@name/"
  end

  def local_index
    dir + "/remote/index.html"
  end

  def index
    dir + "index.html"
  end

  def to_s
    @name
  end

  def can_publish?
    @can_publish
  end

  def recent?(file)
    File.mtime(file) > File.mtime("#{self.dir()}/last_published")
  rescue
    true
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
runeblog-0.3.22 lib/view.rb
runeblog-0.3.21 lib/view.rb
runeblog-0.3.20 lib/view.rb
runeblog-0.3.19 lib/view.rb
runeblog-0.3.18 lib/view.rb
runeblog-0.3.17 lib/view.rb
runeblog-0.3.16 lib/view.rb
runeblog-0.3.15 lib/view.rb
runeblog-0.3.14 lib/view.rb
runeblog-0.3.13 lib/view.rb
runeblog-0.3.12 lib/view.rb
runeblog-0.3.11 lib/view.rb