qwik2md 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (335) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/README.md +36 -0
  6. data/Rakefile +10 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/exe/qwik2md +17 -0
  10. data/lib/qwik2md/version.rb +3 -0
  11. data/lib/qwik2md.rb +39 -0
  12. data/qwik2md.gemspec +30 -0
  13. data/vendor/qwik/AUTHORS +10 -0
  14. data/vendor/qwik/COPYING +340 -0
  15. data/vendor/qwik/COPYRIGHT +346 -0
  16. data/vendor/qwik/lib/qwik/Makefile +63 -0
  17. data/vendor/qwik/lib/qwik/Rakefile +17 -0
  18. data/vendor/qwik/lib/qwik/act-aa.rb +83 -0
  19. data/vendor/qwik/lib/qwik/act-archive.rb +386 -0
  20. data/vendor/qwik/lib/qwik/act-attach.rb +304 -0
  21. data/vendor/qwik/lib/qwik/act-backup.rb +236 -0
  22. data/vendor/qwik/lib/qwik/act-basic.rb +325 -0
  23. data/vendor/qwik/lib/qwik/act-book.rb +161 -0
  24. data/vendor/qwik/lib/qwik/act-calc.rb +371 -0
  25. data/vendor/qwik/lib/qwik/act-charset.rb +251 -0
  26. data/vendor/qwik/lib/qwik/act-christel.rb +112 -0
  27. data/vendor/qwik/lib/qwik/act-chronology.rb +149 -0
  28. data/vendor/qwik/lib/qwik/act-code.rb +155 -0
  29. data/vendor/qwik/lib/qwik/act-comment.rb +554 -0
  30. data/vendor/qwik/lib/qwik/act-config.rb +49 -0
  31. data/vendor/qwik/lib/qwik/act-counter.rb +125 -0
  32. data/vendor/qwik/lib/qwik/act-day.rb +96 -0
  33. data/vendor/qwik/lib/qwik/act-describe.rb +135 -0
  34. data/vendor/qwik/lib/qwik/act-diary.rb +109 -0
  35. data/vendor/qwik/lib/qwik/act-edit.rb +317 -0
  36. data/vendor/qwik/lib/qwik/act-embed-html.rb +296 -0
  37. data/vendor/qwik/lib/qwik/act-emode.rb +150 -0
  38. data/vendor/qwik/lib/qwik/act-event.rb +187 -0
  39. data/vendor/qwik/lib/qwik/act-file.rb +303 -0
  40. data/vendor/qwik/lib/qwik/act-files.rb +771 -0
  41. data/vendor/qwik/lib/qwik/act-getpass.rb +295 -0
  42. data/vendor/qwik/lib/qwik/act-history.rb +136 -0
  43. data/vendor/qwik/lib/qwik/act-html.rb +204 -0
  44. data/vendor/qwik/lib/qwik/act-httpauth.rb +147 -0
  45. data/vendor/qwik/lib/qwik/act-include.rb +142 -0
  46. data/vendor/qwik/lib/qwik/act-interwiki.rb +189 -0
  47. data/vendor/qwik/lib/qwik/act-isearch.rb +109 -0
  48. data/vendor/qwik/lib/qwik/act-keywords.rb +137 -0
  49. data/vendor/qwik/lib/qwik/act-lang.rb +81 -0
  50. data/vendor/qwik/lib/qwik/act-license.rb +63 -0
  51. data/vendor/qwik/lib/qwik/act-list.rb +287 -0
  52. data/vendor/qwik/lib/qwik/act-login.rb +410 -0
  53. data/vendor/qwik/lib/qwik/act-logout.rb +60 -0
  54. data/vendor/qwik/lib/qwik/act-mail.rb +159 -0
  55. data/vendor/qwik/lib/qwik/act-map.rb +292 -0
  56. data/vendor/qwik/lib/qwik/act-md5.rb +42 -0
  57. data/vendor/qwik/lib/qwik/act-mdlb.rb +741 -0
  58. data/vendor/qwik/lib/qwik/act-media.rb +416 -0
  59. data/vendor/qwik/lib/qwik/act-member.rb +157 -0
  60. data/vendor/qwik/lib/qwik/act-menu.rb +142 -0
  61. data/vendor/qwik/lib/qwik/act-metadata.rb +323 -0
  62. data/vendor/qwik/lib/qwik/act-mlsubmitform.rb +49 -0
  63. data/vendor/qwik/lib/qwik/act-monitor.rb +167 -0
  64. data/vendor/qwik/lib/qwik/act-new.rb +418 -0
  65. data/vendor/qwik/lib/qwik/act-pagelist.rb +248 -0
  66. data/vendor/qwik/lib/qwik/act-password.rb +145 -0
  67. data/vendor/qwik/lib/qwik/act-plan.rb +210 -0
  68. data/vendor/qwik/lib/qwik/act-povray.rb +230 -0
  69. data/vendor/qwik/lib/qwik/act-presen.rb +380 -0
  70. data/vendor/qwik/lib/qwik/act-redirect.rb +133 -0
  71. data/vendor/qwik/lib/qwik/act-ring.rb +1071 -0
  72. data/vendor/qwik/lib/qwik/act-rrefs.rb +255 -0
  73. data/vendor/qwik/lib/qwik/act-ruby.rb +116 -0
  74. data/vendor/qwik/lib/qwik/act-sample.rb +170 -0
  75. data/vendor/qwik/lib/qwik/act-save.rb +295 -0
  76. data/vendor/qwik/lib/qwik/act-schedule.rb +374 -0
  77. data/vendor/qwik/lib/qwik/act-search.rb +180 -0
  78. data/vendor/qwik/lib/qwik/act-searchwords.rb +51 -0
  79. data/vendor/qwik/lib/qwik/act-sendpass.rb +83 -0
  80. data/vendor/qwik/lib/qwik/act-site.rb +89 -0
  81. data/vendor/qwik/lib/qwik/act-sitebackup.rb +419 -0
  82. data/vendor/qwik/lib/qwik/act-sitelog.rb +118 -0
  83. data/vendor/qwik/lib/qwik/act-smil.rb +299 -0
  84. data/vendor/qwik/lib/qwik/act-status.rb +220 -0
  85. data/vendor/qwik/lib/qwik/act-style.rb +608 -0
  86. data/vendor/qwik/lib/qwik/act-table.rb +263 -0
  87. data/vendor/qwik/lib/qwik/act-tableform.rb +241 -0
  88. data/vendor/qwik/lib/qwik/act-tag.rb +103 -0
  89. data/vendor/qwik/lib/qwik/act-text.rb +70 -0
  90. data/vendor/qwik/lib/qwik/act-textarea.rb +164 -0
  91. data/vendor/qwik/lib/qwik/act-theme.rb +346 -0
  92. data/vendor/qwik/lib/qwik/act-toc.rb +112 -0
  93. data/vendor/qwik/lib/qwik/act-typekey.rb +198 -0
  94. data/vendor/qwik/lib/qwik/act-under-const.rb +94 -0
  95. data/vendor/qwik/lib/qwik/act-webservice.rb +321 -0
  96. data/vendor/qwik/lib/qwik/act-wema.rb +558 -0
  97. data/vendor/qwik/lib/qwik/act-wysiwyg.rb +238 -0
  98. data/vendor/qwik/lib/qwik/action.rb +325 -0
  99. data/vendor/qwik/lib/qwik/autoreload.rb +98 -0
  100. data/vendor/qwik/lib/qwik/bench-bench.rb +28 -0
  101. data/vendor/qwik/lib/qwik/bench-emode.rb +47 -0
  102. data/vendor/qwik/lib/qwik/bench-format-xml.rb +70 -0
  103. data/vendor/qwik/lib/qwik/bench-large-table.rb +62 -0
  104. data/vendor/qwik/lib/qwik/bench-md5.rb +14 -0
  105. data/vendor/qwik/lib/qwik/bench-module-session.rb +19 -0
  106. data/vendor/qwik/lib/qwik/bench-page.rb +50 -0
  107. data/vendor/qwik/lib/qwik/bench-s-md5.rb +28 -0
  108. data/vendor/qwik/lib/qwik/bench-session.rb +25 -0
  109. data/vendor/qwik/lib/qwik/bench-textformat.rb +31 -0
  110. data/vendor/qwik/lib/qwik/catalog-factory.rb +91 -0
  111. data/vendor/qwik/lib/qwik/catalog-ja.rb +479 -0
  112. data/vendor/qwik/lib/qwik/catalog-ml-ja.rb +145 -0
  113. data/vendor/qwik/lib/qwik/check-act-monitor.rb +112 -0
  114. data/vendor/qwik/lib/qwik/check-act-monitor2.rb +46 -0
  115. data/vendor/qwik/lib/qwik/check-act-theme.rb +27 -0
  116. data/vendor/qwik/lib/qwik/check-event.rb +112 -0
  117. data/vendor/qwik/lib/qwik/check-event2.rb +55 -0
  118. data/vendor/qwik/lib/qwik/check-htree-rexml.rb +77 -0
  119. data/vendor/qwik/lib/qwik/check-htree.rb +51 -0
  120. data/vendor/qwik/lib/qwik/check-libxml.rb +135 -0
  121. data/vendor/qwik/lib/qwik/check-many-pages.rb +47 -0
  122. data/vendor/qwik/lib/qwik/check-monitor.rb +33 -0
  123. data/vendor/qwik/lib/qwik/check-observer.rb +67 -0
  124. data/vendor/qwik/lib/qwik/check-server.rb +61 -0
  125. data/vendor/qwik/lib/qwik/check-uuencode.rb +33 -0
  126. data/vendor/qwik/lib/qwik/check-webdav.rb +65 -0
  127. data/vendor/qwik/lib/qwik/check-xml-xpath.rb +27 -0
  128. data/vendor/qwik/lib/qwik/common-backtrace.rb +94 -0
  129. data/vendor/qwik/lib/qwik/common-basic.rb +111 -0
  130. data/vendor/qwik/lib/qwik/common-condition.rb +142 -0
  131. data/vendor/qwik/lib/qwik/common-error.rb +48 -0
  132. data/vendor/qwik/lib/qwik/common-gettext.rb +50 -0
  133. data/vendor/qwik/lib/qwik/common-javascript.rb +45 -0
  134. data/vendor/qwik/lib/qwik/common-notice.rb +132 -0
  135. data/vendor/qwik/lib/qwik/common-plain.rb +105 -0
  136. data/vendor/qwik/lib/qwik/common-plugin.rb +111 -0
  137. data/vendor/qwik/lib/qwik/common-res.rb +76 -0
  138. data/vendor/qwik/lib/qwik/common-resolve.rb +92 -0
  139. data/vendor/qwik/lib/qwik/common-send.rb +171 -0
  140. data/vendor/qwik/lib/qwik/common-session.rb +139 -0
  141. data/vendor/qwik/lib/qwik/common-surface.rb +261 -0
  142. data/vendor/qwik/lib/qwik/common-url.rb +90 -0
  143. data/vendor/qwik/lib/qwik/compat/Makefile +12 -0
  144. data/vendor/qwik/lib/qwik/compat/add_load_path.rb +1 -0
  145. data/vendor/qwik/lib/qwik/config.rb +299 -0
  146. data/vendor/qwik/lib/qwik/db-b-backup.rb +142 -0
  147. data/vendor/qwik/lib/qwik/db-backup.rb +184 -0
  148. data/vendor/qwik/lib/qwik/db-berkeley.rb +306 -0
  149. data/vendor/qwik/lib/qwik/db-filesystem.rb +305 -0
  150. data/vendor/qwik/lib/qwik/db-indexer.rb +154 -0
  151. data/vendor/qwik/lib/qwik/db-searchwords.rb +238 -0
  152. data/vendor/qwik/lib/qwik/description-ja.rb +267 -0
  153. data/vendor/qwik/lib/qwik/description.rb +256 -0
  154. data/vendor/qwik/lib/qwik/dev-add-copyright.rb +23 -0
  155. data/vendor/qwik/lib/qwik/dev-backup.rb +24 -0
  156. data/vendor/qwik/lib/qwik/dev-bench.rb +175 -0
  157. data/vendor/qwik/lib/qwik/dev-calctime.rb +52 -0
  158. data/vendor/qwik/lib/qwik/dev-css-compressor.rb +60 -0
  159. data/vendor/qwik/lib/qwik/dev-extract-catalog.rb +102 -0
  160. data/vendor/qwik/lib/qwik/dev-js-compressor.rb +73 -0
  161. data/vendor/qwik/lib/qwik/dev-release.rb +235 -0
  162. data/vendor/qwik/lib/qwik/dev-replace.rb +353 -0
  163. data/vendor/qwik/lib/qwik/dev-sendmail.rb +25 -0
  164. data/vendor/qwik/lib/qwik/farm.rb +283 -0
  165. data/vendor/qwik/lib/qwik/gettext.rb +56 -0
  166. data/vendor/qwik/lib/qwik/group-cond.rb +157 -0
  167. data/vendor/qwik/lib/qwik/group-config.rb +247 -0
  168. data/vendor/qwik/lib/qwik/group-confirm.rb +147 -0
  169. data/vendor/qwik/lib/qwik/group-db.rb +326 -0
  170. data/vendor/qwik/lib/qwik/group-mail.rb +195 -0
  171. data/vendor/qwik/lib/qwik/group-member.rb +307 -0
  172. data/vendor/qwik/lib/qwik/group-sendmail.rb +231 -0
  173. data/vendor/qwik/lib/qwik/group-site.rb +374 -0
  174. data/vendor/qwik/lib/qwik/group-sweep.rb +63 -0
  175. data/vendor/qwik/lib/qwik/group.rb +157 -0
  176. data/vendor/qwik/lib/qwik/helper.rb +6 -0
  177. data/vendor/qwik/lib/qwik/html-generator.rb +104 -0
  178. data/vendor/qwik/lib/qwik/html-to-wabisabi.rb +148 -0
  179. data/vendor/qwik/lib/qwik/htree-diff.rb +87 -0
  180. data/vendor/qwik/lib/qwik/htree-format-xml.rb +57 -0
  181. data/vendor/qwik/lib/qwik/htree-generator.rb +144 -0
  182. data/vendor/qwik/lib/qwik/htree-get.rb +251 -0
  183. data/vendor/qwik/lib/qwik/htree-html-generator.rb +179 -0
  184. data/vendor/qwik/lib/qwik/htree-template.rb +263 -0
  185. data/vendor/qwik/lib/qwik/htree-to-wabisabi.rb +171 -0
  186. data/vendor/qwik/lib/qwik/loadlib.rb +79 -0
  187. data/vendor/qwik/lib/qwik/logger.rb +115 -0
  188. data/vendor/qwik/lib/qwik/mail-body.rb +171 -0
  189. data/vendor/qwik/lib/qwik/mail-header.rb +474 -0
  190. data/vendor/qwik/lib/qwik/mail-multipart.rb +193 -0
  191. data/vendor/qwik/lib/qwik/mail-parse.rb +147 -0
  192. data/vendor/qwik/lib/qwik/mail.rb +341 -0
  193. data/vendor/qwik/lib/qwik/mailaddress.rb +83 -0
  194. data/vendor/qwik/lib/qwik/mdlb-model.rb +81 -0
  195. data/vendor/qwik/lib/qwik/mdlb-sample.rb +324 -0
  196. data/vendor/qwik/lib/qwik/ml-catalog-factory.rb +27 -0
  197. data/vendor/qwik/lib/qwik/ml-exception.rb +15 -0
  198. data/vendor/qwik/lib/qwik/ml-generator.rb +28 -0
  199. data/vendor/qwik/lib/qwik/ml-gettext.rb +137 -0
  200. data/vendor/qwik/lib/qwik/ml-logger.rb +82 -0
  201. data/vendor/qwik/lib/qwik/ml-memory.rb +65 -0
  202. data/vendor/qwik/lib/qwik/ml-msg-validator.rb +86 -0
  203. data/vendor/qwik/lib/qwik/ml-processor.rb +609 -0
  204. data/vendor/qwik/lib/qwik/ml-quickml-server.rb +122 -0
  205. data/vendor/qwik/lib/qwik/ml-sendmail.rb +0 -0
  206. data/vendor/qwik/lib/qwik/ml-server.rb +107 -0
  207. data/vendor/qwik/lib/qwik/ml-session.rb +348 -0
  208. data/vendor/qwik/lib/qwik/ml-sweeper.rb +101 -0
  209. data/vendor/qwik/lib/qwik/mock-logger.rb +65 -0
  210. data/vendor/qwik/lib/qwik/mock-sendmail.rb +78 -0
  211. data/vendor/qwik/lib/qwik/mock-socket.rb +82 -0
  212. data/vendor/qwik/lib/qwik/modulobe.rb +406 -0
  213. data/vendor/qwik/lib/qwik/mongrel-server.rb +72 -0
  214. data/vendor/qwik/lib/qwik/page-files.rb +249 -0
  215. data/vendor/qwik/lib/qwik/page-generate.rb +82 -0
  216. data/vendor/qwik/lib/qwik/page-get.rb +262 -0
  217. data/vendor/qwik/lib/qwik/page-images.rb +168 -0
  218. data/vendor/qwik/lib/qwik/page-put.rb +128 -0
  219. data/vendor/qwik/lib/qwik/page-rrefs.rb +154 -0
  220. data/vendor/qwik/lib/qwik/page-title.rb +0 -0
  221. data/vendor/qwik/lib/qwik/page-wikidb.rb +234 -0
  222. data/vendor/qwik/lib/qwik/page.rb +67 -0
  223. data/vendor/qwik/lib/qwik/pages.rb +444 -0
  224. data/vendor/qwik/lib/qwik/parse-plugin.rb +249 -0
  225. data/vendor/qwik/lib/qwik/parser-emode.rb +116 -0
  226. data/vendor/qwik/lib/qwik/parser-inline.rb +272 -0
  227. data/vendor/qwik/lib/qwik/parser.rb +349 -0
  228. data/vendor/qwik/lib/qwik/password.rb +183 -0
  229. data/vendor/qwik/lib/qwik/periodic.rb +79 -0
  230. data/vendor/qwik/lib/qwik/qp.rb +56 -0
  231. data/vendor/qwik/lib/qwik/qwik-service.rb +341 -0
  232. data/vendor/qwik/lib/qwik/qwik.rb +5 -0
  233. data/vendor/qwik/lib/qwik/qwikweb-adduser.rb +34 -0
  234. data/vendor/qwik/lib/qwik/qwikweb-catalog-validator.rb +110 -0
  235. data/vendor/qwik/lib/qwik/qwikweb-incgen.rb +28 -0
  236. data/vendor/qwik/lib/qwik/qwikweb-makesite.rb +41 -0
  237. data/vendor/qwik/lib/qwik/qwikweb-server.rb +44 -0
  238. data/vendor/qwik/lib/qwik/qwikweb-showpassword.rb +26 -0
  239. data/vendor/qwik/lib/qwik/qwikweb-watchlog.rb +67 -0
  240. data/vendor/qwik/lib/qwik/request-path.rb +304 -0
  241. data/vendor/qwik/lib/qwik/request-ua.rb +76 -0
  242. data/vendor/qwik/lib/qwik/request-webrick.rb +81 -0
  243. data/vendor/qwik/lib/qwik/request.rb +91 -0
  244. data/vendor/qwik/lib/qwik/resolve-tdiary.rb +292 -0
  245. data/vendor/qwik/lib/qwik/resolve.rb +121 -0
  246. data/vendor/qwik/lib/qwik/response.rb +228 -0
  247. data/vendor/qwik/lib/qwik/server-memory.rb +57 -0
  248. data/vendor/qwik/lib/qwik/server-webrick.rb +102 -0
  249. data/vendor/qwik/lib/qwik/server.rb +252 -0
  250. data/vendor/qwik/lib/qwik/site-config.rb +149 -0
  251. data/vendor/qwik/lib/qwik/site-db.rb +136 -0
  252. data/vendor/qwik/lib/qwik/site-event.rb +162 -0
  253. data/vendor/qwik/lib/qwik/site-files.rb +86 -0
  254. data/vendor/qwik/lib/qwik/site-group.rb +103 -0
  255. data/vendor/qwik/lib/qwik/site-index.rb +47 -0
  256. data/vendor/qwik/lib/qwik/site-log.rb +64 -0
  257. data/vendor/qwik/lib/qwik/site-member.rb +230 -0
  258. data/vendor/qwik/lib/qwik/site-monitor.rb +97 -0
  259. data/vendor/qwik/lib/qwik/site-pages.rb +62 -0
  260. data/vendor/qwik/lib/qwik/site-plan.rb +139 -0
  261. data/vendor/qwik/lib/qwik/site-report.rb +282 -0
  262. data/vendor/qwik/lib/qwik/site-resolve.rb +230 -0
  263. data/vendor/qwik/lib/qwik/site-rrefs.rb +18 -0
  264. data/vendor/qwik/lib/qwik/site-search.rb +180 -0
  265. data/vendor/qwik/lib/qwik/site-timeline.rb +153 -0
  266. data/vendor/qwik/lib/qwik/site-url.rb +189 -0
  267. data/vendor/qwik/lib/qwik/site.rb +76 -0
  268. data/vendor/qwik/lib/qwik/smil-time.rb +105 -0
  269. data/vendor/qwik/lib/qwik/smtp-session.rb +331 -0
  270. data/vendor/qwik/lib/qwik/template-generator.rb +149 -0
  271. data/vendor/qwik/lib/qwik/template.rb +85 -0
  272. data/vendor/qwik/lib/qwik/test-common.rb +10 -0
  273. data/vendor/qwik/lib/qwik/test-ml-info.rb +225 -0
  274. data/vendor/qwik/lib/qwik/test-module-ml.rb +142 -0
  275. data/vendor/qwik/lib/qwik/test-module-path.rb +110 -0
  276. data/vendor/qwik/lib/qwik/test-module-public.rb +70 -0
  277. data/vendor/qwik/lib/qwik/test-module-server.rb +98 -0
  278. data/vendor/qwik/lib/qwik/test-module-session.rb +264 -0
  279. data/vendor/qwik/lib/qwik/test-module-suite.rb +91 -0
  280. data/vendor/qwik/lib/qwik/test-ms-applemail.rb +59 -0
  281. data/vendor/qwik/lib/qwik/test-ms-attach.rb +174 -0
  282. data/vendor/qwik/lib/qwik/test-ms-basic.rb +40 -0
  283. data/vendor/qwik/lib/qwik/test-ms-close.rb +35 -0
  284. data/vendor/qwik/lib/qwik/test-ms-confirm.rb +75 -0
  285. data/vendor/qwik/lib/qwik/test-ms-ignore-spam.rb +57 -0
  286. data/vendor/qwik/lib/qwik/test-ms-japanese.rb +97 -0
  287. data/vendor/qwik/lib/qwik/test-ms-jfilename.rb +82 -0
  288. data/vendor/qwik/lib/qwik/test-ms-large.rb +58 -0
  289. data/vendor/qwik/lib/qwik/test-ms-member.rb +103 -0
  290. data/vendor/qwik/lib/qwik/test-ms-multipart.rb +84 -0
  291. data/vendor/qwik/lib/qwik/test-ms-org.rb +129 -0
  292. data/vendor/qwik/lib/qwik/test-ms-plan.rb +130 -0
  293. data/vendor/qwik/lib/qwik/test-ms-post.rb +53 -0
  294. data/vendor/qwik/lib/qwik/test-ms-quopri.rb +76 -0
  295. data/vendor/qwik/lib/qwik/test-sub-quopri.rb +45 -0
  296. data/vendor/qwik/lib/qwik/test-submit-base64.rb +59 -0
  297. data/vendor/qwik/lib/qwik/test-submit-forward.rb +61 -0
  298. data/vendor/qwik/lib/qwik/test-submit-html-mail.rb +52 -0
  299. data/vendor/qwik/lib/qwik/test-submit-japanese.rb +135 -0
  300. data/vendor/qwik/lib/qwik/test-submit-jfilename.rb +144 -0
  301. data/vendor/qwik/lib/qwik/test-submit-uuencode.rb +71 -0
  302. data/vendor/qwik/lib/qwik/test-suite-all.rb +8 -0
  303. data/vendor/qwik/lib/qwik/test-suite-basic.rb +9 -0
  304. data/vendor/qwik/lib/qwik/test-suite-ml.rb +9 -0
  305. data/vendor/qwik/lib/qwik/test-typekey.rb +64 -0
  306. data/vendor/qwik/lib/qwik/testunit.rb +45 -0
  307. data/vendor/qwik/lib/qwik/tokenizer-inline.rb +288 -0
  308. data/vendor/qwik/lib/qwik/tokenizer.rb +331 -0
  309. data/vendor/qwik/lib/qwik/typekey.rb +160 -0
  310. data/vendor/qwik/lib/qwik/util-basic.rb +135 -0
  311. data/vendor/qwik/lib/qwik/util-charset.rb +331 -0
  312. data/vendor/qwik/lib/qwik/util-css.rb +56 -0
  313. data/vendor/qwik/lib/qwik/util-csv-tokenizer.rb +113 -0
  314. data/vendor/qwik/lib/qwik/util-filename.rb +112 -0
  315. data/vendor/qwik/lib/qwik/util-pathname.rb +202 -0
  316. data/vendor/qwik/lib/qwik/util-pid.rb +58 -0
  317. data/vendor/qwik/lib/qwik/util-safe.rb +67 -0
  318. data/vendor/qwik/lib/qwik/util-sendmail.rb +273 -0
  319. data/vendor/qwik/lib/qwik/util-string.rb +202 -0
  320. data/vendor/qwik/lib/qwik/util-time.rb +125 -0
  321. data/vendor/qwik/lib/qwik/util-webrick.rb +176 -0
  322. data/vendor/qwik/lib/qwik/version.rb +11 -0
  323. data/vendor/qwik/lib/qwik/wabisabi-basic.rb +163 -0
  324. data/vendor/qwik/lib/qwik/wabisabi-diff.rb +130 -0
  325. data/vendor/qwik/lib/qwik/wabisabi-format-xml.rb +310 -0
  326. data/vendor/qwik/lib/qwik/wabisabi-generator.rb +262 -0
  327. data/vendor/qwik/lib/qwik/wabisabi-index.rb +174 -0
  328. data/vendor/qwik/lib/qwik/wabisabi-table.rb +212 -0
  329. data/vendor/qwik/lib/qwik/wabisabi-template.rb +295 -0
  330. data/vendor/qwik/lib/qwik/wabisabi-to-htree.rb +111 -0
  331. data/vendor/qwik/lib/qwik/wabisabi-to-wiki.rb +690 -0
  332. data/vendor/qwik/lib/qwik/wabisabi-traverse.rb +207 -0
  333. data/vendor/qwik/lib/qwik/wabisabi-validator.rb +116 -0
  334. data/vendor/qwik/lib/qwik/wabisabi.rb +5 -0
  335. metadata +492 -0
@@ -0,0 +1,741 @@
1
+ # -*- coding: shift_jis -*-
2
+ # Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
3
+ # This is free software with ABSOLUTELY NO WARRANTY.
4
+ # You can redistribute it and/or modify it under the terms of the GNU GPL 2.
5
+
6
+ # special mode for modulobe.com
7
+
8
+ $LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
9
+ require 'qwik/modulobe'
10
+ require 'qwik/act-metadata'
11
+ require 'qwik/act-files'
12
+
13
+ module Qwik
14
+ class Action
15
+ # ============================== model
16
+ MODULOBE_MODEL_STYLE = '
17
+
18
+ /* ==================== modulobe model */
19
+ div.modulobe_model {
20
+ margin: 1em 0;
21
+ padding: 10px;
22
+ border: 1px solid #999;
23
+ background-color: #fff;
24
+ }
25
+
26
+ div.modulobe_model table {
27
+ margin: 0;
28
+ width: 100%;
29
+ border: 0;
30
+ }
31
+
32
+ div.modulobe_model td {
33
+ margin: 0;
34
+ padding: 0;
35
+ border: 0;
36
+ line-height: 1.0;
37
+ }
38
+
39
+ div.modulobe_model td.img {
40
+ margin: 0;
41
+ border: 0;
42
+ text-align: center;
43
+ }
44
+
45
+ div.modulobe_model td.img a {
46
+ text-decoration: none;
47
+ border-bottom: 0;
48
+ }
49
+
50
+ div.modulobe_model td.img img {
51
+ border: 0;
52
+ }
53
+
54
+ div.modulobe_model td.desc {
55
+ border: 0;
56
+ }
57
+
58
+ div.modulobe_model td.desc h3 {
59
+ border-bottom: 0;
60
+ margin: 0;
61
+ padding: 0;
62
+ left: 0;
63
+ color: #393;
64
+ }
65
+
66
+ div.modulobe_model td.desc p {
67
+ margin: 0;
68
+ padding: 0;
69
+ line-height: 1.33;
70
+ }
71
+
72
+ div.modulobe_model td.desc strong {
73
+ color: #060;
74
+ font-weight: normal;
75
+ }
76
+
77
+ '
78
+
79
+ def plg_modulobe_model(model)
80
+ div = [:div, {:class=>'modulobe_model'}]
81
+
82
+ # image
83
+ files = @site.files(@req.base)
84
+ file = files.path(model)
85
+
86
+ return [:div, 'No file exist.'] if ! file.exist?
87
+ model = Modulobe::ModelFile.new(file)
88
+
89
+ href, url, img = model.prepare_link(self, "#{@req.base}.files")
90
+
91
+ # description
92
+ content = yield
93
+ #tokens = c_tokenize(content)
94
+ tokens = TextTokenizer.tokenize(content)
95
+
96
+ author = 'anonymous'
97
+ title = 'no title'
98
+ comment = 'no comment'
99
+ tokens.each {|token|
100
+ if token[0] == :dl
101
+ author = token[2] if token[1] == 'author'
102
+ title = token[2] if token[1] == 'title'
103
+ comment = token[2] if token[1] == 'comment'
104
+ end
105
+ }
106
+
107
+ comment.gsub!(/\\n/, "\n")
108
+ comment = c_res(comment)
109
+
110
+ desc = [[:h3, [:a, {:href=>href}, title]],
111
+ [:p, _('Author'), ': ', [:strong, author]],
112
+ [:p, comment]]
113
+
114
+ table = [:table, [:tr,
115
+ [:td, {:class=>'img'}, img],
116
+ [:td, {:class=>'desc'}, desc]]]
117
+
118
+ div << table
119
+
120
+ if ! defined?(@modulobe_model_style)
121
+ @modulobe_model_style = true
122
+ div << [:style, MODULOBE_MODEL_STYLE]
123
+ end
124
+
125
+ return div
126
+ end
127
+
128
+ # ============================== list
129
+ def plg_modulobe_model_list
130
+ pagename = @req.base
131
+ page = @site[pagename]
132
+ return if page.nil?
133
+
134
+ files = @site.files(pagename)
135
+ page.cache[:modellist] ||= Modulobe::ModelList.new(files)
136
+ modellist = page.cache[:modellist]
137
+ return if modellist.empty?
138
+
139
+ div = [:div, {:class=>'files'}]
140
+ path = c_relative_to_root(pagename+'.files')
141
+ div << modellist.get_table(self, path)
142
+ div << modellist.get_style
143
+ return div
144
+ end
145
+
146
+ # ============================== rss
147
+ # Called from act-metadata.rb
148
+ def metadata_model_xml
149
+ # Check pages that has .mdlb file.
150
+ page_keys = Hash.new(0)
151
+ @site.each {|page|
152
+ files = @site.files(page.key)
153
+ files.each {|filename|
154
+ if /\.mdlb\z/ =~ filename
155
+ page_keys[page.key] += 1
156
+ end
157
+ }
158
+ }
159
+
160
+ # Collect model files and check last_time.
161
+ last_time = nil
162
+ models = []
163
+ page_keys.keys.sort.each {|key|
164
+ page = @site[key]
165
+ str = page.load
166
+ tokens = TextTokenizer.tokenize(str)
167
+ tokens.each {|token|
168
+ if token[0] == :plugin && token[1] == 'modulobe_model'
169
+ filename = token[2]
170
+ files = @site.files(page.key)
171
+ file = files.path(filename)
172
+ mtime = file.mtime
173
+ last_time = mtime if last_time.nil? || last_time < mtime
174
+
175
+ content = token[3]
176
+ content_tokens = TextTokenizer.tokenize(content)
177
+ title = author = comment = nil
178
+ content_tokens.each {|ctoken|
179
+ next if ctoken[0] != :dl
180
+ title = ctoken[2] if ctoken[1] == 'title'
181
+ author = ctoken[2] if ctoken[1] == 'author'
182
+ comment = ctoken[2] if ctoken[1] == 'comment'
183
+ }
184
+
185
+ title ||= 'no title'
186
+ author ||= 'no name'
187
+ comment ||= 'no comment'
188
+ models << [mtime, page, file, title, author, comment]
189
+ end
190
+ }
191
+ }
192
+
193
+ xml = []
194
+ xml << [:'?xml', '1.0', 'utf-8']
195
+ rss = [:rss, {:version=>'2.0', :'xmlns:creativeCommons'=>
196
+ 'http://backend.userland.com/creativeCommonsRssModule'}]
197
+
198
+ top_url = c_relative_to_absolute('/')
199
+ channel = [:channel,
200
+ [:title, 'Modulobe model gallery'],
201
+ [:link, top_url],
202
+ [:description, 'This is a model list of Modulobe Wiki.'],
203
+ [:language, 'ja'],
204
+ [:managingEditor, 'modulobe@qwik.jp'],
205
+ [:webMaster, 'modulobe@qwik.jp'],
206
+ [:lastBuildDate, last_time.rfc1123_date],
207
+ [:ttl, '60']]
208
+
209
+ models.sort.each {|mtime, page, file, title, author, comment|
210
+ basename = file.basename
211
+ url = c_relative_to_absolute(page.key+'.files/'+basename)
212
+
213
+ # Check thumb is exist.
214
+ thumb_file = file.dirname+'.thumb'+(file.basename('.mdlb').to_s+'.gif')
215
+ if ! thumb_file.exist?
216
+ # make it.
217
+ end
218
+
219
+ thumb = page.key+'.files/.thumb/'+file.basename('.mdlb').to_s+'.gif'
220
+ thumb_url = c_relative_to_absolute(thumb)
221
+ html = "<p><img src=\"#{thumb_url}\" alt=\"#{title}\" width=\"100\" height=\"75\"/><p>#{comment}</p>"
222
+
223
+ length = file.size
224
+
225
+ item = [:item,
226
+ [:title, title],
227
+ [:link, url],
228
+ [:description, html],
229
+ [:author, author],
230
+ [:pubDate, mtime.rfc1123_date],
231
+ [:enclosure,
232
+ {:url=>url, :length=>length, :type=>'application/xml'}],
233
+ [:'creativeCommons:license',
234
+ 'http://creativecommons.org/licenses/by/2.1/jp/']]
235
+ channel << item
236
+ }
237
+
238
+ rss << channel
239
+ xml << rss
240
+
241
+ return xml
242
+ end
243
+
244
+ def pre_ext_mdlbrss
245
+ xml = []
246
+ xml << [:'?xml', '1.0', 'utf-8']
247
+ rss = [:rss, {:version=>'2.0'}]
248
+
249
+ moved_url = c_relative_to_absolute('/model.xml')
250
+ channel = [:channel,
251
+ [:title, 'moved'],
252
+ [:link, moved_url],
253
+ [:description, 'moved.'],
254
+ [:lastBuildDate, Time.at(0).rfc1123_date],
255
+ [:ttl, '60']]
256
+
257
+ item = [:item,
258
+ [:title, 'moved'],
259
+ [:link, moved_url],
260
+ [:description, 'moved'],
261
+ [:pubDate, Time.at(0).rfc1123_date]]
262
+ channel << item
263
+
264
+ rss << channel
265
+
266
+ xml << rss
267
+
268
+ @res['Content-Type'] = 'application/xml'
269
+ @res.body = xml
270
+ @res.body = @res.body.format_xml.page_to_xml if ! @config.test
271
+ return nil
272
+ end
273
+
274
+ # ============================== upload
275
+ def plg_modulobe_files_form(pagename=nil)
276
+ base = @req.base
277
+ base = pagename if pagename
278
+ ar = []
279
+ ar << [:style, '
280
+ div.modulobe_uploader {
281
+ margin: 10px 0;
282
+ padding: 10px;
283
+ border: 1px solid #ccc;
284
+ background-color: #fff;
285
+ }
286
+ div.modulobe_uploader table {
287
+ margin: 0;
288
+ padding: 0;
289
+ border: 0;
290
+ width: 100%;
291
+ }
292
+ div.modulobe_uploader td,
293
+ div.modulobe_uploader th {
294
+ margin: 0;
295
+ padding: 2px 10px;
296
+ border: 0;
297
+ }
298
+ div.modulobe_uploader th {
299
+ text-align: right;
300
+ }
301
+ div.modulobe_uploader td input {
302
+ font-size: small;
303
+ }
304
+ ']
305
+ ar << [:div, {:class=>'modulobe_uploader'},
306
+ [:form, {:method=>'POST', :action=>base+'.modulobe_files_upload',
307
+ :enctype=>'multipart/form-data'},
308
+ [:table,
309
+ [:tr, [:th, _('Model file'), ' : '],
310
+ [:td, [:input, {:type=>'file', :name=>'content', :size=>'30'}]]],
311
+ [:tr, [:th, _('Image file'), ' : '],
312
+ [:td, [:input, {:type=>'file', :name=>'image', :size=>'30'}]]],
313
+ [:tr, [:td, ''],
314
+ [:td, [:input, {:type=>'submit', :value=>_('Attach')}]]]]]]
315
+ return ar
316
+ end
317
+
318
+ def ext_modulobe_files_upload
319
+ content = @req.query['content'] # WEBrick::HTTPUtils::FormData
320
+ image = @req.query['image']
321
+ return modulobe_files_put(content, image) if content
322
+ return modulobe_files_error(_('Please specify file.'))
323
+ end
324
+
325
+ def modulobe_files_put(content, image)
326
+ c_require_post
327
+
328
+ files = @site.files(@req.base)
329
+
330
+ fullfilename = content.filename
331
+ if fullfilename.empty?
332
+ return modulobe_files_error(_('Please contact the administrator.'))
333
+ end
334
+
335
+ # Get basename.
336
+ filename = fullfilename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 }
337
+
338
+ result_filename = files.fput(filename, content)
339
+
340
+ list = []
341
+ if filename == result_filename
342
+ list << [:p, [:strong, filename], ' : ', _('The file is saved.')]
343
+ else
344
+ list << [:p, [:strong, filename], ' -> ', [:strong, result_filename],
345
+ ' : ', _('The file is saved with this filename.')]
346
+ end
347
+
348
+ if image
349
+ img_fullfilename = image.filename
350
+ if img_fullfilename && ! img_fullfilename.empty?
351
+ img_filename = img_fullfilename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 }
352
+ ext = Filename.extname(img_filename)
353
+ if ext == 'gif'
354
+ img_filename = File.basename(result_filename, '.mdlb')+'.gif'
355
+ files.put(img_filename, image)
356
+ list << [:p, _('The image is also saved.')]
357
+ end
358
+ end
359
+ end
360
+
361
+ c_make_log('modulobe file attach') # Modulobe FILE ATTACH
362
+
363
+ files = @site.files(@req.base)
364
+ file = files.path(result_filename)
365
+ model = Modulobe::ModelFile.new(file)
366
+ model.get_internal_info
367
+ name = model.name
368
+ author = model.author
369
+ comment = model.comment
370
+ comment ||= ''
371
+ comment.gsub!(/\n/, "\\n")
372
+
373
+ page = @site[@req.base]
374
+ v = page.load
375
+ page.add("
376
+ * #{name}
377
+ {{modulobe_model(#{result_filename})
378
+ :title: #{name}
379
+ :author: #{author}
380
+ :comment: #{comment}
381
+ }}
382
+ {{mcomment}}
383
+
384
+ ")
385
+
386
+ list << [:hr]
387
+ url = @req.base+'.html'
388
+ list << [:p,_('Go next'),' : ',[:a,{:href=>url},url]]
389
+ return c_surface(_('File attachment completed')){list}
390
+ end
391
+
392
+ def modulobe_files_error(msg)
393
+ return c_surface(_('Error')){
394
+ [[:h2, {:style=>'margin:2em;text-align:center;'},
395
+ msg],
396
+ [:p, {:style=>'margin:2em;text-align:center;'},
397
+ [:a, {:href=>@req.base+'.html'}, _('Go back')]]]
398
+ }
399
+ end
400
+
401
+ end
402
+ end
403
+
404
+ if $0 == __FILE__
405
+ require 'qwik/test-common'
406
+ $test = true
407
+ end
408
+
409
+ if defined?($test) && $test
410
+ class TestActModulobe < Test::Unit::TestCase
411
+ include TestSession
412
+ include Modulobe::Sample
413
+
414
+ # ============================== model
415
+ def test_model
416
+ t_add_user
417
+
418
+ # test_modulobe_model
419
+ page = @site.create('c')
420
+ page.store('{{modulobe_model(test1.mdlb)
421
+ :author: Modulobe Project
422
+ :title: Test1 Model
423
+ :comment: This is a sample model by Modulobe Project.
424
+
425
+ http://www.modulobe.com/
426
+
427
+ }}
428
+ {{hcomment}}
429
+ ')
430
+
431
+ model = MODULOBE_TEST_MODEL
432
+ @site.files('c').put('test1.mdlb', model, nil, 0)
433
+ image = TEST_PNG_DATA
434
+ @site.files('c').put('test1.gif', image, nil, 1)
435
+
436
+ res = session('/test/c.html')
437
+ ok_xp([:table,
438
+ [:tr,
439
+ [:td, {:class=>'img'},
440
+ [:a, {:href=>'c.files/test1.mdlb'},
441
+ [:img, {:src=>'c.files/.thumb/test1.gif'}]]],
442
+ [:td, {:class=>'desc'},
443
+ [[:h3, [:a, {:href=>'c.files/test1.mdlb'}, 'Test1 Model']],
444
+ [:p, 'Author', ': ', [:strong, 'Modulobe Project']],
445
+ [:p, [[:p,
446
+ 'This is a sample model by Modulobe Project.']]]]]]],
447
+ "//div[@class='modulobe_model']/table")
448
+ end
449
+
450
+ def test_with_minus
451
+ t_add_user
452
+
453
+ page = @site.create('c')
454
+ page.store('{{modulobe_model(test-2.mdlb)
455
+ :author: Modulobe Project
456
+ :title: Test-2 Model
457
+ :comment: This is a sample.
458
+ }}
459
+ {{hcomment}}
460
+ ')
461
+
462
+ model = MODULOBE_TEST_MODEL
463
+ @site.files('c').put('test-2.mdlb', model, nil, 0)
464
+ image = TEST_PNG_DATA
465
+ @site.files('c').put('test-2.gif', image, nil, 1)
466
+
467
+ res = session('/test/c.html')
468
+ ok_xp([:table,
469
+ [:tr,
470
+ [:td, {:class=>'img'},
471
+ [:a, {:href=>'c.files/test-2.mdlb'},
472
+ [:img, {:src=>'c.files/.thumb/test-2.gif'}]]],
473
+ [:td, {:class=>'desc'},
474
+ [[:h3, [:a, {:href=>'c.files/test-2.mdlb'}, 'Test-2 Model']],
475
+ [:p, 'Author', ': ', [:strong, 'Modulobe Project']],
476
+ [:p, [[:p,
477
+ 'This is a sample.']]]]]]],
478
+ "//div[@class='modulobe_model']/table")
479
+ end
480
+
481
+ # ============================== list
482
+ def test_modulobe_list
483
+ t_add_user
484
+
485
+ # test_modulobe_model_list
486
+ page = @site.create('c')
487
+
488
+ model = MODULOBE_TEST_MODEL1
489
+ @site.files('c').put('test1.mdlb', model, nil, 0)
490
+ image = TEST_PNG_DATA
491
+ @site.files('c').put('test1.gif', image, nil, 1)
492
+
493
+ page.store("{{modulobe_model_list}}")
494
+ res = session('/test/c.html')
495
+ list = res.body.get_path("//div[@class='files']")
496
+ ok_xp([:tr, {:class=>'model'},
497
+ [:td, [:a, {:href=>'c.files/test1.mdlb'},
498
+ [:img, {:src=>'c.files/.thumb/test1.gif'}]]],
499
+ [:td, [:div, {:class=>'author'}, 'Alice'],
500
+ [:div, {:class=>'name'},
501
+ [:a, {:href=>'c.files/test1.mdlb'}, 't1 model']],
502
+ [:pre, {:class=>'comment'}, "This is a comment.\n"]]],
503
+ "//div[@class='files']/table/tr[2]")
504
+ end
505
+
506
+ # ============================== rss
507
+ def setup_models
508
+ t_add_user
509
+
510
+ # Prepare a page.
511
+ page = @site.create('a')
512
+ page.store("* a
513
+ * t1 model
514
+ {{modulobe_model(test1.mdlb)
515
+ :title: t1 model
516
+ :author: Alice
517
+ :comment: This is a comment.\n
518
+ }}
519
+ {{hcomment}}
520
+ ")
521
+ files = @site.files('a')
522
+ files.put('test1.mdlb', MODULOBE_TEST_MODEL1, nil, 0)
523
+ files.put('test1.gif', TEST_PNG_DATA, nil, 1)
524
+
525
+ # Prepare another page.
526
+ page = @site.create('b')
527
+ page.store("* b
528
+ * t2 model
529
+ {{modulobe_model(test2.mdlb)
530
+ :title: t2 model
531
+ :author: Bob
532
+ :comment: This is a comment, too.\n
533
+ }}
534
+ {{hcomment}}
535
+ ")
536
+ files = @site.files('b')
537
+ files.put('test2.mdlb', MODULOBE_TEST_MODEL2, nil, 2)
538
+ files.put('test2.gif', TEST_PNG_DATA, nil, 3)
539
+ end
540
+
541
+ def test_ext_mdlbrss
542
+ setup_models
543
+ res = session('/test/nosuch.mdlbrss')
544
+ ok_xp([:title, 'moved'], '//title')
545
+ res = session('/test/a.mdlbrss')
546
+ ok_eq([[:'?xml', '1.0', 'utf-8'],
547
+ [:rss,
548
+ {:version=>'2.0'},
549
+ [:channel,
550
+ [:title, 'moved'],
551
+ [:link, 'http://example.com/model.xml'],
552
+ [:description, 'moved.'],
553
+ [:lastBuildDate, 'Thu, 01 Jan 1970 09:00:00 GMT'],
554
+ [:ttl, '60'],
555
+ [:item,
556
+ [:title, 'moved'],
557
+ [:link, 'http://example.com/model.xml'],
558
+ [:description, 'moved'],
559
+ [:pubDate, 'Thu, 01 Jan 1970 09:00:00 GMT']]]]],
560
+ res.body)
561
+ end
562
+
563
+ def nu_test_metadata_model_xml
564
+ setup_models
565
+ res = session('/test/model.xml')
566
+ ok_eq([[:'?xml', '1.0', 'utf-8'],
567
+ [:rss, {:'xmlns:creativeCommons'=>
568
+ 'http://backend.userland.com/creativeCommonsRssModule',
569
+ :version=>'2.0'},
570
+ [:channel,
571
+ [:title, 'Modulobe model gallery'],
572
+ [:link, 'http://example.com/'],
573
+ [:description, 'This is a model list of Modulobe Wiki.'],
574
+ [:language, 'ja'],
575
+ [:managingEditor, 'modulobe@qwik.jp'],
576
+ [:webMaster, 'modulobe@qwik.jp'],
577
+ [:lastBuildDate, 'Thu, 01 Jan 1970 09:00:02 GMT'],
578
+ [:ttl, '60'],
579
+ [:item,
580
+ [:title, 't1 model'],
581
+ [:link, 'http://example.com/test/a.files/test1.mdlb'],
582
+ [:description,
583
+ "<p><img src=\"http://example.com/test/a.files/.thumb/test1.gif\" alt=\"t1 model\" width=\"100\" height=\"75\"/><p>This is a comment.</p>"],
584
+ [:author, 'Alice'],
585
+ [:pubDate, 'Thu, 01 Jan 1970 09:00:00 GMT'],
586
+ [:enclosure,
587
+ {:url=>'http://example.com/test/a.files/test1.mdlb',
588
+ :length=>563, :type=>'application/xml'}],
589
+ [:'creativeCommons:license',
590
+ 'http://creativecommons.org/licenses/by/2.1/jp/']],
591
+ [:item,
592
+ [:title, 't2 model'],
593
+ [:link, 'http://example.com/test/b.files/test2.mdlb'],
594
+ [:description,
595
+ "<p><img src=\"http://example.com/test/b.files/.thumb/test2.gif\" alt=\"t2 model\" width=\"100\" height=\"75\"/><p>This is a comment, too.</p>"],
596
+ [:author, 'Bob'],
597
+ [:pubDate, 'Thu, 01 Jan 1970 09:00:02 GMT'],
598
+ [:enclosure,
599
+ {:url=>'http://example.com/test/b.files/test2.mdlb',
600
+ :length=>1395, :type=>'application/xml'}],
601
+ [:'creativeCommons:license',
602
+ 'http://creativecommons.org/licenses/by/2.1/jp/']]]]],
603
+ res.body)
604
+ end
605
+
606
+ # ============================== upload
607
+ def prepare(con, im)
608
+ content = WEBrick::HTTPUtils::FormData.new(MODULOBE_TEST_MODEL)
609
+ content.filename = con
610
+ image = WEBrick::HTTPUtils::FormData.new(TEST_PNG_DATA)
611
+ image.filename = im
612
+ return content, image
613
+ end
614
+
615
+ def test_upload
616
+ t_add_user
617
+
618
+ # test_modulobe_files_form
619
+ page = @site.create('c')
620
+ page.store('{{modulobe_files_form}}')
621
+ res = session('/test/c.html') # See the form.
622
+ form = @res.body.get_path("//div[@class='section']/form")
623
+ ok_eq({:method=>'POST', :action=>'c.modulobe_files_upload',
624
+ :enctype=>'multipart/form-data'}, form[1])
625
+ ok_eq([:form, {:enctype=>'multipart/form-data',
626
+ :method=>'POST', :action=>'c.modulobe_files_upload'},
627
+ [:table,
628
+ [:tr,
629
+ [:th, 'Model file', ' : '],
630
+ [:td, [:input,
631
+ {:size=>'30', :type=>'file', :name=>'content'}]]],
632
+ [:tr,
633
+ [:th, 'Image file', ' : '],
634
+ [:td, [:input,
635
+ {:size=>'30', :type=>'file', :name=>'image'}]]],
636
+ [:tr,
637
+ [:td, ''],
638
+ [:td, [:input, {:value=>'Attach', :type=>'submit'}]]]]],
639
+ form)
640
+
641
+ # test_upload
642
+ content, image = prepare('test1.mdlb', 'test1.gif')
643
+ session('POST /test/c.modulobe_files_upload') {|req| # Put a file.
644
+ req.query.update({'content'=>content, 'image'=>image})
645
+ }
646
+ ok_title('File attachment completed')
647
+ sitelog = @site.sitelog # Check log.
648
+ ok_eq(",0.000000,user@e.com,modulobe file attach,c\n",
649
+ @site['_SiteLog'].load)
650
+
651
+ # The model is attached.
652
+ ok_eq("{{modulobe_files_form}}
653
+
654
+ *
655
+ {{modulobe_model(test1.mdlb)
656
+ :title:\t\t
657
+ :author:\t
658
+ :comment:\t
659
+ }}
660
+ {{mcomment}}
661
+
662
+ ", page.load)
663
+
664
+ # Get the file.
665
+ res = session('/test/c.files/test1.mdlb')
666
+ assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body)
667
+ ok_eq('application/x-modulobe', res['Content-Type'])
668
+
669
+ # Get the image file.
670
+ res = session('/test/c.files/test1.gif')
671
+ ok_eq('image/gif', res['Content-Type'])
672
+ end
673
+
674
+ def test_with_invalid_character
675
+ t_add_user
676
+
677
+ page = @site.create('c')
678
+
679
+ content, image = prepare('test 2.mdlb', 'test 2.gif')
680
+ res = session('POST /test/c.modulobe_files_upload') {|req| # Put a file.
681
+ req.query.update({'content'=>content, 'image'=>image})
682
+ }
683
+ ok_title('File attachment completed')
684
+ ok_xp([:p, [:strong, 'test 2.mdlb'], ' : ', 'The file is saved.'],
685
+ "//div[@class='body_main']/p")
686
+
687
+ # test_modulobe_files_upload_with_invalid_character
688
+ content, image = prepare('test+2.mdlb', 'test 2.gif')
689
+ res = session('POST /test/c.modulobe_files_upload') {|req|
690
+ req.query.update({'content'=>content, 'image'=>image})
691
+ }
692
+ ok_title('File attachment completed')
693
+ ok_xp([:p, [:strong, 'test+2.mdlb'], ' : ', 'The file is saved.'],
694
+ "//div[@class='body_main']/p")
695
+
696
+ # Get the file.
697
+ res = session('/test/c.files/test+2.mdlb')
698
+ assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body)
699
+ ok_eq('application/x-modulobe', res['Content-Type'])
700
+
701
+ # Get the image file.
702
+ res = session('/test/c.files/test+2.gif')
703
+ ok_eq('image/gif', res['Content-Type'])
704
+ end
705
+
706
+ def test_with_japanese_character
707
+ t_add_user
708
+ page = @site.create('c')
709
+
710
+ # Put files.
711
+ content, image = prepare('c:\い\あ.mdlb', 'c:\い\あ.gif')
712
+ res = session('POST /test/c.modulobe_files_upload') {|req|
713
+ req.query.update({'content'=>content, 'image'=>image})
714
+ }
715
+ ok_title('File attachment completed')
716
+ ok_xp([:p, [:strong, 'あ.mdlb'], ' : ', 'The file is saved.'],
717
+ "//div[@class='body_main']/p")
718
+
719
+ # Get the file.
720
+ res = session('/test/c.files/=E3=81=82.mdlb')
721
+ assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body)
722
+ ok_eq('application/x-modulobe', res['Content-Type'])
723
+
724
+ # Put files again.
725
+ # content and image are same.
726
+ res = session('POST /test/c.modulobe_files_upload') {|req|
727
+ req.query.update({'content'=>content, 'image'=>image})
728
+ }
729
+ ok_title('File attachment completed')
730
+ ok_xp([:p, [:strong, 'あ.mdlb'], ' -> ', [:strong, '1-あ.mdlb'], ' : ',
731
+ 'The file is saved with this filename.'],
732
+ "//div[@class='body_main']/p")
733
+
734
+ # Get the file.
735
+ res = session('/test/c.files/1-=E3=81=82.mdlb')
736
+ assert_match(/\A<\?xml version="1\.0" encoding="utf-8"\?>/, res.body)
737
+ ok_eq('application/x-modulobe', res['Content-Type'])
738
+ end
739
+
740
+ end
741
+ end