android.moparisthebest.org/.themes/classic/assets/javascripts/github.coffee
Brandon Mathis 7bdab0e65c Added javascript asset management and improved Rakefiles and configuration for themes and plugins.
- Added Guard for file watching
- Configs can be automatically reloaded
- Static asset changes do not trigger Jekyll build
- CommonJS modular js support proved by stich-rb
- Javascript is concatenated and uglified
- Environment variables toggle uglify and fingerprinting
- New Jekyll plugin config_tag
- New Jekyll plugin javascript_assets_tag
- Added theme specific configurations
- Custome Jekyll Guard to the rescue
- Install, Generate, Watch, and Preview work with Guard now.
- Now configs are no longer tracked by Octopress, only theme defauts are.
- Console messages can be colorized.
- misc config reorganization and improvements
2013-03-04 01:12:10 -06:00

61 lines
1.8 KiB
CoffeeScript

# Github fetcher for Octopress (c) Brandon Mathis // MIT License
helpers = require('helpers')
GitHub =
cookie: 'github-feed'
classname: 'github-feed'
template: (data)->
helpers.linkFeed data, @classname
errorTemplate: ->
helpers.errorTemplate "Failed to load repo list.", @classname
addRepo: (repo)->
title: repo.name
url: repo.url
text: repo.description
meta: repo.meta
format: (repos, options) ->
repoList = []
if options.repos
filter = []
filter.push i.trim().toLowerCase() for i in options.repos.split ','
for repo in repos
unless repoList.length is options.count and options.count > 1
if options.forks or options.watchers
repo.meta = ''
if options.watchers
repo.meta += "Watchers: #{repo.watchers}"
if options.forks
repo.meta += ' ,' if repo.meta.length > 0
repo.meta += "Forks: #{repo.forks}"
if filter and filter.indexOf repo.name.toLowerCase() > -1
# repo order should match list
repoList[filter.indexOf repo.name] = @addRepo repo, options
else if !filter
repoList.push @addRepo repo, options unless options.skipForks and repo.fork
repoList
init: (user, options, callback) ->
if options.count or options.repos
feed = $.cookie @cookie
if feed
callback @template JSON.parse(feed)
else
$.ajax
url: "https://api.github.com/users/#{user}/repos?callback=?"
dataType: 'jsonp'
error: (err) => callback @errorTemplate
success: (data) =>
data = @format(data.data, options)
$.cookie @cookie, JSON.stringify data, { path: '/' }
callback @template data
module.exports = GitHub