Class: DocumentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DocumentsController
- Defined in:
- lib/picolena/templates/app/controllers/documents_controller.rb
Overview
Core controller of Picolena search-engine. DocumentsController
- treats queries
- launches searches
- returns matching documents
- displays document content
- displays cached content.
Instance Method Summary collapse
-
#cached ⇒ Object
Returns the content of the document identified by probably_unique_id, as it was at the time it was indexed.
-
#check_query ⇒ Object
Actually doesn’t check anything at all.
-
#content ⇒ Object
Returns the content of the document identified by probably_unique_id, as it is now.
-
#download ⇒ Object
Download the file whose probably_unique_id is given.
-
#show ⇒ Object
Show the matching documents for a given query.
Methods inherited from ApplicationController
#access_denied, #unknown_request
Instance Method Details
#cached ⇒ Object
Returns the content of the document identified by probably_unique_id, as it was at the time it was indexed. similar to Google cache.
50 51 52 |
# File 'lib/picolena/templates/app/controllers/documents_controller.rb', line 50 def cached @query=[params[:query],params.delete(:format)].compact.join('.') end |
#check_query ⇒ Object
Actually doesn’t check anything at all. Just a redirect to show_document(query)
FIXME: remove this useless action, and go directly from submit button to GET :action => show
16 17 18 |
# File 'lib/picolena/templates/app/controllers/documents_controller.rb', line 16 def check_query redirect_to :action=>'show', :id=>params[:query] end |
#content ⇒ Object
Returns the content of the document identified by probably_unique_id, as it is now.
45 46 |
# File 'lib/picolena/templates/app/controllers/documents_controller.rb', line 45 def content end |
#download ⇒ Object
Download the file whose probably_unique_id is given. If the checksum is incorrect, redirect to documents_url via no_valid_link
40 41 42 |
# File 'lib/picolena/templates/app/controllers/documents_controller.rb', line 40 def download send_file @document.complete_path, :type => @document.mime, :disposition => 'inline' end |
#show ⇒ Object
Show the matching documents for a given query
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/picolena/templates/app/controllers/documents_controller.rb', line 22 def show start=Time.now @query=params[:id] @sort_by=params[:sort_by] page=params[:page]||1 finder=Finder.new(@query,@sort_by,page) finder.execute! pager=::Paginator.new(finder.total_hits, Picolena::ResultsPerPage) do finder.matching_documents end @matching_documents=pager.page(page) @total_hits=finder.total_hits @time_needed=Time.now-start end |