« Oct 2003 | Nov 2003 | Dec 2003 »

November 29, 2003

mt-isbn.pl

エントリーに記述した ISBN コードから bk1, jbook, amazon などのサイトにリンクを張る MovableType のプラグイン mt-isbn.pl を作ってみました。

MTISBN 用の Bookmarklet については こちら

このサイトでは mt-bk1.pl と併用して、EntryBody で mt-isbn、EntryMore(追記記事部分)で mt-bk1 を使って画像付書籍を表示するようにしています。

 <$MTEntryBody isbn="1"$>
 <$MTEntryMore bk1="1"$>

■その他の書籍・商品掲載プラグイン

今のところ把握しているものです。他にもお勧めのがあれば教えて下さい。

  • aws.pl
    amazon の商品情報を掲載するためのプラグイン。
  • mt-bk1.pl
    bk1 の書籍情報を掲載するためのプラグイン。
  • Alternate MTAmazon
    MTAmazon に locale 対応を施したプラグイン。
  • Alternate mt-isbn.pl
    mt-isbin.pl に amazon の画像ファイルやタイトルなどを取得できるように拡張したプラグイン。(Net::Amazon が必要です)

■追記 2004/08/02
mt-bk1.pl の blosxom 版もあるようです。
http://cwww.pos.to/whatsnew/blosxom.cgi/blosxom/bk1.htm

November 28, 2003

mt-mostvisited.pl

トップページの右側に人気の記事(TOP10)を表示させてみました。
いい感じです。

■ 必要なものを入手

mt-mostvisited.pl (v1.3)
http://mt-plugins.org/archives/entry/mostvisited.php

Apache::ParseLog (v1.02)
http://search.cpan.org/~akira/Apache-ParseLog-1.02/ParseLog.pm

■ インストール参考ページ

MostVisited 作者のページ
MTで人気記事ランキングを作る
MT Pluginあれこれ - MTMostVisited -

■ Apache::ParseLog 追加

$MT/extlib/Apache 以下に ParseLog.pm を置く。

■ mt-mostvisited.pl の設定

my $logdir = "/path/to/home/log";
my $root = "/weblog/archives";
my $filetype = "html";
my @searchfiles = ("$logdir/httpd-access.log",
                "$logdir/httpd-access.log.1",
                "$logdir/httpd-access.log.2",
                "$logdir/httpd-access.log.3",
                "$logdir/httpd-access.log.4",
                "$logdir/httpd-access.log.5",
                "$logdir/httpd-access.log.6",
                "$logdir/httpd-access.log.7");

MT を DBM で使っている場合は

Error in MTMostVisited, while loading EntryID "XXXXXX": This does not appear to be a valid EntryID. It should be all numbers.

のようなエラーが出るようので以下の修正を加える。

--- mt-mostvisited.pl.orig
+++ mt-mostvisited.pl
@@ -128,7 +128,7 @@
 
     #ASSUMPTION:  The name of the page is the same as the entry_id.
 
-    my $entry = MT::Entry->load($entryid);
+    my $entry = MT::Entry->load(int $entryid);
     #TODO: Need filtering to ensure that it is actually an entry for the current
     #      blog, but that doesn't seem too critical as different blogs probably
     #      have different filepaths

■ プラグイン追加

$MT/plugins 以下に mt-mostvisited.pl を置く。

■ テンプレートの編集

ランキング表示用の新しいテンプレートを管理室の「Template の編集」で作成します。

今回は

Template の名前: Popular Ranking
出力ファイル名: ranking.html
「Index Template を Rebuild するときに自動的にこの Template を Rebuild する」のチェックを外す。

で作りました。

テンプレートの内容は
----
<div class="sidetitle">
Popular Entries
</div>

<div class="side">
<MTMostVisited count="10">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a> (<$MTMostVisitedCount$> hits)<br />
</MTMostVisited>
&gt; <$MTDate format="%Y/%m/%d %H:%M"$>
</div>
----
こんな感じ。

■ Main Index の編集

トップページは SSI を使っているので、Main Index のテンプレートで取り込みたい箇所に

<!--#include file="ranking.html"-->

を追加して Main Index をビルドする。

■ cron の設定

0 */1 * * * /path/to/mt-rebuild.pl -mode=index -blog_id=2 -template="Popular Ranking"

November 23, 2003

CTK-0.04

symlink を使ったロック CTK::Lock を追加。
http://www.asmate.net/software/perl/CTK/

« Oct 2003 | Nov 2003 | Dec 2003 »

Since 2003.6.19, Yutaka@smate.NET <yutaka@asmate.net>. Powered by MT 2.64