Created
May 7, 2011 10:30
-
-
Save grk/960394 to your computer and use it in GitHub Desktop.
Github repos in Jekyll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' | |
module Jekyll | |
class ProjectsIndex < Page | |
def initialize(site, base, projects_dir) | |
@site = site | |
@base = base | |
@dir = projects_dir | |
@name = 'index.html' | |
self.process(@name) | |
self.read_yaml(File.join(base, '_layouts'), 'projects.html') | |
projects = self.data['projects'].split(" ") | |
self.data['projects'] = [] | |
projects.each { |p| self.data['projects'] << Octokit.repo(p) } | |
end | |
end | |
class ProjectsGenerator < Generator | |
safe true | |
def generate(site) | |
dir = site.config['projects_dir'] || 'projects' | |
write_projects_index(site, dir) | |
end | |
def write_projects_index(site, dir) | |
index = ProjectsIndex.new(site, site.source, dir) | |
index.render(site.layouts, site.site_payload) | |
index.write(site.dest) | |
site.pages << index | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
layout: default | |
projects: grk/polish grk/devmail | |
--- | |
<div id="title"> | |
<h1>Open Source Projects</h1> | |
</div> | |
<div id="projects"> | |
{% for project in page.projects %} | |
<div id="project"> | |
<h2 id="project_name"> | |
<a href="{{ project.url }}"> | |
{{ project.name }} | |
</a> | |
</h2> | |
<div id="project_description">{{ project.description }}</div> | |
<div id="project_stats"> | |
<a href="{{ project.url }}/watchers">{{ project.watchers }} | |
{% if project.watchers == 1 %} watcher{% else %} watchers{% endif %}</a>, | |
<a href="{{ project.url }}/network">{{ project.forks }} | |
{% if project.forks == 1 %} fork {% else %} forks {% endif %} | |
</a> | |
</div> | |
<div id="project_links"> | |
{% if project.has_issues %} | |
<a href="{{ project.url }}/issues">issues ({{ project.open_issues }})</a>, | |
{% endif %} | |
{% if project.has_wiki %} | |
<a href="{{ project.url }}/wiki">wiki</a> | |
{% endif %} | |
</div> | |
</div> | |
{% endfor %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment