Module: ContentsHelper

Defined in:
app/helpers/contents_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Array<String>) allowed_content_types(feeds)

All the content types that are allowed on a group of feeds.



19
20
21
22
# File 'app/helpers/contents_helper.rb', line 19

def allowed_content_types(feeds)
  return content_types if feeds.nil?
  feeds.map {|f| f.content_types.reject{|k, value| value != "1"}.keys}.flatten.uniq
end

- (Object) content_types

Expose a copy of the available content subclasses.



4
5
6
# File 'app/helpers/contents_helper.rb', line 4

def content_types
  Concerto::Application.config.content_types.dup
end

- (Object) get_available_types



8
9
10
11
12
13
14
# File 'app/helpers/contents_helper.rb', line 8

def get_available_types
  allowed_types = allowed_content_types(@feeds)
  available_types = content_types.delete_if{ |subclass| !allowed_types.include?(subclass.name)}
  available_types = available_types.sort_by do |subclass|
    (subclass.name == ConcertoConfig['default_upload_type'].titleize ? '00' : '') + subclass.display_name
  end 
end

- (Object) render_content(content, options = {})

Render a piece of content.

options controls what partial is used when rendering the file. Defaults to _render_default.html.erb (:type = 'default').

All options set are passed to the partial in options. The content object is passed in content.



32
33
34
35
36
37
38
39
40
# File 'app/helpers/contents_helper.rb', line 32

def render_content(content, options={})
  options.symbolize_keys! #All the cool kids do this

  options[:type] ||= 'default'

  render_partial_if("contents/#{content.class.to_s.underscore}/render_#{options[:type]}",
                    "contents/render_#{options[:type]}",
                    {:content => content, :options => options})
end