tdiary-contrib 3.2.2.20130518

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (393) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +35 -0
  6. data/README.en.md +12 -0
  7. data/README.md +13 -0
  8. data/Rakefile +41 -0
  9. data/doc/en/filter/spambayes.txt +3 -0
  10. data/doc/en/plugin.txt +1 -0
  11. data/doc/en/style/hatena.txt +10 -0
  12. data/doc/en/style/markdown.txt +16 -0
  13. data/doc/en/util.txt +1 -0
  14. data/doc/ja/filter/antirefspam.history.txt +59 -0
  15. data/doc/ja/filter/antirefspam.txt +86 -0
  16. data/doc/ja/filter/comment_key.ja.html +182 -0
  17. data/doc/ja/filter/spambayes.txt +3 -0
  18. data/doc/ja/plugin/add_bookmark.txt +50 -0
  19. data/doc/ja/plugin/category_to_tag.txt +21 -0
  20. data/doc/ja/plugin/cocoment.txt +31 -0
  21. data/doc/ja/plugin/google_adsense.txt +25 -0
  22. data/doc/ja/plugin/google_analytics.txt +7 -0
  23. data/doc/ja/plugin/image_detail.txt +69 -0
  24. data/doc/ja/plugin/image_gps.txt +36 -0
  25. data/doc/ja/plugin/image_gps2.txt +41 -0
  26. data/doc/ja/plugin/livedoor_weather.txt +105 -0
  27. data/doc/ja/plugin/opensearch_ad.txt +16 -0
  28. data/doc/ja/plugin/section_footer.txt +84 -0
  29. data/doc/ja/plugin/select_theme.txt +1 -0
  30. data/doc/ja/plugin.txt +13 -0
  31. data/doc/ja/style/hatena.txt +10 -0
  32. data/doc/ja/style/markdown.txt +13 -0
  33. data/doc/ja/util.txt +12 -0
  34. data/filter/antirefspam.rb +263 -0
  35. data/filter/commentkey.rb +29 -0
  36. data/filter/commentsize.rb +18 -0
  37. data/filter/hidecomment.rb +13 -0
  38. data/filter/iplookup.rb +55 -0
  39. data/filter/plugin/antirefspam.rb +59 -0
  40. data/filter/plugin/commentkey.rb +58 -0
  41. data/filter/plugin/commentsize.rb +12 -0
  42. data/filter/plugin/en/iplookup.rb +9 -0
  43. data/filter/plugin/en/spambayes.rb +123 -0
  44. data/filter/plugin/iplookup.rb +39 -0
  45. data/filter/plugin/ja/antirefspam.rb +91 -0
  46. data/filter/plugin/ja/commentkey.rb +17 -0
  47. data/filter/plugin/ja/commentsize.rb +6 -0
  48. data/filter/plugin/ja/iplookup.rb +9 -0
  49. data/filter/plugin/ja/spambayes.rb +124 -0
  50. data/filter/plugin/spambayes.rb +501 -0
  51. data/filter/plugin/zh/iplookup.rb +9 -0
  52. data/filter/rblcheck.rb +36 -0
  53. data/filter/spambayes.rb +535 -0
  54. data/filter/spamlookup.rb +37 -0
  55. data/io/dbi_io/ChangeLog +19 -0
  56. data/io/dbi_io/README.ja +39 -0
  57. data/io/dbi_io/dbi_io.rb +181 -0
  58. data/io/dbi_io/plugin/refererDbiIO.rb +76 -0
  59. data/io/dbi_io/tdiary_table.sql +42 -0
  60. data/js/appstore.js +109 -0
  61. data/js/datepicker.js +69 -0
  62. data/js/editor.js +82 -0
  63. data/js/flickr.js +157 -0
  64. data/js/image_ex.js +79 -0
  65. data/js/jquery.socialbutton.js +842 -0
  66. data/js/nicovideo.js +17 -0
  67. data/js/picasa.js +322 -0
  68. data/js/plugin_checker.js +71 -0
  69. data/js/prettify/lang-apollo.js +2 -0
  70. data/js/prettify/lang-clj.js +18 -0
  71. data/js/prettify/lang-css.js +2 -0
  72. data/js/prettify/lang-go.js +1 -0
  73. data/js/prettify/lang-hs.js +2 -0
  74. data/js/prettify/lang-lisp.js +3 -0
  75. data/js/prettify/lang-lua.js +2 -0
  76. data/js/prettify/lang-ml.js +2 -0
  77. data/js/prettify/lang-n.js +4 -0
  78. data/js/prettify/lang-proto.js +1 -0
  79. data/js/prettify/lang-scala.js +2 -0
  80. data/js/prettify/lang-sql.js +2 -0
  81. data/js/prettify/lang-tex.js +1 -0
  82. data/js/prettify/lang-vb.js +2 -0
  83. data/js/prettify/lang-vhdl.js +3 -0
  84. data/js/prettify/lang-wiki.js +2 -0
  85. data/js/prettify/lang-xq.js +3 -0
  86. data/js/prettify/lang-yaml.js +2 -0
  87. data/js/prettify/prettify.css +1 -0
  88. data/js/prettify/prettify.js +28 -0
  89. data/js/referer.js +17 -0
  90. data/js/show_and_hide.js +39 -0
  91. data/js/socialbutton.js +126 -0
  92. data/js/twitter_anywhere.js +28 -0
  93. data/js/yahoo_kousei.js +21 -0
  94. data/lib/bayes/convert.rb +34 -0
  95. data/lib/bayes.rb +232 -0
  96. data/lib/exifparser/BUGS +1 -0
  97. data/lib/exifparser/ChangeLog +169 -0
  98. data/lib/exifparser/README +15 -0
  99. data/lib/exifparser/install.rb +1015 -0
  100. data/lib/exifparser/lib/exifparser/makernote/canon.rb +502 -0
  101. data/lib/exifparser/lib/exifparser/makernote/fujifilm.rb +415 -0
  102. data/lib/exifparser/lib/exifparser/makernote/minolta.rb +84 -0
  103. data/lib/exifparser/lib/exifparser/makernote/mk_nikonflensname.rb +39 -0
  104. data/lib/exifparser/lib/exifparser/makernote/nikon.rb +267 -0
  105. data/lib/exifparser/lib/exifparser/makernote/nikon2.rb +581 -0
  106. data/lib/exifparser/lib/exifparser/makernote/nikonflensname.rb +438 -0
  107. data/lib/exifparser/lib/exifparser/makernote/olympus.rb +225 -0
  108. data/lib/exifparser/lib/exifparser/makernote/prove.rb +84 -0
  109. data/lib/exifparser/lib/exifparser/makernote/sigma.rb +237 -0
  110. data/lib/exifparser/lib/exifparser/pre-setup.rb +1 -0
  111. data/lib/exifparser/lib/exifparser/scan.rb +278 -0
  112. data/lib/exifparser/lib/exifparser/tag.rb +2298 -0
  113. data/lib/exifparser/lib/exifparser/thumbnail.rb +76 -0
  114. data/lib/exifparser/lib/exifparser/utils.rb +88 -0
  115. data/lib/exifparser/lib/exifparser.rb +265 -0
  116. data/lib/exifparser/sample/exifview.rb +279 -0
  117. data/lib/tdiary-contrib.rb +19 -0
  118. data/lib/wgs2tky.rb +93 -0
  119. data/misc/section_footer2/buzzurl.yaml +6 -0
  120. data/misc/section_footer2/fc2.yaml +6 -0
  121. data/misc/section_footer2/ldc.yaml +6 -0
  122. data/misc/section_footer2/retweet.yaml +7 -0
  123. data/misc/section_footer2/twitter.yaml +7 -0
  124. data/misc/section_footer2/yahoo.yaml +6 -0
  125. data/misc/tdiarygraph/tdiarygraph120x90e.swf +0 -0
  126. data/misc/tdiarygraph/tdiarygraph125x125e.swf +0 -0
  127. data/misc/tdiarygraph/tdiarygraph240x180e.swf +0 -0
  128. data/misc/tdiarygraph/tdiarygraph468x60e.swf +0 -0
  129. data/misc/tdiarygraph/tdiarygraph728x90e.swf +0 -0
  130. data/misc/tdiarytimes/tdiarytimes125x125r.swf +0 -0
  131. data/misc/tdiarytimes/tdiarytimes125x125r7.swf +0 -0
  132. data/misc/tdiarytimes/tdiarytimes125x125s.swf +0 -0
  133. data/misc/tdiarytimes/tdiarytimes125x30.swf +0 -0
  134. data/misc/tdiarytimes/tdiarytimes234x30.swf +0 -0
  135. data/misc/tdiarytimes/tdiarytimes468x30.swf +0 -0
  136. data/plugin/add_bookmark.rb +89 -0
  137. data/plugin/apple_webclip.rb +26 -0
  138. data/plugin/appstore.rb +47 -0
  139. data/plugin/bigpresen.rb +86 -0
  140. data/plugin/bitly.rb +39 -0
  141. data/plugin/bootstrap-navi.rb +54 -0
  142. data/plugin/canonical.rb +9 -0
  143. data/plugin/category_similar.rb +73 -0
  144. data/plugin/category_to_tag.rb +60 -0
  145. data/plugin/category_to_tagcloud.rb +172 -0
  146. data/plugin/cocomment.rb +37 -0
  147. data/plugin/code-prettify.rb +23 -0
  148. data/plugin/coderwall.rb +34 -0
  149. data/plugin/datepicker.rb +28 -0
  150. data/plugin/day2section.rb +20 -0
  151. data/plugin/del_footer.rb +111 -0
  152. data/plugin/description_from_body.rb +23 -0
  153. data/plugin/development.rb +16 -0
  154. data/plugin/editor.rb +11 -0
  155. data/plugin/en/add_bookmark.rb +20 -0
  156. data/plugin/en/del_footer.rb +10 -0
  157. data/plugin/en/git-register.rb +3 -0
  158. data/plugin/en/livedoor_weather.rb +25 -0
  159. data/plugin/en/microsummary.rb +18 -0
  160. data/plugin/en/nicovideo.rb +38 -0
  161. data/plugin/en/openid.rb +8 -0
  162. data/plugin/en/section_footer.rb +6 -0
  163. data/plugin/en/section_footer2.rb +3 -0
  164. data/plugin/en/socialbutton.rb +5 -0
  165. data/plugin/everytrail.rb +39 -0
  166. data/plugin/facebook_comments.rb +59 -0
  167. data/plugin/flickr.rb +209 -0
  168. data/plugin/gist.rb +16 -0
  169. data/plugin/git-register.rb +240 -0
  170. data/plugin/github_badge.rb +27 -0
  171. data/plugin/github_link.rb +9 -0
  172. data/plugin/goo_gl.rb +42 -0
  173. data/plugin/google_adsense.rb +132 -0
  174. data/plugin/google_analytics.rb +39 -0
  175. data/plugin/google_map.rb +168 -0
  176. data/plugin/google_sitemaps.rb +60 -0
  177. data/plugin/google_webmaster.rb +22 -0
  178. data/plugin/hatena_bookmark_nocomment.rb +9 -0
  179. data/plugin/hatena_star.rb +66 -0
  180. data/plugin/hb_footer.rb +255 -0
  181. data/plugin/hb_footer4sec.rb +244 -0
  182. data/plugin/hb_footer4sec_js.rb +30 -0
  183. data/plugin/hide_comment_form.rb +4 -0
  184. data/plugin/hide_sidebar_iphone.rb +21 -0
  185. data/plugin/iddy.rb +81 -0
  186. data/plugin/image_detail.rb +143 -0
  187. data/plugin/image_ex.rb +462 -0
  188. data/plugin/image_gps.rb +128 -0
  189. data/plugin/inline_wiki.rb +6 -0
  190. data/plugin/instagr.rb +64 -0
  191. data/plugin/ja/add_bookmark.rb +20 -0
  192. data/plugin/ja/del_footer.rb +10 -0
  193. data/plugin/ja/flickr.rb +62 -0
  194. data/plugin/ja/git-register.rb +3 -0
  195. data/plugin/ja/google_sitemaps.rb +35 -0
  196. data/plugin/ja/livedoor_weather.rb +25 -0
  197. data/plugin/ja/microsummary.rb +18 -0
  198. data/plugin/ja/nicovideo.rb +41 -0
  199. data/plugin/ja/openid.rb +7 -0
  200. data/plugin/ja/section_footer.rb +6 -0
  201. data/plugin/ja/section_footer2.rb +4 -0
  202. data/plugin/ja/socialbutton.rb +6 -0
  203. data/plugin/jdate.rb +20 -0
  204. data/plugin/jholiday.rb +16 -0
  205. data/plugin/jmonth.rb +20 -0
  206. data/plugin/jquery_ui_theme.rb +55 -0
  207. data/plugin/jroku.rb +28 -0
  208. data/plugin/jyear.rb +37 -0
  209. data/plugin/latlonglab_route.rb +25 -0
  210. data/plugin/lazy_referer.rb +38 -0
  211. data/plugin/livedoor_weather.rb +180 -0
  212. data/plugin/make_link.rb +44 -0
  213. data/plugin/makerss_category.rb +43 -0
  214. data/plugin/makerss_comment.rb +35 -0
  215. data/plugin/microsummary.rb +62 -0
  216. data/plugin/mm_footer.rb +215 -0
  217. data/plugin/monthly_autopagerize.rb +67 -0
  218. data/plugin/my_hotentry.rb +132 -0
  219. data/plugin/navi_day.rb +118 -0
  220. data/plugin/navi_this_month.rb +15 -0
  221. data/plugin/nicovideo.rb +115 -0
  222. data/plugin/notify_miniblog.rb +134 -0
  223. data/plugin/ogp.rb +55 -0
  224. data/plugin/ohmsha_estore.rb +71 -0
  225. data/plugin/openid.rb +90 -0
  226. data/plugin/opensearch_ad.rb +33 -0
  227. data/plugin/picasa.rb +56 -0
  228. data/plugin/plugin_checker.rb +41 -0
  229. data/plugin/popit.rb +22 -0
  230. data/plugin/prettify.rb +19 -0
  231. data/plugin/prezi.rb +10 -0
  232. data/plugin/profile.rb +222 -0
  233. data/plugin/puboo.rb +93 -0
  234. data/plugin/pygments_css.rb +76 -0
  235. data/plugin/rating.rb +419 -0
  236. data/plugin/recent_estraier.rb +50 -0
  237. data/plugin/recent_tweet.rb +71 -0
  238. data/plugin/retweet.rb +86 -0
  239. data/plugin/rubykaigi.rb +99 -0
  240. data/plugin/search-bing.rb +87 -0
  241. data/plugin/search-default.rb +264 -0
  242. data/plugin/search-google-custom.rb +60 -0
  243. data/plugin/search-yahoo-websearch.rb +121 -0
  244. data/plugin/search-yahoo.rb +109 -0
  245. data/plugin/section_footer.rb +195 -0
  246. data/plugin/section_footer2.rb +278 -0
  247. data/plugin/section_permalink.rb +73 -0
  248. data/plugin/section_permalink_anchor.rb +39 -0
  249. data/plugin/select_style.rb +42 -0
  250. data/plugin/select_theme.rb +90 -0
  251. data/plugin/show_and_hide.rb +77 -0
  252. data/plugin/slideshare.rb +10 -0
  253. data/plugin/socialbutton.rb +60 -0
  254. data/plugin/tatsu_zine.rb +93 -0
  255. data/plugin/tdiarygraph_flashstyle.rb +296 -0
  256. data/plugin/tdiarytimes.rb +166 -0
  257. data/plugin/tdiarytimes2.rb +406 -0
  258. data/plugin/tdiarytimes_flashstyle.rb +263 -0
  259. data/plugin/tdiarytimes_textstyle.rb +290 -0
  260. data/plugin/title_anchor.rb +16 -0
  261. data/plugin/tweet_quote.rb +106 -0
  262. data/plugin/twitpic.rb +10 -0
  263. data/plugin/twitter.rb +46 -0
  264. data/plugin/twitter_anywhere.rb +209 -0
  265. data/plugin/twitter_badge.rb +42 -0
  266. data/plugin/twitter_js.rb +59 -0
  267. data/plugin/ustream.rb +19 -0
  268. data/plugin/vimeo.rb +14 -0
  269. data/plugin/volatile.rb +89 -0
  270. data/plugin/vote.rb +100 -0
  271. data/plugin/wikiloc.rb +27 -0
  272. data/plugin/windex.rb +512 -0
  273. data/plugin/yahoo_kousei.rb +79 -0
  274. data/plugin/yahoo_map.rb +97 -0
  275. data/plugin/youtube.rb +33 -0
  276. data/plugin/yshop.rb +189 -0
  277. data/plugin/zenback.rb +46 -0
  278. data/spec/apple_webclip_spec.rb +46 -0
  279. data/spec/fixtures/friendfeed.xml +2 -0
  280. data/spec/fixtures/github.json +1 -0
  281. data/spec/fixtures/twitter.xml +73 -0
  282. data/spec/gist_spec.rb +16 -0
  283. data/spec/github_link_spec.rb +39 -0
  284. data/spec/google_analytics_spec.rb +60 -0
  285. data/spec/jdate_spec.rb +23 -0
  286. data/spec/jmonth_spec.rb +28 -0
  287. data/spec/jyear_spec.rb +21 -0
  288. data/spec/my_hotentry_spec.rb +78 -0
  289. data/spec/openid_spec.rb +246 -0
  290. data/spec/opensearch_ad_spec.rb +50 -0
  291. data/spec/profile_spec.rb +88 -0
  292. data/spec/rcov.opts +2 -0
  293. data/spec/spec_helper.rb +223 -0
  294. data/spec/title_anchor_spec.rb +39 -0
  295. data/spec/twitter_js_spec.rb +116 -0
  296. data/spec/youtube_spec.rb +20 -0
  297. data/style/hatena_style.rb +1011 -0
  298. data/style/markdown_style.rb +239 -0
  299. data/style/wikiext_style.rb +21 -0
  300. data/tdiary-contrib.gemspec +25 -0
  301. data/util/clean-spam/README.ja +1 -0
  302. data/util/clean-spam/tdiary-comment-clean +46 -0
  303. data/util/clean-spam/tdiary-comment-clean2 +81 -0
  304. data/util/clean-spam/tdiary-referer-clean +46 -0
  305. data/util/convert_pstore.rb +82 -0
  306. data/util/estraier-search/ChangeLog +36 -0
  307. data/util/estraier-search/README.ja +114 -0
  308. data/util/estraier-search/en/estraier-register.rb +3 -0
  309. data/util/estraier-search/estraier-register.rb +298 -0
  310. data/util/estraier-search/estraier-search.rb +273 -0
  311. data/util/estraier-search/estraier.rhtml +73 -0
  312. data/util/estraier-search/estraier.rxml +23 -0
  313. data/util/estraier-search/i.estraier.rhtml +31 -0
  314. data/util/estraier-search/ja/estraier-register.rb +3 -0
  315. data/util/image-gallery/README.ja +27 -0
  316. data/util/image-gallery/image-gallery.rb +523 -0
  317. data/util/image-gallery/image-gallery.rb.euc-jp +523 -0
  318. data/util/image-gallery/js/SmoothGallery/Changelog +52 -0
  319. data/util/image-gallery/js/SmoothGallery/css/ReMooz.css +186 -0
  320. data/util/image-gallery/js/SmoothGallery/css/img/carrow1.gif +0 -0
  321. data/util/image-gallery/js/SmoothGallery/css/img/carrow2.gif +0 -0
  322. data/util/image-gallery/js/SmoothGallery/css/img/closebox.gif +0 -0
  323. data/util/image-gallery/js/SmoothGallery/css/img/closebox.png +0 -0
  324. data/util/image-gallery/js/SmoothGallery/css/img/fleche1.gif +0 -0
  325. data/util/image-gallery/js/SmoothGallery/css/img/fleche1.png +0 -0
  326. data/util/image-gallery/js/SmoothGallery/css/img/fleche2.gif +0 -0
  327. data/util/image-gallery/js/SmoothGallery/css/img/fleche2.png +0 -0
  328. data/util/image-gallery/js/SmoothGallery/css/img/loading-bar-black.gif +0 -0
  329. data/util/image-gallery/js/SmoothGallery/css/img/open.gif +0 -0
  330. data/util/image-gallery/js/SmoothGallery/css/img/open.png +0 -0
  331. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_e.png +0 -0
  332. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_n.png +0 -0
  333. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_ne.png +0 -0
  334. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_nw.png +0 -0
  335. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_s.png +0 -0
  336. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_se.png +0 -0
  337. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_sw.png +0 -0
  338. data/util/image-gallery/js/SmoothGallery/css/img/remo_bg_w.png +0 -0
  339. data/util/image-gallery/js/SmoothGallery/css/img/spinner.gif +0 -0
  340. data/util/image-gallery/js/SmoothGallery/css/jd.gallery.css +371 -0
  341. data/util/image-gallery/js/SmoothGallery/css/layout.css +91 -0
  342. data/util/image-gallery/js/SmoothGallery/license.txt +621 -0
  343. data/util/image-gallery/js/SmoothGallery/resizer.php +113 -0
  344. data/util/image-gallery/js/SmoothGallery/scripts/Changelog +52 -0
  345. data/util/image-gallery/js/SmoothGallery/scripts/History.Routing.js +126 -0
  346. data/util/image-gallery/js/SmoothGallery/scripts/History.js +109 -0
  347. data/util/image-gallery/js/SmoothGallery/scripts/ReMooz.js +364 -0
  348. data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.js +843 -0
  349. data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.set.js +183 -0
  350. data/util/image-gallery/js/SmoothGallery/scripts/jd.gallery.transitions.js +90 -0
  351. data/util/image-gallery/js/SmoothGallery/scripts/jdgalleryresize.js +828 -0
  352. data/util/image-gallery/js/SmoothGallery/scripts/license.txt +621 -0
  353. data/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2-more.js +103 -0
  354. data/util/image-gallery/js/SmoothGallery/scripts/mootools-1.2.1-core-yc.js +349 -0
  355. data/util/image-gallery/js/SmoothGallery/scripts/resizer.php +113 -0
  356. data/util/image-gallery/misc/plugin/recent_image.rb +406 -0
  357. data/util/image-gallery/skel/gallery.rhtml +154 -0
  358. data/util/image-gallery/skel/gallery.rhtml.euc-jp +154 -0
  359. data/util/image-gallery/tdiary.conf.igsample +8 -0
  360. data/util/image-gallery/theme/image-gallery.css +85 -0
  361. data/util/image2flickr.rb +282 -0
  362. data/util/posttdiary/README.ja +12 -0
  363. data/util/posttdiary/posttdiary-ex.rb +1155 -0
  364. data/util/posttdiary/posttdiary.rb +245 -0
  365. data/util/rast-search/ChangeLog +55 -0
  366. data/util/rast-search/README.ja +99 -0
  367. data/util/rast-search/en/rast-register.rb +3 -0
  368. data/util/rast-search/i.rast.rhtml +33 -0
  369. data/util/rast-search/ja/rast-register.rb +3 -0
  370. data/util/rast-search/rast-register.rb +326 -0
  371. data/util/rast-search/rast-search.rb +249 -0
  372. data/util/rast-search/rast.rhtml +66 -0
  373. data/util/rast-search/rast.rxml +21 -0
  374. data/util/section_link/README +11 -0
  375. data/util/section_link/misc/plugin/section_link.rb +68 -0
  376. data/util/section_link/misc/plugin/section_link_anchor.rb +38 -0
  377. data/util/section_link/tdiary/tdiary_day_ext.rb +21 -0
  378. data/util/section_link/tdiary/tdiaryext_style.rb +36 -0
  379. data/util/section_link/tdiary/wikiext_style.rb +36 -0
  380. data/util/tdiary-for-ruby1.9/compatible.rb +97 -0
  381. data/util/tdiary-for-ruby1.9/tdiary-2.2.0.patch +98 -0
  382. data/util/tdiary-for-ruby1.9/tdiary-2.3.1.patch +212 -0
  383. data/util/tdiary-grep/README +4 -0
  384. data/util/tdiary-grep/grep.rb +445 -0
  385. data/util/tdiary-mode/http.el +130 -0
  386. data/util/tdiary-mode/tdiary-mode.el +613 -0
  387. data/util/tdiary-vim/ChangeLog +25 -0
  388. data/util/tdiary-vim/README +60 -0
  389. data/util/tdiary-vim/tdiary.vim +350 -0
  390. data/util/tdiarysearch/README.en +53 -0
  391. data/util/tdiarysearch/README.ja +99 -0
  392. data/util/tdiarysearch/search.rb +504 -0
  393. metadata +497 -0
@@ -0,0 +1,132 @@
1
+ # show my hot-entry in Hatena::Bookmark
2
+ #
3
+ # usage:
4
+ # <%= my_hotentry %>
5
+ #
6
+ # Copyright (c) MATSUOKA Kohei <http://www.machu.jp/>
7
+ # Distributed under the GPL
8
+ #
9
+ require 'uri'
10
+ require 'open-uri'
11
+ require 'rexml/document'
12
+ require 'pstore'
13
+ require 'timeout'
14
+
15
+ # 人気の日記のソート順(新着順: eid, 注目順: hot, 人気順: count)
16
+ @conf ||= {}
17
+ @conf['my_hotentry.sort'] ||= 'hot'
18
+
19
+ class MyHotEntry
20
+ def initialize(dbfile)
21
+ @dbfile = dbfile
22
+ end
23
+
24
+ # 人気の日記の一覧を返す
25
+ def entries
26
+ r = nil
27
+ PStore.new(@dbfile).transaction(true) do |db|
28
+ r = db[:entries]
29
+ end
30
+ r || []
31
+ end
32
+
33
+ # 人気の日記一覧を取得する
34
+ def update(base_url, options = {})
35
+ options[:title] ||= ''
36
+ options[:sort] ||= 'eid'
37
+ options[:threshold] ||= 3
38
+
39
+ # RSSを取得
40
+ rss = nil
41
+ rss_url = 'http://b.hatena.ne.jp/entrylist?mode=rss&url='
42
+ rss_url << URI.escape(base_url, /[^-.!~*'()\w]/n)
43
+ rss_url << "&sort=#{options[:sort]}&threshold=#{options[:threshold]}"
44
+ begin
45
+ timeout(5) do
46
+ # convert Tempfile to String because REXML can't accept Tempfile
47
+ open(rss_url) do |f|
48
+ rss = REXML::Document.new(f.readlines.join("\n"))
49
+ end
50
+ end
51
+ rescue TimeoutError => e
52
+ return
53
+ end
54
+ # RDF/itemが空ならDBを更新しない (たまにitemが空のデータが返るため)
55
+ return if rss.elements['rdf:RDF/item'].nil?
56
+
57
+ # キャッシュに格納する
58
+ PStore.new(@dbfile).transaction do |db|
59
+ db[:entries] = []
60
+ rss.elements.each('rdf:RDF/item') do |item|
61
+ url = item.elements['link'].text
62
+ title = item.elements['title'].text
63
+ # リンク先のタイトルからサイト名と日付を取り除く
64
+ title.sub!(/(?: - )?#{options[:html_title]}(?: - )?/, '')
65
+ title.sub!(/\(\d{4}-\d{2}-\d{2}\)/, '')
66
+ db[:entries].push({ :url => url, :title => title })
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ # キャッシュファイルのパスを取得する
73
+ def my_hotentry_dbfile
74
+ cache_dir = "#{@cache_path}/hatena"
75
+ Dir::mkdir(cache_dir) unless File::directory?(cache_dir)
76
+ "#{cache_dir}/my_hotentry.dat"
77
+ end
78
+
79
+ # 人気の日記一覧を表示する
80
+ def my_hotentry(count = 5)
81
+ dbfile = my_hotentry_dbfile
82
+ hotentry = MyHotEntry.new(dbfile)
83
+ r = %Q|<ul class="rss-recent">\n|
84
+ hotentry.entries[0...count].each do |entry|
85
+ entry_link = %Q|<a href="#{entry[:url]}">#{CGI::escapeHTML(entry[:title])}</a>|
86
+ escape_url = entry[:url].gsub(/#/, '%23')
87
+ b_image = "http://b.hatena.ne.jp/entry/image/#{escape_url}"
88
+ b_link = "http://b.hatena.ne.jp/entry/#{escape_url}"
89
+ b_title = "このエントリを含むはてなブックマーク"
90
+ bookmark_link = %Q|<a href="#{b_link}" title="#{b_title}"><img border="0" src="#{b_image}"></a>|
91
+ r << "\t\t<li>#{entry_link} #{bookmark_link}</li>"
92
+ end
93
+ r << %Q|</ul>|
94
+ r << %Q|<div class="iddy"><span class="iddy-powered">\tPowered by <a href="http://b.hatena.ne.jp/entrylist?url=#{@conf.base_url}&amp;sort=#{@conf['my_hotentry.sort']}">Hatena Bookmark</a></span></div>\n|
95
+ end
96
+
97
+ # 人気の日記一覧を更新する
98
+ def my_hotentry_update
99
+ dbfile = my_hotentry_dbfile
100
+ hotentry = MyHotEntry.new(dbfile)
101
+ hotentry.update(@conf.base_url,
102
+ :html_title => @conf.html_title,
103
+ :sort => @conf['my_hotentry.sort'])
104
+ end
105
+
106
+ if __FILE__ == $0
107
+ # コマンドラインから実行した場合
108
+ # tdiary.conf に base_url を設定しないと動作しない
109
+ begin
110
+ require 'tdiary'
111
+ rescue LoadError
112
+ STDERR.puts "tdiary.rb not found."
113
+ STDERR.puts "please execute in tdiary base directory"
114
+ exit 1
115
+ end
116
+ cgi = CGI::new
117
+ @conf = TDiary::Config::new(cgi)
118
+ @cache_path = @conf.cache_path || "#{@conf.data_path}cache"
119
+ my_hotentry_update
120
+ puts my_hotentry
121
+ else
122
+ # 人気の日記一覧を取得する (日記更新時)
123
+ add_update_proc do
124
+ # ツッコミ時は実行しない
125
+ if @mode == 'append' or @mode == 'replace'
126
+ begin
127
+ my_hotentry_update
128
+ rescue
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,118 @@
1
+ #
2
+ # navi_day.rb
3
+ #
4
+ # navi_day: 「前の日記」や「次の日記」を“月またぎ”に対応させる。
5
+ #
6
+ # 日単位での表示の時の「前の日記」や「次の日記」のリンクが、
7
+ # 異なる月の日記を正しく指せない場合があるという tDiary の制限を
8
+ # 解消するプラグインです。以前よりある navi_user.rb と機能的には
9
+ # 同じですが、navi_user.rb よりは処理がずっと軽くなっています。
10
+ # また、日記の表示状態(非表示の日記)に対する考慮もなされています。
11
+ #
12
+ # tDiary 2.0 以降で使えると思います。セキュアモードでも使えますが、
13
+ # セキュアモードの場合は、モバイル端末からのアクセスに対しては
14
+ # このプラグインは効力を持ちません(tDiary セキュア環境の制限:
15
+ # モバイル端末の場合は本文を出力するときに calc_links が呼ばれる
16
+ # ため)。
17
+ #
18
+ # navi_user.rb と併用すると navi_user.rb の方が優先されますので、
19
+ # このプラグインを使うときには必ず navi_user.rb を外してください。
20
+ #
21
+ # Copyright (C) 2007, MIYASAKA Masaru <alkaid@coral.ocn.ne.jp>
22
+ # You can redistribute it and/or modify it under GPL2.
23
+ #
24
+ # Last Modified : May 27, 2007
25
+ #
26
+
27
+ # for tDiary 2.0.X
28
+ if not TDiaryMonth.method_defined?(:diaries) then
29
+ eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
30
+ module TDiary
31
+ class TDiaryMonth
32
+ attr_reader :diaries
33
+ end
34
+ end
35
+ MODIFY_CLASS
36
+ end
37
+
38
+ class NaviDayCGI
39
+ attr_reader :params
40
+ def referer; nil; end
41
+ def initialize
42
+ @params = Hash.new([])
43
+ end
44
+ end
45
+
46
+ alias :calc_links_navi_day_backup :calc_links
47
+
48
+ def calc_links
49
+ if not (@conf.secure and @conf.mobile_agent?) and \
50
+ (/day|edit/ =~ @mode or \
51
+ (@conf.mobile_agent? and /latest|month|nyear/ =~ @mode)) then
52
+ if /(latest|month|nyear)/ === @mode
53
+ today = @diaries.keys.sort[-1]
54
+ else
55
+ today = @date.strftime('%Y%m%d')
56
+ end
57
+ days = @diaries.keys
58
+ days |= [today]
59
+ days.sort!
60
+ days.unshift(nil).push(nil)
61
+ today_index = days.index(today)
62
+
63
+ days[0 .. today_index - 1].reverse_each do |prev_day|
64
+ @prev_day = prev_day
65
+ break unless @prev_day
66
+ break if (@mode == 'edit') or @diaries[@prev_day].visible?
67
+ end
68
+
69
+ days[today_index + 1 .. -1].each do |next_day|
70
+ @next_day = next_day
71
+ break unless @next_day
72
+ break if (@mode == 'edit') or @diaries[@next_day].visible?
73
+ end
74
+
75
+ if not @prev_day or not @next_day then
76
+ cgi = NaviDayCGI.new
77
+ years = []
78
+ @years.each do |k, v|
79
+ v.each do |m|
80
+ years << k + m
81
+ end
82
+ end
83
+ this_month = @date.strftime('%Y%m')
84
+ years |= [this_month]
85
+ years.sort!
86
+ years.unshift(nil).push(nil)
87
+ this_month_index = years.index(this_month)
88
+
89
+ years[0 .. this_month_index - 1].reverse_each do |prev_month|
90
+ break unless not @prev_day and prev_month
91
+ cgi.params['date'] = [prev_month]
92
+ diaries = TDiaryMonth.new(cgi, '', @conf).diaries
93
+ days = diaries.keys.sort
94
+ days.unshift(nil)
95
+ days.reverse_each do |prev_day|
96
+ @prev_day = prev_day
97
+ break unless @prev_day
98
+ break if (@mode == 'edit') or diaries[@prev_day].visible?
99
+ end
100
+ end
101
+
102
+ years[this_month_index + 1 .. -1].each do |next_month|
103
+ break unless not @next_day and next_month
104
+ cgi.params['date'] = [next_month]
105
+ diaries = TDiaryMonth.new(cgi, '', @conf).diaries
106
+ days = diaries.keys.sort
107
+ days.push(nil)
108
+ days.each do |next_day|
109
+ @next_day = next_day
110
+ break unless @next_day
111
+ break if (@mode == 'edit') or diaries[@next_day].visible?
112
+ end
113
+ end
114
+ end
115
+ else
116
+ calc_links_navi_day_backup
117
+ end
118
+ end
@@ -0,0 +1,15 @@
1
+ # navi-this-month.rb
2
+ # ref. http://www.tom.sfc.keio.ac.jp/~sakai/d/?date=20080628#p01
3
+ #
4
+ alias navi_this_month__orig__navi_user_day navi_user_day
5
+
6
+ def navi_user_day
7
+ result = navi_this_month__orig__navi_user_day
8
+ if @mode=='day'
9
+ this_month = @date.strftime( '%Y%m' )
10
+ result << navi_item( "#{@index}#{anchor this_month}", "#{navi_this_month}" )
11
+ end
12
+ result
13
+ end
14
+
15
+ def navi_this_month; "月表示"; end
@@ -0,0 +1,115 @@
1
+ #
2
+ # nicovideo.rb - tDiary plugin for Nico Nico Video
3
+ #
4
+ # Copyright (C) 2012 TADA Tadashi <t@tdtds.jp>
5
+ # You can modify and/or distribute it under GPL.
6
+ #
7
+ # usage:
8
+ # Link to the movie and show thumbnail, description...:
9
+ # <%= nicovideo 'sm99999999' %>
10
+ #
11
+ # Link to the movie with original label:
12
+ # <%= nicovideo 'sm99999999', 'movie title' %>
13
+ #
14
+ # Link to the movie with original label and link:
15
+ # <%= nicovideo 'sm99999999', 'movie title', 'http://example.com/video' %>
16
+ #
17
+ # Show Inline player:
18
+ # <%= nicovideo_player 'sm99999999' %>
19
+ #
20
+ # Show Inline player with size:
21
+ # <%= nicovideo_player 'sm99999999', [400,300] %>
22
+ #
23
+ require 'net/http'
24
+ require 'timeout'
25
+ require 'rexml/document'
26
+
27
+ enable_js( 'nicovideo.js' )
28
+
29
+ def nicovideo_call_api( video_id )
30
+ uri = "http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}"
31
+ proxy = @conf['proxy']
32
+ proxy = 'http://' + proxy if proxy
33
+ xml = timeout( feed? ? 10 : 2 ) {
34
+ px_host, px_port = (@conf['proxy'] || '').split( /:/ )
35
+ px_port = 80 if px_host and !px_port
36
+ Net::HTTP::Proxy( px_host, px_port ).get_response( URI::parse( uri ) ).body
37
+ }
38
+ doc = REXML::Document::new( xml ).root
39
+ res = doc.elements.to_a( '/nicovideo_thumb_response' )[0]
40
+ if res.attributes['status'] == 'ok' then
41
+ res.elements.to_a( 'thumb' )[0]
42
+ else
43
+ raise ::Errno::ENOENT::new
44
+ end
45
+ end
46
+
47
+ def nicovideo_inline( video_id, elem, label = nil, link = nil )
48
+ i = {}
49
+ i[:id] = video_id
50
+ i[:url] = link || elem.to_a( 'watch_url' )[0].text
51
+ i[:thumb] = elem.to_a( 'thumbnail_url' )[0].text
52
+ i[:title] = label || elem.to_a( 'title' )[0].text
53
+ i[:desc] = elem.to_a( 'description' )[0].text
54
+ i[:comment] = @conf.mobile_agent? ? '' : elem.to_a( 'last_res_body' )[0].text
55
+ i[:date] = elem.to_a( 'first_retrieve' )[0].text
56
+ i[:length] = elem.to_a( 'length' )[0].text
57
+ i[:view] = elem.to_a( 'view_counter' )[0].text
58
+ i[:comment_num] = elem.to_a( 'comment_num' )[0].text
59
+ i[:mylist] = elem.to_a( 'mylist_counter' )[0].text
60
+
61
+ if feed? then
62
+ result = nicovideo_feed( i )
63
+ else
64
+ result = nicovideo_html( i )
65
+ end
66
+ result.gsub( /^\t+/, '' )
67
+ end
68
+
69
+ def nicovideo_iframe( video_id )
70
+ %Q|<iframe src="http://www.nicovideo.jp/thumb/#{video_id}" scrolling="no" style="border:1px solid #CCC;" frameborder="0"><a href="http://www.nicovideo.jp/watch/#{video_id}">#{label || 'link for nicovideo'}</a></iframe>\n|
71
+ end
72
+
73
+ def nicovideo_player( video_id, size = [544,384] )
74
+ if feed? or @conf.mobile_agent? or @conf.iphone? then
75
+ nicovideo( video_id )
76
+ else
77
+ q = ''
78
+ if size then
79
+ q = "?w=#{h size[0]}&amp;h=#{h size[1]}"
80
+ end
81
+ %Q|<script type="text/javascript" src="#{nicovideo_player_path}/thumb_watch/#{video_id}#{q}"></script>|
82
+ end
83
+ end
84
+
85
+ def nicovideo( video_id, label = nil, link = nil )
86
+ begin
87
+ r = ''
88
+ r << %Q|<div id="thumbnail-#{video_id}">|
89
+ api = nicovideo_call_api( video_id ).elements
90
+ thumb = @conf.to_native( nicovideo_inline( video_id, api, label, link ), 'UTF-8' )
91
+ thumb.gsub!( /"INLINE_PLAYER"/, %Q|"#" onclick="return nicovideoPlayer( '#{video_id}' );"| )
92
+ r << thumb
93
+ r << '</div>'
94
+ if feed? or @conf.mobile_agent? or @conf.iphone? then
95
+ r.gsub!( /<a(?:[ \t\n\r][^>]*)?>/, '' )
96
+ r.gsub!( %r{</a[ \t\n\r]*>}, '' )
97
+ else
98
+ r << %Q|<div id="player-#{video_id}" style="display:none;background-color:#000;margin-left:2em;padding-bottom:4px;">|
99
+ r << %Q|<a name="player-#{video_id}">|
100
+ r << nicovideo_player( video_id, [544,384] )
101
+ r << %Q|</a>|
102
+ r << %Q|<div class="nicovideo-player-close" style="margin:4px;padding:8px;">|
103
+ r << %Q|<a href="#" onclick="return nicovideoThumbnail( '#{video_id}' )" style="background-color:black; color:white; margin:2px; padding:8px; border-color:white; border-radius:6px; border-width:2px; border-style:solid; text-decoration:none;">▲CLOSE PLAYER</a>|
104
+ r << %Q|&nbsp;<a href="#{api.to_a( 'watch_url' )[0].text}" style="background-color:black; color:white; margin:2px; padding:8px; border-color:white; border-radius:6px; border-width:2px; border-style:solid; text-decoration:none;">SHOW ORIGINAL&gt;</a>|
105
+ r << %Q|</div>|
106
+ r << %Q|</div>|
107
+ end
108
+ r
109
+ rescue ::Errno::ENOENT
110
+ "<strong>Sorry, #{video_id} was deleted.</strong>"
111
+ rescue Timeout::Error, NoMethodError, SecurityError, StandardError
112
+ nicovideo_iframe( video_id )
113
+ end
114
+ end
115
+
@@ -0,0 +1,134 @@
1
+ #
2
+ # Copyright (C) 2007 peo <peo@mb.neweb.ne.jp>
3
+ # You can redistribute it and/or modify it under GPL2.
4
+ #
5
+ # modified hsbt.
6
+
7
+ require 'net/http'
8
+
9
+ @miniblog_config = (Struct.const_defined?("MiniBlogConfig") ? Struct::MiniBlogConfig :
10
+ Struct.new("MiniBlogConfig", :host, :path))
11
+
12
+ @miniblog_list = {
13
+ 'HatenaHaiku' => @miniblog_config.new('h.hatena.ne.jp', '/api/statuses/update.json'),
14
+ }
15
+
16
+ module Miniblog
17
+ class Updater
18
+ def initialize( user, pass, config )
19
+ @user = user
20
+ @pass = pass
21
+ @config = config
22
+ end
23
+
24
+ # this code is based on http://la.ma.la/blog/diary_200704111918.htm
25
+ def update( status )
26
+ Net::HTTP.version_1_2
27
+ req = Net::HTTP::Post.new(@config.path)
28
+ req.basic_auth(@user, @pass)
29
+ req.body = status
30
+
31
+ Net::HTTP.start( @config.host, 80 ) do |http|
32
+ response = http.request(req)
33
+ if response.body =~ /error/
34
+ raise 'update failed.'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def notify_miniblog
42
+ notify_miniblog_init
43
+
44
+ date = @date.strftime('%Y%m%d')
45
+ diary = @diaries[date]
46
+ sectitle = ''
47
+ index = 0
48
+
49
+ diary.each_section do |sec|
50
+ index += 1
51
+ sectitle = sec.subtitle
52
+ end
53
+
54
+ # strip category
55
+ sectitle.gsub!(/\[[^\]]+\] */, '')
56
+ url = URI.encode(@conf.base_url + anchor("#{date}p%02d" % index), /[^-.!~*'()\w]/n)
57
+ prefix = @conf['miniblog.notify.prefix']
58
+ format = @conf['miniblog.notify.format']
59
+ source = 'tdiary/notify_miniblog.rb'
60
+
61
+ status = 'status=' + format % [prefix, sectitle, url] + '&source=' + source
62
+ if @conf['miniblog.service'] == "HatenaHaiku" then
63
+ status += '&keyword=id:' + @conf['miniblog.user']
64
+ end
65
+
66
+ config = @miniblog_list[@conf['miniblog.service']]
67
+
68
+ begin
69
+ miniblog_updater = Miniblog::Updater.new(@conf['miniblog.user'], @conf['miniblog.pass'], config)
70
+ miniblog_updater.update( status )
71
+ rescue => e
72
+ @logger.debug( e )
73
+ end
74
+ end
75
+
76
+ def notify_miniblog_init
77
+ @conf['miniblog.notify.prefix'] ||= '[blog update]'
78
+ @conf['miniblog.notify.format'] ||= '%s %s %s'
79
+ @conf['miniblog.service'] ||= 'Twitter'
80
+ end
81
+
82
+ add_update_proc do
83
+ if @mode == 'append' then
84
+ notify_miniblog if @cgi.params['miniblog.notify'][0] == 'true'
85
+ end
86
+ end
87
+
88
+ add_edit_proc do
89
+ checked = ''
90
+ if @mode == 'preview' then
91
+ checked = @cgi.params['miniblog.notify'][0] == 'true' ? ' checked' : ''
92
+ end
93
+ <<-HTML
94
+ <div class="miniblog.notify"><label for="miniblog.notify">
95
+ <input type="checkbox" id="miniblog.notify" name="miniblog.notify" value="true"#{checked} tabindex="400">
96
+ Post the update to #{@conf['miniblog.service']}
97
+ </label>
98
+ </div>
99
+ HTML
100
+ end
101
+
102
+ add_conf_proc( 'notify_miniblog', 'MiniBlog' ) do
103
+ notify_miniblog_init
104
+
105
+ if @mode == 'saveconf' then
106
+ @conf['miniblog.service'] = @cgi.params['miniblog.service'][0]
107
+ @conf['miniblog.user'] = @cgi.params['miniblog.user'][0]
108
+ @conf['miniblog.pass'] = @cgi.params['miniblog.pass'][0]
109
+ @conf['miniblog.notify.prefix'] = @cgi.params['miniblog.notify.prefix'][0]
110
+ @conf['miniblog.notify.format'] = @cgi.params['miniblog.notify.format'][0]
111
+ end
112
+
113
+ options = ''
114
+ @miniblog_list.each_key do |key|
115
+ options << %Q|<option value="#{h key}"#{" selected" if @conf['miniblog.service'] == key}>#{h key}</option>\n|
116
+ end
117
+
118
+ <<-HTML
119
+ <h3 class="subtitle">MiniBlog Service</h3>
120
+ <p><select name="miniblog.service">
121
+ #{options}
122
+ </select></p>
123
+ <h3 class="subtitle">Account Name</h3>
124
+ <p><input name="miniblog.user" value="#{h @conf['miniblog.user']}"></p>
125
+ <h3 class="subtitle">Account Password</h3>
126
+ <p><input name="miniblog.pass" value="#{h @conf['miniblog.pass']}"></p>
127
+ <h3 class="subtitle">Notify prefix</h3>
128
+ <p><input name="miniblog.notify.prefix" value="#{h @conf['miniblog.notify.prefix']}"></p>
129
+ <h3 class="subtitle">Notify status format</h3>
130
+ <p><input name="miniblog.notify.format" value="#{h @conf['miniblog.notify.format']}"></p>
131
+ HTML
132
+ end
133
+
134
+ # vim:ts=3
data/plugin/ogp.rb ADDED
@@ -0,0 +1,55 @@
1
+ # ogp.rb - add Open Graph Protocol <meta> tags to header
2
+ #
3
+ # Copyright (c) 2011 MATSUOKA Kohei <kmachu@gmail.com>
4
+ # You can redistribute it and/or modify it under GPL2.
5
+ #
6
+
7
+ # @conf['ogp.facebook.app_id'] - your facebook application ID.
8
+ # @conf['ogp.facebook.admins'] - your facebook ID.
9
+
10
+ def ogp_description
11
+ section_index = @cgi.params['p'][0]
12
+ # section_index = "1"
13
+ if @mode == 'day' and section_index
14
+ diary = @diaries[@date.strftime('%Y%m%d')]
15
+ sections = diary.instance_variable_get(:@sections)
16
+ section = sections[section_index.to_i - 1].body_to_html
17
+ @conf.shorten(apply_plugin(section, true), 200)
18
+ else
19
+ @conf.description
20
+ end
21
+ end
22
+
23
+ add_header_proc do
24
+ headers = {
25
+ # TODO: og:urlへ対応
26
+ 'og:title' => title_tag.match(/>([^<]+)</).to_a[1],
27
+ 'og:site_name' => @conf.html_title,
28
+ 'og:description' => ogp_description,
29
+ 'og:image' => @conf.banner,
30
+ 'og:type' => (@mode == 'day') ? 'article' : 'blog',
31
+ 'og:author' => @conf.author_name,
32
+ 'fb:app_id' => @conf['ogp.facebook.app_id'],
33
+ 'fb:admins' => @conf['ogp.facebook.admins']
34
+ }
35
+ headers.select {|key, val|
36
+ val && !val.empty?
37
+ }.map {|key, val|
38
+ %Q|<meta property="#{key}" content="#{CGI::escapeHTML(val)}">|
39
+ }.join("\n")
40
+ end
41
+
42
+ add_conf_proc('Open Graph Protocol', 'Open Graph Protocol') do
43
+ if @mode == 'saveconf'
44
+ @conf['ogp.facebook.app_id'] = @cgi.params['ogp.facebook.app_id'][0]
45
+ @conf['ogp.facebook.admins'] = @cgi.params['ogp.facebook.admins'][0]
46
+ end
47
+
48
+ <<-HTML
49
+ <h3>Facebook Application ID</h3>
50
+ <p><input name="ogp.facebook.app_id" value="#{h(@conf['ogp.facebook.app_id'])}"></p>
51
+
52
+ <h3>Facebook User ID</h3>
53
+ <p><input name="ogp.facebook.admins" value="#{h(@conf['ogp.facebook.admins'])}"></p>
54
+ HTML
55
+ end
@@ -0,0 +1,71 @@
1
+ # -*- coding: utf-8 -*-
2
+ # You can redistribute it and/or modify it under the same license as tDiary.
3
+ #
4
+ # display book info in http://estore.ohmsha.co.jp/ like amazon.rb
5
+ # USAGE: {{ohmsha_estore '978427406694P'}}
6
+
7
+ def ohmsha_estore_cache_dir
8
+ cache = "#{@cache_path}/ohmsha-estore"
9
+ Dir.mkdir( cache ) unless File.directory?( cache )
10
+ cache
11
+ end
12
+
13
+ def ohmsha_estore_cache_set( id, result )
14
+ File.open( "#{ohmsha_estore_cache_dir}/#{id}", "w" ) do |f|
15
+ f.write result
16
+ end
17
+ end
18
+
19
+ def ohmsha_estore_cache_get( id )
20
+ File.open( "#{ohmsha_estore_cache_dir}/#{id}", "r" ) do |f|
21
+ f.read
22
+ end
23
+ rescue
24
+ nil
25
+ end
26
+
27
+ def ohmsha_estore( id, doc = nil )
28
+ if !@conf.secure and !(result = ohmsha_estore_cache_get(id)).nil?
29
+ return result
30
+ end
31
+
32
+ domain = "http://estore.ohmsha.co.jp"
33
+ image = "#{domain}/images/covers/#{id}.gif"
34
+ link = "#{domain}/titles/#{id}"
35
+ require 'open-uri'
36
+ doc ||= open(link)
37
+ require 'rexml/document'
38
+ xml = REXML::Document.new( doc )
39
+ biblio = "//html/body/div/div[2]/div/div/div/div[2]"
40
+ title = REXML::XPath.match( xml,
41
+ "#{biblio}/h2").first.text
42
+ author = REXML::XPath.match( xml,
43
+ "#{biblio}/div" ).first.text
44
+
45
+ description =
46
+ REXML::XPath.match( xml, '//html/body/div/div[2]/div/div/div[2]' ).
47
+ first.text
48
+
49
+ result = <<-EOS
50
+ <a class="amazon-detail" href="#{h link}"><div class="amazon-detail">
51
+ <img class="amazon-detail left" src="#{h image}"
52
+ height="150" width="100"
53
+ alt="#{h title}">
54
+ <div class="amazon-detail-desc">
55
+ <span class="amazon-title">#{h title}</span><br>
56
+ <span class="amazon-author">#{h author}</span><br>
57
+ <span class="amazon-label">#{h description}</span><br>
58
+ </div><br style="clear: left">
59
+ </div></a>
60
+ EOS
61
+
62
+ ohmsha_estore_cache_set( id, result ) unless @conf.secure
63
+ result
64
+ end
65
+
66
+ # Local Variables:
67
+ # mode: ruby
68
+ # indent-tabs-mode: t
69
+ # tab-width: 3
70
+ # ruby-indent-level: 3
71
+ # End: