Sha256: 75e252ebc1ec038c5339c4495ca6041f9cc56450bda90bc585ec3766ffe8aeca

Contents?: true

Size: 1.81 KB

Versions: 8

Compression:

Stored size: 1.81 KB

Contents

include_set Type::Json
include_set Abstract::WqlSearch

format do
  view :core, cache: :never do
    _render search_result_view
  end

  def chunk_list
    :query
  end

  def search_result_view
    case search_with_params
    when Exception              then :search_error
    when Integer                then :search_count
    when nest_mode == :template then :raw
    else                         :card_list
    end
  end
end

format :json do
  def items_for_export
    return [] if card.content.empty? || unexportable_tag?(card.name.tag_name.key)
    card.item_cards
  end

  # avoid running the search from +:content_options (huge results)
  # and +:structure (errors)
  # TODO: make this configurable in set mods
  def unexportable_tag? tag_key
    %i[content_options structure].map { |code| code.cardname.key }.include? tag_key
  end
end

format :rss do
  view :feed_body do
    case raw_feed_items
    when Exception then @xml.item(render!(:search_error))
    when Integer then @xml.item(render!(:search_count))
    else super()
    end
  end

  def raw_feed_items
    @raw_feed_items ||= search_with_params
  end
end

format :html do
  view :core do
    _render search_result_view
  end

  view :bar do
    voo.hide :one_line_content
    super()
  end

  view :one_line_content, cache: :never do
    if depth > max_depth
      "..."
    else
      search_params[:limit] = closed_limit
      _render_core hide: "paging", items: { view: :link }
      # TODO: if item is queryified to be "name", then that should work.
      # otherwise use link
    end
  end

  def rss_link_tag
    path_opts = { format: :rss }
    Array(search_params[:vars]).compact.each { |k, v| opts["_#{k}"] = v }
    tag "link", rel: "alternate",
                type: "application/rss+xml",
                title: "RSS",
                href: path(path_opts)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-1.100.0 mod/search/set/type/search_type.rb
card-1.99.6 mod/search/set/type/search_type.rb
card-1.99.5 mod/search/set/type/search_type.rb
card-1.99.4 mod/search/set/type/search_type.rb
card-1.99.3 mod/search/set/type/search_type.rb
card-1.99.2 mod/search/set/type/search_type.rb
card-1.99.1 mod/search/set/type/search_type.rb
card-1.99.0 mod/search/set/type/search_type.rb