qwikdoc 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/CHANGES +3 -0
- data/COPYING +340 -0
- data/Gemfile +3 -0
- data/README.md +10 -0
- data/Rakefile +10 -0
- data/TextFormattingRules +137 -0
- data/TextFormattingRules.ja +143 -0
- data/bin/qwikdoc +34 -0
- data/lib/qwik_doc.rb +15 -0
- data/lib/qwik_doc/hack.rb +184 -0
- data/qwikdoc.gemspec +26 -0
- data/spec/qwik_doc_spec.rb +305 -0
- data/spec/spec_helper.rb +12 -0
- data/vendor/qwik/Makefile +63 -0
- data/vendor/qwik/Rakefile +17 -0
- data/vendor/qwik/act-aa.rb +83 -0
- data/vendor/qwik/act-archive.rb +386 -0
- data/vendor/qwik/act-attach.rb +304 -0
- data/vendor/qwik/act-backup.rb +236 -0
- data/vendor/qwik/act-basic.rb +325 -0
- data/vendor/qwik/act-book.rb +161 -0
- data/vendor/qwik/act-calc.rb +371 -0
- data/vendor/qwik/act-charset.rb +251 -0
- data/vendor/qwik/act-christel.rb +112 -0
- data/vendor/qwik/act-chronology.rb +149 -0
- data/vendor/qwik/act-code.rb +155 -0
- data/vendor/qwik/act-comment.rb +554 -0
- data/vendor/qwik/act-config.rb +49 -0
- data/vendor/qwik/act-counter.rb +125 -0
- data/vendor/qwik/act-day.rb +96 -0
- data/vendor/qwik/act-describe.rb +135 -0
- data/vendor/qwik/act-diary.rb +109 -0
- data/vendor/qwik/act-edit.rb +317 -0
- data/vendor/qwik/act-embed-html.rb +296 -0
- data/vendor/qwik/act-emode.rb +150 -0
- data/vendor/qwik/act-event.rb +187 -0
- data/vendor/qwik/act-file.rb +303 -0
- data/vendor/qwik/act-files.rb +771 -0
- data/vendor/qwik/act-getpass.rb +295 -0
- data/vendor/qwik/act-history.rb +136 -0
- data/vendor/qwik/act-html.rb +204 -0
- data/vendor/qwik/act-httpauth.rb +147 -0
- data/vendor/qwik/act-include.rb +142 -0
- data/vendor/qwik/act-interwiki.rb +189 -0
- data/vendor/qwik/act-isearch.rb +109 -0
- data/vendor/qwik/act-keywords.rb +137 -0
- data/vendor/qwik/act-lang.rb +81 -0
- data/vendor/qwik/act-license.rb +63 -0
- data/vendor/qwik/act-list.rb +287 -0
- data/vendor/qwik/act-login.rb +410 -0
- data/vendor/qwik/act-logout.rb +60 -0
- data/vendor/qwik/act-mail.rb +159 -0
- data/vendor/qwik/act-map.rb +292 -0
- data/vendor/qwik/act-md5.rb +42 -0
- data/vendor/qwik/act-mdlb.rb +741 -0
- data/vendor/qwik/act-media.rb +416 -0
- data/vendor/qwik/act-member.rb +157 -0
- data/vendor/qwik/act-menu.rb +142 -0
- data/vendor/qwik/act-metadata.rb +323 -0
- data/vendor/qwik/act-mlsubmitform.rb +49 -0
- data/vendor/qwik/act-monitor.rb +167 -0
- data/vendor/qwik/act-new.rb +418 -0
- data/vendor/qwik/act-pagelist.rb +248 -0
- data/vendor/qwik/act-password.rb +145 -0
- data/vendor/qwik/act-plan.rb +210 -0
- data/vendor/qwik/act-povray.rb +230 -0
- data/vendor/qwik/act-presen.rb +380 -0
- data/vendor/qwik/act-redirect.rb +133 -0
- data/vendor/qwik/act-ring.rb +1071 -0
- data/vendor/qwik/act-rrefs.rb +255 -0
- data/vendor/qwik/act-ruby.rb +116 -0
- data/vendor/qwik/act-sample.rb +170 -0
- data/vendor/qwik/act-save.rb +295 -0
- data/vendor/qwik/act-schedule.rb +374 -0
- data/vendor/qwik/act-search.rb +180 -0
- data/vendor/qwik/act-searchwords.rb +51 -0
- data/vendor/qwik/act-sendpass.rb +83 -0
- data/vendor/qwik/act-site.rb +89 -0
- data/vendor/qwik/act-sitebackup.rb +419 -0
- data/vendor/qwik/act-sitelog.rb +118 -0
- data/vendor/qwik/act-smil.rb +299 -0
- data/vendor/qwik/act-status.rb +220 -0
- data/vendor/qwik/act-style.rb +608 -0
- data/vendor/qwik/act-table.rb +263 -0
- data/vendor/qwik/act-tableform.rb +241 -0
- data/vendor/qwik/act-tag.rb +103 -0
- data/vendor/qwik/act-text.rb +70 -0
- data/vendor/qwik/act-textarea.rb +164 -0
- data/vendor/qwik/act-theme.rb +346 -0
- data/vendor/qwik/act-toc.rb +112 -0
- data/vendor/qwik/act-typekey.rb +198 -0
- data/vendor/qwik/act-under-const.rb +94 -0
- data/vendor/qwik/act-webservice.rb +321 -0
- data/vendor/qwik/act-wema.rb +558 -0
- data/vendor/qwik/act-wysiwyg.rb +238 -0
- data/vendor/qwik/action.rb +325 -0
- data/vendor/qwik/autoreload.rb +98 -0
- data/vendor/qwik/bench-bench.rb +28 -0
- data/vendor/qwik/bench-emode.rb +47 -0
- data/vendor/qwik/bench-format-xml.rb +70 -0
- data/vendor/qwik/bench-large-table.rb +62 -0
- data/vendor/qwik/bench-md5.rb +14 -0
- data/vendor/qwik/bench-module-session.rb +19 -0
- data/vendor/qwik/bench-page.rb +50 -0
- data/vendor/qwik/bench-s-md5.rb +28 -0
- data/vendor/qwik/bench-session.rb +25 -0
- data/vendor/qwik/bench-textformat.rb +31 -0
- data/vendor/qwik/catalog-factory.rb +91 -0
- data/vendor/qwik/catalog-ja.rb +479 -0
- data/vendor/qwik/catalog-ml-ja.rb +145 -0
- data/vendor/qwik/check-act-monitor.rb +112 -0
- data/vendor/qwik/check-act-monitor2.rb +46 -0
- data/vendor/qwik/check-act-theme.rb +27 -0
- data/vendor/qwik/check-event.rb +112 -0
- data/vendor/qwik/check-event2.rb +55 -0
- data/vendor/qwik/check-htree-rexml.rb +77 -0
- data/vendor/qwik/check-htree.rb +51 -0
- data/vendor/qwik/check-libxml.rb +135 -0
- data/vendor/qwik/check-many-pages.rb +47 -0
- data/vendor/qwik/check-monitor.rb +33 -0
- data/vendor/qwik/check-observer.rb +67 -0
- data/vendor/qwik/check-server.rb +61 -0
- data/vendor/qwik/check-uuencode.rb +33 -0
- data/vendor/qwik/check-webdav.rb +65 -0
- data/vendor/qwik/check-xml-xpath.rb +27 -0
- data/vendor/qwik/common-backtrace.rb +94 -0
- data/vendor/qwik/common-basic.rb +111 -0
- data/vendor/qwik/common-condition.rb +142 -0
- data/vendor/qwik/common-error.rb +48 -0
- data/vendor/qwik/common-gettext.rb +50 -0
- data/vendor/qwik/common-javascript.rb +45 -0
- data/vendor/qwik/common-notice.rb +132 -0
- data/vendor/qwik/common-plain.rb +105 -0
- data/vendor/qwik/common-plugin.rb +111 -0
- data/vendor/qwik/common-res.rb +76 -0
- data/vendor/qwik/common-resolve.rb +92 -0
- data/vendor/qwik/common-send.rb +171 -0
- data/vendor/qwik/common-session.rb +139 -0
- data/vendor/qwik/common-surface.rb +261 -0
- data/vendor/qwik/common-url.rb +90 -0
- data/vendor/qwik/compat/Makefile +12 -0
- data/vendor/qwik/compat/add_load_path.rb +1 -0
- data/vendor/qwik/config.rb +299 -0
- data/vendor/qwik/db-b-backup.rb +142 -0
- data/vendor/qwik/db-backup.rb +184 -0
- data/vendor/qwik/db-berkeley.rb +306 -0
- data/vendor/qwik/db-filesystem.rb +305 -0
- data/vendor/qwik/db-indexer.rb +154 -0
- data/vendor/qwik/db-searchwords.rb +238 -0
- data/vendor/qwik/description-ja.rb +267 -0
- data/vendor/qwik/description.rb +256 -0
- data/vendor/qwik/dev-add-copyright.rb +23 -0
- data/vendor/qwik/dev-backup.rb +24 -0
- data/vendor/qwik/dev-bench.rb +175 -0
- data/vendor/qwik/dev-calctime.rb +52 -0
- data/vendor/qwik/dev-css-compressor.rb +60 -0
- data/vendor/qwik/dev-extract-catalog.rb +102 -0
- data/vendor/qwik/dev-js-compressor.rb +73 -0
- data/vendor/qwik/dev-release.rb +235 -0
- data/vendor/qwik/dev-replace.rb +353 -0
- data/vendor/qwik/dev-sendmail.rb +25 -0
- data/vendor/qwik/farm.rb +283 -0
- data/vendor/qwik/gettext.rb +56 -0
- data/vendor/qwik/group-cond.rb +157 -0
- data/vendor/qwik/group-config.rb +247 -0
- data/vendor/qwik/group-confirm.rb +147 -0
- data/vendor/qwik/group-db.rb +326 -0
- data/vendor/qwik/group-mail.rb +195 -0
- data/vendor/qwik/group-member.rb +307 -0
- data/vendor/qwik/group-sendmail.rb +231 -0
- data/vendor/qwik/group-site.rb +374 -0
- data/vendor/qwik/group-sweep.rb +63 -0
- data/vendor/qwik/group.rb +157 -0
- data/vendor/qwik/helper.rb +6 -0
- data/vendor/qwik/html-generator.rb +104 -0
- data/vendor/qwik/html-to-wabisabi.rb +149 -0
- data/vendor/qwik/htree-diff.rb +87 -0
- data/vendor/qwik/htree-format-xml.rb +57 -0
- data/vendor/qwik/htree-generator.rb +144 -0
- data/vendor/qwik/htree-get.rb +251 -0
- data/vendor/qwik/htree-html-generator.rb +179 -0
- data/vendor/qwik/htree-template.rb +263 -0
- data/vendor/qwik/htree-to-wabisabi.rb +171 -0
- data/vendor/qwik/loadlib.rb +79 -0
- data/vendor/qwik/logger.rb +115 -0
- data/vendor/qwik/mail-body.rb +171 -0
- data/vendor/qwik/mail-header.rb +474 -0
- data/vendor/qwik/mail-multipart.rb +193 -0
- data/vendor/qwik/mail-parse.rb +147 -0
- data/vendor/qwik/mail.rb +341 -0
- data/vendor/qwik/mailaddress.rb +83 -0
- data/vendor/qwik/mdlb-model.rb +81 -0
- data/vendor/qwik/mdlb-sample.rb +324 -0
- data/vendor/qwik/ml-catalog-factory.rb +27 -0
- data/vendor/qwik/ml-exception.rb +15 -0
- data/vendor/qwik/ml-generator.rb +28 -0
- data/vendor/qwik/ml-gettext.rb +137 -0
- data/vendor/qwik/ml-logger.rb +82 -0
- data/vendor/qwik/ml-memory.rb +65 -0
- data/vendor/qwik/ml-msg-validator.rb +86 -0
- data/vendor/qwik/ml-processor.rb +609 -0
- data/vendor/qwik/ml-quickml-server.rb +122 -0
- data/vendor/qwik/ml-sendmail.rb +0 -0
- data/vendor/qwik/ml-server.rb +107 -0
- data/vendor/qwik/ml-session.rb +348 -0
- data/vendor/qwik/ml-sweeper.rb +101 -0
- data/vendor/qwik/mock-logger.rb +65 -0
- data/vendor/qwik/mock-sendmail.rb +78 -0
- data/vendor/qwik/mock-socket.rb +82 -0
- data/vendor/qwik/modulobe.rb +406 -0
- data/vendor/qwik/mongrel-server.rb +72 -0
- data/vendor/qwik/page-files.rb +249 -0
- data/vendor/qwik/page-generate.rb +82 -0
- data/vendor/qwik/page-get.rb +262 -0
- data/vendor/qwik/page-images.rb +168 -0
- data/vendor/qwik/page-put.rb +128 -0
- data/vendor/qwik/page-rrefs.rb +154 -0
- data/vendor/qwik/page-title.rb +0 -0
- data/vendor/qwik/page-wikidb.rb +234 -0
- data/vendor/qwik/page.rb +67 -0
- data/vendor/qwik/pages.rb +444 -0
- data/vendor/qwik/parse-plugin.rb +249 -0
- data/vendor/qwik/parser-emode.rb +116 -0
- data/vendor/qwik/parser-inline.rb +273 -0
- data/vendor/qwik/parser.rb +350 -0
- data/vendor/qwik/password.rb +183 -0
- data/vendor/qwik/periodic.rb +79 -0
- data/vendor/qwik/qp.rb +56 -0
- data/vendor/qwik/qwik-service.rb +341 -0
- data/vendor/qwik/qwik.rb +5 -0
- data/vendor/qwik/qwikweb-adduser.rb +34 -0
- data/vendor/qwik/qwikweb-catalog-validator.rb +110 -0
- data/vendor/qwik/qwikweb-incgen.rb +28 -0
- data/vendor/qwik/qwikweb-makesite.rb +41 -0
- data/vendor/qwik/qwikweb-server.rb +44 -0
- data/vendor/qwik/qwikweb-showpassword.rb +26 -0
- data/vendor/qwik/qwikweb-watchlog.rb +67 -0
- data/vendor/qwik/request-path.rb +304 -0
- data/vendor/qwik/request-ua.rb +76 -0
- data/vendor/qwik/request-webrick.rb +81 -0
- data/vendor/qwik/request.rb +91 -0
- data/vendor/qwik/resolve-tdiary.rb +292 -0
- data/vendor/qwik/resolve.rb +121 -0
- data/vendor/qwik/response.rb +228 -0
- data/vendor/qwik/server-memory.rb +57 -0
- data/vendor/qwik/server-webrick.rb +102 -0
- data/vendor/qwik/server.rb +252 -0
- data/vendor/qwik/site-config.rb +149 -0
- data/vendor/qwik/site-db.rb +136 -0
- data/vendor/qwik/site-event.rb +162 -0
- data/vendor/qwik/site-files.rb +86 -0
- data/vendor/qwik/site-group.rb +103 -0
- data/vendor/qwik/site-index.rb +47 -0
- data/vendor/qwik/site-log.rb +64 -0
- data/vendor/qwik/site-member.rb +230 -0
- data/vendor/qwik/site-monitor.rb +97 -0
- data/vendor/qwik/site-pages.rb +62 -0
- data/vendor/qwik/site-plan.rb +139 -0
- data/vendor/qwik/site-report.rb +282 -0
- data/vendor/qwik/site-resolve.rb +230 -0
- data/vendor/qwik/site-rrefs.rb +18 -0
- data/vendor/qwik/site-search.rb +180 -0
- data/vendor/qwik/site-timeline.rb +153 -0
- data/vendor/qwik/site-url.rb +189 -0
- data/vendor/qwik/site.rb +76 -0
- data/vendor/qwik/smil-time.rb +105 -0
- data/vendor/qwik/smtp-session.rb +331 -0
- data/vendor/qwik/template-generator.rb +149 -0
- data/vendor/qwik/template.rb +85 -0
- data/vendor/qwik/test-common.rb +10 -0
- data/vendor/qwik/test-ml-info.rb +225 -0
- data/vendor/qwik/test-module-ml.rb +142 -0
- data/vendor/qwik/test-module-path.rb +110 -0
- data/vendor/qwik/test-module-public.rb +70 -0
- data/vendor/qwik/test-module-server.rb +98 -0
- data/vendor/qwik/test-module-session.rb +264 -0
- data/vendor/qwik/test-module-suite.rb +91 -0
- data/vendor/qwik/test-ms-applemail.rb +59 -0
- data/vendor/qwik/test-ms-attach.rb +174 -0
- data/vendor/qwik/test-ms-basic.rb +40 -0
- data/vendor/qwik/test-ms-close.rb +35 -0
- data/vendor/qwik/test-ms-confirm.rb +75 -0
- data/vendor/qwik/test-ms-ignore-spam.rb +57 -0
- data/vendor/qwik/test-ms-japanese.rb +97 -0
- data/vendor/qwik/test-ms-jfilename.rb +82 -0
- data/vendor/qwik/test-ms-large.rb +58 -0
- data/vendor/qwik/test-ms-member.rb +103 -0
- data/vendor/qwik/test-ms-multipart.rb +84 -0
- data/vendor/qwik/test-ms-org.rb +129 -0
- data/vendor/qwik/test-ms-plan.rb +130 -0
- data/vendor/qwik/test-ms-post.rb +53 -0
- data/vendor/qwik/test-ms-quopri.rb +76 -0
- data/vendor/qwik/test-sub-quopri.rb +45 -0
- data/vendor/qwik/test-submit-base64.rb +59 -0
- data/vendor/qwik/test-submit-forward.rb +61 -0
- data/vendor/qwik/test-submit-html-mail.rb +52 -0
- data/vendor/qwik/test-submit-japanese.rb +135 -0
- data/vendor/qwik/test-submit-jfilename.rb +144 -0
- data/vendor/qwik/test-submit-uuencode.rb +71 -0
- data/vendor/qwik/test-suite-all.rb +8 -0
- data/vendor/qwik/test-suite-basic.rb +9 -0
- data/vendor/qwik/test-suite-ml.rb +9 -0
- data/vendor/qwik/test-typekey.rb +64 -0
- data/vendor/qwik/testunit.rb +45 -0
- data/vendor/qwik/tokenizer-inline.rb +294 -0
- data/vendor/qwik/tokenizer.rb +332 -0
- data/vendor/qwik/typekey.rb +160 -0
- data/vendor/qwik/util-basic.rb +135 -0
- data/vendor/qwik/util-charset.rb +332 -0
- data/vendor/qwik/util-css.rb +56 -0
- data/vendor/qwik/util-csv-tokenizer.rb +113 -0
- data/vendor/qwik/util-filename.rb +112 -0
- data/vendor/qwik/util-pathname.rb +202 -0
- data/vendor/qwik/util-pid.rb +58 -0
- data/vendor/qwik/util-safe.rb +67 -0
- data/vendor/qwik/util-sendmail.rb +273 -0
- data/vendor/qwik/util-string.rb +203 -0
- data/vendor/qwik/util-time.rb +125 -0
- data/vendor/qwik/util-webrick.rb +176 -0
- data/vendor/qwik/version.rb +11 -0
- data/vendor/qwik/wabisabi-basic.rb +163 -0
- data/vendor/qwik/wabisabi-diff.rb +130 -0
- data/vendor/qwik/wabisabi-format-xml.rb +310 -0
- data/vendor/qwik/wabisabi-generator.rb +262 -0
- data/vendor/qwik/wabisabi-index.rb +174 -0
- data/vendor/qwik/wabisabi-table.rb +212 -0
- data/vendor/qwik/wabisabi-template.rb +295 -0
- data/vendor/qwik/wabisabi-to-htree.rb +111 -0
- data/vendor/qwik/wabisabi-to-wiki.rb +690 -0
- data/vendor/qwik/wabisabi-traverse.rb +207 -0
- data/vendor/qwik/wabisabi-validator.rb +116 -0
- data/vendor/qwik/wabisabi.rb +5 -0
- metadata +416 -0
|
@@ -0,0 +1,76 @@
|
|
|
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/parser'
|
|
7
|
+
require 'qwik/resolve'
|
|
8
|
+
require 'qwik/page-generate'
|
|
9
|
+
|
|
10
|
+
module Qwik
|
|
11
|
+
class Action
|
|
12
|
+
def p_error(msg)
|
|
13
|
+
return [:div, {:class=>'error'}, [:strong, _('Error'), ':'], ' ', msg]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# ==================== generate from string
|
|
17
|
+
def c_tokenize(str)
|
|
18
|
+
return TextTokenizer.tokenize(str)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def c_parse(str)
|
|
22
|
+
tokens = TextTokenizer.tokenize(str)
|
|
23
|
+
return TextParser.make_tree(tokens)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def c_res(str)
|
|
27
|
+
tokens = TextTokenizer.tokenize(str)
|
|
28
|
+
tree = TextParser.make_tree(tokens)
|
|
29
|
+
return Resolver.resolve(@site, self, tree)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# ==================== generate for page
|
|
33
|
+
def c_page_res(pagename)
|
|
34
|
+
page = @site[pagename]
|
|
35
|
+
return nil if page.nil?
|
|
36
|
+
tree = page.get_tree
|
|
37
|
+
return Resolver.resolve(@site, self, tree)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if $0 == __FILE__
|
|
43
|
+
require 'qwik/test-common'
|
|
44
|
+
$test = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
if defined?($test) && $test
|
|
48
|
+
class TestActGenerate < Test::Unit::TestCase
|
|
49
|
+
include TestSession
|
|
50
|
+
|
|
51
|
+
def test_all
|
|
52
|
+
res = session
|
|
53
|
+
a = @action
|
|
54
|
+
|
|
55
|
+
# test_p_error
|
|
56
|
+
eq [:div, {:class=>'error'}, [:strong, 'Error', ':'], ' ', 'e'],
|
|
57
|
+
a.p_error('e')
|
|
58
|
+
|
|
59
|
+
# test_c_tokenize
|
|
60
|
+
eq [[:text, "a"], [:text, "b"]], a.c_tokenize("a\nb")
|
|
61
|
+
|
|
62
|
+
# test_c_parse
|
|
63
|
+
eq [[:p, 'a', "\n", 'b']], a.c_parse("a\nb")
|
|
64
|
+
|
|
65
|
+
# test_c_page_res
|
|
66
|
+
page = @site.create_new
|
|
67
|
+
page.store('* t')
|
|
68
|
+
eq [[:h2, 't']], a.c_page_res('1')
|
|
69
|
+
|
|
70
|
+
page = @site.create_new
|
|
71
|
+
page.store('[[1]]')
|
|
72
|
+
eq [[:p, [:a, {:href=>'1.html'}, 't']]], a.c_page_res('2')
|
|
73
|
+
# FIXME: The cache should be cleaned.
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
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/wabisabi-template'
|
|
7
|
+
|
|
8
|
+
module Qwik
|
|
9
|
+
class Action
|
|
10
|
+
def resolve_all_plugin(wabisabi)
|
|
11
|
+
return wabisabi.each_tag(:plugin) {|w|
|
|
12
|
+
resolve_plugin(w)
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Make index before call this method. Use parent.
|
|
17
|
+
def nunuresolve_all_plugin(wabisabi)
|
|
18
|
+
#wabisabi.make_index
|
|
19
|
+
wabisabi.index_each_tag(:plugin) {|e|
|
|
20
|
+
resolve_plugin(e)
|
|
21
|
+
}
|
|
22
|
+
return wabisabi
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def nu2_resolve_all_plugin(wabisabi)
|
|
26
|
+
wabisabi.make_index
|
|
27
|
+
return wabisabi.index_each_tag(:plugin) {|e|
|
|
28
|
+
new_ele = resolve_plugin(e)
|
|
29
|
+
e.replace(new_ele)
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def resolve_plugin(w)
|
|
34
|
+
attr = w.attr
|
|
35
|
+
return [] if attr.nil?
|
|
36
|
+
|
|
37
|
+
method = attr[:method]
|
|
38
|
+
return [] if method.nil? || method.empty?
|
|
39
|
+
|
|
40
|
+
param = attr[:param]
|
|
41
|
+
param ||= ''
|
|
42
|
+
|
|
43
|
+
if w[2]
|
|
44
|
+
data = w[2].to_s
|
|
45
|
+
result = self.c_call_plugin(method, param) { data }
|
|
46
|
+
else
|
|
47
|
+
result = self.c_call_plugin(method, param)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
result = [] if result.nil?
|
|
51
|
+
#result = [] if result.empty?
|
|
52
|
+
result = [result] if ! result.is_a?(Array)
|
|
53
|
+
return result
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if $0 == __FILE__
|
|
59
|
+
require 'qwik/test-common'
|
|
60
|
+
$test = true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if defined?($test) && $test
|
|
64
|
+
class TestActResolve < Test::Unit::TestCase
|
|
65
|
+
include TestSession
|
|
66
|
+
|
|
67
|
+
def ok(e, w)
|
|
68
|
+
eq e, @action.resolve_plugin(w)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_resolve_plugin
|
|
72
|
+
res = session
|
|
73
|
+
ok [], [:a]
|
|
74
|
+
ok [], [[:plugin]] # error
|
|
75
|
+
ok [], [[:plugin, 't']] # error
|
|
76
|
+
ok [:br], [:plugin, {:method=>'br', :param=>''}, '']
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def ok_all(e, w)
|
|
80
|
+
w.make_index
|
|
81
|
+
eq e, @action.resolve_all_plugin(w)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_resolve_all_plugin
|
|
85
|
+
res = session
|
|
86
|
+
ok_all [[:br]], [[:plugin, {:method=>'br', :param=>''}, '']]
|
|
87
|
+
ok_all [[:span, {:class=>"plg_error"}, "nosuch plugin | ",
|
|
88
|
+
[:strong, "nosuchplugin"]]],
|
|
89
|
+
[[:plugin, {:method=>'nosuchplugin', :param=>''}, '']]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
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 Action
|
|
9
|
+
def c_simple_send(path, type=nil)
|
|
10
|
+
return SimpleSender.send(@config, @req, @res, path.to_s, type)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def c_download(path)
|
|
14
|
+
return SimpleSender.download(@req, @res, path.to_s, @config.test)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class SimpleSender
|
|
19
|
+
# copied from webrick
|
|
20
|
+
def self.send(config, req, res, local_path, mtype=nil)
|
|
21
|
+
local_path = local_path.path
|
|
22
|
+
if ! local_path.exist?
|
|
23
|
+
raise WEBrick::HTTPStatus::NotFound
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
st = local_path.stat
|
|
27
|
+
res['etag'] = sprintf('%x-%x-%x', st.ino, st.size, st.mtime.to_i)
|
|
28
|
+
|
|
29
|
+
if not_modified?(req, res, st.mtime)
|
|
30
|
+
res.body = ''
|
|
31
|
+
raise WEBrick::HTTPStatus::NotModified
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
if mtype.nil?
|
|
35
|
+
mtype = res.get_mimetypes(local_path.ext) # Get content type.
|
|
36
|
+
end
|
|
37
|
+
res['Content-Type'] = mtype
|
|
38
|
+
res['Content-Length'] = st.size
|
|
39
|
+
res['Last-Modified'] = st.mtime.httpdate
|
|
40
|
+
|
|
41
|
+
if config.ssl || config.test
|
|
42
|
+
# BUG: ssl can not send data as stream.
|
|
43
|
+
res.body = local_path.read
|
|
44
|
+
else
|
|
45
|
+
res.body = open(local_path.to_s, 'rb')
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.download(req, res, local_path, test=false)
|
|
50
|
+
local_path = local_path.path
|
|
51
|
+
if ! local_path.exist?
|
|
52
|
+
raise WEBrick::HTTPStatus::NotFound
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
st = local_path.stat
|
|
56
|
+
res['etag'] = sprintf('%x-%x-%x', st.ino, st.size, st.mtime.to_i)
|
|
57
|
+
|
|
58
|
+
if not_modified?(req, res, st.mtime)
|
|
59
|
+
res.body = ''
|
|
60
|
+
raise WEBrick::HTTPStatus::NotModified
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
res.set_content_type(local_path.ext)
|
|
64
|
+
res['Content-Length'] = st.size
|
|
65
|
+
res['Last-Modified'] = st.mtime.httpdate
|
|
66
|
+
|
|
67
|
+
basename = local_path.basename
|
|
68
|
+
decoded = Filename.decode(basename.to_s) # UTF-8
|
|
69
|
+
filename = decoded.to_page_charset
|
|
70
|
+
res['Content-Disposition'] = "attachment; filename=\"#{filename}\""
|
|
71
|
+
|
|
72
|
+
if test
|
|
73
|
+
res.body = local_path.read
|
|
74
|
+
else
|
|
75
|
+
res.body = open(local_path.to_s, 'rb')
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.fsend(config, req, res, local_path, mtype, dfilename)
|
|
80
|
+
local_path = local_path.path
|
|
81
|
+
if ! local_path.exist?
|
|
82
|
+
raise WEBrick::HTTPStatus::NotFound
|
|
83
|
+
end
|
|
84
|
+
res['Content-Type'] = mtype
|
|
85
|
+
res['Content-Disposition'] = ' attachment; filename='+dfilename
|
|
86
|
+
res.body = local_path.read
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def self.not_modified?(req, res, mtime)
|
|
92
|
+
if ir = req['if-range']
|
|
93
|
+
begin
|
|
94
|
+
return true if mtime <= ::Time.httpdate(ir)
|
|
95
|
+
rescue
|
|
96
|
+
if WEBrick::HTTPUtils::split_header_valie(ir).member?(res['etag'])
|
|
97
|
+
return true
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
if (ims = req['if-modified-since']) && mtime <= ::Time.parse(ims)
|
|
103
|
+
return true
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if (inm = req['if-none-match']) &&
|
|
107
|
+
WEBrick::HTTPUtils::split_header_value(inm).member?(res['etag'])
|
|
108
|
+
return true
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
return false
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if $0 == __FILE__
|
|
117
|
+
require 'qwik/test-common'
|
|
118
|
+
$test = true
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if defined?($test) && $test
|
|
122
|
+
class TestCommon < Test::Unit::TestCase
|
|
123
|
+
include TestSession
|
|
124
|
+
|
|
125
|
+
def test_simple_send
|
|
126
|
+
t_add_user
|
|
127
|
+
|
|
128
|
+
page = @site.create_new
|
|
129
|
+
page.store('t')
|
|
130
|
+
|
|
131
|
+
# At the first, attach a text file for test.
|
|
132
|
+
res = session('POST /test/1.files') {|req|
|
|
133
|
+
req.query.update('content'=>t_make_content('t.txt', 't'))
|
|
134
|
+
}
|
|
135
|
+
ok_title('File attachment completed')
|
|
136
|
+
|
|
137
|
+
# Get the content using simple send.
|
|
138
|
+
res = session('/test/1.files/t.txt')
|
|
139
|
+
ok_eq('text/plain', res['Content-Type'])
|
|
140
|
+
ok_eq('t', res.body)
|
|
141
|
+
|
|
142
|
+
t_without_testmode {
|
|
143
|
+
res = session('/test/1.files/t.txt')
|
|
144
|
+
ok_eq('text/plain', res['Content-Type'])
|
|
145
|
+
assert_instance_of(File, res.body)
|
|
146
|
+
str = res.body.read
|
|
147
|
+
res.body.close # important
|
|
148
|
+
ok_eq('t', str)
|
|
149
|
+
}
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_download
|
|
153
|
+
t_add_user
|
|
154
|
+
|
|
155
|
+
page = @site.create_new
|
|
156
|
+
page.store('t')
|
|
157
|
+
|
|
158
|
+
# At the first, attach a test file.
|
|
159
|
+
res = session('POST /test/1.files') {|req|
|
|
160
|
+
req.query.update('content'=>t_make_content('t.txt', 't'))
|
|
161
|
+
}
|
|
162
|
+
ok_title('File attachment completed')
|
|
163
|
+
|
|
164
|
+
# Get the content by download.
|
|
165
|
+
res = session('/test/1.download/t.txt')
|
|
166
|
+
ok_eq('text/plain', res['Content-Type'])
|
|
167
|
+
ok_eq("attachment; filename=\"t.txt\"", res['Content-Disposition'])
|
|
168
|
+
ok_eq('t', res.body)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
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 Action
|
|
9
|
+
# ============================== verify
|
|
10
|
+
# called from act-login.rb:41
|
|
11
|
+
def check_session
|
|
12
|
+
sid = @req.cookies['sid'] # get session id from cookie.
|
|
13
|
+
return if sid.nil? || sid.empty? # return if you don't have session id.
|
|
14
|
+
sdb = @memory.sessiondb
|
|
15
|
+
user = sdb.get(sid) # Get user from SessionDB.
|
|
16
|
+
return if user.nil? # return if there is no session id.
|
|
17
|
+
@req.user = user # OK! I have your sesssion id. I know who you are.
|
|
18
|
+
@req.auth = 'session'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# ============================== login
|
|
22
|
+
# called from act-login, act-typkey and this file.
|
|
23
|
+
def session_store(user)
|
|
24
|
+
sdb = @memory.sessiondb
|
|
25
|
+
sid = sdb.generate_sid # Make a new session id.
|
|
26
|
+
sdb.put(sid, user) # Store the session id to session db.
|
|
27
|
+
return sid
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# ============================== logout
|
|
31
|
+
def session_clear
|
|
32
|
+
sid = @req.cookies['sid'] # Get sid from cookie.
|
|
33
|
+
return if sid.nil? || sid.empty? # return if you don't have session id.
|
|
34
|
+
sdb = @memory.sessiondb
|
|
35
|
+
user = sdb.get(sid) # Get user from SessionDB.
|
|
36
|
+
return if user.nil? # return if there is no session id.
|
|
37
|
+
sdb.clear(sid)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class SessionDB
|
|
42
|
+
DEFAULT_EXPIRE_TIME = 60 * 60 * 24 * 14 # 2 weeks
|
|
43
|
+
|
|
44
|
+
def initialize(config)
|
|
45
|
+
@config = config
|
|
46
|
+
@config.cache_dir.path.check_directory
|
|
47
|
+
@path = @config.cache_dir.path+'sid'
|
|
48
|
+
@path.check_directory
|
|
49
|
+
@expire_time = DEFAULT_EXPIRE_TIME
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def generate_sid
|
|
53
|
+
str = Time.now.to_i.to_s+':'+rand.to_s
|
|
54
|
+
return str.md5hex
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def path(sid)
|
|
58
|
+
@path + sid
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def put(sid, user)
|
|
62
|
+
path(sid).put(user)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def clear(sid)
|
|
66
|
+
file = path(sid)
|
|
67
|
+
return nil if ! file.exist?
|
|
68
|
+
file.unlink # delete it
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def get(sid)
|
|
72
|
+
return if sid.nil? || sid.empty?
|
|
73
|
+
file = path(sid)
|
|
74
|
+
return nil if ! file.exist?
|
|
75
|
+
mtime = file.mtime
|
|
76
|
+
diff = Time.now.to_i - mtime.to_i
|
|
77
|
+
if @expire_time < diff
|
|
78
|
+
clear(sid)
|
|
79
|
+
return nil
|
|
80
|
+
end
|
|
81
|
+
str = file.read
|
|
82
|
+
return str
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
if $0 == __FILE__
|
|
88
|
+
require 'qwik/test-common'
|
|
89
|
+
$test = true
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if defined?($test) && $test
|
|
93
|
+
class TestCommonSession < Test::Unit::TestCase
|
|
94
|
+
include TestSession
|
|
95
|
+
|
|
96
|
+
def test_all
|
|
97
|
+
# not yet
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class TestSessionDB < Test::Unit::TestCase
|
|
102
|
+
def test_all
|
|
103
|
+
if defined?($test_memory)
|
|
104
|
+
@memory = $test_memory
|
|
105
|
+
else
|
|
106
|
+
@memory = Qwik::ServerMemory.new(@config)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
sdb = @memory.sessiondb
|
|
110
|
+
|
|
111
|
+
# test generate session id
|
|
112
|
+
sid = sdb.generate_sid
|
|
113
|
+
ok_eq(32, sid.length)
|
|
114
|
+
assert_match(/\A[0-9a-f]+\z/, sid)
|
|
115
|
+
|
|
116
|
+
# test put
|
|
117
|
+
sdb.put(sid, 'user@e.com')
|
|
118
|
+
file = sdb.path(sid)
|
|
119
|
+
ok_eq(true, file.exist?)
|
|
120
|
+
|
|
121
|
+
# test get empty
|
|
122
|
+
ok_eq(nil, sdb.get(nil))
|
|
123
|
+
ok_eq(nil, sdb.get(''))
|
|
124
|
+
|
|
125
|
+
# test get
|
|
126
|
+
user = sdb.get(sid)
|
|
127
|
+
ok_eq('user@e.com', user)
|
|
128
|
+
|
|
129
|
+
mtime = file.mtime
|
|
130
|
+
oldtime = Time.at(mtime.to_i - 60 * 60 * 24 * 100) # 100 days ago.
|
|
131
|
+
file.utime(oldtime, oldtime)
|
|
132
|
+
|
|
133
|
+
# test session expired
|
|
134
|
+
user = sdb.get(sid)
|
|
135
|
+
ok_eq(nil, user)
|
|
136
|
+
ok_eq(false, file.exist?)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|