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,771 @@
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
+ $LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
7
+
8
+ module Qwik
9
+ class Action
10
+ D_ExtFiles = {
11
+ :dt => 'Attach file function',
12
+ :dd => 'You can attach files to pages.',
13
+ :dc => "* How to
14
+ Go to edit page, you see attach file form on the bottom.
15
+ You can attach many files at once by following 'attach many' link.
16
+
17
+ If you attached files, system automatically added link to the files.
18
+ {{file(\"somefile.txt\")}}
19
+ ** Show attached files plugin
20
+ {{show_files}}
21
+ {{show_files}}
22
+ You can show the list of attached files.
23
+ "
24
+ }
25
+
26
+ D_ExtFiles_ja = {
27
+ :dt => 'ファイル添付機能 ',
28
+ :dd => 'ページにファイルを添付できます。',
29
+ :dc => '* 使い方
30
+ 編集画面の一番下に、ファイル添付のためのフォームがあります。
31
+ 「\'\'\'たくさん添付する\'\'\'」というリンクをたどると、
32
+ たくさんのファイルを一度に添付するための画面にとびます。
33
+
34
+ 添付をすると、に自動的にページの一番下に添付ファイルへのリンクがつきます。
35
+ {{file("somefile.txt")}}
36
+ ** 添付ファイル一覧プラグイン
37
+ {{show_files}}
38
+ ファイル一覧を表示できます。
39
+ '
40
+ }
41
+
42
+ # ============================== files list
43
+ def plg_show_files
44
+ div = [:div, {:class=>'files'},
45
+ [:h5, [:a, {:href=>"#{@req.base}.files"}, _('Files')]]]
46
+ list = files_list
47
+ div << [:ul, *list] if list
48
+ return div
49
+ end
50
+
51
+ def files_list
52
+ return files_list_internal(@req.base, @site.files(@req.base))
53
+ end
54
+
55
+ def files_list_internal(base, files)
56
+ list = files.list
57
+ return nil if list.empty?
58
+ return list.map {|file|
59
+ encoded = Filename.encode(file)
60
+ [:li, [:a, {:href=>"#{base}.files/#{encoded}"}, file.to_page_charset],
61
+ [:span, {:class=>'delete'},
62
+ ' (', [:a, {:href=>"#{base}.file_del/#{encoded}"},
63
+ _('Delete')], ')'],
64
+ [:span, {:class=>'download'},
65
+ ' (', [:a, {:href=>"#{base}.download/#{encoded}"},
66
+ _('Download')], ')'],
67
+ ]
68
+ }
69
+ end
70
+
71
+ # ============================== download
72
+ def ext_download
73
+ if 0 < @req.path_args.length # has target file
74
+ if @req.path_args[0] == '.theme'
75
+ @req.path_args.shift
76
+ return pre_act_theme
77
+ end
78
+
79
+ filename = files_parse_filename(@req.path_args)
80
+ files = @site.files(@req.base)
81
+ if files.nil? || ! files.exist?(filename)
82
+ return c_notfound(_('No such file'))
83
+ end
84
+
85
+ return c_download(files.path(filename).to_s) # Download it.
86
+ end
87
+
88
+ return c_nerror(_('Error'))
89
+ end
90
+ alias act_download ext_download
91
+
92
+ # ============================== files
93
+ def ext_files
94
+ if 0 < @req.path_args.length # has target file
95
+ if @req.path_args[0] == '.theme'
96
+ @req.path_args.shift
97
+ return pre_act_theme
98
+ end
99
+
100
+ filename = files_parse_filename(@req.path_args)
101
+ files = @site.files(@req.base)
102
+ if files.nil? || ! files.exist?(filename)
103
+ return c_notfound(_('No such file'))
104
+ end
105
+
106
+ if files_force_download?(filename)
107
+ return c_download(files.path(filename).to_s) # Download it.
108
+ end
109
+
110
+ if ! Filename.allowable_characters_for_path?(filename)
111
+ return c_download(files.path(filename).to_s) # Download it.
112
+ end
113
+
114
+ return c_simple_send(files.path(filename).to_s) # Send it.
115
+ end
116
+
117
+ # Upload the content.
118
+ content = @req.query['content']
119
+ return files_put(content) if content
120
+
121
+ # Show files form and the list.
122
+ return show_files_form_and_the_list
123
+ end
124
+ alias act_files ext_files
125
+
126
+ def show_files_form_and_the_list
127
+ c_require_member
128
+ ar = plg_files_form(20)
129
+ w = c_notice(_('Attach file')) {[
130
+ [:p, _('Attach a file')],
131
+ ar
132
+ ]}
133
+ return w
134
+ end
135
+
136
+ def files_parse_filename(args)
137
+ filename = args.join('/').set_url_charset # Must be UTF-8
138
+ filename = Filename.decode(filename)
139
+ return filename
140
+ end
141
+
142
+ FILES_FORCE_DOWNLOAD = %w(doc xls ppt html htm)
143
+ def files_force_download?(filename)
144
+ ext = filename.path.ext
145
+ FILES_FORCE_DOWNLOAD.detect { |bad_ext| bad_ext.downcase == ext.downcase }
146
+ end
147
+
148
+ def ext_file_del
149
+ c_require_member
150
+ return c_nerror(_('Error')) if @req.path_args.length == 0
151
+ filename = files_parse_filename(@req.path_args)
152
+
153
+ if @req.path_args[0] == '.theme'
154
+ @req.path_args.shift
155
+ return pre_act_theme
156
+ end
157
+
158
+ # confirm before delete
159
+ return files_delete_confirm(filename) unless @req.is_post?
160
+ return files_delete(filename) # delete it
161
+ end
162
+
163
+ def files_delete_confirm(filename)
164
+ encoded = Filename.encode(filename)
165
+ action = "../#{@req.base}.file_del/#{encoded}" # Bad...
166
+ return c_notice(_('Confirm file deletion')) {
167
+ [:form, {:method=>'POST', :action=>action},
168
+ [:p, _("Push 'Delete' to delete a file")],
169
+ [:p, [:input, {:type=>'submit', :value=>_('Delete')}]]]
170
+ }
171
+ end
172
+
173
+ def files_delete(filename)
174
+ c_require_post
175
+ url = "../#{@req.base}.html"
176
+ begin
177
+ @site.files(@req.base).delete(filename)
178
+ rescue FileNotExist
179
+ return c_nerror(_('Already deleted.'), url)
180
+ rescue FailedToDelete
181
+ return c_nerror(_('Failed to delete.'), url)
182
+ end
183
+
184
+ c_make_log('file delete') # FILE DELETE
185
+
186
+ return c_notice(_('The file has been deleted.'), url) {
187
+ [:p, [:a, {:href=>url}, _('Go back')]]
188
+ }
189
+ end
190
+
191
+ def plg_files_page_total
192
+ total = @site.files(@req.base).total
193
+ msg = sprintf(_("Total %s in this page"), total.byte_format)
194
+ return [:span, msg]
195
+ end
196
+
197
+ def plg_files_site_total
198
+ total = @site.files_total
199
+ max_total = @config[:max_total_file_size]
200
+ warn_size = @config[:max_total_warn_size]
201
+ msg = _("Attached files total:") + " #{total.byte_format}"
202
+ if max_total < total
203
+ msg = [msg + ", ", [:strong, _('Total file size exceeded.')]]
204
+ elsif max_total - warn_size < total
205
+ warn_msg = sprintf(_("%s left"), (max_total - total).byte_format)
206
+ msg = [msg + ", ", [:strong ,warn_msg]]
207
+ end
208
+ return [:span, {:class => 'files_site_total'}, msg]
209
+ end
210
+
211
+ # ==============================
212
+ def plg_files_form(upload_number=1)
213
+ files_form(@req.base, upload_number)
214
+ end
215
+
216
+ # called from act-edit
217
+ def files_form(pagename, upload_number=1)
218
+ size = '40'
219
+ ar = []
220
+ upload_number.times {
221
+ ar << [:div, {:class=>'inputfile'},
222
+ [:input, {:type=>'file', :name=>'content'}]]
223
+ }
224
+ ar << [:div, {:class=>'input_submit'},
225
+ [:input, {:class=>'submit', :type=>'submit', :value=>_('Attach')}]]
226
+ form = [:form, {:action=>"#{pagename}.files",
227
+ :method=>'POST', :enctype=>'multipart/form-data'},
228
+ *ar]
229
+ return form
230
+ end
231
+
232
+ private
233
+
234
+ def files_put(content)
235
+ c_require_member
236
+ c_require_post
237
+
238
+ site_total = @site.files_total
239
+ max_total_file_size = @config[:max_total_file_size]
240
+ warn_size = @config[:max_total_warn_size]
241
+
242
+ list = []
243
+ content.each_data {|data|
244
+ fullfilename = data.filename
245
+ next if fullfilename.empty?
246
+
247
+ # Get basename.
248
+ #filename = fullfilename.path.basename.to_s
249
+ filename = Action.get_basename(fullfilename)
250
+
251
+ max_size = @site.siteconfig['max_file_size'].to_i
252
+ if max_size < data.length
253
+ list << [:p, [:strong, filename], [:em, _('Maximum size exceeded.')],
254
+ [:br],
255
+ _('Maximum size'), max_size, [:br],
256
+ _('File size'), data.length, [:br]]
257
+ next
258
+ elsif max_total_file_size < site_total
259
+ list << [:p, [:strong, filename], ' : ', [:em, _('The file is not saved.')],
260
+ [:br],
261
+ [:strong, _('Total file size exceeded.')],[:br],
262
+ _('Maximum total size'), max_total_file_size.byte_format, [:br],
263
+ _('Current total size'), site_total.byte_format, [:br]]
264
+ #get next even total file size is exceeded
265
+ #to display which files are not saved explicitly
266
+ next
267
+ end
268
+
269
+ # If the file is saved as another name, you can use return value.
270
+ filename = @site.files(@req.base).fput(filename, data)
271
+
272
+ c_make_log('file attach') # FILE ATTACH
273
+ site_total += data.length
274
+
275
+ page = @site[@req.base]
276
+ page.add("\n{{file(#{filename})}}\n") # files_update_page
277
+
278
+ if max_total_file_size < site_total
279
+ list << [:p, [:strong, filename], ' : ', _('The file is saved.'),
280
+ [:br],
281
+ [:strong, _('Exceeded limit.')]]
282
+ elsif max_total_file_size - warn_size < site_total
283
+ msg = _("Reaching limit.") + " " +
284
+ sprintf(_("%s left"), (max_total_file_size - site_total).byte_format)
285
+ list << [:p, [:strong, filename], ' : ', _('The file is saved.'),
286
+ [:br],
287
+ [:strong, msg]]
288
+ else
289
+ list << [:p, [:strong, filename], ' : ', _('The file is saved.')]
290
+ end
291
+ }
292
+
293
+ url = "#{@req.base}.html"
294
+
295
+ ar = list + [
296
+ [:hr],
297
+ [:p, _('Go next'), ' : ', [:a, {:href=>url}, url]],
298
+ ]
299
+ return c_notice(_('File attachment completed'), url) { ar }
300
+ end
301
+
302
+ def self.get_basename(filename)
303
+ basename = filename.sub(/\A.*[\/\\]([^\/\\]+)\z/) { $1 }
304
+ return basename
305
+ end
306
+ end
307
+ end
308
+
309
+ if $0 == __FILE__
310
+ require 'qwik/test-common'
311
+ $test = true
312
+ end
313
+
314
+ if defined?($test) && $test
315
+ class TestActFiles < Test::Unit::TestCase
316
+ include TestSession
317
+
318
+ def test_files
319
+ t_add_user
320
+
321
+ ok_wi([:div, {:class=>'files'},
322
+ [:h5, [:a, {:href=>'1.files'}, 'Files']]],
323
+ '{{show_files}}')
324
+
325
+ page = @site['1']
326
+ page.store('t')
327
+
328
+ # See the form.
329
+ res = session('/test/1.files')
330
+ form = res.body.get_path("//div[@class='section']/form")
331
+ ok_eq({:method=>'POST', :action=>'1.files',
332
+ :enctype=>'multipart/form-data'}, form[1])
333
+ ok_eq([:div, {:class=>'inputfile'},
334
+ [:input, {:type=>'file', :name=>'content'}]], form[2])
335
+ ok_eq([:div, {:class=>'input_submit'},
336
+ [:input, {:value=>'Attach', :type=>'submit', :class=>'submit'}]],
337
+ form.last)
338
+
339
+ # Put a file.
340
+ res = session('POST /test/1.files') {|req|
341
+ req.query.update('content'=>t_make_content('t.txt', 't'))
342
+ }
343
+ ok_title('File attachment completed')
344
+
345
+ # Check log.
346
+ eq(",0.000000,user@e.com,file attach,1\n", @site['_SiteLog'].load)
347
+
348
+ # The reference is added.
349
+ ok_eq('t
350
+
351
+ {{file(t.txt)}}
352
+ ', page.load)
353
+
354
+ # Get the file.
355
+ res = session('/test/1.files/t.txt')
356
+ ok_eq('t', res.body)
357
+ ok_eq('text/plain', res['Content-Type'])
358
+
359
+ # Put a file with same file name again.
360
+ # The file is saved as another filename.
361
+ res = session('POST /test/1.files') {|req|
362
+ req.query.update('content'=>t_make_content('t.txt', 't2'))
363
+ }
364
+ ok_title('File attachment completed')
365
+ ok_xp([:p, [:strong, '1-t.txt'], ' : ',
366
+ 'The file is saved.'],
367
+ "//div[@class='section']/p")
368
+
369
+ # Delete the second file.
370
+ res = session('POST /test/1.file_del/1-t.txt')
371
+ ok_title('The file has been deleted.')
372
+
373
+ # See the page again.
374
+ ok_wi([:div, {:class=>'files'},
375
+ [:h5, [:a, {:href=>'1.files'}, 'Files']],
376
+ [:ul,
377
+ [:li, [:a, {:href=>'1.files/t.txt'}, 't.txt'],
378
+ [:span, {:class=>'delete'},
379
+ " (", [:a, {:href=>"1.file_del/t.txt"}, 'Delete'], ")"],
380
+ [:span, {:class=>'download'},
381
+ " (", [:a, {:href=>'1.download/t.txt'}, 'Download'],
382
+ ")"]]]],
383
+ '{{show_files}}')
384
+
385
+ # Put another file.
386
+ res = session('POST /test/1.files') {|req|
387
+ req.query.update('content'=>t_make_content('s.png', TEST_PNG_DATA))
388
+ }
389
+ ok_title('File attachment completed')
390
+
391
+ # The reference is added too.
392
+ ok_eq('{{show_files}}
393
+
394
+ {{file(s.png)}}
395
+ ', page.load)
396
+
397
+ # See the page again.
398
+ res = session('/test/1.html')
399
+ ok_xp([:div, {:class=>'files'},
400
+ [:h5, [:a, {:href=>'1.files'}, 'Files']],
401
+ [:ul,
402
+ [:li, [:a, {:href=>'1.files/s.png'}, 's.png'],
403
+ [:span, {:class=>'delete'},
404
+ " (", [:a, {:href=>"1.file_del/s.png"}, 'Delete'], ")"],
405
+ [:span, {:class=>'download'},
406
+ " (", [:a, {:href=>'1.download/s.png'},
407
+ 'Download'], ")"]],
408
+ [:li, [:a, {:href=>'1.files/t.txt'}, 't.txt'],
409
+ [:span, {:class=>'delete'},
410
+ " (", [:a, {:href=>"1.file_del/t.txt"}, 'Delete'], ")"],
411
+ [:span, {:class=>'download'},
412
+ " (", [:a, {:href=>'1.download/t.txt'},
413
+ 'Download'], ")"]]]],
414
+ "//div[@class='files']")
415
+
416
+ # Show a form to delete the file.
417
+ res = session('/test/1.file_del/t.txt')
418
+ ok_title('Confirm file deletion')
419
+
420
+ # Delete it.
421
+ res = session('POST /test/1.file_del/t.txt')
422
+ ok_title('The file has been deleted.')
423
+
424
+ # Try to delete it again. But the file is already deleted.
425
+ res = session('POST /test/1.file_del/t.txt')
426
+ ok_title('Already deleted.')
427
+
428
+ # Try to get file agin. But the file is already deleted.
429
+ res = session('/test/1.files/t.txt')
430
+ ok_title('No such file')
431
+ end
432
+
433
+ def test_multi_files
434
+ t_add_user
435
+ page = @site.create_new
436
+
437
+ # See the form.
438
+ res = session('/test/1.files')
439
+ form = @res.body.get_path("//div[@class='section']/form")
440
+ ok_eq({:method=>'POST', :action=>'1.files',
441
+ :enctype=>'multipart/form-data'}, form[1])
442
+ ok_eq([:div, {:class=>'inputfile'},
443
+ [:input, {:type=>'file', :name=>'content'}]], form[2])
444
+ ok_eq([:div, {:class=>'inputfile'},
445
+ [:input, { :type=>'file', :name=>'content'}]], form[4])
446
+ ok_eq([:div, {:class=>'input_submit'},
447
+ [:input, {:value=>'Attach', :type=>'submit', :class=>'submit'}]],
448
+ form.last)
449
+
450
+ # Put multiple files.
451
+ content1 = t_make_content('t1.txt', 't1')
452
+ content2 = t_make_content('t2.txt', 't2')
453
+ content1.append_data(content2)
454
+ res = session('POST /test/1.files') {|req|
455
+ req.query.update('content'=>content1)
456
+ }
457
+
458
+ ok_title('File attachment completed')
459
+ ok_in([
460
+ [:p, [:strong, 't1.txt'], ' : ', 'The file is saved.'],
461
+ [:p, [:strong, 't2.txt'], ' : ', 'The file is saved.'],
462
+ [:hr],
463
+ [:p, 'Go next', ' : ',
464
+ [:a, {:href=>'1.html'}, '1.html']]],
465
+ "//div[@class='section']")
466
+
467
+ # The reference is added.
468
+ ok_eq('
469
+ {{file(t1.txt)}}
470
+
471
+ {{file(t2.txt)}}
472
+ ', page.load)
473
+ end
474
+
475
+ def test_act_files
476
+ t_add_user
477
+
478
+ page = @site['FrontPage']
479
+ page.store('t')
480
+
481
+ # See the form.
482
+ res = session('/test/.files')
483
+ form = res.body.get_path("//div[@class='section']/form")
484
+ ok_eq({:method=>'POST', :action=>'FrontPage.files',
485
+ :enctype=>'multipart/form-data'}, form[1])
486
+
487
+ # Put a file.
488
+ res = session('POST /test/.files') {|req|
489
+ req.query.update('content'=>t_make_content('t.txt', 't'))
490
+ }
491
+ ok_title('File attachment completed')
492
+
493
+ # Check log.
494
+ eq(",0.000000,user@e.com,file attach,FrontPage\n", @site['_SiteLog'].load)
495
+
496
+ # The reference is added.
497
+ ok_eq('t
498
+
499
+ {{file(t.txt)}}
500
+ ', page.load)
501
+
502
+ # Get the file.
503
+ res = session('/test/.files/t.txt')
504
+ ok_eq('t', res.body)
505
+ end
506
+
507
+ def test_jfilename
508
+ t_add_user
509
+
510
+ page = @site.create_new
511
+ page.store('t')
512
+
513
+ # Put a file with Japanese filename.
514
+ res = session('POST /test/1.files') {|req|
515
+ req.query.update('content'=>t_make_content('あ.txt', 't'))
516
+ }
517
+ ok_title('File attachment completed')
518
+
519
+ # Check log.
520
+ ok_eq(",0.000000,user@e.com,file attach,1\n", @site['_SiteLog'].load)
521
+
522
+ # The reference is added.
523
+ ok_eq('t
524
+
525
+ {{file(あ.txt)}}
526
+ ', page.load)
527
+
528
+ # Get the file.
529
+ res = session('/test/1.files/=E3=81=82.txt')
530
+ ok_eq('t', res.body)
531
+
532
+ # You can use SJIS charset.
533
+ res = session('/test/1.files/あ.txt')
534
+ ok_eq('t', res.body)
535
+
536
+ # You can use UTF-8 charset.
537
+ res = session('/test/1.files/あ.txt'.set_sourcecode_charset.to_url_charset)
538
+ ok_eq('t', res.body)
539
+
540
+ # Delete it.
541
+ res = session('POST /test/1.file_del/=E3=81=82.txt')
542
+ ok_title('The file has been deleted.')
543
+ end
544
+
545
+ def test_download
546
+ t_add_user
547
+
548
+ page = @site.create_new
549
+ page.store('t')
550
+
551
+ # Put a file.
552
+ res = session('POST /test/1.files') {|req|
553
+ req.query.update('content'=>t_make_content('t.txt', 't'))
554
+ }
555
+ ok_title('File attachment completed')
556
+
557
+ # Error check.
558
+ res = session('/test/1.download')
559
+ ok_title('Error')
560
+
561
+ # Download the file.
562
+ res = session('/test/1.download/t.txt')
563
+ ok_eq('text/plain', res['Content-Type'])
564
+ ok_eq("attachment; filename=\"t.txt\"", res['Content-Disposition'])
565
+ ok_eq('t', res.body)
566
+
567
+ # Put a file with Japanese filename.
568
+ res = session('POST /test/1.files') {|req|
569
+ req.query.update('content'=>t_make_content('あ.txt', 't'))
570
+ }
571
+ ok_title('File attachment completed')
572
+
573
+ # Download the file.
574
+ res = session('/test/1.download/=E3=81=82.txt')
575
+ ok_eq('text/plain', res['Content-Type'])
576
+ ok_eq("attachment; filename=\"あ.txt\"",
577
+ res['Content-Disposition'])
578
+ ok_eq('t', res.body)
579
+ end
580
+
581
+ def test_force_download
582
+ t_add_user
583
+
584
+ page = @site.create_new
585
+ page.store('t')
586
+
587
+ # Put a file.
588
+ res = session('POST /test/1.files') {|req|
589
+ req.query.update('content'=>t_make_content('t.doc', 't'))
590
+ }
591
+ ok_title('File attachment completed')
592
+
593
+ # Download the file.
594
+ res = session('/test/1.download/t.doc')
595
+ ok_eq('application/msword', res['Content-Type'])
596
+ ok_eq("attachment; filename=\"t.doc\"", res['Content-Disposition'])
597
+ ok_eq('t', res.body)
598
+
599
+ # Download by files extension.
600
+ res = session('/test/1.files/t.doc')
601
+ ok_eq('application/msword', res['Content-Type'])
602
+ ok_eq("attachment; filename=\"t.doc\"", res['Content-Disposition'])
603
+ ok_eq('t', res.body)
604
+ end
605
+
606
+ def test_force_download_capital_ext
607
+ t_add_user
608
+
609
+ page = @site.create_new
610
+ page.store('t')
611
+
612
+ # Put a file.
613
+ res = session('POST /test/1.files') {|req|
614
+ req.query.update('content'=>t_make_content('T.DOC', 't'))
615
+ }
616
+ ok_title('File attachment completed')
617
+
618
+ # Download the file.
619
+ res = session('/test/1.download/T.DOC')
620
+ ok_eq('application/msword', res['Content-Type'])
621
+ ok_eq("attachment; filename=\"T.DOC\"", res['Content-Disposition'])
622
+ ok_eq('t', res.body)
623
+
624
+ # Download by files extension.
625
+ res = session('/test/1.files/T.DOC')
626
+ ok_eq('application/msword', res['Content-Type'])
627
+ ok_eq("attachment; filename=\"T.DOC\"", res['Content-Disposition'])
628
+ ok_eq('t', res.body)
629
+ end
630
+
631
+ def test_class_method
632
+ c = Qwik::Action
633
+ eq("a.txt", c.get_basename("/tmp/a.txt"))
634
+ eq("a.txt", c.get_basename("c:\\tmp\\a.txt"))
635
+ end
636
+
637
+ def test_upload_from_windows
638
+ t_add_user
639
+
640
+ page = @site.create_new
641
+ page.store('t')
642
+
643
+ # Put a file.
644
+ res = session('POST /test/1.files') {|req|
645
+ req.query.update('content'=>t_make_content("c:\\tmp\\t.txt", 't'))
646
+ }
647
+ ok_title('File attachment completed')
648
+
649
+ # Download by files extension.
650
+ res = session('/test/1.files/t.txt')
651
+ ok_eq('text/plain', res['Content-Type'])
652
+ ok_eq('t', res.body)
653
+ end
654
+
655
+ def test_big_file
656
+ t_add_user
657
+
658
+ # Set max_file_size to 1MB.
659
+ config = @site['_SiteConfig']
660
+ max_size = 1 * 1024 * 1024 # 1MB
661
+ config.store(":max_file_size:#{max_size}")
662
+
663
+ page = @site.create_new
664
+ page.store('t')
665
+
666
+ # Try to store a file with 2MB size.
667
+ big_content = '0' * (2 * 1024 * 1024) # 2MB
668
+ res = session('POST /test/1.files') {|req|
669
+ req.query.update('content'=>t_make_content('t.txt', big_content))
670
+ }
671
+ ok_title('File attachment completed')
672
+ ok_in(['Maximum size exceeded.'],
673
+ "//div[@class='section']/p/em")
674
+
675
+ # Get the file.
676
+ res = session('/test/1.files/t.txt')
677
+ ok_title('No such file')
678
+ end
679
+
680
+ def test_force_download_by_character
681
+ t_add_user
682
+
683
+ page = @site.create_new
684
+ page.store('t')
685
+
686
+ # Put a file.
687
+ res = session('POST /test/1.files') {|req|
688
+ req.query.update('content'=>t_make_content('t!.txt', 't'))
689
+ }
690
+ ok_title('File attachment completed')
691
+
692
+ # Download the file.
693
+ res = session('/test/1.download/t!.txt')
694
+ ok_eq("attachment; filename=\"t!.txt\"", res['Content-Disposition'])
695
+ ok_eq('t', res.body)
696
+
697
+ # Download by files extension.
698
+ res = session('/test/1.files/t!.txt')
699
+ ok_eq("attachment; filename=\"t!.txt\"", res['Content-Disposition'])
700
+ ok_eq('t', res.body)
701
+ end
702
+
703
+ def test_total_file_size_limit
704
+ t_add_user
705
+
706
+ def attach(size)
707
+ content = '0' * size
708
+ filename = "#{size.byte_format}.txt"
709
+ res = session('POST /test/1.files') {|req|
710
+ req.query.update('content'=>t_make_content(filename, content))
711
+ }
712
+ ok_title('File attachment completed')
713
+ return filename,content
714
+ end
715
+ # Set max_total_file_size to 1MB and warn 256KB
716
+ default_max_total_file_size = @config[:max_total_file_size]
717
+ default_max_total_warn_size = @config[:max_total_warn_size]
718
+ @config[:max_total_file_size] = 1 * 1024 * 1024 # 1MB
719
+ @config[:max_total_warn_size] = 256 * 1024 # 256KB
720
+
721
+ page = @site.create_new
722
+ page.store('t')
723
+
724
+ ## Try to store a file with 512KB size.
725
+ filename,content = attach(512*1024)
726
+ ok_xp([:p, [:strong, filename], ' : ', 'The file is saved.'],
727
+ "//div[@class='section']/p")
728
+
729
+ # Get the file.
730
+ res = session("/test/1.files/#{filename}")
731
+ ok_eq(content,res.body)
732
+
733
+ ## Try to store a file with 300KB size. will get the warning
734
+ filename,content = attach(300*1024)
735
+ ok_xp([:p, [:strong, filename], ' : ', 'The file is saved.',
736
+ [:br], [:strong, "Reaching limit. 212KB left"]],
737
+ "//div[@class='section']/p")
738
+
739
+ # Get the file.
740
+ res = session("/test/1.files/#{filename}")
741
+ ok_eq(content,res.body)
742
+
743
+ ## Try to store a file with 300KB size. will exceeds the limit
744
+ filename,content = attach(256*1024)
745
+ ok_xp([:p, [:strong, filename], ' : ', 'The file is saved.',
746
+ [:br], [:strong, "Exceeded limit."]],
747
+ "//div[@class='section']/p")
748
+
749
+ # Get the file.
750
+ res = session("/test/1.files/#{filename}")
751
+ ok_eq(content,res.body)
752
+
753
+ ## Try to store a file with 300KB size. will exceeds the limit
754
+ filename,content = attach(1)
755
+ ok_xp([:p, [:strong, filename], ' : ', [:em, 'The file is not saved.'],
756
+ [:br],
757
+ [:strong, "Total file size exceeded."],[:br],
758
+ 'Maximum total size', @config[:max_total_file_size].byte_format, [:br],
759
+ 'Current total size', ((512+300+256)*1024).byte_format, [:br]],
760
+ "//div[@class='section']/p")
761
+
762
+ # Get the file.
763
+ res = session("/test/1.files/#{filename}")
764
+ ok_title('No such file')
765
+
766
+ #clean up
767
+ @config[:max_total_file_size] = default_max_total_file_size
768
+ @config[:max_total_warn_size] = default_max_total_warn_size
769
+ end
770
+ end
771
+ end