blog/content/post/2010-09-15-00001388.md

99 lines
6.9 KiB
Markdown
Raw Normal View History

2019-03-31 11:00:21 +00:00
---
title: GaucheでRSSの生成
author: kazu634
date: 2010-09-15
url: /2010/09/15/_1574/
wordtwit_post_info:
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:5345;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
categories:
- gauche
- Lisp
---
<div class="section">
<p>
<a href="http://d.hatena.ne.jp/sirocco634/20100912#1284300126" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/sirocco634/20100912#1284300126', '前回');" target="_blank">前回</a>までのところでは、「なんかリストを作るのが面倒くさいなぁ」と思ったのだが、よく考えたら quasi-quote を使えば問題ないことに気づく。こんな感じ:
</p>
<pre class="syntax-highlight">
<span class="synSpecial">(</span>use sxml.serializer<span class="synSpecial">)</span>
<span class="synSpecial">(</span>define gen-rss
<span class="synPreProc">`(</span><span class="synType">*TOP*</span>
<span class="synSpecial">(</span><span class="synType">*PI*</span> xml <span class="synConstant">&#34;version=\&#34;1.0\&#34; encoding=\&#34;UTF-8\&#34;&#34;</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>rss <span class="synSpecial">(</span>@ <span class="synSpecial">(</span>version <span class="synConstant">&#34;2.0&#34;</span><span class="synSpecial">))</span>
,channel-example<span class="synSpecial">)</span><span class="synPreProc">)</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>define channel-example
<span class="synPreProc">`(</span>channel
<span class="synSpecial">(</span>title <span class="synConstant">&#34;foobar&#34;</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>link <span class="synConstant">&#34;http://kazu634.tumblr.com/&#34;</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>description <span class="synConstant">&#34;Tumblr&#34;</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>lastBuildDate <span class="synConstant">&#34;Fri, 20 Jul 2007 19:00:00 +0900&#34;</span><span class="synSpecial">)</span>
,items-example<span class="synPreProc">)</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>define items-example
<span class="synPreProc">`(</span>item <span class="synSpecial">(</span>title <span class="synConstant">&#34;Post01&#34;</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>link <span class="synConstant">&#34;http://kazu634.tumblr.com/01&#34;</span><span class="synSpecial">)</span>
<span class="synSpecial">(</span>pubDate <span class="synConstant">&#34;Fri, 20 Jul 2007 19:00:00 +0900&#34;</span><span class="synSpecial">)</span><span class="synPreProc">)</span><span class="synSpecial">)</span>
</pre>
<p>
実行例はこんな感じになる:
</p>
<pre class="syntax-highlight">
gosh&#62;<span class="synSpecial">(</span><span class="synStatement">print</span> <span class="synSpecial">(</span>srl:sxml-&#62;xml gen-rss<span class="synSpecial">))</span>
<span class="synStatement">&#60;</span>?xml version=<span class="synConstant">&#34;1.0&#34;</span> encoding=<span class="synConstant">&#34;UTF-8&#34;</span>?<span class="synStatement">&#62;</span>
&#60;rss version=<span class="synConstant">&#34;2.0&#34;</span><span class="synStatement">&#62;</span>
&#60;channel&#62;
&#60;title&#62;foobar&#60;/title&#62;
&#60;link&#62;http://kazu<span class="synConstant">634.</span>tumblr.com/&#60;/link&#62;
&#60;description&#62;Tumblr&#60;/description&#62;
&#60;lastBuildDate&#62;Fri, <span class="synConstant">20</span> Jul <span class="synConstant">2007</span> <span class="synConstant">19</span>:<span class="synConstant">00</span>:<span class="synConstant">00</span> +<span class="synConstant">0900</span>&#60;/lastBuildDate&#62;
&#60;item&#62;
&#60;title&#62;Post<span class="synConstant">01</span>&#60;/title&#62;
&#60;link&#62;http://kazu<span class="synConstant">634.</span>tumblr.com/<span class="synConstant">01</span>&#60;/link&#62;
&#60;pubDate&#62;Fri, <span class="synConstant">20</span> Jul <span class="synConstant">2007</span> <span class="synConstant">19</span>:<span class="synConstant">00</span>:<span class="synConstant">00</span> +<span class="synConstant">0900</span>&#60;/pubDate&#62;
&#60;/item&#62;
&#60;/channel&#62;
&#60;/rss&#62;
#&#60;undef&#62;
</pre>
<p>
なんだ簡単そうだぞ。
</p>
<div class="hatena-asin-detail">
<a href="http://www.amazon.co.jp/dp/4873113482/?tag=hatena_st1-22&ascsubtag=d-7ibv" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.amazon.co.jp/dp/4873113482/?tag=hatena_st1-22&ascsubtag=d-7ibv', '');"><img src="https://images-na.ssl-images-amazon.com/images/I/51Exg14b4uL._SL160_.jpg" class="hatena-asin-detail-image" alt="プログラミングGauche" title="プログラミングGauche" /></a></p>
<div class="hatena-asin-detail-info">
<p class="hatena-asin-detail-title">
<a href="http://www.amazon.co.jp/dp/4873113482/?tag=hatena_st1-22&ascsubtag=d-7ibv" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://www.amazon.co.jp/dp/4873113482/?tag=hatena_st1-22&ascsubtag=d-7ibv', 'プログラミングGauche');">プログラミングGauche</a>
</p>
<ul>
<li>
<span class="hatena-asin-detail-label">作者:</span> <a href="http://d.hatena.ne.jp/keyword/Kahua%A5%D7%A5%ED%A5%B8%A5%A7%A5%AF%A5%C8" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/keyword/Kahua%A5%D7%A5%ED%A5%B8%A5%A7%A5%AF%A5%C8', 'Kahuaプロジェクト');" class="keyword">Kahuaプロジェクト</a>,<a href="http://d.hatena.ne.jp/keyword/%C0%EE%B9%E7%BB%CB%CF%AF" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/keyword/%C0%EE%B9%E7%BB%CB%CF%AF', '川合史朗');" class="keyword">川合史朗</a>
</li>
<li>
<span class="hatena-asin-detail-label">出版社/メーカー:</span> <a href="http://d.hatena.ne.jp/keyword/%A5%AA%A5%E9%A5%A4%A5%EA%A1%BC%A5%B8%A5%E3%A5%D1%A5%F3" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/keyword/%A5%AA%A5%E9%A5%A4%A5%EA%A1%BC%A5%B8%A5%E3%A5%D1%A5%F3', 'オライリージャパン');" class="keyword">オライリージャパン</a>
</li>
<li>
<span class="hatena-asin-detail-label">発売日:</span> 2008/03/14
</li>
<li>
<span class="hatena-asin-detail-label">メディア:</span> 大型本
</li>
<li>
<span class="hatena-asin-detail-label">購入</span>: 22人 <span class="hatena-asin-detail-label">クリック</span>: 713回
</li>
<li>
<a href="http://d.hatena.ne.jp/asin/4873113482" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/asin/4873113482', 'この商品を含むブログ (272件) を見る');" target="_blank">この商品を含むブログ (272件) を見る</a>
</li>
</ul>
</div>
<div class="hatena-asin-detail-foot">
</div>
</div>
</div>