bcms_page_comments 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/COPYRIGHT.txt +23 -0
  2. data/GPL.txt +674 -0
  3. data/Gemfile +6 -0
  4. data/README.markdown +1 -2
  5. data/app/assets/javascripts/bcms_page_comments/application.js +15 -0
  6. data/app/assets/stylesheets/application.css +13 -0
  7. data/app/assets/stylesheets/bcms_page_comments/application.css +13 -0
  8. data/app/controllers/bcms_page_comments/application_controller.rb +4 -0
  9. data/app/controllers/bcms_page_comments/page_comments_controller.rb +4 -0
  10. data/app/controllers/page_comments_controller.rb +1 -1
  11. data/app/helpers/bcms_page_comments/application_helper.rb +4 -0
  12. data/app/models/bcms_page_comments/page_comment.rb +12 -0
  13. data/app/portlets/most_commented_on_portlet.rb +5 -5
  14. data/app/portlets/page_comments_portlet.rb +4 -3
  15. data/app/views/{cms → bcms_page_comments}/page_comments/_form.html.erb +1 -1
  16. data/app/views/{cms → bcms_page_comments}/page_comments/render.html.erb +0 -0
  17. data/app/views/portlets/page_comments/_form.html.erb +1 -1
  18. data/app/views/portlets/page_comments/render.html.erb +1 -2
  19. data/config/routes.rb +3 -0
  20. data/db/bcms_page_comments.seeds.rb +1 -0
  21. data/db/migrate/20090417155756_create_page_comments.rb +1 -10
  22. data/db/migrate/20120703173145_update_to_2_0_0.rb +9 -0
  23. data/lib/bcms_page_comments.rb +5 -1
  24. data/lib/bcms_page_comments/engine.rb +11 -0
  25. data/lib/bcms_page_comments/route_extensions.rb +8 -0
  26. data/lib/bcms_page_comments/version.rb +3 -0
  27. data/lib/generators/bcms_page_comments/install/USAGE +3 -0
  28. data/lib/generators/bcms_page_comments/install/install_generator.rb +21 -0
  29. data/lib/tasks/bcms_page_comments_tasks.rake +4 -0
  30. metadata +80 -49
  31. data/app/controllers/application_controller.rb +0 -10
  32. data/app/controllers/cms/page_comments_controller.rb +0 -2
  33. data/app/helpers/application_helper.rb +0 -3
  34. data/app/models/page_comment.rb +0 -11
  35. data/lib/bcms_page_comments/routes.rb +0 -13
  36. data/rails/init.rb +0 -3
  37. data/test/performance/browsing_test.rb +0 -9
  38. data/test/test_helper.rb +0 -38
  39. data/test/unit/portlets/most_commented_on_portlet_test.rb +0 -62
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "jquery-rails"
6
+ gem 'sqlite3'
@@ -11,8 +11,7 @@ To install this module, do the following:
11
11
  ### A. Build and install the gem from source
12
12
  This assumes you have the latest copy of the code from github on your machine.
13
13
 
14
- gem build bcms_page_comments.gemspec
15
- sudo gem install bcms_page_comments-1.0.0.gem
14
+ rake install
16
15
 
17
16
  At this point, the Page Comments gem should be installed as a gem on your system, and can be added to your projects.
18
17
 
@@ -0,0 +1,15 @@
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 vendor/assets/javascripts of plugins, if any, 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
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,13 @@
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module BcmsPageComments
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BcmsPageComments
2
+ class PageCommentsController < Cms::ContentBlockController
3
+ end
4
+ end
@@ -3,7 +3,7 @@ class PageCommentsController < Cms::ApplicationController
3
3
  before_filter :verify_user_is_logged_in
4
4
 
5
5
  def create
6
- @page_comment = PageComment.new(params[:page_comment])
6
+ @page_comment = BcmsPageComments::PageComment.new(params[:page_comment])
7
7
  @page_comment.ip = request.remote_ip
8
8
  if @page_comment.save
9
9
  flash[:notice] = "Comment was created"
@@ -0,0 +1,4 @@
1
+ module BcmsPageComments
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ module BcmsPageComments
2
+ class PageComment < ActiveRecord::Base
3
+ acts_as_content_block
4
+ belongs_to :page, :class_name=>"Cms::Page"
5
+
6
+ validates_presence_of :page_id
7
+ attr_accessible :page
8
+
9
+ scope :for_page, lambda{|p| {:conditions => ["#{table_name}.page_id = ?", p.id]}}
10
+
11
+ end
12
+ end
@@ -1,14 +1,14 @@
1
- class MostCommentedOnPortlet < Portlet
1
+ class MostCommentedOnPortlet < Cms::Portlet
2
2
 
3
3
  def render
4
4
  @pages = most_popular_pages(@portlet.number_to_show)
5
5
  end
6
6
 
7
7
  def most_popular_pages (limit)
8
- Page.find(:all,
9
- :select => 'pages.*, COUNT(page_comments.id) AS comments_count',
10
- :joins => 'INNER JOIN page_comments ON page_comments.page_id = pages.id',
11
- :group => 'pages.id',
8
+ Cms::Page.find(:all,
9
+ :select => "#{Cms::Page.table_name}.*, COUNT(#{BcmsPageComments::PageComment.table_name}.id) AS comments_count",
10
+ :joins => "INNER JOIN #{BcmsPageComments::PageComment.table_name} ON #{BcmsPageComments::PageComment.table_name}.page_id = #{Cms::Page.table_name}.id",
11
+ :group => "#{Cms::Page.table_name}.id",
12
12
  :limit => limit,
13
13
  :order => "comments_count desc")
14
14
 
@@ -1,13 +1,14 @@
1
- class PageCommentsPortlet < Portlet
1
+ class PageCommentsPortlet < Cms::Portlet
2
+ enable_template_editor true
2
3
 
3
4
  def render
4
5
  @page = @controller.instance_variable_get("@page")
5
6
  if @page
6
7
  # The list of comments to show
7
- @page_comments = PageComment.for_page(@page).all(:order => "created_at desc")
8
+ @page_comments = BcmsPageComments::PageComment.for_page(@page).all(:order => "created_at desc")
8
9
 
9
10
  # For the form to create a new comment
10
- @page_comment = PageComment.new(:page => @page)
11
+ @page_comment = BcmsPageComments::PageComment.new(:page => @page)
11
12
  end
12
13
  end
13
14
 
@@ -1,4 +1,4 @@
1
- <%= f.cms_drop_down :page_id, Page.all(:order => "path").map{|p| ["#{p.path} (#{p.name})", p.id]}%>
1
+ <%= f.cms_drop_down :page_id, Cms::Page.all(:order => "path").map{|p| ["#{p.path} (#{p.name})", p.id]}%>
2
2
  <%= f.cms_text_field :name %>
3
3
  <%= f.cms_text_field :email %>
4
4
  <%= f.cms_text_field :url %>
@@ -1,2 +1,2 @@
1
1
  <%= f.cms_text_field :name %>
2
- <%= f.cms_text_area :template, :default_value => PageCommentsPortlet.default_template %>
2
+ <%= f.cms_template_editor :template %>
@@ -10,9 +10,8 @@
10
10
  </div>
11
11
  <hr style="margin: 10px 0"/>
12
12
  <% end %>
13
-
14
13
  <% unless current_user.guest? %>
15
- <% form_for @page_comment do |f| %>
14
+ <%= form_for @page_comment do |f| %>
16
15
  <%= f.hidden_field :page_id %>
17
16
  <%= f.label :name %>
18
17
  <%= f.text_field :name %>
@@ -0,0 +1,3 @@
1
+ BcmsPageComments::Engine.routes.draw do
2
+ content_blocks :page_comments
3
+ end
@@ -0,0 +1 @@
1
+ Cms::ContentType.create!(:name => "BcmsPageComments::PageComment", :group_name => "Comments")
@@ -1,5 +1,5 @@
1
1
  class CreatePageComments < ActiveRecord::Migration
2
- def self.up
2
+ def change
3
3
  create_versioned_table :page_comments do |t|
4
4
  t.belongs_to :page
5
5
  t.string :name
@@ -8,14 +8,5 @@ class CreatePageComments < ActiveRecord::Migration
8
8
  t.text :body
9
9
  t.string :ip
10
10
  end
11
-
12
-
13
- ContentType.create!(:name => "PageComment", :group_name => "Comments")
14
- end
15
-
16
- def self.down
17
- ContentType.delete_all(['name = ?', 'PageComment'])
18
- drop_table :page_comment_versions
19
- drop_table :page_comments
20
11
  end
21
12
  end
@@ -0,0 +1,9 @@
1
+ require 'cms/upgrades/v3_5_0'
2
+
3
+ class UpdateTo200 < ActiveRecord::Migration
4
+ def change
5
+ v3_5_0_apply_namespace_to_block("BcmsPageComments", "PageComment")
6
+ end
7
+ end
8
+
9
+
@@ -1 +1,5 @@
1
- require 'bcms_page_comments/routes'
1
+ require "bcms_page_comments/engine"
2
+ require 'bcms_page_comments/route_extensions'
3
+
4
+ module BcmsPageComments
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'browsercms'
2
+ module BcmsPageComments
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace BcmsPageComments
5
+ include Cms::Module
6
+
7
+ initializer 'bcms_page_comments.route_extensions', :after => 'action_dispatch.prepare_dispatcher' do |app|
8
+ ActionDispatch::Routing::Mapper.send :include, BcmsPageComments::RouteExtensions
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module BcmsPageComments::RouteExtensions
2
+ def mount_bcms_page_comments
3
+ mount BcmsPageComments::Engine => "/bcms_page_comments"
4
+ post '/page_comments' => 'page_comments#create', :as=>'page_comments'
5
+ end
6
+
7
+ alias :routes_for_bcms_page_comments :mount_bcms_page_comments
8
+ end
@@ -0,0 +1,3 @@
1
+ module BcmsPageComments
2
+ VERSION = "2.0.0"
3
+ end
@@ -0,0 +1,3 @@
1
+ Installs bcms_page_comments into a project. Typically invoked indirectly via:
2
+
3
+ rails generate cms:install bcms_page_comments
@@ -0,0 +1,21 @@
1
+ require 'cms/module_installation'
2
+
3
+ class BcmsPageComments::InstallGenerator < Cms::ModuleInstallation
4
+ add_migrations_directory_to_source_root __FILE__
5
+
6
+
7
+ def copy_migrations
8
+ rake 'bcms_page_comments:install:migrations'
9
+ end
10
+
11
+ # Uncomment to add module specific seed data to a project.
12
+ def add_seed_data_to_project
13
+ copy_file "../bcms_page_comments.seeds.rb", "db/bcms_page_comments.seeds.rb"
14
+ append_to_file "db/seeds.rb", "\nload File.expand_path('../bcms_page_comments.seeds.rb', __FILE__)\n"
15
+ end
16
+
17
+ def add_routes
18
+ route 'mount_bcms_page_comments'
19
+ end
20
+
21
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bcms_page_comments do
3
+ # # Task goes here
4
+ # end
metadata CHANGED
@@ -1,74 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bcms_page_comments
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - BrowserMedia
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-07-02 00:00:00 -04:00
13
- default_executable:
14
- dependencies: []
15
-
16
- description: The Page Comments Module for BrowserCMS
12
+ date: 2012-07-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: browsercms
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 3.6.0
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 3.5.0
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 3.6.0
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 3.5.0
36
+ description:
17
37
  email: github@browsermedia.com
18
38
  executables: []
19
-
20
39
  extensions: []
21
-
22
- extra_rdoc_files:
23
- - LICENSE.txt
40
+ extra_rdoc_files:
24
41
  - README.markdown
25
- files:
26
- - app/controllers/application_controller.rb
27
- - app/controllers/cms/page_comments_controller.rb
42
+ files:
43
+ - app/assets/javascripts/bcms_page_comments/application.js
44
+ - app/assets/stylesheets/application.css
45
+ - app/assets/stylesheets/bcms_page_comments/application.css
46
+ - app/controllers/bcms_page_comments/application_controller.rb
47
+ - app/controllers/bcms_page_comments/page_comments_controller.rb
28
48
  - app/controllers/page_comments_controller.rb
29
- - app/helpers/application_helper.rb
30
- - app/models/page_comment.rb
49
+ - app/helpers/bcms_page_comments/application_helper.rb
50
+ - app/models/bcms_page_comments/page_comment.rb
31
51
  - app/portlets/most_commented_on_portlet.rb
32
52
  - app/portlets/page_comments_portlet.rb
33
- - app/views/cms/page_comments/_form.html.erb
34
- - app/views/cms/page_comments/render.html.erb
53
+ - app/views/bcms_page_comments/page_comments/_form.html.erb
54
+ - app/views/bcms_page_comments/page_comments/render.html.erb
35
55
  - app/views/portlets/most_commented_on/_form.html.erb
36
56
  - app/views/portlets/most_commented_on/render.html.erb
37
57
  - app/views/portlets/page_comments/_form.html.erb
38
58
  - app/views/portlets/page_comments/render.html.erb
59
+ - config/routes.rb
60
+ - db/bcms_page_comments.seeds.rb
39
61
  - db/migrate/20090417155756_create_page_comments.rb
62
+ - db/migrate/20120703173145_update_to_2_0_0.rb
63
+ - lib/bcms_page_comments/engine.rb
64
+ - lib/bcms_page_comments/route_extensions.rb
65
+ - lib/bcms_page_comments/version.rb
40
66
  - lib/bcms_page_comments.rb
41
- - lib/bcms_page_comments/routes.rb
42
- - rails/init.rb
43
- - LICENSE.txt
67
+ - lib/generators/bcms_page_comments/install/install_generator.rb
68
+ - lib/generators/bcms_page_comments/install/USAGE
69
+ - lib/tasks/bcms_page_comments_tasks.rake
44
70
  - README.markdown
45
- has_rdoc: true
46
- homepage: http://browsercms.org
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - COPYRIGHT.txt
74
+ - GPL.txt
75
+ homepage: http://www.github.com/browsermedia/bcms_page_comments
76
+ licenses: []
47
77
  post_install_message:
48
- rdoc_options:
49
- - --charset=UTF-8
50
- require_paths:
78
+ rdoc_options: []
79
+ require_paths:
51
80
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- version:
58
- required_rubygems_version: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: "0"
63
- version:
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ segments:
88
+ - 0
89
+ hash: -3264692369673889683
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ segments:
97
+ - 0
98
+ hash: -3264692369673889683
64
99
  requirements: []
65
-
66
- rubyforge_project: browsercms
67
- rubygems_version: 1.3.1
100
+ rubyforge_project: bcms_page_comments
101
+ rubygems_version: 1.8.24
68
102
  signing_key:
69
- specification_version: 2
103
+ specification_version: 3
70
104
  summary: The Page Comments Module for BrowserCMS
71
- test_files:
72
- - test/performance/browsing_test.rb
73
- - test/test_helper.rb
74
- - test/unit/portlets/most_commented_on_portlet_test.rb
105
+ test_files: []
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- # filter_parameter_logging :password
10
- end