simple_discussion 0.9.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +12 -0
  3. data/README.md +16 -1
  4. data/app/assets/stylesheets/simple_discussion.scss +40 -2
  5. data/app/controllers/simple_discussion/application_controller.rb +14 -2
  6. data/app/controllers/simple_discussion/forum_posts_controller.rb +4 -3
  7. data/app/controllers/simple_discussion/forum_threads_controller.rb +3 -3
  8. data/app/jobs/simple_discussion/forum_post_notification_job.rb +42 -0
  9. data/app/jobs/simple_discussion/forum_thread_notification_job.rb +40 -0
  10. data/app/mailers/simple_discussion/user_mailer.rb +28 -0
  11. data/app/models/forum_thread.rb +13 -5
  12. data/app/views/layouts/simple_discussion.html.erb +59 -16
  13. data/app/views/simple_discussion/forum_posts/_form.html.erb +2 -2
  14. data/app/views/simple_discussion/forum_posts/_forum_post.html.erb +7 -7
  15. data/app/views/simple_discussion/forum_posts/edit.html.erb +7 -3
  16. data/app/views/simple_discussion/forum_threads/_form.html.erb +8 -8
  17. data/app/views/simple_discussion/forum_threads/_forum_thread.html.erb +3 -3
  18. data/app/views/simple_discussion/forum_threads/edit.html.erb +1 -1
  19. data/app/views/simple_discussion/forum_threads/index.html.erb +11 -9
  20. data/app/views/simple_discussion/forum_threads/new.html.erb +1 -1
  21. data/app/views/simple_discussion/forum_threads/show.html.erb +15 -10
  22. data/app/views/simple_discussion/user_mailer/new_post.html.erb +12 -0
  23. data/app/views/simple_discussion/user_mailer/new_thread.html.erb +12 -0
  24. data/config/locales/en.yml +45 -0
  25. data/config/locales/es.yml +41 -0
  26. data/config/locales/fr.yml +47 -0
  27. data/db/migrate/20170417012930_create_forum_categories.rb +1 -1
  28. data/db/migrate/20170417012931_create_forum_threads.rb +1 -1
  29. data/db/migrate/20170417012932_create_forum_posts.rb +1 -1
  30. data/db/migrate/20170417012933_create_forum_subscriptions.rb +1 -1
  31. data/lib/simple_discussion.rb +13 -53
  32. data/lib/simple_discussion/engine.rb +5 -0
  33. data/lib/simple_discussion/slack.rb +22 -0
  34. data/lib/simple_discussion/version.rb +1 -1
  35. data/lib/simple_discussion/will_paginate.rb +53 -0
  36. data/simple_discussion.gemspec +1 -1
  37. metadata +19 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 584ec2c3ab8802d72c6f363f9b10ea08065caa9f
4
- data.tar.gz: c53ec10ed28f235c1e5d30df9f76b8ef27c2ba88
2
+ SHA256:
3
+ metadata.gz: 3f2f5e88baaa6845d27866a70baa5facf3c48e13798cb4889b83b7e6aa7cc5c3
4
+ data.tar.gz: 2bb6cf3b10096223a6c06cf48aab740c1ead7f9cd6515d0bef25f0151555d028
5
5
  SHA512:
6
- metadata.gz: '09cce64a0c017def10cc52dca5482101f62bfcf36669f72de4afc555f1e54b70256d0eb8a16cc661ab55fd58614ffd95c1c6d1a6886d0d900c39db8b71e94048'
7
- data.tar.gz: acb759aa73030f40137b16475a2d51d4d2f0ae387c3592494334eaac4468b33ebb0256f77029d1af1221c9db6dc43301d252cfea7b4e0d5d249b98e6185c370a
6
+ metadata.gz: bcd1f320d3ea9c3d7015315e8a924700e7f6648545e2297184c3e5eb575f7fb77fc6c7f4d8c3ad99220b638f868100a9cce51b0fe89a5e74c9512dd387c9efbe
7
+ data.tar.gz: 2423d0d19d3495edb17d3789b8372770a98739f19f15df2555cb7d4945624c6f34c9070ca7ec4826fe727361c93ee1e9c46763c12bbf0667742656cabe171c1a
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [excid3] # 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']
data/README.md CHANGED
@@ -4,6 +4,8 @@ SimpleDiscussion is a Rails forum gem extracting the [forum from GoRails](https:
4
4
 
5
5
  Out of the box, SimpleDiscussion 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
6
 
7
+ [![GoRails Forum](https://d3vv6lp55qjaqc.cloudfront.net/items/3j2p3o1j0d1O0R1w2j1Y/Screen%20Shot%202017-08-08%20at%203.12.01%20PM.png?X-CloudApp-Visitor-Id=51470&v=d439dcae)](https://d3vv6lp55qjaqc.cloudfront.net/items/3j2p3o1j0d1O0R1w2j1Y/Screen%20Shot%202017-08-08%20at%203.12.01%20PM.png?X-CloudApp-Visitor-Id=51470&v=d439dcae)
8
+
7
9
  ## Installation
8
10
 
9
11
  Before you get started, SimpleDiscussion requires a `User` model in your application (for now).
@@ -90,6 +92,19 @@ rails g simple_discussion:helpers
90
92
 
91
93
  **NOTE:** Keep in mind that the more customization you do, the tougher gem upgrades will be in the future.
92
94
 
95
+ ### Email And Slack Notifications
96
+
97
+ By default, SimpleDiscussion will attempt to send email and slack notifications for users subscribed to threads. To turn these off you can do the following in `config/initializers/simple_discussion.rb`
98
+
99
+ ```ruby
100
+ SimpleDiscussion.setup do |config|
101
+ config.send_email_notifications = false # Default: true
102
+ config.send_slack_notifications = false # Default: true
103
+ end
104
+ ```
105
+
106
+ Slack notifications require you to set `simple_discussion_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.
107
+
93
108
  ## Development
94
109
 
95
110
  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.
@@ -106,4 +121,4 @@ The gem is available as open source under the terms of the [MIT License](http://
106
121
 
107
122
  ## Code of Conduct
108
123
 
109
- Everyone interacting in the SimpleDiscussion project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/simple_discussion/blob/master/CODE_OF_CONDUCT.md).
124
+ Everyone interacting in the SimpleDiscussion project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/excid3/simple_discussion/blob/master/CODE_OF_CONDUCT.md).
@@ -20,8 +20,28 @@
20
20
 
21
21
  /* Formatting for the forum threads */
22
22
  .forum-thread {
23
- h4 a {
24
- color: #222;
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
+ .forum-thread-filters a {
38
+ color: #555555;
39
+ display: block;
40
+
41
+ &:hover {
42
+ color: #222222;
43
+ font-weight: bold;
44
+ text-decoration: none
25
45
  }
26
46
  }
27
47
 
@@ -45,6 +65,11 @@
45
65
  font-weight: 300;
46
66
  line-height: 1em;
47
67
  }
68
+
69
+ &:hover {
70
+ color: #222;
71
+ text-decoration: none;
72
+ }
48
73
  }
49
74
 
50
75
  /* Formatting for the forum posts themselves */
@@ -64,3 +89,16 @@
64
89
  border: 2px solid #5cb85c;
65
90
  }
66
91
  }
92
+
93
+ /* Formatting for the forum hr to match card border */
94
+ .simple_discussion hr {
95
+ border: 0;
96
+ border-top: 1px solid rgba(0, 0, 0, 0.125);
97
+ margin: 24px -20px;
98
+ }
99
+
100
+ .simple_discussion .text-muted {
101
+ color: #999;
102
+ margin-top: 6px;
103
+ font-size: 13px;
104
+ }
@@ -17,9 +17,21 @@ class SimpleDiscussion::ApplicationController < ::ApplicationController
17
17
  end
18
18
  helper_method :is_moderator?
19
19
 
20
- def require_moderator_or_author!
20
+ def require_mod_or_author_for_post!
21
+ unless is_moderator_or_owner?(@forum_post)
22
+ redirect_to_root
23
+ end
24
+ end
25
+
26
+ def require_mod_or_author_for_thread!
21
27
  unless is_moderator_or_owner?(@forum_thread)
22
- redirect_to simple_discussion.root_path, alert: "You aren't allowed to do that."
28
+ redirect_to_root
23
29
  end
24
30
  end
31
+
32
+ private
33
+
34
+ def redirect_to_root
35
+ redirect_to simple_discussion.root_path, alert: "You aren't allowed to do that."
36
+ end
25
37
  end
@@ -2,14 +2,15 @@ class SimpleDiscussion::ForumPostsController < SimpleDiscussion::ApplicationCont
2
2
  before_action :authenticate_user!
3
3
  before_action :set_forum_thread
4
4
  before_action :set_forum_post, only: [:edit, :update]
5
- before_action :require_moderator_or_author!, only: [:edit, :update, :solved, :unsolved]
5
+ before_action :require_mod_or_author_for_post!, only: [:edit, :update]
6
+ before_action :require_mod_or_author_for_thread!, only: [:solved, :unsolved]
6
7
 
7
8
  def create
8
9
  @forum_post = @forum_thread.forum_posts.new(forum_post_params)
9
10
  @forum_post.user_id = current_user.id
10
11
 
11
12
  if @forum_post.save
12
- #ForumNotificationJob.perform_later(@forum_post.id)
13
+ SimpleDiscussion::ForumPostNotificationJob.perform_later(@forum_post)
13
14
  redirect_to simple_discussion.forum_thread_path(@forum_thread, anchor: "forum_post_#{@forum_post.id}")
14
15
  else
15
16
  render template: "simple_discussion/forum_threads/show"
@@ -53,7 +54,7 @@ class SimpleDiscussion::ForumPostsController < SimpleDiscussion::ApplicationCont
53
54
  end
54
55
 
55
56
  def set_forum_post
56
- if current_user.moderator?
57
+ if is_moderator?
57
58
  @forum_post = @forum_thread.forum_posts.find(params[:id])
58
59
  else
59
60
  @forum_post = current_user.forum_posts.find(params[:id])
@@ -1,7 +1,7 @@
1
1
  class SimpleDiscussion::ForumThreadsController < SimpleDiscussion::ApplicationController
2
2
  before_action :authenticate_user!, only: [:mine, :participating, :new, :create]
3
3
  before_action :set_forum_thread, only: [:show, :edit, :update]
4
- before_action :require_moderator_or_author!, only: [:edit, :update]
4
+ before_action :require_mod_or_author_for_thread!, only: [:edit, :update]
5
5
 
6
6
  def index
7
7
  @forum_threads = ForumThread.pinned_first.sorted.includes(:user, :forum_category).paginate(page: page_number)
@@ -42,7 +42,7 @@ class SimpleDiscussion::ForumThreadsController < SimpleDiscussion::ApplicationCo
42
42
  @forum_thread.forum_posts.each{ |post| post.user_id = current_user.id }
43
43
 
44
44
  if @forum_thread.save
45
- #ForumThreadNotificationJob.perform_later(@forum_thread.forum_posts.first.id)
45
+ SimpleDiscussion::ForumThreadNotificationJob.perform_later(@forum_thread)
46
46
  redirect_to simple_discussion.forum_thread_path(@forum_thread)
47
47
  else
48
48
  render action: :new
@@ -54,7 +54,7 @@ class SimpleDiscussion::ForumThreadsController < SimpleDiscussion::ApplicationCo
54
54
 
55
55
  def update
56
56
  if @forum_thread.update(forum_thread_params)
57
- redirect_to simple_discussion.forum_thread_path(@forum_thread), notice: "Your changes were saved."
57
+ redirect_to simple_discussion.forum_thread_path(@forum_thread), notice: I18n.t('your_changes_were_saved')
58
58
  else
59
59
  render action: :edit
60
60
  end
@@ -0,0 +1,42 @@
1
+ class SimpleDiscussion::ForumPostNotificationJob < ApplicationJob
2
+ include SimpleDiscussion::Engine.routes.url_helpers
3
+
4
+ def perform(forum_post)
5
+ send_emails(forum_post) if SimpleDiscussion.send_email_notifications
6
+ send_webhook(forum_post) if SimpleDiscussion.send_slack_notifications
7
+ end
8
+
9
+ def send_emails(forum_post)
10
+ forum_thread = forum_post.forum_thread
11
+ users = forum_thread.subscribed_users - [forum_post.user]
12
+ users.each do |user|
13
+ SimpleDiscussion::UserMailer.new_post(forum_post, user).deliver_later
14
+ end
15
+ end
16
+
17
+ def send_webhook(forum_post)
18
+ slack_webhook_url = Rails.application.secrets.simple_discussion_slack_url
19
+ return if slack_webhook_url.blank?
20
+
21
+ forum_thread = forum_post.forum_thread
22
+ payload = {
23
+ fallback: "#{forum_post.user.name} replied to <#{forum_thread_url(forum_thread, anchor: ActionView::RecordIdentifier.dom_id(forum_post))}|#{forum_thread.title}>",
24
+ pretext: "#{forum_post.user.name} replied to <#{forum_thread_url(forum_thread, anchor: ActionView::RecordIdentifier.dom_id(forum_post))}|#{forum_thread.title}>",
25
+ fields: [
26
+ {
27
+ title: "Thread",
28
+ value: forum_thread.title,
29
+ short: true
30
+ },
31
+ {
32
+ title: "Posted By",
33
+ value: forum_post.user.name,
34
+ short: true,
35
+ },
36
+ ],
37
+ ts: forum_post.created_at.to_i
38
+ }
39
+
40
+ SimpleDiscussion::Slack.new(slack_webhook_url).post(payload)
41
+ end
42
+ end
@@ -0,0 +1,40 @@
1
+ class SimpleDiscussion::ForumThreadNotificationJob < ApplicationJob
2
+ include SimpleDiscussion::Engine.routes.url_helpers
3
+
4
+ def perform(forum_thread)
5
+ send_emails(forum_thread) if SimpleDiscussion.send_email_notifications
6
+ send_webhook(forum_thread) if SimpleDiscussion.send_slack_notifications
7
+ end
8
+
9
+ def send_emails(forum_thread)
10
+ forum_thread.notify_users.each do |user|
11
+ SimpleDiscussion::UserMailer.new_thread(forum_thread, user).deliver_later
12
+ end
13
+ end
14
+
15
+ def send_webhook(forum_thread)
16
+ slack_webhook_url = Rails.application.secrets.simple_discussion_slack_url
17
+ return if slack_webhook_url.blank?
18
+
19
+ forum_post = forum_thread.forum_posts.first
20
+ payload = {
21
+ fallback: "A new discussion was started: <#{forum_thread_url(forum_thread, anchor: ActionView::RecordIdentifier.dom_id(forum_post))}|#{forum_thread.title}>",
22
+ pretext: "A new discussion was started: <#{forum_thread_url(forum_thread, anchor: ActionView::RecordIdentifier.dom_id(forum_post))}|#{forum_thread.title}>",
23
+ fields: [
24
+ {
25
+ title: "Thread",
26
+ value: forum_thread.title,
27
+ short: true
28
+ },
29
+ {
30
+ title: "Posted By",
31
+ value: forum_post.user.name,
32
+ short: true,
33
+ },
34
+ ],
35
+ ts: forum_post.created_at.to_i
36
+ }
37
+
38
+ SimpleDiscussion::Slack.new(slack_webhook_url).post(payload)
39
+ end
40
+ end
@@ -0,0 +1,28 @@
1
+ class SimpleDiscussion::UserMailer < ApplicationMailer
2
+ # You can set the default `from` address in ApplicationMailer
3
+
4
+ helper SimpleDiscussion::ForumPostsHelper
5
+ helper SimpleDiscussion::Engine.routes.url_helpers
6
+
7
+ def new_thread(forum_thread, recipient)
8
+ @forum_thread = forum_thread
9
+ @forum_post = forum_thread.forum_posts.first
10
+ @recipient = recipient
11
+
12
+ mail(
13
+ to: "#{@recipient.name} <#{@recipient.email}>",
14
+ subject: @forum_thread.title
15
+ )
16
+ end
17
+
18
+ def new_post(forum_post, recipient)
19
+ @forum_post = forum_post
20
+ @forum_thread = forum_post.forum_thread
21
+ @recipient = recipient
22
+
23
+ mail(
24
+ to: "#{@recipient.name} <#{@recipient.email}>",
25
+ subject: "New post in #{@forum_thread.title}"
26
+ )
27
+ end
28
+ end
@@ -56,20 +56,28 @@ class ForumThread < ApplicationRecord
56
56
  end
57
57
 
58
58
  def subscribed_reason(user)
59
- return "You’re not receiving notifications from this thread." if user.nil?
59
+ return I18n.t('.not_receiving_notifications') if user.nil?
60
60
 
61
61
  subscription = subscription_for(user)
62
62
 
63
63
  if subscription.present?
64
64
  if subscription.subscription_type == "optout"
65
- "You're ignoring this thread."
65
+ I18n.t('.ignoring_thread')
66
66
  elsif subscription.subscription_type == "optin"
67
- "You're receiving notifications because you've subscribed to this thread."
67
+ I18n.t('.receiving_notifications_because_subscribed')
68
68
  end
69
69
  elsif forum_posts.where(user_id: user.id).any?
70
- "You're receiving notifications because you've posted in this thread."
70
+ I18n.t('.receiving_notifications_because_posted')
71
71
  else
72
- "You're not receiving notifications from this thread."
72
+ I18n.t('.not_receiving_notifications')
73
73
  end
74
74
  end
75
+
76
+ # These are the users to notify on a new thread. Currently this does nothing,
77
+ # but you can override this to provide whatever functionality you like here.
78
+ #
79
+ # For example: You might use this to send all moderators an email of new threads.
80
+ def notify_users
81
+ []
82
+ end
75
83
  end
@@ -1,25 +1,63 @@
1
- <div class="row">
2
- <div class="col-sm-3">
1
+ <div class="row col-md-12">
2
+ <h1>
3
+ <%= t('community') %>
4
+ </h1>
5
+ </div>
6
+
7
+ <div class="row simple_discussion">
8
+ <div class="col-md-3 mb-3">
3
9
 
4
- <div class="card card-block">
5
- <%= link_to 'Ask A Question', simple_discussion.new_forum_thread_path, class: "btn btn-outline-primary btn-block" %>
10
+ <div class="card card-body">
11
+ <%= link_to t('ask_a_question'), simple_discussion.new_forum_thread_path, class: "btn btn-outline-primary btn-block" %>
6
12
  <hr />
7
13
 
8
14
  <div class="forum-thread-filters">
9
- <h5><strong>Filters</strong></h5>
10
- <div><%= forum_link_to simple_discussion.forum_threads_path, exact: true do %><%= icon "bars" %> All Threads <% end %></div>
15
+ <h5>
16
+ <strong>
17
+ <%= t('filters') %>
18
+ </strong>
19
+ </h5>
20
+ <div>
21
+ <%= forum_link_to simple_discussion.forum_threads_path, exact: true do %>
22
+ <%= icon "bars" %>
23
+ <%= t('.all_threads') %>
24
+ <% end %>
25
+ </div>
11
26
  <% if user_signed_in? %>
12
- <div><%= forum_link_to simple_discussion.mine_forum_threads_path do %><%= icon "user-circle-o" %> My Questions<% end %></div>
13
- <div><%= forum_link_to simple_discussion.participating_forum_threads_path do %><%= icon "comments-o" %> Participating<% end %></div>
27
+ <div>
28
+ <%= forum_link_to simple_discussion.mine_forum_threads_path do %><%= icon "user-circle-o" %>
29
+ <%= t('.my_questions') %>
30
+ <% end %>
31
+ </div>
32
+ <div>
33
+ <%= forum_link_to simple_discussion.participating_forum_threads_path do %>
34
+ <%= icon "comments-o" %>
35
+ <%= t('.participating') %>
36
+ <% end %>
37
+ </div>
14
38
  <% end %>
15
- <div><%= forum_link_to simple_discussion.answered_forum_threads_path do %><%= icon "check" %> Answered<% end %></div>
16
- <div><%= forum_link_to simple_discussion.unanswered_forum_threads_path do %><%= icon "question" %> Unanswered<% end %></div>
39
+ <div>
40
+ <%= forum_link_to simple_discussion.answered_forum_threads_path do %>
41
+ <%= icon "check" %>
42
+ <%= t('.answered') %>
43
+ <% end %>
44
+ </div>
45
+ <div>
46
+ <%= forum_link_to simple_discussion.unanswered_forum_threads_path do %>
47
+ <%= icon "question" %>
48
+ <%= t('.unanswered') %>
49
+ <% end %>
50
+ </div>
17
51
  </div>
18
52
 
19
53
  <hr />
20
54
 
21
55
  <div class="forum-thread-filters">
22
- <p><strong>By Category</strong></p>
56
+ <h6>
57
+ <strong>
58
+ <%= t('.by_category') %>
59
+ </strong>
60
+ </h6>
23
61
  <div><%= forum_link_to simple_discussion.forum_threads_path, exact: true do %><%= icon "circle" %> All<% end %></div>
24
62
  <% ForumCategory.sorted.each do |category| %>
25
63
  <div>
@@ -35,13 +73,14 @@
35
73
  <hr />
36
74
 
37
75
  <%# User has not posted in the thread or subscribed %>
38
- <h5>Notifications</h5>
76
+ <h5><%= t('.notifications') %></h5>
39
77
 
40
78
  <%= link_to simple_discussion.forum_thread_notifications_path(@forum_thread), method: :post, class: "btn btn-secondary btn-sm btn-block mb-2" do %>
41
79
  <% if @forum_thread.subscribed? current_user %>
42
- <%= icon "bell-slash" %> Unsubscribe
80
+ <%= icon "bell-slash" %> t('.unsubscribe')
43
81
  <% else %>
44
- <%= icon "bell" %> Subscribe
82
+ <%= icon "bell" %>
83
+ <%= t('.suscribe') %>
45
84
  <% end %>
46
85
  <% end %>
47
86
 
@@ -51,8 +90,12 @@
51
90
 
52
91
  </div>
53
92
 
54
- <div class="col">
55
- <%= yield %>
93
+ <div class="col-md-9 mb-3">
94
+
95
+ <div class="card card-body">
96
+ <%= yield %>
97
+ </div>
98
+
56
99
  </div>
57
100
  </div>
58
101
 
@@ -15,7 +15,7 @@
15
15
  <% end %>
16
16
 
17
17
  <div class="form-group">
18
- <%= f.text_area :body, placeholder: "Add a comment", rows: 8, class: "form-control simplemde", data: { behavior: "comment-body" } %>
18
+ <%= f.text_area :body, placeholder: t('add_a_comment'), rows: 8, class: "form-control simplemde", data: { behavior: "comment-body" } %>
19
19
  </div>
20
20
 
21
21
  <div class="text-right">
@@ -26,7 +26,7 @@
26
26
  </small>
27
27
  </div>
28
28
 
29
- <%= f.button "#{"Update" unless f.object.new_record?} Comment", class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Saving comment..."} %>
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
30
  </div>
31
31
 
32
32
  <% end %>
@@ -8,7 +8,7 @@
8
8
  <%= link_to icon("pencil"), simple_discussion.edit_forum_thread_forum_post_path(@forum_thread, forum_post),
9
9
  class: "text-muted",
10
10
  data: { toggle: "tooltip", placement: "left" },
11
- title: "Edit this post"
11
+ title: t('edit_this_post')
12
12
  %>
13
13
  </div>
14
14
  <% end %>
@@ -20,25 +20,25 @@
20
20
  <%= forum_post.user.name %> <%= forum_user_badge(forum_post.user) %>
21
21
  </strong>
22
22
  <small>
23
- commented on
23
+ <%= t('commented_on') %>
24
24
  <%= link_to forum_post.created_at.strftime("%b %d, %Y"), simple_discussion.forum_thread_path(@forum_thread, anchor: "forum_post_#{forum_post.id}") %>:
25
25
  </small>
26
26
  </div>
27
27
  </div>
28
28
 
29
- <div class="card-block">
29
+ <div class="card-body">
30
30
  <%= formatted_content forum_post.body %>
31
31
  </div>
32
32
 
33
33
  <% if @forum_thread.solved? && forum_post.solved? %>
34
34
  <div class="card-footer">
35
35
  <div class="pull-right">
36
- <strong class="text-success"><%= icon("check") %> Solved</strong>
36
+ <strong class="text-success"><%= icon("check") %> <%= t('solved') %></strong>
37
37
 
38
38
  <% if is_moderator_or_owner?(@forum_thread) %>
39
39
  <small>
40
- <%= link_to "Undo", simple_discussion.unsolved_forum_thread_forum_post_path(@forum_thread, forum_post), method: :put %>
41
- </small
40
+ <%= link_to t('undo'), simple_discussion.unsolved_forum_thread_forum_post_path(@forum_thread, forum_post), method: :put %>
41
+ </small>
42
42
  <% end %>
43
43
  </div>
44
44
  </div>
@@ -49,7 +49,7 @@
49
49
  <small>
50
50
  <%= link_to simple_discussion.solved_forum_thread_forum_post_path(@forum_thread, forum_post), method: :put do %>
51
51
  <%= icon("check") %>
52
- This solved my question
52
+ <%= t('this_solved_my_question') %>
53
53
  <% end %>
54
54
  </small>
55
55
  </div>
@@ -4,7 +4,8 @@
4
4
 
5
5
  <p class="thread-details">
6
6
  <strong><%= category_link(@forum_thread.forum_category) %></strong>
7
- Asked <%= time_ago_in_words @forum_thread.created_at %> by <%= @forum_thread.user.name %>
7
+ • <%= t('asked_time_ago', time: time_ago_in_words(@forum_thread.created_at), author: @forum_thread.user.name) %>
8
+ </p>
8
9
  </p>
9
10
 
10
11
  <br />
@@ -14,11 +15,14 @@
14
15
  <div>
15
16
  <%= avatar_tag(@forum_post.user.email) %>
16
17
  <strong class="forum-post-user"><%= @forum_post.user.name %></strong>
17
- <small> commented on <%= link_to @forum_post.created_at.strftime("%b %d, %Y"), simple_discussion.forum_thread_url(@forum_thread, anchor: "forum_post_#{@forum_post.id}") %>:</small>
18
+ <small>
19
+ <%= t('commented_on')%>
20
+ <%= link_to @forum_post.created_at.strftime("%b %d, %Y"), simple_discussion.forum_thread_url(@forum_thread, anchor: "forum_post_#{@forum_post.id}") %>:
21
+ </small>
18
22
  </div>
19
23
  </div>
20
24
 
21
- <div class="card-block">
25
+ <div class="card-body">
22
26
  <%= render "form" %>
23
27
  </div>
24
28
  <% end %>
@@ -15,29 +15,29 @@
15
15
  <% end %>
16
16
 
17
17
  <div class="form-group">
18
- <%= f.label :forum_category_id, "Choose a Category" %>
19
- <%= f.collection_select :forum_category_id, ForumCategory.sorted, :id, :name, {include_blank: "Pick a category..."}, {autofocus: true, class: "form-control"} %>
18
+ <%= f.label :forum_category_id, t('choose_a_category') %>
19
+ <%= f.collection_select :forum_category_id, ForumCategory.sorted, :id, :name, {include_blank: t('pick_a_category')}, {autofocus: true, class: "form-control"} %>
20
20
  </div>
21
21
 
22
22
  <div class="form-group">
23
- <%= f.label :title %>
24
- <%= f.text_field :title, placeholder: "How do I...?", class: "form-control" %>
23
+ <%= f.label t('title') %>
24
+ <%= f.text_field :title, placeholder: t('how_do_i'), class: "form-control" %>
25
25
  </div>
26
26
 
27
27
  <% if local_assigns.fetch(:posts, true) %>
28
28
  <%= f.fields_for :forum_posts do |p| %>
29
29
  <div class="form-group">
30
- <%= p.label :body, "What do you need help with?" %>
31
- <%= p.text_area :body, placeholder: "Add a comment", rows: 10, class: "form-control simplemde", data: { behavior: "comment-body" } %>
30
+ <%= p.label :body, t('what_help_needed') %>
31
+ <%= p.text_area :body, placeholder: t('add_a_comment'), rows: 10, class: "form-control simplemde", data: { behavior: "comment-body" } %>
32
32
  </div>
33
33
  <% end %>
34
34
  <% end %>
35
35
 
36
36
  <div class="form-group text-right">
37
37
  <% if f.object.new_record? %>
38
- <%= f.button "Ask Your Question", class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Saving..."} %>
38
+ <%= f.button t('ask_your_question'), class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> #{t('saving')}"} %>
39
39
  <% else %>
40
- <%= f.button "Update Thread", class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Saving..."} %>
40
+ <%= f.button "Update Thread", class: "btn btn-primary", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> #{t('saving')}"} %>
41
41
  <% end %>
42
42
  </div>
43
43
 
@@ -19,16 +19,16 @@
19
19
 
20
20
  <div class="thread-details">
21
21
  <strong><%= category_link(forum_thread.forum_category) %></strong>
22
- Asked <%= time_ago_in_words forum_thread.created_at %> by <%= forum_thread.user.name %>
22
+ • <%= t('asked_time_ago', time: time_ago_in_words(forum_thread.created_at), author: forum_thread.user.name) %>
23
23
  </div>
24
24
 
25
25
  <p class="text-muted"><%= truncate(forum_thread.forum_posts.first.body, length: 200) %></p>
26
26
  </div>
27
27
 
28
- <div class="col-sm-1 text-center">
28
+ <div class="col-sm-2 text-center">
29
29
  <%= link_to simple_discussion.forum_thread_path(forum_thread), class: "thread-posts-count" do %>
30
30
  <span class="count"><%= forum_thread.forum_posts_count %></span>
31
- <small><%= "post".pluralize(forum_thread.forum_posts_count) %></small>
31
+ <small><%= t("post", count: forum_thread.forum_posts_count) %></small>
32
32
  <% end %>
33
33
  </div>
34
34
 
@@ -1,6 +1,6 @@
1
1
  <%= content_for :title, "Edit Thread" %>
2
2
 
3
- <h1>Edit Thread</h1>
3
+ <h1><%= t('edit_thread') %></h1>
4
4
 
5
5
  <div class="forum_post">
6
6
  <%= render 'form', posts: false %>
@@ -1,11 +1,13 @@
1
- <div class="card card-block mb-3">
2
- <%= render partial: "simple_discussion/forum_threads/forum_thread", collection: @forum_threads, spacer_template: "shared/spacer" %>
1
+ <% if @forum_threads.none? %>
3
2
 
4
- <% if @forum_threads.none? %>
5
- <div>No results found for your search. Check out <%= link_to "the latest questions", simple_discussion.forum_threads_path %> instead?</div>
6
- <% end %>
7
- </div>
3
+ <div><%= t('search_not_found') %>. <%= t('check_out') %> <%= link_to t('latest_questions'), simple_discussion.forum_threads_path %> <%= t('instead') %> </div>
8
4
 
9
- <div class="forum-threads-nav text-center">
10
- <%= will_paginate @forum_threads, url_builder: simple_discussion, renderer: SimpleDiscussion::BootstrapLinkRenderer %>
11
- </div>
5
+ <% else %>
6
+
7
+ <%= render partial: "simple_discussion/forum_threads/forum_thread", collection: @forum_threads, spacer_template: "shared/spacer" %>
8
+
9
+ <div class="forum-threads-nav text-center">
10
+ <%= will_paginate @forum_threads, url_builder: simple_discussion, renderer: SimpleDiscussion::BootstrapLinkRenderer %>
11
+ </div>
12
+
13
+ <% end %>
@@ -1,4 +1,4 @@
1
- <h1>Start A Discussion</h1>
1
+ <h1><%= t('start_a_discussion') %></h1>
2
2
 
3
3
  <div class="forum_post">
4
4
  <%= render 'form' %>
@@ -1,17 +1,22 @@
1
- <h1><%= icon "thumb-tack", class: "text-muted" if @forum_thread.pinned? %> <%= @forum_thread.title %></h1>
2
-
3
- <% if is_moderator_or_owner?(@forum_thread) %>
4
- <div class="pull-right">
5
- <%= link_to icon("pencil"), simple_discussion.edit_forum_thread_path(@forum_thread),
6
- class: "text-muted",
7
- data: { toggle: "tooltip", placement: "left" },
8
- title: "Edit this thread" %>
1
+ <div class="row">
2
+ <div class="col-md-11">
3
+ <h1><%= icon "thumb-tack", class: "text-muted" if @forum_thread.pinned? %> <%= @forum_thread.title %></h1>
9
4
  </div>
10
- <% end %>
5
+
6
+ <% if is_moderator_or_owner?(@forum_thread) %>
7
+ <div class="col-md-1">
8
+ <%= link_to icon("pencil"), simple_discussion.edit_forum_thread_path(@forum_thread),
9
+ class: "text-muted",
10
+ data: { toggle: "tooltip", placement: "left" },
11
+ title: t('edit_this_thread') %>
12
+ </div>
13
+ <% end %>
14
+
15
+ </div>
11
16
 
12
17
  <p class="thread-details">
13
18
  <strong><%= category_link(@forum_thread.forum_category) %></strong>
14
- Asked <%= time_ago_in_words @forum_thread.created_at %> by <%= @forum_thread.user.name %>
19
+ • <%= t('asked_time_ago', time: time_ago_in_words(@forum_thread.created_at), author: @forum_thread.user.name) %>
15
20
  </p>
16
21
 
17
22
  <%= render partial: "simple_discussion/forum_posts/forum_post", collection: @forum_thread.forum_posts.includes(:user).sorted %>
@@ -0,0 +1,12 @@
1
+ <div style="position: relative">
2
+ <%= gravatar_image_tag @forum_post.user.email, style: "float: left" %>
3
+
4
+ <div style="margin-left:60px">
5
+ <p><strong><%= @forum_post.user.name %></strong> <small>commented:</small></p>
6
+ <%= formatted_content @forum_post.body %>
7
+ </div>
8
+ </div>
9
+
10
+ <br />
11
+
12
+ <p><%= link_to "Reply to this comment", forum_thread_url(@forum_post.forum_thread, anchor: "forum_post_#{@forum_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 @forum_post.user.email, style: "float: left" %>
3
+
4
+ <div style="margin-left:60px">
5
+ <p><strong><%= @forum_post.user.name %></strong> <small>commented:</small></p>
6
+ <%= formatted_content @forum_post.body %>
7
+ </div>
8
+ </div>
9
+
10
+ <br />
11
+
12
+ <p><%= link_to "Reply to this comment", forum_thread_url(@forum_post.forum_thread, anchor: "forum_post_#{@forum_post.id}"), style: "background:#be2126; color:#fff; text-decoration:none; padding: 10px 20px" %></p>
@@ -0,0 +1,45 @@
1
+ en:
2
+ start_a_discussion: Start A Discussion
3
+ add_a_comment: Add A Comment
4
+ ask_a_question: Ask A Question
5
+ asked_time_ago: "Asked %{time} ago by %{author}"
6
+ choose_a_category: Choose a Category
7
+ comment: comment
8
+ commented_on: Commented on
9
+ community: Community
10
+ edit_this_post: Edit this post
11
+ edit_this_thread: Edit this thread
12
+ edit_thread: Edit thread
13
+ filters: Filters
14
+ how_do_i: How do I...?
15
+ ignoring_thread: You're ignoring this thread.
16
+ not_receiving_notifications: You’re not receiving notifications from this thread.
17
+ layouts:
18
+ simple_discussion:
19
+ all_threads: All Threads
20
+ answered: Answered
21
+ by_category: By Category
22
+ my_questions: My Questions
23
+ notifications: Notifications
24
+ participating: Participating
25
+ suscribe: Subscribe
26
+ unsubscribe: Unsubscribe
27
+ unanswered: Unanswered
28
+ pick_a_category: Pick a category...
29
+ post:
30
+ one: post
31
+ other: posts
32
+ receiving_notifications_because_subscribed: You're receiving notifications because you've subscribed to this thread.
33
+ receiving_notifications_because_posted: You're receiving notifications because you've posted in this thread.
34
+ saving_comment: Saving comment...
35
+ saving: Saving
36
+ this_solved_my_question: This solved my question
37
+ title: title
38
+ what_help_needed: What do you need help with?
39
+ ask_your_question: Ask Your Question
40
+ update_comment: Update comment
41
+ your_changes_were_saved: Your changes were saved
42
+ search_not_found: No results found for your search
43
+ check_out: Check out
44
+ latest_questions: the latest questions
45
+ instead: instead?
@@ -0,0 +1,41 @@
1
+ es:
2
+ start_a_discussion: Iniciar una discusión
3
+ add_a_comment: Añade un comentario
4
+ ask_a_question: HAZ UNA PREGUNTA
5
+ asked_time_ago: "Preguntado hace %{time} por %{author}"
6
+ choose_a_category: Selecciona una categoría
7
+ comment: comenta
8
+ commented_on: Comentado en
9
+ community: Comunidad
10
+ edit_this_post: Edita esta publicación
11
+ edit_this_thread: Edita este tema
12
+ edit_thread: Edita el tema
13
+ filters: Filtros
14
+ how_do_i: Cómo puedo...?
15
+ ignoring_thread: "Estás ignorando este tema"
16
+ not_receiving_notifications: "No estás recibiendo notificaciones de este tema."
17
+ layouts:
18
+ simple_discussion:
19
+ all_threads: Todos Los Temas
20
+ answered: Respondidas
21
+ by_category: Por Categoría
22
+ my_questions: Mis Preguntas
23
+ notifications: Notificaciones
24
+ participating: Participando
25
+ suscribe: Suscribirse
26
+ unsubscribe: Desuscribirse
27
+ unanswered: Sin Responder
28
+ pick_a_category: Elige una categoría...
29
+ post:
30
+ one: publicación
31
+ other: publicaciones
32
+ receiving_notifications_because_subscribed: Estás recibiendo notificaciones porque te suscribiste a este tema.
33
+ receiving_notifications_because_posted: Estás recibiendo notificaciones porque publicaste en este tema.
34
+ saving_comment: Guardando comentario...
35
+ saving: Guardando
36
+ this_solved_my_question: Esto resolvió mi pregunta
37
+ title: Título
38
+ what_help_needed: Con qué necesitas ayuda?
39
+ ask_your_question: Haz tu pregunta
40
+ update_comment: Actualiza tu comentario
41
+ your_changes_were_saved: Tus cambios fueron guardados
@@ -0,0 +1,47 @@
1
+ fr:
2
+ start_a_discussion: Débuter une conversation
3
+ add_a_comment: Ajouter un Commentaire
4
+ ask_a_question: Poser une question
5
+ asked_time_ago: "Demandé il y a %{time} par %{author}"
6
+ choose_a_category: Choisir une catégorie
7
+ comment: commenter
8
+ commented_on: Commenté le
9
+ community: Communauté
10
+ edit_this_post: Modifier ce message
11
+ edit_this_thread: Modifier ce fil
12
+ edit_thread: Modifier le fil
13
+ filters: Les filtres
14
+ how_do_i: Comment puis-je ...?
15
+ ignoring_thread: Vous avez ignoré ce fil.
16
+ not_receiving_notifications: Vous ne recevez plus les notifications de ce fil.
17
+ layouts:
18
+ simple_discussion:
19
+ all_threads: Toutes les discussions
20
+ answered: Résolues
21
+ by_category: Par catégorie
22
+ my_questions: Mes Questions
23
+ notifications: Les notifications
24
+ participating: Participant
25
+ suscribe: S'abonner
26
+ unsubscribe: Désabonner
27
+ unanswered: Non Résolues
28
+ pick_a_category: Choisissez une catégorie ...
29
+ post:
30
+ one: message
31
+ other: messages
32
+ receiving_notifications_because_subscribed: Vous recevez les notifications parce que vous êtes abonné à ce fil.
33
+ receiving_notifications_because_posted: Vous recevez les notifications parce que vous avez posté dans ce fil.
34
+ saving_comment: Envois du commentaire ...
35
+ saving: Enregistrer
36
+ this_solved_my_question: Résolu?
37
+ title: titre
38
+ what_help_needed: Quel problème voulez-vous résoudre ?
39
+ ask_your_question: 'Poser votre question'
40
+ update_comment: Mettre à jour le commentaire
41
+ your_changes_were_saved: Vos modifications ont été enregistrées
42
+ solved: Résolu
43
+ undo: annuler
44
+ search_not_found: Aucun résultat trouvé pour votre recherche
45
+ check_out: Voir
46
+ latest_questions: les dernières questions
47
+ instead: à la place
@@ -1,6 +1,6 @@
1
1
  class CreateForumCategories < ActiveRecord::Migration[4.2]
2
2
  def change
3
- create_table :forum_categories, force: :cascade do |t|
3
+ create_table :forum_categories do |t|
4
4
  t.string :name, null: false
5
5
  t.string :slug, null: false
6
6
  t.string :color, default: "000000"
@@ -1,6 +1,6 @@
1
1
  class CreateForumThreads < ActiveRecord::Migration[4.2]
2
2
  def change
3
- create_table :forum_threads, force: :cascade do |t|
3
+ create_table :forum_threads do |t|
4
4
  t.references :forum_category, foreign_key: true
5
5
  t.references :user, foreign_key: true
6
6
  t.string :title, null: false
@@ -1,6 +1,6 @@
1
1
  class CreateForumPosts < ActiveRecord::Migration[4.2]
2
2
  def change
3
- create_table :forum_posts, force: :cascade do |t|
3
+ create_table :forum_posts do |t|
4
4
  t.references :forum_thread, foreign_key: true
5
5
  t.references :user, foreign_key: true
6
6
  t.text :body
@@ -1,6 +1,6 @@
1
1
  class CreateForumSubscriptions < ActiveRecord::Migration[4.2]
2
2
  def change
3
- create_table :forum_subscriptions, force: :cascade do |t|
3
+ create_table :forum_subscriptions do |t|
4
4
  t.references :forum_thread, foreign_key: true
5
5
  t.references :user, foreign_key: true
6
6
  t.string :subscription_type
@@ -3,60 +3,20 @@ require 'friendly_id'
3
3
  require 'gravatar_image_tag'
4
4
  require 'will_paginate'
5
5
 
6
- require "simple_discussion/version"
7
- require "simple_discussion/engine"
8
- require "simple_discussion/forum_user"
9
-
10
- require 'will_paginate/view_helpers/action_view'
6
+ require 'simple_discussion/engine'
7
+ require 'simple_discussion/forum_user'
8
+ require 'simple_discussion/slack'
9
+ require 'simple_discussion/version'
10
+ require 'simple_discussion/will_paginate'
11
11
 
12
12
  module SimpleDiscussion
13
- # This code serves two purposes
14
- # 1. It patches will_paginate to work with scoped and mounted Rails engines
15
- # by adding in the url_builder option
16
- # 2. It adds Bootstrap 4 styling to will_paginate
17
-
18
- class BootstrapLinkRenderer < WillPaginate::ActionView::LinkRenderer
19
-
20
- # This method adds the `url_builder` option so we can pass in the
21
- # mounted Rails engine's scope for will_paginate
22
- def url(page)
23
- @base_url_params ||= begin
24
- url_params = merge_get_params(default_url_params)
25
- merge_optional_params(url_params)
26
- end
27
-
28
- url_params = @base_url_params.dup
29
- add_current_page_param(url_params, page)
30
-
31
- # Add optional url_builder support
32
- (@options[:url_builder] || @template).url_for(url_params)
33
- end
34
-
35
- protected
36
- def html_container(html)
37
- tag :nav, tag(:ul, html, class: ul_class)
38
- end
39
-
40
- def page_number(page)
41
- item_class = if(page == current_page)
42
- 'active page-item'
43
- else
44
- 'page-item'
45
- end
46
-
47
- tag :li, link(page, page, :rel => rel_value(page), :class => 'page-link'), :class => item_class
48
- end
49
-
50
- def gap
51
- tag :li, link('&hellip;'.html_safe, '#', :class => 'page-link'), :class => 'page-item disabled'
52
- end
53
-
54
- def previous_or_next_page(page, text, classname)
55
- 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(' ')
56
- end
57
-
58
- def ul_class
59
- ["pagination", container_attributes[:class]].compact.join(" ")
60
- end
13
+ # Define who owns the subscription
14
+ mattr_accessor :send_email_notifications
15
+ mattr_accessor :send_slack_notifications
16
+ @@send_email_notifications = true
17
+ @@send_slack_notifications = true
18
+
19
+ def self.setup
20
+ yield self
61
21
  end
62
22
  end
@@ -1,5 +1,10 @@
1
1
  module SimpleDiscussion
2
2
  class Engine < ::Rails::Engine
3
3
  engine_name 'simple_discussion'
4
+
5
+ # Grab the Rails default url options and use them for sending notifications
6
+ config.after_initialize do
7
+ SimpleDiscussion::Engine.routes.default_url_options = ActionMailer::Base.default_url_options
8
+ end
4
9
  end
5
10
  end
@@ -0,0 +1,22 @@
1
+ require 'open-uri'
2
+ require 'net/http'
3
+
4
+ module SimpleDiscussion
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
@@ -1,3 +1,3 @@
1
1
  module SimpleDiscussion
2
- VERSION = "0.9.2"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -0,0 +1,53 @@
1
+ require 'will_paginate/view_helpers/action_view'
2
+
3
+ module SimpleDiscussion
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
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency 'font-awesome-sass', '~> 4.7.0'
24
+ spec.add_dependency 'font-awesome-sass', '>= 4.7.0'
25
25
  spec.add_dependency 'friendly_id', '>= 5.2.0'
26
26
  spec.add_dependency 'gravatar_image_tag'
27
27
  spec.add_dependency 'rails', '>= 4.2'
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_discussion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-08 00:00:00.000000000 Z
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: font-awesome-sass
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.7.0
27
27
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/FUNDING.yml"
90
91
  - ".gitignore"
91
92
  - ".travis.yml"
92
93
  - CODE_OF_CONDUCT.md
@@ -102,6 +103,9 @@ files:
102
103
  - app/controllers/simple_discussion/notifications_controller.rb
103
104
  - app/helpers/simple_discussion/forum_posts_helper.rb
104
105
  - app/helpers/simple_discussion/forum_threads_helper.rb
106
+ - app/jobs/simple_discussion/forum_post_notification_job.rb
107
+ - app/jobs/simple_discussion/forum_thread_notification_job.rb
108
+ - app/mailers/simple_discussion/user_mailer.rb
105
109
  - app/models/forum_category.rb
106
110
  - app/models/forum_post.rb
107
111
  - app/models/forum_subscription.rb
@@ -117,8 +121,13 @@ files:
117
121
  - app/views/simple_discussion/forum_threads/index.html.erb
118
122
  - app/views/simple_discussion/forum_threads/new.html.erb
119
123
  - app/views/simple_discussion/forum_threads/show.html.erb
124
+ - app/views/simple_discussion/user_mailer/new_post.html.erb
125
+ - app/views/simple_discussion/user_mailer/new_thread.html.erb
120
126
  - bin/console
121
127
  - bin/setup
128
+ - config/locales/en.yml
129
+ - config/locales/es.yml
130
+ - config/locales/fr.yml
122
131
  - config/routes.rb
123
132
  - db/migrate/20170417012930_create_forum_categories.rb
124
133
  - db/migrate/20170417012931_create_forum_threads.rb
@@ -130,13 +139,15 @@ files:
130
139
  - lib/simple_discussion.rb
131
140
  - lib/simple_discussion/engine.rb
132
141
  - lib/simple_discussion/forum_user.rb
142
+ - lib/simple_discussion/slack.rb
133
143
  - lib/simple_discussion/version.rb
144
+ - lib/simple_discussion/will_paginate.rb
134
145
  - simple_discussion.gemspec
135
146
  homepage: https://github.com/excid3/simple_discussion
136
147
  licenses:
137
148
  - MIT
138
149
  metadata: {}
139
- post_install_message:
150
+ post_install_message:
140
151
  rdoc_options: []
141
152
  require_paths:
142
153
  - lib
@@ -151,9 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
162
  - !ruby/object:Gem::Version
152
163
  version: '0'
153
164
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.6.11
156
- signing_key:
165
+ rubygems_version: 3.1.2
166
+ signing_key:
157
167
  specification_version: 4
158
168
  summary: A simple, extensible Rails forum
159
169
  test_files: []