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,132 @@
|
|
1
|
+
# show my hot-entry in Hatena::Bookmark
|
2
|
+
#
|
3
|
+
# usage:
|
4
|
+
# <%= my_hotentry %>
|
5
|
+
#
|
6
|
+
# Copyright (c) MATSUOKA Kohei <http://www.machu.jp/>
|
7
|
+
# Distributed under the GPL
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
require 'open-uri'
|
11
|
+
require 'rexml/document'
|
12
|
+
require 'pstore'
|
13
|
+
require 'timeout'
|
14
|
+
|
15
|
+
# 人気の日記のソート順(新着順: eid, 注目順: hot, 人気順: count)
|
16
|
+
@conf ||= {}
|
17
|
+
@conf['my_hotentry.sort'] ||= 'hot'
|
18
|
+
|
19
|
+
class MyHotEntry
|
20
|
+
def initialize(dbfile)
|
21
|
+
@dbfile = dbfile
|
22
|
+
end
|
23
|
+
|
24
|
+
# 人気の日記の一覧を返す
|
25
|
+
def entries
|
26
|
+
r = nil
|
27
|
+
PStore.new(@dbfile).transaction(true) do |db|
|
28
|
+
r = db[:entries]
|
29
|
+
end
|
30
|
+
r || []
|
31
|
+
end
|
32
|
+
|
33
|
+
# 人気の日記一覧を取得する
|
34
|
+
def update(base_url, options = {})
|
35
|
+
options[:title] ||= ''
|
36
|
+
options[:sort] ||= 'eid'
|
37
|
+
options[:threshold] ||= 3
|
38
|
+
|
39
|
+
# RSSを取得
|
40
|
+
rss = nil
|
41
|
+
rss_url = 'http://b.hatena.ne.jp/entrylist?mode=rss&url='
|
42
|
+
rss_url << URI.escape(base_url, /[^-.!~*'()\w]/n)
|
43
|
+
rss_url << "&sort=#{options[:sort]}&threshold=#{options[:threshold]}"
|
44
|
+
begin
|
45
|
+
timeout(5) do
|
46
|
+
# convert Tempfile to String because REXML can't accept Tempfile
|
47
|
+
open(rss_url) do |f|
|
48
|
+
rss = REXML::Document.new(f.readlines.join("\n"))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
rescue TimeoutError => e
|
52
|
+
return
|
53
|
+
end
|
54
|
+
# RDF/itemが空ならDBを更新しない (たまにitemが空のデータが返るため)
|
55
|
+
return if rss.elements['rdf:RDF/item'].nil?
|
56
|
+
|
57
|
+
# キャッシュに格納する
|
58
|
+
PStore.new(@dbfile).transaction do |db|
|
59
|
+
db[:entries] = []
|
60
|
+
rss.elements.each('rdf:RDF/item') do |item|
|
61
|
+
url = item.elements['link'].text
|
62
|
+
title = item.elements['title'].text
|
63
|
+
# リンク先のタイトルからサイト名と日付を取り除く
|
64
|
+
title.sub!(/(?: - )?#{options[:html_title]}(?: - )?/, '')
|
65
|
+
title.sub!(/\(\d{4}-\d{2}-\d{2}\)/, '')
|
66
|
+
db[:entries].push({ :url => url, :title => title })
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# キャッシュファイルのパスを取得する
|
73
|
+
def my_hotentry_dbfile
|
74
|
+
cache_dir = "#{@cache_path}/hatena"
|
75
|
+
Dir::mkdir(cache_dir) unless File::directory?(cache_dir)
|
76
|
+
"#{cache_dir}/my_hotentry.dat"
|
77
|
+
end
|
78
|
+
|
79
|
+
# 人気の日記一覧を表示する
|
80
|
+
def my_hotentry(count = 5)
|
81
|
+
dbfile = my_hotentry_dbfile
|
82
|
+
hotentry = MyHotEntry.new(dbfile)
|
83
|
+
r = %Q|<ul class="rss-recent">\n|
|
84
|
+
hotentry.entries[0...count].each do |entry|
|
85
|
+
entry_link = %Q|<a href="#{entry[:url]}">#{CGI::escapeHTML(entry[:title])}</a>|
|
86
|
+
escape_url = entry[:url].gsub(/#/, '%23')
|
87
|
+
b_image = "http://b.hatena.ne.jp/entry/image/#{escape_url}"
|
88
|
+
b_link = "http://b.hatena.ne.jp/entry/#{escape_url}"
|
89
|
+
b_title = "このエントリを含むはてなブックマーク"
|
90
|
+
bookmark_link = %Q|<a href="#{b_link}" title="#{b_title}"><img border="0" src="#{b_image}"></a>|
|
91
|
+
r << "\t\t<li>#{entry_link} #{bookmark_link}</li>"
|
92
|
+
end
|
93
|
+
r << %Q|</ul>|
|
94
|
+
r << %Q|<div class="iddy"><span class="iddy-powered">\tPowered by <a href="http://b.hatena.ne.jp/entrylist?url=#{@conf.base_url}&sort=#{@conf['my_hotentry.sort']}">Hatena Bookmark</a></span></div>\n|
|
95
|
+
end
|
96
|
+
|
97
|
+
# 人気の日記一覧を更新する
|
98
|
+
def my_hotentry_update
|
99
|
+
dbfile = my_hotentry_dbfile
|
100
|
+
hotentry = MyHotEntry.new(dbfile)
|
101
|
+
hotentry.update(@conf.base_url,
|
102
|
+
:html_title => @conf.html_title,
|
103
|
+
:sort => @conf['my_hotentry.sort'])
|
104
|
+
end
|
105
|
+
|
106
|
+
if __FILE__ == $0
|
107
|
+
# コマンドラインから実行した場合
|
108
|
+
# tdiary.conf に base_url を設定しないと動作しない
|
109
|
+
begin
|
110
|
+
require 'tdiary'
|
111
|
+
rescue LoadError
|
112
|
+
STDERR.puts "tdiary.rb not found."
|
113
|
+
STDERR.puts "please execute in tdiary base directory"
|
114
|
+
exit 1
|
115
|
+
end
|
116
|
+
cgi = CGI::new
|
117
|
+
@conf = TDiary::Config::new(cgi)
|
118
|
+
@cache_path = @conf.cache_path || "#{@conf.data_path}cache"
|
119
|
+
my_hotentry_update
|
120
|
+
puts my_hotentry
|
121
|
+
else
|
122
|
+
# 人気の日記一覧を取得する (日記更新時)
|
123
|
+
add_update_proc do
|
124
|
+
# ツッコミ時は実行しない
|
125
|
+
if @mode == 'append' or @mode == 'replace'
|
126
|
+
begin
|
127
|
+
my_hotentry_update
|
128
|
+
rescue
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
data/plugin/navi_day.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#
|
2
|
+
# navi_day.rb
|
3
|
+
#
|
4
|
+
# navi_day: 「前の日記」や「次の日記」を“月またぎ”に対応させる。
|
5
|
+
#
|
6
|
+
# 日単位での表示の時の「前の日記」や「次の日記」のリンクが、
|
7
|
+
# 異なる月の日記を正しく指せない場合があるという tDiary の制限を
|
8
|
+
# 解消するプラグインです。以前よりある navi_user.rb と機能的には
|
9
|
+
# 同じですが、navi_user.rb よりは処理がずっと軽くなっています。
|
10
|
+
# また、日記の表示状態(非表示の日記)に対する考慮もなされています。
|
11
|
+
#
|
12
|
+
# tDiary 2.0 以降で使えると思います。セキュアモードでも使えますが、
|
13
|
+
# セキュアモードの場合は、モバイル端末からのアクセスに対しては
|
14
|
+
# このプラグインは効力を持ちません(tDiary セキュア環境の制限:
|
15
|
+
# モバイル端末の場合は本文を出力するときに calc_links が呼ばれる
|
16
|
+
# ため)。
|
17
|
+
#
|
18
|
+
# navi_user.rb と併用すると navi_user.rb の方が優先されますので、
|
19
|
+
# このプラグインを使うときには必ず navi_user.rb を外してください。
|
20
|
+
#
|
21
|
+
# Copyright (C) 2007, MIYASAKA Masaru <alkaid@coral.ocn.ne.jp>
|
22
|
+
# You can redistribute it and/or modify it under GPL2.
|
23
|
+
#
|
24
|
+
# Last Modified : May 27, 2007
|
25
|
+
#
|
26
|
+
|
27
|
+
# for tDiary 2.0.X
|
28
|
+
if not TDiaryMonth.method_defined?(:diaries) then
|
29
|
+
eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
|
30
|
+
module TDiary
|
31
|
+
class TDiaryMonth
|
32
|
+
attr_reader :diaries
|
33
|
+
end
|
34
|
+
end
|
35
|
+
MODIFY_CLASS
|
36
|
+
end
|
37
|
+
|
38
|
+
class NaviDayCGI
|
39
|
+
attr_reader :params
|
40
|
+
def referer; nil; end
|
41
|
+
def initialize
|
42
|
+
@params = Hash.new([])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
alias :calc_links_navi_day_backup :calc_links
|
47
|
+
|
48
|
+
def calc_links
|
49
|
+
if not (@conf.secure and @conf.mobile_agent?) and \
|
50
|
+
(/day|edit/ =~ @mode or \
|
51
|
+
(@conf.mobile_agent? and /latest|month|nyear/ =~ @mode)) then
|
52
|
+
if /(latest|month|nyear)/ === @mode
|
53
|
+
today = @diaries.keys.sort[-1]
|
54
|
+
else
|
55
|
+
today = @date.strftime('%Y%m%d')
|
56
|
+
end
|
57
|
+
days = @diaries.keys
|
58
|
+
days |= [today]
|
59
|
+
days.sort!
|
60
|
+
days.unshift(nil).push(nil)
|
61
|
+
today_index = days.index(today)
|
62
|
+
|
63
|
+
days[0 .. today_index - 1].reverse_each do |prev_day|
|
64
|
+
@prev_day = prev_day
|
65
|
+
break unless @prev_day
|
66
|
+
break if (@mode == 'edit') or @diaries[@prev_day].visible?
|
67
|
+
end
|
68
|
+
|
69
|
+
days[today_index + 1 .. -1].each do |next_day|
|
70
|
+
@next_day = next_day
|
71
|
+
break unless @next_day
|
72
|
+
break if (@mode == 'edit') or @diaries[@next_day].visible?
|
73
|
+
end
|
74
|
+
|
75
|
+
if not @prev_day or not @next_day then
|
76
|
+
cgi = NaviDayCGI.new
|
77
|
+
years = []
|
78
|
+
@years.each do |k, v|
|
79
|
+
v.each do |m|
|
80
|
+
years << k + m
|
81
|
+
end
|
82
|
+
end
|
83
|
+
this_month = @date.strftime('%Y%m')
|
84
|
+
years |= [this_month]
|
85
|
+
years.sort!
|
86
|
+
years.unshift(nil).push(nil)
|
87
|
+
this_month_index = years.index(this_month)
|
88
|
+
|
89
|
+
years[0 .. this_month_index - 1].reverse_each do |prev_month|
|
90
|
+
break unless not @prev_day and prev_month
|
91
|
+
cgi.params['date'] = [prev_month]
|
92
|
+
diaries = TDiaryMonth.new(cgi, '', @conf).diaries
|
93
|
+
days = diaries.keys.sort
|
94
|
+
days.unshift(nil)
|
95
|
+
days.reverse_each do |prev_day|
|
96
|
+
@prev_day = prev_day
|
97
|
+
break unless @prev_day
|
98
|
+
break if (@mode == 'edit') or diaries[@prev_day].visible?
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
years[this_month_index + 1 .. -1].each do |next_month|
|
103
|
+
break unless not @next_day and next_month
|
104
|
+
cgi.params['date'] = [next_month]
|
105
|
+
diaries = TDiaryMonth.new(cgi, '', @conf).diaries
|
106
|
+
days = diaries.keys.sort
|
107
|
+
days.push(nil)
|
108
|
+
days.each do |next_day|
|
109
|
+
@next_day = next_day
|
110
|
+
break unless @next_day
|
111
|
+
break if (@mode == 'edit') or diaries[@next_day].visible?
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
else
|
116
|
+
calc_links_navi_day_backup
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# navi-this-month.rb
|
2
|
+
# ref. http://www.tom.sfc.keio.ac.jp/~sakai/d/?date=20080628#p01
|
3
|
+
#
|
4
|
+
alias navi_this_month__orig__navi_user_day navi_user_day
|
5
|
+
|
6
|
+
def navi_user_day
|
7
|
+
result = navi_this_month__orig__navi_user_day
|
8
|
+
if @mode=='day'
|
9
|
+
this_month = @date.strftime( '%Y%m' )
|
10
|
+
result << navi_item( "#{@index}#{anchor this_month}", "#{navi_this_month}" )
|
11
|
+
end
|
12
|
+
result
|
13
|
+
end
|
14
|
+
|
15
|
+
def navi_this_month; "月表示"; end
|
data/plugin/nicovideo.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
#
|
2
|
+
# nicovideo.rb - tDiary plugin for Nico Nico Video
|
3
|
+
#
|
4
|
+
# Copyright (C) 2012 TADA Tadashi <t@tdtds.jp>
|
5
|
+
# You can modify and/or distribute it under GPL.
|
6
|
+
#
|
7
|
+
# usage:
|
8
|
+
# Link to the movie and show thumbnail, description...:
|
9
|
+
# <%= nicovideo 'sm99999999' %>
|
10
|
+
#
|
11
|
+
# Link to the movie with original label:
|
12
|
+
# <%= nicovideo 'sm99999999', 'movie title' %>
|
13
|
+
#
|
14
|
+
# Link to the movie with original label and link:
|
15
|
+
# <%= nicovideo 'sm99999999', 'movie title', 'http://example.com/video' %>
|
16
|
+
#
|
17
|
+
# Show Inline player:
|
18
|
+
# <%= nicovideo_player 'sm99999999' %>
|
19
|
+
#
|
20
|
+
# Show Inline player with size:
|
21
|
+
# <%= nicovideo_player 'sm99999999', [400,300] %>
|
22
|
+
#
|
23
|
+
require 'net/http'
|
24
|
+
require 'timeout'
|
25
|
+
require 'rexml/document'
|
26
|
+
|
27
|
+
enable_js( 'nicovideo.js' )
|
28
|
+
|
29
|
+
def nicovideo_call_api( video_id )
|
30
|
+
uri = "http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}"
|
31
|
+
proxy = @conf['proxy']
|
32
|
+
proxy = 'http://' + proxy if proxy
|
33
|
+
xml = timeout( feed? ? 10 : 2 ) {
|
34
|
+
px_host, px_port = (@conf['proxy'] || '').split( /:/ )
|
35
|
+
px_port = 80 if px_host and !px_port
|
36
|
+
Net::HTTP::Proxy( px_host, px_port ).get_response( URI::parse( uri ) ).body
|
37
|
+
}
|
38
|
+
doc = REXML::Document::new( xml ).root
|
39
|
+
res = doc.elements.to_a( '/nicovideo_thumb_response' )[0]
|
40
|
+
if res.attributes['status'] == 'ok' then
|
41
|
+
res.elements.to_a( 'thumb' )[0]
|
42
|
+
else
|
43
|
+
raise ::Errno::ENOENT::new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def nicovideo_inline( video_id, elem, label = nil, link = nil )
|
48
|
+
i = {}
|
49
|
+
i[:id] = video_id
|
50
|
+
i[:url] = link || elem.to_a( 'watch_url' )[0].text
|
51
|
+
i[:thumb] = elem.to_a( 'thumbnail_url' )[0].text
|
52
|
+
i[:title] = label || elem.to_a( 'title' )[0].text
|
53
|
+
i[:desc] = elem.to_a( 'description' )[0].text
|
54
|
+
i[:comment] = @conf.mobile_agent? ? '' : elem.to_a( 'last_res_body' )[0].text
|
55
|
+
i[:date] = elem.to_a( 'first_retrieve' )[0].text
|
56
|
+
i[:length] = elem.to_a( 'length' )[0].text
|
57
|
+
i[:view] = elem.to_a( 'view_counter' )[0].text
|
58
|
+
i[:comment_num] = elem.to_a( 'comment_num' )[0].text
|
59
|
+
i[:mylist] = elem.to_a( 'mylist_counter' )[0].text
|
60
|
+
|
61
|
+
if feed? then
|
62
|
+
result = nicovideo_feed( i )
|
63
|
+
else
|
64
|
+
result = nicovideo_html( i )
|
65
|
+
end
|
66
|
+
result.gsub( /^\t+/, '' )
|
67
|
+
end
|
68
|
+
|
69
|
+
def nicovideo_iframe( video_id )
|
70
|
+
%Q|<iframe src="http://www.nicovideo.jp/thumb/#{video_id}" scrolling="no" style="border:1px solid #CCC;" frameborder="0"><a href="http://www.nicovideo.jp/watch/#{video_id}">#{label || 'link for nicovideo'}</a></iframe>\n|
|
71
|
+
end
|
72
|
+
|
73
|
+
def nicovideo_player( video_id, size = [544,384] )
|
74
|
+
if feed? or @conf.mobile_agent? or @conf.iphone? then
|
75
|
+
nicovideo( video_id )
|
76
|
+
else
|
77
|
+
q = ''
|
78
|
+
if size then
|
79
|
+
q = "?w=#{h size[0]}&h=#{h size[1]}"
|
80
|
+
end
|
81
|
+
%Q|<script type="text/javascript" src="#{nicovideo_player_path}/thumb_watch/#{video_id}#{q}"></script>|
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def nicovideo( video_id, label = nil, link = nil )
|
86
|
+
begin
|
87
|
+
r = ''
|
88
|
+
r << %Q|<div id="thumbnail-#{video_id}">|
|
89
|
+
api = nicovideo_call_api( video_id ).elements
|
90
|
+
thumb = @conf.to_native( nicovideo_inline( video_id, api, label, link ), 'UTF-8' )
|
91
|
+
thumb.gsub!( /"INLINE_PLAYER"/, %Q|"#" onclick="return nicovideoPlayer( '#{video_id}' );"| )
|
92
|
+
r << thumb
|
93
|
+
r << '</div>'
|
94
|
+
if feed? or @conf.mobile_agent? or @conf.iphone? then
|
95
|
+
r.gsub!( /<a(?:[ \t\n\r][^>]*)?>/, '' )
|
96
|
+
r.gsub!( %r{</a[ \t\n\r]*>}, '' )
|
97
|
+
else
|
98
|
+
r << %Q|<div id="player-#{video_id}" style="display:none;background-color:#000;margin-left:2em;padding-bottom:4px;">|
|
99
|
+
r << %Q|<a name="player-#{video_id}">|
|
100
|
+
r << nicovideo_player( video_id, [544,384] )
|
101
|
+
r << %Q|</a>|
|
102
|
+
r << %Q|<div class="nicovideo-player-close" style="margin:4px;padding:8px;">|
|
103
|
+
r << %Q|<a href="#" onclick="return nicovideoThumbnail( '#{video_id}' )" style="background-color:black; color:white; margin:2px; padding:8px; border-color:white; border-radius:6px; border-width:2px; border-style:solid; text-decoration:none;">▲CLOSE PLAYER</a>|
|
104
|
+
r << %Q| <a href="#{api.to_a( 'watch_url' )[0].text}" style="background-color:black; color:white; margin:2px; padding:8px; border-color:white; border-radius:6px; border-width:2px; border-style:solid; text-decoration:none;">SHOW ORIGINAL></a>|
|
105
|
+
r << %Q|</div>|
|
106
|
+
r << %Q|</div>|
|
107
|
+
end
|
108
|
+
r
|
109
|
+
rescue ::Errno::ENOENT
|
110
|
+
"<strong>Sorry, #{video_id} was deleted.</strong>"
|
111
|
+
rescue Timeout::Error, NoMethodError, SecurityError, StandardError
|
112
|
+
nicovideo_iframe( video_id )
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2007 peo <peo@mb.neweb.ne.jp>
|
3
|
+
# You can redistribute it and/or modify it under GPL2.
|
4
|
+
#
|
5
|
+
# modified hsbt.
|
6
|
+
|
7
|
+
require 'net/http'
|
8
|
+
|
9
|
+
@miniblog_config = (Struct.const_defined?("MiniBlogConfig") ? Struct::MiniBlogConfig :
|
10
|
+
Struct.new("MiniBlogConfig", :host, :path))
|
11
|
+
|
12
|
+
@miniblog_list = {
|
13
|
+
'HatenaHaiku' => @miniblog_config.new('h.hatena.ne.jp', '/api/statuses/update.json'),
|
14
|
+
}
|
15
|
+
|
16
|
+
module Miniblog
|
17
|
+
class Updater
|
18
|
+
def initialize( user, pass, config )
|
19
|
+
@user = user
|
20
|
+
@pass = pass
|
21
|
+
@config = config
|
22
|
+
end
|
23
|
+
|
24
|
+
# this code is based on http://la.ma.la/blog/diary_200704111918.htm
|
25
|
+
def update( status )
|
26
|
+
Net::HTTP.version_1_2
|
27
|
+
req = Net::HTTP::Post.new(@config.path)
|
28
|
+
req.basic_auth(@user, @pass)
|
29
|
+
req.body = status
|
30
|
+
|
31
|
+
Net::HTTP.start( @config.host, 80 ) do |http|
|
32
|
+
response = http.request(req)
|
33
|
+
if response.body =~ /error/
|
34
|
+
raise 'update failed.'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def notify_miniblog
|
42
|
+
notify_miniblog_init
|
43
|
+
|
44
|
+
date = @date.strftime('%Y%m%d')
|
45
|
+
diary = @diaries[date]
|
46
|
+
sectitle = ''
|
47
|
+
index = 0
|
48
|
+
|
49
|
+
diary.each_section do |sec|
|
50
|
+
index += 1
|
51
|
+
sectitle = sec.subtitle
|
52
|
+
end
|
53
|
+
|
54
|
+
# strip category
|
55
|
+
sectitle.gsub!(/\[[^\]]+\] */, '')
|
56
|
+
url = URI.encode(@conf.base_url + anchor("#{date}p%02d" % index), /[^-.!~*'()\w]/n)
|
57
|
+
prefix = @conf['miniblog.notify.prefix']
|
58
|
+
format = @conf['miniblog.notify.format']
|
59
|
+
source = 'tdiary/notify_miniblog.rb'
|
60
|
+
|
61
|
+
status = 'status=' + format % [prefix, sectitle, url] + '&source=' + source
|
62
|
+
if @conf['miniblog.service'] == "HatenaHaiku" then
|
63
|
+
status += '&keyword=id:' + @conf['miniblog.user']
|
64
|
+
end
|
65
|
+
|
66
|
+
config = @miniblog_list[@conf['miniblog.service']]
|
67
|
+
|
68
|
+
begin
|
69
|
+
miniblog_updater = Miniblog::Updater.new(@conf['miniblog.user'], @conf['miniblog.pass'], config)
|
70
|
+
miniblog_updater.update( status )
|
71
|
+
rescue => e
|
72
|
+
@logger.debug( e )
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def notify_miniblog_init
|
77
|
+
@conf['miniblog.notify.prefix'] ||= '[blog update]'
|
78
|
+
@conf['miniblog.notify.format'] ||= '%s %s %s'
|
79
|
+
@conf['miniblog.service'] ||= 'Twitter'
|
80
|
+
end
|
81
|
+
|
82
|
+
add_update_proc do
|
83
|
+
if @mode == 'append' then
|
84
|
+
notify_miniblog if @cgi.params['miniblog.notify'][0] == 'true'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
add_edit_proc do
|
89
|
+
checked = ''
|
90
|
+
if @mode == 'preview' then
|
91
|
+
checked = @cgi.params['miniblog.notify'][0] == 'true' ? ' checked' : ''
|
92
|
+
end
|
93
|
+
<<-HTML
|
94
|
+
<div class="miniblog.notify"><label for="miniblog.notify">
|
95
|
+
<input type="checkbox" id="miniblog.notify" name="miniblog.notify" value="true"#{checked} tabindex="400">
|
96
|
+
Post the update to #{@conf['miniblog.service']}
|
97
|
+
</label>
|
98
|
+
</div>
|
99
|
+
HTML
|
100
|
+
end
|
101
|
+
|
102
|
+
add_conf_proc( 'notify_miniblog', 'MiniBlog' ) do
|
103
|
+
notify_miniblog_init
|
104
|
+
|
105
|
+
if @mode == 'saveconf' then
|
106
|
+
@conf['miniblog.service'] = @cgi.params['miniblog.service'][0]
|
107
|
+
@conf['miniblog.user'] = @cgi.params['miniblog.user'][0]
|
108
|
+
@conf['miniblog.pass'] = @cgi.params['miniblog.pass'][0]
|
109
|
+
@conf['miniblog.notify.prefix'] = @cgi.params['miniblog.notify.prefix'][0]
|
110
|
+
@conf['miniblog.notify.format'] = @cgi.params['miniblog.notify.format'][0]
|
111
|
+
end
|
112
|
+
|
113
|
+
options = ''
|
114
|
+
@miniblog_list.each_key do |key|
|
115
|
+
options << %Q|<option value="#{h key}"#{" selected" if @conf['miniblog.service'] == key}>#{h key}</option>\n|
|
116
|
+
end
|
117
|
+
|
118
|
+
<<-HTML
|
119
|
+
<h3 class="subtitle">MiniBlog Service</h3>
|
120
|
+
<p><select name="miniblog.service">
|
121
|
+
#{options}
|
122
|
+
</select></p>
|
123
|
+
<h3 class="subtitle">Account Name</h3>
|
124
|
+
<p><input name="miniblog.user" value="#{h @conf['miniblog.user']}"></p>
|
125
|
+
<h3 class="subtitle">Account Password</h3>
|
126
|
+
<p><input name="miniblog.pass" value="#{h @conf['miniblog.pass']}"></p>
|
127
|
+
<h3 class="subtitle">Notify prefix</h3>
|
128
|
+
<p><input name="miniblog.notify.prefix" value="#{h @conf['miniblog.notify.prefix']}"></p>
|
129
|
+
<h3 class="subtitle">Notify status format</h3>
|
130
|
+
<p><input name="miniblog.notify.format" value="#{h @conf['miniblog.notify.format']}"></p>
|
131
|
+
HTML
|
132
|
+
end
|
133
|
+
|
134
|
+
# vim:ts=3
|
data/plugin/ogp.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# ogp.rb - add Open Graph Protocol <meta> tags to header
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011 MATSUOKA Kohei <kmachu@gmail.com>
|
4
|
+
# You can redistribute it and/or modify it under GPL2.
|
5
|
+
#
|
6
|
+
|
7
|
+
# @conf['ogp.facebook.app_id'] - your facebook application ID.
|
8
|
+
# @conf['ogp.facebook.admins'] - your facebook ID.
|
9
|
+
|
10
|
+
def ogp_description
|
11
|
+
section_index = @cgi.params['p'][0]
|
12
|
+
# section_index = "1"
|
13
|
+
if @mode == 'day' and section_index
|
14
|
+
diary = @diaries[@date.strftime('%Y%m%d')]
|
15
|
+
sections = diary.instance_variable_get(:@sections)
|
16
|
+
section = sections[section_index.to_i - 1].body_to_html
|
17
|
+
@conf.shorten(apply_plugin(section, true), 200)
|
18
|
+
else
|
19
|
+
@conf.description
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
add_header_proc do
|
24
|
+
headers = {
|
25
|
+
# TODO: og:urlへ対応
|
26
|
+
'og:title' => title_tag.match(/>([^<]+)</).to_a[1],
|
27
|
+
'og:site_name' => @conf.html_title,
|
28
|
+
'og:description' => ogp_description,
|
29
|
+
'og:image' => @conf.banner,
|
30
|
+
'og:type' => (@mode == 'day') ? 'article' : 'blog',
|
31
|
+
'og:author' => @conf.author_name,
|
32
|
+
'fb:app_id' => @conf['ogp.facebook.app_id'],
|
33
|
+
'fb:admins' => @conf['ogp.facebook.admins']
|
34
|
+
}
|
35
|
+
headers.select {|key, val|
|
36
|
+
val && !val.empty?
|
37
|
+
}.map {|key, val|
|
38
|
+
%Q|<meta property="#{key}" content="#{CGI::escapeHTML(val)}">|
|
39
|
+
}.join("\n")
|
40
|
+
end
|
41
|
+
|
42
|
+
add_conf_proc('Open Graph Protocol', 'Open Graph Protocol') do
|
43
|
+
if @mode == 'saveconf'
|
44
|
+
@conf['ogp.facebook.app_id'] = @cgi.params['ogp.facebook.app_id'][0]
|
45
|
+
@conf['ogp.facebook.admins'] = @cgi.params['ogp.facebook.admins'][0]
|
46
|
+
end
|
47
|
+
|
48
|
+
<<-HTML
|
49
|
+
<h3>Facebook Application ID</h3>
|
50
|
+
<p><input name="ogp.facebook.app_id" value="#{h(@conf['ogp.facebook.app_id'])}"></p>
|
51
|
+
|
52
|
+
<h3>Facebook User ID</h3>
|
53
|
+
<p><input name="ogp.facebook.admins" value="#{h(@conf['ogp.facebook.admins'])}"></p>
|
54
|
+
HTML
|
55
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# You can redistribute it and/or modify it under the same license as tDiary.
|
3
|
+
#
|
4
|
+
# display book info in http://estore.ohmsha.co.jp/ like amazon.rb
|
5
|
+
# USAGE: {{ohmsha_estore '978427406694P'}}
|
6
|
+
|
7
|
+
def ohmsha_estore_cache_dir
|
8
|
+
cache = "#{@cache_path}/ohmsha-estore"
|
9
|
+
Dir.mkdir( cache ) unless File.directory?( cache )
|
10
|
+
cache
|
11
|
+
end
|
12
|
+
|
13
|
+
def ohmsha_estore_cache_set( id, result )
|
14
|
+
File.open( "#{ohmsha_estore_cache_dir}/#{id}", "w" ) do |f|
|
15
|
+
f.write result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def ohmsha_estore_cache_get( id )
|
20
|
+
File.open( "#{ohmsha_estore_cache_dir}/#{id}", "r" ) do |f|
|
21
|
+
f.read
|
22
|
+
end
|
23
|
+
rescue
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def ohmsha_estore( id, doc = nil )
|
28
|
+
if !@conf.secure and !(result = ohmsha_estore_cache_get(id)).nil?
|
29
|
+
return result
|
30
|
+
end
|
31
|
+
|
32
|
+
domain = "http://estore.ohmsha.co.jp"
|
33
|
+
image = "#{domain}/images/covers/#{id}.gif"
|
34
|
+
link = "#{domain}/titles/#{id}"
|
35
|
+
require 'open-uri'
|
36
|
+
doc ||= open(link)
|
37
|
+
require 'rexml/document'
|
38
|
+
xml = REXML::Document.new( doc )
|
39
|
+
biblio = "//html/body/div/div[2]/div/div/div/div[2]"
|
40
|
+
title = REXML::XPath.match( xml,
|
41
|
+
"#{biblio}/h2").first.text
|
42
|
+
author = REXML::XPath.match( xml,
|
43
|
+
"#{biblio}/div" ).first.text
|
44
|
+
|
45
|
+
description =
|
46
|
+
REXML::XPath.match( xml, '//html/body/div/div[2]/div/div/div[2]' ).
|
47
|
+
first.text
|
48
|
+
|
49
|
+
result = <<-EOS
|
50
|
+
<a class="amazon-detail" href="#{h link}"><div class="amazon-detail">
|
51
|
+
<img class="amazon-detail left" src="#{h image}"
|
52
|
+
height="150" width="100"
|
53
|
+
alt="#{h title}">
|
54
|
+
<div class="amazon-detail-desc">
|
55
|
+
<span class="amazon-title">#{h title}</span><br>
|
56
|
+
<span class="amazon-author">#{h author}</span><br>
|
57
|
+
<span class="amazon-label">#{h description}</span><br>
|
58
|
+
</div><br style="clear: left">
|
59
|
+
</div></a>
|
60
|
+
EOS
|
61
|
+
|
62
|
+
ohmsha_estore_cache_set( id, result ) unless @conf.secure
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
66
|
+
# Local Variables:
|
67
|
+
# mode: ruby
|
68
|
+
# indent-tabs-mode: t
|
69
|
+
# tab-width: 3
|
70
|
+
# ruby-indent-level: 3
|
71
|
+
# End:
|