概要
TwitRender:Twitterログまとめ
関連記事:テンプレートを指定可能なTwitterログまとめサービス(TwitRender)を作ってみた - 風柳メモ
の、『テンプレートURL』で指定出来るテンプレートの仕様です。
とりあえず、
- 文字コード:UTF-8
- 埋めこみ可能なテンプレート・タグは{{変数名}}や{% 制御文 %}のような形式で、Django 0.96仕様に準拠
が基本です。
作成したら、Web上に公開し、『テンプレートURL』でそのURLを指定します。
テンプレート・タグに指定出来る変数名
テンプレート適用時に、以下の例のような構造体を渡しています。
statuslist=[ { // ステータス(status)ひとつ分 "id":9999999999, "permalink":"http://twitter.com/〜" // ★ "favorited":false, "text":"〜", "html":"〜", // ★ "created_at":"Tue Jul 7 13:02:02 +0000 2009", "jst":{ // ★ "year":2009, "month":7, "day":7, "hour":22, "minute":2, "second":2, "weekday": "火", "iso": "2009-07-07 22:02:02" } "source":"web", "in_reply_to_screen_name":null, "in_reply_to_status_id":null, "in_reply_to_user_id":null, "truncated":false, "user":{ "id":77777777, "screen_name":"〜", "profile_image_url":"http://〜.png", "name":"〜", "url":"http://〜", "description":"〜", "created_at":"〜", "statuses_count":1000, "followers_count":100, "friends_count":200, "favourites_count":2000, "profile_text_color":"000000", "profile_link_color":"0000ff", "profile_background_tile":false, "profile_background_color":"FFFFFF", "profile_background_image_url":"http://〜.gif", "profile_sidebar_fill_color":"eeffcc", "profile_sidebar_border_color":"88bb44", "protected":false, "following":true, "notifications":false, "verified":false, "time_zone":"Tokyo", "utc_offset":32400, "location":"〜", } }, : ]
内容的には、http://twitter.com/status/show/ステータスID.jsonから取得したものに、独自に★の要素を付け加えたものとなります。
例えば、
{% for status in statuslist %} {{status.user.screen_name}} {% endfor %}
とすれば、全ステータスの表示名(screen_name)が出力されます。
なお、{{status.html}}は、{{status.permalink}}先のHTMLから取得しているため、指定すると処理が重くなります。ご了承下さい。
実際のテンプレート例
■http://furyu-tei.appspot.com/twitrender/t/simple_001.html
{% for status in statuslist %}<a href="http://twitter.com/{{status.user.screen_name}}/"><img src="{{status.user.profile_image_url}}" width="32" border"0" /></a> <a href="{{status.permalink}}" />{{status.user.screen_name}}</a> {{status.text}}<br />{% endfor %}
goshichigo ちょっといい アプリケーション 作りたい http://bit.ly/16D16o
(風柳亭 #tanzaku)
■http://furyu-tei.appspot.com/twitrender/t/table_001.html
<table><tbody>{% for status in statuslist %} <tr> <td><a href="http://twitter.com/{{status.user.screen_name}}/"><img src="{{status.user.profile_image_url}}" width="32" border"0" /></a></td> <td><a href="http://twitter.com/{{status.user.screen_name}}/"></a>{{status.user.screen_name}}</td> <td>{{status.text}}</td> <td><a href="{{status.permalink}}" />link</a></td> </tr> {% endfor %}</tbody></table>
![]() |
goshichigo | ちょっといい アプリケーション 作りたい http://bit.ly/16D16o (風柳亭 #tanzaku) |
link |
■http://furyu-tei.appspot.com/twitrender/t/table_003.html
<table><tbody>{% for status in statuslist %} <tr> <td><a href="http://twitter.com/{{status.user.screen_name}}/"><img src="{{status.user.profile_image_url}}" width="32" border"0" /></a></td> <td><a href="{{status.permalink}}" />{{status.user.screen_name}}</a></td> <td>{{status.text}}</td> </tr> {% endfor %}</tbody></table>
![]() |
goshichigo | ちょっといい アプリケーション 作りたい http://bit.ly/16D16o (風柳亭 #tanzaku) |
■http://furyu-tei.appspot.com/twitrender/t/table_005.html
<table><tbody>{% for status in statuslist %} <tr> <td><a href="http://twitter.com/{{status.user.screen_name}}/"><img src="{{status.user.profile_image_url}}" width="32" border"0" /></a></td> <td><a href="{{status.permalink}}" />{{status.user.screen_name}}</a></td> <td>{{status.html}}</td> <td>{{status.jst.year}}年{{status.jst.month}}月{{status.jst.day}}日({{status.jst.weekday}})</td> </tr> {% endfor %}</tbody></table>
![]() |
goshichigo | ちょっといい アプリケーション 作りたい http://bit.ly/16D16o (風柳亭 #tanzaku) |
2009年7月7日(火) |
■http://furyu-tei.appspot.com/twitrender/t/table_006.html
<table border="1" bgcolor="#FFFFFF"><tbody>{% for status in statuslist %} <tr> <td width="32" height="32"><img src="{{status.user.profile_image_url}}" width="32" height="32" /></td> <td><a href="http://twitter.com/{{status.user.screen_name}}/">{{status.user.name}}<br>@{{status.user.screen_name}}</a></td> <td> {{status.html}}({{status.jst.iso}})</td> <td><a href="{{status.permalink}}">link</a></td> </tr> {% endfor %}</tbody></table>
![]() |
お気楽五七五 @goshichigo |
ちょっといい アプリケーション 作りたい http://bit.ly/16D16o (風柳亭 #tanzaku)(2009-07-07 03:16:00) |
link |
■http://furyu-tei.appspot.com/twitrender/t/table_007.html
<table><tbody>{% for status in statuslist %} <tr> <td><a href="http://twitter.com/{{status.user.screen_name}}"><img src="{{status.user.profile_image_url}}" width="32" border="0" /></a></td> <td><a href="{{status.permalink}}">{{status.user.screen_name}}</a></td> <td>{{status.text}} ( {{status.jst.iso}} )</td> </tr> {% endfor %}</tbody></table>
![]() |
goshichigo | ちょっといい アプリケーション 作りたい http://bit.ly/16D16o (風柳亭 #tanzaku) ( 2009-07-07 03:16:00 ) |
http://d.hatena.ne.jp/hrkt0115311/20090722/1248266271のフォーマット準拠。