tdiary 3.2.2.20130507

Sign up to get free protection for your applications and to get access to all the features.
Files changed (509) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +16 -0
  4. data/.travis.yml +29 -0
  5. data/Capfile +2 -0
  6. data/ChangeLog +3173 -0
  7. data/Gemfile +58 -0
  8. data/Gemfile.lock +201 -0
  9. data/LICENSE +340 -0
  10. data/Procfile +1 -0
  11. data/README.md +33 -0
  12. data/Rakefile +26 -0
  13. data/bin/tdiary +7 -0
  14. data/config.ru +61 -0
  15. data/data/.htaccess +2 -0
  16. data/doc/HOWTO-authenticate-in-rack.md +89 -0
  17. data/doc/HOWTO-make-io.md +305 -0
  18. data/doc/HOWTO-make-plugin.md +279 -0
  19. data/doc/HOWTO-make-theme.md +67 -0
  20. data/doc/HOWTO-testing-tDiary.md +44 -0
  21. data/doc/HOWTO-use-plugin.md +148 -0
  22. data/doc/HOWTO-write-tDiary.en.md +131 -0
  23. data/doc/HOWTO-write-tDiary.md +136 -0
  24. data/doc/INSTALL-paas.md +202 -0
  25. data/doc/INSTALL.md +160 -0
  26. data/doc/README.en.md +174 -0
  27. data/doc/README.md +56 -0
  28. data/doc/UPGRADE.md +164 -0
  29. data/doc/doc.css +115 -0
  30. data/dot.htaccess +27 -0
  31. data/index.fcgi +45 -0
  32. data/index.rb +57 -0
  33. data/js/00default.js +60 -0
  34. data/js/01conf.js +62 -0
  35. data/js/02edit.coffee +5 -0
  36. data/js/02edit.js +15 -0
  37. data/js/amazon.js +43 -0
  38. data/js/calendar3.js +130 -0
  39. data/js/caretposition.js +170 -0
  40. data/js/category.js +29 -0
  41. data/js/category_autocomplete.js +96 -0
  42. data/js/comment_ajax.js +27 -0
  43. data/js/draft.js +149 -0
  44. data/js/highlight.js +36 -0
  45. data/js/image.js +181 -0
  46. data/misc/convert2.rb +123 -0
  47. data/misc/filter/antispamservice.rb +101 -0
  48. data/misc/filter/limitdays.rb +40 -0
  49. data/misc/filter/linkcheck.rb +81 -0
  50. data/misc/filter/plugin/antispamservice.rb +82 -0
  51. data/misc/filter/plugin/en/antispamservice.rb +21 -0
  52. data/misc/filter/plugin/ja/antispamservice.rb +20 -0
  53. data/misc/lib/README +4 -0
  54. data/misc/lib/compatible.rb +1 -0
  55. data/misc/lib/fcgi_patch.rb +90 -0
  56. data/misc/migrate.rb +157 -0
  57. data/misc/paas/cloudfoundry/Gemfile +26 -0
  58. data/misc/paas/cloudfoundry/Gemfile.lock +85 -0
  59. data/misc/paas/heroku/Gemfile +22 -0
  60. data/misc/paas/heroku/Gemfile.lock +85 -0
  61. data/misc/paas/sqale/Gemfile +19 -0
  62. data/misc/paas/sqale/Gemfile.lock +85 -0
  63. data/misc/paas/sqale/Procfile +1 -0
  64. data/misc/paas/sqale/dot.env +1 -0
  65. data/misc/plugin/ChangeLog.DO_NOT_UPDATE +2333 -0
  66. data/misc/plugin/a.rb +211 -0
  67. data/misc/plugin/amazon.rb +403 -0
  68. data/misc/plugin/amazon/README.en +17 -0
  69. data/misc/plugin/amazon/README.ja +29 -0
  70. data/misc/plugin/amazon/amazonimg.rb +113 -0
  71. data/misc/plugin/amazon/large.png +0 -0
  72. data/misc/plugin/amazon/medium.png +0 -0
  73. data/misc/plugin/amazon/small.png +0 -0
  74. data/misc/plugin/append-css.rb +51 -0
  75. data/misc/plugin/bq.rb +48 -0
  76. data/misc/plugin/calendar2.rb +184 -0
  77. data/misc/plugin/calendar3.rb +256 -0
  78. data/misc/plugin/category.rb +779 -0
  79. data/misc/plugin/category_autocomplete.rb +33 -0
  80. data/misc/plugin/comment_ajax.rb +11 -0
  81. data/misc/plugin/comment_mail-qmail.rb +57 -0
  82. data/misc/plugin/comment_mail-sendmail.rb +56 -0
  83. data/misc/plugin/comment_mail-smtp.rb +59 -0
  84. data/misc/plugin/comment_rank.rb +36 -0
  85. data/misc/plugin/counter.rb +631 -0
  86. data/misc/plugin/daily_theme.rb +55 -0
  87. data/misc/plugin/disp_referrer.rb +1486 -0
  88. data/misc/plugin/doctype-html401tr.rb +16 -0
  89. data/misc/plugin/draft.rb +20 -0
  90. data/misc/plugin/dropdown_calendar.rb +32 -0
  91. data/misc/plugin/edit_today.rb +50 -0
  92. data/misc/plugin/en/a.rb +10 -0
  93. data/misc/plugin/en/amazon.rb +71 -0
  94. data/misc/plugin/en/append-css.rb +17 -0
  95. data/misc/plugin/en/bq.rb +12 -0
  96. data/misc/plugin/en/calendar2.rb +12 -0
  97. data/misc/plugin/en/category.rb +204 -0
  98. data/misc/plugin/en/counter.rb +48 -0
  99. data/misc/plugin/en/daily_theme.rb +14 -0
  100. data/misc/plugin/en/disp_referrer.rb +387 -0
  101. data/misc/plugin/en/dropdown_calendar.rb +14 -0
  102. data/misc/plugin/en/edit_today.rb +22 -0
  103. data/misc/plugin/en/hide-mail-field.rb +19 -0
  104. data/misc/plugin/en/highlight.rb +29 -0
  105. data/misc/plugin/en/image.rb +54 -0
  106. data/misc/plugin/en/kw.rb +22 -0
  107. data/misc/plugin/en/makerss.rb +47 -0
  108. data/misc/plugin/en/pb-show.rb +21 -0
  109. data/misc/plugin/en/ping.rb +16 -0
  110. data/misc/plugin/en/recent_comment.rb +44 -0
  111. data/misc/plugin/en/recent_comment3.rb +56 -0
  112. data/misc/plugin/en/recent_rss.rb +33 -0
  113. data/misc/plugin/en/referer_scheme.rb +48 -0
  114. data/misc/plugin/en/search_control.rb +74 -0
  115. data/misc/plugin/en/search_form.rb +22 -0
  116. data/misc/plugin/en/speed_comment.rb +19 -0
  117. data/misc/plugin/en/tb-show.rb +37 -0
  118. data/misc/plugin/en/todo.rb +43 -0
  119. data/misc/plugin/en/weather.rb +185 -0
  120. data/misc/plugin/en/xmlrpc.rb +14 -0
  121. data/misc/plugin/footnote.rb +92 -0
  122. data/misc/plugin/gradation.rb +39 -0
  123. data/misc/plugin/gradient.rb +36 -0
  124. data/misc/plugin/hide-mail-field.rb +50 -0
  125. data/misc/plugin/highlight.rb +22 -0
  126. data/misc/plugin/html_anchor.rb +34 -0
  127. data/misc/plugin/image.rb +290 -0
  128. data/misc/plugin/ja/amazon.rb +89 -0
  129. data/misc/plugin/ja/bq.rb +13 -0
  130. data/misc/plugin/ja/calendar2.rb +12 -0
  131. data/misc/plugin/ja/category.rb +212 -0
  132. data/misc/plugin/ja/daily_theme.rb +15 -0
  133. data/misc/plugin/ja/disp_referrer.rb +644 -0
  134. data/misc/plugin/ja/edit_today.rb +23 -0
  135. data/misc/plugin/ja/hide-mail-field.rb +20 -0
  136. data/misc/plugin/ja/highlight.rb +30 -0
  137. data/misc/plugin/ja/makerss.rb +44 -0
  138. data/misc/plugin/ja/my-sequel.rb +52 -0
  139. data/misc/plugin/ja/pb-show.rb +23 -0
  140. data/misc/plugin/ja/ping.rb +17 -0
  141. data/misc/plugin/ja/recent_comment.rb +45 -0
  142. data/misc/plugin/ja/recent_comment3.rb +57 -0
  143. data/misc/plugin/ja/recent_rss.rb +34 -0
  144. data/misc/plugin/ja/referer_scheme.rb +86 -0
  145. data/misc/plugin/ja/search_control.rb +75 -0
  146. data/misc/plugin/ja/search_form.rb +32 -0
  147. data/misc/plugin/ja/tb-show.rb +38 -0
  148. data/misc/plugin/ja/todo.rb +46 -0
  149. data/misc/plugin/ja/weather.rb +402 -0
  150. data/misc/plugin/ja/xmlrpc.rb +15 -0
  151. data/misc/plugin/kw.rb +150 -0
  152. data/misc/plugin/list.rb +40 -0
  153. data/misc/plugin/makelirs.rb +89 -0
  154. data/misc/plugin/makerss.rb +744 -0
  155. data/misc/plugin/my-ex.rb +68 -0
  156. data/misc/plugin/my-sequel.rb +539 -0
  157. data/misc/plugin/navi_user.rb +19 -0
  158. data/misc/plugin/number_anchor.rb +47 -0
  159. data/misc/plugin/pb-show.rb +165 -0
  160. data/misc/plugin/ping.rb +99 -0
  161. data/misc/plugin/pre_wrap.rb +19 -0
  162. data/misc/plugin/random_google.rb +165 -0
  163. data/misc/plugin/recent_comment.rb +82 -0
  164. data/misc/plugin/recent_comment3.rb +192 -0
  165. data/misc/plugin/recent_list.rb +91 -0
  166. data/misc/plugin/recent_namazu.rb +50 -0
  167. data/misc/plugin/recent_rss.rb +305 -0
  168. data/misc/plugin/referer-antibot.rb +53 -0
  169. data/misc/plugin/referer-utf8.rb +12 -0
  170. data/misc/plugin/referer_scheme.rb +87 -0
  171. data/misc/plugin/search_control.rb +227 -0
  172. data/misc/plugin/search_form.rb +53 -0
  173. data/misc/plugin/sn.rb +107 -0
  174. data/misc/plugin/speed_comment.rb +68 -0
  175. data/misc/plugin/squeeze.rb +272 -0
  176. data/misc/plugin/src.rb +30 -0
  177. data/misc/plugin/tb-show.rb +212 -0
  178. data/misc/plugin/title_list.rb +41 -0
  179. data/misc/plugin/title_tag.rb +80 -0
  180. data/misc/plugin/tlink.rb +163 -0
  181. data/misc/plugin/todo.rb +182 -0
  182. data/misc/plugin/weather.rb +505 -0
  183. data/misc/plugin/whatsnew.rb +100 -0
  184. data/misc/plugin/xmlrpc.rb +80 -0
  185. data/misc/plugin/xmlrpc/README +20 -0
  186. data/misc/plugin/xmlrpc/xmlrpc.rb +575 -0
  187. data/misc/style/emptdiary/README.rd +83 -0
  188. data/misc/style/emptdiary/README.rd.en +78 -0
  189. data/misc/style/emptdiary/emptdiary_style.rb +199 -0
  190. data/misc/style/etdiary/README.rd +83 -0
  191. data/misc/style/etdiary/etdiary_style.rb +446 -0
  192. data/misc/style/gfm/gfm_style.rb +194 -0
  193. data/misc/style/rd/README.rd +71 -0
  194. data/misc/style/rd/rd_style.rb +366 -0
  195. data/misc/style/wiki/README +116 -0
  196. data/misc/style/wiki/README.en +101 -0
  197. data/misc/style/wiki/wiki_parser.rb +273 -0
  198. data/misc/style/wiki/wiki_style.rb +478 -0
  199. data/misc/theme_convert/Readme.rd +21 -0
  200. data/misc/theme_convert/append.rcss +150 -0
  201. data/misc/theme_convert/theme_convert.rb +453 -0
  202. data/plugin/00default.rb +1015 -0
  203. data/plugin/05referer.rb +298 -0
  204. data/plugin/10spamfilter.rb +183 -0
  205. data/plugin/50sp.rb +146 -0
  206. data/plugin/60sf.rb +152 -0
  207. data/plugin/90migrate.rb +109 -0
  208. data/plugin/en/00default.rb +390 -0
  209. data/plugin/en/05referer.rb +49 -0
  210. data/plugin/en/10spamfilter.rb +81 -0
  211. data/plugin/en/50sp.rb +56 -0
  212. data/plugin/en/60sf.rb +60 -0
  213. data/plugin/ja/00default.rb +401 -0
  214. data/plugin/ja/05referer.rb +47 -0
  215. data/plugin/ja/10spamfilter.rb +79 -0
  216. data/plugin/ja/50sp.rb +66 -0
  217. data/plugin/ja/60sf.rb +73 -0
  218. data/public/.gitkeep +0 -0
  219. data/public/images/.gitkeep +0 -0
  220. data/public/javascripts/.gitkeep +0 -0
  221. data/public/stylesheets/.gitkeep +0 -0
  222. data/skel/category.rhtml +9 -0
  223. data/skel/conf.rhtml +23 -0
  224. data/skel/day.rhtml +33 -0
  225. data/skel/diary.rhtml +83 -0
  226. data/skel/footer.rhtml +8 -0
  227. data/skel/header.rhtml +10 -0
  228. data/skel/i.category.rhtml +6 -0
  229. data/skel/i.conf.rhtml +14 -0
  230. data/skel/i.day.rhtml +28 -0
  231. data/skel/i.diary.rhtml +17 -0
  232. data/skel/i.footer.rhtml +2 -0
  233. data/skel/i.header.rhtml +3 -0
  234. data/skel/i.latest.rhtml +24 -0
  235. data/skel/i.month.rhtml +39 -0
  236. data/skel/i.search.rhtml +5 -0
  237. data/skel/i.update.rhtml +40 -0
  238. data/skel/i.update.rhtml.en +40 -0
  239. data/skel/latest.rhtml +27 -0
  240. data/skel/mail.rtxt +18 -0
  241. data/skel/mail.rtxt.en +18 -0
  242. data/skel/month.rhtml +27 -0
  243. data/skel/plugin_error.rhtml +27 -0
  244. data/skel/preview.rhtml +85 -0
  245. data/skel/preview.rhtml.en +72 -0
  246. data/skel/referer.rhtml +24 -0
  247. data/skel/search.rhtml +14 -0
  248. data/skel/tdiary.rconf +76 -0
  249. data/skel/update.rhtml +103 -0
  250. data/skel/update.rhtml.en +83 -0
  251. data/spec/acceptance/append_comment_spec.rb +94 -0
  252. data/spec/acceptance/append_diary_spec.rb +98 -0
  253. data/spec/acceptance/bugfix/encoding_error_spec.rb +27 -0
  254. data/spec/acceptance/save_conf_comment_spec.rb +87 -0
  255. data/spec/acceptance/save_conf_default_spec.rb +169 -0
  256. data/spec/acceptance/save_conf_dnsbl_spec.rb +152 -0
  257. data/spec/acceptance/save_conf_filter_spec.rb +50 -0
  258. data/spec/acceptance/save_conf_plugin_spec.rb +69 -0
  259. data/spec/acceptance/save_conf_referer_spec.rb +60 -0
  260. data/spec/acceptance/save_conf_security_spec.rb +280 -0
  261. data/spec/acceptance/support/helpers.rb +49 -0
  262. data/spec/acceptance/support/paths.rb +7 -0
  263. data/spec/acceptance/update_diary_spec.rb +113 -0
  264. data/spec/acceptance/view_category_spec.rb +38 -0
  265. data/spec/acceptance/view_comment_spec.rb +67 -0
  266. data/spec/acceptance/view_diary_spec.rb +126 -0
  267. data/spec/acceptance/view_referer_spec.rb +31 -0
  268. data/spec/acceptance_helper.rb +101 -0
  269. data/spec/core/compatible_spec.rb +54 -0
  270. data/spec/core/core_ext_spec.rb +59 -0
  271. data/spec/core/plugin_spec.rb +389 -0
  272. data/spec/core/rack/assets/precompile_spec.rb +76 -0
  273. data/spec/core/rack/html_anchor_spec.rb +57 -0
  274. data/spec/core/rack/valid_request_path_spec.rb +67 -0
  275. data/spec/core/style/emptdiary_style_spec.rb +165 -0
  276. data/spec/core/style/etdiary_style_spec.rb +512 -0
  277. data/spec/core/style/gfm_style_spec.rb +334 -0
  278. data/spec/core/style/rd_style_spec.rb +202 -0
  279. data/spec/core/style/tdiary_style_spec.rb +240 -0
  280. data/spec/core/style/wiki_style_spec.rb +441 -0
  281. data/spec/fixtures/ascii8bit-pstore.db +0 -0
  282. data/spec/fixtures/invalid-sequence-volatile.tdr +9 -0
  283. data/spec/fixtures/just_installed.conf +1 -0
  284. data/spec/fixtures/plugin/ja/sample.rb +4 -0
  285. data/spec/fixtures/plugin/sample.rb +6 -0
  286. data/spec/fixtures/sample.rb +12 -0
  287. data/spec/fixtures/tdiary.conf.gem +212 -0
  288. data/spec/fixtures/tdiary.conf.rack +212 -0
  289. data/spec/fixtures/tdiary.conf.rdb +227 -0
  290. data/spec/fixtures/tdiary.conf.secure +204 -0
  291. data/spec/fixtures/tdiary.conf.webrick +212 -0
  292. data/spec/javascripts/00default_spec.js +35 -0
  293. data/spec/javascripts/fixtures/00default.html +1 -0
  294. data/spec/javascripts/support/jasmine.yml +76 -0
  295. data/spec/plugin/bq_spec.rb +24 -0
  296. data/spec/plugin/plugin_helper.rb +203 -0
  297. data/spec/spec_helper.rb +32 -0
  298. data/tdiary.conf.beginner +244 -0
  299. data/tdiary.conf.sample +345 -0
  300. data/tdiary.conf.sample-en +333 -0
  301. data/tdiary.gemspec +26 -0
  302. data/tdiary.rb +151 -0
  303. data/tdiary/admin.rb +236 -0
  304. data/tdiary/application.rb +57 -0
  305. data/tdiary/author_only_base.rb +171 -0
  306. data/tdiary/base.rb +220 -0
  307. data/tdiary/cli.rb +116 -0
  308. data/tdiary/comment.rb +40 -0
  309. data/tdiary/comment_manager.rb +94 -0
  310. data/tdiary/compatible.rb +72 -0
  311. data/tdiary/config.rb +270 -0
  312. data/tdiary/core_ext.rb +122 -0
  313. data/tdiary/deploy.rb +50 -0
  314. data/tdiary/dispatcher.rb +77 -0
  315. data/tdiary/dispatcher/index_main.rb +122 -0
  316. data/tdiary/dispatcher/update_main.rb +101 -0
  317. data/tdiary/environment.rb +15 -0
  318. data/tdiary/filter.rb +48 -0
  319. data/tdiary/filter/default.rb +54 -0
  320. data/tdiary/filter/spam.rb +304 -0
  321. data/tdiary/io/base.rb +70 -0
  322. data/tdiary/io/cache/file.rb +123 -0
  323. data/tdiary/io/cache/memcached.rb +88 -0
  324. data/tdiary/io/cache/redis.rb +100 -0
  325. data/tdiary/io/default.rb +297 -0
  326. data/tdiary/io/pstore.rb +252 -0
  327. data/tdiary/io/rdb.rb +213 -0
  328. data/tdiary/lang/en.rb +79 -0
  329. data/tdiary/lang/ja.rb +72 -0
  330. data/tdiary/plugin.rb +375 -0
  331. data/tdiary/rack/assets/precompile.rb +37 -0
  332. data/tdiary/rack/auth/basic.rb +38 -0
  333. data/tdiary/rack/auth/omniauth.rb +51 -0
  334. data/tdiary/rack/html_anchor.rb +31 -0
  335. data/tdiary/rack/valid_request_path.rb +36 -0
  336. data/tdiary/referer_manager.rb +80 -0
  337. data/tdiary/request.rb +217 -0
  338. data/tdiary/response.rb +29 -0
  339. data/tdiary/server.rb +85 -0
  340. data/tdiary/style.rb +194 -0
  341. data/tdiary/style/tdiary_style.rb +198 -0
  342. data/tdiary/style/wiki_style.rb +213 -0
  343. data/tdiary/tasks.rb +1 -0
  344. data/tdiary/tasks/assets.rake +31 -0
  345. data/tdiary/tasks/auth.rake +28 -0
  346. data/tdiary/tasks/db.rake +110 -0
  347. data/tdiary/tasks/doc.rake +31 -0
  348. data/tdiary/tasks/heroku.rake +37 -0
  349. data/tdiary/tasks/jasmine.rake +16 -0
  350. data/tdiary/tasks/rdoc.rake +24 -0
  351. data/tdiary/tasks/release.rake +122 -0
  352. data/tdiary/tasks/rspec.rake +51 -0
  353. data/tdiary/tasks/server.rake +33 -0
  354. data/tdiary/tasks/test.rake +17 -0
  355. data/tdiary/version.rb +3 -0
  356. data/tdiary/view.rb +468 -0
  357. data/tdiary/view_helper.rb +15 -0
  358. data/test/disp_referrer_test.rb +93 -0
  359. data/test/my-sequel_test.rb +238 -0
  360. data/test/test_helper.rb +7 -0
  361. data/test/test_plugin_helper.rb +64 -0
  362. data/test/test_plugin_helper_test.rb +28 -0
  363. data/test/weather_test.rb +33 -0
  364. data/theme/base.css +268 -0
  365. data/theme/conf.block.png +0 -0
  366. data/theme/conf.css +254 -0
  367. data/theme/default/README +11 -0
  368. data/theme/default/body.png +0 -0
  369. data/theme/default/default.css +743 -0
  370. data/theme/help.png +0 -0
  371. data/theme/loading.gif +0 -0
  372. data/theme/tdiary1/README +7 -0
  373. data/theme/tdiary1/tdiary1.css +394 -0
  374. data/theme/tdiary2/README +19 -0
  375. data/theme/tdiary2/tdiary2.css +624 -0
  376. data/update.fcgi +45 -0
  377. data/update.rb +57 -0
  378. data/vendor/hikidoc-0.0.6/COPYING +28 -0
  379. data/vendor/hikidoc-0.0.6/NEWS +30 -0
  380. data/vendor/hikidoc-0.0.6/NEWS.ja +30 -0
  381. data/vendor/hikidoc-0.0.6/README +86 -0
  382. data/vendor/hikidoc-0.0.6/README.ja +83 -0
  383. data/vendor/hikidoc-0.0.6/Rakefile +68 -0
  384. data/vendor/hikidoc-0.0.6/TextFormattingRules +320 -0
  385. data/vendor/hikidoc-0.0.6/TextFormattingRules.ja +318 -0
  386. data/vendor/hikidoc-0.0.6/bin/hikidoc +66 -0
  387. data/vendor/hikidoc-0.0.6/lib/hikidoc.rb +914 -0
  388. data/vendor/hikidoc-0.0.6/setup.rb +1360 -0
  389. data/vendor/hikidoc-0.0.6/test/run-test.rb +13 -0
  390. data/vendor/hikidoc-0.0.6/test/test_hikidoc.rb +506 -0
  391. data/vendor/imagesize-0.1.1/Manifest.txt +19 -0
  392. data/vendor/imagesize-0.1.1/README.txt +49 -0
  393. data/vendor/imagesize-0.1.1/lib/image_size.rb +305 -0
  394. data/vendor/imagesize-0.1.1/lib/image_size/version.rb +9 -0
  395. data/vendor/imagesize-0.1.1/setup.rb +1585 -0
  396. data/vendor/imagesize-0.1.1/test/2-4-7.png +0 -0
  397. data/vendor/imagesize-0.1.1/test/4_1_2.gif +0 -0
  398. data/vendor/imagesize-0.1.1/test/bmp.bmp +0 -0
  399. data/vendor/imagesize-0.1.1/test/cursor.xbm +6 -0
  400. data/vendor/imagesize-0.1.1/test/detect.swf +0 -0
  401. data/vendor/imagesize-0.1.1/test/pbm.pbm +0 -0
  402. data/vendor/imagesize-0.1.1/test/pcx.pcx +0 -0
  403. data/vendor/imagesize-0.1.1/test/pgm.pgm +5 -0
  404. data/vendor/imagesize-0.1.1/test/test.xpm +38 -0
  405. data/vendor/imagesize-0.1.1/test/test_helper.rb +2 -0
  406. data/vendor/imagesize-0.1.1/test/test_image_size.rb +71 -0
  407. data/vendor/imagesize-0.1.1/test/tiff.tiff +0 -0
  408. data/vendor/imagesize-0.1.1/test/tokyo_tower.jpg +0 -0
  409. data/vendor/imagesize-0.1.1/test/tower_e.gif.psd +0 -0
  410. data/vendor/jasmine-jquery-1.4.2/jasmine-jquery.js +548 -0
  411. data/vendor/jquery-1.8/jquery.js +9227 -0
  412. data/vendor/rdtool-0.6.38/COPYING.txt +339 -0
  413. data/vendor/rdtool-0.6.38/Gemfile +3 -0
  414. data/vendor/rdtool-0.6.38/HISTORY +318 -0
  415. data/vendor/rdtool-0.6.38/LGPL-2.1 +502 -0
  416. data/vendor/rdtool-0.6.38/LICENSE.txt +58 -0
  417. data/vendor/rdtool-0.6.38/README.html +66 -0
  418. data/vendor/rdtool-0.6.38/README.ja.html +73 -0
  419. data/vendor/rdtool-0.6.38/README.rd +76 -0
  420. data/vendor/rdtool-0.6.38/README.rd.ja +85 -0
  421. data/vendor/rdtool-0.6.38/Rakefile +152 -0
  422. data/vendor/rdtool-0.6.38/TODO +22 -0
  423. data/vendor/rdtool-0.6.38/bin/rd2 +283 -0
  424. data/vendor/rdtool-0.6.38/bin/rdswap.rb +207 -0
  425. data/vendor/rdtool-0.6.38/doc/rd-draft.html +456 -0
  426. data/vendor/rdtool-0.6.38/doc/rd-draft.ja.html +466 -0
  427. data/vendor/rdtool-0.6.38/doc/rd-draft.rd +479 -0
  428. data/vendor/rdtool-0.6.38/doc/rd-draft.rd.ja +487 -0
  429. data/vendor/rdtool-0.6.38/lib/rd/block-element.rb +114 -0
  430. data/vendor/rdtool-0.6.38/lib/rd/complex-list-item.rb +65 -0
  431. data/vendor/rdtool-0.6.38/lib/rd/desclist.rb +55 -0
  432. data/vendor/rdtool-0.6.38/lib/rd/document-struct.rb +46 -0
  433. data/vendor/rdtool-0.6.38/lib/rd/dot.rd2rc +18 -0
  434. data/vendor/rdtool-0.6.38/lib/rd/element.rb +160 -0
  435. data/vendor/rdtool-0.6.38/lib/rd/filter.rb +255 -0
  436. data/vendor/rdtool-0.6.38/lib/rd/head-filter.rb +14 -0
  437. data/vendor/rdtool-0.6.38/lib/rd/inline-element.rb +233 -0
  438. data/vendor/rdtool-0.6.38/lib/rd/labeled-element.rb +14 -0
  439. data/vendor/rdtool-0.6.38/lib/rd/list.rb +57 -0
  440. data/vendor/rdtool-0.6.38/lib/rd/loose-struct.rb +11 -0
  441. data/vendor/rdtool-0.6.38/lib/rd/methodlist.rb +57 -0
  442. data/vendor/rdtool-0.6.38/lib/rd/output-format-visitor.rb +30 -0
  443. data/vendor/rdtool-0.6.38/lib/rd/package.rb +4 -0
  444. data/vendor/rdtool-0.6.38/lib/rd/parser-util.rb +14 -0
  445. data/vendor/rdtool-0.6.38/lib/rd/post-install +1 -0
  446. data/vendor/rdtool-0.6.38/lib/rd/pre-setup.rb +18 -0
  447. data/vendor/rdtool-0.6.38/lib/rd/rbl-file.rb +69 -0
  448. data/vendor/rdtool-0.6.38/lib/rd/rbl-suite.rb +37 -0
  449. data/vendor/rdtool-0.6.38/lib/rd/rd-struct.rb +86 -0
  450. data/vendor/rdtool-0.6.38/lib/rd/rd2html-ext-lib.rb +266 -0
  451. data/vendor/rdtool-0.6.38/lib/rd/rd2html-ext-opt.rb +34 -0
  452. data/vendor/rdtool-0.6.38/lib/rd/rd2html-lib.rb +490 -0
  453. data/vendor/rdtool-0.6.38/lib/rd/rd2html-opt.rb +67 -0
  454. data/vendor/rdtool-0.6.38/lib/rd/rd2man-lib.rb +251 -0
  455. data/vendor/rdtool-0.6.38/lib/rd/rd2rdo-lib.rb +19 -0
  456. data/vendor/rdtool-0.6.38/lib/rd/rd2rmi-lib.rb +32 -0
  457. data/vendor/rdtool-0.6.38/lib/rd/rdblockparser.ry +518 -0
  458. data/vendor/rdtool-0.6.38/lib/rd/rdblockparser.tab.rb +1061 -0
  459. data/vendor/rdtool-0.6.38/lib/rd/rdfmt.rb +15 -0
  460. data/vendor/rdtool-0.6.38/lib/rd/rdinlineparser.ry +503 -0
  461. data/vendor/rdtool-0.6.38/lib/rd/rdinlineparser.tab.rb +1243 -0
  462. data/vendor/rdtool-0.6.38/lib/rd/rdvisitor.rb +214 -0
  463. data/vendor/rdtool-0.6.38/lib/rd/reference-resolver.rb +114 -0
  464. data/vendor/rdtool-0.6.38/lib/rd/search-file.rb +14 -0
  465. data/vendor/rdtool-0.6.38/lib/rd/tree.rb +103 -0
  466. data/vendor/rdtool-0.6.38/lib/rd/version.rb +41 -0
  467. data/vendor/rdtool-0.6.38/lib/rd/visitor.rb +86 -0
  468. data/vendor/rdtool-0.6.38/rdtool.gemspec +125 -0
  469. data/vendor/rdtool-0.6.38/setup.rb +1596 -0
  470. data/vendor/rdtool-0.6.38/test/data/includee1.html +1 -0
  471. data/vendor/rdtool-0.6.38/test/data/includee2.html +1 -0
  472. data/vendor/rdtool-0.6.38/test/data/includee3.nothtml +1 -0
  473. data/vendor/rdtool-0.6.38/test/data/includee4.xhtml +0 -0
  474. data/vendor/rdtool-0.6.38/test/data/label.rbl +2 -0
  475. data/vendor/rdtool-0.6.38/test/data/label2.rbl +2 -0
  476. data/vendor/rdtool-0.6.38/test/data/sub/includee2.html +1 -0
  477. data/vendor/rdtool-0.6.38/test/data/sub/includee4.html +0 -0
  478. data/vendor/rdtool-0.6.38/test/dummy-observer.rb +6 -0
  479. data/vendor/rdtool-0.6.38/test/dummy.rb +33 -0
  480. data/vendor/rdtool-0.6.38/test/temp-dir.rb +19 -0
  481. data/vendor/rdtool-0.6.38/test/test-block-parser.rb +46 -0
  482. data/vendor/rdtool-0.6.38/test/test-desclist-item.rb +219 -0
  483. data/vendor/rdtool-0.6.38/test/test-document-element.rb +46 -0
  484. data/vendor/rdtool-0.6.38/test/test-document-struct.rb +66 -0
  485. data/vendor/rdtool-0.6.38/test/test-element.rb +46 -0
  486. data/vendor/rdtool-0.6.38/test/test-headline.rb +80 -0
  487. data/vendor/rdtool-0.6.38/test/test-inline-parser.rb +46 -0
  488. data/vendor/rdtool-0.6.38/test/test-list-item.rb +54 -0
  489. data/vendor/rdtool-0.6.38/test/test-list.rb +53 -0
  490. data/vendor/rdtool-0.6.38/test/test-methodlist-item.rb +73 -0
  491. data/vendor/rdtool-0.6.38/test/test-nonterminal-element.rb +170 -0
  492. data/vendor/rdtool-0.6.38/test/test-nonterminal-inline.rb +33 -0
  493. data/vendor/rdtool-0.6.38/test/test-output-format-visitor.rb +48 -0
  494. data/vendor/rdtool-0.6.38/test/test-parser-util.rb +41 -0
  495. data/vendor/rdtool-0.6.38/test/test-rbl-file.rb +156 -0
  496. data/vendor/rdtool-0.6.38/test/test-rbl-suite.rb +43 -0
  497. data/vendor/rdtool-0.6.38/test/test-rd2html-lib.rb +496 -0
  498. data/vendor/rdtool-0.6.38/test/test-rdtree.rb +17 -0
  499. data/vendor/rdtool-0.6.38/test/test-rdvisitor.rb +29 -0
  500. data/vendor/rdtool-0.6.38/test/test-reference-resolver.rb +202 -0
  501. data/vendor/rdtool-0.6.38/test/test-reference.rb +132 -0
  502. data/vendor/rdtool-0.6.38/test/test-search-file.rb +22 -0
  503. data/vendor/rdtool-0.6.38/test/test-terminal-inline.rb +41 -0
  504. data/vendor/rdtool-0.6.38/test/test-textblock.rb +44 -0
  505. data/vendor/rdtool-0.6.38/test/test-tree.rb +82 -0
  506. data/vendor/rdtool-0.6.38/test/test-version.rb +57 -0
  507. data/vendor/rdtool-0.6.38/test/test-visitor.rb +230 -0
  508. data/vendor/rdtool-0.6.38/utils/rd-mode.el +464 -0
  509. metadata +666 -0
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ def label_xmlrpc_url; 'XML-RPC API 設置先URL'; end
3
+ def label_xmlrpc_blogid; 'Blog ID'; end
4
+ def label_xmlrpc_username; 'ユーザ名'; end
5
+ def label_xmlrpc_password; 'パスワード'; end
6
+ def label_xmlrpc_lastname; '名'; end
7
+ def label_xmlrpc_firstname; '姓'; end
8
+ def label_xmlrpc_userid; 'ユーザID'; end
9
+
10
+ # Local Variables:
11
+ # mode: ruby
12
+ # indent-tabs-mode: t
13
+ # tab-width: 3
14
+ # ruby-indent-level: 3
15
+ # End:
data/misc/plugin/kw.rb ADDED
@@ -0,0 +1,150 @@
1
+ # -*- coding: utf-8 -*-
2
+ # kw.rb
3
+ #
4
+ # kw: keyword link generator
5
+ # Parameters:
6
+ # keyword: keyword or InterWikiName (separated by ':').
7
+ # name: anchor string (optional).
8
+ # title: title attribute (optional).
9
+ #
10
+ # @options['kw.dic']
11
+ # array of dictionary table array. an item of array is:
12
+ #
13
+ # [key, URL, style]
14
+ #
15
+ # key: nil or string of key.
16
+ # If keyword is 'foo', it has key nil.
17
+ # If keyword is 'google:foo', it has key 'google'.
18
+ # URL: the URL for link. '$1' is replace by keyword.
19
+ # style: encoding style as: 'euc-jp', 'sjis', 'jis', 'utf-8' or nil.
20
+ #
21
+ # if there isn't @options['kw.dic'], the plugin links to google.
22
+ #
23
+ # @options['kw.show_inter']
24
+ # Show InterWikiName.
25
+ # If this options is true, the keyword 'google:foo' shows 'google:foo'.
26
+ # But it is false, that shows only 'foo'.
27
+ # The default of this option is true.
28
+ #
29
+ # Copyright (C) 2003, TADA Tadashi <sho@spc.gr.jp>
30
+ # You can distribute this under GPL.
31
+ #
32
+
33
+ unless String.method_defined?(:encode)
34
+ require 'nkf'
35
+ end
36
+
37
+ def kw_parse( str )
38
+ kw_list = []
39
+ str.each_line do |pair|
40
+ k, u, s = pair.sub( /[\r\n]+/, '' ).split( /[ \t]+/, 3 )
41
+ k = nil if k == '' or k == 'nil'
42
+ s = nil if s != 'euc-jp' && s != 'sjis' && s != 'jis' && s != 'utf-8'
43
+ kw_list << [k, u, s] if u
44
+ end
45
+ kw_list
46
+ end
47
+
48
+ def kw_generate_dic
49
+ kw_dic = {nil => ['http://www.google.com/search?ie=utf-8&q=$1', 'utf-8']}
50
+
51
+ kw_list = []
52
+ case @conf['kw.dic'].class.to_s
53
+ when "String"
54
+ kw_list = kw_parse( @conf['kw.dic'] )
55
+ when "Array"
56
+ kw_list = @conf['kw.dic']
57
+ end
58
+ kw_list.each do |pair|
59
+ kw_dic[pair[0]] = pair[1..-1]
60
+ end
61
+ kw_dic
62
+ end
63
+
64
+ def kw( keyword, name = nil, title = nil )
65
+ @kw_dic = kw_generate_dic unless @kw_dic
66
+ show_inter = @options['kw.show_inter'] == nil ? true : @options['kw.show_inter']
67
+
68
+ inter, key = keyword.split( /:/, 2 )
69
+ unless key then
70
+ inter = nil
71
+ key = keyword
72
+ end
73
+ keyword = key unless show_inter
74
+ name = keyword unless name
75
+ title = title ? %Q[ title="#{h title}"] : ''
76
+
77
+ unless @kw_dic.has_key?(inter)
78
+ inter = nil
79
+ end
80
+ style = @kw_dic[inter][1]
81
+ if String.method_defined?(:encode)
82
+ if style
83
+ key = key.encode({'jis'=>'ISO-2022-JP', 'sjis'=>'Shift_JIS'}[style] || style)
84
+ end
85
+ else
86
+ key = case style
87
+ when 'euc-jp'
88
+ NKF::nkf( '-m0 -W -e', key )
89
+ when 'sjis'
90
+ NKF::nkf( '-m0 -W -s', key )
91
+ when 'jis'
92
+ NKF::nkf( '-m0 -W -j', key )
93
+ when 'utf-8'
94
+ key
95
+ else # none
96
+ key
97
+ end
98
+ end
99
+ %Q[<a href="#{h @kw_dic[inter][0].sub( /\$1/, u( key ))}"#{title}>#{h name}</a>]
100
+ end
101
+
102
+ #
103
+ # config
104
+ #
105
+ unless @resource_loaded then
106
+ def kw_label
107
+ "キーワード"
108
+ end
109
+
110
+ def kw_desc
111
+ <<-HTML
112
+ <h3>リンクリストの指定</h3>
113
+ <p>特定のサイトへのリンクを、簡単な記述で生成するためのプラグイン(kw)です。
114
+ 「キー URL エンコードスタイル」と空白で区切って指定します。例えば、</p>
115
+ <pre>google http://www.google.com/search?ie=utf-8&amp;q=$1 utf-8</pre>
116
+ <p>と指定すると、</p>
117
+ <pre>&lt;%=kw('google:tdiary')%&gt;</pre>
118
+ <p>のように日記に書けばgoogleでtdiaryを検索するリンクになります
119
+ (記述方法はスタイルによって変わります)。なお、キーにnilを指定すると、
120
+ 「google:」の部分を書かない場合の指定ができます。</p>
121
+ HTML
122
+ end
123
+ end
124
+
125
+ add_conf_proc( 'kw', kw_label ) do
126
+ if @mode == 'saveconf' then
127
+ kw_list = kw_parse( @conf.to_native( @cgi.params['kw.dic'][0] ) )
128
+ if kw_list.empty? then
129
+ @conf.delete( 'kw.dic' )
130
+ else
131
+ @conf['kw.dic'] = kw_list.collect{|a|a.join( ' ' )}.join( "\n" )
132
+ end
133
+ end
134
+ dic = kw_generate_dic
135
+ if dic[nil] then
136
+ dic['nil'] = dic[nil]
137
+ dic.delete( nil )
138
+ end
139
+ <<-HTML
140
+ #{kw_desc}
141
+ <p><textarea name="kw.dic" cols="60" rows="10">#{h dic.collect{|a|a.flatten.join( " " )}.join( "\n" )}</textarea></p>
142
+ HTML
143
+ end
144
+
145
+ # Local Variables:
146
+ # mode: ruby
147
+ # indent-tabs-mode: t
148
+ # tab-width: 3
149
+ # ruby-indent-level: 3
150
+ # End:
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ # list.rb
3
+ #
4
+ # <ol> 順番付きリスト生成
5
+ # <%= ol l %>
6
+ # パラメタ:
7
+ # l: リスト文字列(\nくぎり)
8
+ #
9
+ # <ul> 順番無しリスト
10
+ # <%= ul l , t %>
11
+ # パラメタ:
12
+ # l: リスト文字列(\nくぎり)
13
+ #
14
+ # Copyright (c) 2002 abbey <inlet@cello.no-ip.org>
15
+ # Distributed under the GPL.
16
+ #
17
+
18
+ def ol( l, t = nil, s = nil )
19
+ apply_plugin( %Q[<ol>#{li l}</ol>] )
20
+ end
21
+
22
+ def ul( l, t = nil)
23
+ apply_plugin( %Q[<ul>#{li l}</ul>] )
24
+ end
25
+
26
+ def li( text )
27
+ list = ""
28
+ text.each_line do |line|
29
+ list << ("<li>" + line.chomp + "</li>")
30
+ end
31
+ result = list
32
+ end
33
+
34
+
35
+ # Local Variables:
36
+ # mode: ruby
37
+ # indent-tabs-mode: t
38
+ # tab-width: 3
39
+ # ruby-indent-level: 3
40
+ # End:
@@ -0,0 +1,89 @@
1
+ # -*- coding: utf-8 -*-
2
+ # makelirs.rb
3
+ #
4
+ # 更新情報をLIRSフォーマットのファイルに吐き出す
5
+ #
6
+ # pluginディレクトリに置くだけで動作します。
7
+ #
8
+ # tdiary.confにおいて、@options['makelirs.file']に
9
+ # ファイル名を指定すると、そのファイルを出力先の
10
+ # LIRSファイルとします。無指定時にはindex.rbと同じ
11
+ # パスにantenna.lirsというファイルになります。
12
+ # いずれも、Webサーバから書き込める権限が必要です。
13
+ #
14
+ # Copyright (C) 2002 by Kazuhiro NISHIYAMA
15
+ # You can redistribute it and/or modify it under GPL2.
16
+ #
17
+
18
+ add_header_proc do
19
+ <<-LINK
20
+ <!--link rel="alternate" type="application/x-lirs" title="lirs" href="#{File::basename( @options['makelirs.file'] || 'antenna.lirs' )}"-->
21
+ LINK
22
+ end
23
+
24
+
25
+ add_update_proc do
26
+ eval( <<-MODIFY_CLASS, TOPLEVEL_BINDING )
27
+ unless Time.method_defined?(:utc_offset)
28
+ class Time
29
+ def utc_offset
30
+ l = self.dup.localtime
31
+ u = self.dup.utc
32
+
33
+ if l.year != u.year
34
+ off = l.year < u.year ? -1 : 1
35
+ elsif l.mon != u.mon
36
+ off = l.mon < u.mon ? -1 : 1
37
+ elsif l.mday != u.mday
38
+ off = l.mday < u.mday ? -1 : 1
39
+ else
40
+ off = 0
41
+ end
42
+
43
+ off = off * 24 + l.hour - u.hour
44
+ off = off * 60 + l.min - u.min
45
+ off = off * 60 + l.sec - u.sec
46
+
47
+ return off
48
+ end
49
+ end
50
+ end
51
+ MODIFY_CLASS
52
+
53
+ file = @options['makelirs.file'] || 'antenna.lirs'
54
+
55
+ # create_lirs
56
+ cgi = @cgi.clone
57
+ conf = @conf.clone
58
+ def cgi.mobile_agent?; false; end
59
+ def cgi.mobile_agent?; false; end
60
+
61
+ t = TDiaryLatest::new( cgi, "latest.rhtml", conf )
62
+ body = t.eval_rhtml
63
+ # escape comma
64
+ e = proc{|str| str.gsub(/[,\\]/){ "\\#{$&}" }.gsub( /[\r\n]/, '' ) }
65
+
66
+ now = Time.now
67
+ utc_offset = now.utc_offset
68
+
69
+ uri = @index.dup
70
+ uri[0, 0] = base_url if %r|^https?://|i !~ @index
71
+ uri.gsub!( %r|/\./|, '/' )
72
+
73
+ lirs = "LIRS,#{t.last_modified.tv_sec},#{Time.now.tv_sec},#{utc_offset},#{body.size},#{e[uri]},#{e[@html_title]},#{e[@author_name]},,\n"
74
+ File::open( file, 'w' ) do |o|
75
+ o.puts lirs
76
+ end
77
+ begin
78
+ File::utime( t.last_modified.tv_sec, t.last_modified.tv_sec, file )
79
+ rescue
80
+ end
81
+ end
82
+
83
+
84
+ # Local Variables:
85
+ # mode: ruby
86
+ # indent-tabs-mode: t
87
+ # tab-width: 3
88
+ # ruby-indent-level: 3
89
+ # End:
@@ -0,0 +1,744 @@
1
+ # makerss.rb
2
+ #
3
+ # generate RSS file when updating.
4
+ #
5
+ # options configurable through settings:
6
+ # @conf['makerss.hidecontent'] : hide full-text content. default: false
7
+ # @conf['makerss.shortdesc'] : shorter description. default: false
8
+ # @conf['makerss.comment_link'] : insert tsukkomi's link. default: false
9
+ #
10
+ # options to be edited in tdiary.conf:
11
+ # @conf['makerss.file'] : local file name of RSS file. default: 'index.rdf'.
12
+ # @conf['makerss.url'] : URL of RSS file.
13
+ # @conf['makerss.no_comments.file'] : local file name of RSS file without
14
+ # comments. default: 'no_comments.rdf'.
15
+ # @conf['makerss.no_comments.url'] : URL of RSS file without TSUKOMI.
16
+ # @conf.banner : URL of site banner image (can be relative)
17
+ # @conf.description : desciption of the diary
18
+ # @conf['makerss.partial'] : how much portion of body to be in description
19
+ # used when makerss.shortdesc, default: 0.25
20
+ # @conf['makerss.suffix'] : strings which are appended to the title tag.
21
+ # @conf['makerss.no_comments.suffix'] : strings which are appended to
22
+ # the title tag of the commentless rdf.
23
+ #
24
+ # CAUTION: Before using, make 'index.rdf' and 'no_comments.rdf' file
25
+ # into the directory of your diary, and permit writable to httpd.
26
+ #
27
+ # Copyright (c) 2009 TADA Tadashi <t@tdtds.jp>
28
+ # Distributed under the GPL
29
+ #
30
+
31
+ if /^append|replace|comment|showcomment$/ =~ @mode then
32
+ unless @conf.description
33
+ @conf.description = @conf['whatsnew_list.rdf.description']
34
+ end
35
+ module ::TDiary
36
+ class RDFSection
37
+ attr_reader :id, :time, :section, :diary_title
38
+
39
+ # 'id' has 'YYYYMMDDpNN' format (p or c).
40
+ # 'time' is Last-Modified this section as a Time object.
41
+ def initialize( id, time, section )
42
+ @id, @time, @section, @diary_title = id, time, section, diary_title
43
+ end
44
+
45
+ def time_string
46
+ g = @time.dup.gmtime
47
+ l = Time::local( g.year, g.month, g.day, g.hour, g.min, g.sec )
48
+ tz = (g.to_i - l.to_i)
49
+ zone = sprintf( "%+03d:%02d", tz / 3600, tz % 3600 / 60 )
50
+ @time.strftime( "%Y-%m-%dT%H:%M:%S" ) + zone
51
+ end
52
+
53
+ def <=>( other )
54
+ other.time <=> @time
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ @makerss_rsses = @makerss_rsses || []
61
+
62
+ class MakeRssFull
63
+ include ERB::Util
64
+ include TDiary::ViewHelper
65
+
66
+ def initialize(conf, cgi = CGI.new)
67
+ @conf, @cgi = conf, cgi
68
+ @item_num = 0
69
+ end
70
+
71
+ def title
72
+ @conf['makerss.suffix'] || ''
73
+ end
74
+
75
+ def head( str )
76
+ @head = str
77
+ @head.sub!( /<\/title>/, "#{h title}</title>" )
78
+ end
79
+
80
+ def foot( str ); @foot = str; end
81
+ def image( str ); @image = str; end
82
+ def banner( str ); @banner = str; end
83
+
84
+ def item( seq, body, rdfsec )
85
+ @item_num += 1
86
+ return if @item_num > 15
87
+ @seq = '' unless @seq
88
+ @seq << seq
89
+ @body = '' unless @body
90
+ @body << body
91
+ end
92
+
93
+ def xml
94
+ xml = @head.to_s
95
+ xml << @image.to_s
96
+ xml << "<items><rdf:Seq>\n"
97
+ xml << @seq.to_s
98
+ xml << "</rdf:Seq></items>\n</channel>\n"
99
+ xml << @banner.to_s
100
+ xml << @body.to_s
101
+ xml << @foot.to_s
102
+ xml.gsub( /[\x00-\x1f]/ ){|s| s =~ /[\r\n\t]/ ? s : ""}
103
+ end
104
+
105
+ def file
106
+ f = @conf['makerss.file'] || 'index.rdf'
107
+ f = 'index.rdf' if f.empty?
108
+ f =~ %r|^/| ? f : "#{TDiary.document_root}/#{f}"
109
+ end
110
+
111
+ def writable?
112
+ if FileTest::writable?( file ) then
113
+ return true
114
+ elsif FileTest::exist?( file )
115
+ return false
116
+ else # try to create
117
+ begin
118
+ File::open( file, 'w' ){|f|}
119
+ return true
120
+ rescue
121
+ return false
122
+ end
123
+ end
124
+ end
125
+
126
+ def write( encoder )
127
+ begin
128
+ File::open( file, 'w' ) do |f|
129
+ f.write( encoder.call( xml ) )
130
+ end
131
+ rescue
132
+ end
133
+ end
134
+
135
+ def url
136
+ u = @conf['makerss.url'] || "#{base_url}#{File.basename(file)}"
137
+ u = "#{base_url}#{File.basename(file)}" if u.empty?
138
+ u
139
+ end
140
+ end
141
+
142
+ @makerss_rsses << MakeRssFull::new(@conf, @cgi)
143
+
144
+ class MakeRssNoComments < MakeRssFull
145
+ def title
146
+ @conf['makerss.no_comments.suffix'] || '(without comments)'
147
+ end
148
+
149
+ def item( seq, body, rdfsec )
150
+ return unless rdfsec.section.respond_to?( :body_to_html )
151
+ super
152
+ end
153
+
154
+ def file
155
+ f = @conf['makerss.no_comments.file'] || 'no_comments.rdf'
156
+ f = 'no_comments.rdf' if f.empty?
157
+ f =~ %r|^/| ? f : "#{TDiary.document_root}/#{f}"
158
+ end
159
+
160
+ def write( encoder )
161
+ return unless @conf['makerss.no_comments']
162
+ super( encoder )
163
+ end
164
+
165
+ def url
166
+ return nil unless @conf['makerss.no_comments']
167
+ u = @conf['makerss.no_comments.url'] || "#{base_url}#{File.basename(file)}"
168
+ u = "#{base_url}#{File.basename(file)}" if u.empty?
169
+ u
170
+ end
171
+ end
172
+
173
+ @makerss_rsses << MakeRssNoComments::new(@conf, @cgi)
174
+
175
+ def makerss_update
176
+ date = @date.strftime( "%Y%m%d" )
177
+ diary = @diaries[date]
178
+
179
+ uri = @conf.index.dup
180
+ uri[0, 0] = base_url if %r|^https?://|i !~ @conf.index
181
+ uri.gsub!( %r|/\./|, '/' )
182
+
183
+ require 'pstore'
184
+ cache = {}
185
+ rsses = @makerss_rsses
186
+
187
+ begin
188
+ PStore::new( "#{@cache_path}/makerss.cache" ).transaction do |db|
189
+ begin
190
+ cache = db['cache'] if db.root?( 'cache' )
191
+
192
+ if /^append|replace$/ =~ @mode then
193
+ format = "#{date}p%02d"
194
+ index = 0
195
+ diary.each_section do |section|
196
+ index += 1
197
+ id = format % index
198
+ if diary.visible? and !cache[id] then
199
+ cache[id] = RDFSection::new( id, Time::now, section )
200
+ elsif !diary.visible? and cache[id]
201
+ cache.delete( id )
202
+ elsif diary.visible? and cache[id]
203
+ if cache[id].section.body_to_html != section.body_to_html or
204
+ cache[id].section.subtitle_to_html != section.subtitle_to_html then
205
+ cache[id] = RDFSection::new( id, Time::now, section )
206
+ end
207
+ end
208
+ end
209
+
210
+ loop do
211
+ index += 1
212
+ id = format % index
213
+ if cache[id] then
214
+ cache.delete( id )
215
+ else
216
+ break
217
+ end
218
+ end
219
+ elsif /^comment$/ =~ @mode and @conf.show_comment
220
+ id = "#{date}c%02d" % diary.count_comments( true )
221
+ cache[id] = RDFSection::new( id, @comment.date, @comment )
222
+ elsif /^showcomment$/ =~ @mode
223
+ index = 0
224
+ diary.each_comment do |comment|
225
+ index += 1
226
+ id = "#{date}c%02d" % index
227
+ if !cache[id] and (@conf.show_comment and comment.visible? and /^(TrackBack|Pingback)$/i !~ comment.name) then
228
+ cache[id] = RDFSection::new( id, comment.date, comment )
229
+ elsif cache[id] and !(@conf.show_comment and comment.visible? and /^(TrackBack|Pingback)$/i !~ comment.name)
230
+ cache.delete( id )
231
+ end
232
+ end
233
+ end
234
+
235
+ rsses.each{|rss| rss.head( makerss_header( uri ) ) }
236
+ cache.values.sort{|a,b| b.time <=> a.time}.each_with_index do |rdfsec, idx|
237
+ unless rdfsec.section.respond_to?( :visible? ) and !rdfsec.section.visible?
238
+ rsses.each {|rss|
239
+ rss.item( makerss_seq( uri, rdfsec ), makerss_body( uri, rdfsec ), rdfsec )
240
+ }
241
+ end
242
+ if idx > 50
243
+ cache.delete( rdfsec.id )
244
+ end
245
+ end
246
+
247
+ db['cache'] = cache
248
+ rescue PStore::Error
249
+ end
250
+ end
251
+ rescue ArgumentError
252
+ File.unlink( "#{@cache_path}/makerss.cache" )
253
+ retry
254
+ end
255
+
256
+ if @conf.banner and not @conf.banner.empty?
257
+ if /^http/ =~ @conf.banner
258
+ rdf_image = @conf.banner
259
+ else
260
+ rdf_image = base_url + @conf.banner
261
+ end
262
+ rsses.each {|r| r.image( %Q[<image rdf:resource="#{h rdf_image}" />\n] ) }
263
+ end
264
+
265
+ rsses.each {|r|
266
+ r.banner( makerss_banner( uri, rdf_image ) ) if rdf_image
267
+ r.foot( makerss_footer )
268
+ r.write( Proc::new{|s| replace_entities( to_utf8( s ) )} )
269
+ }
270
+ end
271
+
272
+ def makerss_header( uri )
273
+ rdf_url = @conf['makerss.url'] || "#{base_url}index.rdf"
274
+ rdf_url = "#{base_url}index.rdf" if rdf_url.empty?
275
+
276
+ desc = @conf.description || ''
277
+
278
+ copyright = Time::now.strftime( "Copyright %Y #{@conf.author_name}" )
279
+ copyright += " <#{@conf.author_mail}>" if @conf.author_mail and not @conf.author_mail.empty?
280
+ copyright += ", copyright of comments by respective authors"
281
+
282
+ xml = %Q[<?xml version="1.0" encoding="UTF-8"?>
283
+ <?xml-stylesheet href="rss.css" type="text/css"?>
284
+ <rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xml:lang="#{h @conf.html_lang}">
285
+ <channel rdf:about="#{h rdf_url}">
286
+ <title>#{h @conf.html_title}</title>
287
+ <link>#{h uri}</link>
288
+ <xhtml:link xhtml:rel="alternate" xhtml:media="handheld" xhtml:type="text/html" xhtml:href="#{h uri}" />
289
+ <description>#{h desc}</description>
290
+ <dc:creator>#{h @conf.author_name}</dc:creator>
291
+ <dc:rights>#{h copyright}</dc:rights>
292
+ ]
293
+ end
294
+
295
+ def makerss_seq( uri, rdfsec )
296
+ %Q|<rdf:li rdf:resource="#{h uri}#{anchor rdfsec.id}"/>\n|
297
+ end
298
+
299
+ def makerss_banner( uri, rdf_image )
300
+ %Q[<image rdf:about="#{h rdf_image}">
301
+ <title>#{h @conf.html_title}</title>
302
+ <url>#{h rdf_image}</url>
303
+ <link>#{h uri}</link>
304
+ </image>
305
+ ]
306
+ end
307
+
308
+ def makerss_desc_shorten( text )
309
+ if @conf['makerss.shortdesc'] then
310
+ @conf['makerss.partial'] = 0.25 unless @conf['makerss.partial']
311
+ len = ( text.size.to_f * @conf['makerss.partial'] ).ceil.to_i
312
+ len = 500 if len > 500
313
+ else
314
+ len = 500
315
+ end
316
+ @conf.shorten( text, len )
317
+ end
318
+
319
+ def feed?
320
+ @makerss_in_feed
321
+ end
322
+
323
+ def makerss_body( uri, rdfsec )
324
+ rdf = ""
325
+ if rdfsec.section.respond_to?( :body_to_html ) then
326
+ rdf = %Q|<item rdf:about="#{h uri}#{anchor rdfsec.id}">\n|
327
+ rdf << %Q|<link>#{h uri}#{anchor rdfsec.id}</link>\n|
328
+ rdf << %Q|<xhtml:link xhtml:rel="alternate" xhtml:media="handheld" xhtml:type="text/html" xhtml:href="#{h uri}#{anchor rdfsec.id}" />\n|
329
+ rdf << %Q|<dc:date>#{h rdfsec.time_string}</dc:date>\n|
330
+ a = rdfsec.id.scan( /(\d{4})(\d\d)(\d\d)/ ).flatten.map{|s| s.to_i}
331
+ date = Time::local( *a )
332
+ old_apply_plugin = @conf['apply_plugin']
333
+ @conf['apply_plugin'] = true
334
+
335
+ @makerss_in_feed = true
336
+ subtitle = rdfsec.section.subtitle_to_html
337
+ sec_id = rdfsec.id[9,2].to_i
338
+ body_enter = body_enter_proc( date )
339
+ body = apply_plugin( rdfsec.section.body_to_html )
340
+ body_leave = body_leave_proc( date )
341
+ @makerss_in_feed = false
342
+
343
+ sub = (subtitle || '').sub( /^(\[([^\]]+)\])+ */, '' )
344
+ sub = apply_plugin( sub, true ).strip
345
+ if sub.empty?
346
+ sub = @conf.shorten( remove_tag( body ).strip, 20 )
347
+ end
348
+ rdf << %Q|<title>#{sub}</title>\n|
349
+ rdf << %Q|<dc:creator>#{h @conf.author_name}</dc:creator>\n|
350
+ unless rdfsec.section.categories.empty?
351
+ rdfsec.section.categories.each do |category|
352
+ rdf << %Q|<dc:subject>#{h category}</dc:subject>\n|
353
+ end
354
+ end
355
+ desc = remove_tag( body ).strip
356
+ desc.gsub!( /&.*?;/, '' )
357
+ rdf << %Q|<description>#{h makerss_desc_shorten( desc )}</description>\n|
358
+ unless @conf['makerss.hidecontent']
359
+ text = ''
360
+ text << '<h3>' + apply_plugin( subtitle.sub( /^(\[([^\]]+)\])+ */, '' ) ).strip + '</h3>' if subtitle and not subtitle.empty?
361
+ text << body_enter
362
+ text << body
363
+ text << body_leave
364
+ unless text.empty?
365
+ uri = @conf.index.dup
366
+ uri[0, 0] = base_url unless %r|^https?://|i =~ uri
367
+ uri.gsub!( %r|/\./|, '/' )
368
+ text = absolutify( text, uri )
369
+ text.gsub!( /\]\]>/, ']]]]><![CDATA[>' )
370
+ rdf << %Q|<content:encoded><![CDATA[#{text}|
371
+ unless @conf['makerss.comment_link']
372
+ ymd = date.strftime( "%Y%m%d" )
373
+ rdf << %Q|\n<p><a href="#{h uri}#{anchor "#{ymd}c"}">#{comment_new}</a></p>|
374
+ end
375
+ rdf << %Q|]]></content:encoded>\n|
376
+ end
377
+ end
378
+
379
+ @conf['apply_plugin'] = old_apply_plugin
380
+ rdf << "</item>\n"
381
+ else # TSUKKOMI
382
+ rdf = %Q|<item rdf:about="#{h uri}#{anchor rdfsec.id}">\n|
383
+ rdf << %Q|<link>#{h uri}#{anchor rdfsec.id}</link>\n|
384
+ rdf << %Q|<dc:date>#{h rdfsec.time_string}</dc:date>\n|
385
+ rdf << %Q|<title>#{makerss_tsukkomi_label( rdfsec.id )} (#{h rdfsec.section.name})</title>\n|
386
+ rdf << %Q|<dc:creator>#{h rdfsec.section.name}</dc:creator>\n|
387
+ text = rdfsec.section.body
388
+ rdf << %Q|<description>#{h makerss_desc_shorten( text )}</description>\n|
389
+ unless @conf['makerss.hidecontent']
390
+ rdf << %Q|<content:encoded><![CDATA[#{text.make_link.gsub( /\n/, '<br>' ).gsub( /<br><br>\Z/, '' ).gsub( /\]\]>/, ']]]]><![CDATA[>' )}]]></content:encoded>\n|
391
+ end
392
+ rdf << "</item>\n"
393
+ end
394
+ rdf
395
+ end
396
+
397
+ def makerss_footer
398
+ "</rdf:RDF>\n"
399
+ end
400
+
401
+ add_update_proc do
402
+ makerss_update unless @cgi.params['makerss_update'][0] == 'false'
403
+ end
404
+
405
+ add_header_proc {
406
+ html = ''
407
+ @makerss_rsses.each do |rss|
408
+ next unless rss.url
409
+ html << %Q|\t<link rel="alternate" type="application/rss+xml" title="RSS#{h rss.title}" href="#{h rss.url}">\n|
410
+ end
411
+ html
412
+ }
413
+
414
+ add_conf_proc( 'makerss', @makerss_conf_label, 'update' ) do
415
+ if @mode == 'saveconf' then
416
+ %w( hidecontent shortdesc comment_link no_comments).each do |s|
417
+ item = "makerss.#{s}"
418
+ @conf[item] = ( 't' == @cgi.params[item][0] )
419
+ end
420
+ end
421
+
422
+ @makerss_rsses.each do |rss|
423
+ if rss.class == MakeRssFull then
424
+ @makerss_full = rss
425
+ elsif rss.class == MakeRssNoComments
426
+ @makerss_no_comments = rss
427
+ end
428
+ end
429
+ makerss_conf_html
430
+ end
431
+
432
+ add_edit_proc do
433
+ checked = if @cgi.params['makerss_update'][0] == 'false' then
434
+ ' checked'
435
+ elsif @date < (Time::now - 30*24*60*60) # older over a month
436
+ ' checked'
437
+ else
438
+ ''
439
+ end
440
+ r = <<-HTML
441
+ <div class="makerss"><label for="makerss_update">
442
+ <input type="checkbox" id="makerss_update" name="makerss_update" value="false"#{checked} tabindex="390">
443
+ #{@makerss_edit_label}
444
+ </label></div>
445
+ HTML
446
+ end
447
+
448
+ def replace_entities( text )
449
+ unless @xml_entity_table then
450
+ @xml_entity_table = {
451
+ '&nbsp;' => '&#160;',
452
+ '&iexcl;' => '&#161;',
453
+ '&cent;' => '&#162;',
454
+ '&pound;' => '&#163;',
455
+ '&curren;' => '&#164;',
456
+ '&yen;' => '&#165;',
457
+ '&brvbar;' => '&#166;',
458
+ '&sect;' => '&#167;',
459
+ '&uml;' => '&#168;',
460
+ '&copy;' => '&#169;',
461
+ '&ordf;' => '&#170;',
462
+ '&laquo;' => '&#171;',
463
+ '&not;' => '&#172;',
464
+ '&shy;' => '&#173;',
465
+ '&reg;' => '&#174;',
466
+ '&macr;' => '&#175;',
467
+ '&deg;' => '&#176;',
468
+ '&plusmn;' => '&#177;',
469
+ '&sup2;' => '&#178;',
470
+ '&sup3;' => '&#179;',
471
+ '&acute;' => '&#180;',
472
+ '&micro;' => '&#181;',
473
+ '&para;' => '&#182;',
474
+ '&middot;' => '&#183;',
475
+ '&cedil;' => '&#184;',
476
+ '&sup1;' => '&#185;',
477
+ '&ordm;' => '&#186;',
478
+ '&raquo;' => '&#187;',
479
+ '&frac14;' => '&#188;',
480
+ '&frac12;' => '&#189;',
481
+ '&frac34;' => '&#190;',
482
+ '&iquest;' => '&#191;',
483
+ '&Agrave;' => '&#192;',
484
+ '&Aacute;' => '&#193;',
485
+ '&Acirc;' => '&#194;',
486
+ '&Atilde;' => '&#195;',
487
+ '&Auml;' => '&#196;',
488
+ '&Aring;' => '&#197;',
489
+ '&Aelig;' => '&#198;',
490
+ '&Ccedil;' => '&#199;',
491
+ '&Egrave;' => '&#200;',
492
+ '&Eacute;' => '&#201;',
493
+ '&Ecirc;' => '&#202;',
494
+ '&Euml;' => '&#203;',
495
+ '&Igrave;' => '&#204;',
496
+ '&Iacute;' => '&#205;',
497
+ '&Icirc;' => '&#206;',
498
+ '&Iuml;' => '&#207;',
499
+ '&ETH;' => '&#208;',
500
+ '&Ntilde;' => '&#209;',
501
+ '&Ograve;' => '&#210;',
502
+ '&Oacute;' => '&#211;',
503
+ '&Ocirc;' => '&#212;',
504
+ '&Otilde;' => '&#213;',
505
+ '&Ouml;' => '&#214;',
506
+ '&times;' => '&#215;',
507
+ '&Oslash;' => '&#216;',
508
+ '&Ugrave;' => '&#217;',
509
+ '&Uacute;' => '&#218;',
510
+ '&Ucirc;' => '&#219;',
511
+ '&Uuml;' => '&#220;',
512
+ '&Yacute;' => '&#221;',
513
+ '&THORN;' => '&#222;',
514
+ '&szlig;' => '&#223;',
515
+ '&agrave;' => '&#224;',
516
+ '&aacute;' => '&#225;',
517
+ '&acirc;' => '&#226;',
518
+ '&atilde;' => '&#227;',
519
+ '&auml;' => '&#228;',
520
+ '&aring;' => '&#229;',
521
+ '&aelig;' => '&#230;',
522
+ '&ccedil;' => '&#231;',
523
+ '&egrave;' => '&#232;',
524
+ '&eacute;' => '&#233;',
525
+ '&ecirc;' => '&#234;',
526
+ '&euml;' => '&#235;',
527
+ '&igrave;' => '&#236;',
528
+ '&iacute;' => '&#237;',
529
+ '&icirc;' => '&#238;',
530
+ '&iuml;' => '&#239;',
531
+ '&eth;' => '&#240;',
532
+ '&ntilde;' => '&#241;',
533
+ '&ograve;' => '&#242;',
534
+ '&oacute;' => '&#243;',
535
+ '&ocirc;' => '&#244;',
536
+ '&otilde;' => '&#245;',
537
+ '&ouml;' => '&#246;',
538
+ '&divide;' => '&#247;',
539
+ '&oslash;' => '&#248;',
540
+ '&ugrave;' => '&#249;',
541
+ '&uacute;' => '&#250;',
542
+ '&ucirc;' => '&#251;',
543
+ '&uuml;' => '&#252;',
544
+ '&yacute;' => '&#253;',
545
+ '&thorn;' => '&#254;',
546
+ '&yuml;' => '&#255;',
547
+ '&oelig;' => '&#338;',
548
+ '&oelig;' => '&#339;',
549
+ '&scaron;' => '&#352;',
550
+ '&scaron;' => '&#353;',
551
+ '&yuml;' => '&#376;',
552
+ '&circ;' => '&#710;',
553
+ '&tilde;' => '&#732;',
554
+ '&ensp;' => '&#8194;',
555
+ '&emsp;' => '&#8195;',
556
+ '&thinsp;' => '&#8201;',
557
+ '&zwnj;' => '&#8204;',
558
+ '&zwj;' => '&#8205;',
559
+ '&lrm;' => '&#8206;',
560
+ '&rlm;' => '&#8207;',
561
+ '&ndash;' => '&#8211;',
562
+ '&mdash;' => '&#8212;',
563
+ '&lsquo;' => '&#8216;',
564
+ '&rsquo;' => '&#8217;',
565
+ '&sbquo;' => '&#8218;',
566
+ '&ldquo;' => '&#8220;',
567
+ '&rdquo;' => '&#8221;',
568
+ '&bdquo;' => '&#8222;',
569
+ '&dagger;' => '&#8224;',
570
+ '&Dagger;' => '&#8225;',
571
+ '&permil;' => '&#8240;',
572
+ '&lsaquo;' => '&#8249;',
573
+ '&rsaquo;' => '&#8250;',
574
+ '&euro;' => '&#8364;',
575
+ '&fnof;' => '&#402;',
576
+ '&Alpha;' => '&#913;',
577
+ '&Beta;' => '&#914;',
578
+ '&Gamma;' => '&#915;',
579
+ '&Delta;' => '&#916;',
580
+ '&Epsilon;' => '&#917;',
581
+ '&Zeta;' => '&#918;',
582
+ '&Eta;' => '&#919;',
583
+ '&Theta;' => '&#920;',
584
+ '&Iota;' => '&#921;',
585
+ '&Kappa;' => '&#922;',
586
+ '&Lambda;' => '&#923;',
587
+ '&Mu;' => '&#924;',
588
+ '&Nu;' => '&#925;',
589
+ '&Xi;' => '&#926;',
590
+ '&Omicron;' => '&#927;',
591
+ '&Pi;' => '&#928;',
592
+ '&Rho;' => '&#929;',
593
+ '&Sigma;' => '&#931;',
594
+ '&Tau;' => '&#932;',
595
+ '&Upsilon;' => '&#933;',
596
+ '&Phi;' => '&#934;',
597
+ '&Chi;' => '&#935;',
598
+ '&Psi;' => '&#936;',
599
+ '&Omega;' => '&#937;',
600
+ '&alpha;' => '&#945;',
601
+ '&beta;' => '&#946;',
602
+ '&gamma;' => '&#947;',
603
+ '&delta;' => '&#948;',
604
+ '&epsilon;' => '&#949;',
605
+ '&zeta;' => '&#950;',
606
+ '&eta;' => '&#951;',
607
+ '&theta;' => '&#952;',
608
+ '&iota;' => '&#953;',
609
+ '&kappa;' => '&#954;',
610
+ '&lambda;' => '&#955;',
611
+ '&mu;' => '&#956;',
612
+ '&nu;' => '&#957;',
613
+ '&xi;' => '&#958;',
614
+ '&omicron;' => '&#959;',
615
+ '&pi;' => '&#960;',
616
+ '&rho;' => '&#961;',
617
+ '&sigmaf;' => '&#962;',
618
+ '&sigma;' => '&#963;',
619
+ '&tau;' => '&#964;',
620
+ '&upsilon;' => '&#965;',
621
+ '&phi;' => '&#966;',
622
+ '&chi;' => '&#967;',
623
+ '&psi;' => '&#968;',
624
+ '&omega;' => '&#969;',
625
+ '&thetasym;' => '&#977;',
626
+ '&upsih;' => '&#978;',
627
+ '&piv;' => '&#982;',
628
+ '&bull;' => '&#8226;',
629
+ '&hellip;' => '&#8230;',
630
+ '&prime;' => '&#8242;',
631
+ '&prime;' => '&#8243;',
632
+ '&oline;' => '&#8254;',
633
+ '&frasl;' => '&#8260;',
634
+ '&weierp;' => '&#8472;',
635
+ '&image;' => '&#8465;',
636
+ '&real;' => '&#8476;',
637
+ '&trade;' => '&#8482;',
638
+ '&alefsym;' => '&#8501;',
639
+ '&larr;' => '&#8592;',
640
+ '&rarr;' => '&#8594;',
641
+ '&darr;' => '&#8595;',
642
+ '&harr;' => '&#8596;',
643
+ '&crarr;' => '&#8629;',
644
+ '&lArr;' => '&#8656;',
645
+ '&uArr;' => '&#8657;',
646
+ '&rArr;' => '&#8658;',
647
+ '&dArr;' => '&#8659;',
648
+ '&hArr;' => '&#8660;',
649
+ '&forall;' => '&#8704;',
650
+ '&part;' => '&#8706;',
651
+ '&exist;' => '&#8707;',
652
+ '&empty;' => '&#8709;',
653
+ '&nabla;' => '&#8711;',
654
+ '&isin;' => '&#8712;',
655
+ '&notin;' => '&#8713;',
656
+ '&ni;' => '&#8715;',
657
+ '&prod;' => '&#8719;',
658
+ '&sum;' => '&#8721;',
659
+ '&minus;' => '&#8722;',
660
+ '&lowast;' => '&#8727;',
661
+ '&radic;' => '&#8730;',
662
+ '&prop;' => '&#8733;',
663
+ '&infin;' => '&#8734;',
664
+ '&ang;' => '&#8736;',
665
+ '&and;' => '&#8743;',
666
+ '&or;' => '&#8744;',
667
+ '&cap;' => '&#8745;',
668
+ '&cup;' => '&#8746;',
669
+ '&int;' => '&#8747;',
670
+ '&there4;' => '&#8756;',
671
+ '&sim;' => '&#8764;',
672
+ '&cong;' => '&#8773;',
673
+ '&asymp;' => '&#8776;',
674
+ '&ne;' => '&#8800;',
675
+ '&equiv;' => '&#8801;',
676
+ '&le;' => '&#8804;',
677
+ '&ge;' => '&#8805;',
678
+ '&sub;' => '&#8834;',
679
+ '&sup;' => '&#8835;',
680
+ '&nsub;' => '&#8836;',
681
+ '&sube;' => '&#8838;',
682
+ '&supe;' => '&#8839;',
683
+ '&oplus;' => '&#8853;',
684
+ '&otimes;' => '&#8855;',
685
+ '&perp;' => '&#8869;',
686
+ '&sdot;' => '&#8901;',
687
+ '&lceil;' => '&#8968;',
688
+ '&rceil;' => '&#8969;',
689
+ '&lfloor;' => '&#8970;',
690
+ '&rfloor;' => '&#8971;',
691
+ '&lang;' => '&#9001;',
692
+ '&rang;' => '&#9002;',
693
+ '&loz;' => '&#9674;',
694
+ '&spades;' => '&#9824;',
695
+ '&clubs;' => '&#9827;',
696
+ '&hearts;' => '&#9829;',
697
+ '&diams;' => '&#9830;'
698
+ }
699
+ end
700
+ text.gsub( /&[a-z]+;/im ) do |e|
701
+ @xml_entity_table[e] || e
702
+ end
703
+ end
704
+
705
+ # Copied from below which includes some tests
706
+ # http://github.com/zunda/ruby-absolutify/tree/master
707
+ def absolutify(html, baseurl)
708
+ @@_absolutify_attr_regexp ||= Hash.new
709
+ baseuri = URI.parse(URI.encode(baseurl))
710
+ r = html.gsub(%r|<\S[^>]*/?>|) do |tag|
711
+ type = tag.scan(/\A<(\S+)/)[0][0].downcase
712
+ if attr = {'a' => 'href', 'img' => 'src'}[type]
713
+ @@_absolutify_attr_regexp[attr] ||= %r|(.*#{attr}\s*=\s*)(['"]?)([^\2>]+?)(\2.*)|im
714
+ m = tag.match(@@_absolutify_attr_regexp[attr])
715
+ unless m.nil?
716
+ prefix = m[1] + m[2]
717
+ location = m[3]
718
+ postfix = m[4]
719
+ begin
720
+ uri = URI.parse(location)
721
+ if uri.relative?
722
+ location = (baseuri + location).to_s
723
+ elsif not uri.host and uri.path
724
+ path = uri.path
725
+ path += '?' + uri.query if uri.query
726
+ path += '#' + uri.fragment if uri.fragment
727
+ location = (baseuri + path).to_s
728
+ end
729
+ tag = prefix + location + postfix
730
+ rescue URI::InvalidURIError
731
+ end
732
+ end
733
+ end
734
+ tag
735
+ end
736
+ return r
737
+ end
738
+
739
+ # Local Variables:
740
+ # mode: ruby
741
+ # indent-tabs-mode: t
742
+ # tab-width: 3
743
+ # ruby-indent-level: 3
744
+ # End: