milkode 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/Gemfile
CHANGED
data/HISTORY.ja.rdoc
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
=== 0.9.6 2012/12/28
|
2
|
+
|
3
|
+
* milk web
|
4
|
+
* 絞り込み検索
|
5
|
+
* 拡張子で絞り込み
|
6
|
+
* ディレクトリで絞り込み
|
7
|
+
* ファイル名 + キーワード検索
|
8
|
+
* 'path/to/file def kwd'で'path/to/dir'ファイル内の'def kwd'を含む行を検索可能に
|
9
|
+
* あいまいジャンプ
|
10
|
+
* 'a/filename:15' でマッチしたファイルの指定行に直接ジャンプ
|
11
|
+
* 検索マッチ数が1つの時はファイル本体を表示
|
12
|
+
* g:オプションを付けると確実にジャンプ
|
13
|
+
* おすすめ検索クエリ
|
14
|
+
* ファイル名+キーワード(fp:)、あいまいジャンプモード(g:) 等のクエリを示唆
|
15
|
+
* faviconに対応
|
16
|
+
* その他
|
17
|
+
* 'AName name'で検索した時、'name'は大文字/小文字どちらでもマッチするように
|
18
|
+
* 範囲セレクトボックスを切り替えた時に自動的に再検索
|
19
|
+
* milkode.js: コーディングスタイル変更
|
20
|
+
* バグ修正
|
21
|
+
* Windows環境にて、左上の範囲セレクトボックスが文字化けする問題を修正
|
22
|
+
* .gitignoreが非UTF-8でも読み込めるように
|
23
|
+
|
24
|
+
* milk
|
25
|
+
* svnに対応 (milk add -p svn http://svn/trunk -n a_proj)
|
26
|
+
* milk remove, rebuild の高速化
|
27
|
+
* 'タブを複製'ボタンを押すとアンカーが消えてしまう問題を修正
|
28
|
+
* データベースディレクトリで milk pwd した時は専用メッセージ (On database in XXX)
|
29
|
+
|
1
30
|
=== 0.9.5 2012/12/09
|
2
31
|
|
3
32
|
* milk web
|
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 0.9.6 2012/12/28
|
2
|
+
|
3
|
+
* milk web
|
4
|
+
* Narrow down search
|
5
|
+
* filename + keyword search
|
6
|
+
* Fuzzy direct jump
|
7
|
+
* Recommended search query
|
8
|
+
* Support favicon
|
9
|
+
* Bug fix
|
10
|
+
|
11
|
+
* milk
|
12
|
+
* Support svn (milk add -p svn http://svn/trunk -n a_proj)
|
13
|
+
* Quickly milk remove & rebuild
|
14
|
+
|
1
15
|
=== 0.9.5 2012/12/09
|
2
16
|
|
3
17
|
* milk web
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.6
|
data/bin/gmilk
CHANGED
data/bin/milk
CHANGED
data/lib/milkode/cdstk/cdstk.rb
CHANGED
@@ -28,6 +28,8 @@ require 'milkode/common/plang_detector'
|
|
28
28
|
|
29
29
|
module Milkode
|
30
30
|
class IgnoreError < RuntimeError ; end
|
31
|
+
class AddError < RuntimeError ; end
|
32
|
+
class ConvertError < RuntimeError ; end
|
31
33
|
|
32
34
|
class Cdstk
|
33
35
|
# バイグラムでトークナイズする。連続する記号・アルファベット・数字は一語として扱う。
|
@@ -36,8 +38,6 @@ module Milkode
|
|
36
38
|
# 記号・アルファベット・数字もバイグラムでトークナイズする。
|
37
39
|
DEFAULT_TOKENIZER = "TokenBigramSplitSymbolAlphaDigit"
|
38
40
|
|
39
|
-
class ConvetError < RuntimeError ; end
|
40
|
-
|
41
41
|
def initialize(io = $stdout, db_dir = ".")
|
42
42
|
@db_dir = db_dir
|
43
43
|
@out = io
|
@@ -131,26 +131,30 @@ module Milkode
|
|
131
131
|
begin
|
132
132
|
dirs.each do |v|
|
133
133
|
# コンテンツを読み込める形に変換
|
134
|
-
dir = convert_content(v)
|
134
|
+
dir = convert_content(v, options)
|
135
135
|
|
136
136
|
# YAMLに追加
|
137
137
|
package = Package.create(dir, options[:ignore])
|
138
138
|
add_yaml(package)
|
139
139
|
|
140
140
|
# オプション設定
|
141
|
-
is_update_with_git_pull
|
142
|
-
|
141
|
+
is_update_with_git_pull = git_protocol?(options, v)
|
142
|
+
is_update_with_svn_update = svn_protocol?(options, v)
|
143
|
+
set_yaml_options(package, options, is_update_with_git_pull, is_update_with_svn_update)
|
143
144
|
|
144
145
|
# アップデート
|
145
146
|
update_dir_in(dir) unless options[:empty]
|
146
147
|
end
|
147
|
-
rescue
|
148
|
+
rescue AddError => e
|
149
|
+
error_alert(e.message)
|
150
|
+
return
|
151
|
+
rescue ConvertError => e
|
148
152
|
return
|
149
153
|
end
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
153
|
-
def set_yaml_options(package, options, is_update_with_git_pull)
|
157
|
+
def set_yaml_options(package, options, is_update_with_git_pull, is_update_with_svn_update)
|
154
158
|
is_dirty = false
|
155
159
|
|
156
160
|
if options[:no_auto_ignore]
|
@@ -160,16 +164,24 @@ module Milkode
|
|
160
164
|
is_dirty = true
|
161
165
|
end
|
162
166
|
|
163
|
-
|
167
|
+
# ローカルディレクトリの名前変更は後回し
|
168
|
+
# if options[:name]
|
169
|
+
# dst = package.options
|
170
|
+
# dst[:name] = src[:name]
|
171
|
+
# package.set_options(dst)
|
172
|
+
# is_dirty = true
|
173
|
+
# end
|
174
|
+
|
175
|
+
if is_update_with_git_pull
|
164
176
|
dst = package.options
|
165
|
-
dst[:
|
177
|
+
dst[:update_with_git_pull] = is_update_with_git_pull
|
166
178
|
package.set_options(dst)
|
167
179
|
is_dirty = true
|
168
180
|
end
|
169
181
|
|
170
|
-
if
|
182
|
+
if is_update_with_svn_update
|
171
183
|
dst = package.options
|
172
|
-
dst[:
|
184
|
+
dst[:update_with_svn_update] = is_update_with_svn_update
|
173
185
|
package.set_options(dst)
|
174
186
|
is_dirty = true
|
175
187
|
end
|
@@ -211,10 +223,12 @@ module Milkode
|
|
211
223
|
@grndb.yaml_sync(@yaml.contents)
|
212
224
|
end
|
213
225
|
|
214
|
-
def convert_content(src)
|
226
|
+
def convert_content(src, options)
|
215
227
|
# httpファイルならダウンロード
|
216
228
|
begin
|
217
|
-
src = download_file(src)
|
229
|
+
src = download_file(src, options)
|
230
|
+
rescue AddError => e
|
231
|
+
raise e
|
218
232
|
rescue => e
|
219
233
|
error_alert("download failure '#{src}'.")
|
220
234
|
raise e # そのまま上に持ち上げてスタックトレース表示
|
@@ -245,21 +259,19 @@ module Milkode
|
|
245
259
|
end
|
246
260
|
end
|
247
261
|
|
248
|
-
def download_file(src)
|
249
|
-
if (src
|
262
|
+
def download_file(src, options)
|
263
|
+
if git_protocol?(options, src)
|
264
|
+
git_clone_in(src, options)
|
265
|
+
elsif svn_protocol?(options, src)
|
266
|
+
svn_clone_in(src, options)
|
267
|
+
elsif src =~ /^https?:/
|
250
268
|
download_file_in(src)
|
251
|
-
elsif (git_url? src)
|
252
|
-
git_clone_in(src)
|
253
269
|
else
|
270
|
+
raise AddError, "'--name' option is not available in local directory." if options[:name]
|
254
271
|
src
|
255
272
|
end
|
256
273
|
end
|
257
274
|
|
258
|
-
def git_url?(src)
|
259
|
-
Util::git_url?(src)
|
260
|
-
end
|
261
|
-
private :git_url?
|
262
|
-
|
263
275
|
def download_file_in(url)
|
264
276
|
alert("download", "#{url}")
|
265
277
|
|
@@ -277,13 +289,12 @@ module Milkode
|
|
277
289
|
filename
|
278
290
|
end
|
279
291
|
|
280
|
-
def git_clone_in(url)
|
292
|
+
def git_clone_in(url, options)
|
281
293
|
alert("git", url)
|
282
294
|
|
283
|
-
dst_dir
|
284
|
-
|
285
|
-
|
286
|
-
filename = File.join(dst_dir, File.basename(url).sub(/\.git\Z/, ""))
|
295
|
+
dst_dir = File.join(@db_dir, "packages/git")
|
296
|
+
name = options[:name] || File.basename(url).sub(/\.git\Z/, "")
|
297
|
+
filename = File.join(dst_dir, name)
|
287
298
|
|
288
299
|
# git output progress to stderr.
|
289
300
|
# `git clone #{url} #{filename} 2>&1`
|
@@ -294,6 +305,19 @@ module Milkode
|
|
294
305
|
filename
|
295
306
|
end
|
296
307
|
|
308
|
+
def svn_clone_in(url, options)
|
309
|
+
alert("svn", url)
|
310
|
+
|
311
|
+
dst_dir = File.join(@db_dir, "packages/svn")
|
312
|
+
name = options[:name] || File.basename(url)
|
313
|
+
filename = File.join(dst_dir, name)
|
314
|
+
|
315
|
+
# with output
|
316
|
+
system("svn checkout #{url} #{filename}")
|
317
|
+
|
318
|
+
filename
|
319
|
+
end
|
320
|
+
|
297
321
|
def remove_all
|
298
322
|
print_result do
|
299
323
|
list([], {:verbose => true})
|
@@ -301,9 +325,19 @@ module Milkode
|
|
301
325
|
if yes_or_no("Remove #{@yaml.contents.size} contents? (yes/no)")
|
302
326
|
db_open
|
303
327
|
|
304
|
-
|
305
|
-
|
328
|
+
# documents
|
329
|
+
@documents.remove_all do |record|
|
330
|
+
alert_info("rm_record", record.path)
|
331
|
+
@file_count += 1
|
306
332
|
end
|
333
|
+
|
334
|
+
# packages
|
335
|
+
@grndb.packages.remove_all
|
336
|
+
|
337
|
+
# yaml
|
338
|
+
@package_count += @yaml.contents.size
|
339
|
+
@yaml.remove_all
|
340
|
+
@yaml.save
|
307
341
|
else
|
308
342
|
return
|
309
343
|
end
|
@@ -453,7 +487,16 @@ module Milkode
|
|
453
487
|
@out.puts dir
|
454
488
|
else
|
455
489
|
package = @yaml.package_root(File.expand_path('.'))
|
456
|
-
|
490
|
+
|
491
|
+
name = ""
|
492
|
+
if package
|
493
|
+
name = package.name
|
494
|
+
elsif Dbdir.dbdir?
|
495
|
+
name = 'On database'
|
496
|
+
else
|
497
|
+
name = 'Not package dir'
|
498
|
+
end
|
499
|
+
|
457
500
|
@out.puts "#{name} in #{dir}"
|
458
501
|
end
|
459
502
|
else
|
@@ -907,6 +950,14 @@ EOF
|
|
907
950
|
|
908
951
|
private
|
909
952
|
|
953
|
+
def git_protocol?(options, src)
|
954
|
+
options[:protocol] == 'git' || Util::git_url?(src)
|
955
|
+
end
|
956
|
+
|
957
|
+
def svn_protocol?(options, src)
|
958
|
+
options[:protocol] == 'svn' || Util::svn_url?(src)
|
959
|
+
end
|
960
|
+
|
910
961
|
def db_file
|
911
962
|
Dbdir.expand_groonga_path(@db_dir)
|
912
963
|
end
|
@@ -920,7 +971,7 @@ EOF
|
|
920
971
|
end
|
921
972
|
|
922
973
|
def update_package_in(package, options)
|
923
|
-
updater_exec(package, package.options[:update_with_git_pull], options[:no_clean])
|
974
|
+
updater_exec(package, package.options[:update_with_git_pull], package.options[:update_with_svn_update], options[:no_clean])
|
924
975
|
end
|
925
976
|
|
926
977
|
def update_dir_in(dir)
|
@@ -930,20 +981,21 @@ EOF
|
|
930
981
|
warning_alert("#{dir} (Not found, skip)")
|
931
982
|
else
|
932
983
|
package = @yaml.package_root(dir)
|
933
|
-
updater_exec(package, false, false)
|
984
|
+
updater_exec(package, false, false, false)
|
934
985
|
end
|
935
986
|
end
|
936
987
|
|
937
|
-
def updater_exec(package, is_update_with_git_pull, is_no_clean)
|
988
|
+
def updater_exec(package, is_update_with_git_pull, is_update_with_svn_update, is_no_clean)
|
938
989
|
alert("package", package.name )
|
939
990
|
|
940
991
|
updater = Updater.new(@grndb, package.name)
|
941
992
|
updater.set_package_ignore IgnoreSetting.new("/", package.ignore)
|
942
|
-
updater.enable_no_auto_ignore
|
943
|
-
updater.enable_silent_mode
|
944
|
-
updater.enable_display_info
|
945
|
-
updater.enable_update_with_git_pull
|
946
|
-
updater.
|
993
|
+
updater.enable_no_auto_ignore if package.options[:no_auto_ignore]
|
994
|
+
updater.enable_silent_mode if @is_silent
|
995
|
+
updater.enable_display_info if @is_display_info
|
996
|
+
updater.enable_update_with_git_pull if is_update_with_git_pull
|
997
|
+
updater.enable_update_with_svn_update if is_update_with_svn_update
|
998
|
+
updater.enable_no_clean if is_no_clean
|
947
999
|
updater.exec
|
948
1000
|
|
949
1001
|
@package_count += 1
|
data/lib/milkode/cdweb/app.rb
CHANGED
@@ -22,7 +22,7 @@ set :haml, :format => :html5
|
|
22
22
|
|
23
23
|
get '/' do
|
24
24
|
@setting = WebSetting.new
|
25
|
-
@version = "0.9.
|
25
|
+
@version = "0.9.6"
|
26
26
|
@package_num = Database.instance.yaml_package_num
|
27
27
|
@file_num = Database.instance.totalRecords
|
28
28
|
@package_list = PackageList.new(Database.instance.grndb)
|
@@ -136,7 +136,7 @@ helpers do
|
|
136
136
|
|
137
137
|
<<EOF
|
138
138
|
<select name="shead" id="shead">
|
139
|
-
#{data.map{|v| "<option value='#{v[0]}' #{v[0] == value ? 'selected' : ''}>#{v[1]}</option>"}}
|
139
|
+
#{data.map{|v| "<option value='#{v[0]}' #{v[0] == value ? 'selected' : ''}>#{v[1]}</option>"}.join}
|
140
140
|
</select>
|
141
141
|
EOF
|
142
142
|
end
|
@@ -148,7 +148,7 @@ EOF
|
|
148
148
|
|
149
149
|
<<EOF
|
150
150
|
<select name="package" id="package" onchange="select_package()">
|
151
|
-
#{data.map{|v| "<option value='#{v}' #{v == value ? 'selected' : ''}>#{v}</option>"}}
|
151
|
+
#{data.map{|v| "<option value='#{v}' #{v == value ? 'selected' : ''}>#{v}</option>"}.join}
|
152
152
|
</select>
|
153
153
|
EOF
|
154
154
|
end
|
@@ -159,7 +159,7 @@ EOF
|
|
159
159
|
|
160
160
|
<<EOF
|
161
161
|
<select name="package" id="package_home" onchange="select_package_home()">
|
162
|
-
#{data.map{|v| "<option value='#{v}' #{v == value ? 'selected' : ''}>#{v}</option>"}}
|
162
|
+
#{data.map{|v| "<option value='#{v}' #{v == value ? 'selected' : ''}>#{v}</option>"}.join}
|
163
163
|
</select>
|
164
164
|
EOF
|
165
165
|
end
|
@@ -183,7 +183,7 @@ EOF
|
|
183
183
|
|
184
184
|
<<EOF
|
185
185
|
#{headicon('go-home-5.png')} <a href="/home" class="headmenu">ホーム</a>
|
186
|
-
#{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open(
|
186
|
+
#{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open(document.URL); return false;">タブを複製</a>
|
187
187
|
#{headicon('directory.png')} <a href="#{flist}" class="headmenu">ディレクトリ</a>
|
188
188
|
#{headicon('view-refresh-4.png')} <a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>
|
189
189
|
#{headicon('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
|
@@ -10,6 +10,7 @@ require 'milkode/cdweb/lib/coderay_wrapper'
|
|
10
10
|
require 'milkode/cdweb/lib/search_contents'
|
11
11
|
require 'milkode/cdweb/lib/search_files'
|
12
12
|
require 'milkode/cdweb/lib/search_gotoline'
|
13
|
+
require 'milkode/cdweb/lib/search_fuzzy_gotoline'
|
13
14
|
require 'milkode/cdweb/lib/mkurl'
|
14
15
|
require 'milkode/common/util'
|
15
16
|
|
@@ -52,11 +53,22 @@ module Milkode
|
|
52
53
|
query = Query.new(params[:query])
|
53
54
|
@title = "'#{query.query_string}' in #{path_title(path)}"
|
54
55
|
|
55
|
-
if (query.
|
56
|
-
|
56
|
+
if (query.gotolines.size > 0)
|
57
|
+
searcher = SearchFuzzyGotoLine.new(path, params, query)
|
58
|
+
|
59
|
+
if searcher.directjump?
|
60
|
+
redirect searcher.directjump_url
|
61
|
+
end
|
62
|
+
|
63
|
+
elsif (query.keywords.size > 0)
|
64
|
+
if Util::gotoline_keyword?(query.keywords[0])
|
57
65
|
searcher = SearchGotoLine.new(path, params, query)
|
58
66
|
else
|
59
67
|
searcher = SearchContents.new(path, params, query)
|
68
|
+
|
69
|
+
if searcher.directjump?
|
70
|
+
redirect searcher.directjump_url
|
71
|
+
end
|
60
72
|
end
|
61
73
|
else
|
62
74
|
searcher = SearchFiles.new(path, params, query)
|
@@ -114,8 +126,12 @@ module Milkode
|
|
114
126
|
private
|
115
127
|
|
116
128
|
def file_or_dirimg(is_file)
|
117
|
-
src = (is_file) ? '
|
118
|
-
|
129
|
+
src = (is_file) ? 'file.png' : 'directory.png'
|
130
|
+
img_icon(src)
|
131
|
+
end
|
132
|
+
|
133
|
+
def img_icon(srcfile)
|
134
|
+
"<img alt='' style='vertical-align:bottom; border: 0; margin: 1px;' src='/images/#{srcfile}'>"
|
119
135
|
end
|
120
136
|
|
121
137
|
def sort_change_content(current_value, text, sort_kind = nil)
|