milkode 1.0.2 → 1.1.0
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/HISTORY.ja.rdoc +16 -0
- data/HISTORY.rdoc +16 -0
- data/LICENSE.txt +25 -0
- data/VERSION +1 -1
- data/bin/gmilk +1 -1
- data/bin/milk +1 -1
- data/lib/milkode/cdstk/cdstk.rb +6 -2
- data/lib/milkode/cdweb/app.rb +47 -27
- data/lib/milkode/cdweb/cli_cdweb.rb +7 -2
- data/lib/milkode/cdweb/config.ru +4 -1
- data/lib/milkode/cdweb/lib/command.rb +16 -16
- data/lib/milkode/cdweb/lib/info_home.rb +2 -2
- data/lib/milkode/cdweb/lib/info_package.rb +4 -2
- data/lib/milkode/cdweb/lib/package_list.rb +7 -6
- data/lib/milkode/cdweb/lib/search_contents.rb +10 -8
- data/lib/milkode/cdweb/lib/search_files.rb +7 -5
- data/lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb +10 -14
- data/lib/milkode/cdweb/lib/search_gotoline.rb +9 -13
- data/lib/milkode/cdweb/views/header_menu.haml +1 -1
- data/lib/milkode/cdweb/views/help.haml +1 -1
- data/lib/milkode/cdweb/views/index.haml +18 -18
- data/lib/milkode/cdweb/views/info_home.haml +1 -1
- data/lib/milkode/cdweb/views/info_package.haml +1 -1
- data/lib/milkode/cdweb/views/layout.haml +15 -15
- data/lib/milkode/cdweb/{public/js → views}/milkode.js +3 -3
- data/lib/milkode/cdweb/{public/css/milkode.css → views/milkode.scss} +1 -1
- data/lib/milkode/cdweb/views/search_form.haml +1 -1
- data/lib/milkode/cli.rb +8 -5
- data/lib/milkode/common/util.rb +1 -1
- data/lib/milkode/grep/cli_grep.rb +1 -1
- data/lib/sinatra/url_for.rb +64 -0
- data/milkode.gemspec +5 -4
- metadata +6 -5
data/HISTORY.ja.rdoc
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== 1.1.0 2013/06/26
|
2
|
+
|
3
|
+
* milk web
|
4
|
+
* Support relative URL (e.g. http://example.com/milkode)
|
5
|
+
* Change milkode.css -> milkode.scss (For url_for)
|
6
|
+
|
7
|
+
* milk
|
8
|
+
* 'milk files' add --all option
|
9
|
+
|
10
|
+
* gmilk
|
11
|
+
* Add exist_command?('cat')
|
12
|
+
* Change how to call exist_command?
|
13
|
+
|
14
|
+
* etc
|
15
|
+
* Add sinatra-url-for
|
16
|
+
|
1
17
|
=== 1.0.2 2013/06/08
|
2
18
|
|
3
19
|
* gmilk
|
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== 1.1.0 2013/06/26
|
2
|
+
|
3
|
+
* milk web
|
4
|
+
* Support relative URL (e.g. http://example.com/milkode)
|
5
|
+
* Change milkode.css -> milkode.scss (For url_for)
|
6
|
+
|
7
|
+
* milk
|
8
|
+
* 'milk files' add --all option
|
9
|
+
|
10
|
+
* gmilk
|
11
|
+
* Add exist_command?('cat')
|
12
|
+
* Change how to call exist_command?
|
13
|
+
|
14
|
+
* etc
|
15
|
+
* Add sinatra-url-for
|
16
|
+
|
1
17
|
=== 1.0.2 2013/06/08
|
2
18
|
|
3
19
|
* gmilk
|
data/LICENSE.txt
CHANGED
@@ -146,3 +146,28 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
146
146
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
147
147
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
148
148
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
149
|
+
|
150
|
+
=================================
|
151
|
+
sinatra-url-for - Construct absolute paths and full URLs
|
152
|
+
=================================
|
153
|
+
|
154
|
+
Copyright 2009 Eric Kidd
|
155
|
+
|
156
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
157
|
+
a copy of this software and associated documentation files (the
|
158
|
+
"Software"), to deal in the Software without restriction, including
|
159
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
160
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
161
|
+
permit persons to whom the Software is furnished to do so, subject to
|
162
|
+
the following conditions:
|
163
|
+
|
164
|
+
The above copyright notice and this permission notice shall be
|
165
|
+
included in all copies or substantial portions of the Software.
|
166
|
+
|
167
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
168
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
169
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
170
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
171
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
172
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
173
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/bin/gmilk
CHANGED
data/bin/milk
CHANGED
data/lib/milkode/cdstk/cdstk.rb
CHANGED
@@ -956,7 +956,7 @@ EOF
|
|
956
956
|
end
|
957
957
|
|
958
958
|
def files(args, options)
|
959
|
-
packages = find_packages(args)
|
959
|
+
packages = options[:all] ? @yaml.contents : find_packages(args)
|
960
960
|
return if (packages.empty?)
|
961
961
|
|
962
962
|
db_open
|
@@ -968,7 +968,11 @@ EOF
|
|
968
968
|
if options[:relative]
|
969
969
|
@out.puts Util::relative_path(record.path, basedir)
|
970
970
|
else
|
971
|
-
|
971
|
+
if options[:all]
|
972
|
+
@out.puts record.path
|
973
|
+
else
|
974
|
+
@out.puts record.restpath
|
975
|
+
end
|
972
976
|
end
|
973
977
|
end
|
974
978
|
end
|
data/lib/milkode/cdweb/app.rb
CHANGED
@@ -23,17 +23,32 @@ require 'milkode/cdweb/lib/web_setting'
|
|
23
23
|
require 'milkode/cdweb/lib/package_list'
|
24
24
|
require 'milkode/cdweb/lib/info_home'
|
25
25
|
require 'milkode/cdweb/lib/info_package'
|
26
|
+
require 'sinatra/url_for'
|
26
27
|
|
27
28
|
set :haml, :format => :html5
|
28
29
|
|
30
|
+
get '/js/:filename' do
|
31
|
+
content_type :js
|
32
|
+
erb(File.read(File.join(settings.views, params[:filename])))
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/css/milkode.css' do
|
36
|
+
content_type :css
|
37
|
+
|
38
|
+
contents = File.read(File.join(settings.views, 'milkode.scss'))
|
39
|
+
contents = erb(contents)
|
40
|
+
engine = Sass::Engine.new(contents, :syntax => :scss)
|
41
|
+
engine.render
|
42
|
+
end
|
43
|
+
|
29
44
|
get '/' do
|
30
45
|
if Database.validate?
|
31
46
|
@setting = WebSetting.new
|
32
|
-
@version = "1.0
|
47
|
+
@version = "1.1.0"
|
33
48
|
|
34
49
|
@package_num = Database.instance.yaml_package_num
|
35
50
|
@file_num = Database.instance.totalRecords
|
36
|
-
@package_list = PackageList.new(Database.instance.grndb)
|
51
|
+
@package_list = PackageList.new(Database.instance.grndb, url_for(''))
|
37
52
|
haml :index, :layout => false
|
38
53
|
else
|
39
54
|
<<EOF
|
@@ -43,8 +58,8 @@ EOF
|
|
43
58
|
end
|
44
59
|
end
|
45
60
|
|
46
|
-
def package_path(path)
|
47
|
-
path.split('/')[0,
|
61
|
+
def package_path(homeurl, path)
|
62
|
+
homeurl + path.sub(homeurl, "").split('/')[0,2].join('/')
|
48
63
|
end
|
49
64
|
|
50
65
|
post '/search*' do
|
@@ -53,22 +68,24 @@ post '/search*' do
|
|
53
68
|
if params[:clear]
|
54
69
|
redirect Mkurl.new("#{path}", params).inherit_shead
|
55
70
|
else
|
71
|
+
homeurl = url_for "/home"
|
72
|
+
|
56
73
|
case params[:shead]
|
57
74
|
when 'all'
|
58
|
-
path =
|
75
|
+
path = homeurl
|
59
76
|
when 'package'
|
60
|
-
path = package_path(path)
|
77
|
+
path = package_path(homeurl, path)
|
61
78
|
when 'directory'
|
62
79
|
# do nothing
|
63
80
|
else
|
64
|
-
path = package_path(path)
|
81
|
+
path = package_path(homeurl, path)
|
65
82
|
end
|
66
83
|
|
67
84
|
query = Query.new(params[:query])
|
68
85
|
# gotolineモードで1つだけ渡された時は直接ジャンプ
|
69
86
|
if query.keywords.size == 1 && Milkode::Util::gotoline_keyword?(query.keywords[0])
|
70
87
|
gotoline = Milkode::Util::parse_gotoline(query.keywords)[0]
|
71
|
-
path2 = File.join('/home', gotoline[0][0])
|
88
|
+
path2 = File.join(url_for('/home'), gotoline[0][0])
|
72
89
|
redirect Mkurl.new(path2, params).inherit_query_shead + "#n#{gotoline[1]}"
|
73
90
|
else
|
74
91
|
redirect Mkurl.new("#{path}", params).inherit_query_shead
|
@@ -89,7 +106,7 @@ post '/command' do
|
|
89
106
|
end
|
90
107
|
when 'favorite'
|
91
108
|
Database.instance.set_fav(params[:name], params[:favorited] == 'true')
|
92
|
-
@package_list = PackageList.new(Database.instance.grndb)
|
109
|
+
@package_list = PackageList.new(Database.instance.grndb, url_for(''))
|
93
110
|
"お気に入り: " + @package_list.favorite_list({})
|
94
111
|
end
|
95
112
|
end
|
@@ -98,21 +115,22 @@ get '/home*' do |path|
|
|
98
115
|
before = Time.now
|
99
116
|
path = path.sub(/^\//, "")
|
100
117
|
record = Database.instance.record(path)
|
101
|
-
@package_list = PackageList.new(Database.instance.grndb)
|
118
|
+
@package_list = PackageList.new(Database.instance.grndb, url_for(''))
|
119
|
+
suburl = url_for('')
|
102
120
|
|
103
121
|
if path.empty?
|
104
122
|
if (params[:query] and !params[:query].empty?)
|
105
|
-
search(path, params, before)
|
123
|
+
search(path, params, before, suburl)
|
106
124
|
else
|
107
|
-
packages(params, before)
|
125
|
+
packages(params, before, suburl)
|
108
126
|
end
|
109
127
|
elsif (record)
|
110
128
|
view(record, params, before)
|
111
129
|
else
|
112
130
|
if (params[:query] and !params[:query].empty?)
|
113
|
-
search(path, params, before)
|
131
|
+
search(path, params, before, suburl)
|
114
132
|
else
|
115
|
-
filelist(path, params, before)
|
133
|
+
filelist(path, params, before, suburl)
|
116
134
|
end
|
117
135
|
end
|
118
136
|
end
|
@@ -124,7 +142,7 @@ get %r{/help} do
|
|
124
142
|
end
|
125
143
|
|
126
144
|
get '/info' do
|
127
|
-
obj = InfoHome.new
|
145
|
+
obj = InfoHome.new(url_for '')
|
128
146
|
|
129
147
|
@setting = WebSetting.new
|
130
148
|
@path = ""
|
@@ -138,7 +156,7 @@ get '/info/:package' do
|
|
138
156
|
before = Time.now
|
139
157
|
|
140
158
|
name = params[:package]
|
141
|
-
obj = InfoPackage.new(name)
|
159
|
+
obj = InfoPackage.new(name, url_for(''))
|
142
160
|
|
143
161
|
@setting = WebSetting.new
|
144
162
|
@path = name
|
@@ -215,8 +233,10 @@ EOF
|
|
215
233
|
end
|
216
234
|
|
217
235
|
def create_headmenu(path, query, flistpath = '')
|
218
|
-
|
219
|
-
|
236
|
+
suburl = url_for ""
|
237
|
+
|
238
|
+
href = Mkurl.new("#{suburl}/home/#{path}", params).inherit_query_shead
|
239
|
+
flist = File.join("#{suburl}/home/#{path}", flistpath)
|
220
240
|
|
221
241
|
package_name = ""
|
222
242
|
modal_body = "全てのパッケージを更新しますか?"
|
@@ -226,15 +246,15 @@ EOF
|
|
226
246
|
modal_body = "#{package_name} を更新しますか?"
|
227
247
|
end
|
228
248
|
|
229
|
-
info_path = "/info"
|
249
|
+
info_path = "#{suburl}/info"
|
230
250
|
info_path = File.join(info_path, package_name) if package_name != ""
|
231
251
|
|
232
252
|
<<EOF
|
233
|
-
#{headicon('go-home-5.png')}<a href="/home" class="headmenu">ホーム</a>
|
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>
|
236
|
-
#{headicon('info.png')}<a href="#{info_path}" class="headmenu">統計情報</a>
|
237
|
-
#{headicon('help.png')}<a href="/help" class="headmenu">ヘルプ</a>
|
253
|
+
#{headicon('go-home-5.png', suburl)}<a href="#{suburl}/home" class="headmenu">ホーム</a>
|
254
|
+
#{headicon('directory.png', suburl)}<a href="#{flist}" class="headmenu">ディレクトリ</a>
|
255
|
+
#{headicon('view-refresh-4.png', suburl)}<a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>
|
256
|
+
#{headicon('info.png', suburl)}<a href="#{info_path}" class="headmenu">統計情報</a>
|
257
|
+
#{headicon('help.png', suburl)}<a href="#{suburl}/help" class="headmenu">ヘルプ</a>
|
238
258
|
|
239
259
|
<div id="updateModal" class="modal hide fade">
|
240
260
|
<div class="modal-header">
|
@@ -279,8 +299,8 @@ EOF
|
|
279
299
|
EOF
|
280
300
|
end
|
281
301
|
|
282
|
-
def headicon(name)
|
283
|
-
"<img alt='' style='vertical-align:center; border: 0px; margin: 0px;' src='/images/#{name}'>"
|
302
|
+
def headicon(name, suburl)
|
303
|
+
"<img alt='' style='vertical-align:center; border: 0px; margin: 0px;' src='#{suburl}/images/#{name}'>"
|
284
304
|
end
|
285
305
|
|
286
306
|
def topic_path(path, params)
|
@@ -289,7 +309,7 @@ EOF
|
|
289
309
|
|
290
310
|
path.split('/').map_with_index {|v, index|
|
291
311
|
href += '/' + v
|
292
|
-
"<a id='topic_#{index}' href='#{Mkurl.new(href, params).inherit_query_shead}' onclick='topic_path(\"topic_#{index}\");'>#{v}</a>"
|
312
|
+
"<a id='topic_#{index}' href='#{url_for Mkurl.new(href, params).inherit_query_shead}' onclick='topic_path(\"topic_#{index}\");'>#{v}</a>"
|
293
313
|
}.join('/')
|
294
314
|
end
|
295
315
|
|
@@ -57,6 +57,9 @@ module Milkode
|
|
57
57
|
# 起動URL生成
|
58
58
|
launch_url = create_launch_url(options)
|
59
59
|
|
60
|
+
# URL設定
|
61
|
+
ENV['MILKODE_RELATIVE_URL'] = File.join('/', options[:url]) if options[:url]
|
62
|
+
|
60
63
|
# 起動
|
61
64
|
rack_server.start do
|
62
65
|
# この時点でoptions[:Host]やoptions[:Port]などの値が壊れてしまっているため事前にURLを生成している
|
@@ -71,8 +74,10 @@ module Milkode
|
|
71
74
|
if (options[:LaunchBrowser])
|
72
75
|
host = options[:Host] || options[:BindAddress] # options[:BindAddress] for WEBrick
|
73
76
|
|
74
|
-
|
75
|
-
|
77
|
+
base = "http://#{host}:#{options[:Port]}"
|
78
|
+
|
79
|
+
if options[:url]
|
80
|
+
File.join(base, options[:url])
|
76
81
|
else
|
77
82
|
"http://#{host}:#{options[:Port]}"
|
78
83
|
end
|
data/lib/milkode/cdweb/config.ru
CHANGED
@@ -53,14 +53,14 @@ module Milkode
|
|
53
53
|
haml :view
|
54
54
|
end
|
55
55
|
|
56
|
-
def search(path, params, before)
|
56
|
+
def search(path, params, before, suburl)
|
57
57
|
@setting = WebSetting.new
|
58
58
|
@path = path
|
59
59
|
query = Query.new(params[:query])
|
60
60
|
@title = "'#{query.query_string}' in #{path_title(path)}"
|
61
61
|
|
62
62
|
if (query.gotolines.size > 0)
|
63
|
-
searcher = SearchFuzzyGotoLine.new(path, params, query)
|
63
|
+
searcher = SearchFuzzyGotoLine.new(path, params, query, suburl)
|
64
64
|
|
65
65
|
if searcher.directjump?
|
66
66
|
redirect searcher.directjump_url
|
@@ -68,16 +68,16 @@ module Milkode
|
|
68
68
|
|
69
69
|
elsif (query.keywords.size > 0)
|
70
70
|
if Util::gotoline_keyword?(query.keywords[0])
|
71
|
-
searcher = SearchGotoLine.new(path, params, query)
|
71
|
+
searcher = SearchGotoLine.new(path, params, query, suburl)
|
72
72
|
else
|
73
|
-
searcher = SearchContents.new(path, params, query)
|
73
|
+
searcher = SearchContents.new(path, params, query, suburl)
|
74
74
|
|
75
75
|
if searcher.directjump?
|
76
76
|
redirect searcher.directjump_url
|
77
77
|
end
|
78
78
|
end
|
79
79
|
else
|
80
|
-
searcher = SearchFiles.new(path, params, query)
|
80
|
+
searcher = SearchFiles.new(path, params, query, suburl)
|
81
81
|
end
|
82
82
|
|
83
83
|
@total_records = searcher.total_records
|
@@ -88,21 +88,21 @@ module Milkode
|
|
88
88
|
haml :search
|
89
89
|
end
|
90
90
|
|
91
|
-
def filelist(path, params, before)
|
91
|
+
def filelist(path, params, before, suburl)
|
92
92
|
@setting = WebSetting.new
|
93
93
|
@title = filelist_title(path)
|
94
94
|
@path = path
|
95
95
|
fileList = Database.instance.fileList(path)
|
96
96
|
@total_records = fileList.size
|
97
97
|
@record_content = fileList.map do |v|
|
98
|
-
"<dt class='result-file'>#{file_or_dirimg(v[1])}<a href='#{Mkurl.new('/home/' + v[0], params).inherit_query_shead}'>#{File.basename v[0]}</a></dt>"
|
98
|
+
"<dt class='result-file'>#{file_or_dirimg(v[1], suburl)}<a href='#{Mkurl.new(suburl + '/home/' + v[0], params).inherit_query_shead}'>#{File.basename v[0]}</a></dt>"
|
99
99
|
end.join
|
100
100
|
Database.instance.touch_viewtime(path)
|
101
101
|
@elapsed = Time.now - before
|
102
102
|
haml :filelist
|
103
103
|
end
|
104
104
|
|
105
|
-
def packages(params, before)
|
105
|
+
def packages(params, before, suburl)
|
106
106
|
@setting = WebSetting.new
|
107
107
|
@title = "Package List"
|
108
108
|
@path = ""
|
@@ -123,7 +123,7 @@ module Milkode
|
|
123
123
|
].join("\n")
|
124
124
|
|
125
125
|
@record_content = packages.map do |v|
|
126
|
-
"<dt class='result-file'>#{file_or_dirimg(false)}<a href='#{Mkurl.new('/home/' + v, params).inherit_query_shead}'>#{File.basename v}</a></dt>"
|
126
|
+
"<dt class='result-file'>#{file_or_dirimg(false, suburl)}<a href='#{Mkurl.new(suburl + '/home/' + v, params).inherit_query_shead}'>#{File.basename v}</a></dt>"
|
127
127
|
end.join
|
128
128
|
@elapsed = Time.now - before
|
129
129
|
haml :packages
|
@@ -131,21 +131,21 @@ module Milkode
|
|
131
131
|
|
132
132
|
private
|
133
133
|
|
134
|
-
def file_or_dirimg(is_file)
|
135
|
-
|
136
|
-
img_icon(
|
134
|
+
def file_or_dirimg(is_file, suburl)
|
135
|
+
filename = (is_file) ? 'file.png' : 'directory.png'
|
136
|
+
img_icon(filename, suburl)
|
137
137
|
end
|
138
138
|
|
139
|
-
def img_icon(
|
140
|
-
"<img alt='' style='vertical-align:bottom; border: 0; margin: 1px;' src='/images/#{
|
139
|
+
def img_icon(filename, suburl)
|
140
|
+
"<img alt='' style='vertical-align:bottom; border: 0; margin: 1px;' src='#{suburl}/images/#{filename}'>"
|
141
141
|
end
|
142
142
|
|
143
143
|
def sort_change_content(current_value, text, sort_kind = nil)
|
144
144
|
if (current_value != sort_kind)
|
145
145
|
if (sort_kind)
|
146
|
-
"<a href='#{Mkurl.new('/home', params).inherit_query_shead_set_sort(sort_kind)}'>#{text}</a>"
|
146
|
+
"<a href='#{url_for Mkurl.new('/home', params).inherit_query_shead_set_sort(sort_kind)}'>#{text}</a>"
|
147
147
|
else
|
148
|
-
"<a href='#{Mkurl.new('/home', params).inherit_query_shead}'>#{text}</a>"
|
148
|
+
"<a href='#{url_for Mkurl.new('/home', params).inherit_query_shead}'>#{text}</a>"
|
149
149
|
end
|
150
150
|
else
|
151
151
|
text
|
@@ -10,7 +10,7 @@ module Milkode
|
|
10
10
|
attr_reader :record_content
|
11
11
|
attr_reader :summary_content
|
12
12
|
|
13
|
-
def initialize
|
13
|
+
def initialize(suburl)
|
14
14
|
packages = Database.instance.packages(nil)
|
15
15
|
|
16
16
|
@summary_content = <<EOF
|
@@ -21,7 +21,7 @@ module Milkode
|
|
21
21
|
EOF
|
22
22
|
|
23
23
|
@record_content = packages.map do |name|
|
24
|
-
"<dt class='result-file'><img src='/images/info.png'
|
24
|
+
"<dt class='result-file'><img src='#{suburl}/images/info.png'/><a href='#{suburl}/info/#{name}'>#{name}</a></dt>"
|
25
25
|
end.join("\n")
|
26
26
|
end
|
27
27
|
|
@@ -14,7 +14,9 @@ module Milkode
|
|
14
14
|
attr_reader :summary_content
|
15
15
|
attr_reader :plang_content
|
16
16
|
|
17
|
-
def initialize(name)
|
17
|
+
def initialize(name, suburl)
|
18
|
+
@suburl = suburl
|
19
|
+
|
18
20
|
records = Database.instance.package_records(name)
|
19
21
|
# plangs = sorted_plangs(records)
|
20
22
|
|
@@ -54,7 +56,7 @@ EOF
|
|
54
56
|
params = { :query => lang_to_query(lang) }
|
55
57
|
|
56
58
|
if params[:query] != ""
|
57
|
-
url = "/home/" + Mkurl.new(package_name, params).inherit_query_shead
|
59
|
+
url = @suburl + "/home/" + Mkurl.new(package_name, params).inherit_query_shead
|
58
60
|
"<tr><td>#{name}</td><td align=\"right\"><a href=\"#{url}\">#{count}</a></td><td align=\"right\">#{percent}%</td></tr>"
|
59
61
|
else
|
60
62
|
"<tr><td>#{name}</td><td align=\"right\">#{count}</td><td align=\"right\">#{percent}%</td></tr>"
|
@@ -16,8 +16,9 @@ module Milkode
|
|
16
16
|
|
17
17
|
FAVORITE_LIST_NUM = 7
|
18
18
|
|
19
|
-
def initialize(grndb)
|
20
|
-
@grndb
|
19
|
+
def initialize(grndb, suburl)
|
20
|
+
@grndb = grndb
|
21
|
+
@suburl = suburl
|
21
22
|
end
|
22
23
|
|
23
24
|
# topページへの表示数の調整は結構大切
|
@@ -47,12 +48,12 @@ module Milkode
|
|
47
48
|
names = @grndb.packages.favs.map{|r| r.name}[0..FAVORITE_LIST_NUM-1]
|
48
49
|
|
49
50
|
list = names.map_with_index {|v, index|
|
50
|
-
"<strong><a id='favorite_list_#{index}' href='#{Mkurl.new('/home/' + v, params).inherit_query_shead}' onclick='topic_path(\"favorite_list_#{index}\");'>#{v}</a></strong>"
|
51
|
+
"<strong><a id='favorite_list_#{index}' href='#{Mkurl.new(@suburl + '/home/' + v, params).inherit_query_shead}' onclick='topic_path(\"favorite_list_#{index}\");'>#{v}</a></strong>"
|
51
52
|
}.join(" \n")
|
52
53
|
|
53
54
|
<<EOF
|
54
55
|
#{list}
|
55
|
-
<a href="/home?sort=favtime">...</a>
|
56
|
+
<a href="#{@suburl}/home?sort=favtime">...</a>
|
56
57
|
EOF
|
57
58
|
end
|
58
59
|
|
@@ -66,12 +67,12 @@ EOF
|
|
66
67
|
|
67
68
|
def top_list(list, column_name)
|
68
69
|
list = list.map {|v|
|
69
|
-
" <li><a href=\"/home/#{v}\">#{v}</a></li>"
|
70
|
+
" <li><a href=\"#{@suburl}/home/#{v}\">#{v}</a></li>"
|
70
71
|
}.join("\n")
|
71
72
|
<<EOF
|
72
73
|
<ul class="unstyled_margin">
|
73
74
|
#{list}
|
74
|
-
<li><a href=\"/home?sort=#{column_name}">next >></a></li>
|
75
|
+
<li><a href=\"#{@suburl}/home?sort=#{column_name}">next >></a></li>
|
75
76
|
</ul>
|
76
77
|
EOF
|
77
78
|
end
|
@@ -26,7 +26,7 @@ module Milkode
|
|
26
26
|
|
27
27
|
DEFAULT_WIDE_MATCH_RANGE = 7 # 未指定時のワイド検索範囲
|
28
28
|
|
29
|
-
def initialize(path, params, query)
|
29
|
+
def initialize(path, params, query, suburl)
|
30
30
|
@path = path
|
31
31
|
@params = params
|
32
32
|
@q = query
|
@@ -35,6 +35,8 @@ module Milkode
|
|
35
35
|
@line = params[:line].to_i
|
36
36
|
@is_onematch = params[:onematch] == 'on'
|
37
37
|
@is_sensitive = params[:sensitive] == 'on'
|
38
|
+
@suburl = suburl
|
39
|
+
@homeurl = @suburl + "/home/"
|
38
40
|
|
39
41
|
@searcher_fuzzy_gotoline = nil
|
40
42
|
|
@@ -165,7 +167,7 @@ EOF
|
|
165
167
|
tmpp = @params.clone
|
166
168
|
tmpp[:query] = conv_query.query_string
|
167
169
|
url = Mkurl.new(@path, tmpp).inherit_query_shead
|
168
|
-
result << "<dt class='result-file'>#{img_icon('document-new-4.png')}<a href='#{url}'>#{conv_query.query_string}</a></dt>"
|
170
|
+
result << "<dt class='result-file'>#{img_icon('document-new-4.png', @suburl)}<a href='#{url}'>#{conv_query.query_string}</a></dt>"
|
169
171
|
end
|
170
172
|
|
171
173
|
if recommended_wide_match_range?
|
@@ -184,7 +186,7 @@ EOF
|
|
184
186
|
tmpp[:query] = conv_query.query_string
|
185
187
|
url = Mkurl.new(@path, tmpp).inherit_query_shead
|
186
188
|
|
187
|
-
result << "<dt class='result-file'>#{img_icon('document-new-4.png')}<a href='#{url}'>#{conv_query.query_string}</a> (<a href='#{w0_url}'>w:0</a>, <a href='#{w1_url}'>w:1</a>)</dt>"
|
189
|
+
result << "<dt class='result-file'>#{img_icon('document-new-4.png', @suburl)}<a href='#{url}'>#{conv_query.query_string}</a> (<a href='#{w0_url}'>w:0</a>, <a href='#{w1_url}'>w:1</a>)</dt>"
|
188
190
|
end
|
189
191
|
|
190
192
|
if recommended_fpath_or_packages?
|
@@ -192,7 +194,7 @@ EOF
|
|
192
194
|
tmpp = @params.clone
|
193
195
|
tmpp[:query] = conv_query.query_string
|
194
196
|
url = Mkurl.new(@path, tmpp).inherit_query_shead
|
195
|
-
result << "<dt class='result-file'>#{img_icon('document-new-4.png')}<a href='#{url}'>#{conv_query.query_string}</a></dt>"
|
197
|
+
result << "<dt class='result-file'>#{img_icon('document-new-4.png', @suburl)}<a href='#{url}'>#{conv_query.query_string}</a></dt>"
|
196
198
|
end
|
197
199
|
|
198
200
|
unless result.empty?
|
@@ -308,7 +310,7 @@ EOF
|
|
308
310
|
coderay.col_limit(COL_LIMIT)
|
309
311
|
coderay.set_range(first_index..last_index)
|
310
312
|
|
311
|
-
url =
|
313
|
+
url = @homeurl + record_link(record)
|
312
314
|
|
313
315
|
<<EOS
|
314
316
|
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util::relative_path record.shortpath, @path}</a>#{result_refinement(record)}</dt>
|
@@ -332,7 +334,7 @@ EOS
|
|
332
334
|
|
333
335
|
def result_record(record)
|
334
336
|
<<EOS
|
335
|
-
<dt class='result-file'>#{file_or_dirimg(true)}<a href='#{
|
337
|
+
<dt class='result-file'>#{file_or_dirimg(true, @suburl)}<a href='#{@homeurl + record_link(record)}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
336
338
|
EOS
|
337
339
|
end
|
338
340
|
|
@@ -343,11 +345,11 @@ EOS
|
|
343
345
|
def refinement_suffix(suffix)
|
344
346
|
params = @params.clone
|
345
347
|
params[:query] = [@params[:query], "s:#{suffix}"].join(" ")
|
346
|
-
|
348
|
+
@homeurl + Mkurl.new(@path, params).inherit_query_shead
|
347
349
|
end
|
348
350
|
|
349
351
|
def refinement_directory(path)
|
350
|
-
|
352
|
+
@homeurl + Mkurl.new(path, @params).inherit_query_shead
|
351
353
|
end
|
352
354
|
|
353
355
|
def result_refinement(record)
|
@@ -17,10 +17,12 @@ module Milkode
|
|
17
17
|
|
18
18
|
DISP_NUM = 100 # 1ページの表示数
|
19
19
|
|
20
|
-
def initialize(path, params, query)
|
21
|
-
@path
|
22
|
-
@params
|
23
|
-
@q
|
20
|
+
def initialize(path, params, query, suburl)
|
21
|
+
@path = path
|
22
|
+
@params = params
|
23
|
+
@q = query
|
24
|
+
@suburl = suburl
|
25
|
+
@homeurl = @suburl + "/home/"
|
24
26
|
|
25
27
|
@offset = params[:offset].to_i
|
26
28
|
|
@@ -77,7 +79,7 @@ EOF
|
|
77
79
|
|
78
80
|
def result_record(record)
|
79
81
|
<<EOS
|
80
|
-
<dt class='result-file'>#{file_or_dirimg(true)}<a href='#{
|
82
|
+
<dt class='result-file'>#{file_or_dirimg(true, @suburl)}<a href='#{@homeurl + record_link(record)}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
81
83
|
EOS
|
82
84
|
end
|
83
85
|
|
@@ -22,12 +22,14 @@ module Milkode
|
|
22
22
|
NTH = 3 # 表示範囲
|
23
23
|
COL_LIMIT = 200 # 1行の桁制限
|
24
24
|
|
25
|
-
def initialize(path, params, query)
|
26
|
-
@path
|
27
|
-
@params
|
28
|
-
@q
|
29
|
-
@page
|
30
|
-
@offset
|
25
|
+
def initialize(path, params, query, suburl)
|
26
|
+
@path = path
|
27
|
+
@params = params
|
28
|
+
@q = query
|
29
|
+
@page = params[:page].to_i || 0
|
30
|
+
@offset = params[:offset].to_i
|
31
|
+
@suburl = suburl
|
32
|
+
@homeurl = @suburl + "/home/"
|
31
33
|
|
32
34
|
# 検索クエリを解析
|
33
35
|
gotolines = Util::parse_gotoline(@q.gotolines + @q.keywords)
|
@@ -84,7 +86,7 @@ EOF
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def directjump_url
|
87
|
-
path =
|
89
|
+
path = @homeurl + @match_records[0].record.shortpath
|
88
90
|
lineno = "#n#{@gotoline[1]}"
|
89
91
|
Mkurl.new(path, @params).inherit_query_shead + lineno
|
90
92
|
end
|
@@ -124,7 +126,7 @@ EOF
|
|
124
126
|
coderay.col_limit(COL_LIMIT)
|
125
127
|
coderay.set_range(first_index..last_index)
|
126
128
|
|
127
|
-
url =
|
129
|
+
url = @homeurl + record_link(record)
|
128
130
|
|
129
131
|
<<EOS
|
130
132
|
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
@@ -146,12 +148,6 @@ EOS
|
|
146
148
|
"<ul><li>#{content}</li></ul>\n"
|
147
149
|
end
|
148
150
|
|
149
|
-
def result_record(record)
|
150
|
-
<<EOS
|
151
|
-
<dt class='result-file'>#{file_or_dirimg(true)}<a href='#{"/home/" + record_link(record)}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
152
|
-
EOS
|
153
|
-
end
|
154
|
-
|
155
151
|
def record_link(record)
|
156
152
|
Mkurl.new(record.shortpath, @params).inherit_query_shead
|
157
153
|
end
|
@@ -23,12 +23,14 @@ module Milkode
|
|
23
23
|
MATH_FILE_DISP = 3 # マッチファイルの最大表示数
|
24
24
|
MATH_FILE_LIMIT = MATH_FILE_DISP + 1 # マッチファイルの検索リミット数
|
25
25
|
|
26
|
-
def initialize(path, params, query)
|
27
|
-
@path
|
28
|
-
@params
|
29
|
-
@q
|
30
|
-
@page
|
31
|
-
@offset
|
26
|
+
def initialize(path, params, query, suburl)
|
27
|
+
@path = path
|
28
|
+
@params = params
|
29
|
+
@q = query
|
30
|
+
@page = params[:page].to_i || 0
|
31
|
+
@offset = params[:offset].to_i
|
32
|
+
@suburl = suburl
|
33
|
+
@homeurl = @suburl + "/home/"
|
32
34
|
|
33
35
|
# 検索クエリを解析
|
34
36
|
@gotolines = Util::parse_gotoline(@q.keywords)
|
@@ -113,7 +115,7 @@ EOF
|
|
113
115
|
coderay.col_limit(COL_LIMIT)
|
114
116
|
coderay.set_range(first_index..last_index)
|
115
117
|
|
116
|
-
url =
|
118
|
+
url = @homeurl + record_link(record)
|
117
119
|
|
118
120
|
<<EOS
|
119
121
|
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
@@ -135,12 +137,6 @@ EOS
|
|
135
137
|
"<ul><li>#{content}</li></ul>\n"
|
136
138
|
end
|
137
139
|
|
138
|
-
def result_record(record)
|
139
|
-
<<EOS
|
140
|
-
<dt class='result-file'>#{file_or_dirimg(true)}<a href='#{"/home/" + record_link(record)}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
141
|
-
EOS
|
142
|
-
end
|
143
|
-
|
144
140
|
def record_link(record) #
|
145
141
|
Mkurl.new(record.shortpath, @params).inherit_query_shead
|
146
142
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
.header
|
2
2
|
%h1
|
3
|
-
<a href="/"><img src=#{@setting.header_icon} alt="milkode-icon-mini" border="0" height="75px"/></a>
|
3
|
+
<a href="#{url_for '/'}"><img src=#{url_for @setting.header_icon} alt="milkode-icon-mini" border="0" height="75px"/></a>
|
4
4
|
#{@setting.header_title}
|
5
5
|
= create_headmenu(@path, params, defined?(flistpath) ? flistpath : '')
|
@@ -71,6 +71,6 @@
|
|
71
71
|
/proj1/file.rb:1 /proj2/file.c:2 <span class="comment"># 空白で区切れば複数個渡せる</span>
|
72
72
|
|
73
73
|
%li ファイルモードで行番号をクリックすると取得可能
|
74
|
-
<img src="/images/milkode-directpath-copy.gif" />
|
74
|
+
<img src="#{url_for '/images/milkode-directpath-copy.gif'}" />
|
75
75
|
|
76
76
|
%li <a href="https://github.com/ongaeshi/emacs-milkode">emacs-milkode</a>との連携にも使う
|
@@ -6,27 +6,27 @@
|
|
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}")
|
10
|
-
%link(rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all")
|
11
|
-
%link(rel="stylesheet" href="/css/bootstrap-responsive.min.css" type="text/css" media="all")
|
12
|
-
%link(rel="stylesheet" href="/css/milkode.css" type="text/css" media="all")
|
13
|
-
%link(rel="stylesheet" href="/css/smoothness/jquery-ui-1.8.22.custom.css" type="text/css" media="all")
|
14
|
-
%link(rel="stylesheet" href="/css/jquery.multiselect.css" type="text/css" media="all")
|
15
|
-
%link(rel="stylesheet" href="/css/jquery.multiselect.filter.css" type="text/css" media="all")
|
9
|
+
%link(rel="shortcut icon" href="#{url_for @setting.favicon}")
|
10
|
+
%link(rel="stylesheet" href="#{url_for '/css/bootstrap.min.css'}" type="text/css" media="all")
|
11
|
+
%link(rel="stylesheet" href="#{url_for '/css/bootstrap-responsive.min.css'}" type="text/css" media="all")
|
12
|
+
%link(rel="stylesheet" href="#{url_for '/css/milkode.css'}" type="text/css" media="all")
|
13
|
+
%link(rel="stylesheet" href="#{url_for '/css/smoothness/jquery-ui-1.8.22.custom.css'}" type="text/css" media="all")
|
14
|
+
%link(rel="stylesheet" href="#{url_for '/css/jquery.multiselect.css'}" type="text/css" media="all")
|
15
|
+
%link(rel="stylesheet" href="#{url_for '/css/jquery.multiselect.filter.css'}" type="text/css" media="all")
|
16
16
|
|
17
17
|
%body
|
18
18
|
.container#toppage
|
19
19
|
.row
|
20
20
|
.span10.offset2
|
21
|
-
%h1 <a href="/"><img src=#{@setting.home_icon} alt="milkode-icon" border="0" height="135px" /></a> #{@setting.home_title} <font class="version">#{@version}</font>
|
21
|
+
%h1 <a href="#{url_for '/'}"><img src=#{url_for @setting.home_icon} alt="milkode-icon" border="0" height="135px" /></a> #{@setting.home_title} <font class="version">#{@version}</font>
|
22
22
|
|
23
23
|
.row
|
24
24
|
.span10.offset2
|
25
25
|
.form
|
26
|
-
%form(method="post" action="/search")
|
26
|
+
%form(method="post" action="#{url_for '/search'}")
|
27
27
|
%input(name="query" type="text" style="width: 419px;")
|
28
28
|
%input(type="submit" value="検索")
|
29
|
-
%input(name='pathname' type='hidden' value='/home')
|
29
|
+
%input(name='pathname' type='hidden' value='#{url_for '/home'}')
|
30
30
|
|
31
31
|
.row
|
32
32
|
.span4.offset4
|
@@ -52,16 +52,16 @@
|
|
52
52
|
.row
|
53
53
|
.span4.offset4
|
54
54
|
.footer
|
55
|
-
<a href="/home">#{@package_num}</a>のパッケージ<br>
|
56
|
-
<a href="/home?query=f:*">#{@file_num}</a>のファイル<br>
|
57
|
-
<a href="/help">ヘルプ</a>
|
55
|
+
<a href="#{url_for '/home'}">#{@package_num}</a>のパッケージ<br>
|
56
|
+
<a href="#{url_for '/home?query=f:*'}">#{@file_num}</a>のファイル<br>
|
57
|
+
<a href="#{url_for '/help'}">ヘルプ</a>
|
58
58
|
= @setting.about_milkode
|
59
59
|
|
60
|
-
%script(type='text/javascript' src='/js/jquery-1.7.2.min.js')
|
61
|
-
%script(type='text/javascript' src='/js/jquery-ui-1.8.22.custom.min.js')
|
62
|
-
%script(type='text/javascript' src='/js/jquery.multiselect.min.js')
|
63
|
-
%script(type='text/javascript' src='/js/jquery.multiselect.filter.min.js')
|
64
|
-
%script(type='text/javascript' src='/js/milkode.js')
|
60
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery-1.7.2.min.js'}')
|
61
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery-ui-1.8.22.custom.min.js'}')
|
62
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery.multiselect.min.js'}')
|
63
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery.multiselect.filter.min.js'}')
|
64
|
+
%script(type='text/javascript' src='#{url_for '/js/milkode.js'}')
|
65
65
|
|
66
66
|
|
67
67
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
.content
|
4
4
|
.info-package-content
|
5
|
-
%h1 <a href="/info"><img src="/images/info-big.png"/></a> <a href="/home/#{@path}">#{@path}</a>の統計
|
5
|
+
%h1 <a href="#{url_for '/info'}"><img src="#{url_for '/images/info-big.png'}"/></a> <a href="#{url_for "/home/#{@path}"}">#{@path}</a>の統計
|
6
6
|
|
7
7
|
%h2 基本情報
|
8
8
|
~ @summary_content
|
@@ -4,24 +4,24 @@
|
|
4
4
|
%head
|
5
5
|
%meta(charset='utf-8')
|
6
6
|
%title= [@title, @setting.home_title].compact.join(' - ')
|
7
|
-
%link(rel="shortcut icon" href="#{@setting.favicon}")
|
8
|
-
%link(rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all")
|
9
|
-
%link(rel="stylesheet" href="/css/bootstrap-responsive.min.css" type="text/css" media="all")
|
10
|
-
%link(rel="stylesheet" href="/css/milkode.css" type="text/css" media="all")
|
11
|
-
%link(rel="stylesheet" href="/css/coderay.css" type="text/css" media="all")
|
12
|
-
%link(rel="stylesheet" href="/css/coderay-patch.css" type="text/css" media="all")
|
13
|
-
%link(rel="stylesheet" href="/css/smoothness/jquery-ui-1.8.22.custom.css" type="text/css" media="all")
|
14
|
-
%link(rel="stylesheet" href="/css/jquery.multiselect.css" type="text/css" media="all")
|
15
|
-
%link(rel="stylesheet" href="/css/jquery.multiselect.filter.css" type="text/css" media="all")
|
7
|
+
%link(rel="shortcut icon" href="#{url_for @setting.favicon}")
|
8
|
+
%link(rel="stylesheet" href="#{url_for '/css/bootstrap.min.css'}" type="text/css" media="all")
|
9
|
+
%link(rel="stylesheet" href="#{url_for '/css/bootstrap-responsive.min.css'}" type="text/css" media="all")
|
10
|
+
%link(rel="stylesheet" href="#{url_for '/css/milkode.css'}" type="text/css" media="all")
|
11
|
+
%link(rel="stylesheet" href="#{url_for '/css/coderay.css'}" type="text/css" media="all")
|
12
|
+
%link(rel="stylesheet" href="#{url_for '/css/coderay-patch.css'}" type="text/css" media="all")
|
13
|
+
%link(rel="stylesheet" href="#{url_for '/css/smoothness/jquery-ui-1.8.22.custom.css'}" type="text/css" media="all")
|
14
|
+
%link(rel="stylesheet" href="#{url_for '/css/jquery.multiselect.css'}" type="text/css" media="all")
|
15
|
+
%link(rel="stylesheet" href="#{url_for '/css/jquery.multiselect.filter.css'}" type="text/css" media="all")
|
16
16
|
|
17
17
|
%body
|
18
18
|
.container-fluid#mainpage
|
19
19
|
!= yield
|
20
|
-
%script(type='text/javascript' src='/js/jquery-1.7.2.min.js')
|
21
|
-
%script(type='text/javascript' src='/js/jquery-ui-1.8.22.custom.min.js')
|
22
|
-
%script(type='text/javascript' src='/js/jquery.multiselect.min.js')
|
23
|
-
%script(type='text/javascript' src='/js/jquery.multiselect.filter.min.js')
|
24
|
-
%script(type='text/javascript' src='/js/bootstrap.min.js')
|
25
|
-
%script(type='text/javascript' src='/js/milkode.js')
|
20
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery-1.7.2.min.js'}')
|
21
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery-ui-1.8.22.custom.min.js'}')
|
22
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery.multiselect.min.js'}')
|
23
|
+
%script(type='text/javascript' src='#{url_for '/js/jquery.multiselect.filter.min.js'}')
|
24
|
+
%script(type='text/javascript' src='#{url_for '/js/bootstrap.min.js'}')
|
25
|
+
%script(type='text/javascript' src='#{url_for '/js/milkode.js'}')
|
26
26
|
|
27
27
|
-# GoogleAnalyticsを使いたい場合はここにコードを挿入して下さい。
|
@@ -77,13 +77,13 @@ function favorite_list(id) {
|
|
77
77
|
|
78
78
|
function update_package(package_name) {
|
79
79
|
// click button
|
80
|
-
$("#updateModal .modal-body").html("<h4>更新中... <img src='/images/waiting.gif'/></h4>");
|
80
|
+
$("#updateModal .modal-body").html("<h4>更新中... <img src='" + '<%= url_for "/images/waiting.gif" %>' + "'/></h4>");
|
81
81
|
$("#updateCancel").addClass("hide");
|
82
82
|
$("#updateOk").button('loading').off('click');
|
83
83
|
|
84
84
|
// update end
|
85
85
|
$.post(
|
86
|
-
'/command',
|
86
|
+
'<%= url_for "/command" %>',
|
87
87
|
{
|
88
88
|
kind: 'update',
|
89
89
|
name: package_name
|
@@ -191,7 +191,7 @@ $(document).ready(function() {
|
|
191
191
|
|
192
192
|
// ajax通信
|
193
193
|
$.post(
|
194
|
-
'/command',
|
194
|
+
'<%= url_for "/command" %>',
|
195
195
|
{
|
196
196
|
kind: 'favorite',
|
197
197
|
name: pname,
|
@@ -255,7 +255,7 @@ label.ui-corner-all {
|
|
255
255
|
.star {
|
256
256
|
text-indent: -5000px;
|
257
257
|
display: block;
|
258
|
-
background: transparent url(/images/milkode-star.png) 20px;
|
258
|
+
background: transparent url(<%= url_for "/images/milkode-star.png" %>) 20px;
|
259
259
|
height: 20px;
|
260
260
|
width: 20px;
|
261
261
|
}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
function set_pathname() {
|
4
4
|
document.searchform.pathname.value = location.pathname;
|
5
5
|
}
|
6
|
-
%form(name="searchform" action="/search" method="post")
|
6
|
+
%form(name="searchform" action="#{url_for '/search'}" method="post")
|
7
7
|
%p
|
8
8
|
%input#query(name="query" size="70" type="text" style="width: 419px;"){:value => params[:query]}
|
9
9
|
%input#search(type="submit" name="search" value="検索" onclick="set_pathname()")
|
data/lib/milkode/cli.rb
CHANGED
@@ -151,12 +151,13 @@ EOF
|
|
151
151
|
end
|
152
152
|
|
153
153
|
desc "web", "Startup web interface"
|
154
|
-
option :db, :default => Milkode::CLI_Cdweb::select_dbdir
|
155
|
-
option :host, :default => '127.0.0.1', :aliases => '-o'
|
156
|
-
option :port, :default => 9292, :aliases => '-p'
|
157
|
-
option :server, :default => 'thin', :aliases => '-s'
|
158
|
-
option :no_browser, :type => :boolean, :default => false, :aliases => '-n', :type => :boolean, :desc => 'Do not launch browser.'
|
159
154
|
option :customize, :type => :boolean, :desc => 'Create customize file.'
|
155
|
+
option :db, :default => Milkode::CLI_Cdweb::select_dbdir, :desc => 'Database dir.'
|
156
|
+
option :no_browser, :type => :boolean, :default => false, :aliases => '-n', :type => :boolean, :desc => 'Do not launch browser.'
|
157
|
+
option :host, :default => '127.0.0.1', :aliases => '-o', :desc => 'Listen on HOST.'
|
158
|
+
option :port, :default => 9292, :aliases => '-p', :desc => 'Use PORT.'
|
159
|
+
option :server, :default => 'thin', :aliases => '-s', :desc => 'Use SERVER.'
|
160
|
+
option :url, :aliases => '-u', :type => :string, :desc => 'Relative URL. (Default: "/")'
|
160
161
|
def web
|
161
162
|
opts = {
|
162
163
|
:environment => ENV['RACK_ENV'] || "development",
|
@@ -169,6 +170,7 @@ EOF
|
|
169
170
|
:server => options[:server],
|
170
171
|
:LaunchBrowser => !options[:no_browser],
|
171
172
|
:DbDir => options[:db],
|
173
|
+
:url => options[:url],
|
172
174
|
}
|
173
175
|
opts[:customize] = options[:customize]
|
174
176
|
# cdstk(opts[:DbDir]).assert_compatible
|
@@ -195,6 +197,7 @@ EOF
|
|
195
197
|
end
|
196
198
|
|
197
199
|
desc "files", "Display package files"
|
200
|
+
option :all, :type => :boolean, :aliases => '-a', :desc => 'Display all package files.'
|
198
201
|
option :relative, :type => :boolean, :aliases => '-r', :desc => "Display relative path."
|
199
202
|
def files(*args)
|
200
203
|
cdstk.files(args, options)
|
data/lib/milkode/common/util.rb
CHANGED
@@ -209,7 +209,7 @@ EOF
|
|
209
209
|
findGrep.searchAndPrint2(stdout, records)
|
210
210
|
else
|
211
211
|
# レコード数が多い時は"-e grep"で検索
|
212
|
-
if Util::exist_command?('grep') && Util::exist_command?('xargs')
|
212
|
+
if Util::exist_command?('cat') && Util::exist_command?('grep') && Util::exist_command?('xargs')
|
213
213
|
$stderr.puts "Number of records is large. Use auto external tool (gmilk -e grep)"
|
214
214
|
search_external_tool(arguments, option, records, 'grep -n', 'grep')
|
215
215
|
else
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Sinatra
|
2
|
+
module UrlForHelper
|
3
|
+
# Construct a link to +url_fragment+, which should be given relative to
|
4
|
+
# the base of this Sinatra app. The mode should be either
|
5
|
+
# <code>:path_only</code>, which will generate an absolute path within
|
6
|
+
# the current domain (the default), or <code>:full</code>, which will
|
7
|
+
# include the site name and port number. (The latter is typically
|
8
|
+
# necessary for links in RSS feeds.) Example usage:
|
9
|
+
#
|
10
|
+
# url_for "/" # Returns "/myapp/"
|
11
|
+
# url_for "/foo" # Returns "/myapp/foo"
|
12
|
+
# url_for "/foo", :full # Returns "http://example.com/myapp/foo"
|
13
|
+
#
|
14
|
+
# You can also pass in a hash of options, which will be appended to the
|
15
|
+
# URL as escaped parameters, like so:
|
16
|
+
#
|
17
|
+
# url_for "/", :x => "y" # Returns "/myapp/?x=y"
|
18
|
+
# url_for "/foo", :x => "M&Ms" # Returns "/myapp/foo?x=M%26Ms"
|
19
|
+
#
|
20
|
+
# You can also specify the mode:
|
21
|
+
#
|
22
|
+
# url_for "/foo", :full, :x => "y" # Returns "http://example.com/myapp/foo?x=y"
|
23
|
+
#
|
24
|
+
#--
|
25
|
+
# See README.rdoc for a list of some of the people who helped me clean
|
26
|
+
# up earlier versions of this code.
|
27
|
+
def url_for url_fragment, mode=nil, options = nil
|
28
|
+
if mode.is_a? Hash
|
29
|
+
options = mode
|
30
|
+
mode = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
if mode.nil?
|
34
|
+
mode = :path_only
|
35
|
+
end
|
36
|
+
|
37
|
+
mode = mode.to_sym unless mode.is_a? Symbol
|
38
|
+
optstring = nil
|
39
|
+
|
40
|
+
if options.is_a? Hash
|
41
|
+
optstring = '?' + options.map { |k,v| "#{k}=#{URI.escape(v.to_s, /[^#{URI::PATTERN::UNRESERVED}]/)}" }.join('&')
|
42
|
+
end
|
43
|
+
|
44
|
+
case mode
|
45
|
+
when :path_only
|
46
|
+
base = request.script_name
|
47
|
+
when :full
|
48
|
+
scheme = request.scheme
|
49
|
+
if (scheme == 'http' && request.port == 80 ||
|
50
|
+
scheme == 'https' && request.port == 443)
|
51
|
+
port = ""
|
52
|
+
else
|
53
|
+
port = ":#{request.port}"
|
54
|
+
end
|
55
|
+
base = "#{scheme}://#{request.host}#{port}#{request.script_name}"
|
56
|
+
else
|
57
|
+
raise TypeError, "Unknown url_for mode #{mode.inspect}"
|
58
|
+
end
|
59
|
+
"#{base}#{url_fragment}#{optstring}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
helpers UrlForHelper
|
64
|
+
end
|
data/milkode.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{milkode}
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ongaeshi"]
|
12
|
-
s.date = %q{2013-06-
|
12
|
+
s.date = %q{2013-06-26}
|
13
13
|
s.description = %q{Line based local source code search engine & grep-command & web-app.}
|
14
14
|
s.email = %q{ongaeshi0621@gmail.com}
|
15
15
|
s.executables = ["gmilk", "milk"]
|
@@ -61,7 +61,6 @@ Gem::Specification.new do |s|
|
|
61
61
|
"lib/milkode/cdweb/public/css/coderay.css",
|
62
62
|
"lib/milkode/cdweb/public/css/jquery.multiselect.css",
|
63
63
|
"lib/milkode/cdweb/public/css/jquery.multiselect.filter.css",
|
64
|
-
"lib/milkode/cdweb/public/css/milkode.css",
|
65
64
|
"lib/milkode/cdweb/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png",
|
66
65
|
"lib/milkode/cdweb/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png",
|
67
66
|
"lib/milkode/cdweb/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png",
|
@@ -97,7 +96,6 @@ Gem::Specification.new do |s|
|
|
97
96
|
"lib/milkode/cdweb/public/js/jquery-ui-1.8.22.custom.min.js",
|
98
97
|
"lib/milkode/cdweb/public/js/jquery.multiselect.filter.min.js",
|
99
98
|
"lib/milkode/cdweb/public/js/jquery.multiselect.min.js",
|
100
|
-
"lib/milkode/cdweb/public/js/milkode.js",
|
101
99
|
"lib/milkode/cdweb/views/error.haml",
|
102
100
|
"lib/milkode/cdweb/views/filelist.haml",
|
103
101
|
"lib/milkode/cdweb/views/header_menu.haml",
|
@@ -106,6 +104,8 @@ Gem::Specification.new do |s|
|
|
106
104
|
"lib/milkode/cdweb/views/info_home.haml",
|
107
105
|
"lib/milkode/cdweb/views/info_package.haml",
|
108
106
|
"lib/milkode/cdweb/views/layout.haml",
|
107
|
+
"lib/milkode/cdweb/views/milkode.js",
|
108
|
+
"lib/milkode/cdweb/views/milkode.scss",
|
109
109
|
"lib/milkode/cdweb/views/packages.haml",
|
110
110
|
"lib/milkode/cdweb/views/search.haml",
|
111
111
|
"lib/milkode/cdweb/views/search_form.haml",
|
@@ -133,6 +133,7 @@ Gem::Specification.new do |s|
|
|
133
133
|
"lib/milkode/grep/fast_gotoline.rb",
|
134
134
|
"lib/milkode/grep/findgrep.rb",
|
135
135
|
"lib/milkode/grep/findgrep_option.rb",
|
136
|
+
"lib/sinatra/url_for.rb",
|
136
137
|
"milkode.gemspec",
|
137
138
|
"test/data/.gitignore",
|
138
139
|
"test/data/.gitignore.sjis",
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.2
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- ongaeshi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-06-
|
18
|
+
date: 2013-06-26 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -328,7 +328,6 @@ files:
|
|
328
328
|
- lib/milkode/cdweb/public/css/coderay.css
|
329
329
|
- lib/milkode/cdweb/public/css/jquery.multiselect.css
|
330
330
|
- lib/milkode/cdweb/public/css/jquery.multiselect.filter.css
|
331
|
-
- lib/milkode/cdweb/public/css/milkode.css
|
332
331
|
- lib/milkode/cdweb/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
333
332
|
- lib/milkode/cdweb/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
334
333
|
- lib/milkode/cdweb/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
@@ -364,7 +363,6 @@ files:
|
|
364
363
|
- lib/milkode/cdweb/public/js/jquery-ui-1.8.22.custom.min.js
|
365
364
|
- lib/milkode/cdweb/public/js/jquery.multiselect.filter.min.js
|
366
365
|
- lib/milkode/cdweb/public/js/jquery.multiselect.min.js
|
367
|
-
- lib/milkode/cdweb/public/js/milkode.js
|
368
366
|
- lib/milkode/cdweb/views/error.haml
|
369
367
|
- lib/milkode/cdweb/views/filelist.haml
|
370
368
|
- lib/milkode/cdweb/views/header_menu.haml
|
@@ -373,6 +371,8 @@ files:
|
|
373
371
|
- lib/milkode/cdweb/views/info_home.haml
|
374
372
|
- lib/milkode/cdweb/views/info_package.haml
|
375
373
|
- lib/milkode/cdweb/views/layout.haml
|
374
|
+
- lib/milkode/cdweb/views/milkode.js
|
375
|
+
- lib/milkode/cdweb/views/milkode.scss
|
376
376
|
- lib/milkode/cdweb/views/packages.haml
|
377
377
|
- lib/milkode/cdweb/views/search.haml
|
378
378
|
- lib/milkode/cdweb/views/search_form.haml
|
@@ -400,6 +400,7 @@ files:
|
|
400
400
|
- lib/milkode/grep/fast_gotoline.rb
|
401
401
|
- lib/milkode/grep/findgrep.rb
|
402
402
|
- lib/milkode/grep/findgrep_option.rb
|
403
|
+
- lib/sinatra/url_for.rb
|
403
404
|
- milkode.gemspec
|
404
405
|
- test/data/.gitignore
|
405
406
|
- test/data/.gitignore.sjis
|