<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matthew&#039;s Blog</title>
	<atom:link href="http://www.esashi.mobi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.esashi.mobi</link>
	<description>Various concerns, IT, Politics, Esashi, and so on</description>
	<lastBuildDate>Thu, 26 Apr 2012 09:15:18 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>潮干狩り</title>
		<link>http://www.esashi.mobi/2012/04/08/372/</link>
		<comments>http://www.esashi.mobi/2012/04/08/372/#comments</comments>
		<pubDate>Sat, 07 Apr 2012 22:11:39 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[枝幸]]></category>
		<category><![CDATA[アサリ]]></category>
		<category><![CDATA[漁業権]]></category>
		<category><![CDATA[潮干狩り]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=372</guid>
		<description><![CDATA[世界は暖冬化傾向にあったと言われていたけど、今年は寒かったようで、歌登では氷点下30度以下を連発し、日本一寒い町の称号を数度も得たのは記憶に新しい。また、瞬間的な寒さだけではなく、春の訪れもまだまだ遠く、雪が沢山残ってお [...]]]></description>
			<content:encoded><![CDATA[<p>世界は暖冬化傾向にあったと言われていたけど、今年は寒かったようで、歌登では氷点下30度以下を連発し、日本一寒い町の称号を数度も得たのは記憶に新しい。また、瞬間的な寒さだけではなく、春の訪れもまだまだ遠く、雪が沢山残っており、冬物の上着が手放せず、雪がまだ降るぐらい寒い。ここ最近、去年までなら、３月下旬から、暖気に誘われるように、潮干狩りに出かけ、たくさんアサリを採ったのだが、寒くて行く気がしない。最近の浜をみていると、潮干狩りに来ている人も前年の同時期より遥かに少ない。今年は流氷が浜に長期間残っていたので、アサリの生存率は低いのではないだろうか？調べにいってみよう。あれ、明日は大潮かな？潮見表はどこだ・・・</p>
<p>潮干狩りは干潮時に行くので、潮汐カレンダーと時刻表（潮見表）があると計画を立てやすく、大潮が始まる時間にあわせて始めれば、長い時間楽しめる。潮汐情報を提供するサイトは幾つもあるが、私が最も見やすいと思っている<a href="http://tide.iinori.jp/test2.php?port=0121">日本の潮汐</a>のをこのブログのガジェットとして加えてみた。また、月ごとのカレンダーは<a href="http://tide736.net/month/?pc=1&amp;hc=21&amp;sw=calendar">tide736.netの</a>が分かりやすいと思う。枝幸の潮見表もきちんと表示されるスマートフォン向けアプリとして<a href="http://itunes.apple.com/jp/app/id500375115?mt=8&amp;ign-mpt=uo%3D4">潮汐なび</a>や<a href="http://itunes.apple.com/jp/app/id422001818?mt=8&amp;ign-mpt=uo%3D4">タイドグラフ</a>などがある。タイドグラフは有料で、しかも毎年度ごとに350円課金に最近変更されたようで、レビューをみるとユーザーから不評を買っている。</p>
<p>日本の沿岸ではアサリに対しても漁業権が設定されていることが殆どだが、枝幸の海岸の場合、どうなっているんだろう？藪蛇かもしれないが、調べてみよう。昔は禁止の看板があったし、禁止だが黙認されていると耳にするし。遊魚に関して北海道は<a href="http://www.pref.hokkaido.lg.jp/sr/ggk/ggs/turi-r-m/rule_p04.htm">関係する地元の漁協に訪ねろ</a>といっているから、そうするほかない。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/04/08/372/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RustもいいけどJuliaもね</title>
		<link>http://www.esashi.mobi/2012/04/05/363/</link>
		<comments>http://www.esashi.mobi/2012/04/05/363/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 21:38:40 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Julia]]></category>
		<category><![CDATA[Rust]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=363</guid>
		<description><![CDATA[Rustについての情報が殆ど無いのに、検索ワード&#8221;Rust&#8221;の検索結果の上位に表示されるためか、Rustの情報があると期待してこのサイトを訪れる方々がいらっしゃいますが、ごめんなさい。 突然ですが [...]]]></description>
			<content:encoded><![CDATA[<p>Rustについての情報が殆ど無いのに、検索ワード&#8221;Rust&#8221;の検索結果の上位に表示されるためか、Rustの情報があると期待してこのサイトを訪れる方々がいらっしゃいますが、ごめんなさい。</p>
<p>突然ですが、おそらくRustとは主な適用分野が異なる<a href="http://julialang.org/">Julia</a>なるプログラミング言語も覘いてみて欲しいです。</p>
<p>参考：</p>
<ol>
<li><a href="http://d.hatena.ne.jp/amarui/20120221/1329823079">なぜ僕らはJuliaを作ったか</a>, 丸井綜研</li>
<ul>
<li>詳しいです。</li>
</ul>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/04/05/363/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>数式を表現できるようにしてみた</title>
		<link>http://www.esashi.mobi/2012/04/04/330/</link>
		<comments>http://www.esashi.mobi/2012/04/04/330/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 09:05:50 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[備忘録]]></category>
		<category><![CDATA[数学]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[数式]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=330</guid>
		<description><![CDATA[WP Latexというプラグインをインストールするだけで使えます。画像をつかっているのですが、画像の生成はWordpress.comのサーバを利用します。お手軽になったなぁ。利用できなくなったら、自サーバにも切り替えられ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wordpress.org/extend/plugins/wp-latex/">WP Latexというプラグイン</a>をインストールするだけで使えます。画像をつかっているのですが、画像の生成はWordpress.comのサーバを利用します。お手軽になったなぁ。利用できなくなったら、自サーバにも切り替えられるので安心して使っていけます。CSSでイメージの調整もできます。Knuth氏は偉大ですね。</p>
<img src='http://s.wordpress.com/latex.php?latex=%5Czeta%28s%29%3D1%2B%5Cfrac%7B1%7D%7B2%5Es%7D%2B%5Cfrac%7B1%7D%7B3%5Es%7D%2B%5Cfrac%7B1%7D%7B4%5Es%7D%2B%5Cdots%20%3D%20%5Csum_%7Bn%3D1%7D%5E%5Cinfty%20%5Cfrac%7B1%7D%7Bn%5Es%7D&#038;bg=T&#038;fg=000000&#038;s=2' alt='\zeta(s)=1+\frac{1}{2^s}+\frac{1}{3^s}+\frac{1}{4^s}+\dots = \sum_{n=1}^\infty \frac{1}{n^s}' title='\zeta(s)=1+\frac{1}{2^s}+\frac{1}{3^s}+\frac{1}{4^s}+\dots = \sum_{n=1}^\infty \frac{1}{n^s}' class='latex' />
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/04/04/330/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ウニ養殖#1</title>
		<link>http://www.esashi.mobi/2012/04/03/325/</link>
		<comments>http://www.esashi.mobi/2012/04/03/325/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 22:21:57 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[備忘録]]></category>
		<category><![CDATA[養殖]]></category>
		<category><![CDATA[ウニ]]></category>
		<category><![CDATA[歩留まり]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=325</guid>
		<description><![CDATA[水産物、特に棘皮動物の養殖に興味があったので、調べたことを備忘録代わりに書いておくことにした。なんの脈略も無しに、情報を書き連ねていくだけであるが、たまにはまとめることにする。 最初は、ウニの歩留まりについて調べてみた。 [...]]]></description>
			<content:encoded><![CDATA[<p>水産物、特に棘皮動物の養殖に興味があったので、調べたことを備忘録代わりに書いておくことにした。なんの脈略も無しに、情報を書き連ねていくだけであるが、たまにはまとめることにする。</p>
<p>最初は、ウニの歩留まりについて調べてみた。歩留まり、歩留まり率ぐらいは、何かを製造していれば、分かると思うが、原材料からどれだけの割合で製造物ができるかを示す値である。半導体などに代表される工業製品では不良品を除いた完成品の割合をそう呼んでいるが、食品加工においては食用にできる割合をいう。ウニの場合の歩留まりとは、ウニ全体の重量に対する我々が食べているウニの生殖巣の割合をいう。例えば100gのウニから20gの生殖巣がとれたら歩留まりは20%である。実際には沢山のウニから取り出して歩留まりを計算するのだろうけど。実際の歩留まりはどのくらいだろうか？</p>
<p>これまで、ウニを食べ、生殖巣を取り出した経験からすると、ウニの歩留まりと一口には言えない問題があるように思っていた。水分を多量に含んだ食品によくあることだと思うが、水分量の問題、そして熟成しすぎてまたは放卵・放精しながら溶けていく問題、さらに小さい・切れてる・崩れた生殖巣はそのままでは製品として受け入れられい問題。水産業界・水産加工業界では、こうした問題を考慮して、生殖巣を取り出して直ぐの歩留まりを歩留と呼び、製品としての最終的な歩留まり製品歩留として、どうやら区別しているらしい（参考1）。当然だが、歩留＞製品歩留。送り仮名の有り無しはどうでもよいだろう。</p>
<p>さて、実際の歩留・製品歩留はどのくらいなのか？ウニの種類、時期、産地などによるだろうが、私の大好きなエゾバフンウニは、旬の時期には20%の歩留で良好とされ、15%以上の製品歩留となるようだ。敢えて出典を記さない。炭酸カルシウムと石灰からなる内外骨格が重いのだからその程度であろう。</p>
<p>理想的な状態のウニの歩留はどうなるか？あのウニの殻の中にどれだけ生殖巣を詰め込めるのか？その答えを得るには、ウニの年齢と寿命、そして殻の大きさ、生殖巣以外の内臓についても知っておく必要があると思う。エゾバフンウニの場合、餌や環境にもよるが、3-5年でよく目にする大きさの直径4-5cmに成長し、10年ぐらいで寿命を全うするそうである。個人的な経験であるが、直径が5cm以上で6年以上生きていそうなのは、餌が少ないのが原因なのか、たいていは生殖巣が萎んでいて歩留まりを下げる。中には蜜柑の房のような大きな生殖巣を殻の大きさにあわせて発達させた固体もいるが、多くはない。環境がよいところであれば、多いのだろうか。寿命に関しては、環境さえ良ければ、200年ぐらい生きるといっている研究者もいるらしいので（どの種類なのか？これも敢えて出典ださないけど（笑））、甲殻類のように成長し続け、且つ生殖活動も続くのであれば、物理的・経済的な限界を定めてから理想の最大歩留まりを考えたほうがよさそうである（外骨格の生物は巨大化しにくいと思うので限界があるはず）。これについては、公開される研究の成果を待とう。</p>
<p>参考・参照：</p>
<ol>
<li><a href="http://www.fish-jfrca.jp/pdf/suisan-h18/01_18.pdf">エゾバフンウニの歩留及び成熟度調査指導</a>, 北海道利尻地区水産技術普及指導所</li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/04/03/325/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Mapを「ぼうけん」して枝幸までいってみた</title>
		<link>http://www.esashi.mobi/2012/04/01/319/</link>
		<comments>http://www.esashi.mobi/2012/04/01/319/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 11:33:19 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[枝幸]]></category>
		<category><![CDATA[Google Map]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=319</guid>
		<description><![CDATA[地名があるだけで、ドラゴンどころかスライムすら居なかった。キラークラブとはいわないけど、せめて軍隊ガニぐらい居て欲しかった。北海道付近では択捉島に何かいますね。 Googleがこれをチョチョイノチョイで作ったのなら、Go [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.esashi.mobi/wp-content/uploads/2012/04/google_bouken_esashi.png" rel="lightbox[319]" title="google_bouken_esashi"><img class="alignleft size-thumbnail wp-image-320" title="google_bouken_esashi" src="http://www.esashi.mobi/wp-content/uploads/2012/04/google_bouken_esashi-150x150.png" alt="" width="150" height="150" /></a>地名があるだけで、ドラゴンどころかスライムすら居なかった。キラークラブとはいわないけど、せめて軍隊ガニぐらい居て欲しかった。北海道付近では択捉島に何かいますね。</p>
<p>Googleがこれをチョチョイノチョイで作ったのなら、Google Mapに地図の簡略化機能として公開して欲しい。このようなブロック化だけでなく、滑らかな曲線や少ない頂点のポリラインで表現もできるでしょう。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/04/01/319/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>枝幸の二つ目の島　乙忠部ノ瀬南小島</title>
		<link>http://www.esashi.mobi/2012/03/04/312/</link>
		<comments>http://www.esashi.mobi/2012/03/04/312/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 07:33:47 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[枝幸]]></category>
		<category><![CDATA[国土地理院]]></category>
		<category><![CDATA[海洋政策]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=312</guid>
		<description><![CDATA[最近、遠隔にいる知人からIRC某チャンネル上で、枝幸にある「岩」に島としての名称が今年度中に付けられる予定であると知らされた。官邸が発表した『排他的経済水域（ＥＥＺ）外縁を根拠付ける離島の地図・海図に記載する名称の決定に [...]]]></description>
			<content:encoded><![CDATA[<p>最近、遠隔にいる知人からIRC某チャンネル上で、枝幸にある「岩」に島としての名称が今年度中に付けられる予定であると知らされた。官邸が発表した『<a href="http://www.kantei.go.jp/jp/singi/kaiyou/ritouhoushin/meisyou120302.html">排他的経済水域（ＥＥＺ）外縁を根拠付ける離島の地図・海図に記載する名称の決定について</a>』および『<a href="http://www.kantei.go.jp/jp/singi/kaiyou/ritouhoushin/meisyou.html">名称不明離島の名称決定・地図等への記載について</a>』で確認してみると、「水かぶり岩」と表記されていた岩に「乙忠部ノ瀬南小島」と島の名称がつけられることが確認できる。<strong><span style="color: #0000ff;">謂わば</span></strong>課長島耕作のように出世したようなものである（今市おもしろくないな(^^;)）。</p>
<p>政府が名称をつけたのは、要するに、我が国に経済的恩恵を与える排他的経済水域などの根拠となる岩や小島を確実に日本の領土とし、管轄下にあることを国内外に知らしめるためである。古地図を捏造し島民を皆殺しにして島を奪い取ろうとする国、終戦のドサクサで奪い取った国、大量の資源に目が眩んで主権を主張する国に囲まれている中では非常に弱々しく映るが、文句が来たら突っぱねればよい。実際、<a href="http://taiwantoday.tw/ct.asp?xItem=187172&amp;ctNode=1782">台湾政府外交部からは魚釣島付近の島への命名について抗議</a>がきているようだが、するりと受け流して、何時でも国際司法裁判所で決着つけられるように用意しておいてもらいたい。</p>
<p>今回名前が付けられた枝幸の岩は領海やEEZに大きな変更を加えることにならないだろうが、<strong><span style="color: #0000ff;">想定外の</span></strong>軒下を貸して母屋を取られるようなことが起きることを未然に防ぐ第一歩ではあるので、星一つぐらいは評価すべきことである。さて、実際どこにあるのか？乙忠部集落の人々やホタテ漁業に従事している町民なら分かるのだが、島周辺の道路を通ったことがあるだけの町民には認識されていなかったであろう。Google MapsやGoo地図の航空写真では確認できなかったので、国土地理院の地図閲覧サービスで確認してみた：</p>
<p style="padding-left: 30px;"><a href="http://watchizu.gsi.go.jp/watchizu.html?longitude=142.73827777777&amp;latitude=44.777971958924">国土地理院　乙忠部ノ瀬南小島　北緯44度46分40.6秒　 東経142度44分17.7秒</a></p>
<p>まだ「水かぶり岩」と表記されているが、いずれ新しい名称に書き換えられるだろう。国道からおよそ1kmぐらい沖合いにあるようだ。因みに、これまで枝幸町唯一の島であったゴメ島はここにある：</p>
<p style="padding-left: 30px;"><a href="http://watchizu.gsi.go.jp/watchizu.html?longitude=142.83148611079&amp;latitude=44.700767239685">国土地理院　ゴメ島　北緯44度42分2.7秒　 東経142度49分53.3秒</a></p>
<p>因みに、今年度中に名称決定予定の島はこんなにある</p>
<p style="padding-left: 30px;"><a href="http://www.kantei.go.jp/jp/singi/kaiyou/ritouhoushin/pdf/ritoutizu2.pdf">平成23年度中に名称決定予定の離島（39島）</a></p>
<p>参考・参照：</p>
<ol>
<li><a href="http://www.kantei.go.jp/jp/singi/kaiyou/chousa/teichousen.pdf">排他的経済水域等の基礎となる低潮線を有する離島に関する調査 調査報告書</a>, 2012年3月3日閲覧.</li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/03/04/312/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON出力を処理するGoogle Gadgetの作り方#4</title>
		<link>http://www.esashi.mobi/2012/03/03/297/</link>
		<comments>http://www.esashi.mobi/2012/03/03/297/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 01:40:54 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[備忘録]]></category>
		<category><![CDATA[Google Apps Script]]></category>
		<category><![CDATA[Google code]]></category>
		<category><![CDATA[Google Gadget]]></category>
		<category><![CDATA[Google Site]]></category>
		<category><![CDATA[iGoogle]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=297</guid>
		<description><![CDATA[前回、環境を整えた。今回からやっと本題に入れる。まずは「gadgets.* API デベロッパー ガイド」の「リモートコンテンツの処理」、より本題に近い内容の「フィードの処理」をよく読んで、利用させてもらえばよい。実は、 [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://www.google.com/gadgets/directory/348515928-no_image_gadget_thm.png" alt="" width="120" height="60" /><a title="JSON出力を処理するGoogle Gadgetの作り方#3" href="http://www.esashi.mobi/2012/03/02/258/">前回</a>、環境を整えた。今回からやっと本題に入れる。まずは「<a href="http://code.google.com/intl/ja/apis/gadgets/docs/dev_guide.html">gadgets.* API デベロッパー ガイド</a>」の「<a href="http://code.google.com/intl/ja/apis/gadgets/docs/remote-content.html">リモートコンテンツの処理</a>」、より本題に近い内容の「<a href="http://code.google.com/intl/ja/apis/gadgets/docs/remote-content.html#Fetch_Feed">フィードの処理</a>」をよく読んで、利用させてもらえばよい。実は、テーマにJSONとあるが、実際はFEEDを読み取るガジェットを作る。FEEDを読み取った後のデータの扱いがJSONなだけなのである。</p>
<p>早速、プログラムを示す。</p>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;Module&gt;
&nbsp; &lt;ModulePrefs title=&quot;Chou Feed Gadget&quot;
&nbsp; title_url =http://code.google.com/p/chou-feed-gadget/ description = &quot;Mainly, this gadget exstracts titles of an announcement page from a posts.xml feed in a Google site.&quot;
author =Matthew / Ken ichi AKIMOTO author_email = screenshot = &quot;&quot;
thumbnail = scrolling =false height = &quot;200&quot;&gt;
&nbsp; &nbsp; &lt;Require feature=&quot;dynamic-height&quot;/&gt;
&nbsp; &lt;/ModulePrefs&gt;
&nbsp; &lt;UserPref name=&quot;title&quot; display_name=&quot;Title&quot; default_value=&quot;&quot;/&gt;
&nbsp; &lt;UserPref name=&quot;show_date&quot; display_name=&quot;Show Dates?&quot; datatype=&quot;bool&quot; default_value=&quot;true&quot;/&gt;
&nbsp; &lt;UserPref name=&quot;num_entries&quot; display_name=&quot;Number of Entries:&quot; default_value=&quot;5&quot;/&gt;
&nbsp; &lt;UserPref name=&quot;show_summ&quot; display_name=&quot;Show Summaries?&quot; datatype=&quot;bool&quot; default_value=&quot;false&quot;/&gt;
&nbsp; &lt;UserPref name=&quot;feed_url&quot; display_name=&quot;Feed URL&quot; default_value=&quot;&quot; /&gt;
&nbsp; &lt;UserPref name=&quot;japanese&quot; display_name=&quot;Japanese Format?&quot; datatype=&quot;bool&quot; default_value=&quot;true&quot;/&gt;
&nbsp; &lt;UserPref name=&quot;zero_suppress&quot; display_name=&quot;Zero Suppress?&quot; datatype=&quot;bool&quot; default_value=&quot;false&quot; /&gt;
&nbsp; &lt;UserPref name=&quot;link_url&quot; display_name=&quot;Link URL&quot; default_value=&quot;&quot; /&gt;
&nbsp; &lt;Content type=&quot;html&quot;&gt;
&nbsp; &lt;![CDATA[
&nbsp; &lt;style&gt;&nbsp;
&nbsp; #content_div { font-size: 80%; &nbsp;margin: 5px; background-color: transparent;}
&nbsp; body {background-color: transparent;}
&nbsp; &lt;/style&gt;
&nbsp; &lt;div id=&quot;content_div&quot;&gt;&lt;/div&gt;
&nbsp; &lt;script type=&quot;text/javascript&quot;&gt;

&nbsp; // Get userprefs
&nbsp; var prefs = new gadgets.Prefs();
&nbsp; var title = prefs.getString(&quot;title&quot;);
&nbsp; var showdate = prefs.getBool(&quot;show_date&quot;);
&nbsp; var entries = prefs.getInt(&quot;num_entries&quot;);
&nbsp; var summaries = prefs.getBool(&quot;show_summ&quot;);
&nbsp; var feed_url = prefs.getString(&quot;feed_url&quot;);
&nbsp; var japanese = prefs.getBool(&quot;japanese&quot;);
&nbsp; var link_url = prefs.getString(&quot;link_url&quot;);
&nbsp; var zero_suppress = prefs.getBool(&quot;zero_suppress&quot;);

&nbsp; function getFeed() {
&nbsp; &nbsp; var params = {};
&nbsp; &nbsp; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.FEED; &nbsp;
&nbsp; &nbsp; params[gadgets.io.RequestParameters.NUM_ENTRIES] = new Number(entries); &nbsp;
&nbsp; &nbsp; params[gadgets.io.RequestParameters.GET_SUMMARIES] = summaries;&nbsp;
&nbsp; &nbsp; gadgets.io.makeRequest(feed_url, response, params);
&nbsp; };
&nbsp;&nbsp;
&nbsp; function getJapaneseFormatDate(date) {
&nbsp; &nbsp; var html = &quot;&quot;;
&nbsp; &nbsp; html += date.getFullYear() + &quot;年&quot;;
&nbsp; &nbsp; m = date.getMonth() + 1;
&nbsp; &nbsp; if (!zero_suppress &amp;&amp; m &lt; 10) html += &quot;0&quot;;
&nbsp; &nbsp; html += m + &quot;月&quot;;
&nbsp; &nbsp; d = date.getDate();
&nbsp; &nbsp; if (!zero_suppress &amp;&amp; d &lt; 10) html += &quot;0&quot;;
&nbsp; &nbsp; html += d + &quot;日&quot;;
&nbsp; &nbsp; html += &quot; &quot;;
&nbsp; &nbsp; h = date.getHours();
&nbsp; &nbsp; if (!zero_suppress &amp;&amp; h &lt; 10) html += &quot;0&quot;;
&nbsp; &nbsp; html += h + &quot;時&quot;;
&nbsp; &nbsp; m = date.getMinutes();
&nbsp; &nbsp; if (!zero_suppress &amp;&amp; m &lt; 10) html += &quot;0&quot;;
&nbsp; &nbsp; html += m + &quot;分&quot;;
&nbsp; &nbsp; s = date.getSeconds();
&nbsp; &nbsp; if (!zero_suppress &amp;&amp; s &lt; 10) html += &quot;0&quot;;
&nbsp; &nbsp; html += s + &quot;秒&quot;;
&nbsp; &nbsp; return html;
&nbsp; };

&nbsp; function response(obj) {&nbsp;
&nbsp; &nbsp; // obj.data contains the feed data
&nbsp; &nbsp; var feed = obj.data;
&nbsp; &nbsp; var html = &quot;&quot;;

&nbsp; &nbsp; // Display the feed title and description
&nbsp; &nbsp; html += &quot;&lt;b&gt;&quot; + title + &quot;&lt;/b&gt;&lt;br&gt;&quot;;
&nbsp; &nbsp; html += feed.Description + &quot;&lt;br&gt;&quot;;
&nbsp; &nbsp; // Access the data for a given entry
&nbsp; &nbsp; if (feed.Entry) {
&nbsp; &nbsp; &nbsp; for (var i = 0; i &lt; feed.Entry.length; i++) {
&nbsp; &nbsp; &nbsp; &nbsp; //html += &quot;&lt;div&gt;&quot;
&nbsp; &nbsp; &nbsp; &nbsp; if (showdate==true)&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var date = new Date(feed.Entry[i].Date);&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (japanese)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html += getJapaneseFormatDate(date);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html += date.toLocaleDateString();
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html += &quot; &quot;;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html += date.toLocaleTimeString();&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; html += &quot; &quot;;
&nbsp; &nbsp; &nbsp; &nbsp; var page_url = feed.Entry[i].Link;
&nbsp; &nbsp; &nbsp; &nbsp; if (link_url.length &gt; 0) // brush up point
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; page_url = link_url + &quot;/&quot; + page_url.split(&quot;/&quot;).pop();
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; html += &quot;&lt;a target=&#039;_blank&#039; href=&#039;&quot; + page_url + &quot;&#039;&gt;&quot;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ &nbsp;feed.Entry[i].Title
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ &nbsp;&quot;&lt;/a&gt; &quot;;
&nbsp; &nbsp; &nbsp; &nbsp; if (summaries==true)&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html += &quot;&lt;br&gt;&lt;i&gt;&quot; + feed.Entry[i].Summary + &quot;&lt;/i&gt;&quot;;
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; html += &quot;&lt;br&gt;&quot;;
&nbsp; &nbsp; &nbsp; &nbsp; //html += &quot;&lt;/div&gt;&quot;;
&nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; }
&nbsp; &nbsp; document.getElementById(&#039;content_div&#039;).innerHTML = html;
&nbsp; &nbsp; gadgets.window.adjustHeight(); // for iGoogle
&nbsp; };
&nbsp; gadgets.util.registerOnLoadHandler(getFeed);
&nbsp; gadgets.window.adjustHeight(); // for Google Site
&nbsp; &lt;/script&gt;
&nbsp; ]]&gt;
&nbsp; &lt;/Content&gt;
&lt;/Module&gt;
</pre>
<p>3行めから13行目までの&lt;ModulePrefs&gt;セクションは、ガジェットのすべてのメタデータ、機能、処理規則のコンテナ要素として機能し、より詳細には、がジェットのタイトルや作者などの情報を記述しておくところである。詳しくは、「<a href="ogle.com/intl/ja/apis/gadgets/docs/reference.html">ガジェット XML リファレンス</a>」の「<a href="http://code.google.com/intl/ja/apis/gadgets/docs/reference.html#Moduleprefs_Ref">ModulePrefs 要素と属性</a>」を理解して実践するとよい。とりあえず、</p>
<ul>
<li>title</li>
<li>title_url</li>
<li>description</li>
<li>author</li>
</ul>
<div>ぐらいは記述しておいたほうがよいでしょう。</div>
<div></div>
<div>14行目から21行目まではガジェットを使うユーザーが定義できるパラメータ／変数を定義していて、型とデフォルト値を指定できる。「<a href="http://code.google.com/intl/ja/apis/gadgets/docs/reference.html#Userprefs_Ref">ユーザー設定</a>」をよく読めば記述できるだろう。</div>
<div></div>
<div>25と26行目でガジェットの背景を透明色に指定している。&lt;div&gt;要素と&lt;body&gt;要素どちらでも指定するとよい。</div>
<div></div>
<div>32-40行で、14-21行でページに貼り付けたときにユーザーが設定した値を読み取っている。設定してない値はデフォルト値を読み取る。</div>
<div></div>
<div>42-48行は、このガジェット独自の関数で、RSSフィードを取得するためにパラメータを設定し、gadgets.io.makeRequest()を使ってリモートにアクセスを実行している。gadgets.io.makeRequest()にはリクエスト後にサーバから返されるレスポンスを処理する関数が指定でき、コールバックしてくれる。</div>
<div></div>
<div>50-70行は日本語年月日時分秒表示のための関数で、Google Apps Script版と同じ関数である。</div>
<div></div>
<div>72-116行はサーバーから返されるレスポンスを処理する関数である。細かくみていこう。</div>
<div></div>
<div>引数objのobj.dataはこのプログラムの場合はJSON形式で渡される。このobj.dataを順にパースしながら情報を取り出していくのだ。JSON形式のデータを取り出すには構造と各フィールドを知っていないといけいない。「<a href="http://code.google.com/intl/ja/apis/gadgets/docs/remote-content.html#Fetch_Feed">フィードの処理</a>」にキチント書いてある。フィードデータ例、JSON形式変換後例があるからわかると思う。今回取り出すのは、</div>
<div>
<ul>
<li>Description（本当はガジェットで設定しようと思っているが）</li>
<li>Entry</li>
<ul>
<li>Title</li>
<li>Link</li>
<li>Summary</li>
<li>Date</li>
</ul>
</ul>
<div>である。構造としてはとても簡単で、１個のDescriptionの他にEntryが何個（デフォルトで最大５個取得）もあり、Entryの数だけTitleなどの取得を繰り返せばよいだけである。</div>
<div></div>
<div>82行目は</div>
<div style="padding-left: 30px;">for ( var i in feed.Entry ) {</div>
<div>と記述できるはずであるが、サンプルのままにしてみた。</div>
</div>
<div></div>
<p>114行目は、最初にGASで作ろうとした特別な差込のための&lt;div&gt;要素をみつけて差込むトリックだ。１行でかけるから簡単だ。</p>
<p>&nbsp;</p>
<p>115行目と118行目は、表示件数に応じてガジェットの高さ（縦方向の長さ）をジャストフィットさせるためのおまじないみたいなもので、iGoogleとGoogle Sitesでは何かが違うために異なるタイミングで実行させることにした。</p>
<p>&nbsp;</p>
<p>117行目はこのファイルが読み込まれたときに実行する関数を設定している。</p>
<p>&nbsp;</p>
<p>あとは、プログラムを読んだらおおよそわかるだろうから説明しない。</p>
<h3>気をつけるべきところ</h3>
<p>実は、ガジェットのソースを変更してブラウザでリロードしてもその変更は即座に反映されない。ブラウザかiGoogle/Google Sitesのキャッシュ更新タイミングが合わないのか、数分経ってからじゃないと更新されない。テストをして修正しなくてはならなくなり、即座に変更されないからといって慌てないように。iGoogleにはキャッシュをさせない機能がデベロッパーモードにあるので開発中はその機能を利用するとよい。</p>
<p>&nbsp;</p>
<h3>テスト・デバッグ・公開</h3>
<p>iGoogleの場合は「ガジェットの追加」ボタンをクリックして、さらに画面左下にある「フィードやガジェットを追加」をクリックし、現れる横に細長いポップアップウィンドウのURL入力欄にガジェットを置いているURLを入力する。今回の場合はGoogle codeのホスティングを利用しているので、raw fileのURLを入力する。raw fileのURLは&#8221;Source&#8221;-&gt;&#8221;Browse&#8221;画面で&#8221;details&#8221;の一番したにある&#8221;View raw faile&#8221;のリンク先である。</p>
<p>Google Sitesの場合は、テストのためのページや、いきなり貼りたいページに、「その他ガジェット」メニューを選択し、URLを指定し、追加ボタンをクリックすればよい。あとは各種設定を行えばよい。</p>
<p>iGoogleもGoogle Sitesも設定した値が個別に保存されている。</p>
<p>&nbsp;</p>
<p>参照・参考：</p>
<ol>
<li><a href="http://code.google.com/intl/ja/apis/gadgets/docs/reference.html">ガジェット XML リファレンス</a>, 2012年2月29日閲覧</li>
<li><a href="http://code.google.com/intl/ja/apis/gadgets/docs/dev_guide.html">gadgets.* API デベロッパー ガイド</a>, 2012年2月29日閲覧</li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/03/03/297/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON出力を処理するGoogle Gadgetの作り方#3</title>
		<link>http://www.esashi.mobi/2012/03/02/258/</link>
		<comments>http://www.esashi.mobi/2012/03/02/258/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 10:51:30 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[備忘録]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Google Apps Script]]></category>
		<category><![CDATA[Google code]]></category>
		<category><![CDATA[Google Gadget]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[VCS]]></category>
		<category><![CDATA[プロジェクト管理]]></category>
		<category><![CDATA[ホスティング]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=258</guid>
		<description><![CDATA[前回サーバーサイドで処理させる二つのGAS（実際にはクライアントサイドでも処理しているが）は簡単には使えなかったという結論を経て、やっと本題のGoogle Gadgetを利用するスクリプトを書いてみることにした。 Goo [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://www.google.com/gadgets/directory/348515928-no_image_gadget_thm.png" alt="" width="120" height="60" /><a title="JSON出力を処理するGoogle Gadgetの作り方#2" href="http://www.esashi.mobi/2012/02/27/253/">前回</a>サーバーサイドで処理させる二つのGAS（実際にはクライアントサイドでも処理しているが）は簡単には使えなかったという結論を経て、やっと本題のGoogle Gadgetを利用するスクリプトを書いてみることにした。</p>
<p>Google Gadgetには色々あるらしいが（<span style="color: #0000ff;">要確認</span>）、ウェブページに貼り付けられるもの、例えばiGoogleやGoogle Sitesのページ、自分のウェブサイトのページに貼り付けられるものを作る。作り方はエディタや配布方法などによって幾つかに分かれるので、最も実践的で大掛かりな方法を敢えて選ぶことにした。<a href="http://code.google.com/intl/ja/apis/gadgets/docs/legacy/gs.html#GGE">Google Gadgets Editor</a>(GGE)でプレビューを見ながらコーディングし、そのままGoogleシステム内に置いたり、自分のウェブサーバにアクセスできるファイルとして置いておくだけでもよいが、後でこのシリーズとは別に備忘録を作るが、バージョン管理やグループ（メーリングリスト）の使い方も知りたかったので、Google codeを利用することにした。また、既に<a href="http://code.google.com/intl/ja/apis/gadgets/docs/dev_guide.html">Google code上に日本語化された有益なサンプルスクリプト付きのオンラインドキュメント</a>が用意されているので、大いに参考にした（参照１）。</p>
<h3>1. プロジェクトを管理するシステムを準備する。</h3>
<p>誰でも利用できるガジェットは最終的には公開し、公開したものをiGoogleなどのディレクトリに登録する必要があるので、どこかの公開ウェブサーバなどに置いておかなくてはならない。今回は<a href="http://code.google.com/intl/ja/apis/gadgets/docs/tools.html#GGE_Pub">GGEからのガジェットの公開</a>ではなく、<a href="http://code.google.com/intl/ja/apis/gadgets/docs/tools.html#Host">Google codeでのホスティング</a>を利用するので、Google codeが使えるようにしておく。GMailやGoogle+などを利用してれば、若干の登録作業が必要になるかもしれないが、すぐに利用できるはずなので省略する（どこかに詳しいドキュメントがあるはず）。GMailがない場合は、GMailから登録すべし。</p>
<p>Google Codeのホスティングが利用できる状態になったら、<a href="http://code.google.com/hosting/">Google Codeのホスティングのページ</a>に行って、プロジェクトを登録する。登録の仕方は<a href="http://code.google.com/intl/ja/apis/gadgets/docs/tools.html#Host">すでに紹介したドキュメント</a>（参照１）に日本語で詳しく書かれているのでその通りにやればよい。私の今回のプロジェクトの場合は次のようにしてみた。説明などは日本語で書いても良さそうなものだが、一応拙い英語で書いておいた。英語に間違いがあっても問題はないので<span style="color: #0000ff;">テケトー</span>に何か書いておいたらよい。登録後に何回でも修正できる。</p>
<ul>
<li>プロジェクト名：&#8221;chou-feed-gadget&#8221;としておいた。抽出の抽を北京語読みすると&#8221;chou&#8221;らしい。変更できないので、注意。プロジェクト自体を削除しても29日間は同じ名前のプロジェクトは作成されない。これは29日間は削除したプロジェクトをさせる機能があるため。リポジトリのリセットにはこのような制限はない。</li>
<li>概要：てけとー、一応 &#8220;An Google Gadget extracting RSS feed infomation from Google Sites announcements&#8221; としておいた。</li>
<li>説明：てけとー、一応 &#8220;This gadget extracts title, date or/and data from Google Sites announcement RSS feed(aka posts.xls), then show them.&#8221; としておいた。（英語おかしいと思うけど（汗））。</li>
<li>バージョンコントロールシステム：&#8221;subversion&#8221;とした。後から変更可能だが、リポジトリはどうなるのだろう？（<span style="color: #0000ff;">要調査</span>）実は手軽にちょっとしたソースをおいておくにはGoogle codeの場合はsubversionが一番適切だと思うから（理由は後ほど）。</li>
<li>ライセンス：&#8221;MIT License&#8221;としておいた。変更可能だ。</li>
<li>ラベル:&#8221;Gadget&#8221; と &#8220;JavaScript&#8221; を指定。</li>
</ul>
<div>
<h3>2. プログラムソースをプロジェクトを管理するシステム上で作成する。</h3>
</div>
<div>登録できたら、Google codeにホスティングしてもらえるわけだが、通常ファイルを置くにはバージョン管理ソフトウェアを使ってコミット／プッシュしないといけない。でもそれではちょっとしたプログラムソース置くだけなら手間がかかりすぎることもある。実は、Google codeではブラウザ上でファイルを作成したりアップロードしたりすることが可能となっている。しかし、バージョン管理システム(VCS)にgitを選択した場合、初期状態ではそれができないようになっている。このことがプロジェクトを作成するときに&#8221;subversiono&#8221;を選択した理由である。実際、gitを選らび、できたばかりのプロジェクトサイトで、メニューにある&#8221;Source&#8221;クリックし、さらに&#8221;Browse&#8221;をクリックしてソースツリーをみるとファイル作成・アップロードの作業のためのリンクは表示されない。他の二つのVCSのうち、mercurialは表示こそされないものの初めからファイルの作成・アップロードは可能であり、subversionは最初からファイルの作成とアップロードのリンクが表示される。</div>
<div></div>
<div>ブラウザ上でファイルを作成するには、mercurialの場合、直接URLを指定してソースファイルを作成する。例えば、&#8221;Browse&#8221;で表示させたgitのソースツリーのURLが次のようになっていたら、</div>
<div style="padding-left: 30px;"><a href="https://code.google.com/p/chou-feed-gadget/source/browse/#git%253Fstate%253Dclosed">https:// 省略 /source/browse</a></div>
<div>次のように</div>
<div style="padding-left: 30px;"><a href="https://code.google.com/p/chou-feed-gadget/source/create?path=/">https:// 省略 /source/create</a></div>
<p>&#8220;browse&#8221;のところを&#8221;create&#8221;に書き換えてアクセスするとファイル編集ページが現れる（図１）。</p>
<p>一方、subversionの場合は&#8221;browse&#8221;メニューを実行すると&#8221;Create or upload a new file&#8221;とリンクついた文字列が表示されて、&#8221;Create&#8221;のリンクをクリックすればよい。</p>
<div id="attachment_291" class="wp-caption aligncenter" style="width: 590px"><a title="図1:Google code ホスティングサイト上でソースを作成" href="http://www.esashi.mobi/wp-content/uploads/2012/03/googe_code_create_file.jpg" rel="lightbox[258]"><img class="size-large wp-image-291" title="googe_code_create_file" src="http://www.esashi.mobi/wp-content/uploads/2012/03/googe_code_create_file-1024x664.jpg" alt="図1:Google code ホスティングサイト上でソースを作成" width="580" height="376" /></a><p class="wp-caption-text">図1:Google code ホスティングサイト上でソースを作成</p></div>
<p>上の図を参考にして欲しいが、数字が並んでいることろがソース編集テキストエリアである。ここに文章やソースコードを記述する。とりあえずリポジトリのルートディレクトリにソース／プログラムファイルを置くので、&#8221;Path&#8221;はそのままでよい。&#8221;Branch&#8221;はないのでそのまま。&#8221;Commit Log&#8221;には適切な文言を入れておく。最初なので&#8221;initial commit&#8221;でよいだろう。あとは&#8221;Commit&#8221;ボタンを押下するだけだ。</p>
<p>続く</p>
<p>参照：</p>
<ol>
<li><a href="http://code.google.com/intl/ja/apis/gadgets/docs/dev_guide.html">gadgets.* API デベロッパー ガイド</a>, 2012年2月10日閲覧.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/03/02/258/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>咲来峠の山スキー</title>
		<link>http://www.esashi.mobi/2012/02/28/260/</link>
		<comments>http://www.esashi.mobi/2012/02/28/260/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 09:25:19 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[枝幸]]></category>
		<category><![CDATA[スキー]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=260</guid>
		<description><![CDATA[枝幸町と音威子府村の境界付近に咲来峠がありますが、冬期間にとおりますと、誰も乗っていない自動車と山の斜面にシュプールを見かけることがあります。事情通の某ダイニングバーの店主さんによると、山スキーを楽しんでいる人達がいるよ [...]]]></description>
			<content:encoded><![CDATA[<p>枝幸町と音威子府村の境界付近に咲来峠がありますが、冬期間にとおりますと、誰も乗っていない自動車と山の斜面にシュプールを見かけることがあります。事情通の某ダイニングバーの店主さんによると、山スキーを楽しんでいる人達がいるようです。次のような動画もありました。</p>
<p><a href="http://www.esashi.mobi/2012/02/28/260/"><em>Click here to view the embedded video.</em></a></p>
<p>このあたりでしょうか？</p>
<a href="http://maps.google.com/maps?f=q&amp;hl=ja&amp;geocode=&amp;q=44.70282599311735,142.3286533355713&amp;ie=UTF8&amp;ll=44.70282599311735,142.3286533355713&amp;t=h&amp;z=9&amp;t=p&amp;maptype=G_PHYSICAL_MAP" title="44.702826,142.328653"><img src="http://maps.google.com/staticmap?markers=44.70282599311735,142.3286533355713,red&amp;zoom=9&amp;size=480x270&amp;key=AIzaSyCvtejrb60zuxIk5_x-fwj6KWByXFHrp1I&amp;hl=ja" alt="44.702826,142.328653" title="44.702826,142.328653" /></a>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/02/28/260/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON出力を処理するGoogle Gadgetの作り方#2</title>
		<link>http://www.esashi.mobi/2012/02/27/253/</link>
		<comments>http://www.esashi.mobi/2012/02/27/253/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 03:09:20 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[備忘録]]></category>
		<category><![CDATA[Google Apps Script]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[ウィジット]]></category>

		<guid isPermaLink="false">http://www.esashi.mobi/?p=253</guid>
		<description><![CDATA[前回に引き続きガジェットについて備忘録を記しておく。今度はウィジットを利用するGASについて記しておく。前回の差し込み版と違うのはdoGet()だけである。 var MAIL = "matthew@hoge.tld";  [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://www.google.com/gadgets/directory/348515928-no_image_gadget_thm.png" class="alignleft" width="120" height="60" /><a title="JSON出力を処理するGoogle Gadgetの作り方#1" href="http://www.esashi.mobi/2012/02/25/227/">前回</a>に引き続きガジェットについて備忘録を記しておく。今度はウィジットを利用するGASについて記しておく。前回の差し込み版と違うのはdoGet()だけである。</p>
<pre>
var MAIL = "matthew@hoge.tld";
var DEBUG_MAIL_SUBJECT = "【DEBUG】最新のお知らせ";
var FEED_URL = "http://www.hoge.tld/info/posts.xml";
var LINK_URL = "http://www.hoge.tld/info";
var SITE_NAMESPACE_URL = "http://schemas.google.com/sites/2008";
var TITLE = "お知らせ";
var zero_suppress = false;
var japanese_date_format = true;

function getJapaneseFormatDate( date ) {
  var html = "";
  html += date.getFullYear() + "年";
  var m = date.getMonth() + 1;
  if ( !zero_suppress &#038;&#038; m < 10 ) html += "0";
  html += m + "月";
  var d = date.getDate();
  if ( !zero_suppress &#038;&#038; d < 10 ) html += "0";
  html += d + "日";
  html += " ";
  var h = date.getHours();
  if ( !zero_suppress &#038;&#038; h < 10 ) html += "0";
  html += h + "時";
  m = date.getMinutes();
  if ( !zero_suppress &#038;&#038; m < 10 ) html += "0";
  html += m + "分";
  var s = date.getSeconds();
  if ( !zero_suppress &#038;&#038; s < 10 ) html += "0";
  html += s + "秒";
  return html;
};

function makeSummary( url ) {
  var summaries = [];
  var doc = Xml.parse( UrlFetchApp.fetch( url ).getContentText() );
  // title of the feed
  var entries = doc.getElement().getElements( "entry" );
  for ( var entry in entries ) {
    // date of a entry
    var date = new Date( entries[entry].getElement( "published" ).getText() );
    if ( japanese_date_format ) {
      date = getJapaneseFormatDate( date );
    }
    // link and title of a entry
    var link = LINK_URL + "/" + entries[ entry ].getElement( SITE_NAMESPACE_URL, "pageName" ).getText();
    var title = entries[ entry ].getElement( "title" ).getText();
    summaries.push([date, title, link]);
  }
  return summaries;
}

function debug() {
  var content = makeSummary( FEED_URL );
  Logger.log( content );
  MailApp.sendEmail( MAIL, DEBUG_MAIL_SUBJECT, Logger.getLog() );
}

function doGet(e) {
  var app = UiApp.createApplication();
  app.setStyleAttribute("backgroundColor", "transparent");
  var summaries = makeSummary( FEED_URL );
  for ( var entry in summaries ) {
    var h_panel = app.createHorizontalPanel();
    h_panel.setStyleAttribute("backgroundColor", "transparent");
    var date = app.createLabel( summaries[entry][0] );
    var title = app.createAnchor( summaries[entry][1], summaries[entry][2] );
    h_panel.add(date);
    h_panel.add(title);
    h_panel.setSpacing(1);
    app.add(h_panel);
  }
  return app;
}
</pre>
<p>doGet()内で、UiAppのcreateApplication()を使ってUiIinstace型のインスタンスの属性値を変更したり、インスタンスにウィジットのパネルやラベルを追加して、最後にインスタンスのポインタを返すとウェブサーバとブラウザでよろしくやってくれるようになっている。今回はウィジットのインスタンスを横に並べるパネルに、日付を表示するラベルとリンクを張るアンカーを追加した。背景色を変更したかったのだが、どうしてもできなかった。スタイルシートをとことん<strong>イジル</strong>と変更できそうなのだが、各インスタンスに対して属性を変更するsetStyleAttribute()で背景色に透明を指定しても白色のままであった。これ以外の方法で設定するのであればおそらく面倒くさいのではないかと想像する。</p>
<p>ウィジットを利用したとき、ページで利用されているスタイルシートを利用させたいのだが、どうやら利用していないようである。この課題についても調べたかったのであるが、背景色を簡単に変更できなかったのでこれ以上の調査を中止して、別の方法を考えた。それがクライアントサイドで処理させるGoogle Gadgetを利用する方法である（つづく）。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.esashi.mobi/2012/02/27/253/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

