コメントやトラックバックの情報を収集・配信する Feed のテンプレート

http://hxxk.jp/2006/04/23/0251

記事データ

投稿者

望月真琴

投稿日時

2006-04-23T02:51+09:00

タグ
概要

Movable Type 3.2-ja-2 で、コメントやトラックバックだけをチェックする Feed のテンプレートソースを一挙公開。

リプライ

4 件のリプライがあります。

記事本文

コメントやトラックバックの情報を配信する 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> に置き換えてください。

  1. コメントの投稿状況を配信する RSS 1.0 テンプレート
  2. コメントの投稿状況を配信する RSS 2.0 テンプレート
  3. コメントの投稿状況を配信する Atom テンプレート
  4. トラックバックの受信状況を配信する RSS 1.0 テンプレート
  5. トラックバックの受信状況を配信する RSS 2.0 テンプレート
  6. トラックバックの受信状況を配信する Atom テンプレート
  7. 応用

コメントの投稿状況を配信する RSS 1.0 テンプレート

<?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>&#34;<$MTEntryTitle remove_html="1" encode_xml="1"$>&#34;への<$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">&#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;へコメントを投稿する</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 テンプレート

<?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>&#34;<$MTEntryTitle remove_html="1" encode_xml="1"$>&#34;への<$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">&#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;へコメントを投稿する</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 テンプレート

<?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>&#34;<$MTEntryTitle remove_html="1" encode_xml="1"$>&#34;への<$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">&#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;へコメントを投稿する</a>]]>
          </MTEntryIfCommentsOpen>
        </content>
      </entry>
    </MTCommentEntry>
  </MTComments>
</feed>

トラックバックの受信状況を配信する RSS 1.0 テンプレート

<?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>&#34;<$MTEntryTitle remove_html="1" encode_xml="1"$>&#34;への&#34;<$MTPingBlogName encode_xml="1"$>&#34;からのトラックバック</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>
            &#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;のトラックバック 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 テンプレート

<?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>&#34;<$MTEntryTitle remove_html="1" encode_xml="1"$>&#34;への&#34;<$MTPingBlogName encode_xml="1"$>&#34;からのトラックバック</title>
          <description>
            <$MTPingExcerpt remove_html="1" encode_xml="1" convert_breaks="0"$>
            <MTIfPingsAccepted>
              &#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;のトラックバック URL : <$MTEntryTrackbackLink$>
            </MTIfPingsAccepted>
          </description>
          <link><$MTPingURL$></link>
          <guid><$MTPingURL$></guid>
          <pubDate><$MTPingDate format_name="rfc822"$></pubDate>
        </item>
      </MTPingEntry>
    </MTPings>
   </channel>
</rss>

トラックバックの受信状況を配信する Atom テンプレート

<?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>&#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;への&#34;<$MTPingBlogName encode_xml="1"$>&#34;からのトラックバック</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>
            &#34;<$MTEntryTitle remove_html="1" encode_html="1"$>&#34;のトラックバック URL : <$MTEntryTrackbackLink$>
          </MTIfPingsAccepted>
        </content>
      </entry>
    </MTPingEntry>
  </MTPings>
</feed>

応用

コメント・トラックバックの区別を無くしてひとつの Feed にしたい場合は、 Recent Reaction template ( with HotEntries ) で紹介している HotEntries.txt を使用し、 Recent Reaction template ( with HotEntries ) - テンプレートタグの解説を参考にカスタマイズしてみてください。

ヒントだけ書いておいたら、テンプレートを作ってくれた方がいました ! コメントもトラックバックもまとめた Feed を作りたい場合はまけないこと投げ: コメント・トラックバックの情報を収集・配信する Feed を参考に作ってみてください。

リプライ

4 件のリプライが送られています。

2006-04-28T19:47+09:00 - コメント・トラックバックの情報を収集・配信する Feed < まけないこと投げ

【真琴によるトラックバック】 コメント・トラックバックの区別を無くしてひとつの RSS 2.0 Feed にするテンプレート。

2006-09-18T14:16+09:00 - Nob Seki

こんにちは。 Atomのsummaryの中身で、trim_toを使われていますが、この場合は、remove_htmlも併用された方がいいのではないでしょうか。うちでは、HTMLタグが利用可能のため、タグが閉じられる前にtrim_toが効いてしまって、出力がおかしくなることがありました。

2006-10-02T20:31+09:00 - 真琴

確かに、 remove_html もあった方がいいですね。私のところは HTML タグを使用不可にしていたので失念していました。 MT 3.3 ではコメントやトラックバックの Feed はシステム側で提供されているので、これを使われる方はあまり多くないかもしれませんが。 ところで、関取締役がこのテンプレートについてコメントを書かれているということは、実際に適用をされてみたってことでしょうか…… 不完全なものを公開してしまってすみません。

2006-10-02T20:38+09:00 - 真琴

ということで、テンプレートのコードに remove_html を書き加えました。このテンプレートを使われている方がいらっしゃいましたら、 MTCommentBody および MTPingExcerpt の部分に同様に書き加えるか、新しいコードを用いるようにしてください。

この記事に対するご意見やご質問、ご感想などありましたらこのフォームに簡潔に記入して下さい。 簡潔に記入できない場合や、関連記事にてご意見をお寄せいただく場合は、ご自身の weblog にて記事を書かれた上で あてにトラックバックとして送信してください。

記入フォーム

補足情報

著作、講演、制作実績など