Module: Fuel::PostsHelper

Defined in:
app/helpers/fuel/posts_helper.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



13
14
15
# File 'app/helpers/fuel/posts_helper.rb', line 13

def method_missing method, *args, &block
  fuel.send(method, *args)
end

Instance Method Details

#embedded_svg(filename, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/fuel/posts_helper.rb', line 17

def embedded_svg filename, options={}
  path = Rails.application.assets.find_asset(filename).pathname
  file = File.read(path)
  doc = Nokogiri::HTML::DocumentFragment.parse file
  svg = doc.at_css 'svg'
  if options[:class].present?
    svg['class'] = options[:class]
  end
  doc.to_html.html_safe
end

#format_optionsObject



39
40
41
# File 'app/helpers/fuel/posts_helper.rb', line 39

def format_options
  Fuel::Post::Formats::DISPLAY.dup.invert
end

#hide_published_at(post) ⇒ Object



28
29
30
# File 'app/helpers/fuel/posts_helper.rb', line 28

def hide_published_at(post)
  @post.is_published ? '' : 'display:none;'
end

#markdown(text) ⇒ Object



7
8
9
10
11
# File 'app/helpers/fuel/posts_helper.rb', line 7

def markdown(text)
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
      :autolink => true, :space_after_headers => true, tables: true)
  raw markdown.render(text)
end

#s3_direct_postObject



32
33
34
35
36
37
# File 'app/helpers/fuel/posts_helper.rb', line 32

def s3_direct_post
  @s3_direct_post ||= (
    return unless s3_bucket
    s3_bucket.presigned_post(key: "uploads/#{SecureRandom.uuid}/${filename}", success_action_status: 201, acl: :public_read)
  )
end