Sha256: 1070383a73096c8184979f975928fc1a012ea2945e5bb7d6faa69a80d0929a40

Contents?: true

Size: 1.17 KB

Versions: 32

Compression:

Stored size: 1.17 KB

Contents

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

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
card-1.16.6 mod/05_standard/set/self/search.rb
card-1.16.5 mod/05_standard/set/self/search.rb
card-1.16.4 mod/05_standard/set/self/search.rb
card-1.16.3 mod/05_standard/set/self/search.rb
card-1.16.2 mod/05_standard/set/self/search.rb
card-1.16.1 mod/05_standard/set/self/search.rb
card-1.16.0 mod/05_standard/set/self/search.rb
card-1.15.7 mod/05_standard/set/self/search.rb
card-1.15.6 mod/05_standard/set/self/search.rb
card-1.15.5 mod/05_standard/set/self/search.rb
card-1.15.4 mod/05_standard/set/self/search.rb
card-1.15.3 mod/05_standard/set/self/search.rb
card-1.15.2 mod/05_standard/set/self/search.rb
card-1.15.1 mod/05_standard/set/self/search.rb
card-1.15.0 mod/05_standard/set/self/search.rb
card-1.15.pre2 mod/05_standard/set/self/search.rb
card-1.15.pre mod/05_standard/set/self/search.rb
wagn-1.14.9 mod/05_standard/set/self/search.rb
wagn-1.14.8 mod/05_standard/set/self/search.rb
wagn-1.14.7 mod/05_standard/set/self/search.rb