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,33 @@
1
+ require 'test/unit'
2
+
3
+ require 'rd/inline-element'
4
+ require 'rd/document-struct'
5
+ require 'dummy'
6
+
7
+ include RD
8
+
9
+ DummyStruct.define_relationship(NonterminalInline, DummyElement)
10
+
11
+ class TestNonterminalInline < Test::Unit::TestCase
12
+ def test_children
13
+ el = NonterminalInline.new
14
+ assert_equal([], el.children)
15
+ el.children.push 1
16
+ assert_equal([1], el.children)
17
+ end
18
+
19
+ def test_to_label
20
+ one = NonterminalInline.new
21
+ one.add_child_under_document_struct(DummyElement.new, DummyStruct)
22
+ assert_equal("label", one.to_label)
23
+
24
+ two = NonterminalInline.new
25
+ two.add_child_under_document_struct(DummyElement.new, DummyStruct)
26
+ two.add_child_under_document_struct(DummyElement.new, DummyStruct)
27
+ assert_equal("label label", two.to_label)
28
+
29
+ zero = NonterminalInline.new
30
+ assert_equal("", zero.to_label)
31
+ end
32
+ end
33
+
@@ -0,0 +1,48 @@
1
+ require 'test/unit'
2
+
3
+ require 'temp-dir'
4
+
5
+ require 'rd/output-format-visitor'
6
+ require 'rd/tree'
7
+ require 'rd/element'
8
+ require 'rd/block-element'
9
+ require 'rd/inline-element'
10
+ require 'rd/rd-struct'
11
+
12
+ include RD
13
+
14
+ class TestOFVisitor < Test::Unit::TestCase
15
+ def setup
16
+ end
17
+
18
+ def test_initialize
19
+ vis = OutputFormatVisitor.new
20
+ assert_equal([], vis.include_suffix)
21
+ vis = SampleVisitor.new
22
+ assert_equal(["html"], vis.include_suffix)
23
+ end
24
+
25
+ def test_apply_to_include
26
+ tree = Tree.new_with_document_struct(DocumentStructure::RD,
27
+ ["test/data/sub", "test/data/"])
28
+ de = DocumentElement.new
29
+ # test/data/includee1.html
30
+ inc1 = Include.new("includee1")
31
+ # test/data/includee2.html, test/data/sub/includee2.html
32
+ inc2 = Include.new("includee2")
33
+ # test/data/includee3.nothtml
34
+ inc3 = Include.new("includee3")
35
+ tree.root = de
36
+ de.add_child(inc1)
37
+ de.add_child(inc2)
38
+ de.add_child(inc3)
39
+ vis = SampleVisitor.new
40
+ assert_equal("includee1.html", vis.apply_to_Include(inc1))
41
+ assert_equal("sub/includee2.html", vis.apply_to_Include(inc2))
42
+ assert_equal(nil, vis.apply_to_Include(inc3))
43
+ end
44
+ end
45
+
46
+ class SampleVisitor < OutputFormatVisitor
47
+ INCLUDE_SUFFIX = ["html"]
48
+ end
@@ -0,0 +1,41 @@
1
+ require 'test/unit'
2
+
3
+ require 'rd/rdblockparser.tab'
4
+ require 'rd/rd-struct'
5
+
6
+ include RD
7
+
8
+ class TestParserUtil < Test::Unit::TestCase
9
+ def setup
10
+ @p = RDParser.new
11
+ @tree = tree = Tree.new_with_document_struct(DocumentStructure::RD)
12
+ @p.instance_eval do
13
+ @tree = tree
14
+ end
15
+ end
16
+
17
+ def test_tree
18
+ obj = Object.new
19
+ obj.extend(ParserUtility)
20
+
21
+ assert_raises(NotImplementedError) do
22
+ obj.tree
23
+ end
24
+ end
25
+
26
+ def test_add_children_to_element
27
+ headline = Headline.new(1)
28
+ string_element = StringElement.new "string"
29
+ emphasis = Emphasis.new
30
+ @p.add_children_to_element(headline, string_element, emphasis)
31
+ assert_equal([string_element, emphasis], headline.children)
32
+
33
+ textblock = TextBlock.new
34
+ @p.add_children_to_element(textblock, emphasis, string_element)
35
+ assert_equal([emphasis, string_element], textblock.children)
36
+
37
+ textblock_empty = TextBlock.new
38
+ @p.add_children_to_element(textblock_empty)
39
+ assert_equal([], textblock_empty.children)
40
+ end
41
+ end
@@ -0,0 +1,156 @@
1
+ require 'test/unit'
2
+
3
+ require 'temp-dir'
4
+
5
+ require 'rd/rbl-file'
6
+ require 'rd/block-element'
7
+ require 'rd/inline-element'
8
+ require 'rd/rd-struct'
9
+ require 'rd/reference-resolver'
10
+
11
+ include RD
12
+
13
+ class TestRBLFile < Test::Unit::TestCase
14
+
15
+ def setup
16
+ tr_head2 = Tree.new_with_document_struct(DocumentStructure::RD)
17
+ de_head2 = DocumentElement.new
18
+ tr_head2.root = de_head2
19
+ hl1_head2, hl2_head2 = nil
20
+
21
+ de_head2.build do
22
+ hl1_head2 = new Headline, 1 do
23
+ new StringElement, "label1"
24
+ end
25
+ new TextBlock
26
+ hl2_head2 = new Headline, 2 do
27
+ new StringElement, "label2"
28
+ end
29
+ end
30
+
31
+ @resolv_head2 = ReferenceResolver.new(tr_head2, "label:")
32
+
33
+ tr_desc = Tree.new_with_document_struct(DocumentStructure::RD)
34
+ de_desc = DocumentElement.new
35
+ tr_desc.root = de_desc
36
+ hl1_desc, dt1_desc = nil
37
+ de_desc.build do
38
+ hl1_desc = new(Headline, 1) do
39
+ new StringElement, "label1"
40
+ end
41
+ new DescList do
42
+ new DescListItem do
43
+ dt1_desc = make_term do
44
+ new StringElement, "label2"
45
+ end
46
+ end
47
+ end
48
+ end
49
+ @resolv_desc = ReferenceResolver.new(tr_desc, "Label-")
50
+
51
+ tr_empty = Tree.new_with_document_struct(DocumentStructure::RD)
52
+ de_empty = DocumentElement.new
53
+ tr_empty.root = de_empty
54
+ @resolv_empty = ReferenceResolver.new(tr_empty, "LABEL")
55
+
56
+ tr_arr = Tree.new_with_document_struct(DocumentStructure::RD)
57
+ de_arr = DocumentElement.new
58
+ tr_arr.root = de_arr
59
+
60
+ de_arr.build do
61
+ new Headline, 1 do
62
+ new StringElement, "a => b"
63
+ end
64
+ end
65
+
66
+ @resolv_arr = ReferenceResolver.new(tr_arr, "label:")
67
+
68
+ @rbl_head2 = RBLFile.new("test-head2")
69
+ @rbl_desc = RBLFile.new("test-desc")
70
+ @rbl_empty = RBLFile.new("test-empty")
71
+ @rbl_arr = RBLFile.new("test-arr")
72
+ end
73
+
74
+ def test_labels_to_string
75
+ res = "label1 => label:0\nlabel2 => label:1"
76
+ assert_equal(res, RBLFile.labels_to_string(@resolv_head2))
77
+
78
+ res2 = "label1 => Label-0\nlabel2 => Label-1"
79
+ assert_equal(res2, RBLFile.labels_to_string(@resolv_desc))
80
+
81
+ res_empty = ""
82
+ assert_equal(res_empty, RBLFile.labels_to_string(@resolv_empty))
83
+
84
+ res_arr = "a => b => label:0"
85
+ assert_equal(res_arr, RBLFile.labels_to_string(@resolv_arr))
86
+ end
87
+
88
+ def test_string_to_labels
89
+ rbl = RBLFile.new("test-head2")
90
+ src_head2 = "label1 => label:0\nlabel2 => label:1"
91
+ res_head2 = [["label1", "label:0"], ["label2", "label:1"]]
92
+ assert_equal(res_head2, rbl.string_to_labels(src_head2))
93
+
94
+ src_head2 = "label1 =>label:0\nlabel2=> label:1"
95
+ res_head2 = [["label1", "label:0"], ["label2", "label:1"]]
96
+ assert_equal(res_head2, rbl.string_to_labels(src_head2))
97
+
98
+ src_desc = "label1 => Label-0\nlabel2 => Label-1"
99
+ res_desc = [["label1", "Label-0"], ["label2", "Label-1"]]
100
+ assert_equal(res_desc, rbl.string_to_labels(src_desc))
101
+
102
+ src_empty = ""
103
+ res_empty = []
104
+ assert_equal(res_empty, @rbl_empty.string_to_labels(src_empty))
105
+
106
+ src_arr = "a => b => label:0"
107
+ res_arr = [["a => b", "label:0"]]
108
+ assert_equal(res_arr, @rbl_arr.string_to_labels(src_arr))
109
+ end
110
+
111
+ def test_rbl_file_path
112
+ assert_equal("test-head2.rbl", RBLFile.rbl_file_path("test-head2.rd"))
113
+ assert_equal("test-head2.rbl", RBLFile.rbl_file_path("test-head2.rb"))
114
+ assert_equal("test-desc.rbl", RBLFile.rbl_file_path("test-desc"))
115
+ end
116
+
117
+ def test_s_create_rbl_file
118
+ in_temp_dir do
119
+ begin
120
+ RBLFile.create_rbl_file("test-head2.rd", @resolv_head2)
121
+ assert(File.exist?("test-head2.rbl"))
122
+ ensure
123
+ remove_file("test-head2.rbl")
124
+ end
125
+ end
126
+ end
127
+
128
+ def test_load_rbl_file
129
+ in_temp_dir do
130
+ spath = [Dir.pwd]
131
+ begin
132
+ RBLFile.create_rbl_file("test-head2.rd", @resolv_head2)
133
+
134
+ rbl_rd = RBLFile.new("test-head2.rd")
135
+ rbl_rd.load_rbl_file(spath)
136
+ res = [["label1", "label:0"], ["label2", "label:1"]]
137
+ assert_equal(res, rbl_rd.labels)
138
+
139
+ rbl_no = RBLFile.new("test-head2")
140
+ rbl_no.load_rbl_file(spath)
141
+ assert_equal(res, rbl_no.labels)
142
+ ensure
143
+ remove_file("test-head2.rbl")
144
+ end
145
+ end
146
+ end
147
+
148
+ def test_refer
149
+ spath = ["test/data"]
150
+ rbl = RBLFile.new("label")
151
+ rbl.load_rbl_file(spath)
152
+ assert_equal("label:0", rbl.refer("label1"))
153
+ assert_equal("label:1", rbl.refer("label2"))
154
+ assert_equal(nil, rbl.refer("label3"))
155
+ end
156
+ end
@@ -0,0 +1,43 @@
1
+ require 'test/unit'
2
+
3
+ require 'rd/rbl-suite'
4
+ require 'rd/rbl-file'
5
+
6
+ include RD
7
+
8
+ class TestRBLSuite < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @suite = RBLSuite.new(["test/data"])
12
+ end
13
+
14
+ def test_get_rbl_file
15
+ assert_equal([], @suite.rbl_files)
16
+ rbl = @suite.get_rbl_file("label.rd")
17
+ assert_equal(rbl, @suite.get_rbl_file("label.rd"))
18
+ assert_equal(1, @suite.rbl_files.size)
19
+ end
20
+
21
+ def test_add_rbl_file
22
+ assert_equal([], @suite.rbl_files)
23
+ rbl = @suite.add_rbl_file("label.rd")
24
+ assert_kind_of(RBLFile, rbl)
25
+ assert_equal(1, @suite.rbl_files.size)
26
+ assert_equal("label", @suite.rbl_files[0].filename)
27
+ assert_equal(rbl, @suite.rbl_files[0])
28
+
29
+ assert_nothing_raised do
30
+ @suite.add_rbl_file("not-exist-label.rd")
31
+ end
32
+ end
33
+
34
+ def test_refer
35
+ assert_equal(["label", "label:0"], @suite.refer("label1", "label.rd"))
36
+ assert_equal(["label2", "Label-0"], @suite.refer("label1", "label2.rd"))
37
+ assert_equal(["label", "label:0"], @suite.refer("label1", "label"))
38
+ assert_equal(["label", "label:1"], @suite.refer("label2", "label.rd"))
39
+ assert_equal(["label", nil], @suite.refer("label3", "label.rd"))
40
+ fns = @suite.rbl_files.collect{|i| i.filename }
41
+ assert_equal(["label", "label2"], fns)
42
+ end
43
+ end
@@ -0,0 +1,496 @@
1
+ require 'test/unit'
2
+
3
+ require 'rd/rd2html-lib'
4
+ require 'rd/tree'
5
+ require 'rd/element'
6
+ require 'rd/block-element'
7
+ require 'rd/list'
8
+ require 'rd/desclist'
9
+ require 'rd/methodlist'
10
+ require 'rd/inline-element'
11
+ require 'rd/rd-struct'
12
+
13
+ include RD
14
+
15
+ class TestRD2HTMLVisitor < Test::Unit::TestCase
16
+
17
+ def setup
18
+ @vis = RD2HTMLVisitor.new
19
+ @vis.class.module_eval {
20
+ public :xml_decl
21
+ public :forward_links, :backward_links
22
+ public :document_title
23
+ public :html_content_type
24
+ public :html_title
25
+ public :html_open_tag
26
+ public :link_to_css
27
+ public :prepare_footnotes
28
+ public :make_foottext
29
+ }
30
+ @ch1 = ["a"]
31
+ @ch2 = ["a", "b"]
32
+ @ch3 = ["a\n"]
33
+ @ch0 = []
34
+
35
+ @tr_fn = Tree.new_with_document_struct(DocumentStructure::RD)
36
+ @tr_fn.root = DocumentElement.new
37
+ fn1, fn2 = nil
38
+ @tr_fn.root.build do
39
+ new TextBlock do
40
+ fn1 = new Footnote do
41
+ new StringElement, "footnote 1"
42
+ end
43
+ fn2 = new Footnote do
44
+ new StringElement, "footnote 2"
45
+ end
46
+ end
47
+ end
48
+ @fn1_fn = fn1
49
+ @fn2_fn = fn2
50
+
51
+ @tr2_fn = Tree.new_with_document_struct(DocumentStructure::RD)
52
+ @tr2_fn.root = DocumentElement.new
53
+ @tr2_fn.root.build do
54
+ new Headline, 1
55
+ new TextBlock do
56
+ new StringElement, "string"
57
+ end
58
+ end
59
+ end
60
+
61
+ def test_xml_decl
62
+ vis_with_charset = RD2HTMLVisitor.new
63
+ vis_with_charset.charset = "CharSet"
64
+ assert_equal(%|<?xml version="1.0" encoding="CharSet" ?>|,
65
+ vis_with_charset.xml_decl)
66
+ vis_no_charset = RD2HTMLVisitor.new
67
+ assert_equal(%|<?xml version="1.0" ?>|,
68
+ vis_no_charset.xml_decl)
69
+ end
70
+
71
+ def test_html_open_tag
72
+ vis_with_lang = RD2HTMLVisitor.new
73
+ vis_with_lang.lang = "Language"
74
+ assert_equal(%|<html xmlns="http://www.w3.org/1999/xhtml" lang="Language"|+
75
+ %| xml:lang="Language">|, vis_with_lang.html_open_tag)
76
+
77
+ vis_no_lang = RD2HTMLVisitor.new
78
+ assert_equal(%|<html xmlns="http://www.w3.org/1999/xhtml">|,
79
+ vis_no_lang.html_open_tag)
80
+ end
81
+
82
+ def test_html_title
83
+ vis_with_title = RD2HTMLVisitor.new
84
+ vis_with_title.title = "Title"
85
+ assert_equal("<title>Title</title>", vis_with_title.html_title)
86
+
87
+ vis_no_title = RD2HTMLVisitor.new
88
+ assert_equal("<title>Untitled</title>", vis_no_title.html_title)
89
+ end
90
+
91
+ def test_html_content_type
92
+ vis_with_charset = RD2HTMLVisitor.new
93
+ vis_with_charset.charset = "CharSet"
94
+ assert_equal(%|<meta http-equiv="Content-type" | +
95
+ %|content="text/html; charset=CharSet" | +
96
+ "/>", vis_with_charset.html_content_type)
97
+ vis_no_charset = RD2HTMLVisitor.new
98
+ assert_equal(nil, vis_no_charset.html_content_type)
99
+ end
100
+
101
+ def test_link_to_css
102
+ vis_with_css = RD2HTMLVisitor.new
103
+ vis_with_css.css = "CSS.css"
104
+ assert_equal(%|<link href="CSS.css" type="text/css" rel="stylesheet"| +
105
+ " />", vis_with_css.link_to_css)
106
+ vis_no_css = RD2HTMLVisitor.new
107
+ assert_equal(nil, vis_no_css.link_to_css)
108
+ end
109
+
110
+ def test_forward_links
111
+ vis_rel1 = RD2HTMLVisitor.new
112
+ vis_rel1.html_link_rel["rel1"] = "REL1"
113
+ assert_equal('<link href="REL1" rel="rel1" />', vis_rel1.forward_links)
114
+
115
+ vis_rel2 = vis_rel1
116
+ vis_rel2.html_link_rel["rel2"] = "REL2"
117
+ assert_equal('<link href="REL1" rel="rel1" />' + "\n" +
118
+ '<link href="REL2" rel="rel2" />', vis_rel2.forward_links)
119
+
120
+ vis_no_rel = RD2HTMLVisitor.new
121
+ assert_equal(nil, vis_no_rel.forward_links)
122
+ end
123
+
124
+ def test_backward_links
125
+ vis_rev1 = RD2HTMLVisitor.new
126
+ vis_rev1.html_link_rev["rev1"] = "REV1"
127
+ assert_equal('<link href="REV1" rev="rev1" />', vis_rev1.backward_links)
128
+
129
+ vis_rev2 = vis_rev1
130
+ vis_rev2.html_link_rev["rev2"] = "REV2"
131
+ assert_equal('<link href="REV1" rev="rev1" />' + "\n" +
132
+ '<link href="REV2" rev="rev2" />', vis_rev2.backward_links)
133
+
134
+ vis_no_rev = RD2HTMLVisitor.new
135
+ assert_equal(nil, vis_no_rev.backward_links)
136
+ end
137
+
138
+
139
+ def test_document_title
140
+ vis_titled = RD2HTMLVisitor.new
141
+ vis_titled.title = "Title"
142
+ assert_equal("Title", vis_titled.document_title)
143
+
144
+ vis_with_filename = RD2HTMLVisitor.new
145
+ vis_with_filename.filename = "FileName"
146
+ assert_equal("FileName", vis_with_filename.document_title)
147
+
148
+ vis_untitled = RD2HTMLVisitor.new
149
+ assert_equal("Untitled", vis_untitled.document_title)
150
+ end
151
+
152
+ def test_apply_to_Headline
153
+ tr = Tree.new_with_document_struct(DocumentStructure::RD)
154
+ tr.root = DocumentElement.new
155
+ hl1, hl2 = nil
156
+ tr.root.build do
157
+ hl1 = new Headline, 1 do
158
+ new StringElement, "headline 1"
159
+ end
160
+ hl2 = new Headline, 2 do
161
+ new StringElement, "headline 2"
162
+ end
163
+ end
164
+ @vis.prepare_labels(tr, "label:")
165
+
166
+ assert_equal(expect_for_hl1(@ch1), @vis.apply_to_Headline(hl1, @ch1))
167
+ assert_equal(expect_for_hl1(@ch2), @vis.apply_to_Headline(hl1, @ch2))
168
+ assert_equal(expect_for_hl1(@ch0), @vis.apply_to_Headline(hl1, @ch0))
169
+ assert_equal(expect_for_hl2(@ch1), @vis.apply_to_Headline(hl2, @ch1))
170
+ assert_equal(expect_for_hl2(@ch2), @vis.apply_to_Headline(hl2, @ch2))
171
+ assert_equal(expect_for_hl2(@ch0), @vis.apply_to_Headline(hl2, @ch0))
172
+ end
173
+
174
+ def expect_for_hl1(children)
175
+ %|<h1><a name="label:0" id="label:0">#{children.join('')}</a></h1><!-- RDLabel: "headline 1" -->|
176
+ end
177
+
178
+ def expect_for_hl2(children)
179
+ %|<h2><a name="label:1" id="label:1">#{children.join('')}</a></h2><!-- RDLabel: "headline 2" -->|
180
+ end
181
+
182
+ def test_apply_to_TextBlock
183
+ tb = TextBlock.new
184
+ assert_equal("<p>a</p>", @vis.apply_to_TextBlock(tb, @ch1))
185
+ assert_equal("<p>ab</p>", @vis.apply_to_TextBlock(tb, @ch2))
186
+ assert_equal("<p>a</p>", @vis.apply_to_TextBlock(tb, @ch3))
187
+ assert_equal("<p></p>", @vis.apply_to_TextBlock(tb, @ch0))
188
+
189
+ tb_in_list = TextBlock.new
190
+ li = ItemListItem.new
191
+ li.add_child_under_document_struct(tb_in_list, DocumentStructure::RD)
192
+ assert_equal("a", @vis.apply_to_TextBlock(tb_in_list, @ch1))
193
+ assert_equal("ab", @vis.apply_to_TextBlock(tb_in_list, @ch2))
194
+ assert_equal("a", @vis.apply_to_TextBlock(tb_in_list, @ch3))
195
+ assert_equal("", @vis.apply_to_TextBlock(tb_in_list, @ch0))
196
+
197
+ tb1_in_list2 = TextBlock.new
198
+ tb2_in_list2 = TextBlock.new
199
+ li2 = ItemListItem.new
200
+ li2.add_children_under_document_struct([tb1_in_list2, tb2_in_list2],
201
+ DocumentStructure::RD)
202
+ assert_equal("<p>a</p>", @vis.apply_to_TextBlock(tb1_in_list2, @ch1))
203
+ assert_equal("<p>ab</p>", @vis.apply_to_TextBlock(tb1_in_list2, @ch2))
204
+ assert_equal("<p>a</p>", @vis.apply_to_TextBlock(tb1_in_list2, @ch3))
205
+ assert_equal("<p></p>", @vis.apply_to_TextBlock(tb1_in_list2, @ch0))
206
+ end
207
+
208
+ def test_apply_to_Verbatim
209
+ verb1 = Verbatim.new "aaa"
210
+ assert_equal("<pre>aaa</pre>", @vis.apply_to_Verbatim(verb1))
211
+ verb2 = Verbatim.new "aaa\n"
212
+ assert_equal("<pre>aaa</pre>", @vis.apply_to_Verbatim(verb2))
213
+ verb3 = Verbatim.new "aaa\nbbb"
214
+ assert_equal("<pre>aaa\nbbb</pre>", @vis.apply_to_Verbatim(verb3))
215
+ verb_empty = Verbatim.new ""
216
+ assert_equal("<pre></pre>", @vis.apply_to_Verbatim(verb_empty))
217
+ verb_amp = Verbatim.new "&"
218
+ assert_equal("<pre>&amp;</pre>", @vis.apply_to_Verbatim(verb_amp))
219
+ verb_lt = Verbatim.new "<"
220
+ assert_equal("<pre>&lt;</pre>", @vis.apply_to_Verbatim(verb_lt))
221
+ verb_gt = Verbatim.new ">"
222
+ assert_equal("<pre>&gt;</pre>", @vis.apply_to_Verbatim(verb_gt))
223
+
224
+ verb3 = Verbatim.new ["aaa\n", "bbb"]
225
+ assert_equal("<pre>aaa\nbbb</pre>", @vis.apply_to_Verbatim(verb3))
226
+ end
227
+
228
+ def test_apply_to_ItemList
229
+ list = ItemList.new
230
+ assert_equal("<ul>\na\n</ul>", @vis.apply_to_ItemList(list, @ch1))
231
+ assert_equal("<ul>\na\nb\n</ul>", @vis.apply_to_ItemList(list, @ch2))
232
+ assert_equal("<ul>\na\n</ul>", @vis.apply_to_ItemList(list, @ch3))
233
+ assert_equal("<ul>\n\n</ul>", @vis.apply_to_ItemList(list, @ch0))
234
+ end
235
+
236
+ def test_apply_to_EnumList
237
+ list = EnumList.new
238
+ assert_equal("<ol>\na\n</ol>", @vis.apply_to_EnumList(list, @ch1))
239
+ assert_equal("<ol>\na\nb\n</ol>", @vis.apply_to_EnumList(list, @ch2))
240
+ assert_equal("<ol>\na\n</ol>", @vis.apply_to_EnumList(list, @ch3))
241
+ assert_equal("<ol>\n\n</ol>", @vis.apply_to_EnumList(list, @ch0))
242
+ end
243
+
244
+ def test_apply_to_DescList
245
+ list = DescList.new
246
+ assert_equal("<dl>\na\n</dl>", @vis.apply_to_DescList(list, @ch1))
247
+ assert_equal("<dl>\na\nb\n</dl>", @vis.apply_to_DescList(list, @ch2))
248
+ assert_equal("<dl>\na\n</dl>", @vis.apply_to_DescList(list, @ch3))
249
+ assert_equal("<dl>\n\n</dl>", @vis.apply_to_DescList(list, @ch0))
250
+ end
251
+
252
+ def test_apply_to_MethodList
253
+ list = MethodList.new
254
+ assert_equal("<dl>\na\n</dl>", @vis.apply_to_MethodList(list, @ch1))
255
+ assert_equal("<dl>\na\nb\n</dl>", @vis.apply_to_MethodList(list, @ch2))
256
+ assert_equal("<dl>\na\n</dl>", @vis.apply_to_MethodList(list, @ch3))
257
+ assert_equal("<dl>\n\n</dl>", @vis.apply_to_MethodList(list, @ch0))
258
+ end
259
+
260
+ def test_apply_to_ItemListItem
261
+ item = ItemListItem.new
262
+ assert_equal("<li>a</li>", @vis.apply_to_ItemListItem(item, @ch1))
263
+ assert_equal("<li>a\nb</li>", @vis.apply_to_ItemListItem(item, @ch2))
264
+ assert_equal("<li>a</li>", @vis.apply_to_ItemListItem(item, @ch3))
265
+ assert_equal("<li></li>", @vis.apply_to_ItemListItem(item, @ch0))
266
+ end
267
+
268
+ def test_apply_to_EnumListItem
269
+ item = EnumListItem.new
270
+ assert_equal("<li>a</li>", @vis.apply_to_EnumListItem(item, @ch1))
271
+ assert_equal("<li>a\nb</li>", @vis.apply_to_EnumListItem(item, @ch2))
272
+ assert_equal("<li>a</li>", @vis.apply_to_EnumListItem(item, @ch3))
273
+ assert_equal("<li></li>", @vis.apply_to_EnumListItem(item, @ch0))
274
+ end
275
+
276
+ def test_apply_to_DescListItem
277
+ tr = Tree.new_with_document_struct(DocumentStructure::RD)
278
+ tr.root = DocumentElement.new
279
+ di1, di2 = nil
280
+ tr.root.build do
281
+ new DescList do
282
+ di1 = new DescListItem do
283
+ make_term do
284
+ new StringElement, "desclist 1"
285
+ end
286
+ end
287
+ di2 = new DescListItem do
288
+ make_term do
289
+ new StringElement, "desclist 2"
290
+ end
291
+ end
292
+ end
293
+ end
294
+
295
+ @vis.prepare_labels(tr, "label:")
296
+
297
+ assert_equal(expect_for_di1_with_child("term1", @ch1),
298
+ @vis.apply_to_DescListItem(di1, ["term1"], @ch1))
299
+ assert_equal(expect_for_di1_with_child("term1term2", @ch1),
300
+ @vis.apply_to_DescListItem(di1, ["term1", "term2"], @ch1))
301
+ assert_equal(expect_for_di1_with_child("term1", @ch2),
302
+ @vis.apply_to_DescListItem(di1, ["term1"], @ch2))
303
+ assert_equal(expect_for_di1_with_child("term1", @ch3),
304
+ @vis.apply_to_DescListItem(di1, ["term1"], @ch3))
305
+ assert_equal(expect_for_di1_no_child("term1"),
306
+ @vis.apply_to_DescListItem(di1, ["term1"], @ch0))
307
+ assert_equal(expect_for_di1_no_child("term1term2"),
308
+ @vis.apply_to_DescListItem(di1, ["term1", "term2"], @ch0))
309
+ assert_equal(expect_for_di2_with_child("term1", @ch1),
310
+ @vis.apply_to_DescListItem(di2, ["term1"], @ch1))
311
+ assert_equal(expect_for_di2_no_child("term1"),
312
+ @vis.apply_to_DescListItem(di2, ["term1"], @ch0))
313
+
314
+ end
315
+
316
+ def expect_for_di1_with_child(term, children)
317
+ %|<dt><a name="label:0" id="label:0">#{term}</a></dt><!-- RDLabel: "desclist 1" -->\n| +
318
+ %|<dd>\n#{children.join("\n").chomp}\n</dd>|
319
+ end
320
+
321
+ def expect_for_di1_no_child(term)
322
+ %|<dt><a name="label:0" id="label:0">#{term}</a></dt><!-- RDLabel: "desclist 1" -->|
323
+ end
324
+
325
+ def expect_for_di2_with_child(term, children)
326
+ %|<dt><a name="label:1" id="label:1">#{term}</a></dt><!-- RDLabel: "desclist 2" -->\n| +
327
+ %|<dd>\n#{children.join("\n").chomp}\n</dd>|
328
+ end
329
+
330
+ def expect_for_di2_no_child(term)
331
+ %|<dt><a name="label:1" id="label:1">#{term}</a></dt><!-- RDLabel: "desclist 2" -->|
332
+ end
333
+
334
+ # MethodListItem ...
335
+
336
+ def check_apply_to_NonterminalInline(type, tag)
337
+ element = type.new
338
+ name = type.to_s.sub(/RD::/, "")
339
+
340
+ assert_equal("<#{tag}>a</#{tag}>",
341
+ @vis.send("apply_to_#{name}", element, @ch1))
342
+ assert_equal("<#{tag}>ab</#{tag}>",
343
+ @vis.send("apply_to_#{name}", element, @ch2))
344
+ assert_equal("<#{tag}>a\n</#{tag}>",
345
+ @vis.send("apply_to_#{name}", element, @ch3))
346
+ assert_equal("<#{tag}></#{tag}>",
347
+ @vis.send("apply_to_#{name}", element, @ch0))
348
+ end
349
+
350
+ def test_apply_to_Emphasis
351
+ check_apply_to_NonterminalInline(Emphasis, "em")
352
+ end
353
+
354
+ def test_apply_to_Code
355
+ check_apply_to_NonterminalInline(Code, "code")
356
+ end
357
+
358
+ def test_apply_to_Var
359
+ check_apply_to_NonterminalInline(Var, "var")
360
+ end
361
+
362
+ def test_apply_to_Keyboard
363
+ check_apply_to_NonterminalInline(Keyboard, "kbd")
364
+ end
365
+
366
+ def test_apply_to_StringElement
367
+ se1 = StringElement.new "a"
368
+ assert_equal("a", @vis.apply_to_StringElement(se1))
369
+ se2 = StringElement.new "a\nb"
370
+ assert_equal("a\nb", @vis.apply_to_StringElement(se2))
371
+ se_empty = StringElement.new ""
372
+ assert_equal("", @vis.apply_to_StringElement(se_empty))
373
+ se_ws = StringElement.new " "
374
+ assert_equal(" ", @vis.apply_to_StringElement(se_ws))
375
+ se_lt = StringElement.new "<"
376
+ assert_equal("&lt;", @vis.apply_to_StringElement(se_lt))
377
+ se_gt = StringElement.new ">"
378
+ assert_equal("&gt;", @vis.apply_to_StringElement(se_gt))
379
+ se_amp = StringElement.new "&"
380
+ assert_equal("&amp;", @vis.apply_to_StringElement(se_amp))
381
+ end
382
+
383
+ def test_apply_to_Verb
384
+ verb1 = Verb.new "a"
385
+ assert_equal("a", @vis.apply_to_Verb(verb1))
386
+ verb2 = Verb.new "a\nb"
387
+ assert_equal("a\nb", @vis.apply_to_Verb(verb2))
388
+ verb_empty = Verb.new ""
389
+ assert_equal("", @vis.apply_to_Verb(verb_empty))
390
+ verb_ws = Verb.new " "
391
+ assert_equal(" ", @vis.apply_to_Verb(verb_ws))
392
+ verb_lt = Verb.new "<"
393
+ assert_equal("&lt;", @vis.apply_to_Verb(verb_lt))
394
+ verb_gt = Verb.new ">"
395
+ assert_equal("&gt;", @vis.apply_to_Verb(verb_gt))
396
+ verb_amp = Verb.new "&"
397
+ assert_equal("&amp;", @vis.apply_to_Verb(verb_amp))
398
+ end
399
+
400
+ def test_apply_to_Footnote
401
+ @vis.prepare_footnotes(@tr_fn)
402
+ assert_equal([], @vis.foottexts)
403
+
404
+ assert_equal(expect_for_footnote(1),
405
+ @vis.apply_to_Footnote(@fn1_fn, ["footnote 1"]))
406
+ assert_equal([["footnote 1"]], @vis.foottexts)
407
+
408
+ assert_equal(expect_for_footnote(2),
409
+ @vis.apply_to_Footnote(@fn2_fn, ["footnote", " 2"]))
410
+ assert_equal([["footnote 1"], ["footnote", " 2"]], @vis.foottexts)
411
+
412
+ @vis.prepare_footnotes(@tr2_fn)
413
+ assert_raises(ArgumentError) do
414
+ @vis.apply_to_Footnote(@fn2_fn, [])
415
+ end
416
+ end
417
+
418
+ def expect_for_footnote(num)
419
+ %Q|<a name="footmark-#{num}" id="footmark-#{num}" href="#foottext-#{num}">|+
420
+ %Q|<sup><small>*#{num}</small></sup></a>|
421
+ end
422
+
423
+ def test_get_footnote_num
424
+ @vis.prepare_footnotes(@tr_fn)
425
+ assert_equal(1, @vis.get_footnote_num(@fn1_fn))
426
+ assert_equal(2, @vis.get_footnote_num(@fn2_fn))
427
+ assert_equal(nil, @vis.get_footnote_num(Footnote.new))
428
+ @vis.prepare_footnotes(@tr2_fn)
429
+ assert_equal(nil, @vis.get_footnote_num(@fn1_fn))
430
+
431
+ assert_raises(ArgumentError) do
432
+ @vis.get_footnote_num(Headline.new(1))
433
+ end
434
+ end
435
+
436
+ def test_prepare_footnotes
437
+ @vis.prepare_footnotes(@tr_fn)
438
+ assert_equal([@fn1_fn, @fn2_fn], @vis.footnotes)
439
+
440
+ @vis.prepare_footnotes(@tr2_fn)
441
+ assert_equal([], @vis.footnotes)
442
+ end
443
+
444
+ def test_add_foottext
445
+ @vis.prepare_footnotes(@tr_fn)
446
+ assert_equal([], @vis.foottexts)
447
+ @vis.add_foottext(@vis.get_footnote_num(@fn1_fn), ["footnote 1"])
448
+ assert_equal([["footnote 1"]], @vis.foottexts)
449
+ @vis.add_foottext(@vis.get_footnote_num(@fn2_fn), ["footnote", "2"])
450
+ assert_equal([["footnote 1"], ["footnote", "2"]], @vis.foottexts)
451
+ assert_raises(ArgumentError) do
452
+ @vis.add_foottext(3, "footnote 3")
453
+ end
454
+ end
455
+
456
+ def test_apply_to_Foottext
457
+ @vis.prepare_footnotes(@tr_fn)
458
+
459
+ exp1 = %|<a name="foottext-1" id="foottext-1" href="#footmark-1">| +
460
+ %|<sup><small>*1</small></sup></a>| +
461
+ %|<small>footnote 1</small><br />|
462
+ assert_equal(exp1, @vis.apply_to_Foottext(@fn1_fn, ["footnote 1"]))
463
+ exp2 = %|<a name="foottext-2" id="foottext-2" href="#footmark-2">| +
464
+ %|<sup><small>*2</small></sup></a>| +
465
+ %|<small>footnote 2</small><br />|
466
+ assert_equal(exp2, @vis.apply_to_Foottext(@fn2_fn, ["footnote", " 2"]))
467
+
468
+ @vis.prepare_footnotes(@tr2_fn)
469
+ assert_raises(ArgumentError) do
470
+ @vis.apply_to_Foottext(@fn1_fn, ["footnote 1"])
471
+ end
472
+ end
473
+
474
+ def test_make_foottext
475
+ @vis.prepare_footnotes(@tr_fn)
476
+ ft1 = ["footnote 1"]
477
+ ft2 = ["footnote", " 2"]
478
+ @vis.add_foottext(@vis.get_footnote_num(@fn1_fn), ft1)
479
+ @vis.add_foottext(@vis.get_footnote_num(@fn2_fn), ft2)
480
+ exp1 = @vis.apply_to_Foottext(@fn1_fn, ft1)
481
+ exp2 = @vis.apply_to_Foottext(@fn2_fn, ft2)
482
+ assert_equal(%|<hr />\n<p class="foottext">\n#{exp1}\n#{exp2}\n</p>|, @vis.make_foottext)
483
+
484
+ @vis.prepare_footnotes(@tr2_fn)
485
+ assert_equal(nil, @vis.make_foottext)
486
+ end
487
+
488
+ def test_hyphen_escape
489
+ assert_equal("&shy;&shy;", @vis.hyphen_escape("--"))
490
+ assert_equal("-", @vis.hyphen_escape("-"))
491
+ assert_equal("&shy;&shy;-", @vis.hyphen_escape("---"))
492
+ assert_equal("- -", @vis.hyphen_escape("- -"))
493
+ assert_equal("aa&shy;&shy;bb", @vis.hyphen_escape("aa--bb"))
494
+ assert_equal("", @vis.hyphen_escape(""))
495
+ end
496
+ end