Sha256: 9f300bbb152b7718d545e3e9a27da048bb5ae3b58dcfa90002cc4e15c0312e87

Contents?: true

Size: 911 Bytes

Versions: 18

Compression:

Stored size: 911 Bytes

Contents

# frozen_string_literal: true

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

  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

18 entries across 18 versions & 2 rubygems

Version Path
HornsAndHooves-publify_core-10.5.0 app/models/trackback.rb
HornsAndHooves-publify_core-10.4.0 app/models/trackback.rb
HornsAndHooves-publify_core-10.3.0 app/models/trackback.rb
HornsAndHooves-publify_core-10.2.0 app/models/trackback.rb
HornsAndHooves-publify_core-10.1.1 app/models/trackback.rb
HornsAndHooves-publify_core-10.1.0 app/models/trackback.rb
HornsAndHooves-publify_core-10.0.3 app/models/trackback.rb
HornsAndHooves-publify_core-10.0.2 app/models/trackback.rb
HornsAndHooves-publify_core-10.0.1 app/models/trackback.rb
HornsAndHooves-publify_core-10.0.0 app/models/trackback.rb
publify_core-9.2.7 app/models/trackback.rb
publify_core-9.2.6 app/models/trackback.rb
publify_core-9.2.5 app/models/trackback.rb
publify_core-9.2.4 app/models/trackback.rb
publify_core-9.2.3 app/models/trackback.rb
publify_core-9.2.2 app/models/trackback.rb
publify_core-9.2.1 app/models/trackback.rb
publify_core-9.2.0 app/models/trackback.rb