Sha256: c7226eed3b66c74be26c504b558dfd4aa7761b82ad4af9f95475606acaa3a347

Contents?: true

Size: 1.19 KB

Versions: 43

Compression:

Stored size: 1.19 KB

Contents

require 'helpers-blog'
require 'runeblog'

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

  include RuneBlog::Helpers

  def initialize(name)
    raise NoBlogAccessor if RuneBlog.blog.nil?
    @blog = RuneBlog.blog
    @name = name
    @can_publish = false
    pub_file = @blog.root + "/views/#@name/publish"
    unless File.size(pub_file) == 0
      @publisher = RuneBlog::Publishing.new(read_config(pub_file))
      @can_publish = true
    end
  end

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

  def index
    dir + "index.html"
  end

  def to_s
    @name
  end

  def publishable_files
    vdir = dir()
    files = [index()]
    others = Dir.entries(vdir).grep(/^\d\d\d\d/).map {|x| "#{vdir}/#{x}" }
    assets = Dir.entries("#{@blog.root}/assets") - %w[. ..]
    assets.map! {|x| "#{@blog.root}/assets/#{x}" }
    assets.reject! {|x| File.directory?(x) }
#   assets.reject! {|x| ! recent?(x) }
    files = files + others
    all = files.dup
    dirty = files.reject {|f| ! recent?(f) }
    [dirty, all, assets]
  end

  def can_publish?
    @can_publish
  end

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

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
runeblog-0.1.46 lib/view.rb
runeblog-0.1.45 lib/view.rb
runeblog-0.1.44 lib/view.rb
runeblog-0.1.43 lib/view.rb
runeblog-0.1.42 lib/view.rb
runeblog-0.1.41 lib/view.rb
runeblog-0.1.40 lib/view.rb
runeblog-0.1.39 lib/view.rb
runeblog-0.1.38 lib/view.rb
runeblog-0.1.37 lib/view.rb
runeblog-0.1.36 lib/view.rb
runeblog-0.1.35 lib/view.rb
runeblog-0.1.34 lib/view.rb
runeblog-0.1.33 lib/view.rb
runeblog-0.1.32 lib/view.rb
runeblog-0.1.31 lib/view.rb
runeblog-0.1.30 lib/view.rb
runeblog-0.1.29 lib/view.rb
runeblog-0.1.28 lib/view.rb
runeblog-0.1.27 lib/view.rb