# -*- coding: utf-8 -*- # # @file # @brief # @author ongaeshi # @date 2011/07/11 require 'milkode/cdweb/lib/database' require 'milkode/cdweb/lib/coderay_wrapper' require 'milkode/cdweb/lib/search_contents' require 'milkode/cdweb/lib/search_files' require 'milkode/cdweb/lib/mkurl' module Milkode def view(record, params, before) @title = record.shortpath @path = record.shortpath q = params[:query] && Query.new(params[:query]) if (q and !q.keywords.empty?) grep = Grep.new(record.content) match_lines = grep.match_lines_and(q.keywords) @record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines).to_html_anchor else @record_content = CodeRayWrapper.new(record.content, record.shortpath).to_html end @elapsed = Time.now - before haml :view end def search(path, params, before) @path = path query = Query.new(params[:query]) @title = "'#{query.query_string}' in #{path_title(path)}" if (query.keywords.size > 0) searcher = SearchContents.new(path, params, query) else searcher = SearchFiles.new(path, params, query) end @total_records = searcher.total_records @range = searcher.data_range @record_content = "