- 2011-11-28 (月) 16:28
- JavaScript
ただの2番煎じですが、google buzz がサービス停止するということで、google buzz のつぶやきをエクスポートしたものをストリームっぽく垂れ流すようにしました。
http://www.toshipon.com/sample/buzz/buzz/index.html
以下で google buzz のつぶやきをエクスポートできます。
https://www.google.com/takeout/
まず、ひとつひとつのつぶたきが日本語名のhtmlファイルなので、ファイル作成日でrenameします。
count = 0
Dir::foreach('./buzz') { |f|
count = count + 1
time = Time.now
from = './buzz/' + f
mt = File::mtime('./buzz/'.concat(f))
to = './buzz/' + format("%04d", mt.year) + format("%02d", mt.month) + format("%02d", mt.day) + format("%02d", mt.min) + format("%02d", mt.sec) + ".html"
if File::ftype(from) == "file"
File::rename from, to
end
}
renameしたhtmlファイルのファイル名を一括でfiles.jsonの中に一覧で取り込み
文字列置換で適当にjsonフォーマットに変換します。
ls >> files.json
その後、jsでhtmlファイルを読み込み垂れ流してみます。
$(function(){
console.log("script.js start");
$.ajax({
url : "http://www.toshipon.com/sample/buzz/buzz/buzz/files.json",
//dataType : "json",
success : function(file){
file = JSON.parse(file);
popBuzz(file);
}
});
var i = 0;
function popBuzz(file) {
if (file.length === i+1){ return; }
setTimeout(function(){
$("#content").prepend($("
").load("http://www.toshipon.com/sample/buzz/buzz/buzz/"+ file[i]));
i++;
if ($('#content li').length > 10){$('#content li:last').remove();}
popBuzz(file);
}, 2000);
}
});
簡単ですね。
ソースはこちら。 https://github.com/toshipon/buzz
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://blog.toshipon.com/2011/11/28/google-buzz-%e3%81%ae%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8d%e3%82%92%e5%9e%82%e3%82%8c%e6%b5%81%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f/trackback/
- Listed below are links to weblogs that reference
- Google Buzz のつぶやきを垂れ流してみた from toshipon@sketch.book/blog