qwik2md 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/qwik2md +17 -0
- data/lib/qwik2md/version.rb +3 -0
- data/lib/qwik2md.rb +39 -0
- data/qwik2md.gemspec +30 -0
- data/vendor/qwik/AUTHORS +10 -0
- data/vendor/qwik/COPYING +340 -0
- data/vendor/qwik/COPYRIGHT +346 -0
- data/vendor/qwik/lib/qwik/Makefile +63 -0
- data/vendor/qwik/lib/qwik/Rakefile +17 -0
- data/vendor/qwik/lib/qwik/act-aa.rb +83 -0
- data/vendor/qwik/lib/qwik/act-archive.rb +386 -0
- data/vendor/qwik/lib/qwik/act-attach.rb +304 -0
- data/vendor/qwik/lib/qwik/act-backup.rb +236 -0
- data/vendor/qwik/lib/qwik/act-basic.rb +325 -0
- data/vendor/qwik/lib/qwik/act-book.rb +161 -0
- data/vendor/qwik/lib/qwik/act-calc.rb +371 -0
- data/vendor/qwik/lib/qwik/act-charset.rb +251 -0
- data/vendor/qwik/lib/qwik/act-christel.rb +112 -0
- data/vendor/qwik/lib/qwik/act-chronology.rb +149 -0
- data/vendor/qwik/lib/qwik/act-code.rb +155 -0
- data/vendor/qwik/lib/qwik/act-comment.rb +554 -0
- data/vendor/qwik/lib/qwik/act-config.rb +49 -0
- data/vendor/qwik/lib/qwik/act-counter.rb +125 -0
- data/vendor/qwik/lib/qwik/act-day.rb +96 -0
- data/vendor/qwik/lib/qwik/act-describe.rb +135 -0
- data/vendor/qwik/lib/qwik/act-diary.rb +109 -0
- data/vendor/qwik/lib/qwik/act-edit.rb +317 -0
- data/vendor/qwik/lib/qwik/act-embed-html.rb +296 -0
- data/vendor/qwik/lib/qwik/act-emode.rb +150 -0
- data/vendor/qwik/lib/qwik/act-event.rb +187 -0
- data/vendor/qwik/lib/qwik/act-file.rb +303 -0
- data/vendor/qwik/lib/qwik/act-files.rb +771 -0
- data/vendor/qwik/lib/qwik/act-getpass.rb +295 -0
- data/vendor/qwik/lib/qwik/act-history.rb +136 -0
- data/vendor/qwik/lib/qwik/act-html.rb +204 -0
- data/vendor/qwik/lib/qwik/act-httpauth.rb +147 -0
- data/vendor/qwik/lib/qwik/act-include.rb +142 -0
- data/vendor/qwik/lib/qwik/act-interwiki.rb +189 -0
- data/vendor/qwik/lib/qwik/act-isearch.rb +109 -0
- data/vendor/qwik/lib/qwik/act-keywords.rb +137 -0
- data/vendor/qwik/lib/qwik/act-lang.rb +81 -0
- data/vendor/qwik/lib/qwik/act-license.rb +63 -0
- data/vendor/qwik/lib/qwik/act-list.rb +287 -0
- data/vendor/qwik/lib/qwik/act-login.rb +410 -0
- data/vendor/qwik/lib/qwik/act-logout.rb +60 -0
- data/vendor/qwik/lib/qwik/act-mail.rb +159 -0
- data/vendor/qwik/lib/qwik/act-map.rb +292 -0
- data/vendor/qwik/lib/qwik/act-md5.rb +42 -0
- data/vendor/qwik/lib/qwik/act-mdlb.rb +741 -0
- data/vendor/qwik/lib/qwik/act-media.rb +416 -0
- data/vendor/qwik/lib/qwik/act-member.rb +157 -0
- data/vendor/qwik/lib/qwik/act-menu.rb +142 -0
- data/vendor/qwik/lib/qwik/act-metadata.rb +323 -0
- data/vendor/qwik/lib/qwik/act-mlsubmitform.rb +49 -0
- data/vendor/qwik/lib/qwik/act-monitor.rb +167 -0
- data/vendor/qwik/lib/qwik/act-new.rb +418 -0
- data/vendor/qwik/lib/qwik/act-pagelist.rb +248 -0
- data/vendor/qwik/lib/qwik/act-password.rb +145 -0
- data/vendor/qwik/lib/qwik/act-plan.rb +210 -0
- data/vendor/qwik/lib/qwik/act-povray.rb +230 -0
- data/vendor/qwik/lib/qwik/act-presen.rb +380 -0
- data/vendor/qwik/lib/qwik/act-redirect.rb +133 -0
- data/vendor/qwik/lib/qwik/act-ring.rb +1071 -0
- data/vendor/qwik/lib/qwik/act-rrefs.rb +255 -0
- data/vendor/qwik/lib/qwik/act-ruby.rb +116 -0
- data/vendor/qwik/lib/qwik/act-sample.rb +170 -0
- data/vendor/qwik/lib/qwik/act-save.rb +295 -0
- data/vendor/qwik/lib/qwik/act-schedule.rb +374 -0
- data/vendor/qwik/lib/qwik/act-search.rb +180 -0
- data/vendor/qwik/lib/qwik/act-searchwords.rb +51 -0
- data/vendor/qwik/lib/qwik/act-sendpass.rb +83 -0
- data/vendor/qwik/lib/qwik/act-site.rb +89 -0
- data/vendor/qwik/lib/qwik/act-sitebackup.rb +419 -0
- data/vendor/qwik/lib/qwik/act-sitelog.rb +118 -0
- data/vendor/qwik/lib/qwik/act-smil.rb +299 -0
- data/vendor/qwik/lib/qwik/act-status.rb +220 -0
- data/vendor/qwik/lib/qwik/act-style.rb +608 -0
- data/vendor/qwik/lib/qwik/act-table.rb +263 -0
- data/vendor/qwik/lib/qwik/act-tableform.rb +241 -0
- data/vendor/qwik/lib/qwik/act-tag.rb +103 -0
- data/vendor/qwik/lib/qwik/act-text.rb +70 -0
- data/vendor/qwik/lib/qwik/act-textarea.rb +164 -0
- data/vendor/qwik/lib/qwik/act-theme.rb +346 -0
- data/vendor/qwik/lib/qwik/act-toc.rb +112 -0
- data/vendor/qwik/lib/qwik/act-typekey.rb +198 -0
- data/vendor/qwik/lib/qwik/act-under-const.rb +94 -0
- data/vendor/qwik/lib/qwik/act-webservice.rb +321 -0
- data/vendor/qwik/lib/qwik/act-wema.rb +558 -0
- data/vendor/qwik/lib/qwik/act-wysiwyg.rb +238 -0
- data/vendor/qwik/lib/qwik/action.rb +325 -0
- data/vendor/qwik/lib/qwik/autoreload.rb +98 -0
- data/vendor/qwik/lib/qwik/bench-bench.rb +28 -0
- data/vendor/qwik/lib/qwik/bench-emode.rb +47 -0
- data/vendor/qwik/lib/qwik/bench-format-xml.rb +70 -0
- data/vendor/qwik/lib/qwik/bench-large-table.rb +62 -0
- data/vendor/qwik/lib/qwik/bench-md5.rb +14 -0
- data/vendor/qwik/lib/qwik/bench-module-session.rb +19 -0
- data/vendor/qwik/lib/qwik/bench-page.rb +50 -0
- data/vendor/qwik/lib/qwik/bench-s-md5.rb +28 -0
- data/vendor/qwik/lib/qwik/bench-session.rb +25 -0
- data/vendor/qwik/lib/qwik/bench-textformat.rb +31 -0
- data/vendor/qwik/lib/qwik/catalog-factory.rb +91 -0
- data/vendor/qwik/lib/qwik/catalog-ja.rb +479 -0
- data/vendor/qwik/lib/qwik/catalog-ml-ja.rb +145 -0
- data/vendor/qwik/lib/qwik/check-act-monitor.rb +112 -0
- data/vendor/qwik/lib/qwik/check-act-monitor2.rb +46 -0
- data/vendor/qwik/lib/qwik/check-act-theme.rb +27 -0
- data/vendor/qwik/lib/qwik/check-event.rb +112 -0
- data/vendor/qwik/lib/qwik/check-event2.rb +55 -0
- data/vendor/qwik/lib/qwik/check-htree-rexml.rb +77 -0
- data/vendor/qwik/lib/qwik/check-htree.rb +51 -0
- data/vendor/qwik/lib/qwik/check-libxml.rb +135 -0
- data/vendor/qwik/lib/qwik/check-many-pages.rb +47 -0
- data/vendor/qwik/lib/qwik/check-monitor.rb +33 -0
- data/vendor/qwik/lib/qwik/check-observer.rb +67 -0
- data/vendor/qwik/lib/qwik/check-server.rb +61 -0
- data/vendor/qwik/lib/qwik/check-uuencode.rb +33 -0
- data/vendor/qwik/lib/qwik/check-webdav.rb +65 -0
- data/vendor/qwik/lib/qwik/check-xml-xpath.rb +27 -0
- data/vendor/qwik/lib/qwik/common-backtrace.rb +94 -0
- data/vendor/qwik/lib/qwik/common-basic.rb +111 -0
- data/vendor/qwik/lib/qwik/common-condition.rb +142 -0
- data/vendor/qwik/lib/qwik/common-error.rb +48 -0
- data/vendor/qwik/lib/qwik/common-gettext.rb +50 -0
- data/vendor/qwik/lib/qwik/common-javascript.rb +45 -0
- data/vendor/qwik/lib/qwik/common-notice.rb +132 -0
- data/vendor/qwik/lib/qwik/common-plain.rb +105 -0
- data/vendor/qwik/lib/qwik/common-plugin.rb +111 -0
- data/vendor/qwik/lib/qwik/common-res.rb +76 -0
- data/vendor/qwik/lib/qwik/common-resolve.rb +92 -0
- data/vendor/qwik/lib/qwik/common-send.rb +171 -0
- data/vendor/qwik/lib/qwik/common-session.rb +139 -0
- data/vendor/qwik/lib/qwik/common-surface.rb +261 -0
- data/vendor/qwik/lib/qwik/common-url.rb +90 -0
- data/vendor/qwik/lib/qwik/compat/Makefile +12 -0
- data/vendor/qwik/lib/qwik/compat/add_load_path.rb +1 -0
- data/vendor/qwik/lib/qwik/config.rb +299 -0
- data/vendor/qwik/lib/qwik/db-b-backup.rb +142 -0
- data/vendor/qwik/lib/qwik/db-backup.rb +184 -0
- data/vendor/qwik/lib/qwik/db-berkeley.rb +306 -0
- data/vendor/qwik/lib/qwik/db-filesystem.rb +305 -0
- data/vendor/qwik/lib/qwik/db-indexer.rb +154 -0
- data/vendor/qwik/lib/qwik/db-searchwords.rb +238 -0
- data/vendor/qwik/lib/qwik/description-ja.rb +267 -0
- data/vendor/qwik/lib/qwik/description.rb +256 -0
- data/vendor/qwik/lib/qwik/dev-add-copyright.rb +23 -0
- data/vendor/qwik/lib/qwik/dev-backup.rb +24 -0
- data/vendor/qwik/lib/qwik/dev-bench.rb +175 -0
- data/vendor/qwik/lib/qwik/dev-calctime.rb +52 -0
- data/vendor/qwik/lib/qwik/dev-css-compressor.rb +60 -0
- data/vendor/qwik/lib/qwik/dev-extract-catalog.rb +102 -0
- data/vendor/qwik/lib/qwik/dev-js-compressor.rb +73 -0
- data/vendor/qwik/lib/qwik/dev-release.rb +235 -0
- data/vendor/qwik/lib/qwik/dev-replace.rb +353 -0
- data/vendor/qwik/lib/qwik/dev-sendmail.rb +25 -0
- data/vendor/qwik/lib/qwik/farm.rb +283 -0
- data/vendor/qwik/lib/qwik/gettext.rb +56 -0
- data/vendor/qwik/lib/qwik/group-cond.rb +157 -0
- data/vendor/qwik/lib/qwik/group-config.rb +247 -0
- data/vendor/qwik/lib/qwik/group-confirm.rb +147 -0
- data/vendor/qwik/lib/qwik/group-db.rb +326 -0
- data/vendor/qwik/lib/qwik/group-mail.rb +195 -0
- data/vendor/qwik/lib/qwik/group-member.rb +307 -0
- data/vendor/qwik/lib/qwik/group-sendmail.rb +231 -0
- data/vendor/qwik/lib/qwik/group-site.rb +374 -0
- data/vendor/qwik/lib/qwik/group-sweep.rb +63 -0
- data/vendor/qwik/lib/qwik/group.rb +157 -0
- data/vendor/qwik/lib/qwik/helper.rb +6 -0
- data/vendor/qwik/lib/qwik/html-generator.rb +104 -0
- data/vendor/qwik/lib/qwik/html-to-wabisabi.rb +148 -0
- data/vendor/qwik/lib/qwik/htree-diff.rb +87 -0
- data/vendor/qwik/lib/qwik/htree-format-xml.rb +57 -0
- data/vendor/qwik/lib/qwik/htree-generator.rb +144 -0
- data/vendor/qwik/lib/qwik/htree-get.rb +251 -0
- data/vendor/qwik/lib/qwik/htree-html-generator.rb +179 -0
- data/vendor/qwik/lib/qwik/htree-template.rb +263 -0
- data/vendor/qwik/lib/qwik/htree-to-wabisabi.rb +171 -0
- data/vendor/qwik/lib/qwik/loadlib.rb +79 -0
- data/vendor/qwik/lib/qwik/logger.rb +115 -0
- data/vendor/qwik/lib/qwik/mail-body.rb +171 -0
- data/vendor/qwik/lib/qwik/mail-header.rb +474 -0
- data/vendor/qwik/lib/qwik/mail-multipart.rb +193 -0
- data/vendor/qwik/lib/qwik/mail-parse.rb +147 -0
- data/vendor/qwik/lib/qwik/mail.rb +341 -0
- data/vendor/qwik/lib/qwik/mailaddress.rb +83 -0
- data/vendor/qwik/lib/qwik/mdlb-model.rb +81 -0
- data/vendor/qwik/lib/qwik/mdlb-sample.rb +324 -0
- data/vendor/qwik/lib/qwik/ml-catalog-factory.rb +27 -0
- data/vendor/qwik/lib/qwik/ml-exception.rb +15 -0
- data/vendor/qwik/lib/qwik/ml-generator.rb +28 -0
- data/vendor/qwik/lib/qwik/ml-gettext.rb +137 -0
- data/vendor/qwik/lib/qwik/ml-logger.rb +82 -0
- data/vendor/qwik/lib/qwik/ml-memory.rb +65 -0
- data/vendor/qwik/lib/qwik/ml-msg-validator.rb +86 -0
- data/vendor/qwik/lib/qwik/ml-processor.rb +609 -0
- data/vendor/qwik/lib/qwik/ml-quickml-server.rb +122 -0
- data/vendor/qwik/lib/qwik/ml-sendmail.rb +0 -0
- data/vendor/qwik/lib/qwik/ml-server.rb +107 -0
- data/vendor/qwik/lib/qwik/ml-session.rb +348 -0
- data/vendor/qwik/lib/qwik/ml-sweeper.rb +101 -0
- data/vendor/qwik/lib/qwik/mock-logger.rb +65 -0
- data/vendor/qwik/lib/qwik/mock-sendmail.rb +78 -0
- data/vendor/qwik/lib/qwik/mock-socket.rb +82 -0
- data/vendor/qwik/lib/qwik/modulobe.rb +406 -0
- data/vendor/qwik/lib/qwik/mongrel-server.rb +72 -0
- data/vendor/qwik/lib/qwik/page-files.rb +249 -0
- data/vendor/qwik/lib/qwik/page-generate.rb +82 -0
- data/vendor/qwik/lib/qwik/page-get.rb +262 -0
- data/vendor/qwik/lib/qwik/page-images.rb +168 -0
- data/vendor/qwik/lib/qwik/page-put.rb +128 -0
- data/vendor/qwik/lib/qwik/page-rrefs.rb +154 -0
- data/vendor/qwik/lib/qwik/page-title.rb +0 -0
- data/vendor/qwik/lib/qwik/page-wikidb.rb +234 -0
- data/vendor/qwik/lib/qwik/page.rb +67 -0
- data/vendor/qwik/lib/qwik/pages.rb +444 -0
- data/vendor/qwik/lib/qwik/parse-plugin.rb +249 -0
- data/vendor/qwik/lib/qwik/parser-emode.rb +116 -0
- data/vendor/qwik/lib/qwik/parser-inline.rb +272 -0
- data/vendor/qwik/lib/qwik/parser.rb +349 -0
- data/vendor/qwik/lib/qwik/password.rb +183 -0
- data/vendor/qwik/lib/qwik/periodic.rb +79 -0
- data/vendor/qwik/lib/qwik/qp.rb +56 -0
- data/vendor/qwik/lib/qwik/qwik-service.rb +341 -0
- data/vendor/qwik/lib/qwik/qwik.rb +5 -0
- data/vendor/qwik/lib/qwik/qwikweb-adduser.rb +34 -0
- data/vendor/qwik/lib/qwik/qwikweb-catalog-validator.rb +110 -0
- data/vendor/qwik/lib/qwik/qwikweb-incgen.rb +28 -0
- data/vendor/qwik/lib/qwik/qwikweb-makesite.rb +41 -0
- data/vendor/qwik/lib/qwik/qwikweb-server.rb +44 -0
- data/vendor/qwik/lib/qwik/qwikweb-showpassword.rb +26 -0
- data/vendor/qwik/lib/qwik/qwikweb-watchlog.rb +67 -0
- data/vendor/qwik/lib/qwik/request-path.rb +304 -0
- data/vendor/qwik/lib/qwik/request-ua.rb +76 -0
- data/vendor/qwik/lib/qwik/request-webrick.rb +81 -0
- data/vendor/qwik/lib/qwik/request.rb +91 -0
- data/vendor/qwik/lib/qwik/resolve-tdiary.rb +292 -0
- data/vendor/qwik/lib/qwik/resolve.rb +121 -0
- data/vendor/qwik/lib/qwik/response.rb +228 -0
- data/vendor/qwik/lib/qwik/server-memory.rb +57 -0
- data/vendor/qwik/lib/qwik/server-webrick.rb +102 -0
- data/vendor/qwik/lib/qwik/server.rb +252 -0
- data/vendor/qwik/lib/qwik/site-config.rb +149 -0
- data/vendor/qwik/lib/qwik/site-db.rb +136 -0
- data/vendor/qwik/lib/qwik/site-event.rb +162 -0
- data/vendor/qwik/lib/qwik/site-files.rb +86 -0
- data/vendor/qwik/lib/qwik/site-group.rb +103 -0
- data/vendor/qwik/lib/qwik/site-index.rb +47 -0
- data/vendor/qwik/lib/qwik/site-log.rb +64 -0
- data/vendor/qwik/lib/qwik/site-member.rb +230 -0
- data/vendor/qwik/lib/qwik/site-monitor.rb +97 -0
- data/vendor/qwik/lib/qwik/site-pages.rb +62 -0
- data/vendor/qwik/lib/qwik/site-plan.rb +139 -0
- data/vendor/qwik/lib/qwik/site-report.rb +282 -0
- data/vendor/qwik/lib/qwik/site-resolve.rb +230 -0
- data/vendor/qwik/lib/qwik/site-rrefs.rb +18 -0
- data/vendor/qwik/lib/qwik/site-search.rb +180 -0
- data/vendor/qwik/lib/qwik/site-timeline.rb +153 -0
- data/vendor/qwik/lib/qwik/site-url.rb +189 -0
- data/vendor/qwik/lib/qwik/site.rb +76 -0
- data/vendor/qwik/lib/qwik/smil-time.rb +105 -0
- data/vendor/qwik/lib/qwik/smtp-session.rb +331 -0
- data/vendor/qwik/lib/qwik/template-generator.rb +149 -0
- data/vendor/qwik/lib/qwik/template.rb +85 -0
- data/vendor/qwik/lib/qwik/test-common.rb +10 -0
- data/vendor/qwik/lib/qwik/test-ml-info.rb +225 -0
- data/vendor/qwik/lib/qwik/test-module-ml.rb +142 -0
- data/vendor/qwik/lib/qwik/test-module-path.rb +110 -0
- data/vendor/qwik/lib/qwik/test-module-public.rb +70 -0
- data/vendor/qwik/lib/qwik/test-module-server.rb +98 -0
- data/vendor/qwik/lib/qwik/test-module-session.rb +264 -0
- data/vendor/qwik/lib/qwik/test-module-suite.rb +91 -0
- data/vendor/qwik/lib/qwik/test-ms-applemail.rb +59 -0
- data/vendor/qwik/lib/qwik/test-ms-attach.rb +174 -0
- data/vendor/qwik/lib/qwik/test-ms-basic.rb +40 -0
- data/vendor/qwik/lib/qwik/test-ms-close.rb +35 -0
- data/vendor/qwik/lib/qwik/test-ms-confirm.rb +75 -0
- data/vendor/qwik/lib/qwik/test-ms-ignore-spam.rb +57 -0
- data/vendor/qwik/lib/qwik/test-ms-japanese.rb +97 -0
- data/vendor/qwik/lib/qwik/test-ms-jfilename.rb +82 -0
- data/vendor/qwik/lib/qwik/test-ms-large.rb +58 -0
- data/vendor/qwik/lib/qwik/test-ms-member.rb +103 -0
- data/vendor/qwik/lib/qwik/test-ms-multipart.rb +84 -0
- data/vendor/qwik/lib/qwik/test-ms-org.rb +129 -0
- data/vendor/qwik/lib/qwik/test-ms-plan.rb +130 -0
- data/vendor/qwik/lib/qwik/test-ms-post.rb +53 -0
- data/vendor/qwik/lib/qwik/test-ms-quopri.rb +76 -0
- data/vendor/qwik/lib/qwik/test-sub-quopri.rb +45 -0
- data/vendor/qwik/lib/qwik/test-submit-base64.rb +59 -0
- data/vendor/qwik/lib/qwik/test-submit-forward.rb +61 -0
- data/vendor/qwik/lib/qwik/test-submit-html-mail.rb +52 -0
- data/vendor/qwik/lib/qwik/test-submit-japanese.rb +135 -0
- data/vendor/qwik/lib/qwik/test-submit-jfilename.rb +144 -0
- data/vendor/qwik/lib/qwik/test-submit-uuencode.rb +71 -0
- data/vendor/qwik/lib/qwik/test-suite-all.rb +8 -0
- data/vendor/qwik/lib/qwik/test-suite-basic.rb +9 -0
- data/vendor/qwik/lib/qwik/test-suite-ml.rb +9 -0
- data/vendor/qwik/lib/qwik/test-typekey.rb +64 -0
- data/vendor/qwik/lib/qwik/testunit.rb +45 -0
- data/vendor/qwik/lib/qwik/tokenizer-inline.rb +288 -0
- data/vendor/qwik/lib/qwik/tokenizer.rb +331 -0
- data/vendor/qwik/lib/qwik/typekey.rb +160 -0
- data/vendor/qwik/lib/qwik/util-basic.rb +135 -0
- data/vendor/qwik/lib/qwik/util-charset.rb +331 -0
- data/vendor/qwik/lib/qwik/util-css.rb +56 -0
- data/vendor/qwik/lib/qwik/util-csv-tokenizer.rb +113 -0
- data/vendor/qwik/lib/qwik/util-filename.rb +112 -0
- data/vendor/qwik/lib/qwik/util-pathname.rb +202 -0
- data/vendor/qwik/lib/qwik/util-pid.rb +58 -0
- data/vendor/qwik/lib/qwik/util-safe.rb +67 -0
- data/vendor/qwik/lib/qwik/util-sendmail.rb +273 -0
- data/vendor/qwik/lib/qwik/util-string.rb +202 -0
- data/vendor/qwik/lib/qwik/util-time.rb +125 -0
- data/vendor/qwik/lib/qwik/util-webrick.rb +176 -0
- data/vendor/qwik/lib/qwik/version.rb +11 -0
- data/vendor/qwik/lib/qwik/wabisabi-basic.rb +163 -0
- data/vendor/qwik/lib/qwik/wabisabi-diff.rb +130 -0
- data/vendor/qwik/lib/qwik/wabisabi-format-xml.rb +310 -0
- data/vendor/qwik/lib/qwik/wabisabi-generator.rb +262 -0
- data/vendor/qwik/lib/qwik/wabisabi-index.rb +174 -0
- data/vendor/qwik/lib/qwik/wabisabi-table.rb +212 -0
- data/vendor/qwik/lib/qwik/wabisabi-template.rb +295 -0
- data/vendor/qwik/lib/qwik/wabisabi-to-htree.rb +111 -0
- data/vendor/qwik/lib/qwik/wabisabi-to-wiki.rb +690 -0
- data/vendor/qwik/lib/qwik/wabisabi-traverse.rb +207 -0
- data/vendor/qwik/lib/qwik/wabisabi-validator.rb +116 -0
- data/vendor/qwik/lib/qwik/wabisabi.rb +5 -0
- metadata +492 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
6
|
+
require 'qwik/util-webrick'
|
7
|
+
|
8
|
+
module Qwik
|
9
|
+
class WEBrickRequest < WEBrick::HTTPRequest
|
10
|
+
attr_writer :request_uri, :path, :peeraddr
|
11
|
+
attr_writer :request_method, :cookies, :header, :query
|
12
|
+
attr_writer :user
|
13
|
+
end
|
14
|
+
|
15
|
+
class WEBrickResponse < WEBrick::HTTPResponse
|
16
|
+
def set_config
|
17
|
+
@config.update(WEBrick::Config::HTTP)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if $0 == __FILE__
|
23
|
+
require 'qwik/testunit'
|
24
|
+
require 'qwik/config'
|
25
|
+
require 'qwik/request'
|
26
|
+
$test = true
|
27
|
+
end
|
28
|
+
|
29
|
+
if defined?($test) && $test
|
30
|
+
class TestWEBrickRequest < Test::Unit::TestCase
|
31
|
+
def ok_req(e, req)
|
32
|
+
ok_eq(e, [req.sitename, req.base, req.ext])
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup_server
|
36
|
+
config = Qwik::Config.new
|
37
|
+
config[:debug] = true
|
38
|
+
config[:test] = true # do not show webrick log
|
39
|
+
|
40
|
+
server_config = {}
|
41
|
+
|
42
|
+
req = Qwik::Request.new(config)
|
43
|
+
|
44
|
+
return config, server_config, req
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_parse_webrick
|
48
|
+
config, server_config, req = setup_server
|
49
|
+
|
50
|
+
wreq = Qwik::WEBrickRequest.new(server_config)
|
51
|
+
wreq.request_uri = URI.parse('http://example.com/')
|
52
|
+
wreq.path = '/'
|
53
|
+
req.parse_webrick(wreq)
|
54
|
+
ok_req(['www', 'FrontPage', 'html'], req)
|
55
|
+
|
56
|
+
wreq.request_uri = URI.parse('http://example.com/test/1.html')
|
57
|
+
wreq.path = '/test/1.html'
|
58
|
+
req.parse_webrick(wreq)
|
59
|
+
ok_req(['test', '1', 'html'], req)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_parse_webrick_env
|
63
|
+
config, server_config, req = setup_server
|
64
|
+
|
65
|
+
wreq = Qwik::WEBrickRequest.new(server_config)
|
66
|
+
wreq.path = '/'
|
67
|
+
wreq.peeraddr = [nil, nil, nil, '192.168.0.1']
|
68
|
+
req.parse_webrick(wreq)
|
69
|
+
|
70
|
+
wreq.request_method = 'POST'
|
71
|
+
req.parse_webrick(wreq)
|
72
|
+
ok_eq('POST', req.request_method)
|
73
|
+
|
74
|
+
wreq.request_method = 'HEAD'
|
75
|
+
req.parse_webrick(wreq)
|
76
|
+
ok_eq('HEAD', req.request_method)
|
77
|
+
|
78
|
+
wreq.request_method = 'GET'
|
79
|
+
req.parse_webrick(wreq)
|
80
|
+
ok_eq('GET', req.request_method)
|
81
|
+
|
82
|
+
wreq.header = {'x-test' => ['t']}
|
83
|
+
req.parse_webrick(wreq)
|
84
|
+
ok_eq('t', req['X-Test'])
|
85
|
+
|
86
|
+
wreq.cookies = []
|
87
|
+
wreq.cookies << WEBrick::Cookie.new('s', 't')
|
88
|
+
wreq.cookies << WEBrick::Cookie.new('k', 'v')
|
89
|
+
req.parse_webrick(wreq)
|
90
|
+
ok_eq('t', req.cookies['s'])
|
91
|
+
ok_eq('v', req.cookies['k'])
|
92
|
+
|
93
|
+
wreq.query = {'k' => 'v'}
|
94
|
+
req.parse_webrick(wreq)
|
95
|
+
ok_eq('v', req.query['k'])
|
96
|
+
|
97
|
+
wreq.query = {'c' => 'edit'}
|
98
|
+
req.parse_webrick(wreq)
|
99
|
+
ok_eq('edit', req.query['c'])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,252 @@
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
6
|
+
require 'qwik/config'
|
7
|
+
require 'qwik/server-memory'
|
8
|
+
require 'qwik/server-webrick'
|
9
|
+
require 'qwik/logger'
|
10
|
+
|
11
|
+
require 'qwik/action'
|
12
|
+
require 'qwik/periodic'
|
13
|
+
require 'qwik/request'
|
14
|
+
require 'qwik/response'
|
15
|
+
|
16
|
+
require 'qwik/util-pid'
|
17
|
+
require 'qwik/qp'
|
18
|
+
|
19
|
+
require 'logger'
|
20
|
+
|
21
|
+
module Qwik
|
22
|
+
class Server < WEBrick::HTTPServer
|
23
|
+
include PidModule
|
24
|
+
|
25
|
+
def initialize(qconfig)
|
26
|
+
@qconfig = qconfig
|
27
|
+
@memory = ServerMemory.new(@qconfig)
|
28
|
+
|
29
|
+
# init_trap
|
30
|
+
trap(:TERM) { shutdown; }
|
31
|
+
trap(:INT) { shutdown; }
|
32
|
+
if Signal.list.key?("HUP")
|
33
|
+
trap(:HUP) { reopen; }
|
34
|
+
end
|
35
|
+
|
36
|
+
init_directory(@qconfig)
|
37
|
+
|
38
|
+
webrick_conf, @pidfile = init_webrick_conf(@qconfig, @memory)
|
39
|
+
|
40
|
+
init_bury_logger
|
41
|
+
|
42
|
+
super(webrick_conf)
|
43
|
+
|
44
|
+
mount('/', Servlet) # Delegate all accesses.
|
45
|
+
end
|
46
|
+
attr_reader :memory
|
47
|
+
|
48
|
+
def init_directory(config)
|
49
|
+
config.cache_dir.path.check_directory
|
50
|
+
config.sites_dir.path.check_directory
|
51
|
+
(config.sites_dir.path+config.default_sitename).check_directory
|
52
|
+
config.etc_dir.path.check_directory
|
53
|
+
config.grave_dir.path.check_directory
|
54
|
+
config.log_dir.path.check_directory
|
55
|
+
end
|
56
|
+
|
57
|
+
def init_webrick_conf(config, memory)
|
58
|
+
# qwik-error.log
|
59
|
+
web_error_log = (config.log_dir.path + Logger::WEB_ERROR_LOG).to_s
|
60
|
+
pidfile = config.web_pid_file # qwikweb.pid
|
61
|
+
servertype = WEBrick::Daemon
|
62
|
+
if config.debug
|
63
|
+
pidfile += '-d'
|
64
|
+
servertype = WEBrick::SimpleServer
|
65
|
+
web_error_log = $stdout
|
66
|
+
web_error_log = 'qwik-error.log' if config.test
|
67
|
+
end
|
68
|
+
|
69
|
+
# qwik-access.log
|
70
|
+
log = config.log_dir.path + Logger::WEB_ACCESS_LOG
|
71
|
+
logger = Qwik::Logger.new(log.to_s)
|
72
|
+
logger.verbose = true if config.debug && ! config.test
|
73
|
+
memory[:qwik_access_log] = logger
|
74
|
+
|
75
|
+
web_error_logger = WEBrick::Log.new(web_error_log, WEBrick::Log::INFO)
|
76
|
+
memory[:logger] = web_error_logger
|
77
|
+
|
78
|
+
access_log_file = (config.log_dir.path + Logger::ACCESS_LOG).to_s
|
79
|
+
accesslog_logger =
|
80
|
+
[[WEBrick::BasicLog.new(access_log_file, WEBrick::Log::INFO),
|
81
|
+
WEBrick::AccessLog::COMBINED_LOG_FORMAT]]
|
82
|
+
|
83
|
+
server = Server.server_name
|
84
|
+
#server = "Apache/2.0.54 (Unix) #{server}" # Imitate Apache server
|
85
|
+
|
86
|
+
webrick_config = {
|
87
|
+
:HostnameLookups => false,
|
88
|
+
:BindAddress => config.bind_address,
|
89
|
+
:Port => config.web_port.to_i,
|
90
|
+
:Logger => web_error_logger,
|
91
|
+
:ServerType => servertype,
|
92
|
+
:StartCallback => Proc.new { start_server; },
|
93
|
+
:StopCallback => Proc.new { stop_server; },
|
94
|
+
:AccessLog => accesslog_logger,
|
95
|
+
:ServerSoftware => server,
|
96
|
+
:QwikConfig => config,
|
97
|
+
:QwikMemory => memory,
|
98
|
+
#:MaxClients => 100,
|
99
|
+
#:WEBrickThread => false, # test
|
100
|
+
}
|
101
|
+
|
102
|
+
return webrick_config, pidfile
|
103
|
+
end
|
104
|
+
|
105
|
+
# callback from :StartCallback
|
106
|
+
def start_server
|
107
|
+
write_pid_file(@pidfile)
|
108
|
+
|
109
|
+
threads = []
|
110
|
+
threads << SweepThread.new(@qconfig, @memory)
|
111
|
+
threads << WeeklySendReportThread.new(@memory)
|
112
|
+
threads << DailySendReportThread.new(@memory)
|
113
|
+
threads << HourlySendReportThread.new(@memory)
|
114
|
+
@memory[:threads] = threads
|
115
|
+
threads.each {|th|
|
116
|
+
t = Thread.new {
|
117
|
+
th.start
|
118
|
+
}
|
119
|
+
t.abort_on_exception = true
|
120
|
+
}
|
121
|
+
|
122
|
+
#qp @qconfig.debug
|
123
|
+
if @qconfig.debug
|
124
|
+
require 'qwik/autoreload'
|
125
|
+
AutoReload.start(1, true, 'Web') # auto reload every sec.
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# callback from :StopCallback
|
130
|
+
def stop_server
|
131
|
+
remove_pid_file(@pidfile)
|
132
|
+
end
|
133
|
+
|
134
|
+
def reopen
|
135
|
+
# qwik-access.log is an instance of Qwik::Logger
|
136
|
+
logger = @memory[:qwik_access_log]
|
137
|
+
logger.reopen
|
138
|
+
|
139
|
+
# qwik-error.log is an instance of WEBrick::Log
|
140
|
+
logger = @memory[:logger]
|
141
|
+
logger.reopen
|
142
|
+
|
143
|
+
# access.log is an instance of WEBrick::BasicLog
|
144
|
+
webrick_accesslog = @config[:AccessLog][0][0]
|
145
|
+
webrick_accesslog.reopen
|
146
|
+
end
|
147
|
+
|
148
|
+
def init_bury_logger
|
149
|
+
log_file = (@qconfig.log_dir.path + "bury.log").to_s
|
150
|
+
# '::Logger' means standard library class.
|
151
|
+
log = ::Logger.new(log_file, 'monthly')
|
152
|
+
log.level = ::Logger::INFO
|
153
|
+
@memory[:bury_log] = log
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.version
|
157
|
+
return VERSION
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.server_name
|
161
|
+
return "qwikWeb/#{VERSION}+#{RELEASE_DATE}"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
class Servlet < WEBrick::HTTPServlet::AbstractServlet
|
166
|
+
def do_GET(request, response)
|
167
|
+
start_time = Time.now
|
168
|
+
|
169
|
+
config = @server[:QwikConfig]
|
170
|
+
memory = @server[:QwikMemory]
|
171
|
+
|
172
|
+
req = Request.new(config)
|
173
|
+
req.parse_webrick(request)
|
174
|
+
|
175
|
+
res = Response.new(config)
|
176
|
+
res.set_webrick(response)
|
177
|
+
|
178
|
+
action = Action.new
|
179
|
+
action.init(config, memory, req, res)
|
180
|
+
action.run
|
181
|
+
|
182
|
+
res.setback(response)
|
183
|
+
|
184
|
+
diff = Time.now - start_time
|
185
|
+
diffsec = sprintf("%.2f", diff)
|
186
|
+
|
187
|
+
if response.body.is_a? String
|
188
|
+
response.body.gsub!(/__qwik_page_generate_time__/, diffsec)
|
189
|
+
end
|
190
|
+
|
191
|
+
qlog = memory[:qwik_access_log]
|
192
|
+
logline = Logger.format_log_line(req, response, diff)
|
193
|
+
if qlog && ! Logger::IGNORE_ACTION.include?(req.plugin)
|
194
|
+
qlog.take_log(logline) # Take a log.
|
195
|
+
end
|
196
|
+
|
197
|
+
if res.basicauth
|
198
|
+
proc = res.basicauth
|
199
|
+
WEBrick::HTTPAuth::basic_auth(request, response, 'qwik', &proc)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
alias do_POST do_GET
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
if $0 == __FILE__
|
208
|
+
require 'qwik/test-common'
|
209
|
+
require 'qwik/testunit'
|
210
|
+
require 'qwik/act-theme'
|
211
|
+
$test = true
|
212
|
+
end
|
213
|
+
|
214
|
+
if defined?($test) && $test
|
215
|
+
require 'qwik/test-module-server'
|
216
|
+
|
217
|
+
class TestServer < Test::Unit::TestCase
|
218
|
+
include TestServerModule
|
219
|
+
|
220
|
+
def test_frontpage
|
221
|
+
return if $0 != __FILE__ # Only for unit test.
|
222
|
+
server, config, memory, wreq, wres = setup_server
|
223
|
+
wreq.path = '/'
|
224
|
+
wres = session(config, memory, wreq, wres)
|
225
|
+
ok_eq("text/html; charset=Shift_JIS", wres['content-type'])
|
226
|
+
ok_eq(?<, wres.body[0])
|
227
|
+
|
228
|
+
teardown_server(server)
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_css
|
232
|
+
return if $0 != __FILE__ # Only for unit test.
|
233
|
+
server, config, memory, wreq, wres = setup_server
|
234
|
+
wreq.path = '/.theme/css/base.css'
|
235
|
+
wres = session(config, memory, wreq, wres)
|
236
|
+
ok_eq('text/css', wres['content-type'])
|
237
|
+
assert_match(%r|^/*|, wres.body)
|
238
|
+
teardown_server(server)
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_head
|
242
|
+
return if $0 != __FILE__ # Only for unit test.
|
243
|
+
server, config, memory, wreq, wres = setup_server
|
244
|
+
wreq.path = '/'
|
245
|
+
wreq.request_method = 'HEAD'
|
246
|
+
wres = session(config, memory, wreq, wres)
|
247
|
+
ok_eq("text/html; charset=Shift_JIS", wres['content-type'])
|
248
|
+
ok_eq(?<, wres.body[0])
|
249
|
+
teardown_server(server)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
6
|
+
|
7
|
+
module Qwik
|
8
|
+
class Site
|
9
|
+
def siteconfig
|
10
|
+
# @siteconfig = SiteConfig.new(@config, self) unless defined? @siteconfig
|
11
|
+
#return @siteconfig
|
12
|
+
return SiteConfig.new(@config, self)
|
13
|
+
end
|
14
|
+
|
15
|
+
def is_open?
|
16
|
+
return (siteconfig['open'] == 'true')
|
17
|
+
end
|
18
|
+
|
19
|
+
def is_blessed?
|
20
|
+
file = @path + ",blessed"
|
21
|
+
return file.exist?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class SiteConfig
|
26
|
+
def initialize(config, site)
|
27
|
+
@config = config
|
28
|
+
@site = site
|
29
|
+
|
30
|
+
@default = default_config
|
31
|
+
|
32
|
+
page = get_page
|
33
|
+
|
34
|
+
@db = page.wikidb
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_page
|
38
|
+
#page = @site.get_superpage('SiteConfig')
|
39
|
+
page = @site['_SiteConfig']
|
40
|
+
return page if page
|
41
|
+
return @site.create('_SiteConfig')
|
42
|
+
end
|
43
|
+
|
44
|
+
def [](k)
|
45
|
+
v = @db[k]
|
46
|
+
return @default[k] if v.nil?
|
47
|
+
return v
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# FIXME: Read default site config from super/_SiteConfig.txt
|
53
|
+
def default_config
|
54
|
+
{
|
55
|
+
'open' => 'false',
|
56
|
+
'theme' => 'qwikgreen',
|
57
|
+
'sitename' => '',
|
58
|
+
'aid' => 'q02-22', # amazon associate id
|
59
|
+
'ml_life_time' => (60 * 60 * 24 * 31).to_s, # 1 month
|
60
|
+
'reportmail' => 'hourly',
|
61
|
+
'reportfrom' => '',
|
62
|
+
'titlelink' => 'false',
|
63
|
+
'redirect' => 'false',
|
64
|
+
'siteurl' => '',
|
65
|
+
'siteml' => '',
|
66
|
+
'max_file_size' => (10 * 1024 * 1024).to_s, # 10MB
|
67
|
+
'page_title_first'=> 'true',
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
=begin
|
72
|
+
# Read default site config from super/_SiteConfig.txt
|
73
|
+
def read_default_config
|
74
|
+
dir = @config.super_dir.path
|
75
|
+
str = (dir + '_SiteConfig.txt').read
|
76
|
+
array = WikiDB.parse(str)
|
77
|
+
hash = array.to_hash
|
78
|
+
return hash
|
79
|
+
end
|
80
|
+
=end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if $0 == __FILE__
|
85
|
+
require 'qwik/test-module-session'
|
86
|
+
require 'qwik/site'
|
87
|
+
require 'qwik/farm'
|
88
|
+
$test = true
|
89
|
+
end
|
90
|
+
|
91
|
+
if defined?($test) && $test
|
92
|
+
class TestSiteConfig < Test::Unit::TestCase
|
93
|
+
include TestSession
|
94
|
+
|
95
|
+
def test_is_open?
|
96
|
+
eq false, @site.is_open?
|
97
|
+
page = @site.create '_SiteConfig'
|
98
|
+
page.store ':open:true'
|
99
|
+
eq true, @site.is_open?
|
100
|
+
page.store ':open:false'
|
101
|
+
eq false, @site.is_open?
|
102
|
+
@site.delete '_SiteConfig'
|
103
|
+
eq false, @site.is_open?
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_siteconfig
|
107
|
+
page = @site.create '_SiteConfig'
|
108
|
+
|
109
|
+
# test_theme
|
110
|
+
assert_instance_of String, @site.siteconfig['theme']
|
111
|
+
page.store(':theme:qwik')
|
112
|
+
|
113
|
+
# test_sitename
|
114
|
+
# eq 'example.com', @site.siteconfig['sitename']
|
115
|
+
# eq 'example.com/test', @site.title
|
116
|
+
page.store ':sitename:TestSite'
|
117
|
+
eq 'TestSite', @site.siteconfig['sitename']
|
118
|
+
eq 'TestSite', @site.title
|
119
|
+
|
120
|
+
# test_title
|
121
|
+
page = @site.create 'TestPage'
|
122
|
+
eq 'TestPage', page.get_title
|
123
|
+
# eq 'TestPage - TestSite', @site.title('TestPage')
|
124
|
+
eq 'TestSite', @site.title
|
125
|
+
|
126
|
+
page = @site.create '1'
|
127
|
+
eq '1', page.get_title
|
128
|
+
# eq '1 - TestSite', @site.title('1')
|
129
|
+
page.store('* TestTitle')
|
130
|
+
# eq 'TestTitle - TestSite', @site.title('1')
|
131
|
+
|
132
|
+
# test_bless
|
133
|
+
is false, @site.is_blessed?
|
134
|
+
file = @site.path + ",blessed"
|
135
|
+
file.write("")
|
136
|
+
is true, @site.is_blessed?
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_siteconfig_class
|
140
|
+
siteconfig = @site.siteconfig
|
141
|
+
|
142
|
+
assert_equal "#<Page:_SiteConfig>", siteconfig.get_page.inspect
|
143
|
+
|
144
|
+
assert_equal 'false', siteconfig['open']
|
145
|
+
|
146
|
+
assert_equal '10485760', siteconfig['max_file_size']
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
6
|
+
|
7
|
+
module Qwik
|
8
|
+
class Site
|
9
|
+
def sitedb
|
10
|
+
@sitedb = SiteDB.new(@config, self) unless defined? @sitedb
|
11
|
+
return @sitedb
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class SiteDB
|
16
|
+
def initialize(config, site)
|
17
|
+
require 'sqlite' # SQLite
|
18
|
+
#require 'sqlite3' # SQLite3
|
19
|
+
file = "#{config.cache_dir.path.to_win_dir}/#{site.sitename}.db"
|
20
|
+
@db = ::SQLite::Database.new(file, 0)
|
21
|
+
# @db = ::SQLite3::Database.new(file)
|
22
|
+
end
|
23
|
+
|
24
|
+
def table_exist?(table)
|
25
|
+
@db.table_info(table) {|row|
|
26
|
+
return true
|
27
|
+
}
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def quote(org)
|
32
|
+
::SQLite::Database.quote(org)
|
33
|
+
end
|
34
|
+
|
35
|
+
def encode(org)
|
36
|
+
::SQLite::Database.encode(org)
|
37
|
+
end
|
38
|
+
|
39
|
+
def decode(org)
|
40
|
+
::SQLite::Database.decode(org)
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_table(table)
|
44
|
+
raise unless /\A[a-z]+\z/ =~ table
|
45
|
+
quote(table) # make sure
|
46
|
+
end
|
47
|
+
|
48
|
+
def table_create(table)
|
49
|
+
t = check_table(table)
|
50
|
+
sql = <<'EOT'
|
51
|
+
create table #{t}
|
52
|
+
(
|
53
|
+
id INTEGER PRIMARY KEY,
|
54
|
+
key TEXT,
|
55
|
+
value VARCHAR
|
56
|
+
);
|
57
|
+
create index idx_#{t}_key on #{t} ( key );
|
58
|
+
EOT
|
59
|
+
@db.execute(sql)
|
60
|
+
end
|
61
|
+
|
62
|
+
def delete(t, k)
|
63
|
+
t = check_table(t)
|
64
|
+
k = quote(k)
|
65
|
+
@db.execute("delete from #{t} where key='#{k}';")
|
66
|
+
end
|
67
|
+
|
68
|
+
def set(t, k, v)
|
69
|
+
t = check_table(t)
|
70
|
+
k = quote(k)
|
71
|
+
delete(t, k) if get(t, k)
|
72
|
+
v = encode(v)
|
73
|
+
@db.execute("insert into #{t} values (NULL, '#{k}', '#{v}');")
|
74
|
+
end
|
75
|
+
|
76
|
+
def get(t, k)
|
77
|
+
t = check_table(t)
|
78
|
+
k = quote(k)
|
79
|
+
v = @db.get_first_value("select value from #{t} where key='#{k}'" )
|
80
|
+
return nil if v.nil?
|
81
|
+
decode(v)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
if $0 == __FILE__
|
87
|
+
require 'qwik/testunit'
|
88
|
+
require 'qwik/test-common'
|
89
|
+
require 'qwik/config'
|
90
|
+
require 'qwik/server-memory'
|
91
|
+
$test = true
|
92
|
+
end
|
93
|
+
|
94
|
+
if defined?($test) && $test
|
95
|
+
module Qwik
|
96
|
+
class SiteDB
|
97
|
+
attr_reader :db
|
98
|
+
def test(t)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class TestSiteDB < Test::Unit::TestCase
|
104
|
+
def test_all
|
105
|
+
# not yet.
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class CheckSiteDB < Test::Unit::TestCase
|
110
|
+
include TestSession
|
111
|
+
|
112
|
+
def test_all
|
113
|
+
db = @site.sitedb
|
114
|
+
|
115
|
+
# test_quote
|
116
|
+
eq "''", db.quote("'") # only this...
|
117
|
+
eq 'BAhpAA==', db.encode(0) # marshal and base64
|
118
|
+
eq 0, db.decode('BAhpAA==')
|
119
|
+
|
120
|
+
# test_sitedb
|
121
|
+
assert_instance_of(SQLite::Database, db.db)
|
122
|
+
#assert_instance_of(SQLite3::Database, db.db)
|
123
|
+
db.db.database_list {|row|
|
124
|
+
assert_instance_of(Array, row)
|
125
|
+
}
|
126
|
+
|
127
|
+
#eq '2.8.15', SQLite::Database::VERSION
|
128
|
+
#eq 'iso8859', SQLite::Database::ENCODING
|
129
|
+
db.table_create('test') unless db.table_exist?('test')
|
130
|
+
db.set('test', 'k', 'v')
|
131
|
+
eq 'v', db.get('test', 'k')
|
132
|
+
db.delete('test', 'k')
|
133
|
+
eq nil, db.get('test', 'k')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|