Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 24 lines (19 sloc) 0.748 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
module Toto
  module Template
    def to_html page, config, &blk
      path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages])
      config[:to_html].call(path, page, self, blk)
    end
  end

  class Repo

    FILE = "https://github.com/%s/%s/raw/master/%s"

    def readme
      filename = (FILE % [@config[:github][:user], self[:name], @config[:github][:files][self[:name]]])
      Tilt.new(filename) {open(filename).read }.render(self)
    rescue Timeout::Error, OpenURI::HTTPError => e
      homepage = "https://github.com/%s/%s" % [@config[:github][:user], self[:name]]
      "Couldn't fetch the readme, you can try going to <a href=\"#{homepage}\">the project homepage</a>."
    end

    alias :content readme
  end
end
Something went wrong with that request. Please try again.