help_center 0.0.4 → 0.0.5

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -12
  3. data/.gitignore +10 -10
  4. data/CHANGELOG.md +1 -1
  5. data/CODE_OF_CONDUCT.md +74 -74
  6. data/Gemfile +6 -6
  7. data/LICENSE.txt +21 -21
  8. data/README.md +164 -155
  9. data/Rakefile +10 -10
  10. data/app/assets/stylesheets/help_center.scss +139 -119
  11. data/app/controllers/help_center/application_controller.rb +37 -37
  12. data/app/controllers/help_center/notifications_controller.rb +19 -19
  13. data/app/controllers/help_center/support_categories_controller.rb +58 -17
  14. data/app/controllers/help_center/support_posts_controller.rb +72 -72
  15. data/app/controllers/help_center/support_threads_controller.rb +16 -6
  16. data/app/helpers/help_center/support_posts_helper.rb +29 -29
  17. data/app/helpers/help_center/support_threads_helper.rb +28 -28
  18. data/app/jobs/help_center/support_post_notification_job.rb +42 -42
  19. data/app/jobs/help_center/support_thread_notification_job.rb +40 -40
  20. data/app/mailers/help_center/user_mailer.rb +28 -28
  21. data/app/models/support_category.rb +13 -13
  22. data/app/models/support_post.rb +15 -15
  23. data/app/models/support_subscription.rb +19 -19
  24. data/app/models/support_thread.rb +85 -85
  25. data/app/views/help_center/support_categories/_form.html.erb +35 -0
  26. data/app/views/help_center/support_categories/_support_thread.html.erb +25 -0
  27. data/app/views/help_center/support_categories/edit.html.erb +7 -0
  28. data/app/views/help_center/support_categories/index.html.erb +19 -0
  29. data/app/views/help_center/support_categories/new.html.erb +5 -0
  30. data/app/views/help_center/support_categories/show.html.erb +20 -0
  31. data/app/views/help_center/support_threads/_form.html.erb +6 -4
  32. data/app/views/help_center/support_threads/edit.html.erb +7 -7
  33. data/app/views/help_center/support_threads/index.html.erb +1 -1
  34. data/app/views/help_center/support_threads/new.html.erb +5 -5
  35. data/app/views/help_center/support_threads/show.html.erb +42 -1
  36. data/app/views/layouts/help_center.html.erb +37 -13
  37. data/app/views/shared/_spacer.html.erb +1 -1
  38. data/bin/console +14 -14
  39. data/bin/setup +8 -8
  40. data/config/locales/en.yml +55 -52
  41. data/config/routes.rb +24 -24
  42. data/db/migrate/20170417012930_create_support_categories.rb +19 -19
  43. data/db/migrate/20170417012931_create_support_threads.rb +18 -18
  44. data/db/migrate/20170417012932_create_support_posts.rb +12 -12
  45. data/db/migrate/20170417012933_create_support_subscriptions.rb +11 -11
  46. data/help_center.gemspec +29 -29
  47. data/lib/generators/help_center/controllers_generator.rb +13 -13
  48. data/lib/generators/help_center/helpers_generator.rb +13 -13
  49. data/lib/generators/help_center/views_generator.rb +13 -13
  50. data/lib/help_center.rb +23 -24
  51. data/lib/help_center/engine.rb +10 -10
  52. data/lib/help_center/slack.rb +22 -22
  53. data/lib/help_center/support_user.rb +10 -10
  54. data/lib/help_center/version.rb +3 -3
  55. metadata +11 -8
  56. data/.travis.yml +0 -5
  57. data/app/views/help_center/support_threads/_article.html.erb +0 -32
  58. data/lib/help_center/will_paginate.rb +0 -53
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -1,119 +1,139 @@
1
- @import "font-awesome-sprockets";
2
- @import "font-awesome";
3
-
4
- /* Allow pagination to be centered */
5
- .support-threads-nav nav {
6
- display: inline-block;
7
- }
8
-
9
- /* Highlight the active navigation item in the sidebar */
10
- .support-thread-filters {
11
- a {
12
- color: #555;
13
- }
14
-
15
- .active {
16
- color: #222;
17
- font-weight: bolder;
18
- }
19
- }
20
-
21
- /* Formatting for the support threads */
22
- .support-thread {
23
- margin-bottom: -20px;
24
-
25
- h4 {
26
- margin-bottom: 4px;
27
-
28
- a {
29
- color: #222;
30
- font-size: 16px;
31
- font-weight: normal;
32
- line-height: 1.1;
33
- }
34
- }
35
- }
36
-
37
- .support-thread-filters a {
38
- color: #555555;
39
- display: block;
40
-
41
- &:hover {
42
- color: #222222;
43
- font-weight: bold;
44
- text-decoration: none
45
- }
46
- }
47
-
48
- .thread-details {
49
- color: #999;
50
- font-size: 12px;
51
- text-transform: uppercase;
52
- display: flex;
53
- flex-direction: column;
54
- }
55
-
56
- .thread-reaction {
57
- background: #eeeeee;
58
- padding: 1rem;
59
- text-align: center;
60
- border-radius: 0.5rem;
61
- margin-top: 2rem;
62
- }
63
-
64
- .thread-reaction-links {
65
- font-size: 2rem;
66
- margin: 0.25rem;
67
- }
68
-
69
- /* Display the support post count above the "posts" text on the index page */
70
- .thread-posts-count {
71
- color: #222;
72
- text-align: center;
73
-
74
- span, small {
75
- display: block;
76
- }
77
-
78
- .count {
79
- font-size: 1.5em;
80
- font-weight: 300;
81
- line-height: 1em;
82
- }
83
-
84
- &:hover {
85
- color: #222;
86
- text-decoration: none;
87
- }
88
- }
89
-
90
- /* Formatting for the support posts themselves */
91
- .support-post {
92
- position: relative;
93
-
94
- /* When the URL anchor matches a post id, highlight that item */
95
- &:target {
96
- background-color: rgb(248, 238, 199);
97
- }
98
-
99
- /* Fill this out if you want to highlight the OPs posts */
100
- &.original-poster {
101
- }
102
-
103
- &.solved {
104
- border: 2px solid #5cb85c;
105
- }
106
- }
107
-
108
- /* Formatting for the support hr to match card border */
109
- .help_center hr {
110
- border: 0;
111
- border-top: 1px solid rgba(0, 0, 0, 0.125);
112
- margin: 24px -20px;
113
- }
114
-
115
- .help_center .text-muted {
116
- color: #999;
117
- margin-top: 6px;
118
- font-size: 13px;
119
- }
1
+ @import "font-awesome-sprockets";
2
+ @import "font-awesome";
3
+
4
+ /* Allow pagination to be centered */
5
+ .help_center .support-threads-nav nav {
6
+ display: inline-block;
7
+ }
8
+
9
+ /* Highlight the active navigation item in the sidebar */
10
+ .help_center .support-thread-filters {
11
+ a {
12
+ color: #555;
13
+ }
14
+
15
+ .active {
16
+ color: #eee;
17
+ font-weight: 500;
18
+ padding: 0.25rem;
19
+ border-radius: 5px;
20
+ }
21
+ }
22
+
23
+ /* Formatting for the support threads */
24
+ .help_center .support-thread {
25
+ margin-bottom: -20px;
26
+
27
+ h4 {
28
+ margin-bottom: 4px;
29
+
30
+ a {
31
+ color: #222;
32
+ font-size: 16px;
33
+ font-weight: normal;
34
+ line-height: 1.1;
35
+ }
36
+ }
37
+ }
38
+
39
+ .help_center .support-thread-filters a {
40
+ color: #555555;
41
+ display: block;
42
+
43
+ &:hover {
44
+ color: #bfbfbf;
45
+ text-decoration: none
46
+ }
47
+ }
48
+
49
+ .help_center .thread-details {
50
+ color: #999;
51
+ font-size: 12px;
52
+ text-transform: uppercase;
53
+ display: flex;
54
+ flex-direction: column;
55
+ }
56
+
57
+ .help_center .thread-reaction {
58
+ background: #eeeeee;
59
+ padding: 1rem;
60
+ text-align: center;
61
+ border-radius: 0.5rem;
62
+ margin-top: 2rem;
63
+ }
64
+
65
+ .help_center .thread-reaction-links {
66
+ font-size: 2rem;
67
+ margin: 0.25rem;
68
+ }
69
+
70
+ /* Display the support post count above the "posts" text on the index page */
71
+ .help_center .thread-posts-count {
72
+ color: #222;
73
+ text-align: center;
74
+
75
+ span, small {
76
+ display: block;
77
+ }
78
+
79
+ .count {
80
+ font-size: 1.5em;
81
+ font-weight: 300;
82
+ line-height: 1em;
83
+ }
84
+
85
+ &:hover {
86
+ color: #222;
87
+ text-decoration: none;
88
+ }
89
+ }
90
+
91
+ /* Formatting for the support posts themselves */
92
+ .help_center .support-post {
93
+ position: relative;
94
+
95
+ /* When the URL anchor matches a post id, highlight that item */
96
+ &:target {
97
+ background-color: rgb(248, 238, 199);
98
+ }
99
+
100
+ /* Fill this out if you want to highlight the OPs posts */
101
+ &.original-poster {
102
+ }
103
+
104
+ &.solved {
105
+ border: 2px solid #5cb85c;
106
+ }
107
+ }
108
+
109
+ /* Formatting for the support hr to match card border */
110
+ .help_center hr {
111
+ border: 0;
112
+ border-top: 1px solid rgba(0, 0, 0, 0.125);
113
+ margin: 24px -20px;
114
+ }
115
+
116
+ // Forms
117
+ .help_center label {
118
+ margin-bottom: 0.5rem;
119
+ }
120
+
121
+ .help_center .form-input, .form-select {
122
+ display: block;
123
+ width: 100%;
124
+ font-size: 0.875rem;
125
+ line-height: 1.25rem;
126
+ }
127
+
128
+ .help_center input[type="color" i] {
129
+ appearance: square-button;
130
+ width: 44px;
131
+ height: 23px;
132
+ background-color: -internal-light-dark(rgb(239, 239, 239), rgb(74, 74, 74));
133
+ cursor: default;
134
+ border-width: 1px;
135
+ border-style: solid;
136
+ border-color: -internal-light-dark(rgb(118, 118, 118), rgb(195, 195, 195));
137
+ border-image: initial;
138
+ padding: 1px 2px;
139
+ }
@@ -1,37 +1,37 @@
1
- class HelpCenter::ApplicationController < ::ApplicationController
2
- layout "help_center"
3
-
4
- def page_number
5
- page = params.fetch(:page, '').gsub(/[^0-9]/, '').to_i
6
- page = "1" if page.zero?
7
- page
8
- end
9
-
10
- def is_moderator_or_owner?(object)
11
- is_moderator? || object.user == current_user
12
- end
13
- helper_method :is_moderator_or_owner?
14
-
15
- def is_moderator?
16
- current_user.respond_to?(:moderator) && current_user.moderator? && current_user.admin?
17
- end
18
- helper_method :is_moderator?
19
-
20
- def require_mod_or_author_for_post!
21
- unless is_moderator_or_owner?(@support_post)
22
- redirect_to_root
23
- end
24
- end
25
-
26
- def require_mod_or_author_for_thread!
27
- unless is_moderator_or_owner?(@support_thread)
28
- redirect_to_root
29
- end
30
- end
31
-
32
- private
33
-
34
- def redirect_to_root
35
- redirect_to help_center.root_path, alert: "You aren't allowed to do that."
36
- end
37
- end
1
+ class HelpCenter::ApplicationController < ::ApplicationController
2
+ layout "help_center"
3
+
4
+ def page_number
5
+ page = params.fetch(:page, '').gsub(/[^0-9]/, '').to_i
6
+ page = "1" if page.zero?
7
+ page
8
+ end
9
+
10
+ def is_moderator_or_owner?(object)
11
+ is_moderator?
12
+ end
13
+ helper_method :is_moderator_or_owner?
14
+
15
+ def is_moderator?
16
+ current_user.respond_to?(:moderator) && current_user.moderator? || current_user.respond_to?(:admin) && current_user.admin?
17
+ end
18
+ helper_method :is_moderator?
19
+
20
+ def require_mod_or_author_for_post!
21
+ unless is_moderator_or_owner?(@support_post)
22
+ redirect_to_root
23
+ end
24
+ end
25
+
26
+ def require_mod_or_author_for_thread!
27
+ unless is_moderator_or_owner?(@support_thread)
28
+ redirect_to_root
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def redirect_to_root
35
+ redirect_to help_center.root_path
36
+ end
37
+ end
@@ -1,19 +1,19 @@
1
- class HelpCenter::NotificationsController < HelpCenter::ApplicationController
2
- before_action :authenticate_user!
3
- before_action :set_support_thread
4
-
5
- def create
6
- @support_thread.toggle_subscription(current_user)
7
- redirect_to help_center.support_thread_path(@support_thread)
8
- end
9
-
10
- def show
11
- redirect_to help_center.support_thread_path(@support_thread)
12
- end
13
-
14
- private
15
-
16
- def set_support_thread
17
- @support_thread = SupportThread.friendly.find(params[:support_thread_id])
18
- end
19
- end
1
+ class HelpCenter::NotificationsController < HelpCenter::ApplicationController
2
+ before_action :authenticate_user!
3
+ before_action :set_support_thread
4
+
5
+ def create
6
+ @support_thread.toggle_subscription(current_user)
7
+ redirect_to help_center.support_thread_path(@support_thread)
8
+ end
9
+
10
+ def show
11
+ redirect_to help_center.support_thread_path(@support_thread)
12
+ end
13
+
14
+ private
15
+
16
+ def set_support_thread
17
+ @support_thread = SupportThread.friendly.find(params[:support_thread_id])
18
+ end
19
+ end
@@ -1,17 +1,58 @@
1
- class HelpCenter::SupportCategoriesController < HelpCenter::ApplicationController
2
- before_action :set_category
3
-
4
- def index
5
- @support_threads = SupportThread.where(support_category: @category) if @category.present?
6
- @support_threads = @support_threads.pinned_first.sorted.includes(:user, :support_category).paginate(per_page: 10, page: page_number)
7
- render "help_center/support_threads/index"
8
- end
9
-
10
- private
11
-
12
- def set_category
13
- @category = SupportCategory.friendly.find(params[:id])
14
- rescue ActiveRecord::RecordNotFound
15
- redirect_to help_center.support_threads_path
16
- end
17
- end
1
+ class HelpCenter::SupportCategoriesController < HelpCenter::ApplicationController
2
+ before_action :authenticate_user!, only: [:edit, :update, :destroy]
3
+ before_action :set_category, only: [:index, :show, :edit, :update, :destroy]
4
+ before_action :require_mod_or_author_for_thread!, only: [:edit, :update, :destroy]
5
+
6
+
7
+ def index
8
+ @support_threads = SupportThread.where(support_category: @category) if @category.present?
9
+ @support_threads = @support_threads.pinned_first.sorted.includes(:user, :support_category)
10
+ @pagy, @records = pagy(@support_threads)
11
+ render "help_center/support_threads/index"
12
+ end
13
+
14
+ def new
15
+ @category = SupportCategory.new
16
+ end
17
+
18
+ def show
19
+ end
20
+
21
+ def create
22
+ @category = SupportCategory.new(support_category_params)
23
+
24
+ if @category.save
25
+ redirect_to help_center.support_threads_path
26
+ else
27
+ render action: :new
28
+ end
29
+ end
30
+
31
+ def edit
32
+ end
33
+
34
+ def update
35
+ if @category.update(support_category_params)
36
+ redirect_to help_center.support_category_path(@category), notice: I18n.t('your_changes_were_saved')
37
+ else
38
+ render action: :edit
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ @category.destroy
44
+ redirect_to help_center.support_threads_path, notice: I18n.t('successfully_deleted')
45
+ end
46
+
47
+ private
48
+
49
+ def set_category
50
+ @category = SupportCategory.friendly.find(params[:id])
51
+ rescue ActiveRecord::RecordNotFound
52
+ redirect_to help_center.support_threads_path
53
+ end
54
+
55
+ def support_category_params
56
+ params.require(:support_category).permit(:name, :color, :position)
57
+ end
58
+ end