commentui 0.1.01

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1bca51f6161bc71cf5cf350f50c64ad10eb49415f4ba69216904f66508ca3c55
4
+ data.tar.gz: '02900136895d81f1b3a4c3e501466b57785568dd727663f87214b09b5887fc80'
5
+ SHA512:
6
+ metadata.gz: 44c26ef6404f40348fada9c1f6c42ffa7ae37043776103ede7574359575856b9984ab1efe9d4170f1743fa2acf51a57503efc7c72912613fd5f562373a0be57c
7
+ data.tar.gz: 77432261dc67cf8a35441914166fd43ab6bcaed86b7518b39beec31c69137f81f870cb9a991baf333d9e8112b45350530eadc6bb10f4700c4d1f73b9d65de732
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Huuphuoc19
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Commentui
2
+ A simple comment API gem
3
+
4
+ ## Installation
5
+ ### 1. Gem install
6
+
7
+ Add this line to your application's Gemfile:
8
+ ```ruby
9
+ gem 'commentui', "~> 0.1"
10
+ ```
11
+
12
+ And then execute:
13
+ ```bash
14
+ $ bundle install
15
+ ```
16
+ Or install it yourself as:
17
+ ```bash
18
+ $ gem install commentui
19
+ ```
20
+ ### 2. Migrations
21
+ Run the following [command](https://edgeguides.rubyonrails.org/engines.html#engine-setup) to copy Commentui's migrations to your application:
22
+ ```bash
23
+ $ bundle exec rake commentui:install:migrations
24
+ ```
25
+
26
+
27
+ Then run migrate database command:
28
+ ```bash
29
+ $ rake db:migrate
30
+ ```
31
+
32
+ To remove engine migration, run:
33
+ ```bash
34
+ $ rake db:migrate SCOPE=commentui VERSION=0
35
+ ```
36
+
37
+ ### 3. Initializers
38
+ Run the following command to copy Commentui's initializers to your application:
39
+ ```bash
40
+ $ bundle exec rake commentui:install:initializers
41
+ ```
42
+
43
+ ### 4. Route config
44
+ Add this line to your Rails application's routes.rb file:
45
+ ```ruby
46
+ mount Commentui::Engine => '/commentui'
47
+ ```
48
+
49
+ ## Usage
50
+ ### 1. Models
51
+ Add this line to your model(s) should be able to post comments (usually user model):
52
+ ```ruby
53
+ acts_as_commentuier
54
+ ```
55
+ The model'll look like:
56
+ ```ruby
57
+ class User < ApplicationRecord
58
+ acts_as_commentuier
59
+ end
60
+ ```
61
+
62
+ Add this line to any models you want to be able to comment on (post,...)
63
+ ```ruby
64
+ acts_as_commentuiable
65
+ ```
66
+ The model'll look like:
67
+ ```ruby
68
+ class Post < ApplicationRecord
69
+ acts_as_commentuiable
70
+ end
71
+ ```
72
+
73
+ ### 2. Controllers
74
+ Supported actions
75
+
76
+ |Helper|HTTP Verb|Path|Controller#Action|
77
+ |--- |--- |--- |--- |
78
+ |thread_comments_path|GET|/threads/:thread_id/comments(.:format)|commentui/comments#index|
79
+ ||POST|/threads/:thread_id/comments(.:format)|commentui/comments#create|
80
+ |thread_comment_path|GET|/threads/:thread_id/comments/:id(.:format)|commentui/comments#show|
81
+ ||PATCH|/threads/:thread_id/comments/:id(.:format)|commentui/comments#update|
82
+ ||PUT|/threads/:thread_id/comments/:id(.:format)|commentui/comments#update|
83
+ ||DELETE|/threads/:thread_id/comments/:id(.:format)|commentui/comments#destroy|
84
+ |thread_path|GET|/threads/:id(.:format)|commentui/threads#show|
85
+
86
+
87
+ ## Contributing
88
+ Contribution directions go here.
89
+
90
+ ## License
91
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Commentui'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+ require 'bundler/gem_tasks'
22
+
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/commentui .js
2
+ //= link_directory ../stylesheets/commentui .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,26 @@
1
+ class Commentui::ApplicationController < Commentui.base_controller
2
+ before_action :check_commentui_user
3
+
4
+ rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
5
+
6
+ def render_json_errors(errors, status=:unprocessable_entity)
7
+ errors = [errors] unless errors.instance_of?(Array)
8
+ render json: {
9
+ errors: errors
10
+ }, status: status
11
+ end
12
+
13
+ def record_not_found
14
+ render_json_errors("Record not found", :not_found)
15
+ end
16
+
17
+ def check_commentui_user
18
+ return if commentui_user.present?
19
+
20
+ render_json_errors("Permission denied")
21
+ end
22
+
23
+ def commentui_user
24
+ @commentui_user ||= Commentui.current_user_lambda.call(self)
25
+ end
26
+ end
@@ -0,0 +1,63 @@
1
+ require_dependency "commentui/application_controller"
2
+
3
+ module Commentui
4
+ class CommentsController < ApplicationController
5
+ include Pagy::Backend
6
+
7
+ before_action :set_thread
8
+ before_action :set_comment, only: [:update, :destroy]
9
+ before_action :check_user, only: [:update, :destroy]
10
+ after_action { pagy_headers_merge(@pagy) if @pagy }
11
+
12
+ def index
13
+ @comments = comments_scope.includes(:creator, :editor)
14
+ @pagy, @comments = pagy(@comments, items: params[:items])
15
+ render json: @comments
16
+ end
17
+
18
+ def create
19
+ @comment = comments_scope.new(comment_params)
20
+ @comment.creator = commentui_user
21
+ return render json: @comment if @comment.save
22
+
23
+ render_json_errors(@comment.errors.full_messages)
24
+ end
25
+
26
+ def update
27
+ @comment.assign_attributes(comment_params)
28
+ @comment.editor = commentui_user
29
+ return render json: @comment if @comment.save
30
+
31
+ render_json_errors(@comment.errors.full_messages)
32
+ end
33
+
34
+ def destroy
35
+ render json: @comment.destroy
36
+ end
37
+
38
+ private
39
+
40
+ def set_thread
41
+ @thread ||= Commentui::Thread.find(params[:thread_id])
42
+ end
43
+
44
+ def comments_scope
45
+ @thread.comments.order(created_at: :asc)
46
+ end
47
+
48
+ def set_comment
49
+ @comment ||= comments_scope.find(params[:id])
50
+ end
51
+
52
+ def comment_params
53
+ params.fetch(:comment, {})
54
+ .permit(:content)
55
+ end
56
+
57
+ def check_user
58
+ return if @comment.can_modify?(commentui_user)
59
+
60
+ render_json_errors("Permission denied")
61
+ end
62
+ end #
63
+ end ##
@@ -0,0 +1,5 @@
1
+ module Commentui
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require_dependency "commentui/application_record"
2
+
3
+ module Commentui
4
+ class Comment < ApplicationRecord
5
+ belongs_to :thread
6
+ belongs_to :creator, polymorphic: true
7
+ belongs_to :editor, optional: true, polymorphic: true
8
+
9
+ validates :content, presence: true
10
+
11
+ def can_modify?(edited_user)
12
+ edited_user == self.creator
13
+ end
14
+
15
+ def as_json(_opts={})
16
+ {
17
+ id: self.id,
18
+ content: self.content,
19
+ updated_at: self.updated_at,
20
+ created_at: self.created_at,
21
+ creator: creator,
22
+ editor: editor,
23
+ }
24
+ end
25
+ end ##
26
+ end #
@@ -0,0 +1,10 @@
1
+ require_dependency "commentui/application_record"
2
+
3
+ module Commentui
4
+ class Thread < ApplicationRecord
5
+ belongs_to :commentable, polymorphic: true
6
+ belongs_to :closer, optional: true, polymorphic: true
7
+
8
+ has_many :comments, dependent: :destroy
9
+ end #
10
+ end ##
@@ -0,0 +1,21 @@
1
+ Commentui.configure do |config|
2
+ # ===> base_controller will be inherit by commmentui's application controller
3
+ # where your current_user is defined
4
+ # Type: ActionController::Base relatives class
5
+ # Defautl: ActionController::Base
6
+ # config.base_controller = ActionController::Base
7
+
8
+ # ===> current_user method of your system
9
+ # Type: lambda
10
+ # Params: current controller
11
+ # Default: ->(context) { context.current_user }
12
+ # config.current_user_lambda = ->(context) { context.current_user }
13
+
14
+ # ===> allow_modify_comment should gem provides modify comments function
15
+ # Defautl: true
16
+ # config.allow_modify_comment = true
17
+
18
+ # ===> allow_modify_destroy should gem provides destroy comments function
19
+ # Defautl: true
20
+ # config.allow_modify_destroy = true
21
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Commentui::Engine.routes.draw do
2
+ resources :threads, only: [:show] do
3
+ comment_resources = [:index, :show, :create]
4
+ comment_resources << :update if Commentui.allow_modify_comment
5
+ comment_resources << :destroy if Commentui.allow_modify_destroy
6
+ resources :comments, only: comment_resources
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCommentuiThreads < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :commentui_threads do |t|
4
+ t.references :commentable,
5
+ polymorphic: true,
6
+ index: { unique: true }
7
+ t.references :closer, polymorphic: true
8
+
9
+ t.datetime :closed_at
10
+
11
+ t.timestamps null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ class CreateCommentuiComments < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :commentui_comments do |t|
4
+ t.references :thread,
5
+ null: false,
6
+ index: false,
7
+ foreign_key: {
8
+ to_table: :commentui_threads,
9
+ on_update: :cascade,
10
+ on_delete: :cascade,
11
+ }
12
+
13
+ t.references :creator, polymorphic: true, null: false, index: false
14
+ t.references :editor, polymorphic: true
15
+
16
+ t.text :content, null: false
17
+ t.datetime :deleted_at
18
+
19
+ t.timestamps null: false
20
+ end
21
+
22
+ add_index :commentui_comments,
23
+ [:creator_id, :creator_type, :thread_id],
24
+ name: 'index_commentui_comments_on_c_id_and_c_type_and_t_id'
25
+
26
+ end
27
+ end
data/lib/commentui.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'pagy'
2
+ require "initializers/pagy"
3
+
4
+ module Commentui
5
+ # Your code goes here...
6
+ require "commentui/engine"
7
+ require "commentui/version"
8
+ require "commentui/acts_as_commentuier"
9
+ require "commentui/acts_as_commentuiable"
10
+
11
+ ActiveSupport.on_load(:active_record) do
12
+ include ActsAsCommentuier
13
+ include ActsAsCommentuiable
14
+ end
15
+
16
+ def self.configure
17
+ yield self
18
+ end
19
+
20
+ # The current user (devise current_user helper)
21
+ mattr_accessor :base_controller
22
+ @@base_controller = ActionController::Base
23
+
24
+ # The current user (devise current_user helper)
25
+ mattr_accessor :current_user_lambda
26
+ @@current_user_lambda = ->(context) { context.current_user }
27
+
28
+ # The flag allow modify comment or not
29
+ mattr_accessor :allow_modify_comment
30
+ @@allow_modify_comment = true
31
+
32
+ # The flag allow destroy comment or not
33
+ mattr_accessor :allow_modify_destroy
34
+ @@allow_modify_destroy = true
35
+ end #
@@ -0,0 +1,22 @@
1
+ require 'active_support/concern'
2
+
3
+ module Commentui
4
+ module ActsAsCommentuiable
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def acts_as_commentuiable
9
+ class_exec do
10
+ has_one :commentui_thread,
11
+ dependent: :nullify,
12
+ as: :commentable,
13
+ class_name: "Commentui::Thread"
14
+
15
+ def commentui_thread
16
+ @commentui_thread ||= (super || create_commentui_thread)
17
+ end
18
+ end
19
+ end
20
+ end ###
21
+ end ##
22
+ end #
@@ -0,0 +1,26 @@
1
+ require 'active_support/concern'
2
+
3
+ module Commentui
4
+ module ActsAsCommentuier
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def acts_as_commentuier
9
+ class_exec do
10
+ has_many :commentui_comments,
11
+ dependent: :destroy,
12
+ as: :creator,
13
+ class_name: "Commentui::Comment"
14
+ has_many :commentui_edited_comments,
15
+ dependent: :nullify,
16
+ as: :editor,
17
+ class_name: "Commentui::Comment"
18
+ has_many :commentui_closed_threads,
19
+ dependent: :nullify,
20
+ as: :closer,
21
+ class_name: "Commentui::Thread"
22
+ end
23
+ end
24
+ end ###
25
+ end ##
26
+ end #
@@ -0,0 +1,10 @@
1
+ module Commentui
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Commentui
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.factory_bot dir: "spec/factories", suffix: "factory"
8
+ end
9
+ end ##
10
+ end #
@@ -0,0 +1,3 @@
1
+ module Commentui
2
+ VERSION = "0.1.01"
3
+ end
@@ -0,0 +1,170 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Pagy initializer file (3.6.0)
5
+ # Customize only what you really need and notice that Pagy works also without any of the following lines.
6
+ # Should you just cherry pick part of this file, please maintain the require-order of the extras
7
+
8
+
9
+ # Extras
10
+ # See https://ddnexus.github.io/pagy/extras
11
+
12
+
13
+ # Backend Extras
14
+
15
+ # Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
16
+ # See https://ddnexus.github.io/pagy/extras/array
17
+ # require 'pagy/extras/array'
18
+
19
+ # Countless extra: Paginate without any count, saving one query per rendering
20
+ # See https://ddnexus.github.io/pagy/extras/countless
21
+ # require 'pagy/extras/countless'
22
+ # Pagy::VARS[:cycle] = false # default
23
+
24
+ # Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
25
+ # See https://ddnexus.github.io/pagy/extras/elasticsearch_rails
26
+ # require 'pagy/extras/elasticsearch_rails'
27
+
28
+ # Searchkick extra: Paginate `Searchkick::Results` objects
29
+ # See https://ddnexus.github.io/pagy/extras/searchkick
30
+ # require 'pagy/extras/searchkick'
31
+
32
+
33
+ # Frontend Extras
34
+
35
+ # Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
36
+ # See https://ddnexus.github.io/pagy/extras/bootstrap
37
+ # require 'pagy/extras/bootstrap'
38
+
39
+ # Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination
40
+ # See https://ddnexus.github.io/pagy/extras/bulma
41
+ # require 'pagy/extras/bulma'
42
+
43
+ # Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination
44
+ # See https://ddnexus.github.io/pagy/extras/foundation
45
+ # require 'pagy/extras/foundation'
46
+
47
+ # Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination
48
+ # See https://ddnexus.github.io/pagy/extras/materialize
49
+ # require 'pagy/extras/materialize'
50
+
51
+ # Navs extra: Add nav_js and combo_nav_js javascript helpers
52
+ # Notice: the other frontend extras add their own framework-styled versions,
53
+ # so require this extra only if you need the unstyled version
54
+ # See https://ddnexus.github.io/pagy/extras/navs
55
+ # require 'pagy/extras/navs'
56
+
57
+ # Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination
58
+ # See https://ddnexus.github.io/pagy/extras/semantic
59
+ # require 'pagy/extras/semantic'
60
+
61
+ # UIkit extra: Add nav helper and templates for UIkit pagination
62
+ # See https://ddnexus.github.io/pagy/extras/uikit
63
+ # require 'pagy/extras/uikit'
64
+
65
+ # Multi size var used by the *_nav_js helpers
66
+ # See https://ddnexus.github.io/pagy/extras/navs#steps
67
+ # Pagy::VARS[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
68
+
69
+
70
+ # Feature Extras
71
+
72
+ # Headers extra: http response headers (and other helpers) useful for API pagination
73
+ # See http://ddnexus.github.io/pagy/extras/headers
74
+ require 'pagy/extras/headers'
75
+ # Pagy::VARS[:headers] = { page: 'Current-Page', items: 'Page-Items', count: 'Total-Count', pages: 'Total-Pages' } # default
76
+
77
+ # Support extra: Extra support for features like: incremental, infinite, auto-scroll pagination
78
+ # See https://ddnexus.github.io/pagy/extras/support
79
+ # require 'pagy/extras/support'
80
+
81
+ # Items extra: Allow the client to request a custom number of items per page with an optional selector UI
82
+ # See https://ddnexus.github.io/pagy/extras/items
83
+ # require 'pagy/extras/items'
84
+ # Pagy::VARS[:items_param] = :items # default
85
+ # Pagy::VARS[:max_items] = 100 # default
86
+
87
+ # Overflow extra: Allow for easy handling of overflowing pages
88
+ # See https://ddnexus.github.io/pagy/extras/overflow
89
+ require 'pagy/extras/overflow'
90
+ Pagy::VARS[:overflow] = :empty_page # default (other options: :last_page and :exception)
91
+
92
+ # Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
93
+ # See https://ddnexus.github.io/pagy/extras/metadata
94
+ # you must require the shared internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
95
+ # require 'pagy/extras/shared'
96
+ # require 'pagy/extras/metadata'
97
+ # For performance reason, you should explicitly set ONLY the metadata you use in the frontend
98
+ # Pagy::VARS[:metadata] = [:scaffold_url, :count, :page, :prev, :next, :last] # example
99
+
100
+ # Trim extra: Remove the page=1 param from links
101
+ # See https://ddnexus.github.io/pagy/extras/trim
102
+ # require 'pagy/extras/trim'
103
+
104
+
105
+
106
+ # Pagy Variables
107
+ # See https://ddnexus.github.io/pagy/api/pagy#variables
108
+ # All the Pagy::VARS are set for all the Pagy instances but can be overridden
109
+ # per instance by just passing them to Pagy.new or the #pagy controller method
110
+
111
+
112
+ # Instance variables
113
+ # See https://ddnexus.github.io/pagy/api/pagy#instance-variables
114
+ Pagy::VARS[:items] = 25 # default
115
+
116
+
117
+ # Other Variables
118
+ # See https://ddnexus.github.io/pagy/api/pagy#other-variables
119
+ # Pagy::VARS[:size] = [1,4,4,1] # default
120
+ # Pagy::VARS[:page_param] = :page # default
121
+ # Pagy::VARS[:params] = {} # default
122
+ # Pagy::VARS[:anchor] = '#anchor' # example
123
+ # Pagy::VARS[:link_extra] = 'data-remote="true"' # example
124
+
125
+
126
+ # Rails
127
+
128
+ # Rails: extras assets path required by the helpers that use javascript
129
+ # (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js)
130
+ # See https://ddnexus.github.io/pagy/extras#javascript
131
+ # Rails.application.config.assets.paths << Pagy.root.join('javascripts')
132
+
133
+
134
+ # I18n
135
+
136
+ # Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
137
+ # See https://ddnexus.github.io/pagy/api/frontend#i18n
138
+ # Notice: No need to configure anything in this section if your app uses only "en"
139
+ # or if you use the i18n extra below
140
+ #
141
+ # Examples:
142
+ # load the "de" built-in locale:
143
+ # Pagy::I18n.load(locale: 'de')
144
+ #
145
+ # load the "de" locale defined in the custom file at :filepath:
146
+ # Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml')
147
+ #
148
+ # load the "de", "en" and "es" built-in locales:
149
+ # (the first passed :locale will be used also as the default_locale)
150
+ # Pagy::I18n.load({locale: 'de'},
151
+ # {locale: 'en'},
152
+ # {locale: 'es'})
153
+ #
154
+ # load the "en" built-in locale, a custom "es" locale,
155
+ # and a totally custom locale complete with a custom :pluralize proc:
156
+ # (the first passed :locale will be used also as the default_locale)
157
+ # Pagy::I18n.load({locale: 'en'},
158
+ # {locale: 'es', filepath: 'path/to/pagy-es.yml'},
159
+ # {locale: 'xyz', # not built-in
160
+ # filepath: 'path/to/pagy-xyz.yml',
161
+ # pluralize: lambda{|count| ... } )
162
+
163
+
164
+ # I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
165
+ # than the default pagy internal i18n (see above)
166
+ # See https://ddnexus.github.io/pagy/extras/i18n
167
+ # require 'pagy/extras/i18n'
168
+
169
+ # Default i18n key
170
+ # Pagy::VARS[:i18n_key] = 'pagy.item_name' # default
@@ -0,0 +1,16 @@
1
+ namespace :commentui do
2
+ namespace :install do
3
+ desc "Copy initializers from commentui to the host application"
4
+ # rake commentui:install:initializers
5
+ task :initializers do
6
+ Dir.glob(File.expand_path('../../config/initializers/*.rb', __dir__)) do |file|
7
+ if File.exists?(File.expand_path(File.basename(file), 'config/initializers'))
8
+ print "NOTE: Initializer #{File.basename(file)} from commentui has been skipped. Initializer with the same name already exists.\n"
9
+ else
10
+ cp file, 'config/initializers', verbose: false
11
+ print "Copied initializer #{File.basename(file)} from commentui\n"
12
+ end
13
+ end
14
+ end ###
15
+ end ##
16
+ end #
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commentui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.01
5
+ platform: ruby
6
+ authors:
7
+ - Phuoc Phan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.1.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.1.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: pagy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.6.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.6.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: database_cleaner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.17.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.17.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.18.4
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.18.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.3.9
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.3.9
111
+ - !ruby/object:Gem::Dependency
112
+ name: puma
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 4.2.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 4.2.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: dotenv-rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 2.7.5
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 2.7.5
139
+ - !ruby/object:Gem::Dependency
140
+ name: factory_bot_rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 5.1.1
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 5.1.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: faker
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '2.6'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '2.6'
167
+ description: Allow user to post comment to your models by APIs
168
+ email:
169
+ - phanphuocdt@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - MIT-LICENSE
175
+ - README.md
176
+ - Rakefile
177
+ - app/assets/config/commentui_manifest.js
178
+ - app/assets/javascripts/commentui/application.js
179
+ - app/assets/stylesheets/commentui/application.css
180
+ - app/controllers/commentui/application_controller.rb
181
+ - app/controllers/commentui/comments_controller.rb
182
+ - app/models/commentui/application_record.rb
183
+ - app/models/commentui/comment.rb
184
+ - app/models/commentui/thread.rb
185
+ - config/initializers/commentui.rb
186
+ - config/routes.rb
187
+ - db/migrate/20191012044238_create_commentui_threads.rb
188
+ - db/migrate/20191012050923_create_commentui_comments.rb
189
+ - lib/commentui.rb
190
+ - lib/commentui/acts_as_commentuiable.rb
191
+ - lib/commentui/acts_as_commentuier.rb
192
+ - lib/commentui/engine.rb
193
+ - lib/commentui/version.rb
194
+ - lib/initializers/pagy.rb
195
+ - lib/tasks/commentui_tasks.rake
196
+ homepage: https://github.com/sportavn/commentui/
197
+ licenses:
198
+ - MIT
199
+ metadata: {}
200
+ post_install_message:
201
+ rdoc_options: []
202
+ require_paths:
203
+ - lib
204
+ required_ruby_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ requirements: []
215
+ rubyforge_project:
216
+ rubygems_version: 2.7.6.2
217
+ signing_key:
218
+ specification_version: 4
219
+ summary: A simple comment API gem
220
+ test_files: []