-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
69 lines (55 loc) · 1.39 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# myapp.rb
require 'sinatra'
require 'playnicely'
require 'config'
enable :logging
client = PlayNicely::Client.new(PLAYNICELY_USERNAME, PLAYNICELY_PASSWORD)
post '/feedback' do
me = client.current_user
if(params[:type] == 'bug')
type = 'bug'
elsif(params[:type] == 'idea')
type = 'idea'
else
type = 'bug'
end
if(!params[:short])
params[:short] = ""
end
if(!params[:long])
params[:long] = ""
end
if(params[:email] != "")
params[:long] = "From: #{params[:email]}\n\n#{params[:long]}"
end
begin
item = client.create_item(PLAYNICELY_PROJECT_ID, {
:project_id => PLAYNICELY_PROJECT_ID,
:milestone_id => PLAYNICELY_MILESTONE_ID,
:involved => [me.user_id],
:responsible => me.user_id,
:subject => params[:short],
:body => params[:long],
:tags => ["feedback"],
:status => "new",
:type_name => type
})
"success"
rescue PlayNicely::ClientError => error
error
end
end
get '/' do
File.read('index.html')
end
get '/setup_info' do
me = client.current_user
my_projects = client.user_projects(me.user_id)
puts "Logged in as #{me.username} ID: #{me.user_id}"
puts "Your projects are:"
my_projects.each do |project|
puts "#{project.name} (ID: #{project.project_id})"
end
puts YAML::dump client.project_milestones(PLAYNICELY_PROJECT_ID)
"See your console log for relevant information"
end