Created
April 29, 2011 08:58
-
-
Save pepe/948069 to your computer and use it in GitHub Desktop.
Dr.Ape issues
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 "rubygems" | |
require "sinatra" | |
require "net/http" | |
require "net/https" | |
require "uri" | |
get "/:status?" do | |
erb :index | |
end | |
post "/" do | |
url = URI.parse("https://github.com/api/v2/json/issues/open/LOGIN/REPO_NAME") | |
req = Net::HTTP::Post.new(url.path) | |
req.set_form_data({ :login => "LOGIN", | |
:token => "TOKEN", | |
:title => params[:email], | |
:body => params[:body] }) | |
http = Net::HTTP.new(url.host, url.port) | |
http.use_ssl = true | |
res = http.start {|http| http.request(req) } | |
case res | |
when Net::HTTPSuccess, Net::HTTPRedirection | |
redirect "/ok" | |
else | |
redirect "/fail" | |
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
<% if params[:status] == "ok" %> | |
<div id="notice_ok">Thank you for your interest. We'll send you an email to address you have provided.</div> | |
<% elsif params[:status] == "fail" %> | |
<div id="notice_fail">We're sorry for inconvenience, but some error occured during your feedback. Please try it again later.</div> | |
<% else %> | |
<form name="feedback" method="POST" action="/"> | |
<textarea name="body" required placeholder="Text of your issue or suggestion. Thanks."></textarea><br /> | |
<input type="email" required name="email" placeholder="Your email address." class="text" /><br /> | |
<input type="submit" value="Send!" class="button" /> | |
</form> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment