Sha256: 10536fb03fa11b6d26b93bafc393ef1be16948dd2b0078553b3c824a9a94326f

Contents?: true

Size: 1.4 KB

Versions: 17

Compression:

Stored size: 1.4 KB

Contents

# BASE views

format do
  def default_limit
    20
  end

  def item_links args={}
    card.item_cards(args).map do |item_card|
      subformat(item_card).render_link
    end
  end

  def nest_item_array
    card.item_cards.map do |item|
      nest_item item
    end
  end

  view :core do
    pointer_items.join ", "
  end

  def pointer_items args={}
    page_args = args.extract! :limit, :offset
    listing card.item_cards(page_args), args
  end
end

# JavaScript views

format :js do
  view :core do
    nest_item_array.join "\n\n"
  end
end

# Data views

format :data do
  view :core do
    nest_item_array
  end
end

# JSON views

format :json do
  view :content do
    card.item_names
  end

  def item_cards
    card.item_cards
  end

  def max_depth
    params[:max_depth] || 1
  end

  def items_for_export
    card.item_cards
  end

  def essentials
    return {} if depth > max_depth
    card.item_cards.map do |item|
      nest item, view: :essentials
    end
  end

  view :links do
    []
  end
end

# CSS views

format :css do
  # generalize to all collections?
  def default_item_view
    :content
  end

  view :titled do
    %(#{major_comment "STYLE GROUP: \"#{card.name}\"", '='}#{_render_core})
  end

  view :core do
    nest_item_array.join "\n\n"
  end

  view :content, :core
end

# RSS views

format :rss do
  def raw_feed_items
    @raw_feed_items ||= card.item_cards(limit: limit, offset: offset)
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
card-mod-list-0.11.4 set/abstract/01_pointer/other_views.rb
card-mod-list-0.11.3 set/abstract/01_pointer/other_views.rb
card-mod-list-0.11.2 set/abstract/01_pointer/other_views.rb
card-mod-list-0.11.1 set/abstract/01_pointer/other_views.rb
card-mod-list-0.11.0 set/abstract/01_pointer/other_views.rb
card-1.100.0 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.6 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.5 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.4 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.3 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.2 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.1 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.99.0 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.98.3 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.98.2 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.98.1 mod/pointer/set/abstract/02_pointer/other_views.rb
card-1.98.0 mod/pointer/set/abstract/02_pointer/other_views.rb