Tracのデザインって古臭いというか、ダサいというか、まぁイケてないんですよ。
Trac1.0になって変わるかと思ったら、shadow使いまくりでとても見難かったので、
もうテーマを作りしかないと思い立って、Twitter Bootstarpベースで作りました。
Blogに上げようかと思ったんですが、ファイル数が多いのと今ならGithubだろうと思い、
公開リポジトリとしては初めて上げてみました(Gistはメモ帳代わりに使ってたんですがね)
Twitter Bootstrapから取ってきたファイルは、そちらのリポジトリにリンクしたかったんですが、やりかたが分からなかったので、暫定的に一緒にコミットしてしまっています(あとで直します)
Githubにも書いてありますが、基本的にTrac本体に上書きして使います。
# git clone https://github.com/14kw/twitter-bootstrap-trac-theme.git # wget http://download.edgewall.org/trac/Trac-1.0.1.tar.gz # tar xvfz Trac-1.0.1.tar.gz # cd Trac-1.0.1 # cp ../twitter-bootstrap-trac-theme/trac_src/Trac-1.0.1/trac/* ./trac/ # easy_install babel # python setup.py install
# cp ./twitter-bootstrap-trac-theme/trac_common /usr/share/trac # vi $TRAC_ROOT/conf/trac.ini [header_logo] src = /trac_common/trac_banner.png [inherit] file = /usr/share/trac/conf/trac.ini [project] icon = /trac_common/trac.ico [trac] htdocs_location = /trac_common # vi $APACHE_ROOT/conf/httpd.conf Alias /trac_common /usr/share/trac/htdocs
レポートの日本語化については、インタアクト株式会社が公開している、Trac-1.0.ja1を流用させてもらいました。
デフォルトのwikiも日本語化させたい方は、trac/wiki/default-pages 配下も上書きしてください。
Trac0.12用ならば、こちらのテーマがあるんですが、
せっかくなら最新のTrac1.0.1にしたいってのと、
いまいちデザインが気に入らなかったので。。
ヘッダー画像だけ、Trac本家の画像を拝借しました。
これシンプルな割にカッコいい!
ヘッダー画像をconfから変えられるプラグインとか余力があれば作りたいね♪
Tracのプラグインによって作成されるページはデザインが崩れることがあるので、
そのあたりの対応をチクチクやっていこうかなと。
プラグイン毎にパッチファイルを作成してclassとか付与させて、
patch.cssに追記していく感じになると思う。
フッター用のサイドバーの定義を新しく作成する。
# vi function.php
register_sidebar( array(
'name' => __( 'Another Footer Area One', 'twentyeleven' ),
'id' => 'sidebar-7',
'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Another Footer Area Two', 'twentyeleven' ),
'id' => 'sidebar-8',
'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Another Footer Area Three', 'twentyeleven' ),
'id' => 'sidebar-9',
'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
既存footerのファイルをコピーして、新しく作るフッターの設定を記述する。
# cp -a footer.php footer-another.php
# vi footer-another.php
get_sidebar( 'another-footer' );
# cp -a sidebar-footer.php sidebar-another-footer.php
# vi sidebar-another-footer.php
# diff sidebar-footer.php sidebar-another-footer.php
17,19c17,19
< if ( ! is_active_sidebar( 'sidebar-3' )
< && ! is_active_sidebar( 'sidebar-4' )
< && ! is_active_sidebar( 'sidebar-5' )
---
> if ( ! is_active_sidebar( 'sidebar-7' )
> && ! is_active_sidebar( 'sidebar-8' )
> && ! is_active_sidebar( 'sidebar-9' )
25c25
< <?php if ( is_active_sidebar( 'sidebar-3' ) ) : ?>
---
> <?php if ( is_active_sidebar( 'sidebar-7' ) ) : ?>
27c27
< <?php dynamic_sidebar( 'sidebar-3' ); ?>
---
> <?php dynamic_sidebar( 'sidebar-7' ); ?>
31c31
< <?php if ( is_active_sidebar( 'sidebar-4' ) ) : ?>
---
> <?php if ( is_active_sidebar( 'sidebar-8' ) ) : ?>
33c33
< <?php dynamic_sidebar( 'sidebar-4' ); ?>
---
> <?php dynamic_sidebar( 'sidebar-8' ); ?>
37c37
< <?php if ( is_active_sidebar( 'sidebar-5' ) ) : ?>
---
> <?php if ( is_active_sidebar( 'sidebar-9' ) ) : ?>
39c39
< <?php dynamic_sidebar( 'sidebar-5' ); ?>
---
> <?php dynamic_sidebar( 'sidebar-9' ); ?>
# vi sidebar-another-page.php
<?php get_footer('another'); ?>
なんか余分な設定入っているかもだけど、これで問題ないと思う。
「外観 > ウィジェット」でサイドバーが出ていて、
footer-another.phpで指定したように新しいフッターが設定されているはず。
新しく作るサイドバーの定義を追加。
# vi function.php
register_sidebar( array(
'name' => __( 'Another Sidebar', 'twentyeleven' ),
'id' => 'sidebar-6',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) && ! is_page_template( 'sidebar-another-page.php' ))
既存サイドバーをコピーして、新規サイドバーの設定に変更する。
# cp -a sidebar.php sidebar-another.php
# vi sidebar-another.php
<?php if ( ! dynamic_sidebar( 'sidebar-6' ) ) : ?>
# cp -a sidebar-page.php sidebar-another-page.php
* Template Name: Another Sidebar Template
<?php get_sidebar('another'); ?>
これでテンプレート一覧に「Another Sidebar Template」が出てくるから、
それを選べば新しく作ったサイドバーが適応される。
新しく作ったサイドバーは、「外観 > ウィジェット」に出てくるので、
好きな要素を入れれば完了っと。
Page-level → Session-level Page-level → Visitor-level
Page-levelでの集計はリセットされ、後から入れたものが集計される
Session-level → Visitor-level Visitor-level → Session-level
前の集計はリセットされ、後から入れたものが集計される
Session-level → Page-level Visitor-level → Page-level
セッションが切れるか、Cookieが消えるかしないとPage-levelとして集計できない
これが効かないとリンクを別タブで開けなくなるので結構困る。。。
ググってみると過去にも使えなくなったことがあるようで、ちょこちょこ出てくる。
最新版の修正方法が載っていたのでメモっておく。
#早くpull requestを受け入れてバージョンアップしてくれないかなー
.on('click.dropdown-menu', function (e) { e.stopPropagation() })
↓
.on('click.dropdown-menu', function (e) { if (!(e.altKey || e.metaKey || e.which==2 || e.ctrlKey)) e.stopPropagation() })
リンク先にあるとおり、bootstrap.jsを上記のように修正すれば、Firefoxでもctrl+clickが効くようになる。
新しいバージョンが出るまではしばらくこれで凌いでおこう。