Changeset 334

Show
Ignore:
Timestamp:
05/09/08 04:36:10 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

Multicolor cache highlighting à la Google

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/History.txt

    r331 r334  
    11== 0.1.9  2008-05- 
     2 
     3* 2 minor enhancements: 
     4  * Multicolor cache highlighting à la Google 
     5  * More documentation 
    26 
    37== 0.1.8  2008-05-08 
  • trunk/lib/picolena/templates/app/helpers/documents_helper.rb

    r314 r334  
    7777  end 
    7878   
     79  # Returns multicolor cache à la Google. 
    7980  def highlighted_cache(document, query) 
    80     h(document.highlighted_cache(query)).gsub(/\n/,'<br/>').gsub(/&lt;&lt;(.*?)&gt;&gt;/,content_tag(:span, '\1', :class=>"matching_content")) 
     81    # What are the terms related to :content field? 
     82    content_terms=Query.content_terms(query) 
     83    # Parses cache for found terms 
     84    # Replaces linebreak by <br/> 
     85    # < and > by &lt; and &gt; 
     86    h(document.highlighted_cache(query)).gsub(/\n/,'<br/>').gsub(/&lt;&lt;(.*?)&gt;&gt;/){|c| term=$1 
     87      # and affects a span class to each term 
     88      content_tag(:span, term, :class=>"matching_content_#{content_terms.index(term.downcase)}") 
     89    } 
    8190  end 
    8291   
  • trunk/lib/picolena/templates/public/stylesheets/style.css

    r283 r334  
    149149} 
    150150 
    151 #results .matching_content
     151#results .matching_content_0
    152152        background-color:#ffff66; 
    153153} 
    154154 
     155#results .matching_content_1{ 
     156        background-color:#66ffff; 
     157} 
     158 
     159#results .matching_content_2{ 
     160        background-color:#99ff99; 
     161} 
     162 
     163#results .matching_content_3{ 
     164        background-color:#ff9999; 
     165} 
     166 
     167#results .matching_content_4{ 
     168        background-color:#ff66ff; 
     169} 
     170 
     171#results .matching_content_5{ 
     172        background-color:#9999ff; 
     173} 
     174 
     175#results .matching_content_6{ 
     176        background-color:#66ff66; 
     177} 
    155178 
    156179#results a, #results small{