feature_box 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. data/CHANGELOG.rdoc +1 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +107 -0
  4. data/app/assets/javascripts/feature_box/application.js +39 -0
  5. data/app/assets/stylesheets/feature_box/application.css.scss +133 -0
  6. data/app/assets/stylesheets/feature_box/comments.css.scss +41 -0
  7. data/app/assets/stylesheets/feature_box/mixins.css.scss +37 -0
  8. data/app/assets/stylesheets/feature_box/suggestions.css.scss +110 -0
  9. data/app/controllers/feature_box/application_controller.rb +37 -0
  10. data/app/controllers/feature_box/categories_controller.rb +43 -0
  11. data/app/controllers/feature_box/comments_controller.rb +46 -0
  12. data/app/controllers/feature_box/devise/passwords_controller.rb +4 -0
  13. data/app/controllers/feature_box/devise/redirects.rb +21 -0
  14. data/app/controllers/feature_box/devise/registrations_controller.rb +4 -0
  15. data/app/controllers/feature_box/devise/sessions_controller.rb +4 -0
  16. data/app/controllers/feature_box/home_controller.rb +8 -0
  17. data/app/controllers/feature_box/suggestions_controller.rb +161 -0
  18. data/app/controllers/feature_box/users_controller.rb +32 -0
  19. data/app/helpers/feature_box/application_helper.rb +40 -0
  20. data/app/mailers/feature_box/devise/mailer.rb +3 -0
  21. data/app/models/feature_box/ability.rb +25 -0
  22. data/app/models/feature_box/category.rb +15 -0
  23. data/app/models/feature_box/comment.rb +15 -0
  24. data/app/models/feature_box/suggestion.rb +113 -0
  25. data/app/models/feature_box/user.rb +61 -0
  26. data/app/models/feature_box/vote.rb +6 -0
  27. data/app/views/feature_box/categories/_form.html.haml +14 -0
  28. data/app/views/feature_box/categories/edit.html.haml +3 -0
  29. data/app/views/feature_box/categories/index.html.haml +26 -0
  30. data/app/views/feature_box/categories/new.html.haml +3 -0
  31. data/app/views/feature_box/comments/_comment.html.haml +9 -0
  32. data/app/views/feature_box/comments/_new.html.haml +9 -0
  33. data/app/views/feature_box/comments/edit.html.haml +17 -0
  34. data/app/views/feature_box/comments/index.html.haml +8 -0
  35. data/app/views/feature_box/devise/_links.html.haml +9 -0
  36. data/app/views/feature_box/devise/confirmations/new.html.haml +7 -0
  37. data/app/views/feature_box/devise/mailer/confirmation_instructions.html.haml +4 -0
  38. data/app/views/feature_box/devise/mailer/reset_password_instructions.html.haml +6 -0
  39. data/app/views/feature_box/devise/mailer/unlock_instructions.html.haml +5 -0
  40. data/app/views/feature_box/devise/passwords/edit.html.haml +7 -0
  41. data/app/views/feature_box/devise/passwords/new.html.haml +5 -0
  42. data/app/views/feature_box/devise/registrations/edit.html.haml +16 -0
  43. data/app/views/feature_box/devise/registrations/new.html.haml +8 -0
  44. data/app/views/feature_box/devise/sessions/new.html.haml +8 -0
  45. data/app/views/feature_box/shared/_pages_nav.html.haml +6 -0
  46. data/app/views/feature_box/suggestions/_form.html.haml +30 -0
  47. data/app/views/feature_box/suggestions/_order_nav.html.haml +6 -0
  48. data/app/views/feature_box/suggestions/_search.html.haml +4 -0
  49. data/app/views/feature_box/suggestions/_suggestion.html.haml +31 -0
  50. data/app/views/feature_box/suggestions/edit.html.haml +3 -0
  51. data/app/views/feature_box/suggestions/index.html.haml +27 -0
  52. data/app/views/feature_box/suggestions/new.html.haml +6 -0
  53. data/app/views/feature_box/suggestions/show.html.haml +2 -0
  54. data/app/views/feature_box/users/edit.html.haml +14 -0
  55. data/app/views/feature_box/users/index.html.haml +24 -0
  56. data/app/views/layouts/feature_box/application.html.haml +81 -0
  57. data/config/initializers/devise.rb +3 -0
  58. data/config/routes.rb +35 -0
  59. data/db/seeds.rb +11 -0
  60. data/lib/feature_box.rb +72 -0
  61. data/lib/feature_box/engine.rb +5 -0
  62. data/lib/feature_box/helpers.rb +49 -0
  63. data/lib/feature_box/version.rb +3 -0
  64. data/lib/generators/feature_box/existing_generator.rb +26 -0
  65. data/lib/generators/feature_box/generator_base.rb +47 -0
  66. data/lib/generators/feature_box/initializer_generator.rb +14 -0
  67. data/lib/generators/feature_box/migrations_generator.rb +25 -0
  68. data/lib/generators/feature_box/standalone_generator.rb +27 -0
  69. data/lib/generators/feature_box/templates/initializers/initializer.rb +32 -0
  70. data/lib/generators/feature_box/templates/initializers/new_devise_initializer.rb +8 -0
  71. data/lib/generators/feature_box/templates/migrations/00_create_feature_box_suggestions.rb +15 -0
  72. data/lib/generators/feature_box/templates/migrations/01_create_feature_box_categories.rb +9 -0
  73. data/lib/generators/feature_box/templates/migrations/02_create_feature_box_comments.rb +13 -0
  74. data/lib/generators/feature_box/templates/migrations/03_create_feature_box_votes.rb +12 -0
  75. data/lib/generators/feature_box/templates/migrations/04_create_feature_box_users.rb +10 -0
  76. data/lib/generators/feature_box/templates/migrations/05_add_devise_to_feature_box_users.rb +50 -0
  77. data/lib/generators/feature_box/templates/migrations/06_add_type_to_{model_name}.rb +5 -0
  78. data/lib/generators/feature_box/views_generator.rb +14 -0
  79. data/lib/tasks/feature_box_tasks.rake +9 -0
  80. data/test/existing-template/application.html.erb +40 -0
  81. data/test/existing-template/application_helper.rb +11 -0
  82. data/test/existing-template/index.html.erb +1 -0
  83. data/test/run-all-tests.sh +7 -0
  84. data/test/template.rb +29 -0
  85. data/vendor/assets/stylesheets/bootstrap.min.css +689 -0
  86. metadata +250 -0
@@ -0,0 +1 @@
1
+ == 0.8.0
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Dmitry Filimonov
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.
@@ -0,0 +1,107 @@
1
+ = FeatureBox
2
+
3
+ FeatureBox is a feature request service written using Ruby on Rails framework.
4
+ It is an open source analog of VoteBox[http://www.dropbox.com/votebox] - part of the DropBox
5
+
6
+ It is designed to be flexible and customizable and intended to be easily integrated into your website.
7
+ It uses popular gems like *CanCan* and *Devise*.
8
+
9
+ Take a look at the demo here: http://featurebox.me
10
+
11
+ == Installation
12
+ ===Basic steps
13
+
14
+ Edit your *Gemfile* to add a dependency on the feature_box gem.
15
+ gem 'feature_box'
16
+
17
+ Update dependencies
18
+ bundle update
19
+
20
+ Before moving any further you will need to choose the right generator.
21
+ There are two of them: one for *existing* app and one for *standalone* installation.
22
+
23
+ The main difference is that standalone generator creates a new User model, installs and configures Devise. It is meant to run on a clean rails app and that's why it is called standalone. Use this generator to test FeatureBox or if your application doesn't have any User model.
24
+
25
+ If you installing FeatureBox on existing app you might want to keep existing users and this is situation when you have to use generator for existing application.
26
+
27
+
28
+ === Standalone
29
+ One simple command will create User model, install Devise, run migrations and everything.
30
+
31
+ rails g feature_box:standalone
32
+
33
+
34
+ === Existing Application
35
+ Make sure you have User model in your application.
36
+ Install Devise on if you haven't done this yet.
37
+
38
+ Then install FeatureBox with just one command:
39
+ rails g feature_box:existing
40
+
41
+ If you don't want to rely on this smart generator script, check Manual Installation part.
42
+
43
+
44
+ === Manual Installation
45
+
46
+ ==== Initializer
47
+ Use this generator to create a new initializer in +config/initializers/feature_box.rb+
48
+ rails g feature_box:initializer
49
+
50
+ ==== Routes
51
+ Routing is really easy:
52
+ mount FeatureBox::Engine => '/any_path'
53
+
54
+ ==== Migrations
55
+ FeatureBox has a generator for this:
56
+ rails g feature_box:migrations
57
+
58
+ Here is a list of avaliable migrations:
59
+ * 00_create_feature_box_suggestions.rb
60
+ * 01_create_feature_box_categories.rb
61
+ * 02_create_feature_box_comments.rb
62
+ * 03_create_feature_box_votes.rb
63
+ * 04_create_feature_box_users.rb
64
+ * 05_add_devise_to_feature_box_users.rb
65
+ * 06_add_type_to_{model_name}.rb
66
+
67
+ Migrations 00..03 are a must.
68
+
69
+ Install migrations 04 and 05 if you don't have User model. This is what *standalone* generator does.
70
+
71
+ Install migration 06 if you already have a User model in your app. This will add +:type+ column to the model and this is important because Rails STI doesn't work without this trick. Generator will also ask you for a model name in case it is not User.
72
+
73
+ Run migrations like you always do:
74
+ rake db:migrate
75
+
76
+ ==== Tweaking Initializer
77
+ In case you already use Devise in your app you have to set *devise_router_name* to *:main_app* in the initializer:
78
+ settings.devise_router_name = :main_app
79
+ Make sure you have this line in the initializer:
80
+ settings.devise_parent_model = "User"
81
+
82
+ == Other Things You May Want To Install
83
+ === Views
84
+ Use this generator to copy views to your app so you can easily edit them:
85
+ rails g feature_box:views
86
+
87
+ === ActionMailer Configuration
88
+ It is pretty simple and basically the same as with any other Rails App.
89
+ More info coming soon.
90
+
91
+
92
+ == TODOs
93
+ * Correct spelling mistakes. I am not a native speaker and it is really hard for me. Conribute, please.
94
+ * Test coverage. It is really poor at the moment.
95
+ * AJAX
96
+
97
+
98
+ == Contribution
99
+ I invite everyone who wants to help me with this project.
100
+
101
+ Share your ideas and thoughts here: http://featurebox.me.
102
+
103
+ Issues Tracker is available here: http://github.com/petethepig/featurebox/issues.
104
+
105
+
106
+ == License
107
+ MIT License. Copyright 2012 {Dmitry Filimonov}[http://dfilimonov.com].
@@ -0,0 +1,39 @@
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
+
16
+
17
+ var FeatureBox={
18
+ initAjaxListeners:function(){
19
+ $(".vote-btn").bind("ajax:success",function(ev,data){
20
+ var obj = data;
21
+ if(obj.error){
22
+
23
+ }else{
24
+ $(this).parent().children(".vote-frame").children(".vote-number").text(obj.total_votes);
25
+ $(this).parent().children(".vote-frame").children(".user-votes").text("+"+obj.user_votes).removeClass("hidden");
26
+ $(this).parent().children(".vote-frame").children(".votes-label").text(obj.total_votes==1?"vote":"votes");
27
+ if(obj.votes_left>0)
28
+ $("#votes-left").children("span").text(obj.votes_left+(obj.votes_left==1?" vote":" votes"));
29
+ else
30
+ $("#votes-left").text("You have no votes left")
31
+ }
32
+ });
33
+ $("a.disabled").click(function(e){e.preventDefault();return false});
34
+ }
35
+ }
36
+
37
+ $(document).ready(function(){
38
+ FeatureBox.initAjaxListeners();
39
+ });
@@ -0,0 +1,133 @@
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 bootstrap.min
12
+ *= require_tree .
13
+ */
14
+
15
+ @import 'mixins.css.scss';
16
+
17
+ header {
18
+ padding: 30px 0;
19
+ }
20
+
21
+ .nav-list{
22
+ li{
23
+ a{
24
+ @include radius(4px);
25
+ }
26
+ }.active{
27
+ a{
28
+ background: #08C;
29
+ @include linear-gradient(#0095E0, #08C);
30
+ border:1px solid #0095E0;
31
+ padding:2px 14px;
32
+ }
33
+ }
34
+ }
35
+
36
+ .black-link, .black-link:HOVER{
37
+ text-decoration:none;
38
+ color:black;
39
+ }
40
+
41
+ a.disabled, a.disabled:HOVER{
42
+ color: #ccc;
43
+ }
44
+
45
+ a.danger{
46
+ color:#f22;
47
+ }
48
+
49
+
50
+ .span8-5{
51
+ width:650px;
52
+ }
53
+
54
+ .empty{
55
+ line-height: 27px;
56
+ font-size: 18px;
57
+ margin: 40px 0;
58
+ text-align:center;
59
+ }
60
+
61
+ .inline{
62
+ display:inline;
63
+ }
64
+
65
+ .center{
66
+ text-align: center;
67
+ }
68
+
69
+
70
+ #current-user-wrapper{
71
+ position:absolute;
72
+ width:100%;
73
+ #current-user{
74
+ height:0;
75
+ div{
76
+ padding: 5px 10px;
77
+ }
78
+ }
79
+ }
80
+
81
+ #votes-left{
82
+ line-height:1.25;
83
+ }
84
+
85
+
86
+ .new-btn{
87
+ text-align:center;
88
+ margin-top:40px;
89
+ a{
90
+ width: 670px;
91
+ }
92
+ }
93
+
94
+ #admin-links{
95
+ display:block;
96
+ }
97
+
98
+
99
+ footer .span12{
100
+ margin-top: 45px;
101
+ padding: 35px 0 36px;
102
+ border-top: 1px solid #E5E5E5;
103
+ }
104
+
105
+
106
+ .clearfix{
107
+ clear:both;
108
+ }
109
+
110
+ .hidden{
111
+ visibility:hidden;
112
+ }
113
+
114
+
115
+ @media(max-width: 970px) { /*for better experience on low resolution displays*/
116
+ .container{
117
+ padding-left: 15px;
118
+ padding-right: 15px;
119
+ }
120
+ }
121
+
122
+ //*Categories and Users pages**/
123
+ ul.table-nav{
124
+ margin:0;
125
+ padding:0;
126
+ border-bottom:none;
127
+ font-weight:normal;
128
+ margin-bottom:-34px;
129
+ }
130
+
131
+ table tr td:last-child{
132
+ text-align:right;
133
+ }
@@ -0,0 +1,41 @@
1
+ // Place all the styles related to the Comments controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
4
+
5
+ @import 'mixins.css.scss';
6
+
7
+ #comments{
8
+ margin: 0;
9
+ }
10
+
11
+ #comments-nav{
12
+ margin:0;
13
+ }
14
+
15
+ .comment{
16
+ padding:30px 0;
17
+ border-top:1px solid #ddd;
18
+ margin-top:-1px;
19
+ clear:both;
20
+ .comment-user{
21
+ width:120px;
22
+ float:left;
23
+ padding-left:20px;
24
+ font-weight:bold;
25
+ }
26
+ .comment-text{
27
+ margin:0 100px 0 150px;
28
+ line-height:1.5;
29
+ }
30
+ .comment-date{
31
+ float:right;
32
+ position:relative;
33
+ top:-20px;
34
+ color: #999;
35
+ text-align:right;
36
+ }
37
+ .comment-edit{
38
+ text-align:right;
39
+ }
40
+
41
+ }
@@ -0,0 +1,37 @@
1
+
2
+ @mixin radius($rad) {
3
+ -webkit-border-radius: $rad;
4
+ -moz-border-radius: $rad;
5
+ border-radius: $rad;
6
+ }
7
+
8
+ @mixin shadow($param){
9
+ box-shadow: $param;
10
+ -moz-box-shadow: $param;
11
+ -webkit-box-shadow: $param;
12
+ }
13
+
14
+ @mixin text-shadow($param){
15
+ text-shadow: $param;
16
+ -moz-text-shadow: $param;
17
+ -webkit-text-shadow: $param;
18
+ }
19
+
20
+ @mixin diagonal-gradient($from, $to){
21
+ $deg: -45deg;
22
+ background-image: -moz-linear-gradient($deg, $from, $to);
23
+ background-image: -ms-linear-gradient($deg, $from, $to);
24
+ background-image: -webkit-gradient(linear, left top, right bottom, $from, $to);
25
+ background-image: -webkit-linear-gradient($deg, $from, $to);
26
+ background-image: -o-linear-gradient($deg, $from, $to);
27
+ background-image: linear-gradient($deg, $from, $to);
28
+ }
29
+
30
+ @mixin linear-gradient($from, $to){
31
+ background-image: -moz-linear-gradient(top, $from, $to);
32
+ background-image: -ms-linear-gradient(top, $from, $to);
33
+ background-image: -webkit-gradient(linear, left top, left bottom, $from, $to);
34
+ background-image: -webkit-linear-gradient(top, $from, $to);
35
+ background-image: -o-linear-gradient(top, $from, $to);
36
+ background-image: linear-gradient(top, $from, $to);
37
+ }
@@ -0,0 +1,110 @@
1
+ // Place all the styles related to the Suggestions controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
4
+
5
+ @import 'mixins.css.scss';
6
+
7
+ .suggestion{
8
+
9
+ margin-bottom:40px;
10
+
11
+ .vote-box{
12
+ float: left;
13
+ @include radius(0 0 4px 4px);
14
+ @include shadow(0 2px 6px rgba(100,100,100,0.15));
15
+ }
16
+
17
+ .vote-frame, .vote-btn{
18
+ width: 75px;
19
+ }
20
+
21
+ .vote-btn{
22
+ @include radius(0 0 4px 4px);
23
+ display:block;
24
+ padding:5px 0;
25
+ text-align: center;
26
+ line-height: 13px;
27
+ }
28
+ .vote-btn.disabled{
29
+ border:1px solid #ccc;
30
+ opacity:1;
31
+ color:#999;
32
+ }
33
+ .vote-frame{
34
+
35
+ border:1px solid #ccc;
36
+ border-bottom:none;
37
+ @include radius( 4px 4px 0 0);
38
+
39
+ text-align: center;
40
+ padding: 18px 0;
41
+ line-height: 1.15;
42
+
43
+ color: #999;
44
+ background-color: white;
45
+ @include diagonal-gradient(white, #e8e8e8);
46
+
47
+ .vote-number{
48
+ font-size: 23px;
49
+ color: #08C;
50
+ }.long{
51
+ font-size: 18px;
52
+ }
53
+ .user-votes{
54
+ display:table-cell;
55
+
56
+ $rad:26px;
57
+
58
+ min-width:20px;
59
+ height:$rad;
60
+ line-height:$rad;
61
+ margin-bottom:-$rad;
62
+ @include radius($rad/2);
63
+
64
+ font-weight: bold;
65
+ background: orange;
66
+ color: white;
67
+ font-size:12px;
68
+ position:relative;
69
+ float:right;
70
+ left:13px;
71
+ top:-55px;
72
+ padding:0 3px;
73
+ @include text-shadow(0 1px 2px rgba(100,100,100,0.3));
74
+ @include shadow(0 1px 6px rgba(100,100,100,0.3));
75
+ }
76
+ }
77
+
78
+
79
+ .suggestion-info{
80
+ margin-left: 95px;
81
+ .title{
82
+ color:#08C;
83
+ }
84
+ .description{
85
+ margin:15px 0px;
86
+ line-height:1.5;
87
+ }
88
+ .comments{
89
+ color:#999;
90
+ }
91
+ .name-date{
92
+ float:right;
93
+ color:#999;
94
+ }
95
+ }
96
+ }
97
+
98
+ #search-field{
99
+ margin-top:10px;
100
+ input#q{
101
+ width:585px;
102
+ margin:0;
103
+ }
104
+ input.btn{
105
+ width:65px;
106
+ }
107
+ }
108
+
109
+
110
+