help_center 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.github/FUNDING.yml +12 -0
  3. data/.gitignore +10 -0
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +1 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +153 -0
  10. data/Rakefile +10 -0
  11. data/app/assets/stylesheets/help_center.scss +119 -0
  12. data/app/controllers/help_center/application_controller.rb +37 -0
  13. data/app/controllers/help_center/notifications_controller.rb +19 -0
  14. data/app/controllers/help_center/support_categories_controller.rb +17 -0
  15. data/app/controllers/help_center/support_posts_controller.rb +72 -0
  16. data/app/controllers/help_center/support_threads_controller.rb +72 -0
  17. data/app/helpers/help_center/support_posts_helper.rb +29 -0
  18. data/app/helpers/help_center/support_threads_helper.rb +28 -0
  19. data/app/jobs/help_center/support_post_notification_job.rb +42 -0
  20. data/app/jobs/help_center/support_thread_notification_job.rb +40 -0
  21. data/app/mailers/help_center/user_mailer.rb +28 -0
  22. data/app/models/support_category.rb +13 -0
  23. data/app/models/support_post.rb +15 -0
  24. data/app/models/support_subscription.rb +19 -0
  25. data/app/models/support_thread.rb +85 -0
  26. data/app/views/help_center/support_posts/_form.html.erb +32 -0
  27. data/app/views/help_center/support_posts/_support_post.html.erb +65 -0
  28. data/app/views/help_center/support_posts/edit.html.erb +28 -0
  29. data/app/views/help_center/support_threads/_form.html.erb +56 -0
  30. data/app/views/help_center/support_threads/_support_thread.html.erb +30 -0
  31. data/app/views/help_center/support_threads/edit.html.erb +7 -0
  32. data/app/views/help_center/support_threads/index.html.erb +23 -0
  33. data/app/views/help_center/support_threads/new.html.erb +5 -0
  34. data/app/views/help_center/support_threads/show.html.erb +39 -0
  35. data/app/views/help_center/user_mailer/new_post.html.erb +12 -0
  36. data/app/views/help_center/user_mailer/new_thread.html.erb +12 -0
  37. data/app/views/layouts/help_center.html.erb +120 -0
  38. data/app/views/shared/_spacer.html.erb +1 -0
  39. data/bin/console +14 -0
  40. data/bin/setup +8 -0
  41. data/config/locales/en.yml +52 -0
  42. data/config/routes.rb +24 -0
  43. data/db/migrate/20170417012930_create_support_categories.rb +19 -0
  44. data/db/migrate/20170417012931_create_support_threads.rb +18 -0
  45. data/db/migrate/20170417012932_create_support_posts.rb +12 -0
  46. data/db/migrate/20170417012933_create_support_subscriptions.rb +11 -0
  47. data/help_center.gemspec +29 -0
  48. data/lib/generators/help_center/controllers_generator.rb +13 -0
  49. data/lib/generators/help_center/helpers_generator.rb +13 -0
  50. data/lib/generators/help_center/views_generator.rb +13 -0
  51. data/lib/help_center.rb +24 -0
  52. data/lib/help_center/engine.rb +10 -0
  53. data/lib/help_center/slack.rb +22 -0
  54. data/lib/help_center/support_user.rb +10 -0
  55. data/lib/help_center/version.rb +3 -0
  56. data/lib/help_center/will_paginate.rb +53 -0
  57. metadata +168 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2c7daa878339028e7a0e6bb67b3fd203f37c1f4a59070b27d8b1ea3439a902c9
4
+ data.tar.gz: 5fc519dcf8bce60e626cefbbb1e9ccf65ea0375f64462772a7f89d7a347ba557
5
+ SHA512:
6
+ metadata.gz: 6ba59c2c645c8687617f72e8e5eb7d5a874d31c824effdc7242d3d8ac1cd0dfeb98f0892a519354c3435ad4437dccbfdfb6645aa8316e947b20c4bb9af5c0366
7
+ data.tar.gz: 3d991eec4b3b26bf78f937c879cda2040ab875f8a4a5a86d492ae276ef024139d7bab184c66a7efdea87b52a4bf90794e5a3595a6769d6ea1c43d038d8b6e6cc
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [uurcankaya, pasilobus] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.3
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at excid3@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in simple_discussion.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Ugurcan Kaya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,153 @@
1
+ # HelpCenter
2
+
3
+ HelpCenter is a Rails wiki gem with Trix editor support for organizing app documentation and tutorials. It includes support categories, support articles, simple moderation, the ability to leave comments to support articles and more.
4
+
5
+ Out of the box, HelpCenter comes with styling for Boostrap v4 but you're free to customize the UI as much as you like by installing the views and tweaking the HTML.
6
+
7
+ ## Requirements
8
+
9
+ Rails >= 6.0.0
10
+ bootstrap >= 4.0.0
11
+
12
+ ## Installation
13
+
14
+ Before you get started, HelpCenter requires a `User` model in your application (for now).
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'help_center'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ ```bash
25
+ bundle
26
+ ```
27
+
28
+ Install the migrations and migrate:
29
+
30
+ ```bash
31
+ rails help_center:install:migrations
32
+ rails db:migrate
33
+ ```
34
+
35
+ Add HelpCenter to your `User` model. The model **must** have `name` method which will be used to display the user's name on comments & discussions (if enabled). Currently only a model named `User` will work.
36
+
37
+ ```ruby
38
+ class User < ActiveRecord::Base
39
+ include HelpCenter::SupportUser
40
+
41
+ def name
42
+ "#{first_name} #{last_name}"
43
+ end
44
+ end
45
+ ```
46
+
47
+ Next add a `moderator` or `admin` flag to the `User` model.
48
+
49
+ ```bash
50
+ rails g migration AddModeratorToUsers moderator:boolean
51
+ rails db:migrate
52
+ ```
53
+ Only moderators or admins can add support articles.
54
+
55
+ ```
56
+ if current_user.admin? || current_user.moderator?
57
+ ```
58
+
59
+ Add the following line to your `config/routes.rb` file:
60
+
61
+ ```ruby
62
+ mount HelpCenter::Engine => "/support"
63
+ ```
64
+
65
+ Lastly, add the CSS to your `application.css` to load some default styles.
66
+
67
+ ```scss
68
+ *= require help_center
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ To get all the basic functionality, the only thing you need to do is add a link to HelpCenter in your navbar.
74
+
75
+ ```erb
76
+ <%= link_to "Docs", help_center_path %>
77
+ ```
78
+
79
+ This will take the user to the views inside the Rails engine and that's all you have to do!
80
+
81
+ ### Customizing
82
+
83
+ If you'd like to customize the views that HelpCenter uses, you can install the views to your Rails app:
84
+
85
+ ```bash
86
+ rails g help_center:views
87
+ ```
88
+
89
+ You can also install a copy of the HelpCenter controllers for advanced customization:
90
+
91
+ ```bash
92
+ rails g help_center:controllers
93
+ ```
94
+
95
+ Helpers are available for override as well. They are used for rendering the user avatars, text formatting, and more.
96
+
97
+ ```bash
98
+ rails g help_center:helpers
99
+ ```
100
+
101
+ **NOTE:** Keep in mind that the more customization you do, the tougher gem upgrades will be in the future.
102
+
103
+ ### User comments & Notifications
104
+
105
+ You can enable user comments and questions for support articles. HelpCenter will attempt to send email and slack notifications for users who leave comments when a new reply posted.
106
+
107
+ To turn these off you can do the following in `config/initializers/help_center.rb`
108
+
109
+ ```ruby
110
+ HelpCenter.setup do |config|
111
+ config.article_dicussions = false # Default: false
112
+ config.send_email_notifications = false # Default: true
113
+ config.send_slack_notifications = false # Default: true
114
+ end
115
+ ```
116
+
117
+ Slack notifications require you to set `help_center_slack_url` in your `config/secrets.yml`. If you don't have this value set, it will not attempt Slack notifications even if they are enabled.
118
+
119
+
120
+ ## Development
121
+
122
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
123
+
124
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
125
+
126
+ ## Roadmap / Upcoming features
127
+ Your support is appreciated for this project. Consider backing the project via GitHub Sponsors.
128
+
129
+ We plan to release following features:
130
+
131
+ - Contact form
132
+ - Ticket submission
133
+ - Live chat
134
+ - Help Center Layout templates
135
+ - Built-in search
136
+
137
+ ## Acknowledgment
138
+
139
+ HelpCenter generated from the awesome [simple_discussion](https://github.com/excid3/simple_discussion) gem by [Chris Oliver](https://github.com/excid3)
140
+
141
+ HelpCenter uses [Trix editor](https://github.com/basecamp/trix) by [Basecamp](https://github.com/basecamp)
142
+
143
+ ## Contributing
144
+
145
+ Bug reports and pull requests are welcome on GitHub at https://github.com/uurcank/help_center This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
146
+
147
+ ## License
148
+
149
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
150
+
151
+ ## Code of Conduct
152
+
153
+ Everyone interacting in the HelpCenter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pasilobus/help_center/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +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
@@ -0,0 +1,119 @@
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
+ }
@@ -0,0 +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?
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