Parent

Included Modules

Files

Thoth::Comment

Public Class Methods

recent(page = 1, limit = 10) click to toggle source

Recently-posted comments (up to limit) sorted in reverse order by creation time.

# File lib/thoth/model/comment.rb, line 63
def self.recent(page = 1, limit = 10)
  reverse_order(:created_at).paginate(page, limit)
end

Public Instance Methods

author=(author) click to toggle source
# File lib/thoth/model/comment.rb, line 71
def author=(author)
  self[:author] = author.strip unless author.nil?
end
author_url=(url) click to toggle source
# File lib/thoth/model/comment.rb, line 75
def author_url=(url)
  # Ensure that the URL begins with a valid protocol.
  unless url.nil? || url.empty? || url =~ /^(?:https?|mailto):\/\//
    url = 'http://' + url
  end

  self[:author_url] = url.strip unless url.nil?
end
body=(body) click to toggle source
# File lib/thoth/model/comment.rb, line 84
def body=(body)
  redcloth = RedCloth.new(body, [:filter_styles])

  self[:body]          = body
  self[:body_rendered] = sanitize_html(redcloth.to_html(
    :refs_textile,
    :block_textile_lists,
    :inline_textile_link,
    :inline_textile_code,
    :glyphs_textile,
    :inline_textile_span
  ))
end
created_at(format = nil) click to toggle source

Gets the creation time of this comment. If format is provided, the time will be returned as a formatted String. See Time.strftime for details.

# File lib/thoth/model/comment.rb, line 100
def created_at(format = nil)
  if new?
    format ? Time.now.strftime(format) : Time.now
  else
    format ? self[:created_at].strftime(format) : self[:created_at]
  end
end
post() click to toggle source

Gets the post to which this comment is attached.

# File lib/thoth/model/comment.rb, line 109
def post
  @post ||= Post[post_id]
end
title=(title) click to toggle source
# File lib/thoth/model/comment.rb, line 113
def title=(title)
  self[:title] = title.strip unless title.nil?
end
updated_at(format = nil) click to toggle source

Gets the time this comment was last updated. If format is provided, the time will be returned as a formatted String. See Time.strftime for details.

# File lib/thoth/model/comment.rb, line 119
def updated_at(format = nil)
  if new?
    format ? Time.now.strftime(format) : Time.now
  else
    format ? self[:updated_at].strftime(format) : self[:updated_at]
  end
end
url() click to toggle source

URL for this comment.

# File lib/thoth/model/comment.rb, line 128
def url
  new? ? '#' : post.url + "#comment-#{id}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.