Module: IntenseDebateCommentsPortletHelper

Defined in:
lib/bcms_intensedebate/intense_debate_comments_portlet_helper.rb

Instance Method Summary collapse

Instance Method Details

#id_comments(obj, options = {}) ⇒ Object

Add the full comments list to a page.

Options

  • :url - The URL to the page. Optional.

  • :intensedebate_account - Probably already configured in the initializer. Optional.

  • :title - The title of the page. Optional.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bcms_intensedebate/intense_debate_comments_portlet_helper.rb', line 10

def id_comments(obj, options = {})
  options.symbolize_keys!
  options.assert_valid_keys(:intensedebate_account, :url, :title)
  options[:intensedebate_account] = acct_no unless options[:intensedebate_account]
  raise ArgumentError, "You must specify an IntenseDebate account number", options if options[:intensedebate_account].nil?
  raise "Intense Debate account no. doesn't look valid" unless options[:intensedebate_account] =~ /[\w]{32}/ 

  %Q|
<script type="text/javascript">
var idcomments_acct = "#{ options[:intensedebate_account] }";
var idcomments_post_id = "#{obj.class.name}-#{ obj.id }";
var idcomments_post_url #{ "='%s'" % options[:url] unless options[:url].nil? };
var idcomments_post_title #{ "='%s'" % options[:title] unless options[:title].nil? };
</script>
<span id="IDCommentsPostTitle" style="display:none"></span>
<script type="text/javascript" src="http://www.intensedebate.com/js/genericCommentWrapperV2.js"></script>
|
end

Add a comments counter and link to the item.

Options

  • :intensedebate_account - Probably already configured in the initializer. Optional.

  • :url - The URL. Optional, but required if obj is not RESTful.

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bcms_intensedebate/intense_debate_comments_portlet_helper.rb', line 35

def id_comments_link(obj, options = {})
  options.symbolize_keys!
  options.assert_valid_keys(:intensedebate_account, :url)
  options[:intensedebate_account] = acct_no unless options[:intensedebate_account]
  raise ArgumentError, "You must specify an IntenseDebate account number", options if options[:intensedebate_account].nil?
  raise "Intense Debate account no. doesn't look valid" unless options[:intensedebate_account] =~ /[\w]{32}/

  %Q|
<script type="text/javascript">
var idcomments_acct = "#{ options[:intensedebate_account] }";
var idcomments_post_id = "#{ obj.id }";
var idcomments_post_url = "#{ options[:url] ? options[:url] : self.send( :"#{obj.class.to_s.underscore}_path", obj ) }";
</script>
<script type="text/javascript" src="http://www.intensedebate.com/js/genericLinkWrapperV2.js"></script>
|
end