Sha256: e7edba42b38e3f9f47ae8917c7c37684e6d16ce805d36fc90d1cfd8b5662327d

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; module Self; module Search; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/self/search.rb ~~~~~~~~~~~

format :html do

  view :title do |args|
    vars = root.search_params[:vars]
    if vars && vars[:keyword]
       args.merge! title: %{Search results for: <span class="search-keyword">#{ vars[:keyword] }</span>}
    end
    super args
  end
end


format :json do

  view :complete do |args|
    term = params['_keyword']
    if term =~ /^\+/ && main = params['main']
      term = main+term
    end

    exact = Card.fetch term, new: {}
    goto_cards = Card.search goto_wql(term)
    goto_cards.unshift exact.name if exact.known? && !goto_cards.map{|n| n.to_name.key}.include?(exact.key)

    {
      search: true, # card.ok?( :read ),
      add:    (exact.new_card? && exact.cardname.valid? && !exact.virtual? && exact.ok?( :create ) && exact.name),
      new:    (exact.type_id==Card::CardtypeID &&
                  Card.new(type_id: exact.type_id).ok?(:create) &&
                  [exact.name, exact.cardname.url_key]
                 ),
      goto:   goto_cards.map { |name| [name, highlight(name, term), name.to_name.url_key] }
    }

  end

  #hacky.  here for override
  def goto_wql(term)
   { complete: term, limit: 8, sort: 'name', return: 'name' }
  end

end


# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/self/search.rb ~~~~~~~~~~~
end;end;end;end;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-1.16.9 tmpsets/set/mod007-05_standard/self/search.rb
card-1.16.8 tmpsets/set/mod007-05_standard/self/search.rb
card-1.16.7 tmpsets/set/mod007-05_standard/self/search.rb