Module: ActiveRecord::Acts::Disqusable::InstanceMethods
- Defined in:
- lib/acts_as_disqusable.rb
Instance Method Summary collapse
- #comment_count ⇒ Object
- #comment_form ⇒ Object
-
#comments(opts = {}) ⇒ Object
limit — Number of entries that should be included in the response.
- #thread ⇒ Object
- #thread_identifier ⇒ Object
Instance Method Details
#comment_count ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/acts_as_disqusable.rb', line 122 def comment_count if self.respond_to? self.class.thread_column and self.send(self.class.thread_column) Disqus::Forum.posts_count(self.send(self.class.thread_column), self.class.forum_api_key) else # two separate calls Disqus::Thread.find_or_create(title, slug).posts_count end end |
#comment_form ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/acts_as_disqusable.rb', line 130 def comment_form forum_shortname = self.class.forum_shortname thread_indentifier = self.thread_identifier url = 'http://disqus.com/api/reply.js?' + "forum_shortname=#{forum_shortname}&" + "thread_identifier=#{thread_identifier}" s = '<div id="dsq-reply">' s << '<script type="text/javascript" src="%s"></script>' % url s << '</div>' return s end |
#comments(opts = {}) ⇒ Object
limit — Number of entries that should be included in the response. Default is 25. start — Starting point for the query. Default is 0. filter — Type of entries that should be returned (new, spam or killed). exclude — Type of entries that should be excluded from the response (new, spam or killed).
114 115 116 117 118 119 120 |
# File 'lib/acts_as_disqusable.rb', line 114 def comments(opts={}) if self.respond_to? self.class.thread_column and self.send(self.class.thread_column) Disqus::Thread.posts(self.send(self.class.thread_column), opts) else # two separate calls Disqus::Thread.find_or_create(title, slug).posts(opts) end end |
#thread ⇒ Object
106 107 108 |
# File 'lib/acts_as_disqusable.rb', line 106 def thread Disqus::Thread.find_or_create(self.send(self.class.title_column), self.thread_identifier) end |
#thread_identifier ⇒ Object
102 103 104 |
# File 'lib/acts_as_disqusable.rb', line 102 def thread_identifier self.class.prefix + self.send(self.class.slug_column) end |