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
data/plugin/vote.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# tdiary_vote.rb $Revision: 2 $
|
2
|
+
# Copyright (C) 2006 Michitaka Ohno <elpeo@mars.dti.ne.jp>
|
3
|
+
# You can redistribute it and/or modify it under GPL2.
|
4
|
+
#
|
5
|
+
# ref. http://elpeo.jp/diary/20060622.html#p01
|
6
|
+
#
|
7
|
+
# .tdiary-vote {
|
8
|
+
# float: left;
|
9
|
+
# background-color: aqua;
|
10
|
+
# }
|
11
|
+
|
12
|
+
require 'digest/md5'
|
13
|
+
require 'pstore'
|
14
|
+
|
15
|
+
@tdiary_vote_db = "#{@cache_path}/tdiary_vote"
|
16
|
+
@tdiary_vote_label = "投票"
|
17
|
+
@tdiary_vote_date = nil
|
18
|
+
|
19
|
+
def vote( *items )
|
20
|
+
return '' unless @tdiary_vote_date
|
21
|
+
h, voted = get_vote( @tdiary_vote_date, @cgi.cookies['tdiary_vote'][0] )
|
22
|
+
max = h.empty? ? 1 : h.values.max
|
23
|
+
r = %Q[<table border="1">]
|
24
|
+
items.sort{|a, b| h[b] <=> h[a]}.each do |item|
|
25
|
+
num = h[item]
|
26
|
+
r << %Q[<tr>]
|
27
|
+
r << %Q[<td>#{CGI.escapeHTML( item )}</td>]
|
28
|
+
r << %Q[<td><span class="tdiary-vote" style="height: 2.5ex; width: #{(100*num/max).to_i}px"></span>#{num}</td>]
|
29
|
+
unless voted then
|
30
|
+
r << %Q[<td>]
|
31
|
+
r << %Q[<form submit="#{@conf.index}" method="POST" style="margin: 0px; padding: 0px">]
|
32
|
+
r << %Q[#{csrf_protection}]
|
33
|
+
r << %Q[<input type="hidden" name="date" value="#{@tdiary_vote_date.strftime( "%Y%m%d" )}">]
|
34
|
+
r << %Q[<input type="hidden" name="name" value="">]
|
35
|
+
r << %Q[<input type="hidden" name="body" value="">]
|
36
|
+
r << %Q[<input type="hidden" name="vote" value="#{CGI.escapeHTML( item )}">]
|
37
|
+
r << %Q[<input type="submit" name="comment" value="#{@tdiary_vote_label}">]
|
38
|
+
r << %Q[</form>]
|
39
|
+
r << %Q[</td>]
|
40
|
+
end
|
41
|
+
r << %Q[</tr>]
|
42
|
+
end
|
43
|
+
r << %Q[</table>]
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_vote( date, uid )
|
47
|
+
h = Hash.new(0)
|
48
|
+
voted = false
|
49
|
+
file = "#{@tdiary_vote_db}/#{date.strftime( "%Y%m%d" )}.db"
|
50
|
+
if File.exist?( file ) then
|
51
|
+
PStore.new( file ).transaction do |db|
|
52
|
+
h.update( db['vote'] ) if db.root?( 'vote' )
|
53
|
+
voted = db['voter'].include?( uid ) if db.root?( 'voter' )
|
54
|
+
db.abort
|
55
|
+
end
|
56
|
+
end
|
57
|
+
[h, voted]
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_vote( date, item, uid )
|
61
|
+
Dir::mkdir( @tdiary_vote_db ) unless File::directory?( @tdiary_vote_db )
|
62
|
+
file = "#{@tdiary_vote_db}/#{date.strftime( "%Y%m%d" )}.db"
|
63
|
+
PStore.new( file ).transaction do |db|
|
64
|
+
db['voter'] = Hash.new unless db.root?( 'voter' )
|
65
|
+
db.abort if db['voter'].include?( uid )
|
66
|
+
db['voter'][uid] = @cgi.remote_addr
|
67
|
+
db['vote'] = Hash.new(0) unless db.root?( 'vote' )
|
68
|
+
db['vote'][item] += 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
add_body_enter_proc do |date|
|
73
|
+
@tdiary_vote_date = date
|
74
|
+
''
|
75
|
+
end
|
76
|
+
|
77
|
+
add_body_leave_proc do |date|
|
78
|
+
@tdiary_vote_date = nil
|
79
|
+
''
|
80
|
+
end
|
81
|
+
|
82
|
+
unless bot? then
|
83
|
+
if @mode == 'comment' && @cgi.valid?( 'vote' ) && @cgi.cookies['tdiary_vote'][0] then
|
84
|
+
add_vote( @date, @cgi.params['vote'][0], @cgi.cookies['tdiary_vote'][0] )
|
85
|
+
end
|
86
|
+
|
87
|
+
add_footer_proc do
|
88
|
+
uid = @cgi.cookies['tdiary_vote'][0] || Digest::MD5.hexdigest( @cgi.remote_addr + Time.now.to_s + rand.to_s )
|
89
|
+
cookie_path = File::dirname( @cgi.script_name )
|
90
|
+
cookie_path += '/' if cookie_path !~ /\/$/
|
91
|
+
cookie = CGI::Cookie::new(
|
92
|
+
'name' => 'tdiary_vote',
|
93
|
+
'value' => uid,
|
94
|
+
'path' => cookie_path,
|
95
|
+
'expires' => Time.now.gmtime + 30*24*60*60
|
96
|
+
)
|
97
|
+
add_cookie( cookie )
|
98
|
+
''
|
99
|
+
end
|
100
|
+
end
|
data/plugin/wikiloc.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# wikiloc.rb: plugin embedding trip map on wikiloc.
|
3
|
+
#
|
4
|
+
# Copyright (C) 2008 MUNEDA Takahiro <mux03@panda64.net>
|
5
|
+
# You can redistribute it and/or modify it under GPL2.
|
6
|
+
#
|
7
|
+
# derived from everytrail.rb, Copyright (C) 2008 TADA Tadashi <sho@spc.gr.jp>
|
8
|
+
#
|
9
|
+
# Parameters:
|
10
|
+
# @trip_id : your trip id
|
11
|
+
# @measures : on/off
|
12
|
+
# @maptype : M/S/H/T
|
13
|
+
# @size : [width,height]
|
14
|
+
#
|
15
|
+
# Please see the following address about the details:
|
16
|
+
# http://www.wikiloc.com/forum/posts/list/14.page
|
17
|
+
#
|
18
|
+
# ChangeLog:
|
19
|
+
# 20080706: Initial release
|
20
|
+
# 20080713: Change default parameters
|
21
|
+
#
|
22
|
+
def wikiloc( trip_id, measures = "off", maptype = "M", size = [500,400] )
|
23
|
+
size.collect! {|i| i.to_i }
|
24
|
+
size[0] = 500 if size[0] == 0
|
25
|
+
size[1] = 400 if size[1] == 0
|
26
|
+
%Q|<iframe frameBorder="0" src="http://www.wikiloc.com/wikiloc/spatialArtifacts.do?event=view&id=#{h trip_id}&measures=#{h measures}&title=on&near=on&images=on&maptype=#{maptype}" width="#{size[0]}px" height="#{size[1]}px"></iframe>|
|
27
|
+
end
|
data/plugin/windex.rb
ADDED
@@ -0,0 +1,512 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# windex.rb $Revision: 1.2 $
|
4
|
+
#
|
5
|
+
# windex: 索引を生成する
|
6
|
+
# パラメタ:
|
7
|
+
# str: キーワード文字列
|
8
|
+
# readname: 読み仮名
|
9
|
+
#
|
10
|
+
# wikw: 索引からアンカーを生成する
|
11
|
+
# パラメタ:
|
12
|
+
# str: キーワード文字列
|
13
|
+
#
|
14
|
+
# このファイルをtDiaryのトップディレクトリにも配置し、CGIとして
|
15
|
+
# 実行することで索引ページを出力できます。
|
16
|
+
#
|
17
|
+
# CGI動作時の引数
|
18
|
+
# http://(日記URL)/windex.rb?kw=(キーワード文字列)
|
19
|
+
# とキーワードを指定してアクセスすることでそのキーワードに関係する日記の
|
20
|
+
# 日付一覧を出力できます。一つだけの場合にはその日付の日記への
|
21
|
+
# リダイレクトを出力します。
|
22
|
+
#
|
23
|
+
# tdiary.confによる設定
|
24
|
+
# @options['windex.generate_all'] = true
|
25
|
+
# 全ての日記から索引を生成します。これは時間がかかるので、索引の全生成を
|
26
|
+
# 行いたいときだけtrueに設定して更新を行うような使い方を想定しています。
|
27
|
+
#
|
28
|
+
# Copyright (c) 2003 Gony <gony@sm.rim.or.jp>
|
29
|
+
# Distributed under the GPL
|
30
|
+
#
|
31
|
+
|
32
|
+
mode = ""
|
33
|
+
if $0 == __FILE__
|
34
|
+
mode = "CGI"
|
35
|
+
if FileTest.symlink?(__FILE__) == true
|
36
|
+
org_path = File.dirname(File.readlink(__FILE__))
|
37
|
+
else
|
38
|
+
org_path = File.dirname(__FILE__)
|
39
|
+
end
|
40
|
+
$:.unshift(org_path)
|
41
|
+
require "pstore"
|
42
|
+
require "tdiary"
|
43
|
+
|
44
|
+
tdiarybase = TDiary::TDiaryBase
|
45
|
+
else
|
46
|
+
tdiarybase = TDiaryBase
|
47
|
+
end
|
48
|
+
|
49
|
+
class WITDiary < tdiarybase
|
50
|
+
def load_plugins
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_wordindex(date,plugin,index)
|
55
|
+
wordindex = WIWordIndex.new
|
56
|
+
@io.transaction(date) do |diaries|
|
57
|
+
wordindex.generate(diaries,plugin,index)
|
58
|
+
end
|
59
|
+
|
60
|
+
return wordindex
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class WIWordIndex
|
65
|
+
def initialize
|
66
|
+
@windex = {}
|
67
|
+
@dates = []
|
68
|
+
end
|
69
|
+
|
70
|
+
def generate(diaries,plugin,index)
|
71
|
+
diaries.each_value do |diary|
|
72
|
+
num_section = 1
|
73
|
+
diary.each_section do |section|
|
74
|
+
anchor = index \
|
75
|
+
+ plugin.anchor(diary.date.strftime("%Y%m%d")) \
|
76
|
+
+ "#p%02d" % num_section
|
77
|
+
if section.subtitle != nil
|
78
|
+
scan(section.subtitle,anchor)
|
79
|
+
end
|
80
|
+
scan(section.body,anchor)
|
81
|
+
num_section = num_section + 1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def load(dir)
|
87
|
+
@windex = {}
|
88
|
+
Dir.mkdir(dir) unless File.directory?(dir)
|
89
|
+
PStore.new(dir + "/windex").transaction do |pstore|
|
90
|
+
@dates = pstore.roots
|
91
|
+
@dates.each do |key|
|
92
|
+
windex_tmp = pstore[key]
|
93
|
+
windex_tmp.each_key do |key_windex|
|
94
|
+
if @windex.has_key?(key_windex) == false
|
95
|
+
@windex[key_windex] = {"readname" => nil,
|
96
|
+
"anchor" => []}
|
97
|
+
end
|
98
|
+
if @windex[key_windex]["readname"] == nil \
|
99
|
+
&& windex_tmp[key_windex].has_key?("readname") == true
|
100
|
+
@windex[key_windex]["readname"] = windex_tmp[key_windex]["readname"]
|
101
|
+
end
|
102
|
+
@windex[key_windex]["anchor"].concat(windex_tmp[key_windex]["anchor"])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def save(dir,keyname)
|
109
|
+
if File.directory?(dir) == false
|
110
|
+
Dir.mkdir(dir,0755)
|
111
|
+
end
|
112
|
+
PStore.new(dir + "/windex").transaction do |pstore|
|
113
|
+
pstore[keyname] = @windex
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def generate_html(page)
|
118
|
+
return page.generate_html(@windex)
|
119
|
+
end
|
120
|
+
|
121
|
+
def has_key?(key)
|
122
|
+
return @windex.has_key?(key)
|
123
|
+
end
|
124
|
+
|
125
|
+
def [](key)
|
126
|
+
return @windex[key]
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
def scan(body,anchor)
|
131
|
+
to_delimiter_end = {
|
132
|
+
"(" => ")","[" => "]","{" => "}","<" => ">",
|
133
|
+
}
|
134
|
+
|
135
|
+
wistrs = body.scan(%r[<%\s*=\s*windex\s*[^(<%)]*\s*%>])
|
136
|
+
wistrs.each do |wistr|
|
137
|
+
# 引数抽出
|
138
|
+
argstr = wistr.gsub(%r[<%\s*=\s*windex\s*],"")
|
139
|
+
argstr = argstr.gsub(%r[\s*%>],"")
|
140
|
+
args = []
|
141
|
+
flag_done = false
|
142
|
+
while flag_done == false
|
143
|
+
pos_delimiter = argstr.index(%r['|"|%[Qq].]) #"'
|
144
|
+
if pos_delimiter != nil
|
145
|
+
# デリミタ文字取得
|
146
|
+
delimiter = argstr.scan(%r['|"|%[Qq].])[0] #"'
|
147
|
+
if delimiter.length == 3
|
148
|
+
delimiter_end = delimiter[2].chr
|
149
|
+
if to_delimiter_end.has_key?(delimiter_end)
|
150
|
+
delimiter_end = to_delimiter_end[delimiter_end]
|
151
|
+
end
|
152
|
+
else
|
153
|
+
delimiter_end = delimiter
|
154
|
+
end
|
155
|
+
|
156
|
+
# デリミタまでの文字列を削除
|
157
|
+
argstr = argstr[(pos_delimiter + delimiter.length)..-1]
|
158
|
+
pos_delimiter = argstr.index(delimiter_end)
|
159
|
+
if pos_delimiter != nil
|
160
|
+
if pos_delimiter > 0
|
161
|
+
# 引数として取得
|
162
|
+
args << argstr[0..(pos_delimiter - 1)]
|
163
|
+
else
|
164
|
+
args << ""
|
165
|
+
end
|
166
|
+
# デリミタまでの文字列を削除
|
167
|
+
argstr = argstr[(pos_delimiter + delimiter_end.length)..-1]
|
168
|
+
else
|
169
|
+
flag_done = true
|
170
|
+
end
|
171
|
+
else
|
172
|
+
flag_done = true
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
if args.length > 0
|
177
|
+
if @windex.has_key?(args[0]) == false
|
178
|
+
# ハッシュを生成
|
179
|
+
@windex[args[0]] = {"readname" => nil,"anchor" => []}
|
180
|
+
end
|
181
|
+
if args.length > 1 && @windex[args[0]]["readname"] == nil && args[1] != ""
|
182
|
+
@windex[args[0]]["readname"] = args[1]
|
183
|
+
end
|
184
|
+
@windex[args[0]]["anchor"] << anchor
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class WIIndexPage
|
191
|
+
def initialize(title,css)
|
192
|
+
@title = title
|
193
|
+
@css = css
|
194
|
+
end
|
195
|
+
|
196
|
+
def generate_html(windex)
|
197
|
+
body = ""
|
198
|
+
|
199
|
+
# 大項目名 => 名前の配列 のハッシュを生成
|
200
|
+
subindex_to_name = {}
|
201
|
+
windex.keys.each do |key|
|
202
|
+
subindex = ""
|
203
|
+
if windex[key]["readname"] != nil
|
204
|
+
subindex = get_subindex(windex[key]["readname"])
|
205
|
+
else
|
206
|
+
subindex = get_subindex(key)
|
207
|
+
end
|
208
|
+
if subindex_to_name.has_key?(subindex) == false
|
209
|
+
subindex_to_name[subindex] = []
|
210
|
+
end
|
211
|
+
subindex_to_name[subindex] << key
|
212
|
+
end
|
213
|
+
|
214
|
+
# 大項目名ごとにHTMLを生成
|
215
|
+
if subindex_to_name.has_key?("記号") == true
|
216
|
+
body << generate_html_subindex(windex,subindex_to_name,"記号")
|
217
|
+
end
|
218
|
+
subindex_to_name.keys.sort.each do |key|
|
219
|
+
if key != "記号"
|
220
|
+
body << generate_html_subindex(windex,subindex_to_name,key)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
body = <<-BODY
|
225
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
226
|
+
<html>
|
227
|
+
<head>
|
228
|
+
<title>#{h @title}(索引)</title>
|
229
|
+
#{@css}
|
230
|
+
</head>
|
231
|
+
<body>
|
232
|
+
<h1>#{@title} [索引]</h1>
|
233
|
+
<div class="day"><div class="body">
|
234
|
+
#{body}
|
235
|
+
</div></div>
|
236
|
+
</body>
|
237
|
+
</html>
|
238
|
+
BODY
|
239
|
+
|
240
|
+
return body
|
241
|
+
end
|
242
|
+
|
243
|
+
private
|
244
|
+
def generate_html_subindex(windex,subindex_to_name,key)
|
245
|
+
readname_to_name = {}
|
246
|
+
subindex_to_name[key].each do |name|
|
247
|
+
key_new = ""
|
248
|
+
if windex[name]["readname"] != nil
|
249
|
+
key_new = windex[name]["readname"]
|
250
|
+
else
|
251
|
+
key_new = name
|
252
|
+
end
|
253
|
+
if readname_to_name.has_key?(key_new) == false
|
254
|
+
readname_to_name[key_new] = []
|
255
|
+
end
|
256
|
+
readname_to_name[key_new] << name
|
257
|
+
end
|
258
|
+
|
259
|
+
body = %Q[<div class="section"><h2>#{key}</h2>\n]
|
260
|
+
|
261
|
+
# 読み仮名のソートでループ -> 名前のソートでループ
|
262
|
+
keys = readname_to_name.keys
|
263
|
+
if keys.empty? == false
|
264
|
+
keys.sort.each do |readname|
|
265
|
+
readname_to_name[readname].sort.each do |name|
|
266
|
+
body << "<p>#{name} ... "
|
267
|
+
num_anchor = 1
|
268
|
+
windex[name]["anchor"].sort.each do |anchor|
|
269
|
+
body = body + %Q[<a href="#{h anchor}">#{num_anchor}</a>]
|
270
|
+
if num_anchor < windex[name]["anchor"].length
|
271
|
+
body = body + ","
|
272
|
+
end
|
273
|
+
num_anchor = num_anchor + 1
|
274
|
+
end
|
275
|
+
body << "</p>"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
body << "\n</div>\n"
|
280
|
+
|
281
|
+
return body
|
282
|
+
end
|
283
|
+
|
284
|
+
def get_subindex(name)
|
285
|
+
to_plainhiragana = {
|
286
|
+
"ぁ" => "あ","ぃ" => "い","ぅ" => "う","ぇ" => "え","ぉ" => "お",
|
287
|
+
"が" => "か","ぎ" => "き","ぐ" => "く","げ" => "け","ご" => "こ",
|
288
|
+
"ざ" => "さ","じ" => "し","ず" => "す","ぜ" => "せ","ぞ" => "そ",
|
289
|
+
"だ" => "た","ぢ" => "ち","っ" => "つ","づ" => "つ","で" => "て","ど" => "と",
|
290
|
+
"ば" => "は","ぱ" => "は","び" => "ひ","ぴ" => "ひ","ぶ" => "ふ","ぷ" => "ふ","べ" => "へ","ぺ" => "へ","ぼ" => "ほ","ぽ" => "ほ",
|
291
|
+
"ゃ" => "や","ゅ" => "ゆ","ょ" => "よ",
|
292
|
+
"ゎ" => "わ","ヴ" => "う","ヵ" => "か","ヶ" => "け",
|
293
|
+
}
|
294
|
+
to_1byte = {
|
295
|
+
"!" => "!",'”' => '"',"#" => "#","$" => "$","%" => "%","&" => "&","’" => "'","(" => "(",")" => ")","*" => "*","+" => "+","," => ",","−" => "-","." => ".","/" => "/",
|
296
|
+
"0" => "0","1" => "1","2" => "2","3" => "3","4" => "4","5" => "5","6" => "6","7" => "7","8" => "8","9" => "9",":" => ":",";" => ";","<" => "<","=" => "=",">" => ">","?" => "?",
|
297
|
+
"@" => "@","A" => "A","B" => "B","C" => "C","D" => "D","E" => "E","F" => "F","G" => "G","H" => "H","I" => "I","J" => "J","K" => "K","L" => "L","M" => "M","N" => "N","O" => "O",
|
298
|
+
"P" => "P","Q" => "Q","R" => "R","S" => "S","T" => "T","U" => "U","V" => "V","W" => "W","X" => "X","Y" => "Y","Z" => "Z","[" => "[","¥" => "\\","]" => "]","^" => "^","_" => "_",
|
299
|
+
"a" => "a","b" => "b","c" => "c","d" => "d","e" => "e","f" => "f","g" => "g","h" => "h","i" => "i","j" => "j","k" => "k","l" => "l","m" => "m","n" => "n","o" => "o",
|
300
|
+
"p" => "p","q" => "q","r" => "r","s" => "s","t" => "t","u" => "u","v" => "v","w" => "w","x" => "x","y" => "y","z" => "z","{" => "{","|" => "|","}" => "}","‾" => "~",
|
301
|
+
}
|
302
|
+
|
303
|
+
topchr = name[0,1]
|
304
|
+
if topchr.count("\xA1-\xFE") == 1
|
305
|
+
# マルチバイト文字
|
306
|
+
topchr = name[0,2]
|
307
|
+
end
|
308
|
+
if to_1byte.has_key?(topchr) == true
|
309
|
+
topchr = to_1byte[topchr]
|
310
|
+
end
|
311
|
+
if topchr.length == 1
|
312
|
+
# シングルバイト文字の処理
|
313
|
+
topchr = topchr.upcase
|
314
|
+
|
315
|
+
if (0x21 <= topchr[0] && topchr[0] <= 0x2F) \
|
316
|
+
|| (0x3A <= topchr[0] && topchr[0] <= 0x40) \
|
317
|
+
|| (0x5B <= topchr[0] && topchr[0] <= 0x60) \
|
318
|
+
|| (0x7B <= topchr[0] && topchr[0] <= 0x7B)
|
319
|
+
topchr = "記号"
|
320
|
+
end
|
321
|
+
else
|
322
|
+
# マルチバイト文字の処理
|
323
|
+
# カタカナ->ひらがな変換
|
324
|
+
code = topchr[0] * 0x100 + topchr[1]
|
325
|
+
if 0xA5A1 <= code && code <= 0xA5F3
|
326
|
+
topchr = 0xA4.chr + topchr[1].chr
|
327
|
+
end
|
328
|
+
|
329
|
+
# 濁点 / 半濁点 撥音など変換
|
330
|
+
if to_plainhiragana.has_key?(topchr) == true
|
331
|
+
topchr = to_plainhiragana[topchr]
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
return topchr
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
class WIRedirectPage
|
340
|
+
def initialize(key)
|
341
|
+
@key = key
|
342
|
+
end
|
343
|
+
|
344
|
+
def generate_html(windex)
|
345
|
+
anchor = windex[@key]["anchor"][0]
|
346
|
+
body = <<-BODY
|
347
|
+
<html>
|
348
|
+
<head>
|
349
|
+
<meta http-equiv="refresh" content="0;url=#{h anchor}">
|
350
|
+
<title>moving...</title>
|
351
|
+
</head>
|
352
|
+
<body>Wait or <a href="#{h anchor}">Click here!</a></body>
|
353
|
+
</html>
|
354
|
+
BODY
|
355
|
+
|
356
|
+
return body
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class WISinglePage
|
361
|
+
def initialize(title,date_format,css,key)
|
362
|
+
@title = title
|
363
|
+
@date_format = date_format
|
364
|
+
@css = css
|
365
|
+
@key = key
|
366
|
+
end
|
367
|
+
|
368
|
+
def generate_html(windex)
|
369
|
+
anchors = windex[@key]["anchor"]
|
370
|
+
body = %Q[<div class="section"><h2>#{@key}</h2>\n]
|
371
|
+
anchors.sort.each do |anchor|
|
372
|
+
str_date = anchor.scan(/\d{8}/)[0]
|
373
|
+
date = Time.local(str_date[0..3].to_i,str_date[4..5].to_i,str_date[6..7].to_i)
|
374
|
+
body << %Q[<p><a href="#{h anchor}">#{date.strftime(@date_format)}</a></p>\n]
|
375
|
+
end
|
376
|
+
body << "\n</div>\n"
|
377
|
+
body = <<-BODY
|
378
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
379
|
+
<html>
|
380
|
+
<head>
|
381
|
+
<title>#{h @title}(索引)</title>
|
382
|
+
#{@css}
|
383
|
+
</head>
|
384
|
+
<body>
|
385
|
+
<h1>#{@title} [索引]</h1>
|
386
|
+
<div class="day"><div class="body">
|
387
|
+
#{body}
|
388
|
+
</div></div>
|
389
|
+
</body>
|
390
|
+
</html>
|
391
|
+
BODY
|
392
|
+
|
393
|
+
return body
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
class WIErrorPage
|
398
|
+
def initialize(title,css,key)
|
399
|
+
@title = title
|
400
|
+
@css = css
|
401
|
+
@key = key
|
402
|
+
end
|
403
|
+
|
404
|
+
def generate_html(windex)
|
405
|
+
body = <<-BODY
|
406
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
407
|
+
<html>
|
408
|
+
<head>
|
409
|
+
<title>#{h @title}(索引)</title>
|
410
|
+
#{@css}
|
411
|
+
</head>
|
412
|
+
<body>
|
413
|
+
<h1>#{@title} [索引]</h1>
|
414
|
+
<div class="day"><div class="body">
|
415
|
+
キーワード「#{h @key}」は登録されていません。
|
416
|
+
</div></div>
|
417
|
+
</body>
|
418
|
+
</html>
|
419
|
+
BODY
|
420
|
+
|
421
|
+
return body
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
def windex(str,readname = "")
|
426
|
+
return str
|
427
|
+
end
|
428
|
+
|
429
|
+
def wikw(str)
|
430
|
+
if @wordindex.has_key?(str) == true
|
431
|
+
anchors = @wordindex[str]["anchor"]
|
432
|
+
if anchors.length == 1
|
433
|
+
return %Q[<a href="#{h anchors[0]}">#{str}</a>]
|
434
|
+
else
|
435
|
+
body = "#{str}("
|
436
|
+
num_anchor = 1
|
437
|
+
anchors.sort.each do |anchor|
|
438
|
+
body << %Q[<a href="#{h anchor}">#{num_anchor}</a>]
|
439
|
+
if num_anchor < anchors.length
|
440
|
+
body << ","
|
441
|
+
end
|
442
|
+
num_anchor = num_anchor + 1
|
443
|
+
end
|
444
|
+
body << ")"
|
445
|
+
|
446
|
+
return body
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
return str
|
451
|
+
end
|
452
|
+
|
453
|
+
if mode != "CGI"
|
454
|
+
@wordindex = WIWordIndex.new
|
455
|
+
@wordindex.load(@cache_path + "/windex")
|
456
|
+
|
457
|
+
add_update_proc do
|
458
|
+
if @conf.options["windex.generate_all"] == true
|
459
|
+
tdiary = WITDiary.new(@cgi,"day.rhtml",@conf)
|
460
|
+
@years.each_key do |year|
|
461
|
+
@years[year.to_s].each do |month|
|
462
|
+
date = Time::local(year,month)
|
463
|
+
wordindex = tdiary.generate_wordindex(date,self,@conf.index)
|
464
|
+
wordindex.save(@cache_path + "/windex",date.strftime('%Y%m'))
|
465
|
+
end
|
466
|
+
end
|
467
|
+
else
|
468
|
+
wordindex = WIWordIndex.new
|
469
|
+
wordindex.generate(@diaries,self,@conf.index)
|
470
|
+
wordindex.save(@cache_path + "/windex",@date.strftime('%Y%m'))
|
471
|
+
end
|
472
|
+
end
|
473
|
+
else
|
474
|
+
cgi = CGI.new
|
475
|
+
conf = TDiary::Config.new(cgi)
|
476
|
+
cache_path = conf.data_path + "cache"
|
477
|
+
plugin = WITDiary.new(cgi,"day.rhtml",conf).load_plugins
|
478
|
+
|
479
|
+
wordindex = WIWordIndex.new
|
480
|
+
wordindex.load(cache_path + "/windex")
|
481
|
+
if cgi.valid?('kw') == true
|
482
|
+
key = cgi.params['kw'][0]
|
483
|
+
if wordindex.has_key?(key) == true
|
484
|
+
num_anchor = wordindex[key]["anchor"].length
|
485
|
+
if num_anchor == 0
|
486
|
+
page = WIErrorPage.new(conf.html_title,plugin.css_tag,key)
|
487
|
+
elsif num_anchor == 1
|
488
|
+
page = WIRedirectPage.new(key)
|
489
|
+
else
|
490
|
+
page = WISinglePage.new(conf.html_title,conf.date_format,plugin.css_tag,key)
|
491
|
+
end
|
492
|
+
else
|
493
|
+
page = WIErrorPage.new(conf.html_title,plugin.css_tag,key)
|
494
|
+
end
|
495
|
+
else
|
496
|
+
page = WIIndexPage.new(conf.html_title,plugin.css_tag)
|
497
|
+
end
|
498
|
+
body = wordindex.generate_html(page)
|
499
|
+
|
500
|
+
header = {
|
501
|
+
"type" => "text/html",
|
502
|
+
"charset" => "UTF-8",
|
503
|
+
"Content-Length" => body.size.to_s,
|
504
|
+
"Pragma" => "no-cache",
|
505
|
+
"Cache-Control" => "no-cache",
|
506
|
+
"Vary" => "User-Agent",
|
507
|
+
}
|
508
|
+
head = cgi.header(header)
|
509
|
+
|
510
|
+
print head
|
511
|
+
print body
|
512
|
+
end
|