Sha256: a64e34e10ddbc20ac03de84189f508c9abea57c44e5db1f4571a88abf4a855a8

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 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={}
      file = File.read(Rails.root.join('app', 'assets', 'images', filename))
      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

6 entries across 6 versions & 1 rubygems

Version Path
fuel-0.3.32 app/helpers/fuel/posts_helper.rb
fuel-0.3.31 app/helpers/fuel/posts_helper.rb
fuel-0.3.30 app/helpers/fuel/posts_helper.rb
fuel-0.3.29 app/helpers/fuel/posts_helper.rb
fuel-0.3.28 app/helpers/fuel/posts_helper.rb
fuel-0.3.27 app/helpers/fuel/posts_helper.rb