Showing posts with label FeedKraft. Show all posts
Showing posts with label FeedKraft. Show all posts

Friday, July 24, 2009

a bookmarklet which loaded external script and open in another window


I updated the bookmarklet for FeedKraft. Changes are:
* Now it work even alternate links have relative path (URI).
* Open feedkraft in another window.

To keep maintainability, I decided to split complex part of the scripts into a external js file. However, Safari 4 seems to just ignore window.open() in a external loaded script, and Firefox 3.5 asks users whether popup a window or not.

To get those features work for Safari and Firefox, I struggled with javascript, but I got it.

FeedKraftbookmarklet を更新して
* alternate link の href が相対パス(URL) でも登録できるように
* 別 window で開くように
しました。

"/feed/atom.xml" のようなパスをURLに変換するコードはそれなりに長くなるので bookmarklet の javascript: 以下に続けて書くメンテしずらいので、外部 js ファイルをロードするようにしました。
しかし、外部 js ファイルからでは 別 window で開くための window.open() を実行しても Safari 4 では何も起きないし、 Firefox 3.5 では ポップアップブロックの確認が生じてしまいます。

試行錯誤の末、以下のようなコードになりました(見やすいように空白や改行を入れてます)。



javascript:
void(w = window.open());
void(e = document.createElement('script'));
void(e.src = 'http://feedkraft.com/bookmarklet.js');
void(e.addEventListener('load', function(){ w.location = FeedKraft.bookmarkURL()}, false));
void(document.body.appendChild(e));



Why does window.open() first is to avoid calling it in load event handler which behave like external file (I mean can't open a window). Annoying void() is for Firefox. Without enclosing a sentence with void(), the script will return with result of the sentence.

I'm not a Javascript ninja. I never think that this is the best solution. Please give me advice if you have idea.

load イベントで直接 window.open() すると外部 js ファイルで実行したときと同じ挙動になってしまうため、あらかじめ window を開いてから location を変更してます。
理屈わかってませんが、 void() で囲っていない文があると Firefox ではそこでストップして、その文の結果が表示されてしまいます。

Javascript は苦手なのでもっと良い方法があったら教えて下さい。

Friday, July 17, 2009

FeedKraft prototype version


I just announce that my new application service, FeedKraft, is available. As you notice from the name, it deals RSS and Atom feeds. I said it deals feeds, but for now, there is one function, feed filtering.

As for the filter function, we know there are many other filter services out there. I think FeedKraft is easier to use than Yahoo! Pipes, and little bit more powerful than FeedRinse.

The source code, implemented in Ruby on Rails, is also available here on GitHub.

Anyway, give it a try.


FeedKraft という RSS や Atom フィードを扱うサービスを公開しました。
が、今のところは外部のフィードにフィルターをかける機能しかありません。

フィードのフィルターに関しては、同様の機能を提供するサービスはいくつかありますが、Yahoo Pipe より簡単で、 FeedRinse よりちょっと強力かと思います。

特徴としては、
* 入力フィードを解析してファイルター可能な候補を選択できる (例: このブログの Atom フィードをカテゴリ Rails でフィルター)
* 作成したフィルターは公開され、他のユーザーが作成したフィルターも利用できる
* フィルター結果の feed はログイン状態での購読(subscribe)により生成されるURLにより参照する必要があるので、何人購読しているか分かる

どんだけ意味があるかわかりませんが、フィルター結果などのフィードが公開されることで、フィード提供側と利用側によるコミュニティ的な要素が広がるといいかなと思ったりもしてます。

ちなみに、Rails で実装してます。ソースも GitHub にありますので興味があったらどうぞ。