help_center 0.0.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 (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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "help_center"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,52 @@
1
+ en:
2
+ start_a_discussion: Start A Discussion
3
+ add: Add
4
+ update: Update
5
+ add_a_comment: Add A Comment
6
+ add_an_article: Add Article
7
+ ask_a_question: Ask A Question
8
+ asked_time_ago: "Asked %{time} ago by %{author}"
9
+ choose_a_category: Choose a Category
10
+ comment: Comment
11
+ commented_on: Commented on
12
+ documentation: Documentation
13
+ edit_this_post: Edit this post
14
+ edit_this_thread: Edit this thread
15
+ edit_thread: Edit thread
16
+ filters: Filters
17
+ how_do_i: How do I...?
18
+ ignoring_thread: You're ignoring this thread.
19
+ not_receiving_notifications: You’re not receiving notifications from this thread.
20
+ layouts:
21
+ simple_discussion:
22
+ all_threads: All Threads
23
+ answered: Answered
24
+ by_category: By Category
25
+ my_questions: My Questions
26
+ notifications: Notifications
27
+ participating: Participating
28
+ suscribe: Subscribe
29
+ unsubscribe: Unsubscribe
30
+ unanswered: Unanswered
31
+ pick_a_category: Pick a category...
32
+ post:
33
+ one: post
34
+ other: posts
35
+ receiving_notifications_because_subscribed: You're receiving notifications because you've subscribed to this thread.
36
+ receiving_notifications_because_posted: You're receiving notifications because you've posted in this thread.
37
+ saving_comment: Saving comment...
38
+ saving: Saving
39
+ this_solved_my_question: This solved my question
40
+ title: title
41
+ content: content
42
+ position: position
43
+ what_help_needed: What do you need help with?
44
+ ask_your_question: Ask Your Question
45
+ update_comment: Update comment
46
+ your_changes_were_saved: Your changes were saved
47
+ search_not_found: No results found for your search
48
+ check_out: Check out
49
+ latest_questions: the latest questions
50
+ instead: instead?
51
+ written_by_author: "Written by %{author}"
52
+ content_updated_at: "Updated %{update_time} ago"
@@ -0,0 +1,24 @@
1
+ HelpCenter::Engine.routes.draw do
2
+ scope module: :help_center do
3
+ resources :support_threads, path: :threads do
4
+ collection do
5
+ get :answered
6
+ get :unanswered
7
+ get :mine
8
+ get :participating
9
+ get "category/:id", to: "support_categories#index", as: :support_category
10
+ end
11
+
12
+ resources :support_posts, path: :posts do
13
+ member do
14
+ put :solved
15
+ put :unsolved
16
+ end
17
+ end
18
+
19
+ resource :notifications
20
+ end
21
+ end
22
+
23
+ root to: "help_center/support_threads#index"
24
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSupportCategories < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :support_categories do |t|
4
+ t.string :name, null: false
5
+ t.string :slug, null: false
6
+ t.string :color, default: "000000"
7
+ t.integer :position, default: 0
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ SupportCategory.reset_column_information
13
+
14
+ SupportCategory.create(
15
+ name: "Getting Started",
16
+ color: "#4ea1d3",
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ class CreateSupportThreads < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :support_threads do |t|
4
+ t.references :support_category, foreign_key: true
5
+ t.references :user, foreign_key: true
6
+ t.string :title, null: false
7
+ t.string :slug, null: false
8
+ t.integer :support_posts_count, default: 0
9
+ t.integer :like_count, default: 0
10
+ t.integer :dislike_count, default: 0
11
+ t.boolean :pinned, default: false
12
+ t.boolean :solved, default: false
13
+ t.integer :position, default: 0
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ class CreateSupportPosts < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :support_posts do |t|
4
+ t.references :support_thread, foreign_key: true
5
+ t.references :user, foreign_key: true
6
+ t.text :body
7
+ t.boolean :solved, default: false
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ class CreateSupportSubscriptions < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :support_subscriptions do |t|
4
+ t.references :support_thread, foreign_key: true
5
+ t.references :user, foreign_key: true
6
+ t.string :subscription_type
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "help_center/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "help_center"
8
+ spec.version = HelpCenter::VERSION
9
+ spec.authors = ["Ugurcan Kaya"]
10
+ spec.email = ["support@pasilobus.com"]
11
+
12
+ spec.summary = %q{A simple Rails wiki gem with Trix editor}
13
+ spec.description = %q{A simple Rails wiki gem with Trix editor}
14
+ spec.homepage = "https://github.com/uurcank/help_center"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency 'font-awesome-sass', '~> 5.13.0'
25
+ spec.add_dependency 'friendly_id', '>= 5.2.0'
26
+ spec.add_dependency 'gravatar_image_tag'
27
+ spec.add_dependency 'rails', '>= 6.0.0'
28
+ spec.add_dependency 'will_paginate', '>= 3.1.0'
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module HelpCenter
4
+ module Generators
5
+ class ControllersGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../../..", __FILE__)
7
+
8
+ def copy_controllers
9
+ directory 'app/controllers/help_center', 'app/controllers/help_center'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module HelpCenter
4
+ module Generators
5
+ class HelpersGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../../..", __FILE__)
7
+
8
+ def copy_views
9
+ directory 'app/helpers', 'app/helpers'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module HelpCenter
4
+ module Generators
5
+ class ViewsGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../../..", __FILE__)
7
+
8
+ def copy_views
9
+ directory 'app/views', 'app/views'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ require 'font-awesome-sass'
2
+ require 'friendly_id'
3
+ require 'gravatar_image_tag'
4
+ require 'will_paginate'
5
+
6
+ require 'help_center/engine'
7
+ require 'help_center/support_user'
8
+ require 'help_center/slack'
9
+ require 'help_center/version'
10
+ require 'help_center/will_paginate'
11
+
12
+ module HelpCenter
13
+ # Define who owns the subscription
14
+ mattr_accessor :enable_comments
15
+ mattr_accessor :send_email_notifications
16
+ mattr_accessor :send_slack_notifications
17
+ @@send_email_notifications = false
18
+ @@send_email_notifications = true
19
+ @@send_slack_notifications = true
20
+
21
+ def self.setup
22
+ yield self
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ module HelpCenter
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'help_center'
4
+
5
+ # Grab the Rails default url options and use them for sending emails & notifications
6
+ config.after_initialize do
7
+ HelpCenter::Engine.routes.default_url_options = ActionMailer::Base.default_url_options
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ require 'open-uri'
2
+ require 'net/http'
3
+
4
+ module HelpCenter
5
+ class Slack
6
+ attr_reader :url
7
+
8
+ def initialize(url)
9
+ @url = url
10
+ end
11
+
12
+ def post(payload)
13
+ uri = URI.parse(url)
14
+ request = Net::HTTP::Post.new(uri)
15
+ req_options = { use_ssl: uri.scheme == "https", }
16
+ request.body = "payload=#{payload.to_json}"
17
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
18
+ http.request(request)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ module HelpCenter
2
+ module SupportUser
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :support_threads
7
+ has_many :support_posts
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module HelpCenter
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,53 @@
1
+ require 'will_paginate/view_helpers/action_view'
2
+
3
+ module HelpCenter
4
+ # This code serves two purposes
5
+ # 1. It patches will_paginate to work with scoped and mounted Rails engines
6
+ # by adding in the url_builder option
7
+ # 2. It adds Bootstrap 4 styling to will_paginate
8
+
9
+ class BootstrapLinkRenderer < WillPaginate::ActionView::LinkRenderer
10
+
11
+ # This method adds the `url_builder` option so we can pass in the
12
+ # mounted Rails engine's scope for will_paginate
13
+ def url(page)
14
+ @base_url_params ||= begin
15
+ url_params = merge_get_params(default_url_params)
16
+ merge_optional_params(url_params)
17
+ end
18
+
19
+ url_params = @base_url_params.dup
20
+ add_current_page_param(url_params, page)
21
+
22
+ # Add optional url_builder support
23
+ (@options[:url_builder] || @template).url_for(url_params)
24
+ end
25
+
26
+ protected
27
+ def html_container(html)
28
+ tag :nav, tag(:ul, html, class: ul_class)
29
+ end
30
+
31
+ def page_number(page)
32
+ item_class = if(page == current_page)
33
+ 'active page-item'
34
+ else
35
+ 'page-item'
36
+ end
37
+
38
+ tag :li, link(page, page, :rel => rel_value(page), :class => 'page-link'), :class => item_class
39
+ end
40
+
41
+ def gap
42
+ tag :li, link('&hellip;'.html_safe, '#', :class => 'page-link'), :class => 'page-item disabled'
43
+ end
44
+
45
+ def previous_or_next_page(page, text, classname)
46
+ tag :li, link(text, page || '#', :class => 'page-link'), :class => [(classname[0..3] if @options[:page_links]), (classname if @options[:page_links]), ('disabled' unless page), 'page-item'].join(' ')
47
+ end
48
+
49
+ def ul_class
50
+ ["pagination", container_attributes[:class]].compact.join(" ")
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: help_center
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ugurcan Kaya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: font-awesome-sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.13.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: friendly_id
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 5.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: gravatar_image_tag
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 6.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 6.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: will_paginate
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.1.0
83
+ description: A simple Rails wiki gem with Trix editor
84
+ email:
85
+ - support@pasilobus.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".github/FUNDING.yml"
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - CHANGELOG.md
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - app/assets/stylesheets/help_center.scss
100
+ - app/controllers/help_center/application_controller.rb
101
+ - app/controllers/help_center/notifications_controller.rb
102
+ - app/controllers/help_center/support_categories_controller.rb
103
+ - app/controllers/help_center/support_posts_controller.rb
104
+ - app/controllers/help_center/support_threads_controller.rb
105
+ - app/helpers/help_center/support_posts_helper.rb
106
+ - app/helpers/help_center/support_threads_helper.rb
107
+ - app/jobs/help_center/support_post_notification_job.rb
108
+ - app/jobs/help_center/support_thread_notification_job.rb
109
+ - app/mailers/help_center/user_mailer.rb
110
+ - app/models/support_category.rb
111
+ - app/models/support_post.rb
112
+ - app/models/support_subscription.rb
113
+ - app/models/support_thread.rb
114
+ - app/views/help_center/support_posts/_form.html.erb
115
+ - app/views/help_center/support_posts/_support_post.html.erb
116
+ - app/views/help_center/support_posts/edit.html.erb
117
+ - app/views/help_center/support_threads/_form.html.erb
118
+ - app/views/help_center/support_threads/_support_thread.html.erb
119
+ - app/views/help_center/support_threads/edit.html.erb
120
+ - app/views/help_center/support_threads/index.html.erb
121
+ - app/views/help_center/support_threads/new.html.erb
122
+ - app/views/help_center/support_threads/show.html.erb
123
+ - app/views/help_center/user_mailer/new_post.html.erb
124
+ - app/views/help_center/user_mailer/new_thread.html.erb
125
+ - app/views/layouts/help_center.html.erb
126
+ - app/views/shared/_spacer.html.erb
127
+ - bin/console
128
+ - bin/setup
129
+ - config/locales/en.yml
130
+ - config/routes.rb
131
+ - db/migrate/20170417012930_create_support_categories.rb
132
+ - db/migrate/20170417012931_create_support_threads.rb
133
+ - db/migrate/20170417012932_create_support_posts.rb
134
+ - db/migrate/20170417012933_create_support_subscriptions.rb
135
+ - help_center.gemspec
136
+ - lib/generators/help_center/controllers_generator.rb
137
+ - lib/generators/help_center/helpers_generator.rb
138
+ - lib/generators/help_center/views_generator.rb
139
+ - lib/help_center.rb
140
+ - lib/help_center/engine.rb
141
+ - lib/help_center/slack.rb
142
+ - lib/help_center/support_user.rb
143
+ - lib/help_center/version.rb
144
+ - lib/help_center/will_paginate.rb
145
+ homepage: https://github.com/uurcank/help_center
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubygems_version: 3.1.2
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: A simple Rails wiki gem with Trix editor
168
+ test_files: []