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.67 lib/view.rb
runeblog-0.1.66 lib/view.rb
runeblog-0.1.65 lib/view.rb
runeblog-0.1.64 lib/view.rb
runeblog-0.1.63 lib/view.rb
runeblog-0.1.62 lib/view.rb
runeblog-0.1.61 lib/view.rb
runeblog-0.1.59 lib/view.rb
runeblog-0.1.58 lib/view.rb
runeblog-0.1.57 lib/view.rb
runeblog-0.1.56 lib/view.rb
runeblog-0.1.55 lib/view.rb
runeblog-0.1.54 lib/view.rb
runeblog-0.1.53 lib/view.rb
runeblog-0.1.52 lib/view.rb
runeblog-0.1.51 lib/view.rb
runeblog-0.1.50 lib/view.rb
runeblog-0.1.49 lib/view.rb
runeblog-0.1.48 lib/view.rb
runeblog-0.1.47 lib/view.rb