Sha256: 70341a52714d5bc4f9d3c0dc238202563f55d52ebb99243169719455ad8fbe97

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# Legacy class to support old feedback sent as trackbacks.
class Trackback < Feedback
  content_fields :excerpt
  validates :title, :excerpt, :url, presence: true

  # attr_accessible :url, :blog_name, :title, :excerpt, :ip, :published, :article_id

  def initialize(*args, &block)
    super(*args, &block)
    self.title ||= url
    self.blog_name ||= ''
  end

  before_create :process_trackback

  def process_trackback
    if excerpt.length >= 251
      # this limits excerpt to 250 chars, including the trailing "..."
      self.excerpt = excerpt[0..246] << '...'
    end
  end

  def article_allows_feedback?
    return true if article.allow_pings?
    errors.add(:article, 'Article is not pingable')
    false
  end

  def blog_allows_feedback?
    return true unless blog.global_pings_disable
    errors.add(:article, 'Pings are disabled')
    false
  end

  def originator
    blog_name
  end

  def body
    excerpt
  end

  def body=(newval)
    self.excerpt = newval
  end

  def feed_title
    "Trackback from #{blog_name}: #{title} on #{article.title}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
publify_core-9.1.0 app/models/trackback.rb
publify_core-9.0.1 app/models/trackback.rb
publify_core-9.0.0 app/models/trackback.rb