Changeset 176
- Timestamp:
- 04/19/08 12:23:10 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/oo_indexer/lib/picolena/templates/app/models/document.rb
r170 r176 2 2 class Document 3 3 attr_reader :complete_path 4 attr_accessor :user, :score, :matching_content, :index_id 4 attr_writer :index_id 5 attr_accessor :user, :score, :matching_content 5 6 6 7 def initialize(path) … … 10 11 validate_in_indexed_directory 11 12 end 12 13 alias_method :to_param, :id14 13 15 14 #Delegating properties to File::method_name(complete_path) … … 66 65 # Returns content as it was at the time it was indexed. 67 66 def cached 68 get_index_id! unless index_id69 67 IndexReader.new[index_id][:content] 70 68 end 71 69 70 # FIXME: Not just date anymore. 72 71 # Returns the last modification date before the document got indexed. 73 72 # Useful to know how old a document is, and to which version the cache corresponds. 74 73 def date 75 get_index_id! unless index_id 76 IndexReader.new[index_id][:date].sub(/(\d{4})(\d{2})(\d{2})/,'\1-\2-\3') 74 from_index[:date].sub(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/,'\1-\2-\3 \4:\5:\6') 77 75 end 78 76 79 77 def mtime 80 get_index_id! unless index_id 81 IndexReader.new[index_id][:date].to_i 78 from_index[:date].to_i 79 end 80 81 # Returns the id with which the document is indexed. 82 def index_id 83 @index_id ||= Document.find_by_complete_path(complete_path).index_id 82 84 end 83 85 84 86 private 85 86 def get_index_id! 87 @index_id = Document.find_by_unique_id(probably_unique_id).index_id 87 88 # Retrieves the document from the index. 89 # Useful to get meta-info about it. 90 def from_index 91 IndexReader.new[index_id] 88 92 end 89 93 branches/oo_indexer/lib/picolena/templates/app/views/documents/_document.html.haml
r117 r176 4 4 =highlight_matching_content(document) 5 5 %p=link_to_containing_directory(document) 6 - if document.supported?6 -if document.supported? 7 7 %p 8 8 =link_to_plain_text_content(document)
