Sha256: 941de97892f110b17b8efc83f54a344c600e5818a1211067a349436fd673338a

Contents?: true

Size: 1.32 KB

Versions: 187

Compression:

Stored size: 1.32 KB

Contents

class Layout < Erector::Widget

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

    def generate_site
      FileUtils.mkdir_p(site_dir)
      @@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.to_html)
      end
    end

    def absolute_path
      absolutize(relative_path)
    end

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

    def absolutize(relative_path)
      File.join(site_dir, relative_path)
    end

    def abstract
      @abstract = true
    end

    def abstract?
      @abstract
    end

    def site_dir
      File.join(File.dirname(__FILE__), "site")
    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

187 entries across 172 versions & 28 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/treetop-1.4.15/doc/sitegen.rb