Class: Thoth::Comment

### Home Classes Methods

### In Files

- lib/thoth/model/comment.rb

### Parent

Sequel::Model

### Methods

- ::recent
- #author=
- #author_url=
- #body=
- #created_at
- #post
- #title=
- #updated_at
- #url

### Included Modules

- Ramaze::Helper::Link
- Ramaze::Helper::Sanitize

### Files

- robots.txt

### Class/Module Index

Quicksearch

- Thoth
- Thoth::AdminController
- Thoth::ArchiveController
- Thoth::Comment
- Thoth::CommentApiController
- Thoth::CommentController
- Thoth::Config
- Thoth::Error
- Thoth::Importer
- Thoth::MainController
- Thoth::Media
- Thoth::MediaController
- Thoth::MinifyController
- Thoth::Page
- Thoth::PageApiController
- Thoth::PageController
- Thoth::Pager
- Thoth::Plugin
- Thoth::Plugin::Delicious
- Thoth::Plugin::Flickr
- Thoth::Plugin::Tags
- Thoth::Plugin::Twitter
- Thoth::Post
- Thoth::PostApiController
- Thoth::PostController
- Thoth::SchemaError
- Thoth::SearchController
- Thoth::Tag
- Thoth::TagApiController
- Thoth::TagController
- Thoth::TagsPostsMap
- Ramaze
- Ramaze::Dispatcher
- Ramaze::Dispatcher::File
- Ramaze::Helper
- Ramaze::Helper::Admin
- Ramaze::Helper::Cookie
- Ramaze::Helper::Error
- Ramaze::Helper::Pagination
- Ramaze::Helper::Sanitize
- Ramaze::Helper::Wiki
- Ramaze::Helper::Ysearch
- Ramaze::Helper::Ysearch::SearchError
- AddMediaSize
- CreateSchema
- PantsImporter
- PoseidonImporter

No matching classes.

# 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.