2008年12月28日日曜日

CSSで要素を表示したり非表示にしたりする方法

CSSで要素を非表示にする方法をメモしておきます.

display プロパティに none を指定すると,要素は完全に表示されなくなります.

<span style="{display: none;}">要素</span>を非表示

visibility プロパティに hidden を指定すると,要素は表示されませんが,表示領域は確保されます.

<span style="{visibility: hidden;}">要素</span>を非表示

[1] スタイルシート CSS / ボックス / 表示・非表示を指定する
http://www.tagindex.com/stylesheet/box/visibility.html

Subversionにてリポジトリ内のディレクトリを削除する方法

Subversionにてリポジトリ内のディレクトリを削除する方法を以下にメモしておきます.

svn delete -m "コメント" 削除するディレクトリのURL

2008年12月26日金曜日

DojoでHTML要素をドラッグアンドドロップする方法

Dojoを使ってHTML要素をドラッグアンドドロップする方法をメモしておきます.

<script type="text/javascript">
dojo.require("dojo.dnd.Moveable");
dojo.addOnLoad(function() {
  var movable = new dojo.dnd.Moveable(dojo.byId("movable"));
});
</script>
  :
<div id="movable">...</div>
  :


[1] dojoライブラリでドラッグ&ドロップ!, http://kanamehackday.blog17.fc2.com/blog-entry-120.html

TracWebAdminプラグインのインストール

TracWebAdminプラグインをインストールしたので,その方法をメモしておきます.

# su
# yum install yum install trac-webadmin
# vi /var/www/trac/dokan/conf/trac.ini
--
[components]
webadmin.* = enabled
--
# trac-admin /var/www/trac/dokan permission add admin TRAC_ADMIN
# /sbin/service httpd restart


[1] Tracの使い方 - TracWebAdminインストール -
http://ameblo.jp/itboy/entry-10036436354.html

2008年12月20日土曜日

HTTPヘッダのAccept-Encodingフィールド

HTTPヘッダのAccept-Encodingフィールドについてメモしておきます.

Accept-Encodingフィールドは,クライアントが受け入れることのできるレスポンスボディのエンコード方式です.その値には,gzip,compress,identity,*等があります.詳しくは下記の資料に掲載されています.

リクエストヘッダにこのフィールドが記されていて,サーバにその値に対応する能力があれば,その値で指定された方式でレスポンスボディをエンコードします.

[Studying HTTP] Message Bogy 内容コーディング
http://www.studyinghttp.net/body#Content_Codings

2008年12月16日火曜日

TracGanttCalendarプラグインのインストール

TracGanttCalendarプラグイン(for Trac-0.10(trac-ja))をインストールしたので,その方法をメモしておきます.

$ wget http://pw.tech-arts.co.jp/technical/src/ganttcalendar-0.0.1.tar.gz
$ tar zxvf ganttcalendar-0.0.1.tar.gz
$ cd ganttcalendar-0.0.1
$ python setup.py bdist_egg
$ su
# chgrp apache /var/www
# chmod g+rwx /var/www
# cp dist/TracGanttCalendarPlugin-0.0.1-py2.4 /var/www/trac/dokan/plugins
# vi /var/www/trac/dokan/conf/trac.ini
--
[ticket-custom]
due_assign = text
due_assign.label = 開始日
due_assign.order = 1

due_close= text
due_close.label = 終了日
due_close.order = 2

complete= text
complete.label = 進捗率(%)
complete.order = 3
--
# /sbin/service httpd restart


注意点は以下のとおりです.
  • python-setuptools.noarch.rpmをインストールしておく必要あり.
  • /var/wwwディレクトリに.pyhton-eggsというディレクトリを作成するので,/var/wwwディレクトリにapacheが書込み権限を持っている必要あり.

[1] TracGanttCalendarプラグイン for Trac-0.10(trac-ja)
http://pw.tech-arts.co.jp/technical/2008/04/trac_tracganttcalendar_for_tra.html

2008年12月10日水曜日

WordPressのエントリへのpタグの自動挿入機能の解除方法

WordPressのエントリへのpタグの自動挿入機能を解除する方法をメモしておきます.

wp-includes/default-filters.phpの

add_filter('the_content', 'wpautop');

をコメントアウトするだけです.

[1] WordPressエントリ内の<P>タグを無効化
http://blog.sudabon.com/archives/30

2008年12月9日火曜日

Tracのインストール

Tracをインストールしました.その方法をメモしておきます.

yum install apache subversion trac mod_dav_svn mod_python mod_ssl
vi /etc/httpd/conf.d/subversion.conf
--
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

DAV svn
SVNParentPath /var/www/svn
# Limit write permission to list of valid users.

# Require SSL connection for password protection.
SSLRequireSSL
AuthType Basic
AuthName "Member Only"
AuthBasicProvider ldap
AuthLDAPURL ldap://xx.xx.xx.xx:389/xxxx
AuthLDAPBindDN cn=Manager,xxxx
AuthLDAPBindPassword xxxxxxxx
AuthzLDAPAuthoritative off
Require valid-user


--
vi /etc/httpd/conf.d/trac.conf
--

SetHandler mod_python
PythonDebug On
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/www/trac
PythonOption TracUriRoot /trac


SSLRequireSSL
AuthType Basic
AuthName "Member Only"
AuthBasicProvider ldap
AuthLDAPURL ldap://xx.xx.xx.xx:389/xxxx
AuthLDAPBindDN cn=Manager,xxxx
AuthLDAPBindPassword xxxx
AuthzLDAPAuthoritative off
Require valid-user

--
mkdir /var/www/svn
chown apache:apache /var/www/svn
mkdir /var/www/trac
chown apache:apache /var/www/trac
svnadmin create /var/svn/test_project
chown -R apache:apache /var/svn/test_project
trac-admin /var/trac/test_project initenv
chown -R apache:apache /var/trac/test_project

VelocityにてResourceNotFoundException

Velocityを使い始めたのですが,早々にResourceNotFoundExceptionという例外に遭遇してしまいました.ちょっと調べると解決できたので,その方法を以下にメモしておきます.

資料[1]を参考に以下のようなコードを書いて実行すると,テンプレートファイルが置かれた正しいパスをVelocity#getTemplateメソッドに指定しているにもかかわらず(ちなみにこれは自分の間違った解釈です),そのファイルがないことが原因でResourceNotFoundExceptionが発生し,プログラムが異常終了します.

Velocity.init();
VelocityContext context = new VelocityContext();
context.put("sensorName", sensor.getName());
Template template = Velocity.getTemplate(this.rootPath +"chart.vm", "UTF-8");
StringWriter writer = new StringWriter();
template.merge(context, writer);
buffer.append(writer.toString());


ライブラリに添付されていたドキュメントを読むと,Velocity#getTemplateメソッドの引数に指定するテンプレートファイルのパスは,Velocityのfile.resource.loader.pathというプロパティからの相対パスになるとのことでした.

そういうわけで,必要なプロパティ(file.resource.loader.path以外にもいくつかあります)をセットしたPropertiesクラスのインスタンスをVelocity#initに与えてやると,うまくテンプレートファイルを読み込むことができました.

Properties properties = new Properties();
properties.setProperty("resource.loader", "file");
properties.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
properties.setProperty("file.resource.loader.path", this.rootPath);
properties.setProperty("file.resource.loader.cache", "true");
properties.setProperty("file.resource.loader.modificationCheckInterval", "2");
Velocity.init(properties);
VelocityContext context = new VelocityContext();
context.put("sensorName", sensor.getName());
Template template = Velocity.getTemplate("/chart.vm", "UTF-8");
StringWriter writer = new StringWriter();
template.merge(context, writer);
buffer.append(writer.toString());


[1] Velocity
http://www.techscore.com/tech/ApacheJakarta/Velocity/index.html

2008年12月5日金曜日

Cygwinの日本語化

Cygwinの日本語化についてメモしておきます.

[lsの日本語表示]
~/.bashrc
alias ls='ls --show-control-chars'

[vimの日本語表示]
~/.vimrc
set encoding=japan
set fileencodings=iso-2002,utf-8,euc-jp,cp932


[日本語入力]
~/.inputrc
set convert-meta off
set meta-flag on
set output-meta on


[1] Cygwin/日本語化
http://co-coa.sakura.ne.jp/index.php?Cygwin%2F%E6%97%A5%E6%9C%AC%E8%AA%9E%E5%8C%96