Class: Fuel::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Fuel::Post
- Extended by:
- FriendlyId
- Includes:
- ActionView::Helpers::OutputSafetyHelper
- Defined in:
- app/models/fuel/post.rb
Defined Under Namespace
Modules: Formats
Instance Method Summary collapse
- #avatar_url ⇒ Object
- #content ⇒ Object
- #featured_image_url ⇒ Object
- #html? ⇒ Boolean
- #is_published ⇒ Object
- #markdown? ⇒ Boolean
- #next ⇒ Object
- #previous ⇒ Object
- #prioritized_featured_image_url(type = :original) ⇒ Object
- #raw_content ⇒ Object
- #s3_credentials ⇒ Object
- #save_as_draft ⇒ Object
- #should_generate_new_friendly_id? ⇒ Boolean
- #teaser_content ⇒ Object
- #to_html(content = raw_content) ⇒ Object
Instance Method Details
#avatar_url ⇒ Object
93 94 95 96 |
# File 'app/models/fuel/post.rb', line 93 def avatar_url return unless .present? .avatar.url(:medium) end |
#content ⇒ Object
73 74 75 |
# File 'app/models/fuel/post.rb', line 73 def content markdown? ? to_html(raw_content) : raw_content end |
#featured_image_url ⇒ Object
89 90 91 |
# File 'app/models/fuel/post.rb', line 89 def featured_image_url featured_image.url(:medium) end |
#html? ⇒ Boolean
81 82 83 |
# File 'app/models/fuel/post.rb', line 81 def html? format == Formats::HTML end |
#is_published ⇒ Object
55 56 57 |
# File 'app/models/fuel/post.rb', line 55 def is_published self.published end |
#markdown? ⇒ Boolean
85 86 87 |
# File 'app/models/fuel/post.rb', line 85 def markdown? format == Formats::MARKDOWN end |
#next ⇒ Object
39 40 41 |
# File 'app/models/fuel/post.rb', line 39 def next self.class.recent.where("published_at <= ? AND id != ?", published_at, id).first end |
#previous ⇒ Object
43 44 45 |
# File 'app/models/fuel/post.rb', line 43 def previous self.class.recent.where("published_at >= ? AND id != ?", published_at, id).last end |
#prioritized_featured_image_url(type = :original) ⇒ Object
59 60 61 |
# File 'app/models/fuel/post.rb', line 59 def prioritized_featured_image_url(type = :original) featured_image_file_name.present? ? featured_image.url(type) : featured_image_url end |
#raw_content ⇒ Object
77 78 79 |
# File 'app/models/fuel/post.rb', line 77 def raw_content attributes["content"] end |
#s3_credentials ⇒ Object
35 36 37 |
# File 'app/models/fuel/post.rb', line 35 def s3_credentials { :bucket => Fuel.configuration.aws_bucket, :access_key_id => Fuel.configuration.aws_access_key, :secret_access_key => Fuel.configuration.aws_secret_access_key } end |
#save_as_draft ⇒ Object
51 52 53 |
# File 'app/models/fuel/post.rb', line 51 def save_as_draft self.published = false end |
#should_generate_new_friendly_id? ⇒ Boolean
47 48 49 |
# File 'app/models/fuel/post.rb', line 47 def should_generate_new_friendly_id? new_record? #Don't generate new id on edit end |
#teaser_content ⇒ Object
63 64 65 |
# File 'app/models/fuel/post.rb', line 63 def .present? ? : content end |
#to_html(content = raw_content) ⇒ Object
67 68 69 70 71 |
# File 'app/models/fuel/post.rb', line 67 def to_html(content = raw_content) markdown = Redcarpet::Markdown.new(Fuel::Html, :autolink => true, :space_after_headers => true, fenced_code_blocks: true, disable_indented_code_blocks: true, tables: true) raw markdown.render(content) end |