記事本文
コメントやトラックバックの情報を配信する Feed
Feed の中に、作成者以外が書いた文章を混ぜるということという記事で、コミュニケーションを補助する機能を Feed に構築する考え方について触れましたので、それを実際に実践するテンプレートの雛形を公開しようと思います。 なお、コメントやトラックバックという、自分以外の人が書いた情報を配信することになりますので、事前に告知する文章をコメント欄やトラックバック欄の近くに書いておいた方が良いでしょう。
基本的にインデックス・テンプレートを新規作成する画面を呼び出して、そのままコピー & ペーストするだけで良いのですが、出力ファイル名の指定に気を付ける必要があったりプラグインの導入が必要だったりするものもありますのでご注意ください。 また、 Movable Type 3.2-ja-2 を想定したテンプレートになっています。 なお、生成サンプルはこの場限りの生成ですので、今後最新のコメントやトラックバックは反映されません。 Feed として講読したい場合は http://feeds.feedburner.jp/hxxk_comment および http://feeds.feedburner.jp/hxxk_trackback をご利用ください。
Movable Type のデフォルトの Atom Feed テンプレートに、 id が恒久性を持たないような指定がされている件の修正を、こちらのテンプレートに反映させていませんでした。
2007 年 1 月 11 日以前にコメントの投稿状況を配信する Atom テンプレートおよびトラックバックの受信状況を配信する Atom テンプレートのソースを参考にされた方は、
<$MTDate format="%Y"$>
を
<MTArchiveList archive_type="Monthly" sort_order="ascend" lastn="1"><$MTArchiveDate format="%Y"$></MTArchiveList>
に置き換えてください。
コメントの投稿状況を配信する RSS 1.0 テンプレート
- 生成サンプルは hxxk.jp のコメントの投稿状況 ( RSS 1.0 ) をご覧ください。
- コメント文にマルチバイト文字と 1 バイト文字が混在した場合に、 trim_to による文字列トリミングがうまくいかない場合がありますので、気になる場合は SG::Acme : マルチバイトな文字列を切り詰めるなどの方法による対処をする必要があります。
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:cc="http://web.resource.org/cc/"
xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="<$MTBlogURL$>">
<title>Comment of <$MTBlogName remove_html="1" encode_xml="1"$></title>
<link><$MTBlogURL$></link>
<description><$MTBlogName remove_html="1" encode_xml="1"$> に寄せられたコメント</description>
<dc:language><$MTDefaultLanguage$></dc:language>
<dc:creator><MTEntries lastn="1"><$MTEntryAuthor encode_xml="1"$></MTEntries></dc:creator>
<dc:date><MTComments lastn="1"><MTCommentEntry><$MTEntryDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></MTCommentEntry></MTComments></dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=<$MTVersion$>" />
<MTBlogIfCCLicense>
<cc:license rdf:resource="<$MTBlogCCLicenseURL$>" />
</MTBlogIfCCLicense>
<items>
<rdf:Seq>
<MTComments lastn="15" sort_order="descend">
<MTCommentEntry><rdf:li rdf:resource="<$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$>" /></MTCommentEntry>
</MTComments>
</rdf:Seq>
</items>
</channel>
<MTComments lastn="15" sort_order="descend">
<MTCommentEntry>
<item rdf:about="<$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$>">
<title>"<$MTEntryTitle remove_html="1" encode_xml="1"$>"への<$MTCommentAuthor default="Anonymous" encode_xml="1"$>さんのコメント</title>
<link><$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$></link>
<description><$MTCommentBody encode_xml="1" convert_breaks="0" trim_to="30"$>...</description>
<content:encoded>
<$MTCommentBody remove_html="1" encode_xml="1" convert_breaks="0"$>
<MTEntryIfCommentsOpen>
<![CDATA[<a href="<$MTEntryPermalink encode_xml="1"$>#comments-open">"<$MTEntryTitle remove_html="1" encode_html="1"$>"へコメントを投稿する</a>]]>
</MTEntryIfCommentsOpen>
</content:encoded>
<dc:creator><$MTCommentAuthor default="Anonymous" encode_xml="1"$></dc:creator>
<dc:date><$MTCommentDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></dc:date>
<dc:source><$MTEntryPermalink encode_xml="1"$></dc:source>
</item>
</MTCommentEntry>
</MTComments>
</rdf:RDF>
コメントの投稿状況を配信する RSS 2.0 テンプレート
- 生成サンプルは hxxk.jp のコメントの投稿状況 ( RSS 2.0 ) をご覧ください。
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rss version="2.0">
<channel>
<title>Comment of <$MTBlogName remove_html="1" encode_xml="1"$></title>
<link><$MTBlogURL$></link>
<description><$MTBlogName remove_html="1" encode_xml="1"$> に寄せられたコメント</description>
<language><$MTBlogLanguage ietf="1"$></language>
<copyright>Copyright <$MTDate format="%Y"$></copyright>
<lastBuildDate><MTComments lastn="1"><MTCommentEntry><$MTEntryDate format_name="rfc822"$></MTCommentEntry></MTComments></lastBuildDate>
<generator>http://www.sixapart.com/movabletype/?v=<$MTVersion$></generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<MTComments lastn="15" sort_order="descend">
<MTCommentEntry>
<item>
<title>"<$MTEntryTitle remove_html="1" encode_xml="1"$>"への<$MTCommentAuthor default="Anonymous" encode_xml="1"$>さんのコメント</title>
<description>
<$MTCommentBody remove_html="1" encode_xml="1" convert_breaks="0"$>
<MTEntryIfCommentsOpen>
<![CDATA[<a href="<$MTEntryPermalink encode_xml="1"$>#comments-open">"<$MTEntryTitle remove_html="1" encode_html="1"$>"へコメントを投稿する</a>]]>
</MTEntryIfCommentsOpen>
</description>
<link><$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$></link>
<guid><$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$></guid>
<pubDate><$MTCommentDate format_name="rfc822"$></pubDate>
</item>
</MTCommentEntry>
</MTComments>
</channel>
</rss>
コメントの投稿状況を配信する Atom テンプレート
- 生成サンプルは hxxk.jp のコメントの投稿状況 ( Atom ) をご覧ください。
- コメント文にマルチバイト文字と 1 バイト文字が混在した場合に、 trim_to による文字列トリミングがうまくいかない場合がありますので、気になる場合は SG::Acme : マルチバイトな文字列を切り詰めるなどの方法による対処をする必要があります。
- 出力ファイル名を comment_atom.xml 以外にする場合は、
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>comment_atom.xml" />部分を合わせて変更する必要があります。
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Comment of <$MTBlogName remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>comment_atom.xml" />
<id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<MTArchiveList archive_type="Monthly" sort_order="ascend" lastn="1"><$MTArchiveDate format="%Y"$></MTArchiveList>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
<updated><MTComments lastn="1"><MTCommentEntry><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTCommentEntry></MTComments></updated>
<subtitle><$MTBlogName remove_html="1" encode_xml="1"$> に寄せられたコメント</subtitle>
<generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>
<MTComments lastn="15" sort_order="descend">
<MTCommentEntry>
<entry>
<title>"<$MTEntryTitle remove_html="1" encode_xml="1"$>"への<$MTCommentAuthor default="Anonymous" encode_xml="1"$>さんのコメント</title>
<dc:source><$MTEntryPermalink encode_xml="1"$></dc:source>
<link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>#comment-<$MTCommentID$>" />
<id><$MTEntryAtomID$><$MTCommentID$></id>
<published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
<updated><$MTCommentDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
<summary><$MTCommentBody remove_html="1" encode_xml="1" convert_breaks="0" trim_to="30"$>...</summary>
<author>
<name><$MTCommentAuthor default="Anonymous" encode_xml="1"$></name>
<MTIfNonEmpty tag="MTCommentURL"><uri><$MTCommentURL encode_xml="1"$></uri></MTIfNonEmpty>
</author>
<content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
<$MTCommentBody remove_html="1" encode_xml="1" convert_breaks="0"$>
<MTEntryIfCommentsOpen>
<![CDATA[<a href="<$MTEntryPermalink encode_xml="1"$>#comments-open">"<$MTEntryTitle remove_html="1" encode_html="1"$>"へコメントを投稿する</a>]]>
</MTEntryIfCommentsOpen>
</content>
</entry>
</MTCommentEntry>
</MTComments>
</feed>
トラックバックの受信状況を配信する RSS 1.0 テンプレート
- 生成サンプルは hxxk.jp のトラックバックの受信状況 ( RSS 1.0 ) をご覧ください。
- hirata's techknow MT: つづきを書く前に... で紹介されている PingEntry.pl というプラグインの導入が必要です。
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:cc="http://web.resource.org/cc/"
xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="<$MTBlogURL$>">
<title>Trackback of <$MTBlogName remove_html="1" encode_xml="1"$></title>
<link><$MTBlogURL$></link>
<description><$MTBlogName remove_html="1" encode_xml="1"$> に寄せられたトラックバック</description>
<dc:language><$MTDefaultLanguage$></dc:language>
<dc:creator><MTEntries lastn="1"><$MTEntryAuthor encode_xml="1"$></MTEntries></dc:creator>
<dc:date><MTPings lastn="1"><MTPingEntry><$MTEntryDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></MTPingEntry></MTPings></dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=<$MTVersion$>" />
<MTBlogIfCCLicense>
<cc:license rdf:resource="<$MTBlogCCLicenseURL$>" />
</MTBlogIfCCLicense>
<items>
<rdf:Seq>
<MTPings lastn="15" sort_order="descend">
<MTPingEntry><rdf:li rdf:resource="<$MTPingURL$>" /></MTPingEntry>
</MTPings>
</rdf:Seq>
</items>
</channel>
<MTPings lastn="15" sort_order="descend">
<MTPingEntry>
<item rdf:about="<$MTPingURL$>">
<title>"<$MTEntryTitle remove_html="1" encode_xml="1"$>"への"<$MTPingBlogName encode_xml="1"$>"からのトラックバック</title>
<link><$MTPingURL$></link>
<description><$MTPingExcerpt encode_xml="1" convert_breaks="0"$></description>
<content:encoded>
<$MTPingExcerpt remove_html="1" encode_xml="1" convert_breaks="0"$>
<MTIfPingsAccepted>
"<$MTEntryTitle remove_html="1" encode_html="1"$>"のトラックバック URL : <$MTEntryTrackbackLink$>
</MTIfPingsAccepted>
</content:encoded>
<dc:creator><$MTPingBlogName encode_xml="1"$></dc:creator>
<dc:date><$MTPingDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></dc:date>
<dc:source><$MTEntryPermalink encode_xml="1"$></dc:source>
</item>
</MTPingEntry>
</MTPings>
</rdf:RDF>
トラックバックの受信状況を配信する RSS 2.0 テンプレート
- 生成サンプルは hxxk.jp のトラックバックの受信状況 ( RSS 2.0 ) をご覧ください。
- hirata's techknow MT: つづきを書く前に... で紹介されている PingEntry.pl というプラグインの導入が必要です。
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rss version="2.0">
<channel>
<title>Trackback of <$MTBlogName remove_html="1" encode_xml="1"$></title>
<link><$MTBlogURL$></link>
<description><$MTBlogName remove_html="1" encode_xml="1"$> に寄せられたトラックバック</description>
<language><$MTBlogLanguage ietf="1"$></language>
<copyright>Copyright <$MTDate format="%Y"$></copyright>
<lastBuildDate><MTPings lastn="1"><MTPingEntry><$MTEntryDate format_name="rfc822"$></MTPingEntry></MTPings></lastBuildDate>
<generator>http://www.sixapart.com/movabletype/?v=<$MTVersion$></generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<MTPings lastn="15" sort_order="descend">
<MTPingEntry>
<item>
<title>"<$MTEntryTitle remove_html="1" encode_xml="1"$>"への"<$MTPingBlogName encode_xml="1"$>"からのトラックバック</title>
<description>
<$MTPingExcerpt remove_html="1" encode_xml="1" convert_breaks="0"$>
<MTIfPingsAccepted>
"<$MTEntryTitle remove_html="1" encode_html="1"$>"のトラックバック URL : <$MTEntryTrackbackLink$>
</MTIfPingsAccepted>
</description>
<link><$MTPingURL$></link>
<guid><$MTPingURL$></guid>
<pubDate><$MTPingDate format_name="rfc822"$></pubDate>
</item>
</MTPingEntry>
</MTPings>
</channel>
</rss>
トラックバックの受信状況を配信する Atom テンプレート
- 生成サンプルは hxxk.jp のトラックバックの受信状況 ( Atom ) をご覧ください。
- hirata's techknow MT: つづきを書く前に... で紹介されている PingEntry.pl というプラグインの導入が必要です。
- 出力ファイル名を trackback_atom.xml 以外にする場合は、
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>trackback_atom.xml" />部分を合わせて変更する必要があります。
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Trackback of <$MTBlogName remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>trackback_atom.xml" />
<id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<MTArchiveList archive_type="Monthly" sort_order="ascend" lastn="1"><$MTArchiveDate format="%Y"$></MTArchiveList>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
<updated><MTPings lastn="1"><MTPingEntry><$MTPingDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTPingEntry></MTPings></updated>
<subtitle><$MTBlogName remove_html="1" encode_xml="1"$> に寄せられたトラックバック</subtitle>
<generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>
<MTPings lastn="15" sort_order="descend">
<MTPingEntry>
<entry>
<title>"<$MTEntryTitle remove_html="1" encode_html="1"$>"への"<$MTPingBlogName encode_xml="1"$>"からのトラックバック</title>
<dc:source><$MTEntryPermalink encode_xml="1"$></dc:source>
<link rel="alternate" type="text/html" href="<$MTPingURL$>" />
<id><$MTEntryAtomID$><$MTPingID$></id>
<published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
<updated><$MTPingDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
<summary><$MTPingExcerpt remove_html="1" encode_xml="1" convert_breaks="0"$></summary>
<author>
<name><$MTPingBlogName encode_xml="1"$></name>
<uri><$MTPingURL encode_xml="1"$></uri>
</author>
<content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
<$MTPingExcerpt remove_html="1" encode_xml="1" convert_breaks="0"$>
<MTIfPingsAccepted>
"<$MTEntryTitle remove_html="1" encode_html="1"$>"のトラックバック URL : <$MTEntryTrackbackLink$>
</MTIfPingsAccepted>
</content>
</entry>
</MTPingEntry>
</MTPings>
</feed>
応用
コメント・トラックバックの区別を無くしてひとつの Feed にしたい場合は、 Recent Reaction template ( with HotEntries ) で紹介している HotEntries.txt を使用し、 Recent Reaction template ( with HotEntries ) - テンプレートタグの解説を参考にカスタマイズしてみてください。
ヒントだけ書いておいたら、テンプレートを作ってくれた方がいました ! コメントもトラックバックもまとめた Feed を作りたい場合はまけないこと投げ: コメント・トラックバックの情報を収集・配信する Feed を参考に作ってみてください。

