Sha256: 4048dc0eff5c7705dfd1b458b42df0d2bfb13c53c58687fb8927bd9ff606848b

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module Transit
  module PackageHelper
    unloadable
    
    def deliver_content(resource, force_edit = false, &block)
      return capture(resource, &block).html_safe unless force_edit || edit_mode_enabled?
      tpl  = resource.delivery_template
      with_output_buffer do
        concat(form_for([transit, resource], as: tpl, html: { remote: true, id: "transit_edit_#{tpl.to_s}" }) do |dform|
          concat(capture(Transit::Builders::PackageBuilder.new(resource, dform, nil), &block))
        end)
      end
    end
    
    def deliver(obj)
      if obj.respond_to?(:deliver)
        return obj.deliver
      end
      obj.contexts.ascending(:position).map do |field|
        unless field.media_context?
          render(:partial => "contexts/#{field.class.to_s.underscore}", :format => :html, :locals => { :context => field }).html_safe
        else
          deliver_media_context(field, field.to_backbone)          
        end
      end.join("\n").html_safe
    end
  
    def deliver_rss(post)
      send(:"#{post.class.name.to_s.underscore}_path", post.slug)
    end
  
    private
  
    def deliver_media_context(context, attrs = {})
      type = context.class.name.underscore
      attrs = { transit_context: type, context_attributes: attrs }
      content_tag(:div, "", { id: "#{type}_context_#{context.id}", data: attrs, class: "#{type}_player" })
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transit-0.0.2 app/helpers/transit/package_helper.rb