class Jekyll::Tweetsert::TweetIndex

Public Class Methods

new(site, dir, value) click to toggle source
# File lib/jekyll-tweetsert.rb, line 56
def initialize(site, dir, value)
  @site = site
  @dir = dir
  @base = @site.source
  @name = 'index.html'
  @value = value

  @config ||= @type

  self.process(@name)

  idx_config = site.config['tweetsert'][@config] || {}

  idx_layout = idx_config["layout"] || @type+"_index"

  if site.layouts.key?(idx_layout)
    layout_file = idx_layout + site.layouts[idx_layout].ext
    @layout = idx_layout
  end

  if !@layout.nil?
    self.read_yaml(File.join(@base, '_layouts'), layout_file)
    self.data[@type] = @value

    prefix = idx_config.has_key?("title") ? idx_config['title']['prefix'] : ""
    suffix = idx_config.has_key?("title") ? idx_config['title']['suffix'] : ""

    self.data['title'] = prefix + @value + suffix
  end
end

Public Instance Methods

generate() click to toggle source
# File lib/jekyll-tweetsert.rb, line 87
def generate()
  if @layout.nil?
    Tweetsert::warn "#{@type} layout for #{@value} not found"
  else
    self.render(@site.layouts, @site.site_payload)
    self.write(@site.dest)
    @site.pages << self
  end
end