pivotal_reporter 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +101 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/pivotal_reporter/application.js +15 -0
  5. data/app/assets/javascripts/pivotal_reporter/report_button.js.erb +47 -0
  6. data/app/assets/javascripts/pivotal_reporter/stories.js +20 -0
  7. data/app/assets/stylesheets/pivotal_reporter/application.css +13 -0
  8. data/app/assets/stylesheets/pivotal_reporter/report_button.css +80 -0
  9. data/app/assets/stylesheets/pivotal_reporter/stories.css +107 -0
  10. data/app/controllers/pivotal_reporter/application_controller.rb +16 -0
  11. data/app/controllers/pivotal_reporter/stories_controller.rb +46 -0
  12. data/app/helpers/pivotal_reporter/application_helper.rb +14 -0
  13. data/app/helpers/pivotal_reporter/stories_helper.rb +4 -0
  14. data/app/views/layouts/pivotal_reporter/application.html.erb +14 -0
  15. data/app/views/pivotal_reporter/stories/index.html.erb +27 -0
  16. data/app/views/pivotal_reporter/stories/new.html.erb +29 -0
  17. data/config/routes.rb +12 -0
  18. data/lib/pivotal_reporter/engine.rb +5 -0
  19. data/lib/pivotal_reporter/version.rb +3 -0
  20. data/lib/pivotal_reporter.rb +21 -0
  21. data/lib/tasks/pivotal_reporter_tasks.rake +4 -0
  22. data/test/dummy/README.rdoc +261 -0
  23. data/test/dummy/Rakefile +7 -0
  24. data/test/dummy/app/assets/javascripts/application.js +16 -0
  25. data/test/dummy/app/assets/stylesheets/application.css +14 -0
  26. data/test/dummy/app/controllers/application_controller.rb +3 -0
  27. data/test/dummy/app/controllers/home_controller.rb +5 -0
  28. data/test/dummy/app/helpers/application_helper.rb +2 -0
  29. data/test/dummy/app/views/home/show.html.erb +1 -0
  30. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  31. data/test/dummy/config/application.rb +66 -0
  32. data/test/dummy/config/boot.rb +10 -0
  33. data/test/dummy/config/database.yml +42 -0
  34. data/test/dummy/config/environment.rb +5 -0
  35. data/test/dummy/config/environments/development.rb +37 -0
  36. data/test/dummy/config/environments/production.rb +67 -0
  37. data/test/dummy/config/environments/test.rb +37 -0
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/dummy/config/initializers/inflections.rb +15 -0
  40. data/test/dummy/config/initializers/mime_types.rb +5 -0
  41. data/test/dummy/config/initializers/secret_token.rb +7 -0
  42. data/test/dummy/config/initializers/session_store.rb +8 -0
  43. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/test/dummy/config/locales/en.yml +5 -0
  45. data/test/dummy/config/routes.rb +4 -0
  46. data/test/dummy/config.ru +4 -0
  47. data/test/dummy/db/schema.rb +16 -0
  48. data/test/dummy/log/development.log +4364 -0
  49. data/test/dummy/public/404.html +26 -0
  50. data/test/dummy/public/422.html +26 -0
  51. data/test/dummy/public/500.html +25 -0
  52. data/test/dummy/public/favicon.ico +0 -0
  53. data/test/dummy/script/rails +6 -0
  54. data/test/dummy/tmp/cache/assets/C48/EB0/sprockets%2F1fb20c80c4175665273211488da697a1 +0 -0
  55. data/test/dummy/tmp/cache/assets/CA0/6A0/sprockets%2F6e014911e252a4b46c1cf70d670d2258 +0 -0
  56. data/test/dummy/tmp/cache/assets/CC9/5F0/sprockets%2Fa34fa8f3e0359b60251a71b6c026f041 +0 -0
  57. data/test/dummy/tmp/cache/assets/CCC/750/sprockets%2F1e2a9d985453c368995fa8bce4314789 +0 -0
  58. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  59. data/test/dummy/tmp/cache/assets/CDC/090/sprockets%2F10723973b4ee69a1a05ffb2091337f6f +0 -0
  60. data/test/dummy/tmp/cache/assets/CDE/880/sprockets%2F832319e041af12e36f4e7ea6491e76a3 +0 -0
  61. data/test/dummy/tmp/cache/assets/CDE/D10/sprockets%2F2bf3485a7d04d30e575db1680881f71c +0 -0
  62. data/test/dummy/tmp/cache/assets/CE0/370/sprockets%2F46a324b6fba8a3560c497c701c0779c9 +0 -0
  63. data/test/dummy/tmp/cache/assets/CF0/4F0/sprockets%2F81b494569ff00bf867c4812ed7ac1893 +0 -0
  64. data/test/dummy/tmp/cache/assets/CF4/E00/sprockets%2F97b92e64264f2fb7dc84175cb4608f75 +0 -0
  65. data/test/dummy/tmp/cache/assets/D15/B00/sprockets%2Ffb4b27a943e00ae9a5690586e9ac1468 +0 -0
  66. data/test/dummy/tmp/cache/assets/D21/100/sprockets%2F096d6b84e044e65bd722ec77716f4fc9 +0 -0
  67. data/test/dummy/tmp/cache/assets/D31/620/sprockets%2F6ce94a6b36d1bac354b15b306b4f7245 +0 -0
  68. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  69. data/test/dummy/tmp/cache/assets/D40/110/sprockets%2Fd37eb54db96cc70b5d8161a137e8716b +0 -0
  70. data/test/dummy/tmp/cache/assets/D47/8D0/sprockets%2Fde66b6526de8ac1e4d86728d1f32e109 +0 -0
  71. data/test/dummy/tmp/cache/assets/D4A/DC0/sprockets%2Fa8e7efa43c40f589179e7f53f13cb243 +0 -0
  72. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  73. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  74. data/test/dummy/tmp/cache/assets/D72/E60/sprockets%2F6cbacd35713005996a70c6bdf39ef2f7 +0 -0
  75. data/test/dummy/tmp/cache/assets/DD0/AC0/sprockets%2Ff4ac624dd7b9c1bb9af6cfd07982340d +0 -0
  76. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  77. data/test/dummy/tmp/cache/assets/DE1/840/sprockets%2Fc8dc8a7e4cdfc6ca2899d92d489331bc +0 -0
  78. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  79. data/test/dummy/tmp/pids/server.pid +1 -0
  80. data/test/functional/pivotal_reporter/stories_controller_test.rb +21 -0
  81. data/test/integration/navigation_test.rb +10 -0
  82. data/test/pivotal_reporter_test.rb +7 -0
  83. data/test/test_helper.rb +15 -0
  84. data/test/unit/helpers/pivotal_reporter/stories_helper_test.rb +6 -0
  85. metadata +244 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ Pivotal Reporter
2
+ ==============
3
+
4
+ Pivotal Reporter is a Rails Mountable Engine that injects a reporting overlay for rails applications that ties into
5
+ PivotalTracker in order to provide in-app bug reporting and feature requests.
6
+
7
+ Installation
8
+ ============
9
+
10
+ ## Install the Gem
11
+
12
+ gem 'pivotal_reporter', :git => 'git://github.com/7eyesllc/pivotal_reporter.git'
13
+
14
+ bundle install
15
+
16
+ ## Set Up Route
17
+
18
+ In routes.rb:
19
+
20
+ ```ruby
21
+ mount PivotalReporter::Engine => "/tracker" # can be mounted at whatever endpoint you want, not just /tracker
22
+ ```
23
+
24
+ If you want to limit the engine to logged in users with devise then:
25
+
26
+ ```ruby
27
+ authenticated :user do
28
+ mount PivotalReporter::Engine => "/tracker" # can be mounted at whatever endpoint you want, not just /tracker
29
+ end
30
+ ```
31
+
32
+ ## Configure
33
+
34
+ Add the top of the /config/application.rb:
35
+
36
+ require "pivotal_reporter"
37
+
38
+ Inside the application class definition in /config/application.rb:
39
+
40
+ ```ruby
41
+ PivotalReporter.config do |config|
42
+ config.token = '<your_api_token>'
43
+ config.project_id = <your_project_id>
44
+ config.mount_point = '/tracker'
45
+ config.request_user = '<your_request_user>'
46
+ config.enabled = true
47
+ end
48
+ ```
49
+
50
+ **API Token** can be found by visiting https://www.pivotaltracker.com/profile (logged in to your PivotalTracker account),
51
+ then scrolling all the way to the bottom.
52
+
53
+ **Project ID** is a large integer like `625931`. The idea behind this engine is that users can submit bugs and features
54
+ to a specific PivotalTracker project that corresponds to the rails application into which the engine is mounted. To find
55
+ your project ID, go to the project page in PivotalTracker and look at the url. The number in that URL is the Project ID.
56
+
57
+ **Mount Point** should match the endpoint you specified in your routes file in the previous step
58
+
59
+ **Request User** is the name of the PivotalTracker user under whom you will submit the bugs and features. The name is
60
+ literally just a name like "Pete Michaud" and should correspond exactly to the name of a project member who has access
61
+ to the project in PivotalTracker (otherwise the report submission will fail). Ideally this will be a generic "API user".
62
+
63
+ Alternatively, you can choose not to specify a request_user. What happens in that case is PivotalReporter will look for a
64
+ variable called current_user (the devise gem, for example, would define current_user), and it calls the full_name method
65
+ on current_user. So instead of using "Pete Michaud" it would use `current_user.full_name`.
66
+
67
+ The only way that will work is if:
68
+ 1) You have authentication set up so that current_user.full_name is defined
69
+ 2) All users who access the reporting tool are authenticated
70
+ 3) All users of your application correspond to PivotalTracker users who have access to the PivotalTracker project
71
+ 4) All those users use the exact same names across the application and PivotalTracker
72
+
73
+ ## Including the Widget
74
+
75
+ At this point the engine is mounted and accessible via the endpoint you specified. But the idea here is that the
76
+ reporting tool should be available at all times, on all pages. To make that happen:
77
+
78
+ 1) Add `//= require pivotal_reporter/report_button` to your application.js manifest
79
+
80
+ 2) Add `*= require pivotal_reporter/report_button` to your application.css manifest
81
+
82
+ The button should now appear.
83
+
84
+ ## Customizing the Widget
85
+
86
+ If you want to change the style of the widget, add these definitions to your application css files:
87
+
88
+ ```css
89
+ a#pt_report_button { } /* The Report button itself */
90
+
91
+ div#pivotal_reporter { } /* The frame that appears after clicking the Report button */
92
+ ```
93
+
94
+ If you want to style the report form or report list you'll have to fork and edit the engine repo. If that sounds
95
+ daunting, it's probably not worth the effort.
96
+
97
+ License
98
+ =======
99
+
100
+ MIT
101
+
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'PivotalReporter'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require ./stories
@@ -0,0 +1,47 @@
1
+ $(document).ready(function(){
2
+
3
+ if(!PivotalReporter::Engine.config.enabled) return;
4
+
5
+ ar slide_action = -1;
6
+ var container_width = -1;
7
+
8
+ $pr_toggle = $('<a href="#" id="pr_report_button" title="Report Bug or Request Feature">!</a>');
9
+ $pr_container = $('<div id="pivotal_reporter">');
10
+ $pr_frame = $('<iframe id="pivotal_reporter_window" border="0" >').attr('src', '<%= PivotalReporter::Engine.config.mount_point %>');
11
+ $pr_container.append($pr_frame).hide();
12
+
13
+ $pr_toggle.click(function(e){
14
+ h_slide_toggle($pr_container)
15
+ });
16
+
17
+ $pr_container
18
+ .mouseover(function(e) {
19
+ clearTimeout(slide_action);
20
+ })
21
+ .mouseout(function(e) {
22
+ slide_action = setTimeout(toggle_report_window, 500);
23
+ });
24
+
25
+ $('body').prepend($pr_container).prepend($pr_toggle);
26
+
27
+ var container_width = $pr_container.width();
28
+
29
+ $pr_container.css('width', 0).css('top', $pr_toggle.css('top')).show();
30
+
31
+ function toggle_report_window()
32
+ {
33
+ h_slide_toggle($pr_container);
34
+ }
35
+ function h_slide_toggle($obj)
36
+ {
37
+ var new_w = $obj.css('width') == '0px' ? container_width : 0;
38
+
39
+ $obj.animate(
40
+ {
41
+ width: new_w
42
+ },
43
+ 250,
44
+ 'swing');
45
+ }
46
+
47
+ });
@@ -0,0 +1,20 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
3
+
4
+ $(document).ready(function(){
5
+ $('.reject-btn').click(function(e){
6
+ var msg = '';
7
+ while (msg == '' || msg == null)
8
+ {
9
+ msg = prompt("Reason for Rejection:");
10
+ if (msg == null)
11
+ {
12
+ alert("You must enter a reason for your rejection.");
13
+ }
14
+ }
15
+
16
+ window.location = $(this).data('reject-path') + "?reject_message=" + encodeURI(msg);
17
+
18
+ return false;
19
+ });
20
+ });
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require ./stories
13
+ */
@@ -0,0 +1,80 @@
1
+ #pr_report_button {
2
+ display:block;
3
+ width:25px;
4
+ height:100px;
5
+
6
+ font-size:3em;
7
+ text-align: center;
8
+ line-height:100px;
9
+ text-decoration: none;
10
+ color: #fff;
11
+
12
+ position:absolute;
13
+ top:100px;
14
+ right:0;
15
+ z-index:2000;
16
+
17
+ border-left:2px solid #a0421c;
18
+
19
+ -webkit-border-top-left-radius: 5px;
20
+ -webkit-border-bottom-left-radius: 5px;
21
+ -moz-border-radius-topleft: 5px;
22
+ -moz-border-radius-bottomleft: 5px;
23
+ border-top-left-radius: 5px;
24
+ border-bottom-left-radius: 5px;
25
+
26
+ background: #ce3a00; /* Old browsers */
27
+ background: -moz-linear-gradient(45deg, #ce3a00 0%, #fe6a2c 100%); /* FF3.6+ */
28
+ background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#ce3a00), color-stop(100%,#fe6a2c)); /* Chrome,Safari4+ */
29
+ background: -webkit-linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* Chrome10+,Safari5.1+ */
30
+ background: -o-linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* Opera 11.10+ */
31
+ background: -ms-linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* IE10+ */
32
+ background: linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* W3C */
33
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ce3a00', endColorstr='#fe6a2c',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
34
+ }
35
+ #pr_report_button:hover {
36
+ background: #cc7a00; /* Old browsers */
37
+ background: -moz-linear-gradient(45deg, #cc7a00 0%, #ff8b2d 100%); /* FF3.6+ */
38
+ background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#cc7a00), color-stop(100%,#ff8b2d)); /* Chrome,Safari4+ */
39
+ background: -webkit-linear-gradient(45deg, #cc7a00 0%,#ff8b2d 100%); /* Chrome10+,Safari5.1+ */
40
+ background: -o-linear-gradient(45deg, #cc7a00 0%,#ff8b2d 100%); /* Opera 11.10+ */
41
+ background: -ms-linear-gradient(45deg, #cc7a00 0%,#ff8b2d 100%); /* IE10+ */
42
+ background: linear-gradient(45deg, #cc7a00 0%,#ff8b2d 100%); /* W3C */
43
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc7a00', endColorstr='#ff8b2d',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
44
+ }
45
+
46
+
47
+ #pivotal_reporter {
48
+ width:380px;
49
+ height:450px;
50
+ position:absolute;
51
+ top:0;
52
+ right:0;
53
+
54
+ background: #ce3a00; /* Old browsers */
55
+ background: -moz-linear-gradient(45deg, #ce3a00 0%, #fe6a2c 100%); /* FF3.6+ */
56
+ background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#ce3a00), color-stop(100%,#fe6a2c)); /* Chrome,Safari4+ */
57
+ background: -webkit-linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* Chrome10+,Safari5.1+ */
58
+ background: -o-linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* Opera 11.10+ */
59
+ background: -ms-linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* IE10+ */
60
+ background: linear-gradient(45deg, #ce3a00 0%,#fe6a2c 100%); /* W3C */
61
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ce3a00', endColorstr='#fe6a2c',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
62
+
63
+ -webkit-border-top-left-radius: 5px;
64
+ -webkit-border-bottom-left-radius: 5px;
65
+ -moz-border-radius-topleft: 5px;
66
+ -moz-border-radius-bottomleft: 5px;
67
+ border-top-left-radius: 5px;
68
+ border-bottom-left-radius: 5px;
69
+
70
+ z-index:2000;
71
+ overflow:hidden;
72
+ }
73
+
74
+ #pivotal_reporter_window {
75
+ width:360px;
76
+ height:430px;
77
+ margin:10px;
78
+ border:0;
79
+ overflow:hidden;
80
+ }
@@ -0,0 +1,107 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ body {
7
+ background: #fff;
8
+ }
9
+
10
+ table {
11
+ margin:15px auto;
12
+ width:95%;
13
+ }
14
+
15
+ thead {
16
+ font-weight:900;
17
+ background: #cce8ff;
18
+ }
19
+
20
+ td {
21
+ padding:5px;
22
+ }
23
+
24
+ tr {
25
+ border-bottom:1px solid #ddd;
26
+ }
27
+
28
+ .status, .type {
29
+ width:50px;
30
+ text-align: center;
31
+ }
32
+
33
+ .type a {
34
+ display:block;
35
+ width:25px;
36
+ height:25px;
37
+ line-height:25px;
38
+ border-radius: 5px;
39
+ background:#eee;
40
+ margin:0 auto;
41
+ color:#fff;
42
+ text-decoration: none;
43
+ }
44
+
45
+ .type a.bug {
46
+ background:#900;
47
+ }
48
+
49
+ .type a.feature {
50
+ background: #009;
51
+ }
52
+
53
+ label {
54
+ float:left;
55
+ width:100px;
56
+ text-align: right;
57
+ margin:0 10px 0 0
58
+ }
59
+
60
+ select, input, textarea {
61
+ width:200px
62
+ }
63
+
64
+ textarea {
65
+ height:100px;
66
+ }
67
+
68
+ input[type="submit"] {
69
+ margin-left:110px;
70
+ }
71
+
72
+ .success {
73
+ width:85%;
74
+ padding:10px;
75
+ margin:15px auto;
76
+ border:1px solid #090;
77
+ border-radius: 5px;
78
+ background:#dbffb7;
79
+ }
80
+
81
+ a.accept-btn, a.reject-btn {
82
+ display:block;
83
+ height:25px;
84
+ line-height:25px;
85
+ border-radius: 5px;
86
+ background:#eee;
87
+ margin:0 auto;
88
+ color:#fff;
89
+ text-decoration: none;
90
+ }
91
+
92
+ a.accept-btn {
93
+ background:#090;
94
+ margin-bottom:5px;
95
+ }
96
+
97
+ a.accept-btn:hover{
98
+ background:#0e0;
99
+ }
100
+
101
+ a.reject-btn {
102
+ background:#900;
103
+ }
104
+
105
+ a.reject-btn:hover{
106
+ background:#e00;
107
+ }
@@ -0,0 +1,16 @@
1
+ module PivotalReporter
2
+ class ApplicationController < ActionController::Base
3
+
4
+ PivotalTracker::Client.token = PivotalReporter::Engine.config.token
5
+
6
+ def pivotal_project
7
+ PivotalTracker::Project.find(PivotalReporter::Engine.config.project_id)
8
+ end
9
+
10
+ def pivotal_unique_label
11
+ "pivotal_reporter_#{PivotalReporter::Engine.config.project_id}"
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,46 @@
1
+ require_dependency "pivotal_reporter/application_controller"
2
+
3
+ module PivotalReporter
4
+ class StoriesController < ApplicationController
5
+ def index
6
+ @stories = pivotal_project.stories.all(label: pivotal_unique_label)
7
+ end
8
+
9
+ def show
10
+ @story = pivotal_project.stories.find(params[:id])
11
+ end
12
+
13
+ def new
14
+ @pivotal_unique_label = pivotal_unique_label
15
+ end
16
+
17
+ def create
18
+ story = PivotalTracker::Story.new(params[:story]).create
19
+
20
+ if story.errors.count > 0
21
+ flash[:error] = "Report Submission Failed: #{story.errors}"
22
+ else
23
+ flash[:success] = 'Report Submitted!'
24
+ end
25
+
26
+ redirect_to new_story_path
27
+ end
28
+
29
+ def accept
30
+ @story = pivotal_project.stories.find(params[:id])
31
+ @story.update({current_state: 'accepted'})
32
+
33
+ redirect_to stories_path
34
+ end
35
+
36
+ def reject
37
+ @story = pivotal_project.stories.find(params[:id])
38
+ @story.update({current_state: 'rejected'})
39
+ @story.notes.create(:text => URI.decode(params[:reject_message]))
40
+
41
+ redirect_to stories_path
42
+ end
43
+
44
+
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ module PivotalReporter
2
+ module ApplicationHelper
3
+
4
+ def pivotal_labels
5
+ "#{@pivotal_unique_label}, remote_user_#{requested_by.gsub(' ', '').underscore}"
6
+ end
7
+
8
+ def requested_by
9
+ PivotalReporter::Engine.config.request_user || current_user.full_name
10
+ end
11
+
12
+
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module PivotalReporter
2
+ module StoriesHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>PivotalReporter</title>
5
+ <%= stylesheet_link_tag "pivotal_reporter/application", :media => "all" %>
6
+ <%= javascript_include_tag "pivotal_reporter/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,27 @@
1
+ <%= link_to "Submit New Report", new_story_path %>
2
+ <table>
3
+ <thead>
4
+ <tr>
5
+ <th class="type">Type</th>
6
+ <th class="status">Status</th>
7
+ <th>Description</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @stories.each do |story| %>
12
+ <tr>
13
+ <td class="type"><a href="<%= story.url %>" class="<%= story.story_type %>" title="<%= story.story_type %> <%= story.id %>"><%= story.story_type[0].capitalize %></a></td>
14
+ <td class="status">
15
+ <%= story.current_state.capitalize %>
16
+ <% if story.current_state == 'delivered' %>
17
+ <%= link_to 'Accept', accept_story_path(story.id), class: 'accept-btn' %>
18
+ <%= link_to 'Reject', '#', class: 'reject-btn', :'data-reject-path' => reject_story_path(story.id) %>
19
+ <% end %>
20
+ </td>
21
+ <td><%= story.name %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+
27
+ <%= link_to "Submit New Report", new_story_path %>
@@ -0,0 +1,29 @@
1
+ <% if flash[:success] %>
2
+ <div class="success"><%= flash[:success] %></div>
3
+ <% end %>
4
+
5
+ <form method="post" action="<%= PivotalReporter::Engine.config.mount_point %>/stories">
6
+ <label for="story[story_type]">Type</label>
7
+ <select name="story[story_type]">
8
+ <option value="bug">Bug</option>
9
+ <option value="feature">Feature</option>
10
+ </select>
11
+ <br />
12
+
13
+ <label for="story[name]">Title</label>
14
+ <input type="text" name="story[name]" />
15
+ <br />
16
+
17
+ <label for="story[description]">Description</label>
18
+ <textarea name="story[description]"></textarea>
19
+ <br />
20
+
21
+ <input type="hidden" name="story[labels]" value="<%= pivotal_labels %>" />
22
+ <input type="hidden" name="story[project_id]" value="<%= PivotalReporter::Engine.config.project_id %>" />
23
+ <input type="hidden" name="story[requested_by]" value="<%= requested_by %>" />
24
+
25
+ <input type="submit" value="Report" />
26
+
27
+ </form>
28
+
29
+ <%= link_to "View Your Active Submissions", stories_path %>
data/config/routes.rb ADDED
@@ -0,0 +1,12 @@
1
+ PivotalReporter::Engine.routes.draw do
2
+
3
+ resources :stories do
4
+ member do
5
+ get 'accept' => 'stories#accept', to: :accept_story
6
+ get 'reject' => 'stories#reject', to: :reject_story
7
+ end
8
+ end
9
+
10
+ root :to => 'stories#new'
11
+
12
+ end
@@ -0,0 +1,5 @@
1
+ module PivotalReporter
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace PivotalReporter
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module PivotalReporter
2
+ VERSION = "0.7.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ require "pivotal_reporter/engine"
2
+ require 'pivotal-tracker'
3
+
4
+ module PivotalReporter
5
+ class Engine < Rails::Engine
6
+
7
+ initializer "pivotal_reporter.configure_rails_initialization" do |app|
8
+ #
9
+ end
10
+
11
+ end
12
+
13
+ # This is what I was trying to figure out
14
+ def self.config(&block)
15
+ @@config ||= Engine::Configuration.new
16
+
17
+ yield @@config if block
18
+
19
+ return @@config
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :pivotal_reporter do
3
+ # # Task goes here
4
+ # end