bcms_intensedebate 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ # IntenseDebate plugin for BrowserCMS
2
+
3
+ Provides IntenseDebate commenting features for your BrowserCMS site. It gives you:
4
+
5
+ * A portlet to use on arbitrary pages,
6
+ * View helpers you can use to emit IntenseDebate API calls in a more precise fashion in your views or content blocks.
7
+
8
+ ## Installation
9
+
10
+ 1. Create an intensedebate.com site key for your specific URL,
11
+ 2. Follow the generic module instructions here: http://guides.browsercms.org/installing_modules.html
12
+ 3. Edit BROWSER_CMS_ROOT/config/initializer/intense_debate_settings.rb to include your site key. Restart your rails app.
13
+ 4. There are no migrations to run.
14
+
15
+ ## Notes
16
+
17
+ * Each IntenseDebateCommentsPortlet generates a unique idcomments_post_id value to be used by the IntenseDebate API. You may want to reuse or generate a new portlet for every page depending on your commenting goals.
18
+ * Look in lib/bcms_intensedebate/intense_debate_comments_portlet_helper.rb for full docs, or just generate the rdoc for this plugin.
19
+
20
+ ## Uninstallation
21
+
22
+ Nothing special. Be sure to remove calls to id_comments and id_comments_link in your views.
23
+
24
+ ## Author
25
+
26
+ Dan Collis-Puro
27
+ djcp@cyber.law.harvard.edu, dan@collispuro.com
28
+ Created for http://www.lawlab.org/
29
+
30
+ ## License
31
+
32
+ LGPL
33
+
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,7 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+
4
+ def test_helper_djcp
5
+ "djcp foo bar"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class IntenseDebateCommentsPortlet < Portlet
2
+
3
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
4
+ enable_template_editor false
5
+
6
+ def render
7
+ # Your Code Goes Here
8
+ end
9
+
10
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
5
+ <title><%= page_title %></title>
6
+ <%= yield :html_head %>
7
+ </head>
8
+ <body style="margin: 0; padding: 0; text-align: center;">
9
+ <%= cms_toolbar %>
10
+ <div id="wrapper" style="width: 700px; margin: 0 auto; text-align: left; padding: 30px">
11
+ Breadcrumbs: <%= render_breadcrumbs %>
12
+ Main Menu: <%= render_menu %>
13
+ <h1><%= page_title %></h1>
14
+ <%= container :main %>
15
+ </div>
16
+ </body>
17
+ </html>
@@ -0,0 +1,2 @@
1
+ <%= f.cms_text_field :name, :instructions => 'The name is only used to identify this portlet in the backend.' %>
2
+ <%= f.cms_template_editor :template %>
@@ -0,0 +1 @@
1
+ <%= id_comments @portlet %>
@@ -0,0 +1 @@
1
+ ENV['INTENSEDEBATE_ACCOUNT'] = 'Your intense debate site account / key here'
@@ -0,0 +1,3 @@
1
+ require 'bcms_intensedebate/routes'
2
+ require 'bcms_intensedebate/intense_debate_comments_portlet_helper'
3
+ ActionView::Base.send(:include, IntenseDebateCommentsPortletHelper)
@@ -0,0 +1,59 @@
1
+ module IntenseDebateCommentsPortletHelper
2
+
3
+ # Add the full comments list to a page.
4
+ #
5
+ # *Options*
6
+ # * :url - The URL to the page. Optional.
7
+ # * :intensedebate_account - Probably already configured in the initializer. Optional.
8
+ # * :title - The title of the page. Optional.
9
+ #
10
+ def id_comments(obj, options = {})
11
+ options.symbolize_keys!
12
+ options.assert_valid_keys(:intensedebate_account, :url, :title)
13
+ options[:intensedebate_account] = acct_no unless options[:intensedebate_account]
14
+ raise ArgumentError, "You must specify an IntenseDebate account number", options if options[:intensedebate_account].nil?
15
+ raise "Intense Debate account no. doesn't look valid" unless options[:intensedebate_account] =~ /[\w]{32}/
16
+
17
+ %Q|
18
+ <script type="text/javascript">
19
+ var idcomments_acct = "#{ options[:intensedebate_account] }";
20
+ var idcomments_post_id = "#{obj.class.name}-#{ obj.id }";
21
+ var idcomments_post_url #{ "='%s'" % options[:url] unless options[:url].nil? };
22
+ var idcomments_post_title #{ "='%s'" % options[:title] unless options[:title].nil? };
23
+ </script>
24
+ <span id="IDCommentsPostTitle" style="display:none"></span>
25
+ <script type="text/javascript" src="http://www.intensedebate.com/js/genericCommentWrapperV2.js"></script>
26
+ |
27
+ end
28
+
29
+ # Add a comments counter and link to the item.
30
+ #
31
+ # *Options*
32
+ # * :intensedebate_account - Probably already configured in the initializer. Optional.
33
+ # * :url - The URL. Optional, but required if obj is not RESTful.
34
+ #
35
+ def id_comments_link(obj, options = {})
36
+ options.symbolize_keys!
37
+ options.assert_valid_keys(:intensedebate_account, :url)
38
+ options[:intensedebate_account] = acct_no unless options[:intensedebate_account]
39
+ raise ArgumentError, "You must specify an IntenseDebate account number", options if options[:intensedebate_account].nil?
40
+ raise "Intense Debate account no. doesn't look valid" unless options[:intensedebate_account] =~ /[\w]{32}/
41
+
42
+ %Q|
43
+ <script type="text/javascript">
44
+ var idcomments_acct = "#{ options[:intensedebate_account] }";
45
+ var idcomments_post_id = "#{ obj.id }";
46
+ var idcomments_post_url = "#{ options[:url] ? options[:url] : self.send( :"#{obj.class.to_s.underscore}_path", obj ) }";
47
+ </script>
48
+ <script type="text/javascript" src="http://www.intensedebate.com/js/genericLinkWrapperV2.js"></script>
49
+ |
50
+ end
51
+
52
+ protected
53
+
54
+ def acct_no
55
+ raise "Please set ENV['INTENSEDEBATE_ACCOUNT'] in config/initializers/intense_debate_settings.rb" unless defined?(ENV['INTENSEDEBATE_ACCOUNT'])
56
+ ENV['INTENSEDEBATE_ACCOUNT']
57
+ end
58
+
59
+ end
@@ -0,0 +1,7 @@
1
+ module Cms::Routes
2
+ def routes_for_bcms_intensedebate
3
+ namespace(:cms) do |cms|
4
+ #cms.content_blocks :intensedebates
5
+ end
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ Use this directory to add public files that should copied from the gem into the project.
@@ -0,0 +1,5 @@
1
+ gem_root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2
+ Cms.add_to_rails_paths gem_root
3
+ Cms.add_generator_paths gem_root, "db/migrate/[0-9]*_*.rb"
4
+ Cms.add_generator_paths gem_root, "public/bcms/intensedebate/**/*"
5
+ Cms.add_generator_paths gem_root, "config/initializers/intense_debate_settings.rb"
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bcms_intensedebate
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
+ platform: ruby
12
+ authors:
13
+ - Dan Collis-Puro
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-22 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description:
23
+ email: dan@collispuro.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.markdown
30
+ files:
31
+ - app/portlets/intense_debate_comments_portlet.rb
32
+ - app/helpers/application_helper.rb
33
+ - app/views/portlets/intense_debate_comments/_form.html.erb
34
+ - app/views/portlets/intense_debate_comments/render.html.erb
35
+ - app/views/layouts/templates/default.html.erb
36
+ - app/controllers/application_controller.rb
37
+ - lib/bcms_intensedebate.rb
38
+ - lib/bcms_intensedebate/routes.rb
39
+ - lib/bcms_intensedebate/intense_debate_comments_portlet_helper.rb
40
+ - config/initializers/intense_debate_settings.rb
41
+ - rails/init.rb
42
+ - public/bcms/intensedebate/README
43
+ - README.markdown
44
+ has_rdoc: true
45
+ homepage: http://www.collispuro.com
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project: bcms_intensedebate
74
+ rubygems_version: 1.3.7
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Integrate IntenseDebate commenting into your BrowserCMS site
78
+ test_files: []
79
+