Sha256: 738a0b8228ce6b40b8bf3a5379aabb7862086614c6803831da314ea1ee4938ed
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
# -*- coding: utf-8 -*- # # @file # @brief # @author ongaeshi # @date 2011/07/18 require 'milkode/cdweb/lib/query' require 'milkode/cdweb/lib/mkurl' require 'milkode/cdweb/lib/command' module Milkode class SearchFiles attr_reader :total_records DISP_NUM = 100 # 1ページの表示数 def initialize(path, params, query) @params = params @q = query @offset = params[:offset].to_i fpaths = @q.fpaths fpaths << path unless path == "" if (fpaths.include?("*")) @records, @total_records = Database.instance.selectAll(@offset, DISP_NUM) else @records, @total_records = Database.instance.search(@q.keywords, @q.packages, fpaths, @q.suffixs, @offset, DISP_NUM) end end def query @q.query_string end def next_offset @offset + @records.size end def data_range @offset..(next_offset - 1) end def html_contents @records.map {|record| result_record(record)}.join end def html_pagination return "" if @q.empty? return "" if next_offset >= @total_records return <<EOF <div class='pagination'> #{pagination_link(next_offset, "next >>")} </div> EOF end def match_num @records.size end private def pagination_link(offset, label) tmpp = @params tmpp[:offset] = offset.to_s href = Mkurl.new("", tmpp).inherit_query_shead_offset pagination_span("<a href='#{href}'>#{label}</a>") end def pagination_span(content) "<span class='pagination-link'>#{content}</span>\n" end def result_record(record) <<EOS <dt class='result-file'>#{file_or_dirimg(true)}<a href='#{"/home/" + record_link(record)}'>#{record.shortpath}</a></dt> EOS end def record_link(record) Mkurl.new(record.shortpath, @params).inherit_query_shead end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
milkode-0.2.0 | lib/milkode/cdweb/lib/search_files.rb |