codestock 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/cdweb +2 -2
- data/codestock.gemspec +56 -10
- data/lib/cdstk/cdstk.rb +4 -1
- data/lib/codestock/cdweb/app.rb +136 -0
- data/lib/codestock/cdweb/cli_cdweb.rb +84 -0
- data/lib/codestock/cdweb/config.ru +3 -0
- data/lib/codestock/cdweb/lib/coderay_wrapper.rb +94 -0
- data/lib/codestock/cdweb/lib/command.rb +67 -0
- data/lib/{cdweb → codestock/cdweb/lib}/database.rb +55 -28
- data/lib/{cdweb → codestock/cdweb/lib}/grep.rb +24 -8
- data/lib/codestock/cdweb/lib/mkurl.rb +56 -0
- data/lib/{cdweb → codestock/cdweb/lib}/query.rb +3 -4
- data/lib/codestock/cdweb/lib/search_contents.rb +117 -0
- data/lib/codestock/cdweb/lib/search_files.rb +88 -0
- data/lib/{cdweb → codestock/cdweb}/public/css/gren.css +16 -1
- data/lib/codestock/cdweb/public/images/directory.png +0 -0
- data/lib/codestock/cdweb/public/images/file.png +0 -0
- data/lib/codestock/cdweb/views/filelist.haml +14 -0
- data/lib/codestock/cdweb/views/help.haml +16 -0
- data/lib/codestock/cdweb/views/index.haml +17 -0
- data/lib/codestock/cdweb/views/layout.haml +33 -0
- data/lib/codestock/cdweb/views/search.haml +12 -0
- data/lib/codestock/cdweb/views/view.haml +16 -0
- data/test/file_assert.rb +41 -0
- data/test/test_coderay_wrapper.rb +22 -0
- data/test/test_coderay_wrapper_data.rb +91 -0
- data/test/test_database.rb +54 -0
- data/test/test_mkurl.rb +30 -0
- data/test/test_query.rb +54 -0
- metadata +52 -26
- data/lib/cdweb/cli_cdweb.rb +0 -54
- data/lib/cdweb/coderay_wrapper.rb +0 -38
- data/lib/cdweb/grenweb.ru +0 -35
- data/lib/cdweb/help.rb +0 -40
- data/lib/cdweb/home.rb +0 -40
- data/lib/cdweb/html_renderer.rb +0 -243
- data/lib/cdweb/searcher.rb +0 -130
- data/lib/cdweb/viewer.rb +0 -52
- data/test/test_grenweb_database.rb +0 -36
- data/test/test_grenweb_html_renderer.rb +0 -41
- data/test/test_grenweb_query.rb +0 -54
- data/test/test_grenweb_searcher.rb +0 -35
- /data/lib/{cdweb → codestock/cdweb}/public/css/coderay.css +0 -0
- /data/lib/{cdweb → codestock/cdweb}/public/images/gren-icon-mini.png +0 -0
- /data/lib/{cdweb → codestock/cdweb}/public/images/gren-icon.png +0 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# @file
|
4
|
+
# @brief
|
5
|
+
# @author ongaeshi
|
6
|
+
# @date 2011/02/20
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'groonga'
|
10
|
+
require 'test_helper'
|
11
|
+
require 'file_test_utils'
|
12
|
+
require 'stringio'
|
13
|
+
require 'cdstk/cdstk'
|
14
|
+
require 'codestock/cdweb/lib/database'
|
15
|
+
|
16
|
+
module CodeStock
|
17
|
+
class TestDatabase < Test::Unit::TestCase
|
18
|
+
include FileTestUtils
|
19
|
+
|
20
|
+
def setup_db
|
21
|
+
# データベース作成
|
22
|
+
io = StringIO.new
|
23
|
+
obj = Cdstk.new(io)
|
24
|
+
obj.init
|
25
|
+
obj.add('../../test')
|
26
|
+
obj.add('../../lib')
|
27
|
+
# puts io.string
|
28
|
+
|
29
|
+
# データベースのセットアップ
|
30
|
+
Database.setup('.')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_database
|
34
|
+
setup_db
|
35
|
+
t_open
|
36
|
+
t_fileList
|
37
|
+
end
|
38
|
+
|
39
|
+
def t_open
|
40
|
+
Database.instance
|
41
|
+
end
|
42
|
+
|
43
|
+
def t_fileList
|
44
|
+
db = Database.instance
|
45
|
+
assert_equal [['test', false], ['lib', false]], db.fileList('')
|
46
|
+
assert db.fileList('test').include? ['test/test_database.rb', true]
|
47
|
+
assert_equal ['lib/cdstk', false], db.fileList('lib')[0]
|
48
|
+
assert_equal ['lib/cdstk/cdstk.rb', true], db.fileList('lib/cdstk')[0]
|
49
|
+
assert_equal nil, db.fileList('lib/cdstk/cdstk.rb')[0]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
data/test/test_mkurl.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# @file
|
4
|
+
# @brief
|
5
|
+
# @author ongaeshi
|
6
|
+
# @date 2010/10/21
|
7
|
+
|
8
|
+
require 'test_helper'
|
9
|
+
require 'codestock/cdweb/lib/mkurl'
|
10
|
+
|
11
|
+
module CodeStock
|
12
|
+
class TestMkurl < Test::Unit::TestCase
|
13
|
+
def test_basic
|
14
|
+
p1 = {:query => 'test', :shead => 'package', :page => '2'}
|
15
|
+
p2 = {:query => 'test', :page => '2'}
|
16
|
+
p3 = {:page => '2'}
|
17
|
+
|
18
|
+
assert_equal '/home/foo/bar.hpp?query=test&shead=package', Mkurl.new('/home/foo/bar.hpp', p1).inherit_query_shead
|
19
|
+
assert_equal '.?query=test&shead=package', Mkurl.new('.', p1).inherit_query_shead
|
20
|
+
assert_equal '/home/foo/bar.hpp?query=test', Mkurl.new('/home/foo/bar.hpp', p2).inherit_query_shead
|
21
|
+
assert_equal '/home/foo/bar.hpp', Mkurl.new('/home/foo/bar.hpp', p3).inherit_query_shead
|
22
|
+
|
23
|
+
assert_equal '/home/foo/bar.hpp?shead=package', Mkurl.new('/home/foo/bar.hpp', p1).inherit_shead
|
24
|
+
assert_equal '.?shead=package', Mkurl.new('.', p1).inherit_shead
|
25
|
+
assert_equal '/home/foo/bar.hpp', Mkurl.new('/home/foo/bar.hpp', p2).inherit_shead
|
26
|
+
assert_equal '/home/foo/bar.hpp', Mkurl.new('/home/foo/bar.hpp', p3).inherit_shead
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/test/test_query.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# @file
|
4
|
+
# @brief
|
5
|
+
# @author ongaeshi
|
6
|
+
# @date 2010/10/21
|
7
|
+
|
8
|
+
require 'test_helper'
|
9
|
+
require 'codestock/cdweb/lib/query'
|
10
|
+
|
11
|
+
module CodeStock
|
12
|
+
class TestQuery < Test::Unit::TestCase
|
13
|
+
def test_query
|
14
|
+
q = create_query("test fire beam")
|
15
|
+
assert_equal q.keywords, ['test', 'fire', 'beam']
|
16
|
+
assert_equal q.packages, []
|
17
|
+
assert_equal q.fpaths, []
|
18
|
+
assert_equal q.suffixs, []
|
19
|
+
assert_equal q.escape_html, 'test fire beam'
|
20
|
+
|
21
|
+
q = create_query("test fire beam f:testfile1")
|
22
|
+
assert_equal q.keywords, ['test', 'fire', 'beam']
|
23
|
+
assert_equal q.packages, []
|
24
|
+
assert_equal q.fpaths, ['testfile1']
|
25
|
+
assert_equal q.suffixs, []
|
26
|
+
|
27
|
+
q = create_query("test fire beam f:testfile1 filepath:dir32")
|
28
|
+
assert_equal q.keywords, ['test', 'fire', 'beam']
|
29
|
+
assert_equal q.packages, []
|
30
|
+
assert_equal q.fpaths, ['dir32', 'testfile1']
|
31
|
+
assert_equal q.suffixs, []
|
32
|
+
|
33
|
+
q = create_query("package:gren test fire beam f:testfile1 filepath:dir32 s:rb p:test suffix:pl")
|
34
|
+
assert_equal q.keywords, ['test', 'fire', 'beam']
|
35
|
+
assert_equal q.packages, ['gren', 'test']
|
36
|
+
assert_equal q.fpaths, ['dir32', 'testfile1']
|
37
|
+
assert_equal q.suffixs, ['pl', 'rb']
|
38
|
+
|
39
|
+
q = create_query("&p")
|
40
|
+
assert_equal "&p", q.query_string
|
41
|
+
assert_equal q.escape_html, '&p'
|
42
|
+
|
43
|
+
q = create_query("int &p")
|
44
|
+
assert_equal q.escape_html, 'int &p'
|
45
|
+
|
46
|
+
q = create_query('"def update"')
|
47
|
+
assert_equal q.keywords, ['def update']
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_query(query)
|
51
|
+
Query.new(query)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- ongaeshi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-07-
|
17
|
+
date: 2011-07-20 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -127,6 +127,20 @@ dependencies:
|
|
127
127
|
requirement: *id008
|
128
128
|
prerelease: false
|
129
129
|
type: :runtime
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
segments:
|
136
|
+
- 1
|
137
|
+
- 2
|
138
|
+
- 10
|
139
|
+
version: 1.2.10
|
140
|
+
name: thin
|
141
|
+
requirement: *id009
|
142
|
+
prerelease: false
|
143
|
+
type: :runtime
|
130
144
|
description: longer description of your gem
|
131
145
|
email: ongaeshi0621@gmail.com
|
132
146
|
executables:
|
@@ -157,22 +171,30 @@ files:
|
|
157
171
|
- lib/cdstk/cdstk_yaml.rb
|
158
172
|
- lib/cdstk/cli_cdstk.rb
|
159
173
|
- lib/cdview/cli_cdview.rb
|
160
|
-
- lib/cdweb/cli_cdweb.rb
|
161
|
-
- lib/cdweb/coderay_wrapper.rb
|
162
|
-
- lib/cdweb/database.rb
|
163
|
-
- lib/cdweb/grenweb.ru
|
164
|
-
- lib/cdweb/grep.rb
|
165
|
-
- lib/cdweb/help.rb
|
166
|
-
- lib/cdweb/home.rb
|
167
|
-
- lib/cdweb/html_renderer.rb
|
168
|
-
- lib/cdweb/public/css/coderay.css
|
169
|
-
- lib/cdweb/public/css/gren.css
|
170
|
-
- lib/cdweb/public/images/gren-icon-mini.png
|
171
|
-
- lib/cdweb/public/images/gren-icon.png
|
172
|
-
- lib/cdweb/query.rb
|
173
|
-
- lib/cdweb/searcher.rb
|
174
|
-
- lib/cdweb/viewer.rb
|
175
174
|
- lib/codestock.rb
|
175
|
+
- lib/codestock/cdweb/app.rb
|
176
|
+
- lib/codestock/cdweb/cli_cdweb.rb
|
177
|
+
- lib/codestock/cdweb/config.ru
|
178
|
+
- lib/codestock/cdweb/lib/coderay_wrapper.rb
|
179
|
+
- lib/codestock/cdweb/lib/command.rb
|
180
|
+
- lib/codestock/cdweb/lib/database.rb
|
181
|
+
- lib/codestock/cdweb/lib/grep.rb
|
182
|
+
- lib/codestock/cdweb/lib/mkurl.rb
|
183
|
+
- lib/codestock/cdweb/lib/query.rb
|
184
|
+
- lib/codestock/cdweb/lib/search_contents.rb
|
185
|
+
- lib/codestock/cdweb/lib/search_files.rb
|
186
|
+
- lib/codestock/cdweb/public/css/coderay.css
|
187
|
+
- lib/codestock/cdweb/public/css/gren.css
|
188
|
+
- lib/codestock/cdweb/public/images/directory.png
|
189
|
+
- lib/codestock/cdweb/public/images/file.png
|
190
|
+
- lib/codestock/cdweb/public/images/gren-icon-mini.png
|
191
|
+
- lib/codestock/cdweb/public/images/gren-icon.png
|
192
|
+
- lib/codestock/cdweb/views/filelist.haml
|
193
|
+
- lib/codestock/cdweb/views/help.haml
|
194
|
+
- lib/codestock/cdweb/views/index.haml
|
195
|
+
- lib/codestock/cdweb/views/layout.haml
|
196
|
+
- lib/codestock/cdweb/views/search.haml
|
197
|
+
- lib/codestock/cdweb/views/view.haml
|
176
198
|
- lib/common/dbdir.rb
|
177
199
|
- lib/common/display_util.rb
|
178
200
|
- lib/common/grenfiletest.rb
|
@@ -182,19 +204,21 @@ files:
|
|
182
204
|
- lib/common/util.rb
|
183
205
|
- lib/findgrep/findgrep.rb
|
184
206
|
- lib/findgrep/result.rb
|
207
|
+
- test/file_assert.rb
|
185
208
|
- test/file_test_utils.rb
|
186
209
|
- test/rake_test_loader.rb
|
187
210
|
- test/runner.rb
|
188
211
|
- test/test_bin_exec.rb
|
189
212
|
- test/test_cdstk.rb
|
190
213
|
- test/test_cdstk_yaml.rb
|
214
|
+
- test/test_coderay_wrapper.rb
|
215
|
+
- test/test_coderay_wrapper_data.rb
|
216
|
+
- test/test_database.rb
|
191
217
|
- test/test_dbdir.rb
|
192
218
|
- test/test_gren_util.rb
|
193
|
-
- test/test_grenweb_database.rb
|
194
|
-
- test/test_grenweb_html_renderer.rb
|
195
|
-
- test/test_grenweb_query.rb
|
196
|
-
- test/test_grenweb_searcher.rb
|
197
219
|
- test/test_helper.rb
|
220
|
+
- test/test_mkurl.rb
|
221
|
+
- test/test_query.rb
|
198
222
|
- test/test_string_snip.rb
|
199
223
|
has_rdoc: true
|
200
224
|
homepage: http://github.com/ongaeshi/codestock
|
@@ -227,17 +251,19 @@ signing_key:
|
|
227
251
|
specification_version: 3
|
228
252
|
summary: one-line summary of your gem
|
229
253
|
test_files:
|
254
|
+
- test/file_assert.rb
|
230
255
|
- test/file_test_utils.rb
|
231
256
|
- test/rake_test_loader.rb
|
232
257
|
- test/runner.rb
|
233
258
|
- test/test_bin_exec.rb
|
234
259
|
- test/test_cdstk.rb
|
235
260
|
- test/test_cdstk_yaml.rb
|
261
|
+
- test/test_coderay_wrapper.rb
|
262
|
+
- test/test_coderay_wrapper_data.rb
|
263
|
+
- test/test_database.rb
|
236
264
|
- test/test_dbdir.rb
|
237
265
|
- test/test_gren_util.rb
|
238
|
-
- test/test_grenweb_database.rb
|
239
|
-
- test/test_grenweb_html_renderer.rb
|
240
|
-
- test/test_grenweb_query.rb
|
241
|
-
- test/test_grenweb_searcher.rb
|
242
266
|
- test/test_helper.rb
|
267
|
+
- test/test_mkurl.rb
|
268
|
+
- test/test_query.rb
|
243
269
|
- test/test_string_snip.rb
|
data/lib/cdweb/cli_cdweb.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'optparse'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'cdweb/database'
|
6
|
-
require 'common/dbdir'
|
7
|
-
include CodeStock
|
8
|
-
require 'rack'
|
9
|
-
require 'launchy'
|
10
|
-
|
11
|
-
module CodeStock
|
12
|
-
class CLI_Cdweb
|
13
|
-
def self.execute(stdout, arguments=[])
|
14
|
-
option = {
|
15
|
-
:Port => 9292,
|
16
|
-
:DbDir => db_default_dir,
|
17
|
-
}
|
18
|
-
|
19
|
-
opt = OptionParser.new("#{File.basename($0)}")
|
20
|
-
opt.on('--db DB_DIR', 'Database dir (default : ~/.codestock)') {|v| option[:DbDir] = v }
|
21
|
-
opt.on('-p', '--port PORT', 'use PORT (default: 9292)') {|v| option[:Port] = v }
|
22
|
-
opt.on('--no-browser', 'No launch browser.') {|v| option[:NoBrowser] = true }
|
23
|
-
opt.parse!(arguments)
|
24
|
-
|
25
|
-
# webサーバー起動
|
26
|
-
stdout.puts <<EOF
|
27
|
-
Start up grenweb !!
|
28
|
-
URL : http://localhost:#{option[:Port]}
|
29
|
-
DB : #{option[:DbDir]}
|
30
|
-
----------------------------------------
|
31
|
-
EOF
|
32
|
-
|
33
|
-
# 使用するデータベースの位置設定
|
34
|
-
Database.setup(option[:DbDir])
|
35
|
-
|
36
|
-
# サーバースクリプトのある場所へ移動
|
37
|
-
FileUtils.cd(File.dirname(__FILE__))
|
38
|
-
|
39
|
-
# ブラウザ起動
|
40
|
-
Launchy.open("http://localhost:#{option[:Port]}") unless (option[:NoBrowser])
|
41
|
-
|
42
|
-
# サーバー起動
|
43
|
-
Rack::Server.start(
|
44
|
-
:environment => "development",
|
45
|
-
:pid => nil,
|
46
|
-
:Port => option[:Port],
|
47
|
-
:Host => "0.0.0.0",
|
48
|
-
:AccessLog => [],
|
49
|
-
:config => "grenweb.ru"
|
50
|
-
)
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# @file
|
4
|
-
# @brief
|
5
|
-
# @author ongaeshi
|
6
|
-
# @date 2011/07/03
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'coderay'
|
10
|
-
require 'coderay/helpers/file_type'
|
11
|
-
|
12
|
-
module CodeStock
|
13
|
-
class CodeRayWrapper
|
14
|
-
def self.html_memfile(content, filename)
|
15
|
-
to_html_code(content, file_type(filename))
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.to_html_code(code, kind)
|
19
|
-
CodeRay.scan(code, kind).
|
20
|
-
html(
|
21
|
-
:wrap => nil,
|
22
|
-
:line_numbers => :table,
|
23
|
-
:css => :class
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.file_type(filename)
|
28
|
-
case File.extname(filename)
|
29
|
-
when ".el"
|
30
|
-
:scheme
|
31
|
-
else
|
32
|
-
CodeRay::FileType.fetch filename, :plaintext
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
data/lib/cdweb/grenweb.ru
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# @file
|
4
|
-
# @brief gren web検索
|
5
|
-
# @author ongaeshi
|
6
|
-
# @date 2010/10/13
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rack'
|
10
|
-
require 'cdweb/home'
|
11
|
-
require 'cdweb/searcher'
|
12
|
-
require 'cdweb/viewer'
|
13
|
-
require 'cdweb/help'
|
14
|
-
|
15
|
-
use Rack::CommonLogger
|
16
|
-
use Rack::Runtime
|
17
|
-
use Rack::Static, :urls => ["/css", "/images"], :root => "public"
|
18
|
-
use Rack::ContentLength
|
19
|
-
|
20
|
-
map '/' do
|
21
|
-
run CodeStock::Home.new
|
22
|
-
end
|
23
|
-
|
24
|
-
map '/::search' do
|
25
|
-
run CodeStock::Searcher.new
|
26
|
-
end
|
27
|
-
|
28
|
-
map '/::view' do
|
29
|
-
run CodeStock::Viewer.new
|
30
|
-
end
|
31
|
-
|
32
|
-
map '/::help' do
|
33
|
-
run CodeStock::Help.new
|
34
|
-
end
|
35
|
-
|
data/lib/cdweb/help.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# @file
|
4
|
-
# @brief ホーム画面
|
5
|
-
# @author ongaeshi
|
6
|
-
# @date 2010/10/13
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rack'
|
10
|
-
require 'cdweb/database'
|
11
|
-
require 'cdweb/html_renderer'
|
12
|
-
require 'cdweb/query'
|
13
|
-
|
14
|
-
module CodeStock
|
15
|
-
class Help
|
16
|
-
include Rack::Utils
|
17
|
-
|
18
|
-
def call(env)
|
19
|
-
@env = env
|
20
|
-
@request = Rack::Request.new(env)
|
21
|
-
@query = Query.new(@request)
|
22
|
-
|
23
|
-
@response = Rack::Response.new
|
24
|
-
@response["Content-Type"] = "text/html; charset=UTF-8"
|
25
|
-
|
26
|
-
render
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def render
|
32
|
-
r = HTMLRendeler.new(@request.script_name + '/..')
|
33
|
-
@response.write r.header("gren - help", "gren - help")
|
34
|
-
@response.write r.sample_code
|
35
|
-
@response.write r.footer
|
36
|
-
@response.to_a
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
data/lib/cdweb/home.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# @file
|
4
|
-
# @brief ホーム画面
|
5
|
-
# @author ongaeshi
|
6
|
-
# @date 2010/10/13
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rack'
|
10
|
-
require 'cdweb/database'
|
11
|
-
require 'cdweb/html_renderer'
|
12
|
-
require 'cdweb/query'
|
13
|
-
|
14
|
-
module CodeStock
|
15
|
-
class Home
|
16
|
-
include Rack::Utils
|
17
|
-
|
18
|
-
def call(env)
|
19
|
-
@env = env
|
20
|
-
@request = Rack::Request.new(env)
|
21
|
-
@query = Query.new(@request)
|
22
|
-
|
23
|
-
@response = Rack::Response.new
|
24
|
-
@response["Content-Type"] = "text/html; charset=UTF-8"
|
25
|
-
|
26
|
-
render
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def render
|
32
|
-
r = HTMLRendeler.new(@request.script_name)
|
33
|
-
@response.write r.header_home("gren", "gren", Version)
|
34
|
-
@response.write r.search_box
|
35
|
-
@response.write r.footer_home("??", Database.instance.fileNum)
|
36
|
-
@response.to_a
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|