Sha256: 8f2b61ca4385fd2222f6f6d48a6f595600cd09b3b5342172719db431a43f75c3

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 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

  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

3 entries across 3 versions & 1 rubygems

Version Path
card-mod-list-0.14.2 set/abstract/01_pointer/other_views.rb
card-mod-list-0.14.1 set/abstract/01_pointer/other_views.rb
card-mod-list-0.14.0 set/abstract/01_pointer/other_views.rb