Skip to content

Commit e181662

Browse files
committed
Merge remote-tracking branch 'clear-code/master' into merge-upstream
2 parents b9ea82d + 4a32ce8 commit e181662

9 files changed

+72
-25
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/groonga-database
33
/public/1.*
44
/public/2.*
5+
/public/3.*
56
/test-unit
67
/webrat.log
78
/test/db-*

Gemfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# -*- mode: ruby; coding: utf-8 -*-
1+
# -*- ruby -*-
22
#
3-
# Copyright (C) 2011-2016 Kouhei Sutou <[email protected]>
3+
# Copyright (C) 2011-2020 Sutou Kouhei <[email protected]>
44
#
55
# This library is free software; you can redistribute it and/or
66
# modify it under the terms of the GNU Lesser General Public
@@ -19,8 +19,8 @@ source "https://rubygems.org/"
1919

2020
gem "rroonga"
2121
gem "racknga"
22-
gem "bitclust-core"
23-
gem "bitclust-dev"
22+
gem "bitclust-core", github: "rurema/bitclust"
23+
gem "bitclust-dev", github: "rurema/bitclust"
2424

2525
gem 'rack-protection'
2626

README.rdoc

+28
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,34 @@ license/lgpl-3.0.txtを見てください。
5454
% rackup > /dev/null 2>&1 &
5555
% open http://localhost:9292/
5656

57+
==== WSL Ubuntu-20.04(Windows) + rbenv
58+
59+
First, install Groonga in advance.
60+
Groonga installation is easy and convenient to {install from Ubuntu PPA}[https://groonga.org/ja/docs/install/ubuntu.html#ubuntu].
61+
62+
Depending on your environment, you may need to install additional `zsh` package.
63+
64+
$ sudo apt install zsh
65+
66+
Enter the following command lines in the terminal of WSL:
67+
68+
$ mkdir rurema
69+
$ cd rurema
70+
$ git clone https://github.com/rurema/doctree.git
71+
$ git clone https://github.com/rurema/bitclust.git
72+
$ git clone https://github.com/ranguba/racknga.git
73+
$ git clone https://github.com/clear-code/rurema-search.git
74+
$ rbenv local 2.6.6
75+
$ cd rurema-search
76+
$ gem install groonga
77+
$ gem install bitclust-core bitclust-dev refe2
78+
$ bundle install
79+
$ ./update.sh
80+
$ rackup
81+
82+
Finally, open http://localhost:9292/ by your Web browser.
83+
84+
5785
=== サーバ利用の場合
5886

5987
==== Debian GNU/Linux wheezy

config.ru

+11-5
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,19 @@ urls = [
141141
"/css/",
142142
"/images/",
143143
"/javascripts/",
144-
"/1.8.",
145-
"/1.9.",
146-
"/2.0.",
147-
"/2.1.",
148-
"/2.2.",
144+
"/1.",
145+
"/2.",
146+
"/3.",
149147
]
150148

149+
case environment
150+
when "development"
151+
use Rack::Static,
152+
:urls => urls,
153+
:root => (base_dir + "public").to_s,
154+
:index => "index.html"
155+
end
156+
151157
use Racknga::Middleware::Deflater
152158
use Rack::Lint
153159
use Rack::Head

lib/rurema_search/groonga_indexer.rb

+14-7
Original file line numberDiff line numberDiff line change
@@ -210,37 +210,44 @@ def extract_attributes(source)
210210

211211
class RDAttributesExtractor < BitClust::RDCompiler
212212
def initialize
213-
super(nil)
213+
opt = {:stop_on_syntax_error => false}
214+
super(nil, 1, opt)
214215
end
215216

216217
def extract(src)
217218
@related_names = []
218219
compile(src)
219220
{
220221
:summary => src.split(/\n\n/, 2).first,
221-
:related_names => @related_names.compact.uniq,
222+
:related_names => @related_names.uniq,
222223
}
223224
end
224225

225226
private
226-
def library_link(name, label=nil, fragment=nil)
227+
def add_related_name(name)
228+
return if name.nil?
229+
return if name.empty?
227230
@related_names << name
228231
end
229232

233+
def library_link(name, label=nil, fragment=nil)
234+
add_related_name(name)
235+
end
236+
230237
def class_link(name, label=nil, fragment=nil)
231-
@related_names << name
238+
add_related_name(name)
232239
end
233240

234241
def method_link(spec, label=nil, fragment=nil)
235-
@related_names << spec
242+
add_related_name(name)
236243
end
237244

238245
def function_link(name, label=nil, fragment=nil)
239-
@related_names << name
246+
add_related_name(name)
240247
end
241248

242249
def document_link(name, label=nil, fragment=nil)
243-
@related_names << name
250+
add_related_name(name)
244251
end
245252
end
246253
end

lib/rurema_search/groonga_suggest_database.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def register_keyword(keyword, related_keywords)
7171
@context.receive
7272

7373
item_values = []
74-
item_values << {"_key" => keyword, "kana" => keyword}
74+
item_values << {"_key" => keyword, "kana" => [keyword]}
7575
related_keywords.each do |related_keyword|
76-
item_values << {"_key" => related_keyword, "kana" => related_keyword}
76+
item_values << {"_key" => related_keyword, "kana" => [related_keyword]}
7777
end
7878
@context.send("load --table #{table_name('item')}")
7979
@context.send(JSON.generate(item_values))

public/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
User-agent: bingbot
22
Disallow: /
33

4+
User-agent: cotoba_bot
5+
Disallow: /
6+
47
User-agent: *
58
Clawl-Delay: 5

update.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
base_dir=$(cd "$(dirname "$0")" && pwd)
44
: ${RUBY:=ruby}
5-
bitclust_dir=$($RUBY -rubygems -e 'print Gem::Specification.find_by_name("bitclust-core").gem_dir')
5+
bitclust_dir=$($RUBY -rrubygems -e 'print Gem::Specification.find_by_name("bitclust-core").gem_dir')
66
doctree_dir=${base_dir}/../doctree
77

88
PATH=${base_dir}/local/bin:$PATH
@@ -67,13 +67,16 @@ update_rurema()
6767
--database ${base_dir}/db-${version} \
6868
statichtml \
6969
--quiet \
70+
--no-stop-on-syntax-error \
7071
--fs-casesensitive \
7172
--outputdir ${base_dir}/public/${version}.new \
7273
--catalog ${bitclust_dir}/data/bitclust/catalog \
7374
--template ${bitclust_dir}/data/bitclust/template
74-
mv ${base_dir}/public/${version}{,.old}
75-
mv ${base_dir}/public/${version}{.new,}
76-
rm -rf ${base_dir}/public/${version}.old
75+
if [ $? -eq 0 ]; then
76+
mv ${base_dir}/public/${version}{,.old}
77+
mv ${base_dir}/public/${version}{.new,}
78+
rm -rf ${base_dir}/public/${version}.old
79+
fi
7780
}
7881

7982
if [ "$update_rurema" = "yes" ]; then
@@ -83,7 +86,7 @@ if [ "$update_rurema" = "yes" ]; then
8386
git clone https://github.com/rurema/doctree.git ${doctree_dir}
8487
fi
8588

86-
for version in 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0; do
89+
for version in 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 3.0.0; do
8790
update_rurema $version
8891
done
8992
wait

views/index.html.erb

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222
<form method="POST" action="./">
2323
<p class="input-form">
2424
<input id="query-input" type="text" class="query ui-autocomplete-input"
25-
name="query" autocomplete="off"
25+
name="query" autocomplete="off" autofocus
2626
value="<%= default_query_form_value %>" />
2727
</p>
2828
<p class="button">
2929
<input type="submit" value="検索" />
3030
</p>
3131
</form>
3232
<script type="text/javascript">
33-
$("#query-input").focus();
3433
$("#query-input").autocomplete({
3534
source: <%= auto_complete_api_path.to_json %>
3635
});

0 commit comments

Comments
 (0)