class Wst::Post

Public Class Methods

all() click to toggle source
# File lib/wst/post.rb, line 30
def all
  post_files.inject([]) { |posts, file| posts << Post.new(file) }
end
new(file_path) click to toggle source
Calls superclass method Wst::MdContent::new
# File lib/wst/post.rb, line 8
def initialize file_path
  super file_path

  base_path = File.join(Configuration.config['path'], '_posts') + '/'
  @cats = @cats.gsub(base_path, '') if !@cats.nil?
  @cats.chomp!('/')
end

Private Class Methods

all_files() click to toggle source
# File lib/wst/post.rb, line 40
def all_files
  Dir.glob glob_path
end
glob_path() click to toggle source
# File lib/wst/post.rb, line 36
def glob_path
  File.join "#{Configuration.config['path']}/_posts", '**', @@glob
end
post_files() click to toggle source
# File lib/wst/post.rb, line 48
def post_files
  select_match(all_files).sort
end
select_match(files) click to toggle source
# File lib/wst/post.rb, line 44
def select_match files
  files.select { |file| file =~ @@matcher }
end

Public Instance Methods

content_url() click to toggle source
# File lib/wst/post.rb, line 16
def content_url
  generate_url = {
    "year"  => @date.strftime("%Y"),
    "month" => @date.strftime("%m"),
    "day"   => @date.strftime("%d"),
    "title" => CGI.escape(@slug)
  }.inject(":year/:month/:day/:title.html") { |result, token|
    result.gsub(/:#{Regexp.escape token.first}/, token.last)
  }.gsub(/\/\//, "/")
  generate_url = "#{@cats}/#{generate_url}" if @cats != ''
  generate_url
end