~ubuntu-branches/ubuntu/utopic/tdiary/utopic

« back to all changes in this revision

Viewing changes to contrib2/util/rast-search/rast-search.rb

  • Committer: Bazaar Package Importer
  • Author(s): Daigo Moriwaki
  • Date: 2011-04-11 21:53:16 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110411215316-ih4gt4q8p29d2wf8
Tags: 3.0.1-1
* New upstream release (Closes: #542801, #594947)
* debian/control:
 - Bumped up Standards-Version to 3.9.1.
 - Updated version dependency.
* debian/tdiary-setup.rb: Followed the upstream changes, incorporating js and
  index.fcgi

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env ruby
2
 
# rast-search.rb $Revision: 1.9 $
 
2
# rast-search.rb $Revision: 1.6.2.2 $
3
3
#
4
4
# Copyright (C) 2005 Kazuhiko <kazuhiko@fdiary.net>
5
5
# You can redistribute it and/or modify it under GPL2.
6
6
#
7
 
$KCODE= 'e'
8
 
BEGIN { $defout.binmode }
 
7
$KCODE= 'u'
 
8
BEGIN { $stdout.binmode }
9
9
 
10
10
if FileTest::symlink?( __FILE__ ) then
11
11
        org_path = File::dirname( File::readlink( __FILE__ ) )
23
23
        class TDiaryRast < ::TDiary::TDiaryBase
24
24
                MAX_PAGES = 20
25
25
                SORT_OPTIONS = [
26
 
                        ["score", "��������"],
27
 
                        ["date", "���ս�"],
 
26
                        ["score", "スコア順"],
 
27
                        ["date", "日付順"],
28
28
                ]
29
29
                SORT_PROPERTIES = ["date"]
30
30
                ORDER_OPTIONS = [
31
 
                        ["asc", "����"],
32
 
                        ["desc", "�߽�"],
 
31
                        ["asc", "昇順"],
 
32
                        ["desc", "降順"],
33
33
                ]
34
34
                NUM_OPTIONS = [10, 20, 30, 50, 100]
35
35
 
36
36
                def initialize( cgi, rhtml, conf )
37
37
                        super
38
38
                        @db_path = conf.options['rast.db_path'] || "#{cache_path}/rast"
39
 
                        @encoding = conf.options['rast.encoding'] || 'euc_jp'
 
39
                        @encoding = 'utf8'
40
40
                        # conf.options['sp.selected'] = ''
41
41
                        parse_args
42
42
                        format_form
43
43
                        if @query.empty?
44
 
                                @msg = '�����������Ϥ��ơ��ָ����ץܥ���򲡤��Ƥ�������'
 
44
                                @msg = '検索条件を入力して、「検索」ボタンを押してください'
45
45
                        else
46
46
                                search
47
47
                        end
87
87
                                @result = db.search(convert(@query), options)
88
88
                                @secs = Time.now - t
89
89
                        rescue
90
 
                                @msg = "���顼: #{_($!.to_s)}</p>"
 
90
                                @msg = "エラー: #{_($!.to_s)}</p>"
91
91
                        ensure
92
92
                                db.close
93
93
                        end
118
118
                        end
119
119
                        buf = "<p class=\"infobar\">\n"
120
120
                        if current_page > 1
121
 
                                buf.concat(format_link("����", @start - @num, @num))
 
121
                                buf.concat(format_link("前へ", @start - @num, @num))
122
122
                        end
123
123
                        if first_page > 1
124
124
                                buf.concat("... ")
134
134
                                buf.concat("... ")
135
135
                        end
136
136
                        if current_page < page_count
137
 
                                buf.concat(format_link("����", @start + @num, @num))
 
137
                                buf.concat(format_link("次へ", @start + @num, @num))
138
138
                        end
139
139
                        buf.concat("</p>\n")
140
140
                        return buf
184
184
                def format_form
185
185
                        @num_options = NUM_OPTIONS.collect { |n|
186
186
                                if n == @num
187
 
                                        "<option value=\"#{n}\" selected>#{n}�鷺��</option>"
 
187
                                        "<option value=\"#{n}\" selected>#{n}件ずつ</option>"
188
188
                                else
189
 
                                        "<option value=\"#{n}\">#{n}�鷺��</option>"
 
189
                                        "<option value=\"#{n}\">#{n}件ずつ</option>"
190
190
                                end
191
191
                        }.join("\n")
192
192
                        @sort_options = format_options(SORT_OPTIONS, @sort)
198
198
                end
199
199
 
200
200
                def convert(str)
201
 
                        case @encoding
202
 
                        when 'utf8'
203
 
                                require 'nkf'
204
 
                                NKF::nkf('-w -m0', str)
205
 
                        else
206
 
                                @conf.to_native(str)
207
 
                        end
 
201
                        @conf.to_native(str)
208
202
                end
209
203
        end
210
204
end