Created
June 1, 2013 19:57
-
-
Save ryanbriones/5691547 to your computer and use it in GitHub Desktop.
Civic Needs Issue test
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 "sinatra" | |
require "octokit" | |
class CivicNeedsIssuesList < Sinatra::Base | |
get "/" do | |
out = "" | |
Octokit.list_issues("ryanbriones/civicneeds", {:labels => "need"}).each do |issue| | |
out << %Q{<a href="/needs/#{issue.number}">##{issue.number} #{issue.title} (#{issue.comments} comments)</a>} | |
end | |
out | |
end | |
get "/needs/:issue_id" do |issue_id| | |
out = "" | |
issue = Octokit.issue("ryanbriones/civicneeds", issue_id) | |
issue_is_need = if issue | |
is_need = false | |
issue.labels.each do |label| | |
if label.name == "need" | |
is_need = true | |
break | |
end | |
end | |
is_need | |
else | |
false | |
end | |
if issue && issue_is_need | |
out << "<h1>#{issue.title}</h1>" | |
out << "<p>#{issue.body}</p>" | |
out << "<h2>Comments</h2>" | |
Octokit.issue_comments("ryanbriones/civicneeds", issue_id).each do |comment| | |
out << "<p><b>#{comment.user.login}</b> #{comment.body}</p>" | |
end | |
out | |
else | |
out = "Could not find need" | |
end | |
end | |
end | |
run CivicNeedsIssuesList.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment