http://film.rlss.okayama-u.ac.jp/~kgk/dillo-jp/index.html
doc/02solution.txt より
------------------------------------------------------------------------
爆速ブラウザ Dillo 3 の日本語化の挑戦 2013/08/03
ここでは、問題点に対する解決策を提示する。
・キー操作が標準的でない。(FirfoxやChromiumと違う)
/etc/dillo/keysrc を ~/.dillo/ にコピーして、好きなように設定すればよ
い。例えば、
<alt>left = back
<alt>right = forward
といったあたりは設定しておくとよい。
・デフォルトの検索エンジンが見慣れないものになっている。
/etc/dillo/dillorc を ~/.dillo/ にコピーして、'search_url=' が並んでい
る先頭に、
search_url="Google
http://www.google.co.jp/search?ie=UTF-8&oe=UTF-8&q=%s"
などを挿入する。
・googleの検索結果のページに行くときに、ワンクッションある。
~/.dillo/dillorc で、
filter_auto_requests=allow_all
を設定する。
・フォント指定してないと、日本語が表示できない。
~/.dillo/dillorc で設定する。
font_serif="fonts-japanese-mincho"
font_sans_serif="fonts-japanese-gothic"
font_cursive="fonts-japanese-gothic"
font_fantasy="fonts-japanese-gothic"
font_monospace="fonts-japanese-gothic"
自分の好みのフォントに指定してもよい。例えば、
font_serif="TakaoExMincho"
font_sans_serif="TakaoExGothic"
font_cursive="TakaoExGothic"
font_fantasy="TakaoExGothic"
font_monospace="TakaoExGothic"
・googleの検索結果が文字化けする。
・HTTPヘッダでCharsetの指定がないと化けることがある。
・Charset=x-sjisが解釈できない。(http-equivでの指定も含めて)
3つまとめて、自前のプロキシで解決する。ここでは、ruby で書いたプロキシ
を用意する。
# ruby 1.9.3p194 で動作確認。
$ cat ~/bin/dillo_proxy.rb
#!/usr/bin/env ruby
# dillo_proxy 1.02
# proxy for dillo 3 to be japanized
# ver 1.00: 2013/07/28 by KGK (
k...@film.rlss.okayama-u.ac.jp)
# ver 1.01: rescue for double execute. 2013/07/31 by KGK
# ver 1.02: add trap for SIGTERM. 2013/08/03 by KGK
# cf.
http://thinkit.co.jp/article/117/3?page=0,0
require 'webrick'
require 'webrick/httpproxy'
require 'kconv'
include WEBrick
# cf.
http://www2u.biglobe.ne.jp/~MAS/ruby/CAB8BBFAA5B3A1BCA5C9A4CEBFE4C2AC.html
CODE_NAME = {
Kconv::JIS => 'ISO-2022-JP',
Kconv::EUC => 'EUC-JP',
Kconv::SJIS => 'Shift_JIS',
Kconv::BINARY => '',
Kconv::UNKNOWN => '',
Kconv::ASCII => '',
Kconv::UTF8 => 'UTF-8',
Kconv::UTF16 => 'UTF-16',
}
class DilloHTTPProxyServer < HTTPProxyServer
def proxy_service(req, res)
if %r|www\.google\.co\.jp$|.match(req.host)
uri_s = res.request_uri.to_s
if %r/search/.match(uri_s) and ! %r/&oe=UTF-8/.match(uri_s)
if uri_s.gsub!(/&oe=[^&]+/, '&oe=UTF-8')
uri = URI.parse(uri_s)
else
uri = URI.parse(uri_s + '&oe=UTF-8')
end
# print ">redirect: #{uri_s} -> #{uri.to_s}\n"
self.logger.debug(">redirect: #{uri_s} -> #{uri.to_s}")
res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, uri)
return
end
end
super
self.logger.debug(">request uri: #{res.request_uri.to_s}")
if res.header['content-type'] =~ %r!^text/html!
guess = CODE_NAME[Kconv.guess(res.body)]
if guess != '' and ! %r/#{guess}/.match(res.header["content-type"])
ct = "text/html; charset=#{guess}"
# print ">Content-Type: #{res.header["content-type"]} -> #{ct}\n"
self.logger.debug(">Content-Type: #{res.header["content-type"]} -> #{ct}")
res.header["content-type"] = ct
end
res.body.sub!(/(<META .*; Charset=)x-sjis/i, '\1Shift_JIS')
end
end
end
alog="#{ENV['HOME']}/log/dillo_proxy.log"
dlog="#{ENV['HOME']}/log/dillo_proxy_debug.log"
config = {:Port => 8080,
:Logger => WEBrick::Log::new(dlog, WEBrick::Log::DEBUG),
:AccessLog => [[File.open(alog, 'w'), WEBrick::AccessLog::CLF]]}
s = DilloHTTPProxyServer.new(config) rescue exit(0)
File.delete(alog) if File.exist?(alog)
File.delete(dlog) if File.exist?(dlog)
trap("INT"){s.shutdown}
trap("TERM"){s.shutdown}
s.start
# end of script
ここでは、ポート番号を8080にしている。よって、~/.dillo/dillorc で、
http_proxy="
http://127.0.0.1:8080/"
と設定する。
また、~/log というディレクトリがあると仮定している。ついでに、
$ cat ~/bin/dillo.sh
#!/bin/sh
dillo $* 2>&1 > ~/log/dillo.log
# end of script
というのを用意しておくと、ログが ~/.xsession-errors ではなく
~/log/dillo.log に出力される。
プロキシの自動立ち上げの方法はデスクトップ環境によって違う。LXDE な
ら、~/.config/autostart/ に適当な desktop ファイルを用意する。
・cssの影響で文字化けすることがある。(cssを強化した3.0.3ではどうだろう?)
~/.dillo/dillorc で、
parse_embedded_css=NO
filter_auto_requests=allow_all
を設定する。