milkode 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/HISTORY.ja.rdoc +29 -0
- data/HISTORY.rdoc +14 -0
- data/VERSION +1 -1
- data/bin/gmilk +1 -1
- data/bin/milk +1 -1
- data/lib/milkode/cdstk/cdstk.rb +90 -38
- data/lib/milkode/cdstk/milkode_yaml.rb +6 -0
- data/lib/milkode/cdstk/yaml_file_wrapper.rb +4 -0
- data/lib/milkode/cdweb/app.rb +5 -5
- data/lib/milkode/cdweb/lib/command.rb +20 -4
- data/lib/milkode/cdweb/lib/database.rb +20 -16
- data/lib/milkode/cdweb/lib/grep.rb +6 -6
- data/lib/milkode/cdweb/lib/query.rb +36 -1
- data/lib/milkode/cdweb/lib/search_contents.rb +134 -19
- data/lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb +162 -0
- data/lib/milkode/cdweb/lib/web_setting.rb +9 -1
- data/lib/milkode/cdweb/public/css/milkode.css +5 -0
- data/lib/milkode/cdweb/public/images/favicon.ico +0 -0
- data/lib/milkode/cdweb/public/js/milkode.js +46 -48
- data/lib/milkode/cdweb/views/index.haml +1 -0
- data/lib/milkode/cli.rb +6 -3
- data/lib/milkode/common/util.rb +19 -0
- data/lib/milkode/database/document_table.rb +40 -22
- data/lib/milkode/database/package_table.rb +1 -1
- data/lib/milkode/database/updater.rb +14 -7
- data/lib/milkode/findgrep/findgrep.rb +23 -11
- data/lib/milkode/grep/cli_grep.rb +1 -4
- data/milkode.gemspec +10 -5
- data/test/data/.gitignore.sjis +46 -0
- data/test/data/ignore_test_sjis/.gitignore +2 -0
- data/test/data/ignore_test_sjis/a.txt +1 -0
- data/test/test_cdstk.rb +2 -1
- data/test/test_ignore_setting.rb +9 -0
- data/test/test_query.rb +6 -0
- data/test/test_updater.rb +13 -1
- data/test/test_util.rb +10 -0
- metadata +17 -4
@@ -17,12 +17,18 @@ module Milkode
|
|
17
17
|
:header_title => "Milkode",
|
18
18
|
:header_icon => "/images/MilkodeIcon135.png",
|
19
19
|
|
20
|
+
:favicon => "/images/favicon.ico",
|
21
|
+
|
20
22
|
:display_about_milkode => true
|
21
23
|
}
|
22
24
|
|
23
25
|
def self.hash_method(name)
|
24
26
|
define_method(name) do
|
25
|
-
@data[name]
|
27
|
+
if @data[name]
|
28
|
+
@data[name]
|
29
|
+
else
|
30
|
+
DEFAULT_SETTING[name]
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
@@ -43,6 +49,8 @@ module Milkode
|
|
43
49
|
hash_method :header_title
|
44
50
|
hash_method :header_icon
|
45
51
|
|
52
|
+
hash_method :favicon
|
53
|
+
|
46
54
|
def about_milkode
|
47
55
|
if (@data[:display_about_milkode])
|
48
56
|
', <a href="http://milkode.ongaeshi.me">milkodeについて</a>'
|
Binary file
|
@@ -7,8 +7,7 @@ function escapeHTML(str) {
|
|
7
7
|
return str.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
8
8
|
}
|
9
9
|
|
10
|
-
function replace_query_param(url, value)
|
11
|
-
{
|
10
|
+
function replace_query_param(url, value) {
|
12
11
|
var url_s = url.split("?");
|
13
12
|
|
14
13
|
if (url_s.length <= 1) {
|
@@ -35,22 +34,19 @@ function replace_query_param(url, value)
|
|
35
34
|
}
|
36
35
|
}
|
37
36
|
|
38
|
-
function topic_path(id)
|
39
|
-
{
|
37
|
+
function topic_path(id) {
|
40
38
|
var url = document.getElementById(id).href;
|
41
39
|
url = replace_query_param(url, document.searchform.query.value);
|
42
40
|
document.getElementById(id).href = url;
|
43
41
|
}
|
44
42
|
|
45
|
-
function repalce_package_name(url, package_name)
|
46
|
-
{
|
43
|
+
function repalce_package_name(url, package_name) {
|
47
44
|
var url_s = url.split("?");
|
48
45
|
url = url_s[0].replace(/\/home(\/.*)?/, "/home/" + package_name); // home以下をパッケージ名に置き換え
|
49
46
|
return url;
|
50
47
|
}
|
51
48
|
|
52
|
-
function select_package()
|
53
|
-
{
|
49
|
+
function select_package() {
|
54
50
|
var url = document.URL;
|
55
51
|
var name = document.getElementById('package').value;
|
56
52
|
|
@@ -62,8 +58,7 @@ function select_package()
|
|
62
58
|
document.location = url;
|
63
59
|
}
|
64
60
|
|
65
|
-
function select_package_home()
|
66
|
-
{
|
61
|
+
function select_package_home() {
|
67
62
|
var url = document.URL.replace(/\/$/, "");
|
68
63
|
var name = document.getElementById('package_home').value;
|
69
64
|
|
@@ -74,40 +69,7 @@ function select_package_home()
|
|
74
69
|
document.location = url + "/home/" + name;
|
75
70
|
}
|
76
71
|
|
77
|
-
|
78
|
-
$("select#package").multiselect({
|
79
|
-
multiple: false,
|
80
|
-
header: "",
|
81
|
-
selectedList: 1,
|
82
|
-
height: 450
|
83
|
-
}).multiselectfilter();
|
84
|
-
|
85
|
-
$("select#package_home").multiselect({
|
86
|
-
multiple: false,
|
87
|
-
header: "",
|
88
|
-
selectedList: 1,
|
89
|
-
height: 350
|
90
|
-
}).multiselectfilter();
|
91
|
-
|
92
|
-
$("#updateOk").click(function (e) {
|
93
|
-
update_package($("#updateOk").attr("milkode-package-name"));
|
94
|
-
return false;
|
95
|
-
});
|
96
|
-
|
97
|
-
var match = document.URL.match(/.+(#n\d+)$/);
|
98
|
-
if ( match ) {
|
99
|
-
$(match[1]).addClass("select-line");
|
100
|
-
} else {
|
101
|
-
$("#query").select();
|
102
|
-
}
|
103
|
-
|
104
|
-
$('#query').click(function(){
|
105
|
-
$(this).select();
|
106
|
-
});
|
107
|
-
});
|
108
|
-
|
109
|
-
function update_package(package_name)
|
110
|
-
{
|
72
|
+
function update_package(package_name) {
|
111
73
|
// click button
|
112
74
|
$("#updateModal .modal-body").html("<h4>更新中... <img src='/images/waiting.gif'/></h4>");
|
113
75
|
$("#updateCancel").addClass("hide");
|
@@ -127,8 +89,7 @@ function update_package(package_name)
|
|
127
89
|
);
|
128
90
|
}
|
129
91
|
|
130
|
-
function clippy_text(text, bgcolor)
|
131
|
-
{
|
92
|
+
function clippy_text(text, bgcolor) {
|
132
93
|
return ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
|
133
94
|
' width="110"' +
|
134
95
|
' height="14"' +
|
@@ -153,8 +114,7 @@ function clippy_text(text, bgcolor)
|
|
153
114
|
' </object>';
|
154
115
|
}
|
155
116
|
|
156
|
-
function lineno_setup(path, lineno)
|
157
|
-
{
|
117
|
+
function lineno_setup(path, lineno) {
|
158
118
|
var n_lineno = "#n" + lineno;
|
159
119
|
|
160
120
|
// scroll reset
|
@@ -176,3 +136,41 @@ function lineno_setup(path, lineno)
|
|
176
136
|
$("#lineno-copyall").html("Lineno + Text" + clippy_text(directpath + " " + escapeHTML(n_lineno_dom.text()), '#F5F5F5'));
|
177
137
|
}
|
178
138
|
|
139
|
+
$(document).ready(function() {
|
140
|
+
$("select#package").multiselect({
|
141
|
+
multiple: false,
|
142
|
+
header: "",
|
143
|
+
selectedList: 1,
|
144
|
+
height: 450
|
145
|
+
}).multiselectfilter();
|
146
|
+
|
147
|
+
$("select#package_home").multiselect({
|
148
|
+
multiple: false,
|
149
|
+
header: "",
|
150
|
+
selectedList: 1,
|
151
|
+
height: 350
|
152
|
+
}).multiselectfilter();
|
153
|
+
|
154
|
+
$("#updateOk").click(function (e) {
|
155
|
+
update_package($("#updateOk").attr("milkode-package-name"));
|
156
|
+
return false;
|
157
|
+
});
|
158
|
+
|
159
|
+
var match = document.URL.match(/.+(#n\d+)$/);
|
160
|
+
if ( match ) {
|
161
|
+
$(match[1]).addClass("select-line");
|
162
|
+
} else {
|
163
|
+
$("#query").select();
|
164
|
+
}
|
165
|
+
|
166
|
+
$('#query').click(function(){
|
167
|
+
$(this).select();
|
168
|
+
});
|
169
|
+
|
170
|
+
$('#shead').change(function(){
|
171
|
+
$('#search').click();
|
172
|
+
});
|
173
|
+
});
|
174
|
+
|
175
|
+
|
176
|
+
|
@@ -6,6 +6,7 @@
|
|
6
6
|
%head
|
7
7
|
%meta(charset='utf-8')
|
8
8
|
%title= [@title, @setting.home_title].compact.join(' - ')
|
9
|
+
%link(rel="shortcut icon" href="#{@setting.favicon}")
|
9
10
|
%link(rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all")
|
10
11
|
%link(rel="stylesheet" href="/css/bootstrap-responsive.min.css" type="text/css" media="all")
|
11
12
|
%link(rel="stylesheet" href="/css/milkode.css" type="text/css" media="all")
|
data/lib/milkode/cli.rb
CHANGED
@@ -33,9 +33,12 @@ Samples:
|
|
33
33
|
milk add http://example.com/urlfile.zip
|
34
34
|
milk add git://github.com/ongaeshi/milkode.git
|
35
35
|
EOF
|
36
|
-
option :empty,
|
37
|
-
option :ignore,
|
38
|
-
option :
|
36
|
+
option :empty, :type => :boolean, :desc => 'Add empty package.'
|
37
|
+
option :ignore, :type => :array, :aliases => '-i', :desc => 'Ignore path.'
|
38
|
+
option :name, :type => :string, :aliases => '-n', :desc => 'Rename package.'
|
39
|
+
option :no_auto_ignore, :type => :boolean, :aliases => '--ni', :desc => 'Disable auto ignore.'
|
40
|
+
option :protocol, :type => :string, :aliases => '-p', :desc => 'Specify protocol. (git, svn)'
|
41
|
+
|
39
42
|
option :verbose, :type => :boolean, :aliases => '-v', :desc => 'Be verbose.'
|
40
43
|
|
41
44
|
def add(*args)
|
data/lib/milkode/common/util.rb
CHANGED
@@ -116,6 +116,10 @@ module Milkode
|
|
116
116
|
keyword =~ /\A\/.*:\d+\Z/
|
117
117
|
end
|
118
118
|
|
119
|
+
def fuzzy_gotoline_keyword?(keyword)
|
120
|
+
keyword =~ /\A.*:\d+\Z/
|
121
|
+
end
|
122
|
+
|
119
123
|
# parse_gotoline(['a', '123', 'b']) #=> [['a', 'b'], 123]]
|
120
124
|
# parse_gotoline(['a', '123', 'b', 55]) #=> [['a', 'b', '123'], 55]]
|
121
125
|
# parse_gotoline(['a:5']) #=> [['a'], 55]]
|
@@ -179,6 +183,10 @@ module Milkode
|
|
179
183
|
(src =~ /^(:?git[:@])|(:?ssh:)/) != nil
|
180
184
|
end
|
181
185
|
|
186
|
+
def svn_url?(src)
|
187
|
+
(src =~ /^(:?svn|svn\+ssh):\/\//) != nil
|
188
|
+
end
|
189
|
+
|
182
190
|
# StringIO patch
|
183
191
|
def pipe?(io)
|
184
192
|
!io.instance_of?(IO) || !File.pipe?(io)
|
@@ -187,6 +195,17 @@ module Milkode
|
|
187
195
|
def warning_alert(out, msg)
|
188
196
|
out.puts "[warning] #{msg}"
|
189
197
|
end
|
198
|
+
|
199
|
+
def load_content(out, filename)
|
200
|
+
str = File.read(filename)
|
201
|
+
begin
|
202
|
+
Kconv.kconv(str, Kconv::UTF8)
|
203
|
+
rescue ArgumentError
|
204
|
+
warning_alert(out, "skip kconv. file size too big (or negative string size) : #{filename}.")
|
205
|
+
str
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
190
209
|
end
|
191
210
|
end
|
192
211
|
|
@@ -33,6 +33,37 @@ module Milkode
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
# レコードをまとめて削除する
|
38
|
+
# 検索結果にマッチしたレコード等をまとめて削除
|
39
|
+
# 削除前にインデックスを削除し、削除後にインデックスを再度追加してい
|
40
|
+
# 大量のレコードを削除する場合に高速に動作する
|
41
|
+
def remove_records(records, &block)
|
42
|
+
Groonga::Schema.define do |schema|
|
43
|
+
schema.change_table("terms") do |table|
|
44
|
+
table.remove_index("documents.path")
|
45
|
+
table.remove_index("documents.package")
|
46
|
+
table.remove_index("documents.restpath")
|
47
|
+
table.remove_index("documents.content")
|
48
|
+
table.remove_index("documents.suffix")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
records.each do |record|
|
53
|
+
yield record if block
|
54
|
+
record.key.delete
|
55
|
+
end
|
56
|
+
|
57
|
+
Groonga::Schema.define do |schema|
|
58
|
+
schema.change_table("terms") do |table|
|
59
|
+
table.index("documents.path", :with_position => true)
|
60
|
+
table.index("documents.package", :with_position => true)
|
61
|
+
table.index("documents.restpath", :with_position => true)
|
62
|
+
table.index("documents.content", :with_position => true)
|
63
|
+
table.index("documents.suffix", :with_position => true)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
36
67
|
|
37
68
|
def initialize(table)
|
38
69
|
@table = table
|
@@ -94,19 +125,12 @@ module Milkode
|
|
94
125
|
@table[name].delete
|
95
126
|
end
|
96
127
|
|
97
|
-
def remove_match_path(path)
|
98
|
-
|
99
|
-
|
100
|
-
result.each do |r|
|
101
|
-
yield r if block_given?
|
102
|
-
r.record_id.delete
|
103
|
-
end
|
128
|
+
def remove_match_path(path, &block)
|
129
|
+
remove_records(search(:paths => [path]), &block)
|
104
130
|
end
|
105
131
|
|
106
|
-
def remove_all
|
107
|
-
|
108
|
-
r.record_id.delete
|
109
|
-
end
|
132
|
+
def remove_all(&block)
|
133
|
+
remove_records(@table.select, &block)
|
110
134
|
end
|
111
135
|
|
112
136
|
# shortpathの一致するレコードを取得
|
@@ -137,7 +161,7 @@ module Milkode
|
|
137
161
|
unless File.exist? r.path
|
138
162
|
yield r if block_given?
|
139
163
|
# p r.restpath
|
140
|
-
r.
|
164
|
+
remove(r.path)
|
141
165
|
end
|
142
166
|
end
|
143
167
|
end
|
@@ -301,16 +325,16 @@ module Milkode
|
|
301
325
|
end
|
302
326
|
|
303
327
|
# 指定されたパッケージのクリーンアップ
|
304
|
-
def cleanup_package_name(
|
328
|
+
def cleanup_package_name(package_name)
|
305
329
|
# クリーンアップ対象のファイルを検索
|
306
|
-
result = @table.select { |record| record.package ==
|
330
|
+
result = @table.select { |record| record.package == package_name }
|
307
331
|
|
308
332
|
# 存在しないファイルの削除
|
309
333
|
result.each do |r|
|
310
334
|
unless File.exist? r.path
|
311
335
|
yield r if block_given?
|
312
336
|
# p r.restpath
|
313
|
-
r.
|
337
|
+
remove(r.path)
|
314
338
|
end
|
315
339
|
end
|
316
340
|
end
|
@@ -334,13 +358,7 @@ module Milkode
|
|
334
358
|
private
|
335
359
|
|
336
360
|
def load_content(filename)
|
337
|
-
|
338
|
-
begin
|
339
|
-
Kconv.kconv(str, Kconv::UTF8)
|
340
|
-
rescue ArgumentError
|
341
|
-
Util.warning_alert($stdout, "skip kconv. file size too big (or negative string size) : #{filename}.")
|
342
|
-
str
|
343
|
-
end
|
361
|
+
Util::load_content($stdout, filename)
|
344
362
|
end
|
345
363
|
|
346
364
|
def package_expression(record, packages)
|
@@ -30,6 +30,11 @@ module Milkode
|
|
30
30
|
Dir.chdir(@package.directory) { system("git pull") }
|
31
31
|
end
|
32
32
|
|
33
|
+
# svn update
|
34
|
+
if @options[:update_with_svn_update]
|
35
|
+
Dir.chdir(@package.directory) { system("svn update") }
|
36
|
+
end
|
37
|
+
|
33
38
|
# cleanup
|
34
39
|
unless @options[:no_clean]
|
35
40
|
@grndb.documents.cleanup_package_name(@package_name)
|
@@ -62,6 +67,10 @@ module Milkode
|
|
62
67
|
@options[:update_with_git_pull] = true
|
63
68
|
end
|
64
69
|
|
70
|
+
def enable_update_with_svn_update
|
71
|
+
@options[:update_with_svn_update] = true
|
72
|
+
end
|
73
|
+
|
65
74
|
def enable_no_clean
|
66
75
|
@options[:no_clean] = true
|
67
76
|
end
|
@@ -209,14 +218,12 @@ module Milkode
|
|
209
218
|
end
|
210
219
|
|
211
220
|
def add_current_gitignore(dirname, path)
|
212
|
-
|
221
|
+
filename = File.join(dirname, path, ".gitignore")
|
213
222
|
|
214
|
-
if File.exist?
|
215
|
-
alert_info("add_ignore",
|
216
|
-
|
217
|
-
|
218
|
-
@current_ignore.add IgnoreSetting.create_from_gitignore(path, f.read)
|
219
|
-
end
|
223
|
+
if File.exist? filename
|
224
|
+
alert_info("add_ignore", filename)
|
225
|
+
str = Util::load_content($stdout, filename)
|
226
|
+
@current_ignore.add IgnoreSetting.create_from_gitignore(path, str)
|
220
227
|
end
|
221
228
|
end
|
222
229
|
|
@@ -20,6 +20,7 @@ module FindGrep
|
|
20
20
|
:directory,
|
21
21
|
:depth,
|
22
22
|
:ignoreCase,
|
23
|
+
:caseSensitive,
|
23
24
|
:colorHighlight,
|
24
25
|
:isSilent,
|
25
26
|
:debugMode,
|
@@ -47,6 +48,7 @@ module FindGrep
|
|
47
48
|
false,
|
48
49
|
false,
|
49
50
|
false,
|
51
|
+
false,
|
50
52
|
[],
|
51
53
|
[],
|
52
54
|
[],
|
@@ -68,15 +70,15 @@ module FindGrep
|
|
68
70
|
attr_reader :documents
|
69
71
|
|
70
72
|
def initialize(patterns, option)
|
71
|
-
@patterns
|
72
|
-
@option
|
73
|
-
@patternRegexps = strs2regs(patterns
|
74
|
-
@subRegexps
|
75
|
-
@orRegexps
|
76
|
-
@filePatterns
|
77
|
-
@ignoreFiles
|
78
|
-
@ignoreDirs
|
79
|
-
@result
|
73
|
+
@patterns = patterns
|
74
|
+
@option = option
|
75
|
+
@patternRegexps = strs2regs(patterns)
|
76
|
+
@subRegexps = strs2regs(option.patternsNot)
|
77
|
+
@orRegexps = strs2regs(option.patternsOr)
|
78
|
+
@filePatterns = (!@option.dbFile) ? strs2regs_simple(option.filePatterns) : []
|
79
|
+
@ignoreFiles = strs2regs_simple(option.ignoreFiles)
|
80
|
+
@ignoreDirs = strs2regs_simple(option.ignoreDirs)
|
81
|
+
@result = Result.new(option.directory)
|
80
82
|
open_database if (@option.dbFile)
|
81
83
|
end
|
82
84
|
|
@@ -97,18 +99,28 @@ module FindGrep
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
100
|
-
def strs2regs(strs
|
102
|
+
def strs2regs(strs)
|
101
103
|
regs = []
|
102
104
|
|
103
105
|
strs.each do |v|
|
104
106
|
option = 0
|
105
|
-
option |= Regexp::IGNORECASE if (
|
107
|
+
option |= Regexp::IGNORECASE if (@option.ignoreCase || (!@option.caseSensitive && Milkode::Util::downcase?(v)))
|
106
108
|
regs << Regexp.new(v, option)
|
107
109
|
end
|
108
110
|
|
109
111
|
regs
|
110
112
|
end
|
111
113
|
|
114
|
+
def strs2regs_simple(strs)
|
115
|
+
regs = []
|
116
|
+
|
117
|
+
strs.each do |v|
|
118
|
+
regs << Regexp.new(v, 0)
|
119
|
+
end
|
120
|
+
|
121
|
+
regs
|
122
|
+
end
|
123
|
+
|
112
124
|
def searchAndPrint(stdout)
|
113
125
|
unless (@option.dbFile)
|
114
126
|
searchFromDir(stdout, @option.directory, 0)
|