Sha256: e8e6ad4f2bcdfae3be400e2e29725bed39f3214809e29515b315e517fb79daaa

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

class Layout < Erector::Widget

  class << self
    def inherited(page_class)
      puts page_class
      (@@page_classes ||= []) << page_class
    end

    def generate_site
      @@page_classes.each do |page_class|
        page_class.generate_html unless page_class.abstract?
        puts page_class
      end
    end

    def generate_html
      File.open(absolute_path, 'w') do |file|
        file.write(new.render)
      end
    end

    def absolute_path
      absolutize(relative_path)
    end

    def relative_path
      "#{name.gsub('::', '_').underscore}.html"
    end

    def absolutize(relative_path)
      File.join(File.dirname(__FILE__), "site", relative_path)
    end

    def abstract
      @abstract = true
    end

    def abstract?
      @abstract
    end
  end

  def bluecloth(relative_path)
    File.open(File.join(File.dirname(__FILE__), relative_path)) do |file|
      rawtext BlueCloth.new(file.read).to_html
    end
  end

  def absolutize(relative_path)
    self.class.absolutize(relative_path)
  end

  def link_to(link_text, page_class, section_class=nil)
    if instance_of?(page_class) || section_class && is_a?(section_class)
      text link_text
    else
      a link_text, :href => page_class.relative_path
    end
  end
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
cognita-treetop-1.2.4 doc/sitegen.rb
skylinecms-3.1.0 vendor/digitpaint/personify/vendor/treetop/doc/sitegen.rb
personify-1.0.0 vendor/treetop/doc/sitegen.rb
westarete-skylinecms-3.0.8.20100329 vendor/digitpaint/personify/vendor/treetop/doc/sitegen.rb
westarete-skylinecms-3.0.8.20100330 vendor/digitpaint/personify/vendor/treetop/doc/sitegen.rb
skylinecms-3.0.8 vendor/digitpaint/personify/vendor/treetop/doc/sitegen.rb
skylinecms-3.0.7 vendor/digitpaint/personify/vendor/treetop/doc/sitegen.rb
treetop-1.3.0 doc/sitegen.rb
treetop-1.2.6 doc/sitegen.rb
treetop-1.2.5 doc/sitegen.rb
treetop-1.2.4 doc/sitegen.rb