2003-09-29 (Mon)
▲ include プラグイン
VikiWiki のimport プラグインが羨ましくなり、himi さんからの要望もあったので Hiki 用の include プラグインをでっちあげてみた。
# $Id $ # Copyright (C) 2003 Koichiro Ohba <koichiro@meadowy.org> def include( page ) @content = '' return '' unless @db.exist?( page ) include_content( page ) @content end def include_content( page ) include_page_backup( page ) parser = Parser::new tokens = parser.parse( @db.load( page ) ) formatter = HikiFormatter::new( tokens, @db, @db.plugin ) @content << formatter.apply_tdiary_theme_include(formatter.to_s).sanitize include_page_restore end def include_page_backup( page ) @tmp_page = @page @page = page end def include_page_restore @page = @tmp_page end
hiki/hiki_formatter.rb への修正。
diff -c -r1.1.2.2 hiki_formatter.rb
*** hiki/hiki_formatter.rb 31 May 2003 10:13:01 -0000 1.1.2.2
--- hiki/hiki_formatter.rb 22 Oct 2003 15:16:02 -0000
***************
*** 15,20 ****
--- 15,42 ----
if /(.*?)(<h2>.+)/ =~ line
section << $1
if section.size > 0 or first_f
+ tdiary_html << tdiary_day(title, section)
+ section = ''
+ end
+ first_f = true
+ title = $2
+ else
+ section << line
+ end
+ end
+ tdiary_html << tdiary_day(title, section)
+ end
+
+ def apply_tdiary_theme_include(html)
+ section = ''
+ title = ''
+ tdiary_html = ''
+ first_f = false
+
+ html.each do |line|
+ if /(.*?)(<h2>.+)/ =~ line
+ section << $1
+ if section.size > 0 or first_f
tdiary_html << tdiary_section(title, section)
section = ''
end
***************
*** 30,42 ****
private
def tdiary_section(title, section)
<<"EOS"
- <div class="day">
#{title}
<div class="body">
<div class="section">
#{section}
</div>
</div>
</div>
EOS
end
--- 52,70 ----
private
def tdiary_section(title, section)
<<"EOS"
#{title}
<div class="body">
<div class="section">
#{section}
</div>
</div>
+ EOS
+ end
+
+ def tdiary_day(title, section)
+ <<"EOS"
+ <div class="day">
+ #{tdiary_section(title, section)}
</div>
EOS
end
使い方は埋め込みたい場所でページ名を指定する。
{{include('SandBox')}}
実行例 about:SandBox
セクションが分かれるようにしたほうがよいのかな。 <div class="day"> が入れ子にならないように対処。
あとこのままでは include 先のプラグインが元ページの情報で実行されてしまうために BBS プラグインなどが正常に動かない。include 先に合わせて Plugin クラスを初期化するとかしないとイカンかも。安直に対応。
2007-09-29 (Sat)
▲ BookScope (2)
お陰さまで調査機関GのBookScope界ランキングでトップに。ありがたや。
小関さんの
本のバーコードの画像を携帯からメールで送ると「バーコード認識」によりその本を自分の蔵書に登録してくれる。
これは「あ」の人から聞いた「Kinjiro」が近いかも。そんな小関さんでも大丈夫です。BookScope設計段階からここへんを参考にさせて頂いた仮想ユーザーですから安心です(謎)。
B000I5O8I2は、PCから見ると普通のUSBキーボードとして認識するので、可能ならウィルコムのZero3に繋いで書斎に持ち込みBookScopeへ登録できたらいいなーとか、あの人と妄想。BookScopeのためにバーコードリーダを買いましたという人が現れることが野望なんですが、民生品ではないので高いですよね... B0002A9WR0のがちょっと安いか。3000円くらいであるといいのだが。
カヲルくんも唐突に上位に躍り出た登録数でびっくり。ありがとう。いったいどんなマジックが...
最近の修正や変更点をメモしておきます。
- ユーザー毎の新着Atomフィードのリンクがおかしくなっていたのを修正。
- 「あ」の人より、Amazonから蔵書登録するBookmarkletを提供してもらったので取り込んだ。Amazonの商品表示画面から一発登録できるようになった。蔵書登録の下のほうに各ユーザー向けのBookmarkletを表示してます。>あの人thx!
- 誰がどの本を持っているか見る機能を追加。本の総合情報から見れます。
- 本にタグを付ける。タグで絞込み検索する。
など。細かい使い勝手の修正。





