This repository has been archived by the owner on Apr 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pete Nicholls
committed
Jan 12, 2012
0 parents
commit 923ae18
Showing
13 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tmp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source :rubygems | ||
|
||
gem 'rake' | ||
gem 'sinatra' | ||
gem 'redis-namespace' | ||
gem 'sass' | ||
gem 'thin' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
daemons (1.1.5) | ||
eventmachine (0.12.10) | ||
rack (1.4.0) | ||
rack-protection (1.2.0) | ||
rack | ||
rake (0.9.2.2) | ||
redis (2.2.2) | ||
redis-namespace (1.1.0) | ||
redis (< 3.0.0) | ||
sass (3.1.12) | ||
sinatra (1.3.2) | ||
rack (~> 1.3, >= 1.3.6) | ||
rack-protection (~> 1.2) | ||
tilt (~> 1.3, >= 1.3.3) | ||
thin (1.3.1) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
tilt (1.3.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rake | ||
redis-namespace | ||
sass | ||
sinatra | ||
thin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: bundle exec thin start -p $PORT -e $RACK_ENV |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'bundler/setup' | ||
require 'fileutils' | ||
|
||
task :update_scripts do | ||
mkdir 'tmp' | ||
rmdir 'tmp/hubot-scripts' | ||
exec 'git clone git://github.com/github/hubot-scripts.git tmp/hubot-scripts' | ||
end | ||
|
||
task :catalog do | ||
require './brain' | ||
|
||
Dir['tmp/hubot-scripts/src/scripts/*.coffee'].each do |script| | ||
name = script.split('/').last | ||
|
||
begin | ||
file = File.new(script, 'r') | ||
description = "" | ||
commands = "" | ||
|
||
# See Hubot's robot.coffee for how it approaches reading comments | ||
while line = file.gets | ||
break unless (line[0] == "#" || line[0..1] == "//") | ||
cleaned_line = line.gsub(/^[#|\/\/]?/, '').lstrip | ||
|
||
if cleaned_line.match("-") | ||
commands << cleaned_line | ||
elsif !cleaned_line.strip.empty? | ||
description << cleaned_line | ||
end | ||
end | ||
|
||
$redis.hmset("scripts:#{name}", :description, description, :commands, commands) | ||
rescue => error | ||
puts "Error in #{name}: #{error}" | ||
ensure | ||
file.close | ||
end | ||
end | ||
|
||
$redis[:last_updated] = Time.now | ||
end | ||
|
||
task :default => :catalog |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'bundler/setup' | ||
require 'sinatra' | ||
require './brain' | ||
|
||
helpers do | ||
include Rack::Utils | ||
alias_method :h, :escape_html | ||
|
||
def format_description(d) | ||
escape_html(d).gsub(/\n/, "<br>") | ||
end | ||
end | ||
|
||
def all_scripts | ||
scripts = [] | ||
|
||
$redis.keys('scripts:*').each do |key| | ||
scripts << $redis.hgetall(key).merge('name' => key.split(':').last) | ||
end | ||
|
||
scripts.sort_by { |s| s['name'] } | ||
end | ||
|
||
get '/' do | ||
@scripts = all_scripts | ||
@last_updated = Time.parse($redis['last_updated']) | ||
erb :index | ||
end | ||
|
||
get '/stylesheets/master.css' do | ||
sass :master | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'redis/namespace' | ||
|
||
redis_config = {} | ||
|
||
if ENV["REDISTOGO_URL"] | ||
uri = URI.parse(ENV["REDISTOGO_URL"]) | ||
redis_config = { :host => uri.host, :port => uri.port, :password => uri.password } | ||
end | ||
|
||
redis = Redis.new(redis_config) | ||
$redis = Redis::Namespace.new(:hubot_catalog, :redis => redis) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require './app' | ||
run Sinatra::Application |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<table> | ||
<% @scripts.each do |script| %> | ||
<tr class="script"> | ||
<th> | ||
<a href="https://github.com/github/hubot-scripts/blob/master/src/scripts/<%=h script['name'] %>"> | ||
<%=h script['name'] %> | ||
</a> | ||
</th> | ||
|
||
<td> | ||
<% if script['description'].empty? %> | ||
<p class="empty">No description available.</p> | ||
<% else %> | ||
<p class="description"><%= format_description script['description'] %></p> | ||
<% end %> | ||
|
||
<% if !script['commands'].empty? %> | ||
<div class="commands"> | ||
<pre><%=h script['commands'] %></pre> | ||
</div> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
|
||
<p class="last-updated"> | ||
Last updated: <%= @last_updated %> | ||
</p> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hubot Script Catalog</title> | ||
<link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen"> | ||
</head> | ||
<body> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@import reset | ||
|
||
body | ||
font: 12pt/1.6em Palatino, Georgia, serif | ||
color: #333 | ||
|
||
a | ||
border-bottom: 1px dashed #ccc | ||
color: black | ||
text-decoration: none | ||
|
||
&:hover | ||
color: #1F6EBD | ||
|
||
table | ||
border-bottom: 1px solid #E5E5EE | ||
|
||
td, th | ||
padding: 1em | ||
|
||
td | ||
background: #F5F5FF | ||
border-left: 1px solid #E5E5EE | ||
|
||
th | ||
font-size: 1.2em | ||
text-align: right | ||
|
||
.script | ||
&:hover | ||
th | ||
background: #FFF9EC | ||
|
||
td | ||
background: #FFE8AE | ||
|
||
.commands | ||
display: block | ||
|
||
.commands | ||
display: none | ||
|
||
pre | ||
background: #FCFBE4 | ||
font: 10pt/1.6em Monaco, monospace | ||
padding: 0.2em | ||
margin: 1em 0 | ||
overflow: auto | ||
|
||
.empty | ||
color: #999 | ||
font-style: italic | ||
|
||
.last-updated | ||
padding: 1em | ||
text-align: center |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Meyer's CSS Reset, translated into SASS | ||
/* v1.0 | 20080212 */ | ||
|
||
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, | ||
del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, | ||
fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td | ||
margin: 0 | ||
padding: 0 | ||
border: 0 | ||
outline: 0 | ||
font-size: 100% | ||
vertical-align: baseline | ||
background: transparent | ||
|
||
body | ||
line-height: 1 | ||
|
||
ol, ul | ||
list-style: none | ||
|
||
blockquote, q | ||
quotes: none | ||
|
||
blockquote:before, blockquote:after, q:before, q:after | ||
content: '' | ||
content: none | ||
|
||
/* remember to define focus styles! */ | ||
\:focus | ||
outline: 0 | ||
|
||
/* remember to highlight inserts somehow! */ | ||
ins | ||
text-decoration: none | ||
|
||
del | ||
text-decoration: line-through | ||
|
||
/* tables still need 'cellspacing="0"' in the markup */ | ||
table | ||
border-collapse: collapse | ||
border-spacing: 0 |