[[PageOutline]] = Templates for Trac = * Trac 0.11以降を対象 * [http://d.hatena.ne.jp/jun66j5/20080905/trac_menu_genshi Trac 0.11.x で Wiki ページにメニューを付ける - d.hatena.ne.jp/jun66j5/] * PukiWikiのMenuBarにあたるもの * [http://d.hatena.ne.jp/uyamae/20081201/1228111934 Trac Genshi テンプレートのヒント - 見切り発車] * Genshiのコードを手探りする方法 == parameters == * 設定例 * trac.fcgiのURLは「/trac」 * ScriptAlias /trac /usr/local/trac/cgi-bin/trac.fcgi * 環境名は「test」 * インストール先は /path/to/trac/test * htdocs_location = /static/trac * trac.iniで設定 * Alias /static/trac /var/www/trac * ${href.chrome()} * => /trac/test/chrome * ${href.chrome('common/style.css')} * => /trac/test/chrome/common/style.css -> /var/www/trac/style.css * ${href.chrome('site/style.css')} * => /trac/test/chrome/site/style.css -> /path/to/trac/test/htdocs/style.css * ${chrome.htdocs_location} * => /static/trac/ == site.html == * Trac 0.11で新しく環境を作成すると、/path/to/trac/env/templates/site.htmlが自動生成される。 {{{ }}} * globalのtrac.iniなどで指定([inherit] templates_dir)したsite.htmlは各環境ごとのsite.htmlで上書きされるため、0.11からupgradeした場合などは注意が必要。 * 0.12ではsite.html.sampleが自動生成される {{{ }}} * site.htmlを空のファイル(0byte)にするとエラーになる {{{ TemplateSyntaxError: no element found: line 1, column 0 (/path/to/global/trac/templates/site.html, line 1) }}} === 例 === #examples * site.html {{{ ${select('*|comment()|text()')} }}} * => diff of wiki:WikiStart {{{#!diff @@ -3,6 +3,8 @@ + + @@ -30,6 +32,7 @@ $(".foldable").enableFolding(true, true); }); </script> + <link rel="stylesheet" type="text/css" href="/trac/testenv/chrome/site/style.css" /> </head> <body> <div id="banner"> }}} === CSSの追加 === #addCSS * [http://discypus.jp/wiki/?%A5%BD%A5%D5%A5%C8%2FBug%20Tracking%2Ftrac%2F%A5%E1%A5%E2#css ソフト/Bug Tracking/trac/メモ - discypus] * 0.12では /path/to/trac/ENV_NAME/htdocs/ の共有ディレクトリ(trac.iniにおける[inherit] templates_dirなどで指定できるディレクトリと同等の意味を持つもの)版が設定できない * => templates/site.htmlで「href="/static/htdocs/custom.css"」などと指定して、Apache側でAliasすることで回避 * 設定例 * site.html => source:/lab.git/TipAndDoc/trac/site.html * Alias /static/htdocs /var/www/htdocs * custom.css => source:/lab.git/TipAndDoc/trac/custom.css