ecm_comments 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: '05841a0b21b7afebeb8717cab055e7bd4b475365'
4
+ data.tar.gz: bec7b24428a66751e65291cd5e1679dbe939d997
5
+ SHA512:
6
+ metadata.gz: 84af730847fb0cbc4c478caa8c1be41ce9f498c2e5663b891b189e39d1ff2e1ccbc01fdb548f0e225aed4574d3a6cf9a72615be99c4b733617b7bc5673052600
7
+ data.tar.gz: c2dfdba528e6658da8729679eba6e2e1890e1f10781fb47f51666ae12c05cd83ad61123306d1f5f0f8d094776fdae44e5ca82e6dc234d0e7ecc53190cddd906c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Roberto Vasquez Angel
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Ecm::Comments
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
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 = 'Ecm::Comments'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+ Bundler::GemHelper.install_tasks
@@ -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.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,14 @@
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. It is generally better to create a new file per style scope.
11
+ *
12
+ *= require_tree .
13
+ *= require_self
14
+ */
@@ -0,0 +1,6 @@
1
+ module Ecm
2
+ module Comments
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,44 @@
1
+ module Ecm
2
+ module Comments
3
+ class CommentsController < Ecm::Comments::Configuration.base_controller.constantize
4
+ include Controller::ResourceConcern
5
+ include Controller::ResourceUrlsConcern
6
+ include Controller::ResourceInflectionsConcern
7
+ include Controller::RestActionsConcern
8
+
9
+ helper Twitter::Bootstrap::Components::Rails::V3::ComponentsHelper
10
+
11
+ before_action :store_original_location, only: [:new, :create]
12
+
13
+ def self.resource_class
14
+ Ecm::Comments::Comment
15
+ end
16
+
17
+ private
18
+
19
+ def after_create_location
20
+ if @resource.errors.empty?
21
+ original_location!
22
+ else
23
+ original_location
24
+ end
25
+ end
26
+
27
+ def permitted_params
28
+ params.require(:comment).permit(:name, :email, :body, :commentable_type, :commentable_id)
29
+ end
30
+
31
+ def store_original_location
32
+ session[:original_location] = request.referer unless request.referer == request.url
33
+ end
34
+
35
+ def original_location
36
+ session[:original_location]
37
+ end
38
+
39
+ def original_location!
40
+ session.delete(:original_location)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,10 @@
1
+ module Ecm
2
+ module Comments
3
+ module ApplicationHelper
4
+ def commentable(resource)
5
+ @comment = Ecm::Comments::Comment.new(commentable_type: resource.class, commentable_id: resource.id)
6
+ render partial: 'ecm/comments/commentable', locals: { resource: resource }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,72 @@
1
+ module Ecm::Comments
2
+ class Comment < ActiveRecord::Base
3
+ belongs_to :commentable, polymorphic: true
4
+
5
+ validates :name, presence: true
6
+ validates :email, presence: true
7
+ validates :body, presence: true
8
+
9
+ module Userstamps
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ belongs_to :creator, foreign_key: 'created_by_id', class_name: Ecm::Comments.creator_class_name, optional: true
14
+ belongs_to :updater, foreign_key: 'updated_by_id', class_name: Ecm::Comments.creator_class_name, optional: true
15
+
16
+ after_initialize :set_creator, if: :new_record?
17
+ after_initialize :set_updater, if: :persisted?
18
+ end
19
+
20
+ private
21
+
22
+ def set_creator
23
+ self.creator = Ecm::UserArea.current_user
24
+ end
25
+
26
+ def set_updater
27
+ self.updater = Ecm::UserArea.current_user
28
+ end
29
+ end
30
+
31
+ include Userstamps
32
+
33
+ module IpTracking
34
+ extend ActiveSupport::Concern
35
+
36
+ included do
37
+ validates :created_by_ip_address, presence: true, if: :new_record?
38
+ validates :updated_by_ip_address, presence: true, if: :persisted?
39
+
40
+ after_initialize :set_created_by_ip_address, if: :new_record?
41
+ after_initialize :set_updated_by_ip_address, if: :persisted?
42
+ end
43
+
44
+ private
45
+
46
+ def set_created_by_ip_address
47
+ self.created_by_ip_address = Ecm::Core.remote_ip
48
+ end
49
+
50
+ def set_updated_by_ip_address
51
+ self.updated_by_ip_address = Ecm::Core.remote_ip
52
+ end
53
+ end
54
+
55
+ include IpTracking
56
+
57
+ module SpamProtection
58
+ attr_accessor :nickname
59
+
60
+ def save
61
+ if nickname.present?
62
+ valid?
63
+ return true
64
+ else
65
+ super
66
+ end
67
+ end
68
+ end
69
+
70
+ prepend SpamProtection
71
+ end
72
+ end
@@ -0,0 +1,8 @@
1
+ #comments
2
+ %h2= "#{Ecm::Comments::Comment.model_name.human(count: :other)} (#{resource.comments.count})"
3
+ = render resource.comments.order(created_at: :desc)
4
+
5
+ %h2= t('.new', model_name: @comment.class.model_name.human)
6
+ = simple_form_for(@comment, url: ecm_comments.url_for(@comment)) do |f|
7
+ = render partial: 'ecm/comments/comments/form_errors', locals: { resource: @comment } if @comment.errors.any?
8
+ = render partial: 'ecm/comments/comments/form', locals: { form: f }
@@ -0,0 +1,7 @@
1
+ %div{ class: dom_id(comment) }
2
+ %blockquote
3
+ %p.comment-body= comment.body
4
+ %footer
5
+ %span.comment-creator= comment.name
6
+ |
7
+ %span.comment-created-at= l(comment.created_at)
@@ -0,0 +1,7 @@
1
+ = form.input :commentable_type, as: :hidden
2
+ = form.input :commentable_id, as: :hidden
3
+ = form.input :name
4
+ = form.input :email
5
+ = form.input :nickname, input_html: { style: 'display: none;' }, label_html: { style: 'display: none;' }
6
+ = form.input :body
7
+ = form.submit class: 'btn btn-primary'
@@ -0,0 +1,5 @@
1
+ = bootstrap_alert(context: :danger, class: 'error-explanation') do
2
+ .error-heading= t('errors.template.header', count: resource.errors.count, model: resource.class.model_name.human)
3
+ %ul
4
+ - resource.errors.full_messages.each do |msg|
5
+ %li= msg
@@ -0,0 +1,5 @@
1
+ %h1= t(".title")
2
+
3
+ = simple_form_for(@resource, url: ecm_comments.url_for(@resource)) do |f|
4
+ = render partial: 'form_errors', locals: { resource: @resource } if @resource.errors.any?
5
+ = render partial: 'form', locals: { form: f }
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Comments</title>
5
+ <%= stylesheet_link_tag "ecm/comments/application", media: "all" %>
6
+ <%= javascript_include_tag "ecm/comments/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,11 @@
1
+ de:
2
+ activerecord:
3
+ models:
4
+ ecm/comments/comment:
5
+ one: Kommentar
6
+ other: Kommentare
7
+ ecm:
8
+ comments:
9
+ commentable:
10
+ comments_information: "%{comments_count} Kommentare"
11
+ new: "Kommentieren"
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Ecm::Comments::Engine.routes.draw do
2
+ localized do
3
+ scope :ecm_comments_engine do
4
+ resources :comments, only: [:new, :create]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ class CreateEcmCommentsComments < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :ecm_comments_comments do |t|
4
+ t.string :commentable_type
5
+ t.integer :commentable_id
6
+ t.string :name
7
+ t.string :homepage
8
+ t.string :email
9
+ t.text :body
10
+ t.integer :created_by_id
11
+ t.string :created_by_ip_address
12
+ t.integer :updated_by_id
13
+ t.string :updated_by_ip_address
14
+
15
+ t.timestamps null: false
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require 'active_support/core_ext/module/delegation'
2
+ require 'active_support/core_ext/module/attribute_accessors'
3
+ require 'active_support/hash_with_indifferent_access'
4
+
5
+ module Ecm
6
+ module Comments
7
+ module Configuration
8
+ def configure
9
+ yield self
10
+ end
11
+
12
+ mattr_accessor(:base_controller) { '::FrontendController' }
13
+ mattr_accessor(:creator_class_name) { 'User' }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module Ecm
2
+ module Comments
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Ecm::Comments
5
+ end
6
+
7
+ end
8
+ end
9
+
10
+
11
+
@@ -0,0 +1,5 @@
1
+ module Ecm
2
+ module Comments
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'ecm/comments/configuration'
2
+
3
+ module Ecm
4
+ module Comments
5
+ extend Configuration
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'twitter_bootstrap_components_rails'
2
+
3
+ require "ecm/comments"
4
+ require "ecm/comments/engine"
@@ -0,0 +1,21 @@
1
+ module Ecm
2
+ module Comments
3
+ module Generators
4
+ class InstallGenerator < Rails::Generators::Base
5
+ desc 'Generates the initializer'
6
+
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def generate_initializer
10
+ copy_file 'initializer.rb', 'config/initializers/ecm_comments.rb'
11
+ end
12
+
13
+ def generate_routes
14
+ inject_into_file 'config/routes.rb', before: "\nend" do
15
+ File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ Ecm::Comments.configure do |config|
2
+ # Set the base controller for the controllers
3
+ #
4
+ # Default: config.base_controller = '::FrontendController'
5
+ #
6
+ config.base_controller = '::FrontendController'
7
+
8
+ config.creator_class_name = 'User'
9
+ end
@@ -0,0 +1,3 @@
1
+
2
+
3
+ mount Ecm::Comments::Engine, at: '/'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :comments do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ecm_comments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Vasquez Angel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-31 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: twitter-bootstrap-components-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Ecm::Comments Module.
42
+ email:
43
+ - roberto@vasquez-angel.de
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.rdoc
50
+ - Rakefile
51
+ - app/assets/javascripts/ecm/comments/application.js
52
+ - app/assets/stylesheets/ecm/comments/application.css
53
+ - app/controllers/ecm/comments/application_controller.rb
54
+ - app/controllers/ecm/comments/comments_controller.rb
55
+ - app/helpers/ecm/comments/application_helper.rb
56
+ - app/models/ecm/comments/comment.rb
57
+ - app/views/ecm/comments/_commentable.haml
58
+ - app/views/ecm/comments/comments/_comment.haml
59
+ - app/views/ecm/comments/comments/_form.haml
60
+ - app/views/ecm/comments/comments/_form_errors.haml
61
+ - app/views/ecm/comments/comments/new.haml
62
+ - app/views/layouts/ecm/comments/application.html.erb
63
+ - config/locales/de.yml
64
+ - config/routes.rb
65
+ - db/migrate/20160214134347_create_ecm_comments_comments.rb
66
+ - lib/ecm/comments.rb
67
+ - lib/ecm/comments/configuration.rb
68
+ - lib/ecm/comments/engine.rb
69
+ - lib/ecm/comments/version.rb
70
+ - lib/ecm_comments.rb
71
+ - lib/generators/ecm/comments/install/install_generator.rb
72
+ - lib/generators/ecm/comments/install/templates/initializer.rb
73
+ - lib/generators/ecm/comments/install/templates/routes.source
74
+ - lib/tasks/ecm/comments_tasks.rake
75
+ homepage: https://github.com/robotex82/ecm_comments
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.6.11
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Ecm::Comments.
99
+ test_files: []