milkode 0.9.9 → 0.9.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.travis.yml +2 -1
  2. data/Gemfile +12 -11
  3. data/HISTORY.ja.rdoc +41 -1
  4. data/HISTORY.rdoc +28 -1
  5. data/VERSION +1 -1
  6. data/bin/gmilk +1 -1
  7. data/bin/milk +1 -1
  8. data/lib/milkode/cdstk/cdstk.rb +15 -1
  9. data/lib/milkode/cdstk/package.rb +16 -0
  10. data/lib/milkode/cdweb/app.rb +72 -9
  11. data/lib/milkode/cdweb/cli_cdweb.rb +25 -55
  12. data/lib/milkode/cdweb/lib/database.rb +14 -0
  13. data/lib/milkode/cdweb/lib/info_home.rb +30 -0
  14. data/lib/milkode/cdweb/lib/info_package.rb +83 -0
  15. data/lib/milkode/cdweb/lib/package_list.rb +18 -0
  16. data/lib/milkode/cdweb/public/css/milkode.css +93 -8
  17. data/lib/milkode/cdweb/public/images/info-big.png +0 -0
  18. data/lib/milkode/cdweb/public/images/info.png +0 -0
  19. data/lib/milkode/cdweb/public/images/milkode-directpath-copy.gif +0 -0
  20. data/lib/milkode/cdweb/public/images/milkode-star.png +0 -0
  21. data/lib/milkode/cdweb/public/js/milkode.js +35 -5
  22. data/lib/milkode/cdweb/views/filelist.haml +9 -1
  23. data/lib/milkode/cdweb/views/header_menu.haml +1 -1
  24. data/lib/milkode/cdweb/views/help.haml +70 -23
  25. data/lib/milkode/cdweb/views/info_home.haml +14 -0
  26. data/lib/milkode/cdweb/views/info_package.haml +13 -0
  27. data/lib/milkode/cdweb/views/layout.haml +1 -0
  28. data/lib/milkode/cdweb/views/packages.haml +6 -2
  29. data/lib/milkode/cdweb/views/search.haml +13 -7
  30. data/lib/milkode/cdweb/views/search_form.haml +2 -0
  31. data/lib/milkode/cdweb/views/view.haml +9 -1
  32. data/lib/milkode/cli.rb +3 -2
  33. data/lib/milkode/common/util.rb +6 -2
  34. data/lib/milkode/database/document_table.rb +4 -0
  35. data/lib/milkode/database/package_table.rb +4 -0
  36. data/lib/milkode/grep/cli_grep.rb +48 -36
  37. data/lib/milkode/grep/fast_gotoline.rb +53 -0
  38. data/lib/milkode/{findgrep → grep}/findgrep.rb +42 -56
  39. data/lib/milkode/grep/findgrep_option.rb +63 -0
  40. data/milkode.gemspec +22 -11
  41. data/test/test_cli.rb +3 -1
  42. data/test/test_cli_grep.rb +1 -1
  43. data/test/test_findgrep.rb +2 -2
  44. data/test/test_milkode_yaml.rb +48 -4
  45. data/test/test_query.rb +2 -0
  46. metadata +39 -22
  47. data/lib/milkode/common/archive-zip.rb +0 -10
  48. data/lib/milkode/findgrep/result.rb +0 -43
@@ -7,8 +7,9 @@ notifications:
7
7
  - ongaeshi0621@gmail.com
8
8
 
9
9
  rvm:
10
- - 1.8.7
10
+ # - 1.8.7
11
11
  - 1.9.3
12
+ - 2.0.0
12
13
 
13
14
  before_install:
14
15
  - curl https://raw.github.com/groonga/groonga/master/data/travis/setup.sh | sh
data/Gemfile CHANGED
@@ -4,17 +4,17 @@ source "http://rubygems.org"
4
4
  # Example:
5
5
  # gem "activesupport", ">= 2.3.5"
6
6
  # gemspec
7
- gem 'termcolor','>= 1.2.0', '< 1.2.2'
8
- gem 'rroonga','>= 1.1.0'
9
- gem 'rack','>=1.3.4', '~> 1.4.0'
10
- gem 'sinatra', '>=1.2.6'
11
- gem 'launchy', '>=0.3.7'
12
- gem 'coderay', '>=1.0.5'
13
- gem 'thin', '>=1.2.10'
14
- gem 'archive-zip', '>=0.4.0'
15
- gem 'haml', '>=3.1.2'
16
- gem 'sass', '>=3.1.3'
17
- gem 'thor', '~> 0.15.0'
7
+ gem 'termcolor' , '>= 1.2.0' , '< 1.2.2'
8
+ gem 'rroonga' , '>= 1.1.0'
9
+ gem 'rack' , '>= 1.5.2'
10
+ gem 'sinatra' , '>= 1.2.6'
11
+ gem 'launchy' , '>= 0.3.7'
12
+ gem 'coderay' , '>= 1.0.5'
13
+ gem 'thin' , '>= 1.2.10'
14
+ gem 'archive-zip' , '>= 0.4.0'
15
+ gem 'haml' , '>= 3.1.2'
16
+ gem 'sass' , '>= 3.1.3'
17
+ gem 'thor' , '>= 0.18.1'
18
18
 
19
19
  # Add dependencies to develop your gem here.
20
20
  # Include everything needed to run rake, tests, features, etc.
@@ -23,4 +23,5 @@ group :development do
23
23
  gem 'jeweler'
24
24
  gem 'rack-test'
25
25
  gem 'sinatra-reloader'
26
+ gem 'test-unit' , '>= 2.5.4'
26
27
  end
@@ -1,3 +1,44 @@
1
+ === 0.9.9.9 2013/05/05
2
+
3
+ * milk web
4
+ * お気に入りリスト
5
+ * お気に入りを付けたパッケージにすぐアクセス出来る
6
+ * ☆マークをクリックでwebアプリからも設定が可能に
7
+
8
+ * 統計情報ボタンの設置
9
+ * ファイル数、行数、言語別割合の表示をWebインターフェースで
10
+
11
+ * 「新規タブ」ボタンを設置
12
+ * タブを開きながら検索
13
+
14
+ * help.haml
15
+ * 全体的にリニューアル
16
+ * 'w:' オプションについて追記
17
+
18
+ * gmilk
19
+ * 依存関係を整理して、起動時間の高速化
20
+ * ダイレクトパス検索('gmilk /path/to/file:5')に関してはさらに高速化
21
+ * gmilk -d が正しく動いていない問題を修正
22
+
23
+ * milk
24
+ * milk fav --sync-yaml を追加
25
+ * webアプリ経由のお気に入り設定をyamlに取り込む
26
+
27
+ * etc
28
+ * Ruby2.0.0 に対応
29
+ * test/test_milkode_yaml.rb が動かない問題を修正: Yaml#dumpの取得形式が変わった
30
+ * Gemfile更新: test-unit >= 2.5.4
31
+ * .travis.yml に Ruby2.0 を追加
32
+
33
+ * Gemfile
34
+ * 'thor 0.18.1' に対応
35
+ * 'rack 1.5.2' に対応
36
+
37
+ * ファイル構造の整理 : findgrep/findgrep.rb -> grep/findgrep.rb
38
+
39
+ * バグ修正
40
+ * Issues#47 add meta tag for favicon (thanks y-ken)
41
+
1
42
  === 0.9.9 2013/02/26
2
43
 
3
44
  * ワイド範囲検索のサポート
@@ -13,7 +54,6 @@
13
54
  * export MILKODE_SINATRA_RELOADER=1
14
55
 
15
56
  * Delete 'milkode/cdweb/app_error.rb'
16
- * Recommend 'RACK_ENV=production'
17
57
 
18
58
  === 0.9.8 2013/02/27
19
59
 
@@ -1,3 +1,31 @@
1
+ === 0.9.9.9 2013/05/05
2
+
3
+ * milk web
4
+ * Add favorite-list
5
+ * Add info
6
+ * Add 「newtab」button
7
+ * Renewal help.haml
8
+
9
+ * gmilk
10
+ * Fast startup time
11
+ * Fast directpath search('gmilk /path/to/file:5') more
12
+ * Fix 'gmilk -d'
13
+
14
+ * milk
15
+ * Add 'milk fav --sync-yaml'
16
+
17
+ * etc
18
+ * Support Ruby2.0.0
19
+
20
+ * Gemfile
21
+ * Support 'thor 0.18.1'
22
+ * Support 'rack 1.5.2'
23
+
24
+ * findgrep/findgrep.rb -> grep/findgrep.rb
25
+
26
+ * Bug fix
27
+ * Issues#47 add meta tag for favicon (thanks y-ken)
28
+
1
29
  === 0.9.9 2013/02/26
2
30
 
3
31
  * Suppor wide range search
@@ -5,7 +33,6 @@
5
33
  * Support sinatra-reloader
6
34
  * export MILKODE_SINATRA_RELOADER=1
7
35
  * Delete 'milkode/cdweb/app_error.rb'
8
- * Recommend 'RACK_ENV=production'
9
36
 
10
37
  === 0.9.8 2013/02/27
11
38
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.9
1
+ 0.9.9.9
data/bin/gmilk CHANGED
@@ -6,5 +6,5 @@
6
6
  require 'rubygems'
7
7
  require 'milkode/grep/cli_grep'
8
8
 
9
- Version = "0.9.9"
9
+ Version = "0.9.9.9"
10
10
  Milkode::CLI_Grep.execute(STDOUT, ARGV)
data/bin/milk CHANGED
@@ -6,5 +6,5 @@
6
6
  require 'rubygems'
7
7
  require 'milkode/cli'
8
8
 
9
- Version = "0.9.9"
9
+ Version = "0.9.9.9"
10
10
  Milkode::CLI.start(ARGV)
@@ -428,7 +428,21 @@ module Milkode
428
428
  def fav(args, options)
429
429
  db_open
430
430
 
431
- if (args.empty?)
431
+ if (options[:sync_yaml])
432
+ is_dirty = false
433
+
434
+ @yaml.contents.each do |package|
435
+ db_fav = @grndb.packages.fav?(package.name)
436
+ if package.fav? != db_fav
437
+ @out.puts "#{package.name} : #{package.fav?} -> #{db_fav}"
438
+ package.set_fav(db_fav)
439
+ is_dirty = true
440
+ end
441
+ end
442
+
443
+ @yaml.save if is_dirty
444
+
445
+ elsif (args.empty?)
432
446
  @out.puts @grndb.packages.favs.map{|r| r.name}
433
447
  else
434
448
  is_dirty = false
@@ -69,6 +69,22 @@ module Milkode
69
69
  name == rhs.name && directory == rhs.directory && ignore == rhs.ignore
70
70
  end
71
71
 
72
+ def fav?
73
+ options[:fav] == true
74
+ end
75
+
76
+ def set_fav(value)
77
+ if value
78
+ if @hash['options']
79
+ @hash['options'][:fav] = true
80
+ else
81
+ @hash['options'] = {:fav => true}
82
+ end
83
+ else
84
+ @hash['options'].delete(:fav) if @hash['options']
85
+ end
86
+ end
87
+
72
88
  private
73
89
 
74
90
  def normalize
@@ -15,19 +15,21 @@ require 'sass'
15
15
  require 'haml'
16
16
 
17
17
  $LOAD_PATH.unshift '../..'
18
+ require 'milkode/common/util'
18
19
  require 'milkode/cdweb/lib/database'
19
20
  require 'milkode/cdweb/lib/command'
20
21
  require 'milkode/cdweb/lib/mkurl'
21
22
  require 'milkode/cdweb/lib/web_setting'
22
23
  require 'milkode/cdweb/lib/package_list'
23
- require 'milkode/common/util'
24
+ require 'milkode/cdweb/lib/info_home'
25
+ require 'milkode/cdweb/lib/info_package'
24
26
 
25
27
  set :haml, :format => :html5
26
28
 
27
29
  get '/' do
28
30
  if Database.validate?
29
31
  @setting = WebSetting.new
30
- @version = "0.9.9"
32
+ @version = "0.9.9.9"
31
33
 
32
34
  @package_num = Database.instance.yaml_package_num
33
35
  @file_num = Database.instance.totalRecords
@@ -85,6 +87,10 @@ post '/command' do
85
87
  result = Database.instance.update(params[:name])
86
88
  update_result_str(result, before)
87
89
  end
90
+ when 'favorite'
91
+ Database.instance.set_fav(params[:name], params[:favorited] == 'true')
92
+ @package_list = PackageList.new(Database.instance.grndb)
93
+ "お気に入り: " + @package_list.favorite_list({})
88
94
  end
89
95
  end
90
96
 
@@ -92,6 +98,7 @@ get '/home*' do |path|
92
98
  before = Time.now
93
99
  path = path.sub(/^\//, "")
94
100
  record = Database.instance.record(path)
101
+ @package_list = PackageList.new(Database.instance.grndb)
95
102
 
96
103
  if path.empty?
97
104
  if (params[:query] and !params[:query].empty?)
@@ -112,9 +119,37 @@ end
112
119
 
113
120
  get %r{/help} do
114
121
  @setting = WebSetting.new
122
+ @path = ""
115
123
  haml :help
116
124
  end
117
125
 
126
+ get '/info' do
127
+ obj = InfoHome.new
128
+
129
+ @setting = WebSetting.new
130
+ @path = ""
131
+ @summary_content = obj.summary_content
132
+ @record_content = obj.record_content
133
+
134
+ haml :info_home
135
+ end
136
+
137
+ get '/info/:package' do
138
+ before = Time.now
139
+
140
+ name = params[:package]
141
+ obj = InfoPackage.new(name)
142
+
143
+ @setting = WebSetting.new
144
+ @path = name
145
+ @summary_content = obj.summary_content
146
+ @plang_content = obj.plang_content
147
+
148
+ @elapsed = Time.now - before
149
+
150
+ haml :info_package
151
+ end
152
+
118
153
  # -- helper function --
119
154
 
120
155
  helpers do
@@ -127,8 +162,12 @@ helpers do
127
162
  end
128
163
 
129
164
  # -- utility --
130
- def link(query)
131
- "<a href='#{'/home?query=' + escape_url(query)}'>#{query}</a>"
165
+ def link(query, text = nil)
166
+ if text.nil?
167
+ "<a href='#{'/home?query=' + escape_url(query)}'>#{query}</a>"
168
+ else
169
+ "<a href='#{'/home?query=' + escape_url(query)}'>#{text}</a>"
170
+ end
132
171
  end
133
172
 
134
173
  def create_select_shead(value)
@@ -187,12 +226,15 @@ EOF
187
226
  modal_body = "#{package_name} を更新しますか?"
188
227
  end
189
228
 
229
+ info_path = "/info"
230
+ info_path = File.join(info_path, package_name) if package_name != ""
231
+
190
232
  <<EOF
191
- #{headicon('go-home-5.png')} <a href="/home" class="headmenu">ホーム</a>
192
- #{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open(document.URL); return false;">タブを複製</a>
193
- #{headicon('directory.png')} <a href="#{flist}" class="headmenu">ディレクトリ</a>
194
- #{headicon('view-refresh-4.png')} <a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>
195
- #{headicon('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
233
+ #{headicon('go-home-5.png')}<a href="/home" class="headmenu">ホーム</a>&nbsp;
234
+ #{headicon('directory.png')}<a href="#{flist}" class="headmenu">ディレクトリ</a>
235
+ #{headicon('view-refresh-4.png')}<a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>&nbsp;
236
+ #{headicon('info.png')}<a href="#{info_path}" class="headmenu">統計情報</a>&nbsp;
237
+ #{headicon('help.png')}<a href="/help" class="headmenu">ヘルプ</a>
196
238
 
197
239
  <div id="updateModal" class="modal hide fade">
198
240
  <div class="modal-header">
@@ -227,6 +269,16 @@ EOF
227
269
  EOF
228
270
  end
229
271
 
272
+ def create_favorite_list(package_list)
273
+ <<EOF
274
+ <div class="favorite_list">
275
+ お気に入り:
276
+ #{package_list.favorite_list(params)}
277
+ </div>
278
+ </div>
279
+ EOF
280
+ end
281
+
230
282
  def headicon(name)
231
283
  "<img alt='' style='vertical-align:center; border: 0px; margin: 0px;' src='/images/#{name}'>"
232
284
  end
@@ -295,6 +347,17 @@ EOF
295
347
  "#{r.join(', ')} (#{Time.now - before} sec)"
296
348
  end
297
349
 
350
+ def favstar(path)
351
+ pname = package_name(path)
352
+
353
+ if pname != "root"
354
+ classes = Database.instance.fav?(pname) ? "star favorited" : "star"
355
+ "<a href=\"javascript:\" class=\"#{classes}\" milkode-package-name=\"#{pname}\">Favorite Me</a>"
356
+ else
357
+ ""
358
+ end
359
+ end
360
+
298
361
  # .search-summary に追加情報を表示したい時はこの関数をオーバーライド
299
362
  def search_summary_hook(path)
300
363
  ""
@@ -5,59 +5,6 @@ require 'launchy'
5
5
  require 'optparse'
6
6
  require 'milkode/cdweb/lib/database'
7
7
 
8
- module Rack
9
- class Server
10
- def start
11
- if options[:warn]
12
- $-w = true
13
- end
14
-
15
- if includes = options[:include]
16
- $LOAD_PATH.unshift(*includes)
17
- end
18
-
19
- if library = options[:require]
20
- require library
21
- end
22
-
23
- if options[:debug]
24
- $DEBUG = true
25
- require 'pp'
26
- p options[:server]
27
- pp wrapped_app
28
- pp app
29
- end
30
-
31
- # Touch the wrapped app, so that the config.ru is loaded before
32
- # daemonization (i.e. before chdir, etc).
33
- wrapped_app
34
-
35
- daemonize_app if options[:daemonize]
36
- write_pid if options[:pid]
37
-
38
- trap(:INT) do
39
- if server.respond_to?(:shutdown)
40
- server.shutdown
41
- else
42
- exit
43
- end
44
- end
45
-
46
- server.run wrapped_app, options do
47
- if (options[:LaunchBrowser])
48
- host = options[:Host] || options[:BindAddress] # options[:BindAddress] for WEBrick
49
-
50
- if (options[:LaunchURL])
51
- Launchy.open("http://#{host}:#{options[:Port]}#{options[:LaunchURL]}")
52
- else
53
- Launchy.open("http://#{host}:#{options[:Port]}")
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
60
-
61
8
  module Milkode
62
9
  class CLI_Cdweb
63
10
  def self.execute(stdout, argv)
@@ -104,13 +51,36 @@ module Milkode
104
51
  # サーバースクリプトのある場所へ移動
105
52
  FileUtils.cd(File.dirname(__FILE__))
106
53
 
107
- # Rackサーバー起動
108
- Rack::Server.start(options)
54
+ # Rackサーバー生成
55
+ rack_server = Rack::Server.new(options)
56
+
57
+ # 起動URL生成
58
+ launch_url = create_launch_url(options)
59
+
60
+ # 起動
61
+ rack_server.start do
62
+ # この時点でoptions[:Host]やoptions[:Port]などの値が壊れてしまっているため事前にURLを生成している
63
+ Launchy.open(launch_url) if launch_url
64
+ end
109
65
  else
110
66
  create_customize_file(dbdir)
111
67
  end
112
68
  end
113
69
 
70
+ def self.create_launch_url(options)
71
+ if (options[:LaunchBrowser])
72
+ host = options[:Host] || options[:BindAddress] # options[:BindAddress] for WEBrick
73
+
74
+ if (options[:LaunchURL])
75
+ "http://#{host}:#{options[:Port]}#{options[:LaunchURL]}"
76
+ else
77
+ "http://#{host}:#{options[:Port]}"
78
+ end
79
+ else
80
+ nil
81
+ end
82
+ end
83
+
114
84
  def self.select_dbdir
115
85
  # if (Dbdir.dbdir?('.') || !Dbdir.dbdir?(Dbdir.default_dir))
116
86
  if Dbdir.dbdir?('.')