Trac S5 plugin インストール
昨日日記で書いた「TracWikiSlides : プレゼン資料をTracWiki形式で書く」をすでに実現しているTracプラグインがありました。やつの名は S5 Plugin。S5というのはDHTMLを使ったプレゼンツールでたぶん一番有名なやつです。TracのWiki記法をS5形式に変換して出力してあげれば、あとはS5の実行に任せられるので便利ですね。
で、Trac Pluginのインストールの仕方がまずわかってないので、そこから学ぶ必要がある、と。
Trac Pluginは、Pythonのライブラリのインストールに従っているので、まずはPythonのライブラリインストールのやり方を学ぶ必要がありそうです。
そうそう。
この日記は、作業をやりながら書いてますので、どっかでハマったらすみません。
Pythonプラグインのインストール方法
お手本にした手順はここです。ありがとうございます。
ウノウラボ Unoh Labs: Python開発環境を整えよう
http://labs.unoh.net/2007/04/python.html
手元の環境(OSX Leopard)にはすでにpythonが入っていますが(Trac動きますから)、RubyのGemに相当するツール ez_setup は入っていないみたいなので、インストールします。
$ curl -O http://peak.telecommunity.com/dist/ez_setup.py $ python ez_setup.py
実行結果
$ curl -O http://peak.telecommunity.com/dist/ez_setup.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 9716 100 9716 0 0 8826 0 0:00:01 0:00:01 --:--:-- 26474 $ python ez_setup.py ownloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py2.5.egg Processing setuptools-0.6c9-py2.5.egg Copying setuptools-0.6c9-py2.5.egg to /Library/Python/2.5/site-packages Adding setuptools 0.6c9 to easy-install.pth file error: /Library/Python/2.5/site-packages/easy-install.pth: Permission denied
後の方のコマンドは管理者権限が必要なようですので、sudoつけてもう一度
$ sudo python ez_setup.py Password: Processing setuptools-0.6c9-py2.5.egg Removing /Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg Copying setuptools-0.6c9-py2.5.egg to /Library/Python/2.5/site-packages Adding setuptools 0.6c9 to easy-install.pth file Installing easy_install script to /usr/local/bin Installing easy_install-2.5 script to /usr/local/bin Installed /Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg Processing dependencies for setuptools==0.6c9 Finished processing dependencies for setuptools==0.6c9
なんか入ったっぽい雰囲気ですので、次行きます。
Tracプラグインのインストール
お手本にした手順はここです。ありがとうございます。
- TracPlugins - 気の向くままに・・・ - livedoor Wiki(ウィキ)
その後、インストールしたいPluginのアーカイブに含まれているsetup.pyを用いて、インストールを行うと自動的にLib/site-packagesフォルダ内にeggファイルが作成されます。
入れるのは S5 plugin なので、まずそれをとってきます。
Download
Download the zipped source from here.
これをダウンロードして解凍すると、こういうディレクトリができました。
$ find s5plugin s5plugin s5plugin/0.10 s5plugin/0.10/s5 s5plugin/0.10/s5/__init__.py s5plugin/0.10/s5/htdocs (htdocs以下略) s5plugin/0.10/s5/s5.py s5plugin/0.10/s5/templates s5plugin/0.10/s5/templates/s5.cs s5plugin/0.10/setup.py
s5plugin/0.10/setup.py を ez_setup で実行すればインストールできそうです。
$ cd s5plugin/0.10/ $ python setup.py install running install running bdist_egg running egg_info creating S5.egg-info writing S5.egg-info/PKG-INFO writing top-level names to S5.egg-info/top_level.txt writing dependency_links to S5.egg-info/dependency_links.txt (中略) Processing S5-0.1-py2.5.egg Copying S5-0.1-py2.5.egg to /Library/Python/2.5/site-packages Adding S5 0.1 to easy-install.pth file error: /Library/Python/2.5/site-packages/easy-install.pth: Permission denied
最後のエラーを見ると、やはり管理者権限が必要っぽいですので、sudoをつけてもう一度。
$ sudo python setup.py install unning install running bdist_egg running egg_info (中略) copying build/lib/s5/s5.py -> build/bdist.macosx-10.5-i386/egg/s5 creating build/bdist.macosx-10.5-i386/egg/s5/templates copying build/lib/s5/templates/s5.cs -> build/bdist.macosx-10.5-i386/egg/s5/templates byte-compiling build/bdist.macosx-10.5-i386/egg/s5/__init__.py to __init__.pyc byte-compiling build/bdist.macosx-10.5-i386/egg/s5/s5.py to s5.pyc creating build/bdist.macosx-10.5-i386/egg/EGG-INFO copying S5.egg-info/PKG-INFO -> build/bdist.macosx-10.5-i386/egg/EGG-INFO copying S5.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-i386/egg/EGG-INFO copying S5.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-i386/egg/EGG-INFO copying S5.egg-info/entry_points.txt -> build/bdist.macosx-10.5-i386/egg/EGG-INFO copying S5.egg-info/top_level.txt -> build/bdist.macosx-10.5-i386/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... creating 'dist/S5-0.1-py2.5.egg' and adding 'build/bdist.macosx-10.5-i386/egg' to it removing 'build/bdist.macosx-10.5-i386/egg' (and everything under it) Processing S5-0.1-py2.5.egg Removing /Library/Python/2.5/site-packages/S5-0.1-py2.5.egg Copying S5-0.1-py2.5.egg to /Library/Python/2.5/site-packages Adding S5 0.1 to easy-install.pth file Installed /Library/Python/2.5/site-packages/S5-0.1-py2.5.egg Processing dependencies for S5==0.1 Finished processing dependencies for S5==0.1
あ、インストールできたっぽいですね。
試してみる
tracdを再起動して、Tracサイトを見てみます。
- Tracの管理者権限は付与していますので、Admin(管理)メニューに入れます。
- 左メニューから [General]-[Plugins] を選択すると、右のリストに、"S5 0.1" がいます。
- ▼アイコンをクリックしてメニューを展開すると、以下のようになっているので
- Component: S5Renderer
- Enabled: Off
- EnabledをチェックONしときます。
- Component: S5Renderer
- Enabled: On
- [Apply Changes]ボタンをクリックすると反映しそうです。
すると、各Wikiページの下のにある表示形式リンクに "Slideshow" が追加されます。期待が高まります。
Download in other formats:
Plain Text Slideshow
うーむ。エラーになりました。
Oops…
Trac detected an internal error:
AttributeError: 'genshi._speedups.Markup' object has no attribute 'plaintext'
0.11対応パッチの適用
そういえば、S5 Plugin のチケットにTrac 0.11 対応パッチが添付されていました。
- #1951 (0.11 support patch) - Trac Hacks - Plugins Macros etc. - Trac
- http://trac-hacks.org/ticket/1951
- s5plugin_0.11.patch (5.5 kB) - added by dgynn on 08/20/07 19:53:25.
- http://trac-hacks.org/attachment/ticket/1951/s5plugin_0.11.patch
- http://trac-hacks.org/ticket/1951
このパッチをどう当てたらいいのか....。ダウンロードした S5Pluginに
s5plugin/0.10/s5/s5.py s5plugin/0.10/s5/templates s5plugin/0.10/s5/templates/s5.cs
というファイルがありますので、たぶんここにパッチを当てればよさそうです。
カレントディレクトリは s5plugin/0.10 なので、ここにダウンロードしたパッチファイルをおきます。
lsをとるとこういう感じです。
$ ls S5.egg-info dist s5plugin_0.11.patch build s5 setup.py
恥ずかしながらパッチコマンドを記憶していないので、manをみながらこういうコマンドではないかと推測しました。
$ patch -p0 < s5plugin_0.11.patch
やってみます。えいっ。
patch -p0 < s5plugin_0.11.patch patching file s5/templates/s5.html patching file s5/s5.py
うまくいった感じでしょうか。
s5/templates/s5.htmlができていて、s5/s5.pyの5行目に"Chrome"という文字列が追加されていれば、きっと旨く行っていると思います。
$ head -5 s5/templates/s5.html !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" $ head -5 s5/s5.py # s5 plugin import re from trac.core import * from trac.web.chrome import ITemplateProvider, add_stylesheet, Chrome
お、成功している感じ。
じゃあもう一回インストールしてみます。
$ sudo python setup.py install (中略) copying build/lib/s5/htdocs/ui/yatil/toggle.gif -> build/bdist.macosx-10.5-i386/egg/s5/htdocs/ui/yatil copying build/lib/s5/s5.py -> build/bdist.macosx-10.5-i386/egg/s5 creating build/bdist.macosx-10.5-i386/egg/s5/templates copying build/lib/s5/templates/s5.cs -> build/bdist.macosx-10.5-i386/egg/s5/templates (中略) Installed /Library/Python/2.5/site-packages/S5-0.1-py2.5.egg Processing dependencies for S5==0.1 Finished processing dependencies for S5==0.1
なんとなく、新しくできた s5/templates/s5.html が取り込めていない感がありますが、まあとにかく tracd再起動してみてみます。
Oops… Trac detected an internal error: TemplateNotFound: Template "s5.html" not found
やっぱし。setup.pyあたりにファイルリストがあるんでしょうか?
$ cat setup.py from setuptools import setup themes = ['blue', 'default', 'dokuwiki', 'flower', 'i18n', 'pixel', 'yatil'] data = ['templates/*.cs', 'htdocs/*.png'] + \ ['htdocs/ui/%s/*.*' % theme for theme in themes] setup(name='S5', version='0.1', packages=['s5'], author='Alec Thomas', url='http://trac-hacks.org/wiki/S5Plugin', license='Public Domain', entry_points = {'trac.plugins': ['s5 = s5']}, package_data={'s5' : data})
"data = "のところで、ファイルの拡張子っぽいものを選択しているあたりが気になります。そこを書き換えてみます。
data = ['templates/*.cs', 'templates/*.html', 'htdocs/*.png'] + \ ['htdocs/ui/%s/*.*' % theme for theme in themes]
で、もう一回インストール。
$ sudo python setup.py install (中略) creating build/bdist.macosx-10.5-i386/egg/s5/templates copying build/lib/s5/templates/s5.cs -> build/bdist.macosx-10.5-i386/egg/s5/templates copying build/lib/s5/templates/s5.html -> build/bdist.macosx-10.5-i386/egg/s5/templates (中略) Installed /Library/Python/2.5/site-packages/S5-0.1-py2.5.egg Processing dependencies for S5==0.1 Finished processing dependencies for S5==0.1
こんどは s5/templates/s5.html が取り込まれたようです。tracd再起動してみてみます。
お、動きました!
日本語表示を目指して (今日は断念)
しかし、日本語を含むページが表示できないようです。
スライドを表示したときにHTMLのソースを見ると、文字コード(UTF-8)が指定できていないのがまずそうです。先ほどの、s5/templates/s5.html がそのソースっぽい匂いがしますので、ここに文字コードを示すmetaタグを追記してみます。
$ vim s5/templates/s5.html (中略) <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>$title</title> (以下略)
で、もう一回インストール。
だめっすね。日本語を含むページだけ無視されます。
文字化けしている訳ではないので、HTML表示部ではなく、wikiの処理部分で飛ばされている可能性が高そうです。
今日は日本語ページの表示は断念します。
すみません。
(断念中止)日本語表示できてました。
日本語表示できていました。ただし、前節の metaタグ追記は必要なようです。
だめっすね。日本語を含むページだけ無視されます。
これは、S5Plugin の Wikiの書き方の癖がつかめてなかったのが原因でした。
なんとなく理解した記法はこんな感じ。
おかげさまで、枕を高くして寝られます。
ありがとうございました。