tdiary-contrib 3.2.2.20130518
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +35 -0
- data/README.en.md +12 -0
- data/README.md +13 -0
- data/Rakefile +41 -0
- data/doc/en/filter/spambayes.txt +3 -0
- data/doc/en/plugin.txt +1 -0
- data/doc/en/style/hatena.txt +10 -0
- data/doc/en/style/markdown.txt +16 -0
- data/doc/en/util.txt +1 -0
- data/doc/ja/filter/antirefspam.history.txt +59 -0
- data/doc/ja/filter/antirefspam.txt +86 -0
- data/doc/ja/filter/comment_key.ja.html +182 -0
- data/doc/ja/filter/spambayes.txt +3 -0
- data/doc/ja/plugin/add_bookmark.txt +50 -0
- data/doc/ja/plugin/category_to_tag.txt +21 -0
- data/doc/ja/plugin/cocoment.txt +31 -0
- data/doc/ja/plugin/google_adsense.txt +25 -0
- data/doc/ja/plugin/google_analytics.txt +7 -0
- data/doc/ja/plugin/image_detail.txt +69 -0
- data/doc/ja/plugin/image_gps.txt +36 -0
- data/doc/ja/plugin/image_gps2.txt +41 -0
- data/doc/ja/plugin/livedoor_weather.txt +105 -0
- data/doc/ja/plugin/opensearch_ad.txt +16 -0
- data/doc/ja/plugin/section_footer.txt +84 -0
- data/doc/ja/plugin/select_theme.txt +1 -0
- data/doc/ja/plugin.txt +13 -0
- data/doc/ja/style/hatena.txt +10 -0
- data/doc/ja/style/markdown.txt +13 -0
- data/doc/ja/util.txt +12 -0
- data/filter/antirefspam.rb +263 -0
- data/filter/commentkey.rb +29 -0
- data/filter/commentsize.rb +18 -0
- data/filter/hidecomment.rb +13 -0
- data/filter/iplookup.rb +55 -0
- data/filter/plugin/antirefspam.rb +59 -0
- data/filter/plugin/commentkey.rb +58 -0
- data/filter/plugin/commentsize.rb +12 -0
- data/filter/plugin/en/iplookup.rb +9 -0
- data/filter/plugin/en/spambayes.rb +123 -0
- data/filter/plugin/iplookup.rb +39 -0
- data/filter/plugin/ja/antirefspam.rb +91 -0
- data/filter/plugin/ja/commentkey.rb +17 -0
- data/filter/plugin/ja/commentsize.rb +6 -0
- data/filter/plugin/ja/iplookup.rb +9 -0
- data/filter/plugin/ja/spambayes.rb +124 -0
- data/filter/plugin/spambayes.rb +501 -0
- data/filter/plugin/zh/iplookup.rb +9 -0
- data/filter/rblcheck.rb +36 -0
- data/filter/spambayes.rb +535 -0
- data/filter/spamlookup.rb +37 -0
- data/io/dbi_io/ChangeLog +19 -0
- data/io/dbi_io/README.ja +39 -0
- data/io/dbi_io/dbi_io.rb +181 -0
- data/io/dbi_io/plugin/refererDbiIO.rb +76 -0
- data/io/dbi_io/tdiary_table.sql +42 -0
- data/js/appstore.js +109 -0
- data/js/datepicker.js +69 -0
- data/js/editor.js +82 -0
- data/js/flickr.js +157 -0
- data/js/image_ex.js +79 -0
- data/js/jquery.socialbutton.js +842 -0
- data/js/nicovideo.js +17 -0
- data/js/picasa.js +322 -0
- data/js/plugin_checker.js +71 -0
- data/js/prettify/lang-apollo.js +2 -0
- data/js/prettify/lang-clj.js +18 -0
- data/js/prettify/lang-css.js +2 -0
- data/js/prettify/lang-go.js +1 -0
- data/js/prettify/lang-hs.js +2 -0
- data/js/prettify/lang-lisp.js +3 -0
- data/js/prettify/lang-lua.js +2 -0
- data/js/prettify/lang-ml.js +2 -0
- data/js/prettify/lang-n.js +4 -0
- data/js/prettify/lang-proto.js +1 -0
- data/js/prettify/lang-scala.js +2 -0
- data/js/prettify/lang-sql.js +2 -0
- data/js/prettify/lang-tex.js +1 -0
- data/js/prettify/lang-vb.js +2 -0
- data/js/prettify/lang-vhdl.js +3 -0
- data/js/prettify/lang-wiki.js +2 -0
- data/js/prettify/lang-xq.js +3 -0
- data/js/prettify/lang-yaml.js +2 -0
- data/js/prettify/prettify.css +1 -0
- data/js/prettify/prettify.js +28 -0
- data/js/referer.js +17 -0
- data/js/show_and_hide.js +39 -0
- data/js/socialbutton.js +126 -0
- data/js/twitter_anywhere.js +28 -0
- data/js/yahoo_kousei.js +21 -0
- data/lib/bayes/convert.rb +34 -0
- data/lib/bayes.rb +232 -0
- data/lib/exifparser/BUGS +1 -0
- data/lib/exifparser/ChangeLog +169 -0
- data/lib/exifparser/README +15 -0
- data/lib/exifparser/install.rb +1015 -0
- data/lib/exifparser/lib/exifparser/makernote/canon.rb +502 -0
- data/lib/exifparser/lib/exifparser/makernote/fujifilm.rb +415 -0
- data/lib/exifparser/lib/exifparser/makernote/minolta.rb +84 -0
- data/lib/exifparser/lib/exifparser/makernote/mk_nikonflensname.rb +39 -0
- data/lib/exifparser/lib/exifparser/makernote/nikon.rb +267 -0
- data/lib/exifparser/lib/exifparser/makernote/nikon2.rb +581 -0
- data/lib/exifparser/lib/exifparser/makernote/nikonflensname.rb +438 -0
- data/lib/exifparser/lib/exifparser/makernote/olympus.rb +225 -0
- data/lib/exifparser/lib/exifparser/makernote/prove.rb +84 -0
- data/lib/exifparser/lib/exifparser/makernote/sigma.rb +237 -0
- data/lib/exifparser/lib/exifparser/pre-setup.rb +1 -0
- data/lib/exifparser/lib/exifparser/scan.rb +278 -0
- data/lib/exifparser/lib/exifparser/tag.rb +2298 -0
- data/lib/exifparser/lib/exifparser/thumbnail.rb +76 -0
- data/lib/exifparser/lib/exifparser/utils.rb +88 -0
- data/lib/exifparser/lib/exifparser.rb +265 -0
- data/lib/exifparser/sample/exifview.rb +279 -0
- data/lib/tdiary-contrib.rb +19 -0
- data/lib/wgs2tky.rb +93 -0
- data/misc/section_footer2/buzzurl.yaml +6 -0
- data/misc/section_footer2/fc2.yaml +6 -0
- data/misc/section_footer2/ldc.yaml +6 -0
- data/misc/section_footer2/retweet.yaml +7 -0
- data/misc/section_footer2/twitter.yaml +7 -0
- data/misc/section_footer2/yahoo.yaml +6 -0
- data/misc/tdiarygraph/tdiarygraph120x90e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph125x125e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph240x180e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph468x60e.swf +0 -0
- data/misc/tdiarygraph/tdiarygraph728x90e.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x125r.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x125r7.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x125s.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes125x30.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes234x30.swf +0 -0
- data/misc/tdiarytimes/tdiarytimes468x30.swf +0 -0
- data/plugin/add_bookmark.rb +89 -0
- data/plugin/apple_webclip.rb +26 -0
- data/plugin/appstore.rb +47 -0
- data/plugin/bigpresen.rb +86 -0
- data/plugin/bitly.rb +39 -0
- data/plugin/bootstrap-navi.rb +54 -0
- data/plugin/canonical.rb +9 -0
- data/plugin/category_similar.rb +73 -0
- data/plugin/category_to_tag.rb +60 -0
- data/plugin/category_to_tagcloud.rb +172 -0
- data/plugin/cocomment.rb +37 -0
- data/plugin/code-prettify.rb +23 -0
- data/plugin/coderwall.rb +34 -0
- data/plugin/datepicker.rb +28 -0
- data/plugin/day2section.rb +20 -0
- data/plugin/del_footer.rb +111 -0
- data/plugin/description_from_body.rb +23 -0
- data/plugin/development.rb +16 -0
- data/plugin/editor.rb +11 -0
- data/plugin/en/add_bookmark.rb +20 -0
- data/plugin/en/del_footer.rb +10 -0
- data/plugin/en/git-register.rb +3 -0
- data/plugin/en/livedoor_weather.rb +25 -0
- data/plugin/en/microsummary.rb +18 -0
- data/plugin/en/nicovideo.rb +38 -0
- data/plugin/en/openid.rb +8 -0
- data/plugin/en/section_footer.rb +6 -0
- data/plugin/en/section_footer2.rb +3 -0
- data/plugin/en/socialbutton.rb +5 -0
- data/plugin/everytrail.rb +39 -0
- data/plugin/facebook_comments.rb +59 -0
- data/plugin/flickr.rb +209 -0
- data/plugin/gist.rb +16 -0
- data/plugin/git-register.rb +240 -0
- data/plugin/github_badge.rb +27 -0
- data/plugin/github_link.rb +9 -0
- data/plugin/goo_gl.rb +42 -0
- data/plugin/google_adsense.rb +132 -0
- data/plugin/google_analytics.rb +39 -0
- data/plugin/google_map.rb +168 -0
- data/plugin/google_sitemaps.rb +60 -0
- data/plugin/google_webmaster.rb +22 -0
- data/plugin/hatena_bookmark_nocomment.rb +9 -0
- data/plugin/hatena_star.rb +66 -0
- data/plugin/hb_footer.rb +255 -0
- data/plugin/hb_footer4sec.rb +244 -0
- data/plugin/hb_footer4sec_js.rb +30 -0
- data/plugin/hide_comment_form.rb +4 -0
- data/plugin/hide_sidebar_iphone.rb +21 -0
- data/plugin/iddy.rb +81 -0
- data/plugin/image_detail.rb +143 -0
- data/plugin/image_ex.rb +462 -0
- data/plugin/image_gps.rb +128 -0
- data/plugin/inline_wiki.rb +6 -0
- data/plugin/instagr.rb +64 -0
- data/plugin/ja/add_bookmark.rb +20 -0
- data/plugin/ja/del_footer.rb +10 -0
- data/plugin/ja/flickr.rb +62 -0
- data/plugin/ja/git-register.rb +3 -0
- data/plugin/ja/google_sitemaps.rb +35 -0
- data/plugin/ja/livedoor_weather.rb +25 -0
- data/plugin/ja/microsummary.rb +18 -0
- data/plugin/ja/nicovideo.rb +41 -0
- data/plugin/ja/openid.rb +7 -0
- data/plugin/ja/section_footer.rb +6 -0
- data/plugin/ja/section_footer2.rb +4 -0
- data/plugin/ja/socialbutton.rb +6 -0
- data/plugin/jdate.rb +20 -0
- data/plugin/jholiday.rb +16 -0
- data/plugin/jmonth.rb +20 -0
- data/plugin/jquery_ui_theme.rb +55 -0
- data/plugin/jroku.rb +28 -0
- data/plugin/jyear.rb +37 -0
- data/plugin/latlonglab_route.rb +25 -0
- data/plugin/lazy_referer.rb +38 -0
- data/plugin/livedoor_weather.rb +180 -0
- data/plugin/make_link.rb +44 -0
- data/plugin/makerss_category.rb +43 -0
- data/plugin/makerss_comment.rb +35 -0
- data/plugin/microsummary.rb +62 -0
- data/plugin/mm_footer.rb +215 -0
- data/plugin/monthly_autopagerize.rb +67 -0
- data/plugin/my_hotentry.rb +132 -0
- data/plugin/navi_day.rb +118 -0
- data/plugin/navi_this_month.rb +15 -0
- data/plugin/nicovideo.rb +115 -0
- data/plugin/notify_miniblog.rb +134 -0
- data/plugin/ogp.rb +55 -0
- data/plugin/ohmsha_estore.rb +71 -0
- data/plugin/openid.rb +90 -0
- data/plugin/opensearch_ad.rb +33 -0
- data/plugin/picasa.rb +56 -0
- data/plugin/plugin_checker.rb +41 -0
- data/plugin/popit.rb +22 -0
- data/plugin/prettify.rb +19 -0
- data/plugin/prezi.rb +10 -0
- data/plugin/profile.rb +222 -0
- data/plugin/puboo.rb +93 -0
- data/plugin/pygments_css.rb +76 -0
- data/plugin/rating.rb +419 -0
- data/plugin/recent_estraier.rb +50 -0
- data/plugin/recent_tweet.rb +71 -0
- data/plugin/retweet.rb +86 -0
- data/plugin/rubykaigi.rb +99 -0
- data/plugin/search-bing.rb +87 -0
- data/plugin/search-default.rb +264 -0
- data/plugin/search-google-custom.rb +60 -0
- data/plugin/search-yahoo-websearch.rb +121 -0
- data/plugin/search-yahoo.rb +109 -0
- data/plugin/section_footer.rb +195 -0
- data/plugin/section_footer2.rb +278 -0
- data/plugin/section_permalink.rb +73 -0
- data/plugin/section_permalink_anchor.rb +39 -0
- data/plugin/select_style.rb +42 -0
- data/plugin/select_theme.rb +90 -0
- data/plugin/show_and_hide.rb +77 -0
- data/plugin/slideshare.rb +10 -0
- data/plugin/socialbutton.rb +60 -0
- data/plugin/tatsu_zine.rb +93 -0
- data/plugin/tdiarygraph_flashstyle.rb +296 -0
- data/plugin/tdiarytimes.rb +166 -0
- data/plugin/tdiarytimes2.rb +406 -0
- data/plugin/tdiarytimes_flashstyle.rb +263 -0
- data/plugin/tdiarytimes_textstyle.rb +290 -0
- data/plugin/title_anchor.rb +16 -0
- data/plugin/tweet_quote.rb +106 -0
- data/plugin/twitpic.rb +10 -0
- data/plugin/twitter.rb +46 -0
- data/plugin/twitter_anywhere.rb +209 -0
- data/plugin/twitter_badge.rb +42 -0
- data/plugin/twitter_js.rb +59 -0
- data/plugin/ustream.rb +19 -0
- data/plugin/vimeo.rb +14 -0
- data/plugin/volatile.rb +89 -0
- data/plugin/vote.rb +100 -0
- data/plugin/wikiloc.rb +27 -0
- data/plugin/windex.rb +512 -0
- data/plugin/yahoo_kousei.rb +79 -0
- data/plugin/yahoo_map.rb +97 -0
- data/plugin/youtube.rb +33 -0
- data/plugin/yshop.rb +189 -0
- data/plugin/zenback.rb +46 -0
- data/spec/apple_webclip_spec.rb +46 -0
- data/spec/fixtures/friendfeed.xml +2 -0
- data/spec/fixtures/github.json +1 -0
- data/spec/fixtures/twitter.xml +73 -0
- data/spec/gist_spec.rb +16 -0
- data/spec/github_link_spec.rb +39 -0
- data/spec/google_analytics_spec.rb +60 -0
- data/spec/jdate_spec.rb +23 -0
- data/spec/jmonth_spec.rb +28 -0
- data/spec/jyear_spec.rb +21 -0
- data/spec/my_hotentry_spec.rb +78 -0
- data/spec/openid_spec.rb +246 -0
- data/spec/opensearch_ad_spec.rb +50 -0
- data/spec/profile_spec.rb +88 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec_helper.rb +223 -0
- data/spec/title_anchor_spec.rb +39 -0
- data/spec/twitter_js_spec.rb +116 -0
- data/spec/youtube_spec.rb +20 -0
- data/style/hatena_style.rb +1011 -0
- data/style/markdown_style.rb +239 -0
- data/style/wikiext_style.rb +21 -0
- data/tdiary-contrib.gemspec +25 -0
- data/util/clean-spam/README.ja +1 -0
- data/util/clean-spam/tdiary-comment-clean +46 -0
- data/util/clean-spam/tdiary-comment-clean2 +81 -0
- data/util/clean-spam/tdiary-referer-clean +46 -0
- data/util/convert_pstore.rb +82 -0
- data/util/estraier-search/ChangeLog +36 -0
- data/util/estraier-search/README.ja +114 -0
- data/util/estraier-search/en/estraier-register.rb +3 -0
- data/util/estraier-search/estraier-register.rb +298 -0
- data/util/estraier-search/estraier-search.rb +273 -0
- data/util/estraier-search/estraier.rhtml +73 -0
- data/util/estraier-search/estraier.rxml +23 -0
- data/util/estraier-search/i.estraier.rhtml +31 -0
- data/util/estraier-search/ja/estraier-register.rb +3 -0
- data/util/image-gallery/README.ja +27 -0
- data/util/image-gallery/image-gallery.rb +523 -0
- data/util/image-gallery/image-gallery.rb.euc-jp +523 -0
- data/util/image-gallery/js/SmoothGallery/Changelog +52 -0
- data/util/image-gallery/js/SmoothGallery/css/ReMooz.css +186 -0
- data/util/image-gallery/js/SmoothGallery/css/img/carrow1.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/carrow2.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/closebox.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/closebox.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche1.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche1.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche2.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/fleche2.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/loading-bar-black.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/open.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/open.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_e.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_n.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_ne.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_nw.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_s.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_se.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_sw.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_w.png +0 -0
- data/util/image-gallery/js/SmoothGallery/css/img/spinner.gif +0 -0
- data/util/image-gallery/js/SmoothGallery/css/jd.gallery.css +371 -0
- data/util/image-gallery/js/SmoothGallery/css/layout.css +91 -0
- data/util/image-gallery/js/SmoothGallery/license.txt +621 -0
- data/util/image-gallery/js/SmoothGallery/resizer.php +113 -0
- data/util/image-gallery/js/SmoothGallery/scripts/Changelog +52 -0
- data/util/image-gallery/js/SmoothGallery/scripts/History.Routing.js +126 -0
- data/util/image-gallery/js/SmoothGallery/scripts/History.js +109 -0
- data/util/image-gallery/js/SmoothGallery/scripts/ReMooz.js +364 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.js +843 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.set.js +183 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.transitions.js +90 -0
- data/util/image-gallery/js/SmoothGallery/scripts/jdgalleryresize.js +828 -0
- data/util/image-gallery/js/SmoothGallery/scripts/license.txt +621 -0
- data/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2-more.js +103 -0
- data/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2.1-core-yc.js +349 -0
- data/util/image-gallery/js/SmoothGallery/scripts/resizer.php +113 -0
- data/util/image-gallery/misc/plugin/recent_image.rb +406 -0
- data/util/image-gallery/skel/gallery.rhtml +154 -0
- data/util/image-gallery/skel/gallery.rhtml.euc-jp +154 -0
- data/util/image-gallery/tdiary.conf.igsample +8 -0
- data/util/image-gallery/theme/image-gallery.css +85 -0
- data/util/image2flickr.rb +282 -0
- data/util/posttdiary/README.ja +12 -0
- data/util/posttdiary/posttdiary-ex.rb +1155 -0
- data/util/posttdiary/posttdiary.rb +245 -0
- data/util/rast-search/ChangeLog +55 -0
- data/util/rast-search/README.ja +99 -0
- data/util/rast-search/en/rast-register.rb +3 -0
- data/util/rast-search/i.rast.rhtml +33 -0
- data/util/rast-search/ja/rast-register.rb +3 -0
- data/util/rast-search/rast-register.rb +326 -0
- data/util/rast-search/rast-search.rb +249 -0
- data/util/rast-search/rast.rhtml +66 -0
- data/util/rast-search/rast.rxml +21 -0
- data/util/section_link/README +11 -0
- data/util/section_link/misc/plugin/section_link.rb +68 -0
- data/util/section_link/misc/plugin/section_link_anchor.rb +38 -0
- data/util/section_link/tdiary/tdiary_day_ext.rb +21 -0
- data/util/section_link/tdiary/tdiaryext_style.rb +36 -0
- data/util/section_link/tdiary/wikiext_style.rb +36 -0
- data/util/tdiary-for-ruby1.9/compatible.rb +97 -0
- data/util/tdiary-for-ruby1.9/tdiary-2.2.0.patch +98 -0
- data/util/tdiary-for-ruby1.9/tdiary-2.3.1.patch +212 -0
- data/util/tdiary-grep/README +4 -0
- data/util/tdiary-grep/grep.rb +445 -0
- data/util/tdiary-mode/http.el +130 -0
- data/util/tdiary-mode/tdiary-mode.el +613 -0
- data/util/tdiary-vim/ChangeLog +25 -0
- data/util/tdiary-vim/README +60 -0
- data/util/tdiary-vim/tdiary.vim +350 -0
- data/util/tdiarysearch/README.en +53 -0
- data/util/tdiarysearch/README.ja +99 -0
- data/util/tdiarysearch/search.rb +504 -0
- metadata +497 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# tweet_quote.rb - tDiary plugin to quote tweet on twitter.com,
|
4
|
+
# formaly known as blackbird-pie.rb
|
5
|
+
#
|
6
|
+
# Copyright (C) 2010, hb <smallstyle@gmail.com>
|
7
|
+
#
|
8
|
+
# usage:
|
9
|
+
# <%= tweet_quote "id|url" %>
|
10
|
+
# or
|
11
|
+
# <%= twitter_quote "id|url" %>
|
12
|
+
# or
|
13
|
+
# <%= blackbird_pie "id|url" %>
|
14
|
+
# or
|
15
|
+
# <%= bbp "id|url" %>
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'pstore'
|
19
|
+
require 'open-uri'
|
20
|
+
require 'timeout'
|
21
|
+
require 'rexml/document'
|
22
|
+
require 'time'
|
23
|
+
require 'uri'
|
24
|
+
|
25
|
+
def twitter_statuses_show_api( tweet_id )
|
26
|
+
url = "http://api.twitter.com/1/statuses/show/#{tweet_id}.xml"
|
27
|
+
|
28
|
+
proxy = @conf['proxy']
|
29
|
+
proxy = 'http://' + proxy if proxy
|
30
|
+
|
31
|
+
timeout( 20 ) do
|
32
|
+
open( url, :proxy => proxy ) {|f| f.read }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def tweet_quote( src )
|
38
|
+
if %r|http(?:s)?://twitter.com/(?:#!/)?[^/]{1,15}/status(?:es)?/([0-9]+)| =~ src.to_s.downcase
|
39
|
+
src = $1
|
40
|
+
end
|
41
|
+
|
42
|
+
return unless /\A[0-9]+\z/ =~ src.to_s
|
43
|
+
|
44
|
+
cache = "#{@cache_path}/blackbird.pstore"
|
45
|
+
xml = nil
|
46
|
+
|
47
|
+
db = PStore.new( cache )
|
48
|
+
db.transaction do
|
49
|
+
key = src
|
50
|
+
db[key] ||= {}
|
51
|
+
if db[key][:xml]
|
52
|
+
xml = db[key][:xml]
|
53
|
+
else
|
54
|
+
begin
|
55
|
+
xml = twitter_statuses_show_api( src )
|
56
|
+
rescue OpenURI::HTTPError
|
57
|
+
return %Q|<p class="bbpMessage">#$!</p>|
|
58
|
+
end
|
59
|
+
db[key][:xml] = xml
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
doc = REXML::Document::new( REXML::Source.new( xml ) ).root
|
64
|
+
|
65
|
+
tweet_id = doc.elements['//id'].text
|
66
|
+
screen_name = doc.elements['//user/screen_name'].text
|
67
|
+
name = doc.elements['//user/name'].text
|
68
|
+
background_url = doc.elements['//user/profile_background_image_url'].text
|
69
|
+
profile_background_color = '#' + doc.elements['//user/profile_background_color'].text
|
70
|
+
avatar = doc.elements['//user/profile_image_url'].text
|
71
|
+
source = doc.elements['//source'].text
|
72
|
+
timestamp = Time.parse( doc.elements['//created_at'].text ).to_s
|
73
|
+
content = doc.elements['//text'].text
|
74
|
+
content.gsub!( URI.regexp( %w|http https| ) ){ %Q|<a href="#{$&}">#{$&}</a>| }
|
75
|
+
content = content.split( /(<[^>]*>)/ ).map do |s|
|
76
|
+
next s if s[/\A</]
|
77
|
+
s.gsub!( /@(?>([a-zA-Z0-9_]{1,15}))(?![a-zA-Z0-9_])/ ){ %Q|<a href="http://twitter.com/#{$1}">#{$&}</a>| }
|
78
|
+
s.gsub( /#([a-zA-Z0-9]{1,16})/ ){ %Q|<a href="http://twitter.com/search?q=%23#{$1}">#{$&}</a>| }
|
79
|
+
end.join
|
80
|
+
|
81
|
+
r = <<-HTML
|
82
|
+
<!-- http://twitter.com/#{screen_name}/status/#{tweet_id} -->
|
83
|
+
<div class="bbpBox" style=
|
84
|
+
"background:url(#{background_url}) #{profile_background_color};padding:20px;">
|
85
|
+
<p class="bbpTweet" style=
|
86
|
+
"background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:16px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px;">
|
87
|
+
#{content} <span class="bbpTimestamp" style=
|
88
|
+
"font-size:12px;display:block;"><a title="#{timestamp}" href=
|
89
|
+
"http://twitter.com/#{screen_name}/status/#{tweet_id}">#{timestamp}</a> via #{source}
|
90
|
+
</span> <span class="bbpMetadata" style=
|
91
|
+
"display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6;">
|
92
|
+
<span class="bbpAuthor" style="line-height:19px;"><a href=
|
93
|
+
"http://twitter.com/#{screen_name}"><img alt="#{name}" src=
|
94
|
+
"#{avatar}" style=
|
95
|
+
"float:left;margin:0 7px 0 0;width:38px;height:38px;"></a>
|
96
|
+
<strong><a href=
|
97
|
+
"http://twitter.com/#{screen_name}">#{screen_name}</a></strong><br>
|
98
|
+
#{name}</span></span></p>
|
99
|
+
</div>
|
100
|
+
<!-- end of tweet -->
|
101
|
+
HTML
|
102
|
+
end
|
103
|
+
|
104
|
+
alias :blackbird_pie :tweet_quote
|
105
|
+
alias :bbp :tweet_quote
|
106
|
+
alias :twitter_quote :tweet_quote
|
data/plugin/twitpic.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#
|
2
|
+
# twitpic.rb: plugin to insert images on twitpic.com.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 TADA Tadashi <t@tdtds.jp>
|
5
|
+
# You can redistribute it and/or modify it under GPL2.
|
6
|
+
#
|
7
|
+
|
8
|
+
def twitpic( image_id, label = 'image on Twitpic', place = 'photo' )
|
9
|
+
%Q|<a class="twitpic" href="http://twitpic.com/#{h image_id}" title="#{h label}"><img class="#{h place}" src="http://twitpic.com/show/thumb/#{h image_id}.jpg" width="150" height="150" alt="#{h label}"></a>|
|
10
|
+
end
|
data/plugin/twitter.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# twitter.rb $Revision: 1.1 $
|
2
|
+
# Copyright (C) 2007 Michitaka Ohno <elpeo@mars.dti.ne.jp>
|
3
|
+
# You can redistribute it and/or modify it under GPL2.
|
4
|
+
|
5
|
+
require 'timeout'
|
6
|
+
require 'time'
|
7
|
+
require 'open-uri'
|
8
|
+
require 'rexml/document'
|
9
|
+
|
10
|
+
@twitter_statuses = []
|
11
|
+
|
12
|
+
if /^(latest|day)$/ =~ @mode then
|
13
|
+
add_header_proc do
|
14
|
+
xml = nil
|
15
|
+
timeout( 5 ) do
|
16
|
+
begin
|
17
|
+
xml = open( "http://twitter.com/statuses/user_timeline/#{@conf['twitter.user']}.xml" ){|f| f.read}
|
18
|
+
rescue Exception
|
19
|
+
end
|
20
|
+
end
|
21
|
+
doc = REXML::Document.new( xml ).root if xml
|
22
|
+
if doc then
|
23
|
+
doc.elements.each( 'status' ) do |e|
|
24
|
+
@twitter_statuses << [@conf.to_native( e.elements['text'].text ), Time.parse( e.elements['created_at'].text ).localtime]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
''
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
add_body_leave_proc do |date|
|
32
|
+
today_statuses = []
|
33
|
+
@twitter_statuses.each do |t, d|
|
34
|
+
today_statuses << [t, d] if d.to_a[3,3] == date.to_a[3,3]
|
35
|
+
end
|
36
|
+
if !today_statuses.empty?
|
37
|
+
r = %Q[<div class="section">]
|
38
|
+
r << %Q[<h3><a href="http://twitter.com/#{@conf['twitter.user']}">Twitter statuses</a></h3>]
|
39
|
+
today_statuses.sort{|a, b| b.last<=>a.last}.each do |t, d|
|
40
|
+
r << %Q[<p><strong>#{CGI::escapeHTML( t )}</strong> (#{d.strftime( '%H:%M:%S' )})</p>]
|
41
|
+
end
|
42
|
+
r << %Q[</div>]
|
43
|
+
else
|
44
|
+
''
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# twitter_anywhere.rb - bringing the Twitter communication platform to tDiary
|
4
|
+
# refer to the URL below.
|
5
|
+
# https://dev.twitter.com/docs/anywhere/welcome
|
6
|
+
#
|
7
|
+
# Copyright (C) 2010-2012, tamoot <tamoot+tdiary@gmail.com>
|
8
|
+
# You can redistribute it and/or modify it under GPL2.
|
9
|
+
#
|
10
|
+
|
11
|
+
def follow_button(account)
|
12
|
+
return not_support_anywhere unless support_anywhere?
|
13
|
+
return not_ready_anywhere unless ready_anywhere?
|
14
|
+
|
15
|
+
if account.nil? || account == ''
|
16
|
+
return anywhere_plugin_error("Account name is not specified.")
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
<<-FOLLOW_API
|
21
|
+
<span id="follow-twitterapi"></span>
|
22
|
+
<script type="text/javascript">
|
23
|
+
twttr.anywhere(function (T) {
|
24
|
+
T('#follow-twitterapi').followButton("#{account}");
|
25
|
+
});
|
26
|
+
</script>
|
27
|
+
FOLLOW_API
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def tweet_box(label = nil, content = nil, option = {})
|
32
|
+
return not_support_anywhere unless support_anywhere?
|
33
|
+
return not_ready_anywhere unless ready_anywhere?
|
34
|
+
init_tweetbox
|
35
|
+
|
36
|
+
@tweetbox_opt.merge!(option)
|
37
|
+
@tweetbox_opt.merge!(:height => 120) unless option[:height].to_i > 0
|
38
|
+
@tweetbox_opt.merge!(:width => 480) unless option[:width].to_i > 0
|
39
|
+
|
40
|
+
@tweetbox_opt.merge!(:label => label) if label
|
41
|
+
@tweetbox_opt.merge!(:defaultContent => content) if content
|
42
|
+
|
43
|
+
%Q|<span id="tweetbox"></span>|
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def twitter_anywhere_settings
|
48
|
+
enable_js('twitter_anywhere.js')
|
49
|
+
add_js_setting('$tDiary.plugin.twitter_anywhere')
|
50
|
+
|
51
|
+
selectors = @conf['twitter_anywhere.hovercards.selectors'].split(',').collect do |selector|
|
52
|
+
%Q|"#{selector.strip}"|
|
53
|
+
end
|
54
|
+
add_js_setting('$tDiary.plugin.twitter_anywhere.selectors',
|
55
|
+
"[#{selectors.join(',')}]" )
|
56
|
+
|
57
|
+
expanded = '{}'
|
58
|
+
if @conf['twitter_anywhere.hovercards.expand_default'] == 'true'
|
59
|
+
expanded = '{"expanded":true}'
|
60
|
+
|
61
|
+
end
|
62
|
+
add_js_setting('$tDiary.plugin.twitter_anywhere.hovercards')
|
63
|
+
add_js_setting('$tDiary.plugin.twitter_anywhere.hovercards.expand_default',
|
64
|
+
expanded)
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
add_header_proc do
|
70
|
+
|
71
|
+
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
|
72
|
+
|
73
|
+
if ready_anywhere?
|
74
|
+
%Q|<script src="http://platform.twitter.com/anywhere.js?id=#{h @conf['twitter_anywhere.id']}&v=1"></script>|
|
75
|
+
|
76
|
+
else
|
77
|
+
''
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
def init_tweetbox
|
86
|
+
@tweetbox_json_opt ||= []
|
87
|
+
@tweetbox_opt ||= {}
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
add_footer_proc do |date|
|
92
|
+
|
93
|
+
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
|
94
|
+
|
95
|
+
if ready_anywhere?
|
96
|
+
|
97
|
+
init_tweetbox
|
98
|
+
|
99
|
+
@tweetbox_opt.each_pair do |k, v|
|
100
|
+
@tweetbox_json_opt << "\"#{k}\":\"#{v}\""
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
tweet_box_call = %Q|<script type="text/javascript">\n|
|
105
|
+
tweet_box_call << %Q|<!--\n|
|
106
|
+
tweet_box_call << %Q| showTweetBox({#{@tweetbox_json_opt.join(',')}});\n|
|
107
|
+
tweet_box_call << %Q|//-->\n|
|
108
|
+
tweet_box_call << %Q|</script>\n|
|
109
|
+
|
110
|
+
else
|
111
|
+
''
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
else
|
116
|
+
''
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
add_conf_proc( 'twitter_anywhere', 'Twitter Anywhere' ) do
|
122
|
+
if @mode == 'saveconf' then
|
123
|
+
@conf['twitter_anywhere.id'] = @cgi.params['twitter_anywhere.id'][0]
|
124
|
+
@conf['twitter_anywhere.hovercards.selectors'] = @cgi.params['twitter_anywhere.hovercards.selectors'][0]
|
125
|
+
@conf['twitter_anywhere.hovercards.expand_default'] = @cgi.params['twitter_anywhere.hovercards.expand_default'][0]
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
expand_true = ""
|
130
|
+
expand_false = "selected"
|
131
|
+
|
132
|
+
if @conf['twitter_anywhere.hovercards.expand_default'] == "true"
|
133
|
+
expand_true = "selected"
|
134
|
+
expand_false = ""
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
<<-HTML
|
139
|
+
<h3 class="subtitle">Consumer key</h3>
|
140
|
+
|
141
|
+
<p><input name="twitter_anywhere.id" value="#{h @conf['twitter_anywhere.id']}" size="70"></p>
|
142
|
+
<p>Register your tDiary and get Consumer key.
|
143
|
+
<a href="http://dev.twitter.com/anywhere">Go Twitter OAuth settings.</a></p>
|
144
|
+
|
145
|
+
<h3 class="subtitle">Rending Hovercards</h3>
|
146
|
+
|
147
|
+
<h4>CSS Selector To limit the scope of where Hovercards appear</h4>
|
148
|
+
<p><input name="twitter_anywhere.hovercards.selectors" value="#{h @conf['twitter_anywhere.hovercards.selectors']}" size="70"></p>
|
149
|
+
<p>example) div.section p, div.commentshort p, div.commentbody p</p>
|
150
|
+
|
151
|
+
<h4>Expanded by Default</h4>
|
152
|
+
<p><select name="twitter_anywhere.hovercards.expand_default">
|
153
|
+
<option value="true" #{expand_true}>true</option>
|
154
|
+
<option value="false" #{expand_false}>false</option>
|
155
|
+
</select></p>
|
156
|
+
HTML
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
def support_anywhere?
|
161
|
+
return false if @conf.mobile_agent? || feed?
|
162
|
+
return true
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
def ready_anywhere?
|
167
|
+
if @conf['twitter_anywhere.id'] && @conf['twitter_anywhere.id'].size > 0
|
168
|
+
return true
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
return false
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
def not_support_anywhere
|
178
|
+
'[Twitter@Anywhere] not support this environment.'
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
def not_ready_anywhere
|
183
|
+
anywhere_plugin_error(
|
184
|
+
"Twitter consumer Key not specified.",
|
185
|
+
%Q|<a href="http://dev.twitter.com/anywhere">Go Twitter OAuth settings.</a>|)
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
def anywhere_plugin_error(message, detail= '')
|
190
|
+
<<-PLUGIN_ERROR
|
191
|
+
<div class="plugin-message" style="background: #FDC; border: 2px solid #d00; color: #500; padding: .1em; margin: 1em 0;">
|
192
|
+
<p style="font-weight: bold;">[ERROR] twitter_anywhere.rb: #{message}</p><br>
|
193
|
+
<p>#{detail}</p>
|
194
|
+
</div>
|
195
|
+
PLUGIN_ERROR
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
if /\A(?:latest|day|month|nyear|preview)\z/ =~ @mode
|
200
|
+
twitter_anywhere_settings
|
201
|
+
end
|
202
|
+
|
203
|
+
# Local Variables:
|
204
|
+
# mode: ruby
|
205
|
+
# indent-tabs-mode: t
|
206
|
+
# tab-width: 3
|
207
|
+
# ruby-indent-level: 3
|
208
|
+
# End:
|
209
|
+
# vim: ts=3
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# twitter_badge.rb: insert 'Follow me' badge of Twitter.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 TADA Tadashi <t@tdtds.jp>
|
5
|
+
# You can redistribute it and/or modify it under GPL2.
|
6
|
+
#
|
7
|
+
|
8
|
+
def twitter_badge( account, opt = {} )
|
9
|
+
return '' unless account
|
10
|
+
@twitter_badge_setting = {
|
11
|
+
:account => account,
|
12
|
+
:label => (opt[:label] || 'follow-me'),
|
13
|
+
:color => (opt[:color] || '#35ccff'),
|
14
|
+
:side => (opt[:side] || 'right')[0,1],
|
15
|
+
:top => (opt[:top] || 136).to_i,
|
16
|
+
:delay => (opt[:delay] || 5).to_i * 1000,
|
17
|
+
}
|
18
|
+
'' # do nothing in this method.
|
19
|
+
end
|
20
|
+
|
21
|
+
add_footer_proc do
|
22
|
+
if @twitter_badge_setting then
|
23
|
+
t = @twitter_badge_setting
|
24
|
+
<<-TEXT
|
25
|
+
<!-- Twitter follow badge by go2web20 -->
|
26
|
+
<script src="http://files.go2web20.net/twitterbadge/1.0/badge.js" type="text/javascript" charset="utf-8"></script>
|
27
|
+
<script type="text/javascript"><!--
|
28
|
+
tfb.account = '#{t[:account]}';
|
29
|
+
tfb.label = '#{t[:label]}';
|
30
|
+
tfb.color = '#{t[:color]}';
|
31
|
+
tfb.side = '#{t[:side]}';
|
32
|
+
tfb.top = #{t[:top]};
|
33
|
+
setTimeout( tfb.showbadge, #{t[:delay]} );
|
34
|
+
//-->
|
35
|
+
</script>
|
36
|
+
<!-- end of Twitter follow badge -->
|
37
|
+
TEXT
|
38
|
+
else
|
39
|
+
''
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# twitter_js.rb $Revision: 1.1 $
|
2
|
+
# Copyright (C) 2007 Michitaka Ohno <elpeo@mars.dti.ne.jp>
|
3
|
+
# You can redistribute it and/or modify it under GPL2.
|
4
|
+
|
5
|
+
if /\A(?:latest|day)\z/ =~ @mode then
|
6
|
+
if @conf['twitter.user'] then
|
7
|
+
twitter_user = @conf['twitter.user']
|
8
|
+
add_header_proc do
|
9
|
+
result = <<-HTML
|
10
|
+
<script type="text/javascript"><!--
|
11
|
+
function twitter_cb(a){
|
12
|
+
var f=function(n){return (n<10?'0':'')+n};
|
13
|
+
for(var i=0,l=a.length;i<l;i++){
|
14
|
+
var d=new Date(a[i]['created_at'].replace('+0000','UTC'));
|
15
|
+
var id='twitter_statuses_'+f(d.getFullYear())+f(d.getMonth()+1)+f(d.getDate());
|
16
|
+
var e=document.getElementById(id);
|
17
|
+
if(!e) continue;
|
18
|
+
if(!e.innerHTML) e.innerHTML='<h3><a href="http://twitter.com/#{h twitter_user}">Twitter statuses</a></h3>';
|
19
|
+
e.innerHTML+='<p><strong>'+a[i]['text']+'</strong> ('+f(d.getHours())+':'+f(d.getMinutes())+':'+f(d.getSeconds())+')</p>';
|
20
|
+
}
|
21
|
+
}
|
22
|
+
function twitter_js(){
|
23
|
+
var e=document.createElement('script');
|
24
|
+
e.type='text/javascript';
|
25
|
+
e.src='http://twitter.com/statuses/user_timeline/#{h twitter_user}.json?callback=twitter_cb&count=20';
|
26
|
+
document.documentElement.appendChild(e);
|
27
|
+
}
|
28
|
+
if(window.addEventListener){
|
29
|
+
window.addEventListener('load',twitter_js,false);
|
30
|
+
}else if(window.attachEvent){
|
31
|
+
window.attachEvent('onload',twitter_js);
|
32
|
+
}else{
|
33
|
+
window.onload=twitter_js;
|
34
|
+
}
|
35
|
+
// --></script>
|
36
|
+
HTML
|
37
|
+
result.gsub( /^\t\t/, '' )
|
38
|
+
end
|
39
|
+
|
40
|
+
add_body_leave_proc do |date|
|
41
|
+
result = <<-HTML
|
42
|
+
<div id="twitter_statuses_#{date.strftime( "%Y%m%d" )}" class="section"></div>
|
43
|
+
HTML
|
44
|
+
result.gsub( /^\t\t/, '' )
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
add_conf_proc( 'twitter_js', 'Twitter' ) do
|
50
|
+
|
51
|
+
if @mode == 'saveconf' then
|
52
|
+
@conf['twitter.user'] = @cgi.params['twitter.user'][0]
|
53
|
+
end
|
54
|
+
|
55
|
+
<<-HTML
|
56
|
+
<h3 class="subtitle">Account Name</h3>
|
57
|
+
<p><input name="twitter.user" value="#{h @conf['twitter.user']}"></p>
|
58
|
+
HTML
|
59
|
+
end
|
data/plugin/ustream.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# ustream.rb - insert some services of Ustream.tv
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010, TADA Tadashi <t@tdtds.jp>.
|
5
|
+
# You can redistribute it and/or modify it under GPL2.
|
6
|
+
#
|
7
|
+
|
8
|
+
def ustream( id, type = :recorded )
|
9
|
+
if type == :live then
|
10
|
+
return ''
|
11
|
+
end
|
12
|
+
|
13
|
+
# insert recorded video
|
14
|
+
if @conf.mobile_agent? or @conf.iphone? or feed? then
|
15
|
+
return %Q|<a href="http://www.ustream.tv/recorded/#{id}">Link to Ustream ##{id}</a></p><p>|
|
16
|
+
end
|
17
|
+
|
18
|
+
%Q|<iframe class="ustream" width="480" height="302" src="http://www.ustream.tv/embed/recorded/#{id}?v=3&wmode=direct" scrolling="no" frameborder="0" style="border: 0px none transparent;"></iframe>|
|
19
|
+
end
|
data/plugin/vimeo.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#
|
2
|
+
# vimeo.rb - insert some services of vimeo.com
|
3
|
+
#
|
4
|
+
# Copyright (C) 2011, Kiwamu Okabe <kiwamu@debian.or.jp>.
|
5
|
+
# You can redistribute it and/or modify it under GPL2.
|
6
|
+
#
|
7
|
+
|
8
|
+
def vimeo( id )
|
9
|
+
if @conf.mobile_agent? or @conf.iphone? or feed? then
|
10
|
+
return %Q|<a href="http://vimeo.com/#{id}">Link to vimeo ##{id}</a></p><p>|
|
11
|
+
end
|
12
|
+
|
13
|
+
%Q|<iframe src="http://player.vimeo.com/video/#{id}?title=0&byline=0&portrait=0" width="400" height="300" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>|
|
14
|
+
end
|
data/plugin/volatile.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# hide old diaries
|
2
|
+
#
|
3
|
+
# options configurable through settings:
|
4
|
+
# @conf['volatile.limit'] : number of diaries to show
|
5
|
+
#
|
6
|
+
# Copyright (c) MATSUOKA Kohei <http://www.machu.jp/diary/>
|
7
|
+
# Distributed under the GPL
|
8
|
+
#
|
9
|
+
module ::TDiary
|
10
|
+
# 複数の日記を一括して更新するためのクラス
|
11
|
+
class TDiaryBulkUpdate < TDiaryUpdate
|
12
|
+
def initialize( cgi, rhtm, conf )
|
13
|
+
super
|
14
|
+
date = Time::local( *cgi.params['date'][0].scan( /^(\d{4})(\d\d)$/ )[0] )
|
15
|
+
@io.transaction( date ) do |diaries|
|
16
|
+
yield(diaries)
|
17
|
+
# DIRTY_DIARYは@ioへ日記を更新することを伝えるフラグ
|
18
|
+
DIRTY_DIARY
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# 古い日記を非表示にするプラグイン
|
25
|
+
class VolatileDiaryPlugin
|
26
|
+
def initialize(conf)
|
27
|
+
@conf = conf
|
28
|
+
@limit = conf['volatile.limit'] || 10
|
29
|
+
end
|
30
|
+
|
31
|
+
# all を true にすると全ての日記を対象とする
|
32
|
+
def update(years, all = false)
|
33
|
+
each_recent_diary(years) do |date, diary, count|
|
34
|
+
diary.show(count <= @limit)
|
35
|
+
all || count <= @limit
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def each_recent_diary(years)
|
40
|
+
cgi = CGI.new
|
41
|
+
count = 1
|
42
|
+
break_flag = false
|
43
|
+
years.keys.sort.reverse_each do |year|
|
44
|
+
years[year].sort.reverse_each do |month|
|
45
|
+
cgi.params['date'] = ["#{year}#{month}"]
|
46
|
+
cgi.params['year'] = [year]
|
47
|
+
cgi.params['month'] = [month]
|
48
|
+
cgi.params['day'] = ["1"]
|
49
|
+
m = TDiaryBulkUpdate::new(cgi, '', @conf) {|diaries|
|
50
|
+
# diaries.class is Hash (date => diary)
|
51
|
+
diaries.sort.reverse_each do |date, diary|
|
52
|
+
unless yield(date, diary, count)
|
53
|
+
break_flag = true
|
54
|
+
break
|
55
|
+
end
|
56
|
+
count += 1
|
57
|
+
end
|
58
|
+
}
|
59
|
+
break if break_flag
|
60
|
+
end
|
61
|
+
break if break_flag
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
add_update_proc do
|
67
|
+
# 古い日記を非表示にする
|
68
|
+
plugin = VolatileDiaryPlugin.new(@conf)
|
69
|
+
plugin.update(@years)
|
70
|
+
end
|
71
|
+
|
72
|
+
add_conf_proc('volatile', "揮発性日記", 'update') do
|
73
|
+
if @mode == 'saveconf' then
|
74
|
+
@conf['volatile.limit'] = @cgi.params['volatile.limit'][0].to_i
|
75
|
+
p = VolatileDiaryPlugin.new(@conf)
|
76
|
+
p.update(@years, true)
|
77
|
+
end
|
78
|
+
|
79
|
+
r = <<-HTML
|
80
|
+
<p>日記の更新時に古い日記を非表示にします。</p>
|
81
|
+
<h3>公開する日記の件数</h3>
|
82
|
+
<dl>
|
83
|
+
<dt>公開したい日記の件数を入力してください。</dt>
|
84
|
+
<dd><input name="volatile.limit" value="#{@conf['volatile.limit'] || '10'}"></dd>
|
85
|
+
</dl>
|
86
|
+
HTML
|
87
|
+
r
|
88
|
+
end
|
89
|
+
|