TypePadJSONフィードの出力に対応したそうで。JSONフィードってーのはdel.icio.usJSON Feedsとかで見られる、JSONを利用したRSSやAtomっぽい配信フォーマットで、Pure JavaScriptで扱えるのが最大の特徴。特に仕様なんかは無い(と思う)。かなり昔にこのサイトで妄想として取り上げていたのが現実になった感じ。

というわけでblosxomindex.jsonというTypePadのJSONフィードに似せた感じの出力を確保する仕組みの実装する方法書いてみる。TypePadのテンプレートに準拠したいところだけどTypePadとかいうprefixがちょっとアレなアレでアレ。

flavourだけでJSONフィードを出力するのはちょっと難しい。W3CDTFで日付を出力とかでつまづいちゃうので、interpolate_fancyプラグインとテキトウな作りのrssプラグインが必要な感じ。でもまぁとりあえずは以下のような感じで比較的手軽に実装可能。ただこのままだとjsonFeeds.entriesの最後の要素の後ろにもカンマが付いちゃうのでInternet Explorerでエラーが起きる。このことへの対処や日本語をUnicodeのhexでエスケープするとかも含め、実際に利用する場合はjsonfeedなどといった専用プラグインを作った方が良さそう。

content_type.json

text/javascript

head.json

// This JSON Feed automatically generated by blosxom 2.0
// http://creativecommons.org/licenses/by-nc/2.1/jp/

if (typeof(jsonFeeds) == "undefined") jsonFeeds = new Array();

jsonFeeds["$url/index.json"] = {
  "title": "hail2u.net - $blog_title",
  "link": "$url/",
  "id": "tag:hail2u.net,2002:/blog/",
  "author": "$rss::name ($rss::email)",
  "updated": "$rss::last_build_date_w3cdtf",
  "subtitle": "$blog_description",
  "generator": "http://www.blosxom.com/?v=2.0",
  "entry": [

date.json

空のファイルを用意。

story.json

    {
  "title": "$title",
  "link": "$url$path/$fn.$default_flavour",
  "id": "tag:hail2u.net,$yr<?$yr>:</?>$path/$fn",
  "summary": "$rss::excerpt",
  "author": "$rss::name ($rss::email)",
  "category": "$categories::name",
  "published": "$yr-$mo_num-$da<?$yr>T</?>$ti<?$yr>:</?>00+09:00"
},

foot.json

  ]
};

次はJSONFP(JSON Feed with Padding)だな。