Changeset 277
- Timestamp:
- 04/26/08 05:00:57 (7 months ago)
- Files:
-
- trunk/History.txt (modified) (4 diffs)
- trunk/lib/picolena/templates/app/controllers/documents_controller.rb (modified) (1 diff)
- trunk/lib/picolena/templates/app/helpers/documents_helper.rb (modified) (1 diff)
- trunk/lib/picolena/templates/app/models/document.rb (modified) (2 diffs)
- trunk/lib/picolena/templates/app/views/documents/_document.html.haml (modified) (1 diff)
- trunk/lib/picolena/templates/app/views/documents/cached.html.haml (modified) (1 diff)
- trunk/lib/picolena/templates/app/views/documents/show.html.haml (modified) (1 diff)
- trunk/lib/picolena/templates/public/stylesheets/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/History.txt
r272 r277 1 == 0.1.7 2008-04- 2 3 * 1 minor enhancement: 4 * added cache highlighting à la Google 5 1 6 == 0.1.6 2008-04-25 2 7 … … 5 10 6 11 * bug fixes: 7 * Added forgotten public/images/flags to generator file .12 * Added forgotten public/images/flags to generator file 8 13 9 14 == 0.1.5 2008-04-25 … … 25 30 26 31 * 1 bug fix: 27 * removed verbose debug info .32 * removed verbose debug info 28 33 29 34 == 0.1.2 2008-04-20 … … 50 55 * can now be installed on win32 (doesn't pass every spec though) 51 56 * moved rails_plugins away from lib/ so that they don't get parsed by rdoc/ri 52 * shorter and prettier base26_hash id for documents .57 * shorter and prettier base26_hash id for documents 53 58 54 59 == 0.0.99 2008-04-06 trunk/lib/picolena/templates/app/controllers/documents_controller.rb
r265 r277 48 48 # similar to Google cache. 49 49 def cached 50 @query=[params[:query],params.delete(:format)].compact.join('.') 50 51 end 51 52 trunk/lib/picolena/templates/app/helpers/documents_helper.rb
r268 r277 72 72 73 73 # For any indexed document, returns a link to show its cached content. 74 def link_to_cached_content(document )74 def link_to_cached_content(document, query) 75 75 link_name="("<<content_tag(:small,:cached.l)<<")" 76 link_to link_name, cached_document_path(document.probably_unique_id) 76 link_to link_name, cached_document_path(:id => document.probably_unique_id, :query => query) 77 end 78 79 def highlighted_cache(document, query) 80 h(document.highlighted_cache(query)).gsub(/\n/,'<br/>').gsub(/<<(.*?)>>/,content_tag(:span, '\1', :class=>"matching_content")) 77 81 end 78 82 end trunk/lib/picolena/templates/app/models/document.rb
r274 r277 65 65 from_index[:content] 66 66 end 67 68 def highlighted_cache(raw_query) 69 #TODO: Report to Ferret. Highlight should accept :key and not only :doc_id. 70 Indexer.index.highlight(Query.extract_from(raw_query), doc_id, 71 :field => :content, :excerpt_length => :all, 72 :pre_tag => "<<", :post_tag => ">>" 73 ) 74 end 67 75 68 76 # Returns the last modification date before the document got indexed. … … 98 106 99 107 private 108 109 # FIXME: Is there a way to easily retrieve doc_id for a given document? 110 # Better yet, fix Index#highlight to accept :probably_unique_id and stop using :doc_id. 111 def doc_id 112 Indexer.index.search(Ferret::Search::TermQuery.new(:probably_unique_id,probably_unique_id)).hits.first.doc 113 end 100 114 101 115 # Retrieves the document from the index. trunk/lib/picolena/templates/app/views/documents/_document.html.haml
r274 r277 13 13 =document.pretty_date 14 14 - 15 =link_to_cached_content(document )15 =link_to_cached_content(document,query) 16 16 %hr/ trunk/lib/picolena/templates/app/views/documents/cached.html.haml
r274 r277 6 6 ) 7 7 %p=link_to_containing_directory(@document) 8 %blockquote=h (@document.cached).gsub(/\n/,'<br/>')8 %blockquote=highlighted_cache(@document, @query) trunk/lib/picolena/templates/app/views/documents/show.html.haml
r256 r277 10 10 %span{:class=>'pagination'}=should_paginate(@matching_documents, @query) 11 11 =describe_results(@matching_documents, @total_hits, @time_needed, h(@query)) 12 = render :partial =>'document', :collection => @matching_documents 12 = render :partial =>'document', :collection => @matching_documents, :locals => { :query => @query} trunk/lib/picolena/templates/public/stylesheets/style.css
r263 r277 138 138 } 139 139 140 #results .matching_content{ 141 background-color:#ffff66; 142 } 143 144 140 145 #results a, #results small{ 141 146 font-family:"Trebuchet MS";
