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