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,32 @@
1
+ <%= form_for [@support_thread, @support_post],
2
+ url: (@support_post.persisted? ? help_center.support_thread_support_post_path(@support_thread, @support_post) : help_center.support_thread_support_posts_path(@support_thread)),
3
+ html: { data: { behavior: "comment-form" } } do |f| %>
4
+
5
+ <% if @support_post.errors.any? %>
6
+ <div id="error_explanation">
7
+ <h2><%= pluralize(@support_post.errors.count, "error") %> prohibited this support_post from being saved:</h2>
8
+
9
+ <ul>
10
+ <% @support_post.errors.full_messages.each do |message| %>
11
+ <li><%= message %></li>
12
+ <% end %>
13
+ </ul>
14
+ </div>
15
+ <% end %>
16
+
17
+ <div class="form-group">
18
+ <%= f.text_area :body, placeholder: t('add_a_comment'), rows: 8, class: "form-control simplemde", data: { behavior: "comment-body" } %>
19
+ </div>
20
+
21
+ <div class="text-right">
22
+ <div class="pull-left">
23
+ <small>
24
+ <%# Describe text formatting options here with a link %>
25
+ <%#= link_to "Parsed with Markdown", "https://guides.github.com/features/mastering-markdown/", target: "_blank" %>
26
+ </small>
27
+ </div>
28
+
29
+ <%= f.button "#{f.object.new_record? ? t('comment') : t('update_comment') }", class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> #{t('saving_comment')}"} %>
30
+ </div>
31
+
32
+ <% end %>
@@ -0,0 +1,65 @@
1
+ <%# We don't currently cache the support posts because they have permissions to deal with %>
2
+
3
+ <%= content_tag :div, id: dom_id(support_post), class: support_post_classes(support_post) do %>
4
+ <div class="card-header">
5
+
6
+ <% if is_moderator_or_owner?(support_post) %>
7
+ <div class="float-right">
8
+ <%= link_to icon("fas","edit"), simple_discussion.edit_support_thread_support_post_path(@support_thread, support_post),
9
+ class: "text-muted",
10
+ data: { toggle: "tooltip", placement: "left" },
11
+ title: t('edit_this_post')
12
+ %>
13
+ &nbsp;
14
+ <%= link_to icon("fas","trash"), simple_discussion.support_thread_support_post_path(@support_thread, support_post),
15
+ class: "text-muted",
16
+ method: :delete,
17
+ data: { toggle: "tooltip", placement: "left", confirm: "Are you sure you want to delete this post?" },
18
+ title: t('edit_this_post')
19
+ %>
20
+ </div>
21
+ <% end %>
22
+
23
+ <div>
24
+ <%= avatar_tag(support_post.user.email) %>
25
+
26
+ <strong class="support-post-user">
27
+ <%= support_post.user.name %> <%= support_user_badge(support_post.user) %>
28
+ </strong>
29
+ <small>
30
+ <%= t('commented_on') %>
31
+ <%= link_to support_post.created_at.strftime("%b %d, %Y"), simple_discussion.support_thread_path(@support_thread, anchor: "support_post_#{support_post.id}") %>:
32
+ </small>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="card-body">
37
+ <%= formatted_content support_post.body %>
38
+ </div>
39
+
40
+ <% if @support_thread.solved? && support_post.solved? %>
41
+ <div class="card-footer">
42
+ <div class="pull-right">
43
+ <strong class="text-success"><%= icon("fas","check") %> <%= t('solved') %></strong>
44
+
45
+ <% if is_moderator_or_owner?(@support_thread) %>
46
+ <small>
47
+ <%= link_to t('undo'), simple_discussion.unsolved_support_thread_support_post_path(@support_thread, support_post), method: :put %>
48
+ </small>
49
+ <% end %>
50
+ </div>
51
+ </div>
52
+
53
+ <% elsif is_moderator_or_owner?(@support_thread) %>
54
+ <div class="card-footer">
55
+ <div class="pull-right">
56
+ <small>
57
+ <%= link_to simple_discussion.solved_support_thread_support_post_path(@support_thread, support_post), method: :put do %>
58
+ <%= icon("fas","fas","check") %>
59
+ <%= t('this_solved_my_question') %>
60
+ <% end %>
61
+ </small>
62
+ </div>
63
+ </div>
64
+ <% end %>
65
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <p><small><%= link_to "← Back to the thread", help_center.support_thread_path(@support_thread) %></small></p>
2
+
3
+ <h2><%= content_tag :span, "Pinned", class: "text-muted" if @support_thread.pinned? %> <%= @support_thread.title %></h2>
4
+
5
+ <p class="thread-details">
6
+ <strong><%= category_link(@support_thread.support_category) %></strong>
7
+ • <%= t('asked_time_ago', time: time_ago_in_words(@support_thread.created_at), author: @support_thread.user.name) %>
8
+ </p>
9
+ </p>
10
+
11
+ <br />
12
+
13
+ <%= content_tag :div, id: dom_id(@support_post), class: support_post_classes(@support_post) do %>
14
+ <div class="card-header">
15
+ <div>
16
+ <%= avatar_tag(@support_post.user.email) %>
17
+ <strong class="support-post-user"><%= @support_post.user.name %></strong>
18
+ <small>
19
+ <%= t('commented_on')%>
20
+ <%= link_to @support_post.created_at.strftime("%b %d, %Y"), simple_discussion.support_thread_url(@support_thread, anchor: "support_post_#{@support_post.id}") %>:
21
+ </small>
22
+ </div>
23
+ </div>
24
+
25
+ <div class="card-body">
26
+ <%= render "form" %>
27
+ </div>
28
+ <% end %>
@@ -0,0 +1,56 @@
1
+ <%= form_for @support_thread,
2
+ url: (@support_thread.persisted? ? help_center.support_thread_path(@support_thread) : help_center.support_threads_path),
3
+ html: { data: {behavior: "comment-form"} } do |f| %>
4
+
5
+ <% if @support_thread.errors.any? %>
6
+ <div id="error_explanation">
7
+ <h2><%= pluralize(@support_thread.errors.count, "error") %> prohibited this support_thread from being saved:</h2>
8
+
9
+ <ul>
10
+ <% @support_thread.errors.full_messages.each do |message| %>
11
+ <li><%= message %></li>
12
+ <% end %>
13
+ </ul>
14
+ </div>
15
+ <% end %>
16
+
17
+ <div class="form-group">
18
+ <%= f.label :support_category_id, t('choose_a_category') %>
19
+ <%= f.collection_select :support_category_id, SupportCategory.sorted, :id, :name, {include_blank: t('pick_a_category')}, {autofocus: true, class: "form-control"} %>
20
+ </div>
21
+
22
+ <div class="form-group">
23
+ <%= f.label t('title') %>
24
+ <%= f.text_field :title, placeholder: t('how_do_i'), class: "form-control" %>
25
+ </div>
26
+
27
+ <div class="form-group">
28
+ <%= f.label t('position') %>
29
+ <%= f.text_field :position, class: "form-control" %>
30
+ </div>
31
+
32
+ <div class="form-group">
33
+ <%= f.label t('content') %>
34
+ <%= f.rich_text_area :content %>
35
+ </div>
36
+
37
+ <% if local_assigns.fetch(:posts, true) %>
38
+ <% if !f.object.new_record? %>
39
+ <%= f.fields_for :support_posts do |p| %>
40
+ <div class="form-group">
41
+ <%= p.label :body, t('what_help_needed') %>
42
+ <%= p.text_area :body, placeholder: t('add_a_comment'), rows: 10, class: "form-control simplemde", data: { behavior: "comment-body" } %>
43
+ </div>
44
+ <% end %>
45
+ <% end %>
46
+ <% end %>
47
+
48
+ <div class="form-group text-right">
49
+ <% if f.object.new_record? %>
50
+ <%= f.button t('add'), class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> #{t('saving')}"} %>
51
+ <% else %>
52
+ <%= f.button t('update'), class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> #{t('saving')}"} %>
53
+ <% end %>
54
+ </div>
55
+
56
+ <% end %>
@@ -0,0 +1,30 @@
1
+ <%= cache support_thread do %>
2
+ <div class="support-thread">
3
+ <div class="row">
4
+
5
+ <div class="col">
6
+ <%= link_to help_center.support_thread_path(support_thread) do %>
7
+ <h4>
8
+ <%= support_thread.title %>
9
+ </h4>
10
+
11
+ <p class="text-muted"><%= truncate(support_thread.content.to_plain_text, length: 200) %></p>
12
+
13
+ <div class="thread-details">
14
+ <%= t('content_updated_at', update_time: time_ago_in_words(support_thread.created_at)) %>
15
+ </div>
16
+ <% end %>
17
+ </div>
18
+
19
+ <% if HelpCenter.enable_comments %>
20
+ <div class="col-sm-1 text-center">
21
+ <%= link_to help_center.support_thread_path(support_thread), class: "thread-posts-count" do %>
22
+ <span class="count"><%= support_thread.support_posts_count %></span>
23
+ <small><%= t("post", count: support_thread.support_posts_count) %></small>
24
+ <% end %>
25
+ </div>
26
+ <% end %>
27
+
28
+ </div>
29
+ </div>
30
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= content_for :title, "Edit Thread" %>
2
+
3
+ <h1><%= t('edit_thread') %></h1>
4
+
5
+ <div class="support_post">
6
+ <%= render 'form', posts: false %>
7
+ </div>
@@ -0,0 +1,23 @@
1
+ <% if @support_threads.none? %>
2
+
3
+ <div><%= t('search_not_found') %>. <%= t('check_out') %> <%= link_to t('latest_questions'), help_center.support_threads_path %> <%= t('instead') %> </div>
4
+
5
+ <% else %>
6
+ <div class="container">
7
+ <% if request.url.include?('category') %>
8
+ <%# If category, list all articles %>
9
+ <div class="col-12 text-left p-0">
10
+ <h3> <%= @support_threads.first.support_category.name %></h3>
11
+ </div>
12
+ <%= render partial: "help_center/support_threads/support_thread", collection: @support_threads, spacer_template: "shared/spacer" %>
13
+
14
+ <div class="support-threads-nav text-center">
15
+ <%= will_paginate @support_threads, url_builder: help_center, renderer: HelpCenter::BootstrapLinkRenderer %>
16
+ </div>
17
+
18
+ <% else %>
19
+ <%# Set default index here %>
20
+
21
+ <% end %>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1><%= t('add_an_article') %></h1>
2
+
3
+ <div class="support_post">
4
+ <%= render 'form' %>
5
+ </div>
@@ -0,0 +1,39 @@
1
+ <div class="container">
2
+ <div class="row">
3
+ <div class="col-md-11">
4
+ <small class="mb-2"><%= support_category_link(@support_thread.support_category) %> > <%= @support_thread.title %></small>
5
+ <h1><%= icon "fas", "thumb-tack", class: "text-muted" if @support_thread.pinned? %> <%= @support_thread.title %></h1>
6
+ </div>
7
+
8
+ <% if is_moderator_or_owner?(@support_thread) %>
9
+ <div class="col-md-1">
10
+ <%= link_to icon("fas","pencil"), help_center.edit_support_thread_path(@support_thread),
11
+ class: "text-muted",
12
+ data: { toggle: "tooltip", placement: "left" },
13
+ title: t('edit_this_thread') %>
14
+ </div>
15
+ <% end %>
16
+
17
+ </div>
18
+
19
+ <p class="thread-details d-flex">
20
+ <%= t('written_by_author', author: @support_thread.user.name) %>
21
+ <small><%= t('content_updated_at', update_time: time_ago_in_words(@support_thread.updated_at)) %></small>
22
+ </p>
23
+
24
+ <%= @support_thread.content %>
25
+
26
+ <div class="thread-reaction">
27
+ <p>Did this answer your question?</p>
28
+ <p class="thread-reaction-links">
29
+ <a>😞<a>
30
+ <a>😃<a>
31
+ </p>
32
+ <div>
33
+
34
+ <% if HelpCenter.enable_comments %>
35
+ <hr>
36
+ <%= render partial: "help_center/support_posts/support_post", collection: @support_thread.support_posts.includes(:user).sorted %>
37
+ <%= render partial: "help_center/support_posts/form" if user_signed_in? %>
38
+ <% end %>
39
+ </div>
@@ -0,0 +1,12 @@
1
+ <div style="position: relative">
2
+ <%= gravatar_image_tag @support_post.user.email, style: "float: left" %>
3
+
4
+ <div style="margin-left:60px">
5
+ <p><strong><%= @support_post.user.name %></strong> <small>commented:</small></p>
6
+ <%= formatted_content @support_post.body %>
7
+ </div>
8
+ </div>
9
+
10
+ <br />
11
+
12
+ <p><%= link_to "Reply to this comment", support_thread_url(@support_post.support_thread, anchor: "support_post_#{@support_post.id}"), style: "background:#be2126; color:#fff; text-decoration:none; padding: 10px 20px" %></p>
@@ -0,0 +1,12 @@
1
+ <div style="position: relative">
2
+ <%= gravatar_image_tag @support_post.user.email, style: "float: left" %>
3
+
4
+ <div style="margin-left:60px">
5
+ <p><strong><%= @support_post.user.name %></strong> <small>commented:</small></p>
6
+ <%= formatted_content @support_post.body %>
7
+ </div>
8
+ </div>
9
+
10
+ <br />
11
+
12
+ <p><%= link_to "Reply to this comment", support_thread_url(@support_post.support_thread, anchor: "support_post_#{@support_post.id}"), style: "background:#be2126; color:#fff; text-decoration:none; padding: 10px 20px" %></p>
@@ -0,0 +1,120 @@
1
+ <% @layout = 'website' %>
2
+
3
+ <div class="container mt-6">
4
+ <!-- Title
5
+ <div class="row col-md-12">
6
+ <h1>
7
+ <%= t('documentation') %>
8
+ </h1>
9
+ </div>
10
+ -->
11
+
12
+ <div class="row help_center">
13
+ <div class="col-md-3 mb-3">
14
+
15
+ <div class="card card-body">
16
+ <% if current_user && (current_user.admin? || current_user.moderator?) %>
17
+ <%= link_to t('add_an_article'), help_center.new_support_thread_path, class: "btn btn-outline-primary btn-block" %>
18
+ <hr />
19
+ <% end %>
20
+
21
+ <div class="support-thread-filters">
22
+ <% SupportCategory.sorted.each do |category| %>
23
+ <div>
24
+ <%= support_link_to help_center.support_category_support_threads_path(category) do %>
25
+ <%= category.name %>
26
+ <% end %>
27
+ <% if @category.present? && @category == category %>
28
+ <div class="pl-2">
29
+ <% @support_threads.each do |thread| %>
30
+ <%= support_link_to help_center.support_thread_path(thread) do %>
31
+ <%= thread.title %>
32
+ <% end %>
33
+ <% end %>
34
+ </div>
35
+ <% end %>
36
+ </div>
37
+ <% end %>
38
+ </div>
39
+
40
+
41
+
42
+ <% if HelpCenter.enable_comments %>
43
+ <hr />
44
+
45
+
46
+
47
+ <div class="support-thread-filters">
48
+ <h5>
49
+ <strong>
50
+ <%= t('filters') %>
51
+ </strong>
52
+ </h5>
53
+ <div>
54
+ <%= support_link_to help_center.support_threads_path, exact: true do %>
55
+ <%= icon "fa-fw fas", "bars" %>
56
+ <%= t('.all_threads') %>
57
+ <% end %>
58
+ </div>
59
+ <% if user_signed_in? %>
60
+ <div>
61
+ <%= support_link_to help_center.mine_support_threads_path do %><%= icon "fa-fw far", "user-circle" %>
62
+ <%= t('.my_questions') %>
63
+ <% end %>
64
+ </div>
65
+ <div>
66
+ <%= support_link_to help_center.participating_support_threads_path do %>
67
+ <%= icon "fa-fw far", "comments" %>
68
+ <%= t('.participating') %>
69
+ <% end %>
70
+ </div>
71
+ <% end %>
72
+ <div>
73
+ <%= support_link_to help_center.answered_support_threads_path do %>
74
+ <%= icon "fa-fw fas", "check" %>
75
+ <%= t('.answered') %>
76
+ <% end %>
77
+ </div>
78
+ <div>
79
+ <%= support_link_to help_center.unanswered_support_threads_path do %>
80
+ <%= icon "fa-fw fas", "question" %>
81
+ <%= t('.unanswered') %>
82
+ <% end %>
83
+ </div>
84
+ </div>
85
+
86
+
87
+
88
+ <% if @support_thread.present? && @support_thread.persisted? %>
89
+ <hr />
90
+
91
+ <%# User has not posted in the thread or subscribed %>
92
+ <h5><%= t('.notifications') %></h5>
93
+
94
+ <%= link_to help_center.support_thread_notifications_path(@support_thread), method: :post, class: "btn btn-secondary btn-sm btn-block mb-2" do %>
95
+ <% if @support_thread.subscribed? current_user %>
96
+ <%= icon "fa-fw fas", "bell-slash" %> <%= t('.unsubscribe') %>
97
+ <% else %>
98
+ <%= icon "fa-fw fas", "bell" %>
99
+ <%= t('.suscribe') %>
100
+ <% end %>
101
+ <% end %>
102
+
103
+ <small><%= @support_thread.subscribed_reason(current_user) %></small>
104
+ <% end %>
105
+ <% end %>
106
+ </div>
107
+
108
+ </div>
109
+
110
+ <div class="col-md-9 mb-3">
111
+
112
+ <div class="card card-body">
113
+ <%= yield %>
114
+ </div>
115
+
116
+ </div>
117
+ </div>
118
+ </div>
119
+
120
+ <% parent_layout("application") %>
@@ -0,0 +1 @@
1
+ <hr/>