Archive for the ‘Chrome’ Category
Google Chromeのtextareaを外部エディタで編集する (Ruby版)
Google Chrome のテキストエリアを外部エディタで編集する Edit with Emacs
自分のPCにはPerlがインストールされていないので、Rubyで書いてみました。Perlは分からないので勘で移植しましたが、一応動作しているようです。
#!/usr/bin/ruby -Ku
require 'webrick'
require 'tempfile'
require 'kconv'
$EDITOR = 'C:\vim\gvim.exe'
$PORT = 9292
server = WEBrick::HTTPServer.new(:Port => $PORT)
trap('INT') { server.shutdown }
server.mount_proc('/status') do |req, res|
res.status = 200
end
server.mount_proc('/edit') do |req, res|
temp = Tempfile.new('editwith_')
temp << req.body
temp.close false
system $EDITOR, temp.path
temp.open
res.body = temp.read.toutf8
temp.close
res.status = 200
res['Content-Type'] = 'text/plain'
res['Content-Length'] = res.body.size
end
server.start
$EDITORと$PORTを適切に設定すれば動作するんじゃないかと思います。