■ Blackbird Pie – Twitter Media
「Blackbird Pie」を使うとある人の1ツイートをブログに引用することが出来ます。
特徴的なのは、デザインに優れているところ。
横幅が可変式になっているのでどんなサイズでも綺麗に表示してくれます。
例えばこんな感じ。
蚊に刺されたなう
ところがライブドアブログ(livedoor Blog)のHTMLエディタを使っているとこううまくはいきません。
実はHTMLエディタには無駄なタグを削除してくれる機能がついているのです。
上記ツイート表示のソースは本来ですと以下のようになっています。
<!-- http://twitter.com/Norisa/status/18828316446 --> <style type='text/css'>.bbpBox18828316446 {background:url(http://s.twimg.com/a/1281028705/images/themes/theme1/bg.png) #C0DEED;padding:20px;} p.bbpTweet{background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:18px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px} p.bbpTweet span.metadata{display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6} p.bbpTweet span.metadata span.author{line-height:19px} p.bbpTweet span.metadata span.author img{float:left;margin:0 7px 0 0px;width:38px;height:38px} p.bbpTweet a:hover{text-decoration:underline}p.bbpTweet span.timestamp{font-size:12px;display:block}</style> <div class='bbpBox18828316446'><p class='bbpTweet'>蚊に刺されたなう<span class='timestamp'><a title='Sun Jul 18 08:59:01 +0000 2010' href='http://twitter.com/Norisa/status/18828316446'>less than a minute ago</a> via <a href="http://twitter.com/" rel="nofollow">Twitter for iPhone</a></span><span class='metadata'><span class='author'><a href='http://twitter.com/Norisa'><img src='http://a2.twimg.com/profile_images/378732498/blog_____normal.jpg' /></a><strong><a href='http://twitter.com/Norisa'>のりさ</a></strong><br/>Norisa</span></span></p></div> <!-- end of tweet -->
ところがlivedoorブログのHTMLエディタを使うと以下のように自動的に改変されます。
<!-- http://twitter.com/Norisa/status/18828316446 --> <!-- .bbpBox18828316446 {background:url(http://s.twimg.com/a/1281028705/images/themes/theme1/bg.png) #C0DEED;padding:20px;} p.bbpTweet{background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:18px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px} p.bbpTweet span.metadata{display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6} p.bbpTweet span.metadata span.author{line-height:19px} p.bbpTweet span.metadata span.author img{float:left;margin:0 7px 0 0px;width:38px;height:38px} p.bbpTweet a:hover{text-decoration:underline}p.bbpTweet span.timestamp{font-size:12px;display:block} --> <div class="bbpBox18828316446"><p class="bbpTweet">蚊に刺されたなう<span class="timestamp"><a title="Sun Jul 18 08:59:01 +0000 2010" href="http://twitter.com/Norisa/status/18828316446">less than a minute ago</a> via <a rel="nofollow" href="http://twitter.com/">Twitter for iPhone</a></span><span class="metadata"><span class="author"><a href="http://twitter.com/Norisa"><img src="http://a2.twimg.com/profile_images/378732498/blog_____normal.jpg" alt="" /></a><strong><a href="http://twitter.com/Norisa">のりさ</a></strong><br />Norisa</span></span></p></div> <!-- end of tweet -->
分かりやすいように変わってしまった部分を太字赤文字にしました。つまり「style」タグをコメントに変えてしまうようなのです。
(シングルクォーテーションをダブルクォーテーションに変えていますがここでは割愛)
だからといって、 「Blackbird Pie」を使うときだけ「シンプルエディタ」に変えるのも面倒。
そこで、なるべく余計な作業をせずに「Blackbird Pie」で作ったソースをlivedoorブログのHTMLエディタで使う方法を考えてみました。
まずはデザインテンプレートのCSSに「Blackbird Pie」で作ったソースの共通CSSの部分を書き込みます。
書き足した部分はこんな感じになります。(上記ソースの斜体部分)
/* Blackbird Pie対応 */
p.bbpTweet{background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:18px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px} p.bbpTweet span.metadata{display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6} p.bbpTweet span.metadata span.author{line-height:19px} p.bbpTweet span.metadata span.author img{float:left;margin:0 7px 0 0px;width:38px;height:38px} p.bbpTweet a:hover{text-decoration:underline}p.bbpTweet span.timestamp{font-size:12px;display:block}
p.bbpTweet{background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:18px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px} p.bbpTweet span.metadata{display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6} p.bbpTweet span.metadata span.author{line-height:19px} p.bbpTweet span.metadata span.author img{float:left;margin:0 7px 0 0px;width:38px;height:38px} p.bbpTweet a:hover{text-decoration:underline}p.bbpTweet span.timestamp{font-size:12px;display:block}
つぎにブログに書き込むソースをちょっといじります。
早速ソースを紹介。
<div style="background:url(http://s.twimg.com/a/1281028705/images/themes/theme1/bg.png) #C0DEED;padding:20px;"><p class="bbpTweet">蚊に刺されたなう<span class="timestamp"><a title="Sun Jul 18 08:59:01 +0000 2010" href="http://twitter.com/Norisa/status/18828316446">less than a minute ago</a> via <a rel="nofollow" href="http://twitter.com/">Twitter for iPhone</a></span><span class="metadata"><span class="author"><a href="http://twitter.com/Norisa"><img src="http://a2.twimg.com/profile_images/378732498/blog_____normal.jpg" alt="" /></a><strong><a href="http://twitter.com/Norisa">のりさ</a></strong><br />Norisa</span></span></p></div>
後半の<DIV>に囲まれた部分のみ抽出します。ポイントは最初のDIVの属性、太文字の部分。共通CSSでない部分をタグ内にstyle属性として書き込んでいます。
つまり、上記ソースで青文字にした部分をDIVに反映させる必要があるということです。
具体的にはちょっとしたコピー&ペーストで作業は終了します。
- まずはDIVに囲まれた後半部分のみコピーしてHTMLソース編集モードでペースト。
- 上記ソース斜体青文字の部分をコピー。
- 最上位DIVの「class」を「style」に書き換える。
- ダブルクォーテーション「"」に囲まれた部分を選択してペースト
これでlivedoorブログのHTMLエディタでも比較的簡単に「Blackbird Pie」で作ったソースが使えると思います。
まあ、シンプルエディタを使うってのが一番手っ取り早いっちゃ手っ取り早いのですが。。