talkie 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 515c6dccadc7671d553437edfa87bfc7eb191c87c912c41ef3c66e3a4a543240
4
- data.tar.gz: 001e9c2acb8fadc073c36143e3c239b0511893e8783ff492b0353f01c86d596f
3
+ metadata.gz: 82f6715118d4b0022047d97dc002dba51f831e09da19bc374cc0d75ddc2a62aa
4
+ data.tar.gz: df4af0404f088395e42c5c92c5dfdd55624292dc0759dbb421d18a941a775e1b
5
5
  SHA512:
6
- metadata.gz: 3c8b1bbd9ea4f991622db621ddbac930432a2e7e2525f2dd2d2a67aa9de7b7e78730962b804f39c6340ec03111c923a69b16736c8771f519e18368f8897d3c0c
7
- data.tar.gz: c12375bdec3f5f319981b93088b797c1bf6b8d0fd408c03cfd99d6a82f114eeda827399313855d28d073c7ad3f5c9b8fe8a5b9fd9fa737fb99e0d83fbb0e828a
6
+ metadata.gz: 3dea24f754eb1f95328120601f284ef6530f798c1de001ff233963b8bff83becad84d98cf064741df7df74c3541887c11c7d3855f535785b6538b8be11a100cf
7
+ data.tar.gz: f52e51279684b0fa5266ed13d30d5a5ca29d4ff247f76b32012ffacb41549c0a3598d0de4ca2b6707b75538c08d3d76fecede184aa0afcba34755c1d56ebae47
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- talkie (0.1.0)
4
+ talkie (0.2.0)
5
5
  awesome_nested_set (~> 3.1)
6
6
  rails (~> 5.0)
7
7
  sassc-rails (~> 2.1)
@@ -152,7 +152,7 @@ GEM
152
152
  sassc (2.0.1)
153
153
  ffi (~> 1.9)
154
154
  rake
155
- sassc-rails (2.1.1)
155
+ sassc-rails (2.1.2)
156
156
  railties (>= 4.0.0)
157
157
  sassc (>= 2.0)
158
158
  sprockets (> 3.0)
@@ -178,9 +178,9 @@ GEM
178
178
  tilt (2.0.9)
179
179
  tzinfo (1.2.5)
180
180
  thread_safe (~> 0.1)
181
- websocket-driver (0.7.0)
181
+ websocket-driver (0.7.1)
182
182
  websocket-extensions (>= 0.1.0)
183
- websocket-extensions (0.1.3)
183
+ websocket-extensions (0.1.4)
184
184
 
185
185
  PLATFORMS
186
186
  ruby
data/README.md CHANGED
@@ -89,6 +89,7 @@ Talkie, currently only offers 3 options for the `talkie_on` helper method:
89
89
  | **nested** | Whether users are able to reply to comments or not. *Default: false* |
90
90
  | **display_user_avatar** | Whether the helper should render an avatar. *Default: true* |
91
91
  | **display_user_handler** | Whether the helper should render the user handler. *Default: false* |
92
+ | **deletable** | Whether the helper should render the delete link. *Default: false* |
92
93
 
93
94
  Don't worry about those nasty N+1 queries, Talkie is smart enough to take care of them. You don't need to restart the server for chanes on this invokation.
94
95
 
@@ -9,10 +9,12 @@ module Talkie
9
9
  respond_to do |format|
10
10
  if @comment.save
11
11
  make_child_comment if reply?
12
- format.html { redirect_to main_app.polymorphic_path(@comment.commentable), notice: "Comment was successfully added." }
12
+ format.html { redirect_to Talkie.success_redirect_to.call(main_app, @comment.commentable),
13
+ notice: t('talkie.controllers.comments.flash.success') }
13
14
  format.js
14
15
  else
15
- format.html { redirect_to :back, notice: "Something went wrong, blank comments are not allowed" }
16
+ format.html { redirect_back fallback_location: Talkie.fail_redirect_to.call(main_app),
17
+ notice: t('talkie.controllers.comments.flash.error') }
16
18
  format.js
17
19
  end
18
20
  end
@@ -1,6 +1,11 @@
1
1
  ---
2
2
  en:
3
3
  talkie:
4
+ controllers:
5
+ comments:
6
+ flash:
7
+ success: "Comment was successfully added."
8
+ error: "Something went wrong, blank comments are not allowed."
4
9
  comments:
5
10
  form:
6
11
  submit: "Publish"
@@ -1,6 +1,11 @@
1
1
  ---
2
2
  es:
3
3
  talkie:
4
+ controllers:
5
+ comments:
6
+ flash:
7
+ success: "El comentario fue agregado satisfactoriamente."
8
+ error: "Algo salió mal, tu comentario no puede estar en blanco."
4
9
  comments:
5
10
  form:
6
11
  submit: "Publicar"
@@ -43,4 +43,21 @@ Talkie.configure do |config|
43
43
  #
44
44
  # The default looks like:
45
45
  # config.creator_avatar_url = lambda { |user| "//api.adorable.io/avatars/40/abott@adorable.png" }
46
+ #
47
+
48
+ # ==> Redirect for comments controller
49
+ # There are sometimes you want to redirect to different locations
50
+ # for the app on success or failure of a comment post,
51
+ # you can easily achieve this through the following configurations
52
+ #
53
+ # The default value for success redirection is:
54
+ # config.success_redirect_to = lambda { |router, commentable| router.polymorphic_path(commentable) }
55
+ # You can override it to anything you want. Inside this lambda function
56
+ # you have access to the main router and the commentable object
57
+ #
58
+ # The default value for failure redirection is:
59
+ # config.fail_redirect_to = lambda { |router| router.url }
60
+ # Inside the comments controller, the redirection would be to go back
61
+ # to the page where the submit came, and if not, it will go to this
62
+ # lambda
46
63
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Talkie
2
- VERSION = "0.1.1"
4
+ VERSION = '0.2.0'.freeze
3
5
  end
data/lib/talkie.rb CHANGED
@@ -6,17 +6,23 @@ require "awesome_nested_set"
6
6
 
7
7
  module Talkie
8
8
 
9
- @@default_comments_scope = -> { order(created_at: :desc) }
10
- mattr_accessor :default_comments_scope
9
+ mattr_accessor :default_comments_scope,
10
+ default: -> { order(created_at: :desc) }
11
11
 
12
- @@comment_creator_handler = :email
13
- mattr_accessor :comment_creator_handler
12
+ mattr_accessor :comment_creator_handler,
13
+ default: :email
14
14
 
15
- @@creator_path = lambda { |_user, _router| "#" }
16
- mattr_accessor :creator_path
15
+ mattr_accessor :creator_path,
16
+ default: lambda { |_user, _router| "#" }
17
17
 
18
- @@creator_avatar_url = lambda { |_user| "//api.adorable.io/avatars/40/abott@adorable.png" }
19
- mattr_accessor :creator_avatar_url
18
+ mattr_accessor :creator_avatar_url,
19
+ default: lambda { |_user| "//api.adorable.io/avatars/40/abott@adorable.png" }
20
+
21
+ mattr_accessor :success_redirect_to,
22
+ default: lambda { |router, commentable| router.polymorphic_path(commentable) }
23
+
24
+ mattr_accessor :fail_redirect_to,
25
+ default: lambda { |router| router.root_url }
20
26
 
21
27
  def self.configure
22
28
  yield self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talkie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abraham Kuri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-05 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ammeter