Feeds.App - Movable Type のテンプレートにsyndicationフィードを導入する為のプラグイン.
Version 2.0
Feeds.App は Movable Type 3.0D 以上ならびに以下のモジュールが必要です:
すべてのモジュールはCPANより取得できます。
[1] 注: まだCPANでは発表されていないバグがClass::XPath manpage にあるので、モジュールの横に記載されたバージョンを守ってください. 詳しくはCAVEATS AND KNOWN BUGS で。
lib -> mt/extlib plugins -> mt/plugins contents ->mt/tmpl docs -> path/of/mt/docs
MTディレクトリ内にあるフォルダと置き換えないでください。これらのフォルダにはシステムや他のプラグインに必要なファイルが含まれています
755とはすべてのユーザーに読み込み・実行権限があり、オーナーにのみ書き込み権限が与えられることを意味する。
Unixのshellでパーミッションを設定している場合、以下のコマンドで設定ができる。
$ chmod 755 *.cgi agent
もしサーバーにスクリプトの実行をスケジュールできる権限があるのであれば、Feeds.Appのagentを定期的に実行しキャッシュの情報を最新のものに更新することをオススメします。
例えば、もしcronに書き込む権限があるのであれば以下の処理をUnixのシェルで行います。
$ crontab -e
これで今までに書かれたcronが開かれます。(最初の場合は白紙の状態です)mysubs.txtを30分ごとにagentを使って更新するには以下の行を書き足して保存します。
*/30 * * * * /path/to/mt/plugins/feed/agent --blog_id=2 --tmpl="Feeds" path/to/data/mysubs.txt
mysubs.txt はリスト(1つの行につき1つのsyndivation feed URL)として扱われます。feedをチェックしキャッシュを更新した後、agentはブログのidが2で名前がFeedsのインデックス・テンプレートを再構築します。
以下はテンプレートのIDとCSVフォーマットのリストを使ったagentスクリプトの例です
/path/to/mt/plugins/feed/agent --tmpl_id=40 -c path/to/data/mysubs.csv
agentは他にも以下のコマンドを指定してあげることができます
--help -? ヘルプ --version スクリプトのバージョン モード --silent -s ステータスメッセージを表示しない --quiet -q 最小限のステータスメッセージ (デフォルト) --verbose -v 詳細なステータスメッセージ、並びにトレースレポート タイプ --list -l リスト化されたコレクション --opml -o OPMLのコレクション --csv -c CSVのコレクション --type A argument for stating type by key --tmpl_id キャッシュ更新後に再構築するテンプレートID --tmpl キャッシュ更新後に再構築するテンプレートの名前 --blog_id テンプレートが属するブログのID
ファイルを保存、終了してください。agentはバックグラウンドで30分おきに実行されます。
以下のMTタグがh3タグで囲まれたfeedのタイトル、そしてエントリーのタイトルとリンクが順不同で生成される。
<$MTFeedsInclude uri=``http://www.timaoutloud.org/xml/index.rdf'' lastn=``5''$>
そう、たったこれだけ。このタグ与えられたパラメーターと共に以下のタグを生成、再構築される。
<MTFeeds uri="http://www.timaoutloud.org/xml/index.rdf"> <h3><$MTFeedTitle$></h3> <ul><MTFeedEntries lastn="5"> <li><a href="<$MTFeedEntryLink$>"><$MTFeedEntryTitle$></a></li> </MTFeedEntries></ul> <$MTFeedVersionSlug$> </MTFeeds>
ここでmysubs.txtというsyndication feed のURLのリストを含んだファイルを作ったとして話を進める。
http://www.timaoutloud.org/xml/atom.xml http://www.movabletype.org/index.xml http://www.sixapart.com/log/index.rdf http://sixapart.com/corner/index.rdf http://www.sixapart.com/pronet/index.rdf
これらのサイトから最新の記事五つを表示するには以下のタグを書き込む。
<$MTFeedsInclude collection=``mysubs.txt'' lastn=``5''$>
このタグが以下のレイアウトで再構築される。
<MTFeeds collection="mysubs.txt" type="list"> <h3><$MTFeedTitle$></h3> <ul><MTFeedEntries lastn="5"> <li><a href="<$MTFeedEntryLink$>"><$MTFeedEntryTitle$></a></li> </MTFeedEntries></ul> <$MTFeedVersionSlug$> </MTFeeds>
注:type="list"はパラメータで設定されてなければデフォルトでつく。typeで使用可能なパラメーターは"opml"や"csv"である。詳しくはテンプレートタグのドキュメントを参照。
ここではfeedのタイトルをh3タグで囲み、mysubs.txtに含まれる各feedのエントリーのタイトルとリンクが5つ順不同で生成される。
Syndication feedsの更新速度は各サイトによって違う。もし自分のサイトですべてのサイトにおいて最新記事を表示させたいのであれば先ほどの記述ではうまくいかない。以下のパラメーターを渡してやることでこれが可能となる。
<$MTFeedsIncludeLatest collection=``mysubs.txt'' lastn=``25'' title=``Latest Posts''$>
この記述が以下のテンプレートを生成する。
<MTFeedsLatest collection="mysubs.txt" type="list"> <h3>Latest Posts</h3> <ul><MTFeedEntries lastn="25"> <li><a href="<$MTFeedEntryLink$>"><$MTFeedEntryTitle$></a> (<$MTFeedEntrySourceName$>)</li> </MTFeedEntries></ul> </MTFeedsLatest>
ここでは静的なタイトル”Latest Posts"を表示し、mysubs.txtに含まれるリストから25の最新記事を一つの順不同のリストにして生成する。この時、ソースのfeedのタイトルがカッコに囲まれてエントリーのタイトルの横に表示される。
以上は基本的な使い方を記したもので、このプラグインでは更なるオプションが用意されている。プラグインタグのドキュメントを読んで他のオプションを参照してください。
Feeds.Appで以下のテンプレートタグが使えます。
uri又はcollectionは指定されてなければならない。
一つのfeedを使うときuriでfeedの場所を指定する。サポートされているプロトコルはhttp://、https:// と file://である。
複数のfeedを使うときはcollectionでリストを含むファイルのパス(ブログのディレクトリがroot)を指定する。typeは指定しなくともよい。typeでcollectionのソースのタイプを指定できる。
list type readerは各行にURIを含むplain text fileを処理する。これがtypeが指定されなかった場合のデフォルトの動作である。
The opml type reader uses an XML parser to find all <outline> tags and extracts URIs from either the xmlUrl or xmlurl attributes. Outline tags with either of these are skipped.
The csv type reader will process a plain text file of comma seperated values extracting URIs.The first row in these files are assumed to be field names. Links are extracted from the 'link' or 'url' field in each row.
The collection argument is the path of a file relative to the blogs root directory.
The type argument is optional and specifies the collection source type. The default is 'list'.
Using the optional argument of type will only return content if a description/abstract is available with the specified MIME type.
The optional format argument can be used to format the timestamp using the same specifiers as other MT timestamp tags such as MTDate. The default is W3C Date Time Format (W3CDTF aka ISO 8601) using UTC (Coordinated Universal Time).
MTEntries
this tag supports
optional arguments of limit and offset to control the
number entries and starting point to be insert. Entries are
sorted in reverse chronological order.
Using the optional argument of type will only return content if a description/abstract is available with the specified MIME type.
Due to the varying nature of RSS format feeds this may not return what you expect. This tag will only return content if a description tag exists in the syndication feed along with a ``full content'' tag such as a XHTML body or content:encoded tagset.
Using the optional argument of type will only return content if it matches the specified MIME type.
The optional format argument can be used to format the timestamp using the same specifiers as other MT timestamp tags such as MTDate. The default is W3C Date Time Format (W3CDTF aka ISO 8601) using UTC (Coordinated Universal Time).
The optional format argument can be used to format the timestamp using the same specifiers as other MT timestamp tags such as MTDate. The default is W3C Date Time Format (W3CDTF aka ISO 8601) using UTC (Coordinated Universal Time).
The optional format argument can be used to format the timestamp using the same specifiers as other MT timestamp tags such as MTDate. The default is W3C Date Time Format (W3CDTF aka ISO 8601) using UTC (Coordinated Universal Time).
The required name argument is the plugin tag (sans the MTFeed prefix -- MTFeedLink is 'Link' and so on) whose content will be tested. If the associated tag has content the contents of MTFeedIf will be inserted. Otherwise it will be skipped unless the standard MTElse tagset is used to render a different result.
An optional argument of type can also be used to specify a specific MIME type for the condition. This is only useful when working with content tags such as MTFeedEntryContent and MTFeedEntryDescription.
The Feeds.App agent will use the standard MT configuration parameters of PingTimeout, PingProxy and PingNoProxy if they have been set.
If you are running mt in an environment that requires the use of a proxy server to connect outside of your network, these parameter must be set. Chances are you may have already set them if you are using outbound Trackbacks.
Users of Feeds.App are encouraged to join the Feeds.App-announce group at http://groups.yahoo.com/group/Feeds.App-announce/. This is a low-volume mailing list that will let you keep up with the latest news and releases of Feeds.App and related activites.
Technical support is not provided for the Beta Software. You may find the Feeds.App-discuss user-to-user mailing list and archive at http://groups.yahoo.com/group/Feeds.App-discuss/ helpful in addressing any issues.
Class::XPath 1.4 chokes on feeds that use \ in their identifier string which is most a URI uses this character. A patch has been submitted to the author of the module, but it has not been posted for some time. In the meanwhile, I am including my patched version 1.41.
There is a known bug effecting MT 3.0D using SQLite. It was fixed by SixApart with the release of 3.1.
Atom feeds using relative links are not supported yet.
Error handling needs to be refined through out. For instance
MT::CacheMgr-
expire()> does not pass success or failure
indicator back.
Using the optional argument of type will only return content if a description/abstract is available with the specified MIME type.
See FEEDS-APP-LICENSE included in the Feeds.App distribution.
This code cannot be redistributed without permission from
the author. Except where otherwise noted, Feeds.App is
Copyright 2002-2005, Timothy Appnel, Appnel Internet
Solutions, tim@appnel.com. All rights reserved.
翻訳:春口陽寿