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,109 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# search-yahoo.rb - site search plugin sample using Yahoo! Search BOSS API.
|
4
|
+
#
|
5
|
+
# Copyright (C) 2009, TADA Tadashi <t@tdtds.jp>
|
6
|
+
# You can redistribute it and/or modify it under GPL.
|
7
|
+
#
|
8
|
+
# Needed these options below:
|
9
|
+
#
|
10
|
+
# @options['search-yahoo.appid'] : Your BOSS APPID
|
11
|
+
# @options['search-yahoo.result_filter'] : your dialy's URL format of DAY mode into Regexp.
|
12
|
+
#
|
13
|
+
|
14
|
+
require 'timeout'
|
15
|
+
require 'rexml/document'
|
16
|
+
require 'net/http'
|
17
|
+
Net::HTTP.version_1_2
|
18
|
+
|
19
|
+
def search_title
|
20
|
+
'全文検索 by Yahoo! Search BOSS'
|
21
|
+
end
|
22
|
+
|
23
|
+
def search_input_form( q )
|
24
|
+
r = <<-HTML
|
25
|
+
<form method="GET" action="#{@conf.index}"><div>
|
26
|
+
検索キーワード:
|
27
|
+
<input name="q" value="#{h q}">
|
28
|
+
<input type="submit" value="OK">
|
29
|
+
</div></form>
|
30
|
+
HTML
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_boss_api( q, start = 0 )
|
34
|
+
url = 'http://boss.yahooapis.com/ysearch/web/v1/'
|
35
|
+
appid = @conf['search-yahoo.appid']
|
36
|
+
|
37
|
+
url << "#{q}?appid=#{appid}&format=xml&count=20&start=#{start}"
|
38
|
+
|
39
|
+
proxy = @conf['proxy']
|
40
|
+
proxy = 'http://' + proxy if proxy
|
41
|
+
|
42
|
+
proxy_host, proxy_port = nil
|
43
|
+
if proxy
|
44
|
+
proxy_host = proxy_uri.host
|
45
|
+
proxy_port = proxy_uri.port
|
46
|
+
end
|
47
|
+
proxy_class = Net::HTTP::Proxy(proxy_host, proxy_port)
|
48
|
+
|
49
|
+
query = URI.parse(url)
|
50
|
+
req = Net::HTTP::Get.new(query.request_uri)
|
51
|
+
http = proxy_class.new(query.host, query.port)
|
52
|
+
http.open_timeout = 20
|
53
|
+
http.read_timeout = 20
|
54
|
+
res = http.start do
|
55
|
+
http.request(req)
|
56
|
+
end
|
57
|
+
res.body
|
58
|
+
end
|
59
|
+
|
60
|
+
def search_to_html( str )
|
61
|
+
(str || '').gsub( /(?:<wbr(?:[ \t\r\n][^>]*)?>)+/, '' ).gsub( %r{<(/?)b[ \t\n\r]*>}, '<\\1strong>' )
|
62
|
+
end
|
63
|
+
|
64
|
+
def search_result
|
65
|
+
query = CGI::unescape( @cgi.params['q'][0] )
|
66
|
+
start = CGI::unescape( @cgi.params['start'][0] || '0' ).to_i
|
67
|
+
|
68
|
+
begin
|
69
|
+
uri = URI::parse( @conf.base_url )
|
70
|
+
q = "#{query} site:#{uri.host}"
|
71
|
+
q << %Q| inurl:"#{uri.path}"| unless uri.path == '/'
|
72
|
+
xml = search_boss_api( u( q.untaint ), start )
|
73
|
+
doc = REXML::Document::new( REXML::Source.new( xml ) ).root
|
74
|
+
res = doc.elements.to_a( '/ysearchresponse' )[0]
|
75
|
+
unless res.attribute( 'responsecode' ).value == '200' then
|
76
|
+
return '<p class="message">ERROR</p>'
|
77
|
+
end
|
78
|
+
rescue OpenURI::HTTPError
|
79
|
+
return %Q|<p class="message">#$!</p>|
|
80
|
+
end
|
81
|
+
|
82
|
+
r = search_input_form( query )
|
83
|
+
r << '<dl class="search-result autopagerize_page_element">'
|
84
|
+
doc.elements.to_a( '*/result' ).each do |elem|
|
85
|
+
url = elem.elements.to_a( 'url' )[0].text
|
86
|
+
next unless url =~ @conf['search-yahoo.result_filter']
|
87
|
+
title = elem.elements.to_a( 'title' )[0].text
|
88
|
+
abstract = elem.elements.to_a( 'abstract' )[0].text
|
89
|
+
r << %Q|<dt><a href="#{h url}">#{search_to_html title}</a></dt>|
|
90
|
+
r << %Q|<dd>#{search_to_html abstract}</dd>|
|
91
|
+
end
|
92
|
+
r << '</dl>'
|
93
|
+
|
94
|
+
r << '<div class="search-navi">'
|
95
|
+
doc.elements.to_a( '/ysearchresponse/prevpage' ).each do |p|
|
96
|
+
if /start=\d+/ =~ p.text then
|
97
|
+
r << %Q|<a href="#{@conf.index}?q=#{u query}&#$&" rel="prev"><前の20件</a> |
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
doc.elements.to_a( '/ysearchresponse/nextpage' ).each do |n|
|
102
|
+
if /start=\d+/ =~ n.text then
|
103
|
+
r << %Q|<a href="#{@conf.index}?q=#{u query}&#$&" rel="next">次の20件></a>|
|
104
|
+
end
|
105
|
+
end
|
106
|
+
r << '</div>'
|
107
|
+
|
108
|
+
r
|
109
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# section_footer.rb
|
3
|
+
#
|
4
|
+
# Copyright (c) 2005 SHIBATA Hiroshi <h-sbt@nifty.com>
|
5
|
+
# You can redistribute it and/or modify it under GPL2.
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'digest/md5'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'timeout'
|
11
|
+
|
12
|
+
def permalink( date, index, escape = true )
|
13
|
+
ymd = date.strftime( "%Y%m%d" )
|
14
|
+
uri = @conf.index.dup
|
15
|
+
uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
|
16
|
+
uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
|
17
|
+
link = uri + anchor( "#{ymd}p%02d" % index )
|
18
|
+
link.sub!( "#", "%23" ) if escape
|
19
|
+
link
|
20
|
+
end
|
21
|
+
|
22
|
+
add_header_proc do
|
23
|
+
<<-SCRIPT
|
24
|
+
<link rel="stylesheet" href="theme/hatena_bookmark.css" type="text/css" media="all">
|
25
|
+
<script type="text/javascript" src="http://b.hatena.ne.jp/js/BookmarkCommentViewerAllInOne.1.2.js" charset="utf-8"></script>
|
26
|
+
<script type="text/javascript">
|
27
|
+
initCreateRelAfterIcon();
|
28
|
+
BookmarkCommentViewer.options['dateFormat'] = '%y-%m-%d';
|
29
|
+
// BookmarkCommentViewer.options['blankCommentHide'] = true;
|
30
|
+
BookmarkCommentViewer.options['tags'] = false;
|
31
|
+
</script>
|
32
|
+
SCRIPT
|
33
|
+
end
|
34
|
+
|
35
|
+
add_section_enter_proc do |date, index|
|
36
|
+
@category_to_tag_list = {}
|
37
|
+
end
|
38
|
+
|
39
|
+
alias subtitle_link_original subtitle_link
|
40
|
+
def subtitle_link( date, index, subtitle )
|
41
|
+
s = ''
|
42
|
+
if subtitle then
|
43
|
+
s = subtitle.sub( /^(\[([^\[]+?)\])+/ ) do
|
44
|
+
$&.scan( /\[(.*?)\]/ ) do |tag|
|
45
|
+
@category_to_tag_list[tag] = false # false when diary
|
46
|
+
end
|
47
|
+
''
|
48
|
+
end
|
49
|
+
end
|
50
|
+
subtitle_link_original( date, index, s.strip )
|
51
|
+
end
|
52
|
+
|
53
|
+
add_section_leave_proc do |date, index|
|
54
|
+
r = '<div class="tags">'
|
55
|
+
|
56
|
+
unless @conf.mobile_agent? then
|
57
|
+
# カテゴリタグの追加
|
58
|
+
if @category_to_tag_list and not @category_to_tag_list.empty? then
|
59
|
+
r << "Tags: "
|
60
|
+
@category_to_tag_list.each do |tag, blog|
|
61
|
+
if blog
|
62
|
+
r << %Q|<a href="#{@index}?blogcategory=#{h tag}">#{tag}</a> |
|
63
|
+
else
|
64
|
+
r << category_anchor( "#{tag}" ).sub( /^\[/, '' ).sub( /\]$/, '' ) << ' '
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# 「このエントリの Delicious history (JSON)」
|
70
|
+
r << add_delicious_json(date, index)
|
71
|
+
|
72
|
+
# 「このエントリを含む Delicious (画像API)」
|
73
|
+
# r << add_delicious(date, index)
|
74
|
+
|
75
|
+
# 「このエントリを含むはてなブックーク」
|
76
|
+
r << add_hatenabm(date, index)
|
77
|
+
|
78
|
+
# 「このエントリを含む livedoor クリップ」
|
79
|
+
r << add_ldclip(date, index)
|
80
|
+
|
81
|
+
# 「このエントリを含む Buzzurl」
|
82
|
+
r << add_buzzurl(date, index)
|
83
|
+
|
84
|
+
# 「このエントリを含む Yahoo!ブックマーク」
|
85
|
+
r << add_yahoobm(date, index)
|
86
|
+
|
87
|
+
# Permalinkの追加
|
88
|
+
r << add_permalink(date, index)
|
89
|
+
end
|
90
|
+
|
91
|
+
r << "</div>\n"
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_permalink(date, index)
|
95
|
+
r = " | "
|
96
|
+
r << %Q|<a href="#{permalink(date, index, false)}">Permalink</a> |
|
97
|
+
return r
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_hatenabm(date, index)
|
101
|
+
r = " | "
|
102
|
+
r << %Q|<a href="http://b.hatena.ne.jp/entry/#{permalink(date, index)}"><img src="http://d.hatena.ne.jp/images/b_entry.gif" style="border: 0 none;vertical-align: middle;" title="#{@section_footer_hatenabm_label}" alt="#{@section_footer_hatenabm_label}" width="16" height="12"> <img src="http://b.hatena.ne.jp/entry/image/normal/#{permalink(date, index)}" style="border: 0 none;vertical-align: middle;"></a> <img src="http://r.hatena.ne.jp/images/popup.gif" style="border: 0 none;vertical-align: middle;" onclick="iconImageClickHandler(this, '#{permalink(date, index, false)}', event);" alt="">|
|
103
|
+
return r
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_ldclip(date, index)
|
107
|
+
r = " | "
|
108
|
+
r << %Q|<a href="http://clip.livedoor.com/page/#{permalink(date, index)}"><img src="http://parts.blog.livedoor.jp/img/cmn/clip_16_16_w.gif" width="16" height="16" style="border: 0 none;vertical-align: middle;" alt="#{@section_footer_ldclip_label}" title="#{@section_footer_ldclip_label}"> <img src="http://image.clip.livedoor.com/counter/#{permalink(date, index)}" style="border: 0 none;vertical-align: middle;"></a>|
|
109
|
+
return r
|
110
|
+
end
|
111
|
+
|
112
|
+
def add_buzzurl(date, index)
|
113
|
+
r = " | "
|
114
|
+
r << %Q|<a href="http://buzzurl.jp/entry/#{permalink(date, index)}"><img src="http://buzzurl.jp/static/image/api/icon/add_icon_mini_10.gif" style="border: 0 none;vertical-align: middle;" title="#{@section_footer_buzzurl_label}" alt="#{@section_footer_buzzurl_label}" width="16" height="12" class="icon"> <img src="http://buzzurl.jp/api/counter/#{permalink(date, index)}" style="border: 0 none;vertical-align: middle;"></a>|
|
115
|
+
return r
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_delicious(date, index)
|
119
|
+
url_md5 = Digest::MD5.hexdigest(permalink(date, index, false))
|
120
|
+
|
121
|
+
r = " | "
|
122
|
+
r << %Q|<a href="http://delicious.com/url/#{url_md5}"><img src="http://static.delicious.com/img/delicious.small.gif" width="10" height="10" style="border: 0 none;vertical-align: middle;" alt="#{@section_footer_delicious_label}" title="#{@section_footer_delicious_label}"> <img src="http://del.icio.us/feeds/img/savedcount/#{url_md5}?aggregate" style="border: 0 none;margin: 0;"></a>|
|
123
|
+
return r
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_delicious_json(date, index)
|
127
|
+
require 'fileutils'
|
128
|
+
begin
|
129
|
+
require 'json'
|
130
|
+
rescue
|
131
|
+
retry if require 'rubygems'
|
132
|
+
end
|
133
|
+
|
134
|
+
url_md5 = Digest::MD5.hexdigest(permalink(date, index, false))
|
135
|
+
cache_dir = "#{@cache_path}/delicious/#{date.strftime( "%Y%m" )}/"
|
136
|
+
file_name = "#{cache_dir}/#{url_md5}.json"
|
137
|
+
cache_time = 8 * 60 * 60 # 8 hour
|
138
|
+
update = false
|
139
|
+
count = 0
|
140
|
+
|
141
|
+
r = " | "
|
142
|
+
r << %Q|<a href="http://delicious.com/url/#{url_md5}"><img src="http://static.delicious.com/img/delicious.small.gif" width="10" height="10" style="border: 0 none;vertical-align: middle;" alt="#{@section_footer_delicious_label}" title="#{@section_footer_delicious_label}">|
|
143
|
+
|
144
|
+
begin
|
145
|
+
FileUtils.mkdir_p( cache_dir ) unless File::directory?( cache_dir )
|
146
|
+
cached_time = nil
|
147
|
+
cached_time = File::mtime( file_name ) if File::exist?( file_name )
|
148
|
+
|
149
|
+
unless cached_time.nil?
|
150
|
+
if Time.now > cached_time + cache_time
|
151
|
+
update = true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
if cached_time.nil? or update
|
156
|
+
begin
|
157
|
+
timeout(10) do
|
158
|
+
open( "http://feeds.delicious.com/v2/json/urlinfo/#{url_md5}") do |file|
|
159
|
+
File::open( file_name, 'wb' ) do |f|
|
160
|
+
f.write( file.read )
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
rescue => e
|
165
|
+
@logger.debug( e )
|
166
|
+
end
|
167
|
+
end
|
168
|
+
rescue
|
169
|
+
end
|
170
|
+
|
171
|
+
begin
|
172
|
+
File::open( file_name ) do |f|
|
173
|
+
data = JSON.parse(@conf.to_native( f.read, 'utf-8' ))
|
174
|
+
unless data[0].nil?
|
175
|
+
count = data[0]["total_posts"].to_i
|
176
|
+
end
|
177
|
+
end
|
178
|
+
rescue
|
179
|
+
end
|
180
|
+
|
181
|
+
if count > 0
|
182
|
+
r << %Q| #{count} users</a>|
|
183
|
+
else
|
184
|
+
r << %Q|</a>|
|
185
|
+
end
|
186
|
+
|
187
|
+
return r
|
188
|
+
end
|
189
|
+
|
190
|
+
def add_yahoobm(date, index)
|
191
|
+
r = " | "
|
192
|
+
r << %Q|<a href="http://bookmarks.yahoo.co.jp/url?url=#{permalink(date, index)}&opener=bm&ei=UTF-8"><img src="http://i.yimg.jp/images/sicons/ybm16.gif" style="border: 0 none;vertical-align: middle;" title="#{@section_footer_yahoobm_label}" alt="#{@section_footer_yahoobm_label}" width="16" height="16" class="icon"></a>|
|
193
|
+
return r
|
194
|
+
end
|
195
|
+
|
@@ -0,0 +1,278 @@
|
|
1
|
+
# section_footer2.rb
|
2
|
+
#
|
3
|
+
# Copyright (c) 2008 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
4
|
+
# You can redistribute it and/or modify it under GPL2.
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'digest/md5'
|
8
|
+
require 'timeout'
|
9
|
+
require 'open-uri'
|
10
|
+
require 'yaml'
|
11
|
+
require 'pathname'
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'json'
|
15
|
+
rescue LoadError
|
16
|
+
retry if require 'rubygems'
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def permalink( date, index, escape = true )
|
21
|
+
ymd = date.strftime( "%Y%m%d" )
|
22
|
+
uri = @conf.index.dup
|
23
|
+
uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
|
24
|
+
uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
|
25
|
+
link = uri + anchor( "#{ymd}p%02d" % index )
|
26
|
+
link.sub!( "#", "%23" ) if escape
|
27
|
+
link
|
28
|
+
end
|
29
|
+
|
30
|
+
unless defined?(subtitle)
|
31
|
+
def subtitle( date, index, escape = true )
|
32
|
+
diary = @diaries[date.strftime( "%Y%m%d" )]
|
33
|
+
return "" unless diary
|
34
|
+
sn = 1
|
35
|
+
diary.each_section do |section|
|
36
|
+
if sn == index
|
37
|
+
old_apply_plugin = @options["apply_plugin"]
|
38
|
+
@options["apply_plugin"] = true
|
39
|
+
title = apply_plugin( section.subtitle_to_html, true )
|
40
|
+
@options["apply_plugin"] = old_apply_plugin
|
41
|
+
title.gsub!( /(?=")/, "\\" ) if escape
|
42
|
+
return title
|
43
|
+
end
|
44
|
+
sn += 1
|
45
|
+
end
|
46
|
+
''
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def init_buttons_status
|
51
|
+
@installed_buttons = ['yaml', 'delicious', 'hatena', 'facebook', 'twitter', 'plusone']
|
52
|
+
if @conf['section_footer2.isDisplay'].nil?
|
53
|
+
@conf['section_footer2.isDisplay'] = ''
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
add_header_proc do
|
58
|
+
<<-"EOS"
|
59
|
+
<script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button_wo_al.js" charset="utf-8" async="async"></script>
|
60
|
+
<style type="text/css">iframe.hatena-bookmark-button-frame {margin-bottom: -7px; }</style>
|
61
|
+
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
|
62
|
+
<style type="text/css">iframe.twitter-share-button.twitter-count-horizontal {margin-bottom: -6px; }</style>
|
63
|
+
<script src="http://connect.facebook.net/#{@section_footer2_locale}/all.js"></script>
|
64
|
+
<script>
|
65
|
+
FB.init({
|
66
|
+
appId : '',
|
67
|
+
status : true, // check login status
|
68
|
+
cookie : true, // enable cookies to allow the server to access the session
|
69
|
+
xfbml : true // parse XFBML
|
70
|
+
});
|
71
|
+
</script>
|
72
|
+
<style type="text/css">iframe.fb_ltr {margin-bottom: -2px; margin-right: 4px;}</style>
|
73
|
+
<script type="text/javascript" src="http://apis.google.com/js/plusone.js">
|
74
|
+
{lang: '#{@section_footer2_locale}'}
|
75
|
+
</script>
|
76
|
+
<style type="text/css">.tags > div > iframe {margin-bottom: -6px !important; }</style>
|
77
|
+
EOS
|
78
|
+
end
|
79
|
+
|
80
|
+
add_section_enter_proc do |date, index|
|
81
|
+
@category_to_tag_list = {}
|
82
|
+
init_buttons_status
|
83
|
+
''
|
84
|
+
end
|
85
|
+
|
86
|
+
alias section_footer2_subtitle_link_original subtitle_link unless defined?( section_footer2_subtitle_link_original )
|
87
|
+
def subtitle_link( date, index, subtitle )
|
88
|
+
s = ''
|
89
|
+
@subtitle = subtitle
|
90
|
+
if subtitle then
|
91
|
+
s = subtitle.sub( /^(?:\[[^\[]+?\])+/ ) do
|
92
|
+
$&.scan( /\[(.*?)\]/ ) do |tag|
|
93
|
+
@category_to_tag_list[tag.shift] = false # false when diary
|
94
|
+
end
|
95
|
+
''
|
96
|
+
end
|
97
|
+
end
|
98
|
+
section_footer2_subtitle_link_original( date, index, s.strip )
|
99
|
+
end
|
100
|
+
|
101
|
+
add_section_leave_proc do |date, index|
|
102
|
+
unless @conf.mobile_agent? or @conf.iphone? or feed? or bot?
|
103
|
+
r = '<div class="tags">'
|
104
|
+
# add category_tag
|
105
|
+
if @category_to_tag_list and not @category_to_tag_list.empty? then
|
106
|
+
r << "Tags: "
|
107
|
+
@category_to_tag_list.each do |tag, blog|
|
108
|
+
r << category_anchor( "#{tag}" ).sub( /^\[/, '' ).sub( /\]$/, '' ) << ' '
|
109
|
+
end
|
110
|
+
r << ' | '
|
111
|
+
end
|
112
|
+
|
113
|
+
# add button
|
114
|
+
r << add_button_by_service(date, index)
|
115
|
+
|
116
|
+
# add Permalink
|
117
|
+
r << %Q|<a href="#{permalink(date, index, false)}">Permalink</a> |
|
118
|
+
|
119
|
+
r << "</div>\n"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def call_delicious_json( url_md5 )
|
124
|
+
json = nil
|
125
|
+
begin
|
126
|
+
timeout(10) do
|
127
|
+
open( "http://feeds.delicious.com/v2/json/urlinfo/#{url_md5}" ) do |f|
|
128
|
+
json = JSON.parse( f.read )
|
129
|
+
end
|
130
|
+
end
|
131
|
+
rescue => e
|
132
|
+
@logger.debug( e )
|
133
|
+
end
|
134
|
+
return json
|
135
|
+
end
|
136
|
+
|
137
|
+
def add_delicious( date, index )
|
138
|
+
url_md5 = Digest::MD5.hexdigest(permalink(date, index, false))
|
139
|
+
db_file = "#{@cache_path}/delicious.cache"
|
140
|
+
|
141
|
+
r = ''
|
142
|
+
r << %Q|<a href="http://delicious.com/url/#{url_md5}"><img src="http://static.delicious.com/img/delicious.small.gif" style="border: none;vertical-align: middle;" alt="#{@section_footer2_delicious_label}" title="#{@section_footer2_delicious_label}">|
|
143
|
+
|
144
|
+
begin
|
145
|
+
cache_time = 8 * 60 * 60 # 12 hour
|
146
|
+
|
147
|
+
PStore.new(db_file).transaction do |db|
|
148
|
+
entry = db[url_md5]
|
149
|
+
entry = { :count => 0, :update=> Time.at(0) } if entry.nil?
|
150
|
+
|
151
|
+
if Time.now > entry[:update] + cache_time
|
152
|
+
json = call_delicious_json( url_md5 )
|
153
|
+
entry[:count] = json[0]["total_posts"].to_i unless json[0].nil?
|
154
|
+
entry[:update] = Time.now
|
155
|
+
db[url_md5] = entry
|
156
|
+
end
|
157
|
+
|
158
|
+
if entry[:count] > 0
|
159
|
+
r << %Q| #{entry[:count]} user|
|
160
|
+
r << 's' if entry[:count] > 1
|
161
|
+
end
|
162
|
+
end
|
163
|
+
rescue => e
|
164
|
+
@logger.debug( e )
|
165
|
+
end
|
166
|
+
|
167
|
+
r << '</a>'
|
168
|
+
r << ' | '
|
169
|
+
|
170
|
+
return r
|
171
|
+
end
|
172
|
+
|
173
|
+
def add_hatena( date, index )
|
174
|
+
%Q!<a href="http://b.hatena.ne.jp/entry/#{permalink( date, index )}" class="hatena-bookmark-button" data-hatena-bookmark-layout="standard"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" width="20" height="20" style="border: none;" /></a> | !
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_facebook(date, index)
|
178
|
+
# add Facebook Like!
|
179
|
+
r = ''
|
180
|
+
r << %Q!<fb:like href="#{permalink(date, index, false)}" layout="button_count"></fb:like> | !
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_twitter(date, index)
|
184
|
+
r = <<-"EOS"
|
185
|
+
<a href="http://twitter.com/share" class="twitter-share-button"
|
186
|
+
data-url="#{permalink(date, index, false).gsub(/#.*$/, '')}"
|
187
|
+
data-text="#{CGI.escapeHTML(subtitle(date, index))}"
|
188
|
+
data-via="#{@conf['twitter.user']}"
|
189
|
+
>tweet</a> |
|
190
|
+
EOS
|
191
|
+
end
|
192
|
+
|
193
|
+
def add_plusone(date, index)
|
194
|
+
%Q!<g:plusone size="medium" href="#{permalink(date, index, false)}"></g:plusone> | !
|
195
|
+
end
|
196
|
+
|
197
|
+
def add_yaml(date, index)
|
198
|
+
r = ''
|
199
|
+
yaml_dir = "#{@cache_path}/yaml/"
|
200
|
+
Dir.glob( yaml_dir + "*.yaml" ) do |file|
|
201
|
+
r << parse_sbm_yaml(file, date, index)
|
202
|
+
end
|
203
|
+
return r
|
204
|
+
end
|
205
|
+
|
206
|
+
def add_button_by_service(date, index)
|
207
|
+
|
208
|
+
r = ''
|
209
|
+
|
210
|
+
@installed_buttons.each do |button|
|
211
|
+
if @conf['section_footer2.isDisplay'].include?(button) then
|
212
|
+
method = "add_" + button + "(date, index)"
|
213
|
+
unless method.nil? then
|
214
|
+
r << instance_eval(method)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
return r
|
219
|
+
end
|
220
|
+
|
221
|
+
def parse_sbm_yaml(file, date, index)
|
222
|
+
config = YAML.load( Pathname.new( file ).expand_path.read )
|
223
|
+
r = ""
|
224
|
+
|
225
|
+
unless config.nil?
|
226
|
+
|
227
|
+
url = config["url"]
|
228
|
+
unless config['usesubtitle'].nil?
|
229
|
+
sub = (@subtitle || '').sub( /\A(?:\[[^\]]*\])+ */, '' )
|
230
|
+
sub = apply_plugin( sub, true ).strip
|
231
|
+
regexp = config["usesubtitle"]
|
232
|
+
url.gsub!(regexp, sub)
|
233
|
+
char_space = ' '
|
234
|
+
end
|
235
|
+
|
236
|
+
title = config["title"][@conf.lang]
|
237
|
+
r << %Q|<a href="#{url}#{char_space}#{permalink(date, index)}">|
|
238
|
+
r << %Q|<img src="#{config["src"]}" style="border: none;vertical-align: middle;" |
|
239
|
+
r << %Q|title="#{title}" |
|
240
|
+
r << %Q|alt="#{title}">|
|
241
|
+
r << %Q| <img src="#{config["counter"]}#{permalink(date, index)}" style="border: none;vertical-align: middle;">| unless config["counter"].nil?
|
242
|
+
r << '</a>'
|
243
|
+
r << ' | '
|
244
|
+
end
|
245
|
+
|
246
|
+
return r
|
247
|
+
end
|
248
|
+
|
249
|
+
add_conf_proc('section_footer2', 'Section Footer Button') do
|
250
|
+
|
251
|
+
if @mode == 'saveconf' then
|
252
|
+
@conf['section_footer2.isDisplay'] = ''
|
253
|
+
@cgi.params['section_footer2.isDisplay'].each do |item|
|
254
|
+
@conf['section_footer2.isDisplay'] << item + '\n'
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
r = '<h3>表示するボタンをチェックしてください(YAMLをチェックすると各自でインストールしたYAMLのボタンをすべて表示します)</h3>'
|
259
|
+
r << '<p>'
|
260
|
+
init_buttons_status
|
261
|
+
@installed_buttons.each do |button|
|
262
|
+
if @conf['section_footer2.isDisplay'].include?(button) then
|
263
|
+
item_checked = "checked"
|
264
|
+
else
|
265
|
+
item_checked = ''
|
266
|
+
end
|
267
|
+
r << %Q|<input name="section_footer2.isDisplay" value="#{button}" #{item_checked} type="checkbox" />#{button}|
|
268
|
+
end
|
269
|
+
r << '</p>'
|
270
|
+
end
|
271
|
+
|
272
|
+
# Local Variables:
|
273
|
+
# mode: ruby
|
274
|
+
# indent-tabs-mode: t
|
275
|
+
# tab-width: 3
|
276
|
+
# ruby-indent-level: 3
|
277
|
+
# End:
|
278
|
+
# vim: ts=3
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011, KADO Masanori <kdmsnr@gmail.com>
|
3
|
+
# You can redistribute it and/or modify it under GPL.
|
4
|
+
#
|
5
|
+
# section_permalink.rb
|
6
|
+
# - enables section permalink and shows section title
|
7
|
+
|
8
|
+
def section_mode?
|
9
|
+
@mode == 'day' and @cgi.params['p'][0].to_s != ""
|
10
|
+
end
|
11
|
+
|
12
|
+
# Change permalink
|
13
|
+
def anchor( s )
|
14
|
+
if /^([\-\d]+)#?([pct]\d*)?$/ =~ s then
|
15
|
+
if $2 then
|
16
|
+
s1 = $1
|
17
|
+
s2 = $2
|
18
|
+
if $2 =~ /^p/
|
19
|
+
"?date=#{s1}&p=#{s2.gsub(/p/, '')}"
|
20
|
+
else
|
21
|
+
"?date=#{s1}.html##{s2}"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
"?date=#$1"
|
25
|
+
end
|
26
|
+
else
|
27
|
+
""
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Change HTML title to section name
|
32
|
+
alias :_orig_title_tag :title_tag
|
33
|
+
def title_tag
|
34
|
+
if section_mode? and diary = @diaries[@date.strftime('%Y%m%d')]
|
35
|
+
sections = diary.instance_variable_get(:@sections)
|
36
|
+
|
37
|
+
title = "<title>"
|
38
|
+
section = sections[@cgi.params['p'][0].to_i - 1].stripped_subtitle_to_html
|
39
|
+
title << apply_plugin(section, true).chomp
|
40
|
+
title << " - #{h @html_title}"
|
41
|
+
title << "(#{@date.strftime( '%Y-%m-%d' )})" if @date
|
42
|
+
title << "</title>"
|
43
|
+
return title
|
44
|
+
else
|
45
|
+
_orig_title_tag
|
46
|
+
end
|
47
|
+
rescue
|
48
|
+
_orig_title_tag
|
49
|
+
end
|
50
|
+
|
51
|
+
add_header_proc do
|
52
|
+
if section_mode? and diary = @diaries[@date.strftime('%Y%m%d')]
|
53
|
+
index = @cgi.params['p'][0]
|
54
|
+
<<-EOS
|
55
|
+
<script type="text/javascript">
|
56
|
+
$(document).ready(function() {
|
57
|
+
var anc = $("a[name=p#{h(index)}]");
|
58
|
+
anc.parent().css("background-color", "yellow");
|
59
|
+
var dest = anc.offset().top;
|
60
|
+
$("body").animate({scrollTop: dest});
|
61
|
+
});
|
62
|
+
</script>
|
63
|
+
EOS
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Local Variables:
|
68
|
+
# mode: ruby
|
69
|
+
# indent-tabs-mode: t
|
70
|
+
# tab-width: 3
|
71
|
+
# ruby-indent-level: 3
|
72
|
+
# End:
|
73
|
+
# vim: ts=3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011, KADO Masanori <kdmsnr@gmail.com>
|
3
|
+
# You can redistribute it and/or modify it under GPL.
|
4
|
+
#
|
5
|
+
# section_permalink_anchor.rb
|
6
|
+
# - enables section permalink with mod_rewrite
|
7
|
+
# - depends on section_permalink.rb
|
8
|
+
#
|
9
|
+
# sample .htaccess:
|
10
|
+
# <IfModule mod_rewrite.c>
|
11
|
+
# RewriteEngine on
|
12
|
+
# RewriteRule ^([0-9\-]+)p?([0-9]*)\.html$ ?date=$1&p=$2 [L]
|
13
|
+
# </IfModule>
|
14
|
+
|
15
|
+
def anchor( s )
|
16
|
+
if /^([\-\d]+)#?([pct]\d*)?$/ =~ s then
|
17
|
+
if $2 then
|
18
|
+
s1 = $1
|
19
|
+
s2 = $2
|
20
|
+
if $2 =~ /^p/
|
21
|
+
"#{s1}#{s2}.html"
|
22
|
+
else
|
23
|
+
"#{s1}.html##{s2}"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
"#$1.html"
|
27
|
+
end
|
28
|
+
else
|
29
|
+
""
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Local Variables:
|
34
|
+
# mode: ruby
|
35
|
+
# indent-tabs-mode: t
|
36
|
+
# tab-width: 3
|
37
|
+
# ruby-indent-level: 3
|
38
|
+
# End:
|
39
|
+
# vim: ts=3
|