Sha256: aa0bfd00aad04cbe401118f143dca132a82deb8aa3625fadf01bd2cdc0b0ac92

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Fuel
  module PostsHelper
    Fuel.configuration.helpers.each do |helper|
      include "::#{helper}".constantize
    end

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

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

    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

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

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fuel-0.3.34 app/helpers/fuel/posts_helper.rb
fuel-0.3.33 app/helpers/fuel/posts_helper.rb