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,38 @@
|
|
1
|
+
# -*- coding: utf-8; -*-
|
2
|
+
#
|
3
|
+
# lazy_referer.rb: lazy loading referer
|
4
|
+
#
|
5
|
+
# Copyright (C) 2013 by MATSUOKA Kohei <kmachu@gmail.com>
|
6
|
+
# You can distribute it under GPL.
|
7
|
+
#
|
8
|
+
if /^(day|form|edit)$/ =~ @mode and not bot? then
|
9
|
+
enable_js('referer.js')
|
10
|
+
|
11
|
+
#
|
12
|
+
# overwrite method: draw only referer area (content will feach with ajax)
|
13
|
+
#
|
14
|
+
def referer_of_today_long( diary, limit )
|
15
|
+
return if limit == 0
|
16
|
+
return unless diary
|
17
|
+
date = diary.date.strftime('%Y%m%d')
|
18
|
+
# FIXME: endpoint is should created by TDiary::Plugin, because easy customize routing
|
19
|
+
endpoint = "#{@conf.index}?plugin=referer&date=#{date}"
|
20
|
+
%Q[<button class="lazy_referer" style="padding: 0.5em; width: 20em;" data-endpoint="#{h endpoint}">#{referer_today}</button>\n]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# return referer of date as is (html)
|
26
|
+
#
|
27
|
+
add_content_proc('referer') do |date|
|
28
|
+
diary = @diaries[date]
|
29
|
+
referer_load_current( diary )
|
30
|
+
referer_of_today_long( diary, 100 )
|
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:
|
@@ -0,0 +1,180 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# livedoor_weather.rb
|
3
|
+
#
|
4
|
+
# insert weather information using livedoor weather web service.
|
5
|
+
#
|
6
|
+
# Copyright (C) 2007 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
7
|
+
# You can redistribute it and/or modify it under GPL2.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'open-uri'
|
11
|
+
require 'timeout'
|
12
|
+
require 'time'
|
13
|
+
|
14
|
+
@lwws_rest_url = 'http://weather.livedoor.com/forecast/webservice/json/v1'
|
15
|
+
|
16
|
+
def lwws_init
|
17
|
+
@conf['lwws.city_id'] ||= 130010
|
18
|
+
@conf['lwws.icon.disp'] ||= ""
|
19
|
+
@conf['lwws.max_temp.disp'] ||= ""
|
20
|
+
@conf['lwws.min_temp.disp'] ||= ""
|
21
|
+
@conf['lwws.cache'] ||= ""
|
22
|
+
@conf['lwws.cache_time'] ||= 6
|
23
|
+
end
|
24
|
+
|
25
|
+
def lwws_request( city_id )
|
26
|
+
url = @lwws_rest_url.dup
|
27
|
+
url << "?city=#{city_id}"
|
28
|
+
|
29
|
+
proxy = @conf['proxy']
|
30
|
+
proxy = 'http://' + proxy if proxy
|
31
|
+
timeout( 10 ) do
|
32
|
+
open( url, :proxy => proxy ) {|f| f.read }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def lwws_get
|
37
|
+
lwws_init
|
38
|
+
|
39
|
+
city_id = @conf['lwws.city_id']
|
40
|
+
cache_time = @conf['lwws.cache_time'] * 60 * 60
|
41
|
+
file_name = "#{@cache_path}/lwws/#{Time.now.strftime("%Y%m%d")}.json"
|
42
|
+
|
43
|
+
begin
|
44
|
+
Dir.mkdir("#{@cache_path}/lwws") unless File.directory?("#{@cache_path}/lwws")
|
45
|
+
|
46
|
+
cached_time = if File.exist?( file_name )
|
47
|
+
File.mtime( file_name )
|
48
|
+
else
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
|
52
|
+
update = true if @conf['lwws.cache'] == "t" && cached_time && Time.now > cached_time + cache_time
|
53
|
+
|
54
|
+
if cached_time.nil? || update
|
55
|
+
json = lwws_request(city_id)
|
56
|
+
File.open(file_name, 'wb') {|f| f.write(json)}
|
57
|
+
end
|
58
|
+
rescue => e
|
59
|
+
@logger.error( e )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def lwws_to_html(date)
|
64
|
+
lwws_init
|
65
|
+
|
66
|
+
file_name = "#{@cache_path}/lwws/#{date.strftime("%Y%m%d")}.xml"
|
67
|
+
|
68
|
+
begin
|
69
|
+
# http://weather.livedoor.com/help/restapi_close
|
70
|
+
if Time.parse('20130331') < date
|
71
|
+
file_name.sub!(/xml/, 'json')
|
72
|
+
require 'json'
|
73
|
+
doc = JSON.parse(File.read(file_name))
|
74
|
+
|
75
|
+
telop = @conf.to_native( doc["forecasts"][0]["telop"], 'utf-8' )
|
76
|
+
# 「今日」のデータに気温は含まれない場合がある
|
77
|
+
max_temp = doc["forecasts"][0]["temperature"]["max"]["celsius"] rescue nil
|
78
|
+
min_temp = doc["forecasts"][0]["temperature"]["min"]["celsius"] rescue nil
|
79
|
+
detail_url = doc["link"]
|
80
|
+
title = @conf.to_native( doc["forecasts"][0]["image"]["title"], 'utf-8' )
|
81
|
+
url = doc["forecasts"][0]["image"]["url"]
|
82
|
+
width = doc["forecasts"][0]["image"]["width"]
|
83
|
+
height = doc["forecasts"][0]["image"]["height"]
|
84
|
+
else
|
85
|
+
require 'rexml/document'
|
86
|
+
doc = REXML::Document.new(File.read(file_name)).root
|
87
|
+
|
88
|
+
telop = @conf.to_native( doc.elements["telop"].text, 'utf-8' )
|
89
|
+
max_temp = doc.elements["temperature/max/celsius"].text
|
90
|
+
min_temp = doc.elements["temperature/min/celsius"].text
|
91
|
+
detail_url = doc.elements["link"].text
|
92
|
+
title = @conf.to_native( doc.elements["image/title"].text, 'utf-8' )
|
93
|
+
url = doc.elements["image/url"].text
|
94
|
+
width = doc.elements["image/width"].text
|
95
|
+
height = doc.elements["image/height"].text
|
96
|
+
end
|
97
|
+
|
98
|
+
result = ""
|
99
|
+
result << %Q|<div class="lwws">|
|
100
|
+
if @conf['lwws.icon.disp'] != "t" or @conf.mobile_agent? then
|
101
|
+
result << %Q|<a href="#{h(detail_url)}">#{telop}</a>|
|
102
|
+
else
|
103
|
+
result << %Q|<a href="#{h(detail_url)}"><img src="#{url}" border="0" alt="#{title}" title="#{title}" width=#{width} height="#{height}"></a>|
|
104
|
+
end
|
105
|
+
if @conf['lwws.max_temp.disp'] == "t" and not max_temp.nil? then
|
106
|
+
result << %Q| #{@lwws_max_temp_label}:#{h(max_temp)}#{@celsius_label}|
|
107
|
+
end
|
108
|
+
if @conf['lwws.min_temp.disp'] == "t" and not min_temp.nil? then
|
109
|
+
result << %Q| #{@lwws_min_temp_label}:#{h(min_temp)}#{@celsius_label}|
|
110
|
+
end
|
111
|
+
result << %Q|</div>|
|
112
|
+
|
113
|
+
result
|
114
|
+
rescue StandardError, Errno::ENOENT => e
|
115
|
+
@logger.error( e )
|
116
|
+
''
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def lwws_conf_proc
|
121
|
+
lwws_init
|
122
|
+
|
123
|
+
if @mode == 'saveconf' then
|
124
|
+
@conf['lwws.city_id'] = @cgi.params['lwws.city_id'][0].to_i
|
125
|
+
@conf['lwws.icon.disp'] = @cgi.params['lwws.icon.disp'][0]
|
126
|
+
@conf['lwws.max_temp.disp'] = @cgi.params['lwws.max_temp.disp'][0]
|
127
|
+
@conf['lwws.min_temp.disp'] = @cgi.params['lwws.min_temp.disp'][0]
|
128
|
+
@conf['lwws.cache'] = @cgi.params['lwws.cache'][0]
|
129
|
+
@conf['lwws.cache_time'] = @cgi.params['lwws.cache_time'][0].to_i
|
130
|
+
end
|
131
|
+
|
132
|
+
result = ''
|
133
|
+
|
134
|
+
result << <<-HTML
|
135
|
+
<h3>#{@lwws_label_city_id}</h3>
|
136
|
+
<p>#{@lwws_desc_city_id}</p>
|
137
|
+
<p><input name="lwws.city_id" value="#{h(@conf['lwws.city_id'])}"></p>
|
138
|
+
HTML
|
139
|
+
|
140
|
+
result << %Q|<h3>#{@lwws_icon_label}</h3>|
|
141
|
+
checked = "t" == @conf['lwws.icon.disp'] ? ' checked' : ''
|
142
|
+
result << %Q|<p><label for="lwws.icon.disp"><input id="lwws.icon.disp" name="lwws.icon.disp" type="checkbox" value="t"#{checked}>#{@lwws_icon_desc}</label></p>|
|
143
|
+
result << %Q|<h3>#{@lwws_label_disp_item}</h3>|
|
144
|
+
result << %Q|<p>#{@lwws_desc_disp_item}</p>|
|
145
|
+
result << %Q|<ul>|
|
146
|
+
checked = "t" == @conf['lwws.max_temp.disp'] ? ' checked' : ''
|
147
|
+
result << %Q|<li><label for="lwws.max_temp.disp"><input id="lwws.max_temp.disp" name="lwws.max_temp.disp" type="checkbox" value="t"#{checked}>#{@lwws_max_temp_label}</label></li>|
|
148
|
+
checked = "t" == @conf['lwws.min_temp.disp'] ? ' checked' : ''
|
149
|
+
result << %Q|<li><label for="lwws.min_temp.disp"><input id="lwws.min_temp.disp" name="lwws.min_temp.disp" type="checkbox" value="t"#{checked}>#{@lwws_min_temp_label}</label></li>|
|
150
|
+
result << %Q|</ul>|
|
151
|
+
result << %Q|<h3>#{@lwws_label_cache}</h3>|
|
152
|
+
checked = "t" == @conf['lwws.cache'] ? ' checked' : ''
|
153
|
+
result << %Q|<p><label for="lwws.cache"><input id="lwws.cache" name="lwws.cache" type="checkbox" value="t"#{checked}>#{@lwws_desc_cache}</label></p>|
|
154
|
+
result << %Q|<p>#{@lwws_desc_cache_time}</p>|
|
155
|
+
result << %Q|<p><input name="lwws.cache_time" value="#{h(@conf['lwws.cache_time'])}"></p>|
|
156
|
+
|
157
|
+
result
|
158
|
+
end
|
159
|
+
|
160
|
+
add_body_enter_proc do |date|
|
161
|
+
unless @conf.mobile_agent? or @conf.iphone? or feed? or bot?
|
162
|
+
lwws_to_html(date)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
add_update_proc do
|
167
|
+
lwws_get
|
168
|
+
end
|
169
|
+
|
170
|
+
add_conf_proc( 'lwws', @lwws_plugin_name ) do
|
171
|
+
lwws_conf_proc
|
172
|
+
end
|
173
|
+
|
174
|
+
# Local Variables:
|
175
|
+
# mode: ruby
|
176
|
+
# indent-tabs-mode: t
|
177
|
+
# tab-width: 3
|
178
|
+
# ruby-indent-level: 3
|
179
|
+
# End:
|
180
|
+
# vim: ts=3
|
data/plugin/make_link.rb
ADDED
@@ -0,0 +1,44 @@
|
|
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
|
+
# needs category.rb plugin
|
6
|
+
|
7
|
+
add_edit_proc do
|
8
|
+
<<-HTML
|
9
|
+
<div class="make-link">
|
10
|
+
|
11
|
+
Link URL: <input type="text" id="make-link-url" style="width:400px" />
|
12
|
+
<button id="make-link-button">Get Title and Link</button>
|
13
|
+
|
14
|
+
<script>
|
15
|
+
$('#make-link-button').click(function() {
|
16
|
+
var url = $('#make-link-url')[0].value;
|
17
|
+
var title = $.ajax({
|
18
|
+
url: "http://query.yahooapis.com/v1/public/yql",
|
19
|
+
type: "GET",
|
20
|
+
dataType: "json",
|
21
|
+
async: false,
|
22
|
+
data: {
|
23
|
+
q: 'select * from html where url = "' + url + '" and xpath = "//head/title"',
|
24
|
+
format: 'xml',
|
25
|
+
charset: 'utf-8'
|
26
|
+
}
|
27
|
+
}).responseXML.getElementsByTagName('title')[0].textContent
|
28
|
+
.replace(/\\n/g, ''); // FIXME: need to convert to UTF-8
|
29
|
+
|
30
|
+
var link = "[[" + title + "|" + url + "]]";
|
31
|
+
|
32
|
+
if (typeof(inj_c) == 'function') {
|
33
|
+
inj_c(link); // old category.rb
|
34
|
+
} else {
|
35
|
+
$('#body').insertAtCaret(link);
|
36
|
+
}
|
37
|
+
|
38
|
+
return false;
|
39
|
+
});
|
40
|
+
</script>
|
41
|
+
|
42
|
+
</div>
|
43
|
+
HTML
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# makerss_category.rb: extension for makerss plugin.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2007 by SHIBATA Hiroshi <h-sbt@nifty.com>
|
5
|
+
# Distributed under GPL2.
|
6
|
+
#
|
7
|
+
# Usage:
|
8
|
+
# @conf['makerss.category'] = ["mixi", "sns"]
|
9
|
+
#
|
10
|
+
|
11
|
+
class MakeRssCategory < MakeRssFull
|
12
|
+
def title
|
13
|
+
'(category only)'
|
14
|
+
end
|
15
|
+
|
16
|
+
def item( seq, body, rdfsec )
|
17
|
+
return unless rdfsec.section.respond_to?( :body_to_html )
|
18
|
+
return if rdfsec.section.categories.length == 0
|
19
|
+
rdfsec.section.categories.each do |category|
|
20
|
+
if @conf['makerss.category'].include?(category)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def file
|
27
|
+
f = @conf['makerss.category.file'] || 'category.rdf'
|
28
|
+
f = 'category.rdf' if f.length == 0
|
29
|
+
f
|
30
|
+
end
|
31
|
+
|
32
|
+
def write( encoder )
|
33
|
+
super( encoder )
|
34
|
+
end
|
35
|
+
|
36
|
+
def url
|
37
|
+
u = @conf['makerss.category.url'] || "#{@conf.base_url}category.rdf"
|
38
|
+
u = "#{@conf.base_url}category.rdf" if u.length == 0
|
39
|
+
u
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
@makerss_rsses << MakeRssCategory::new( @conf )
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# makerss_comment.rb: extension for makerss plugin.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2007 by SHIBATA Hiroshi <h-sbt@nifty.com>
|
5
|
+
# Distributed under GPL2.
|
6
|
+
#
|
7
|
+
|
8
|
+
class MakeRssComments < MakeRssFull
|
9
|
+
def title
|
10
|
+
'(comments only)'
|
11
|
+
end
|
12
|
+
|
13
|
+
def item( seq, body, rdfsec )
|
14
|
+
return if rdfsec.section.respond_to?( :body_to_html )
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def file
|
19
|
+
f = @conf['makerss.no_comments.file'] || 'comments.rdf'
|
20
|
+
f = 'comments.rdf' if f.length == 0
|
21
|
+
f
|
22
|
+
end
|
23
|
+
|
24
|
+
def write( encoder )
|
25
|
+
super( encoder )
|
26
|
+
end
|
27
|
+
|
28
|
+
def url
|
29
|
+
u = @conf['makerss.no_comments.url'] || "#{@conf.base_url}comments.rdf"
|
30
|
+
u = "#{@conf.base_url}comments.rdf" if u.length == 0
|
31
|
+
u
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
@makerss_rsses << MakeRssComments::new( @conf )
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# microsummary.rb
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006 elytsllams <smallstyle@gmail.com>
|
4
|
+
# Distributed under the GPL
|
5
|
+
#
|
6
|
+
|
7
|
+
add_header_proc do
|
8
|
+
generator_xml = @conf['generator.xml']
|
9
|
+
|
10
|
+
if generator_xml != nil and @mode == 'latest' and !@cgi.valid?( 'date' )
|
11
|
+
%Q|\t<link rel="microsummary" href="#{generator_xml}" type="application/x.microsummary+xml">\n|
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_xml file_name
|
16
|
+
xml = <<-XML
|
17
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
18
|
+
<generator xmlns="http://www.mozilla.org/microsummaries/0.1"
|
19
|
+
name="tDiary Entry Title">
|
20
|
+
<template>
|
21
|
+
<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
22
|
+
<output method="text"/>
|
23
|
+
<template match="/">
|
24
|
+
<value-of select="html/head/title"/>
|
25
|
+
<choose>
|
26
|
+
<when test="boolean(descendant::div[attribute::class='body'][1]/div[attribute::class='section'][last()]/h3)">
|
27
|
+
<text> - </text>
|
28
|
+
<value-of select="descendant::div[attribute::class='body'][1]/div[attribute::class='section'][last()]/h3"/>
|
29
|
+
</when>
|
30
|
+
<when test="boolean(descendant::div[attribute::class='day'][1]/h2)">
|
31
|
+
<text> - </text>
|
32
|
+
<value-of select="descendant::div[attribute::class='day'][1]/h2"/>
|
33
|
+
</when>
|
34
|
+
</choose>
|
35
|
+
</template>
|
36
|
+
</transform>
|
37
|
+
</template>
|
38
|
+
<update interval="240"/>
|
39
|
+
<pages>
|
40
|
+
<include>^#{@conf.base_url.gsub(/\./, '\\.')}$</include>
|
41
|
+
</pages>
|
42
|
+
</generator>
|
43
|
+
XML
|
44
|
+
|
45
|
+
begin
|
46
|
+
File::open( file_name, 'w' ) do |f|
|
47
|
+
f.print to_utf8( xml )
|
48
|
+
end
|
49
|
+
rescue
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def microsummary_init
|
54
|
+
@conf['generator.xml'] ||= ""
|
55
|
+
create_xml( @conf['generator.xml'] ) unless File::exists? @conf['generator.xml']
|
56
|
+
end
|
57
|
+
|
58
|
+
if @mode == 'saveconf'
|
59
|
+
def saveconf_microsummary
|
60
|
+
@conf['generator.xml'] = @cgi.params['generator.xml'][0]
|
61
|
+
end
|
62
|
+
end
|
data/plugin/mm_footer.rb
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
#
|
2
|
+
# mm_footer.rb
|
3
|
+
#
|
4
|
+
# MM ( http://1470.net/mm/) のmylistを各日付に貼り付けるtDiaryプラグイン
|
5
|
+
#
|
6
|
+
# Licence: GPL
|
7
|
+
# Author: ishinao <ishinao@ishinao.net>
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'nkf'
|
11
|
+
|
12
|
+
add_body_leave_proc(Proc.new do |date|
|
13
|
+
|
14
|
+
oldest_date = Time.local(2005, 1, 11)
|
15
|
+
if date > oldest_date
|
16
|
+
if @mode == 'day' or @mode == 'latest'
|
17
|
+
if date < Time.local(2006, 7, 6)
|
18
|
+
mm_user = 82 # your MM id
|
19
|
+
url = "http://1470.net/mm/mylist.html/#{mm_user}?date=#{date.strftime('%Y-%m-%d')}"
|
20
|
+
rssurl = "http://1470.net/mm/mylist.html/#{mm_user}?date=#{date.strftime('%Y-%m-%d')}&mode=rss"
|
21
|
+
template_list = '<li>#{content}</li>'
|
22
|
+
else
|
23
|
+
userName = 'hsbt' # your 1470.net id
|
24
|
+
url = "http://1470.net/user/#{userName}/#{date.strftime('%Y/%m/%d')}"
|
25
|
+
rssurl = "http://1470.net/user/#{userName}/#{date.strftime('%Y/%m/%d')}/feed"
|
26
|
+
template_list = '<li>#{content.gsub(/href="\//, "href=\"http://1470.net\/")}</li>'
|
27
|
+
end
|
28
|
+
|
29
|
+
template_head = %Q[<div class="section mm_footer">\n<h3><a href="#{CGI.escapeHTML(url)}">今日のメモ</a> powered by <a href="http://1470.net/">1470.net</a></h3>\n<ul class="mm_footer">\n]
|
30
|
+
template_foot = "</ul>\n</div>\n"
|
31
|
+
|
32
|
+
cache_time = 3600;
|
33
|
+
if date.strftime('%Y-%m-%d') != Time.now.strftime('%Y-%m-%d')
|
34
|
+
cache_time = 3600 * 12;
|
35
|
+
end
|
36
|
+
NKF.nkf('-e', mm_footer(rssurl, 50, cache_time, template_head, template_list, template_foot))
|
37
|
+
else
|
38
|
+
''
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end)
|
42
|
+
|
43
|
+
require "rss/rss"
|
44
|
+
|
45
|
+
MM_FOOTER_FIELD_SEPARATOR = "\0"
|
46
|
+
MM_FOOTER_ENTRY_SEPARATOR = "\1"
|
47
|
+
MM_FOOTER_VERSION = "0.0.5i"
|
48
|
+
MM_FOOTER_HTTP_HEADER = {
|
49
|
+
"User-Agent" => "tDiary RSS recent plugin version #{MM_FOOTER_VERSION}. " <<
|
50
|
+
"Using RSS parser version is #{::RSS::VERSION}.",
|
51
|
+
}
|
52
|
+
|
53
|
+
def mm_footer(url, max = 5, cache_time = 3600, \
|
54
|
+
template_head = "<ul>\n", \
|
55
|
+
template_list = '<li><span class="#{mm_footer_modified_class(time)}"><a href="#{CGI.escapeHTML(url)}" title="#{CGI.escapeHTML(title)}">#{CGI::escapeHTML(title)}</a></span></li>\n', \
|
56
|
+
template_foot = "</ul>\n")
|
57
|
+
url.untaint
|
58
|
+
|
59
|
+
cache_file = "#{@cache_path}/rss-recent/rss-recent.#{CGI.escape(url)}"
|
60
|
+
|
61
|
+
mm_footer_cache_rss(url, cache_file, cache_time.to_i)
|
62
|
+
|
63
|
+
return '' unless test(?r, cache_file)
|
64
|
+
|
65
|
+
rv = template_head
|
66
|
+
|
67
|
+
i = 0
|
68
|
+
mm_footer_read_from_cache(cache_file).each do |title, url, time, content|
|
69
|
+
break if i >= max
|
70
|
+
next if (url.nil? or title.nil?)
|
71
|
+
rv << eval('%Q[' + template_list + ']')
|
72
|
+
i += 1
|
73
|
+
end
|
74
|
+
|
75
|
+
rv << template_foot
|
76
|
+
|
77
|
+
if i > 0
|
78
|
+
rv
|
79
|
+
else
|
80
|
+
''
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class InvalidResourceError < StandardError; end
|
85
|
+
|
86
|
+
def mm_footer_cache_rss(url, cache_file, cache_time)
|
87
|
+
|
88
|
+
cached_time = nil
|
89
|
+
cached_time = File.mtime(cache_file) if File.exist?(cache_file)
|
90
|
+
|
91
|
+
if cached_time.nil? or Time.now > cached_time + cache_time
|
92
|
+
require 'time'
|
93
|
+
require 'open-uri'
|
94
|
+
require 'net/http'
|
95
|
+
require 'uri/generic'
|
96
|
+
require 'rss/parser'
|
97
|
+
require 'rss/1.0'
|
98
|
+
require 'rss/2.0'
|
99
|
+
require 'rss/dublincore'
|
100
|
+
require 'rss/content'
|
101
|
+
|
102
|
+
begin
|
103
|
+
uri = URI.parse(url)
|
104
|
+
|
105
|
+
raise URI::InvalidURIError if uri.scheme != "http"
|
106
|
+
|
107
|
+
rss_source = mm_footer_fetch_rss(uri, cached_time)
|
108
|
+
|
109
|
+
raise InvalidResourceError if rss_source.nil?
|
110
|
+
|
111
|
+
# parse RSS
|
112
|
+
rss = ::RSS::Parser.parse(rss_source, false)
|
113
|
+
raise ::RSS::Error if rss.nil?
|
114
|
+
|
115
|
+
# pre processing
|
116
|
+
begin
|
117
|
+
rss.output_encoding = @conf.charset || charset
|
118
|
+
rescue ::RSS::UnknownConversionMethodError
|
119
|
+
end
|
120
|
+
|
121
|
+
rss_infos = rss.items.collect do |item|
|
122
|
+
mm_footer_pubDate_to_dc_date(item)
|
123
|
+
[item.title, item.link, item.dc_date, item.content_encoded]
|
124
|
+
end
|
125
|
+
mm_footer_write_to_cache(cache_file, rss_infos)
|
126
|
+
|
127
|
+
rescue URI::InvalidURIError
|
128
|
+
mm_footer_write_to_cache(cache_file, [['Invalid URI', url]])
|
129
|
+
rescue InvalidResourceError, ::RSS::Error
|
130
|
+
# mm_footer_write_to_cache(cache_file, [['Invalid Resource', url]])
|
131
|
+
# when cannot get valid RSS, use old cache
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
def mm_footer_fetch_rss(uri, cache_time)
|
138
|
+
rss = nil
|
139
|
+
begin
|
140
|
+
uri.open(mm_footer_http_header(cache_time)) do |f|
|
141
|
+
case f.status.first
|
142
|
+
when "200"
|
143
|
+
rss = f.read
|
144
|
+
# STDERR.puts "Got RSS of #{uri}"
|
145
|
+
when "304"
|
146
|
+
# not modified
|
147
|
+
# STDERR.puts "#{uri} does not modified"
|
148
|
+
else
|
149
|
+
raise InvalidResourceError
|
150
|
+
end
|
151
|
+
end
|
152
|
+
rescue TimeoutError, SocketError, StandardError,
|
153
|
+
SecurityError # occured in redirect
|
154
|
+
raise InvalidResourceError
|
155
|
+
end
|
156
|
+
rss
|
157
|
+
end
|
158
|
+
|
159
|
+
def mm_footer_http_header(cache_time)
|
160
|
+
header = MM_FOOTER_HTTP_HEADER.dup
|
161
|
+
if cache_time.respond_to?(:rfc2822)
|
162
|
+
header["If-Modified-Since"] = cache_time.rfc2822
|
163
|
+
end
|
164
|
+
header
|
165
|
+
end
|
166
|
+
|
167
|
+
def mm_footer_write_to_cache(cache_file, rss_infos)
|
168
|
+
File.open(cache_file, 'w') do |f|
|
169
|
+
f.flock(File::LOCK_EX)
|
170
|
+
rss_infos.each do |info|
|
171
|
+
f << info.join(MM_FOOTER_FIELD_SEPARATOR)
|
172
|
+
f << MM_FOOTER_ENTRY_SEPARATOR
|
173
|
+
end
|
174
|
+
f.flock(File::LOCK_UN)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def mm_footer_read_from_cache(cache_file)
|
179
|
+
require 'time'
|
180
|
+
infos = []
|
181
|
+
File.open(cache_file) do |f|
|
182
|
+
while info = f.gets(MM_FOOTER_ENTRY_SEPARATOR)
|
183
|
+
info = info.chomp(MM_FOOTER_ENTRY_SEPARATOR)
|
184
|
+
infos << info.split(MM_FOOTER_FIELD_SEPARATOR)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
infos.collect do |title, url, time, content|
|
188
|
+
[
|
189
|
+
mm_footer_convert(title),
|
190
|
+
mm_footer_convert(url),
|
191
|
+
mm_footer_convert(time) {|time| Time.parse(time)},
|
192
|
+
mm_footer_convert(content)
|
193
|
+
]
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def mm_footer_convert(str)
|
198
|
+
if str.nil? or str.empty?
|
199
|
+
nil
|
200
|
+
else
|
201
|
+
if block_given?
|
202
|
+
yield str
|
203
|
+
else
|
204
|
+
str
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def mm_footer_pubDate_to_dc_date(target)
|
210
|
+
if target.respond_to?(:pubDate)
|
211
|
+
class << target
|
212
|
+
alias_method(:dc_date, :pubDate)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# monthly_autopagerize.rb - tDiary plugin
|
3
|
+
#
|
4
|
+
# add <link rel="prev"> and <link rel="next"> tags for AutoPagerize at monthly mode
|
5
|
+
#
|
6
|
+
# Copyright (C) 2009 MATSUI Shinsuke <poppen@karashi.org>
|
7
|
+
# You can redistribute it and/or modify it under GPL2.
|
8
|
+
#
|
9
|
+
|
10
|
+
if @mode == 'month' then
|
11
|
+
add_header_proc do
|
12
|
+
stream = @conf['monthly_autopagerize.stream'] || 0
|
13
|
+
result = String.new
|
14
|
+
|
15
|
+
ym = []
|
16
|
+
@years.keys.each do |y|
|
17
|
+
ym += @years[y].collect {|m| y + m}
|
18
|
+
end
|
19
|
+
ym.sort!
|
20
|
+
now = @date.strftime( '%Y%m' )
|
21
|
+
return '' unless ym.index( now )
|
22
|
+
prev_month = ym.index( now ) == 0 ? nil : ym[ym.index( now )-1]
|
23
|
+
next_month = ym[ym.index( now )+1]
|
24
|
+
|
25
|
+
case stream
|
26
|
+
#when 0
|
27
|
+
# rel_prev_month = 'next'
|
28
|
+
# rel_next_month = 'prev'
|
29
|
+
when 1
|
30
|
+
rel_prev_month = 'prev'
|
31
|
+
rel_next_month = 'next'
|
32
|
+
else
|
33
|
+
rel_prev_month = 'next'
|
34
|
+
rel_next_month = 'prev'
|
35
|
+
end
|
36
|
+
|
37
|
+
if prev_month then
|
38
|
+
result << %Q[<link rel="#{rel_prev_month}" title="#{h navi_prev_month}" href="#{h @index}#{anchor( prev_month )}">\n\t]
|
39
|
+
end
|
40
|
+
if next_month then
|
41
|
+
result << %Q[<link rel="#{rel_next_month}" title="#{h navi_next_month}" href="#{h @index}#{anchor( next_month )}">\n\t]
|
42
|
+
end
|
43
|
+
|
44
|
+
result.chop.chop
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
add_conf_proc( 'monthly_autopagerize', 'Monthly AutoPagerize' ) do
|
49
|
+
if @mode == 'saveconf' then
|
50
|
+
@conf['monthly_autopagerize.stream'] = @cgi.params['monthly_autopagerize.stream'][0].to_i
|
51
|
+
end
|
52
|
+
<<-HTML
|
53
|
+
<h3>Stream of Monthly AutoPagerize</h3>
|
54
|
+
<p><select name="monthly_autopagerize.stream">
|
55
|
+
<option value="0"#{' selected' if @conf['monthly_autopagerize.stream'] == 0}>To Past</option>
|
56
|
+
<option value="1"#{' selected' if @conf['monthly_autopagerize.stream'] == 1}>To Future</option>
|
57
|
+
</select></p>
|
58
|
+
HTML
|
59
|
+
end
|
60
|
+
|
61
|
+
# Local Variables:
|
62
|
+
# mode: ruby
|
63
|
+
# indent-tabs-mode: t
|
64
|
+
# tab-width: 3
|
65
|
+
# ruby-indent-level: 3
|
66
|
+
# End:
|
67
|
+
# vi: ts=3 sw=3
|