Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[cdweb] ホームの時は fp で検索、それ以外は f で検索

  • Loading branch information...
commit 64e1de0948c4b8df1940dfe7f465388274c5cbc9 1 parent 262db59
@ongaeshi authored
View
12 lib/milkode/cdweb/lib/query.rb
@@ -65,6 +65,18 @@ def conv_keywords_to_fpath
Query.new(s)
end
+ def conv_keywords_to_fpath_or_packages
+ s = query_string.split.map {|v|
+ if keywords.include? v
+ "fp:#{v}"
+ else
+ v
+ end
+ }.join(' ')
+
+ Query.new(s)
+ end
+
private
def calc_param(index)
View
10 lib/milkode/cdweb/lib/search_contents.rb
@@ -40,8 +40,12 @@ def initialize(path, params, query)
@match_files = []
if @offset == 0 && @line == 0
t = 0
- @match_files, t, @elapsed = Database.instance.search([], @q.packages, path, @q.keywords, @q.suffixs, @q.fpath_or_packages, @offset, MATH_FILE_LIMIT)
- p t
+
+ if (@path != "")
+ @match_files, t, @elapsed = Database.instance.search([], @q.packages, path, @q.fpaths + @q.keywords, @q.suffixs, @q.fpath_or_packages, @offset, MATH_FILE_LIMIT)
+ else
+ @match_files, t, @elapsed = Database.instance.search([], @q.packages, path, @q.fpaths, @q.suffixs, @q.fpath_or_packages + @q.keywords, @offset, MATH_FILE_LIMIT)
+ end
end
grep_contents
@@ -89,7 +93,7 @@ def match_files_contents
unless @match_files.empty?
is_and_more = @match_files.size >= MATH_FILE_LIMIT
@match_files = @match_files[0..MATH_FILE_DISP-1]
- conv_query = @q.conv_keywords_to_fpath
+ conv_query = (@path != "") ? @q.conv_keywords_to_fpath : @q.conv_keywords_to_fpath_or_packages
tmpp = @params.clone
tmpp[:query] = conv_query.query_string
url = Mkurl.new(@path, tmpp).inherit_query_shead
View
5 test/test_query.rb
@@ -67,6 +67,11 @@ def test_fp
assert_equal q.fpath_or_packages, ['pack', 'age']
end
+ def test_conv_keywords_to_fpath_or_packages
+ q = create_query("array test s:rb")
+ assert_equal q.conv_keywords_to_fpath_or_packages.query_string, 'fp:array fp:test s:rb'
+ end
+
def create_query(query)
Query.new(query)
end
Please sign in to comment.
Something went wrong with that request. Please try again.