qwikdoc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,180 @@
|
|
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/site-search'
|
7
|
+
require 'qwik/site-index'
|
8
|
+
|
9
|
+
module Qwik
|
10
|
+
class Action
|
11
|
+
D_PluginSearch = {
|
12
|
+
:dt => 'Search plugin',
|
13
|
+
:dd => 'You can show a search form.',
|
14
|
+
:dc => '* Example
|
15
|
+
{{search}}
|
16
|
+
{{search}}
|
17
|
+
'
|
18
|
+
}
|
19
|
+
|
20
|
+
D_PluginSearch_ja = {
|
21
|
+
:dt => '�����v���O�C��',
|
22
|
+
:dd => '�����������܂��B',
|
23
|
+
:dc => '* ��
|
24
|
+
{{search}}
|
25
|
+
{{search}}
|
26
|
+
'
|
27
|
+
}
|
28
|
+
|
29
|
+
# ============================== search
|
30
|
+
def plg_side_search_form
|
31
|
+
return [
|
32
|
+
[:h2, _('Search')],
|
33
|
+
plg_search_form,
|
34
|
+
# plg_search_word_cloud
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def plg_search_form(focus = false)
|
39
|
+
return search_form(focus)
|
40
|
+
end
|
41
|
+
alias plg_search plg_search_form
|
42
|
+
|
43
|
+
def search_form(focus = false, query = nil)
|
44
|
+
query_attr = {:name=>'q'}
|
45
|
+
query_attr[:class] = 'focus' if focus
|
46
|
+
query_attr[:value] = query if query
|
47
|
+
return [:form, {:action=>'.search'},
|
48
|
+
[:input, query_attr],
|
49
|
+
[:input, {:type=>'submit', :value=>_('Search')}]]
|
50
|
+
end
|
51
|
+
|
52
|
+
def act_search
|
53
|
+
query = search_get_query
|
54
|
+
if query.nil?
|
55
|
+
return search_form_page
|
56
|
+
end
|
57
|
+
|
58
|
+
ar = @site.search(query)
|
59
|
+
if ar.empty?
|
60
|
+
return search_notfound_page(query)
|
61
|
+
end
|
62
|
+
|
63
|
+
return search_result(@site, ar, query)
|
64
|
+
end
|
65
|
+
alias ext_search act_search
|
66
|
+
|
67
|
+
def search_get_query
|
68
|
+
query = @req.query['q']
|
69
|
+
return query if query && ! query.empty?
|
70
|
+
|
71
|
+
query = @req.base
|
72
|
+
return query if query && ! query.empty? && query != "FrontPage"
|
73
|
+
#return query if query && ! query.empty?
|
74
|
+
|
75
|
+
return nil
|
76
|
+
end
|
77
|
+
|
78
|
+
def search_form_page(title = _('Search'), notice = nil, query = nil)
|
79
|
+
body = []
|
80
|
+
body << [:h2, notice] if notice
|
81
|
+
body << [:div, {:class => 'form'}, search_form(true, query)]
|
82
|
+
return c_notice(title) { body }
|
83
|
+
end
|
84
|
+
|
85
|
+
# called also from act-isearch.rb
|
86
|
+
def search_notfound_page(query)
|
87
|
+
return search_form_page(_('Search result'), _('No match.'), query)
|
88
|
+
end
|
89
|
+
|
90
|
+
def search_result(site, ar, query = nil)
|
91
|
+
ul = [:ul]
|
92
|
+
ar.each {|key, line, i|
|
93
|
+
page = site[key]
|
94
|
+
url = page.url
|
95
|
+
ul << [:li,
|
96
|
+
[:h3, [:a, {:href => url}, page.get_title]],
|
97
|
+
[:span, {:class => 'content'}, line],
|
98
|
+
[:div, [:a, {:href => url}, url]]]
|
99
|
+
}
|
100
|
+
div = []
|
101
|
+
div << [:div, {:class => 'day'},
|
102
|
+
[:div, {:class => 'section'},
|
103
|
+
[:div, {:class=>'form'}, search_form(true, query)]]]
|
104
|
+
div << [:div, {:class => 'day'},
|
105
|
+
[:div, {:class => 'section'},
|
106
|
+
[:div, {:class => 'search_result'}, ul]]]
|
107
|
+
title = _('Search result') + ": " + query
|
108
|
+
return c_plain(title) { div }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
if $0 == __FILE__
|
114
|
+
require 'qwik/test-common'
|
115
|
+
$test = true
|
116
|
+
end
|
117
|
+
|
118
|
+
if defined?($test) && $test
|
119
|
+
class TestActSearch < Test::Unit::TestCase
|
120
|
+
include TestSession
|
121
|
+
|
122
|
+
def test_plg_search_form
|
123
|
+
ok_wi([:form, {:action=>'.search'},
|
124
|
+
[:input, {:name=>'q'}],
|
125
|
+
[:input, {:value=>'Search', :type=>'submit'}]],
|
126
|
+
"{{search_form}}")
|
127
|
+
ok_wi([:form, {:action=>'.search'},
|
128
|
+
[:input, {:name=>'q', :class=>'focus'}],
|
129
|
+
[:input, {:value=>'Search', :type=>'submit'}]],
|
130
|
+
"{{search_form(true)}}")
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_search
|
134
|
+
t_add_user
|
135
|
+
|
136
|
+
# test_act_search
|
137
|
+
res = session('/test/.search')
|
138
|
+
ok_xp([:form, {:action=>'.search'},
|
139
|
+
[:input, {:class=>'focus', :name=>'q'}],
|
140
|
+
[:input, {:value=>'Search', :type=>'submit'}]],
|
141
|
+
'//form')
|
142
|
+
|
143
|
+
res = session("/test/.search?q=nosuchkey")
|
144
|
+
assert_text('Search result', 'h1')
|
145
|
+
ok_in(['No match.'], '//h2')
|
146
|
+
|
147
|
+
page = @site.create_new
|
148
|
+
page.store('This is a keyword.')
|
149
|
+
res = session("/test/.search?q=keyword")
|
150
|
+
ok_in([:ul, [:li,
|
151
|
+
[:h3, [:a, {:href=>'1.html'}, '1']],
|
152
|
+
[:span, {:class=>'content'}, 'This is a keyword.'],
|
153
|
+
[:div, [:a, {:href=>'1.html'},"1.html"]]]],
|
154
|
+
"//div[@class='search_result']")
|
155
|
+
|
156
|
+
res = session("/test/keyword.search") # Both OK.
|
157
|
+
ok_in([:ul, [:li,
|
158
|
+
[:h3, [:a, {:href=>'1.html'}, '1']],
|
159
|
+
[:span, {:class=>'content'}, 'This is a keyword.'],
|
160
|
+
[:div, [:a, {:href => '1.html'},"1.html"]]]],
|
161
|
+
"//div[@class='search_result']")
|
162
|
+
|
163
|
+
page = @site.create_new # 2.txt
|
164
|
+
page.store("����")
|
165
|
+
res = session("/test/.search?q=��")
|
166
|
+
ok_in([:ul, [:li,
|
167
|
+
[:h3, [:a, {:href=>'2.html'}, '2']],
|
168
|
+
[:span, {:class=>'content'}, "����"],
|
169
|
+
[:div, [:a, {:href=>'2.html'}, '2.html']]]],
|
170
|
+
"//div[@class='search_result']")
|
171
|
+
|
172
|
+
res = session("/test/��.search") # Both OK.
|
173
|
+
ok_in([:ul, [:li,
|
174
|
+
[:h3, [:a, {:href=>'2.html'}, '2']],
|
175
|
+
[:span, {:class=>'content'}, "����"],
|
176
|
+
[:div, [:a, {:href=>'2.html'}, '2.html']]]],
|
177
|
+
"//div[@class='search_result']")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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/act-search"
|
7
|
+
|
8
|
+
module Qwik
|
9
|
+
class Action
|
10
|
+
def plg_search_word_cloud
|
11
|
+
list = @site.get_search_words
|
12
|
+
[:span] + list.map{|em|
|
13
|
+
w = em.word.to_s.escape
|
14
|
+
if em.nil?
|
15
|
+
em = Word.new(w, 1, Time.new)
|
16
|
+
end
|
17
|
+
[[:span, {:class => "search_word#{em.count}"},
|
18
|
+
[:a, {:href => ".search?q=#{w}"}, em.word]],
|
19
|
+
[:span, {:class => "search_word_delete"},
|
20
|
+
[:a, {:href => ".delete?q=#{w}"},
|
21
|
+
[:img, {:src => ".theme/css/delete.png",:border =>"0",
|
22
|
+
:alt => "del"}]]]]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# search word delete action
|
27
|
+
def act_delete
|
28
|
+
query = search_get_query
|
29
|
+
if query
|
30
|
+
@site.delete_search_word(query)
|
31
|
+
end
|
32
|
+
return c_notice("Deleted",@req.header["referer"]) { "deleted" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if $0 == __FILE__
|
38
|
+
require 'qwik/test-common'
|
39
|
+
$test = true
|
40
|
+
end
|
41
|
+
|
42
|
+
if defined?($test) && $test
|
43
|
+
class TestActSearchWords < Test::Unit::TestCase
|
44
|
+
include TestSession
|
45
|
+
|
46
|
+
def test_dummy
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
@@ -0,0 +1,83 @@
|
|
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/act-getpass'
|
7
|
+
require 'qwik/mailaddress'
|
8
|
+
|
9
|
+
module Qwik
|
10
|
+
class Action
|
11
|
+
def act_sendpass
|
12
|
+
c_require_member
|
13
|
+
|
14
|
+
return sendpass_show_form if ! @req.is_post?
|
15
|
+
|
16
|
+
status = {}
|
17
|
+
members = @site.member.list
|
18
|
+
@req.query.each {|mail, v|
|
19
|
+
if ! MailAddress.valid?(mail) || v != 'on'
|
20
|
+
status[mail] = _('Wrong format.')
|
21
|
+
next
|
22
|
+
end
|
23
|
+
|
24
|
+
if ! members.include?(mail)
|
25
|
+
status[mail] = _('Not a member.')
|
26
|
+
next
|
27
|
+
end
|
28
|
+
|
29
|
+
passmail = generate_password_mail(mail)
|
30
|
+
sendmail = Sendmail.new(@config.smtp_host, @config.smtp_port,
|
31
|
+
@config.test)
|
32
|
+
begin
|
33
|
+
sendmail.send(passmail)
|
34
|
+
status[mail] = _('Succeeded.')
|
35
|
+
rescue
|
36
|
+
status[mail] = _('Failed.')
|
37
|
+
end
|
38
|
+
}
|
39
|
+
|
40
|
+
ar = []
|
41
|
+
status.each {|mail, result|
|
42
|
+
ar << [:li, mail, ' : ', result.to_s]
|
43
|
+
}
|
44
|
+
return c_notice(_('Send Password done')) {
|
45
|
+
[:ul, ar]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def sendpass_show_form
|
50
|
+
members = @site.member.list.sort
|
51
|
+
return c_notice(_('Send Password')) {
|
52
|
+
[[:h2, _('You can send password for the members.')],
|
53
|
+
[:p, _('Please select members to send password.')],
|
54
|
+
[:form, {:action=>'.sendpass', :method=>'post',
|
55
|
+
:style=>'text-align: center; margin: 32px 0 48px;'},
|
56
|
+
[:ul, members.map {|member|
|
57
|
+
[:li, [:input, {:type=>'checkbox', :name=>member}, ' '+member]]
|
58
|
+
}
|
59
|
+
],
|
60
|
+
[:input, {:type=>'submit', :value=>_('Send Password')}]]]
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if $0 == __FILE__
|
67
|
+
require 'qwik/test-common'
|
68
|
+
require 'qwik/test-module-public'
|
69
|
+
$test = true
|
70
|
+
end
|
71
|
+
|
72
|
+
if defined?($test) && $test
|
73
|
+
class TestActSendPass < Test::Unit::TestCase
|
74
|
+
include TestSession
|
75
|
+
|
76
|
+
def test_all
|
77
|
+
t_add_user
|
78
|
+
|
79
|
+
res = session '/test/.sendpass'
|
80
|
+
ok_title 'Send Password'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Copyright (C) 2003-2009 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/act-status"
|
7
|
+
|
8
|
+
module Qwik
|
9
|
+
class Action
|
10
|
+
def site_delete_unused_config_files
|
11
|
+
files1 = %w{
|
12
|
+
,members
|
13
|
+
,count
|
14
|
+
,config
|
15
|
+
,charset
|
16
|
+
,alerted
|
17
|
+
,forward
|
18
|
+
,permanent
|
19
|
+
,unlimited
|
20
|
+
,waiting-members
|
21
|
+
,waiting-message
|
22
|
+
}
|
23
|
+
|
24
|
+
files1.each {|f1, i|
|
25
|
+
p1 = (sitepath + f1)
|
26
|
+
if p1.exist?
|
27
|
+
p1.unlink
|
28
|
+
li << "deleted. "
|
29
|
+
li << [:a, {:href=>"/#{sitename}/"}, "/#{sitename}/"]
|
30
|
+
ul << li
|
31
|
+
end
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def act_site
|
36
|
+
c_require_login
|
37
|
+
return c_nerror("You are not administrator.") if ! is_administrator?
|
38
|
+
|
39
|
+
farm = @memory.farm
|
40
|
+
ul = [:ul]
|
41
|
+
|
42
|
+
farm.list.each {|sitename|
|
43
|
+
# next unless /\A[0-9]/ =~ sitename
|
44
|
+
|
45
|
+
# site = farm.get_site(sitename)
|
46
|
+
sitepath = "#{@config.sites_dir}/#{sitename}".path
|
47
|
+
|
48
|
+
li = [:li]
|
49
|
+
li << [:a, {:href=>"/#{sitename}/"}, "/#{sitename}/"]
|
50
|
+
ul << li
|
51
|
+
}
|
52
|
+
|
53
|
+
div = [:div, {:class => 'day'},
|
54
|
+
[:div, {:class => 'section'},
|
55
|
+
[:h2, _("Site list.")], ul]]
|
56
|
+
|
57
|
+
return c_plain(_("Site list. __qwik_page_generate_time__ sec. past.")) {
|
58
|
+
div
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if $0 == __FILE__
|
65
|
+
require "pp"
|
66
|
+
require 'qwik/test-common'
|
67
|
+
$test = true
|
68
|
+
end
|
69
|
+
|
70
|
+
if defined?($test) && $test
|
71
|
+
class TestActSite < Test::Unit::TestCase
|
72
|
+
include TestSession
|
73
|
+
|
74
|
+
def test_all
|
75
|
+
t_add_user
|
76
|
+
|
77
|
+
file = @config.etc_dir.path + "administrator.txt"
|
78
|
+
file.write("")
|
79
|
+
|
80
|
+
res = session("/test/.site")
|
81
|
+
ok_title("You are not administrator.")
|
82
|
+
|
83
|
+
file.write("user@e.com\n")
|
84
|
+
|
85
|
+
res = session("/test/.site")
|
86
|
+
ok_title "Site list. __qwik_page_generate_time__ sec. past."
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,419 @@
|
|
1
|
+
# -*- coding: shift_jis -*-
|
2
|
+
# Copyright (C) 2008 National Institute of
|
3
|
+
# Advanced Industrial Science and Technology (AIST)
|
4
|
+
# All rights reserved.
|
5
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
6
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
7
|
+
|
8
|
+
module Qwik
|
9
|
+
class Site
|
10
|
+
def lastmod_of_all
|
11
|
+
ar = []
|
12
|
+
self.path.find do |p|
|
13
|
+
Find.prune if p.basename.to_s == '.cache' or p.basename.to_s == '.svn'
|
14
|
+
ar << p.mtime
|
15
|
+
end
|
16
|
+
ar.max
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Action
|
21
|
+
D_SiteBackup = {
|
22
|
+
:dt => 'Site backup',
|
23
|
+
:dd => 'You can get a tgz(tar.gz) archive of the whole site content.',
|
24
|
+
:dc => '* Example
|
25
|
+
{{sitebackup}}
|
26
|
+
|
27
|
+
You can get a zip archive with all text data of the Wiki site.
|
28
|
+
You can get a tgz(tar and gziped) archive of the whole site content.
|
29
|
+
|
30
|
+
You can move your site by getting the archive and placing them on your
|
31
|
+
qwikWeb data directory.
|
32
|
+
|
33
|
+
At the first click, it only shows the progress of archiving.
|
34
|
+
After the archiving is finished, you can download the archive file.
|
35
|
+
|
36
|
+
If you change anything on the site, it\'ll recreate the archive.
|
37
|
+
'
|
38
|
+
}
|
39
|
+
|
40
|
+
D_SiteBackup_ja = {
|
41
|
+
:dt => '�T�C�g�E�o�b�N�A�b�v',
|
42
|
+
:dd => '�T�C�g�E�o�b�N�A�b�v���擾�ł��܂��B',
|
43
|
+
:dc => '* �g����
|
44
|
+
{{sitebackup}}
|
45
|
+
|
46
|
+
���̃����N����A�T�C�g�̓��e���ׂĂ�tar.gz�`���̃A�[�J�C�u�ɂ��ă_�E�����[�h�ł��܂��B
|
47
|
+
|
48
|
+
�W�J����qwikWeb��data�f�B���N�g���ɒu���C�T�C�g�����̂܂܈ڍs���邱�Ƃ��ł��܂��D
|
49
|
+
|
50
|
+
�ŏ��̈��ڂ́A�A�[�J�C�u�쐬�̂��߂̃v���Z�X�����s����܂��B
|
51
|
+
�쐬���I����Ă��烊���[�h���邩�A�u���E�U���猳�̃y�[�W�ɖ߂���
|
52
|
+
������x�����N���N���b�N����ƁA�A�[�J�C�u���_�E�����[�h���邱�Ƃ��ł��܂��B
|
53
|
+
|
54
|
+
�T�C�g�̓��e���X�V���ꂽ��A���̃����N���ēx�N���b�N����ƁA�A�[�J�C�u���č쐬����܂��B
|
55
|
+
'
|
56
|
+
}
|
57
|
+
|
58
|
+
def plg_sitebackup
|
59
|
+
return "no tar command" if ! SiteBackup.command_exist?
|
60
|
+
return page_attribute('sitebackup', _('Site backup'), @site.sitename)
|
61
|
+
end
|
62
|
+
|
63
|
+
def ext_sitebackup
|
64
|
+
return c_nerror("no tar command") if ! SiteBackup.command_exist?
|
65
|
+
c_require_member
|
66
|
+
c_require_base_is_sitename
|
67
|
+
|
68
|
+
backup = SiteBackup.new(@site, @config)
|
69
|
+
if backup.latest?
|
70
|
+
return c_notice("Download archive", "#{@site.sitename}.tgz", 200, 2) {
|
71
|
+
[:p, "Backup process is complete. download ",
|
72
|
+
[:a, {:href=>"#{@site.sitename}.tgz"}, "archive"],
|
73
|
+
"."
|
74
|
+
]
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
if backup.generating?
|
79
|
+
return c_notice("in progress", "#{@site.sitename}.sitebackup", 200, 5) {
|
80
|
+
[:p, "Backup process is running."]
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
backup.generate
|
85
|
+
return c_notice("starting", "#{@site.sitename}.sitebackup", 200, 5) {
|
86
|
+
[:p, "Backup process is starting"]
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
# only for download archive
|
91
|
+
def ext_tgz
|
92
|
+
c_require_member
|
93
|
+
c_require_base_is_sitename
|
94
|
+
|
95
|
+
backup = SiteBackup.new(@site, @config)
|
96
|
+
if backup.latest?
|
97
|
+
return c_simple_send(backup.archive_path, "application/gzip")
|
98
|
+
else
|
99
|
+
return c_notfound { "no latest backup" }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class SiteBackup
|
105
|
+
TAR_CMD = '/bin/tar' # path to tar command (GNU version is required)
|
106
|
+
def self.command_exist?
|
107
|
+
TAR_CMD.path.executable?
|
108
|
+
end
|
109
|
+
|
110
|
+
def initialize(site, config)
|
111
|
+
@site = site
|
112
|
+
@config = config
|
113
|
+
@archive_path = site.cache_path + "#{@site.sitename}.tgz"
|
114
|
+
@tmpfile_path = site.cache_path + "sitebackup.tmp"
|
115
|
+
end
|
116
|
+
attr_reader :archive_path
|
117
|
+
attr_reader :tmpfile_path
|
118
|
+
|
119
|
+
def _site_lastmod
|
120
|
+
@site.lastmod_of_all
|
121
|
+
end
|
122
|
+
|
123
|
+
def _archive_mtime
|
124
|
+
result = nil
|
125
|
+
result = @archive_path.mtime if @archive_path.exist?
|
126
|
+
return result
|
127
|
+
end
|
128
|
+
|
129
|
+
def _tmpfile_mtime
|
130
|
+
result = nil
|
131
|
+
result = @tmpfile_path.mtime if @tmpfile_path.exist?
|
132
|
+
return result
|
133
|
+
end
|
134
|
+
|
135
|
+
def latest?(site_lastmod = _site_lastmod, archive_mtime = _archive_mtime,
|
136
|
+
tmpfile_mtime = _tmpfile_mtime) # explicit arguments for test
|
137
|
+
return false if archive_mtime.nil?
|
138
|
+
if tmpfile_mtime.nil?
|
139
|
+
archive_mtime >= site_lastmod
|
140
|
+
else
|
141
|
+
archive_mtime >= site_lastmod && archive_mtime > tmpfile_mtime
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def generating?(site_lastmod = _site_lastmod, archive_mtime = _archive_mtime,
|
146
|
+
tmpfile_mtime = _tmpfile_mtime) # explicit arguments for test
|
147
|
+
return false if tmpfile_mtime.nil?
|
148
|
+
if archive_mtime.nil?
|
149
|
+
tmpfile_mtime > site_lastmod
|
150
|
+
else
|
151
|
+
tmpfile_mtime >= archive_mtime && tmpfile_mtime > site_lastmod
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def invoke(cmd)
|
156
|
+
system(cmd)
|
157
|
+
child_process = $?
|
158
|
+
child_process.exitstatus == 0 ? :success : :failure
|
159
|
+
end
|
160
|
+
|
161
|
+
def command
|
162
|
+
"#{TAR_CMD} zcf #{@tmpfile_path} -C #{@config.sites_dir} " +
|
163
|
+
"--exclude .cache --exclude .svn -h #{@site.sitename}"
|
164
|
+
end
|
165
|
+
|
166
|
+
def generate
|
167
|
+
if defined?($test) && $test
|
168
|
+
_generate
|
169
|
+
else
|
170
|
+
do_concurrent { _generate }
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def _generate
|
175
|
+
cleanup
|
176
|
+
result = invoke(command)
|
177
|
+
if result == :success && @tmpfile_path.exist?
|
178
|
+
@tmpfile_path.rename(@archive_path)
|
179
|
+
else
|
180
|
+
@tmpfile_path.unlink if @tmpfile_path.exist?
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def do_concurrent
|
185
|
+
Thread.new {
|
186
|
+
yield
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
def cleanup
|
191
|
+
@tmpfile_path.unlink if @tmpfile_path.exist?
|
192
|
+
@archive_path.unlink if @archive_path.exist?
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
if $0 == __FILE__
|
199
|
+
$LOAD_PATH << '..' unless $LOAD_PATH.include? '..'
|
200
|
+
require 'qwik/test-common'
|
201
|
+
require 'qwik/util-pathname'
|
202
|
+
$test = true
|
203
|
+
end
|
204
|
+
|
205
|
+
if defined?($test) && $test
|
206
|
+
class MockSite
|
207
|
+
def cache_path; ".test/data/test/.cache/".path; end
|
208
|
+
def sitename; "test"; end
|
209
|
+
end
|
210
|
+
|
211
|
+
class MockConfig
|
212
|
+
def sites_dir; ".test/data/"; end
|
213
|
+
end
|
214
|
+
|
215
|
+
class TestSiteBackup < Test::Unit::TestCase
|
216
|
+
include TestSession
|
217
|
+
|
218
|
+
def setup
|
219
|
+
site = MockSite.new
|
220
|
+
config = MockConfig.new
|
221
|
+
@backup = Qwik::SiteBackup.new(site, config)
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_archive_path
|
225
|
+
expected = ".test/data/test/.cache/test.tgz".path
|
226
|
+
actual = @backup.archive_path
|
227
|
+
is expected, actual
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_tmpfile_path
|
231
|
+
expected = ".test/data/test/.cache/sitebackup.tmp".path
|
232
|
+
actual = @backup.tmpfile_path
|
233
|
+
is expected, actual
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_command_exist
|
237
|
+
ok Qwik::SiteBackup.command_exist?
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_backup_is_latest
|
241
|
+
site_lastmod = Time.at(0)
|
242
|
+
archive_mtime = Time.at(1)
|
243
|
+
tmpfile_mtime = nil
|
244
|
+
excepted = true
|
245
|
+
actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
|
246
|
+
is excepted, actual
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_backup_is_latest2
|
250
|
+
site_lastmod = Time.at(0)
|
251
|
+
archive_mtime = Time.at(0)
|
252
|
+
tmpfile_mtime = nil
|
253
|
+
excepted = true
|
254
|
+
actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
|
255
|
+
is excepted, actual, "archive and site-lastmod is same"
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_backup_is_not_latest2
|
259
|
+
site_lastmod = Time.at(0)
|
260
|
+
archive_mtime = Time.at(1)
|
261
|
+
tmpfile_mtime = Time.at(1)
|
262
|
+
excepted = false
|
263
|
+
actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
|
264
|
+
is excepted, actual, "tmpfile is latest"
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_backup_is_not_latest3
|
268
|
+
site_lastmod = Time.at(0)
|
269
|
+
archive_mtime = nil
|
270
|
+
tmpfile_mtime = nil
|
271
|
+
excepted = false
|
272
|
+
actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
|
273
|
+
is excepted, actual, "backup is not exist"
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_backup_is_creating
|
277
|
+
site_lastmod = Time.at(0)
|
278
|
+
archive_mtime = Time.at(0)
|
279
|
+
tmpfile_mtime = Time.at(1)
|
280
|
+
excepted = true
|
281
|
+
actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
|
282
|
+
is excepted, actual
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_backup_is_creating2
|
286
|
+
site_lastmod = Time.at(0)
|
287
|
+
archive_mtime = nil
|
288
|
+
tmpfile_mtime = Time.at(1)
|
289
|
+
excepted = true
|
290
|
+
actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
|
291
|
+
is excepted, actual, "at first: backup is not exist"
|
292
|
+
end
|
293
|
+
|
294
|
+
def test_backup_is_creating3
|
295
|
+
site_lastmod = Time.at(0)
|
296
|
+
archive_mtime = Time.at(1)
|
297
|
+
tmpfile_mtime = Time.at(1)
|
298
|
+
excepted = true
|
299
|
+
actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
|
300
|
+
is excepted, actual, "tmp and backup is same"
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_backup_is_not_creating
|
304
|
+
site_lastmod = Time.at(0)
|
305
|
+
archive_mtime = Time.at(0)
|
306
|
+
tmpfile_mtime = nil
|
307
|
+
excepted = false
|
308
|
+
actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
|
309
|
+
is excepted, actual, "tmp is absent"
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_backup_is_not_creating2
|
313
|
+
site_lastmod = Time.at(1)
|
314
|
+
archive_mtime = Time.at(1)
|
315
|
+
tmpfile_mtime = Time.at(1)
|
316
|
+
excepted = false
|
317
|
+
actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
|
318
|
+
is excepted, actual, "site is modified"
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_invoke
|
322
|
+
expected = :success
|
323
|
+
input = "ruby -e 'true'"
|
324
|
+
actual = @backup.invoke(input)
|
325
|
+
is expected, actual
|
326
|
+
end
|
327
|
+
|
328
|
+
def test_invoke_fail
|
329
|
+
expected = :failure
|
330
|
+
input = "ruby -e 'exit 1'"
|
331
|
+
actual = @backup.invoke(input)
|
332
|
+
is expected, actual, "exit status sould be 1"
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_invoke_unavailable
|
336
|
+
expected = :failure
|
337
|
+
input = "never-seen-command"
|
338
|
+
actual = @backup.invoke(input)
|
339
|
+
is expected, actual, "command should not found"
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_command
|
343
|
+
expected = "#{Qwik::SiteBackup::TAR_CMD} zcf .test/data/test/.cache/sitebackup.tmp -C .test/data/ " +
|
344
|
+
"--exclude .cache --exclude .svn -h test"
|
345
|
+
actual = @backup.command
|
346
|
+
is expected, actual
|
347
|
+
end
|
348
|
+
|
349
|
+
def test_do_concurrent
|
350
|
+
t1 = t2 = nil
|
351
|
+
thread = @backup.do_concurrent {
|
352
|
+
Thread.pass
|
353
|
+
sleep 0.1
|
354
|
+
t1 = Time.now
|
355
|
+
}
|
356
|
+
t2 = Time.now
|
357
|
+
thread.join
|
358
|
+
assert_not_equal t1.to_f, t2.to_f
|
359
|
+
end
|
360
|
+
|
361
|
+
end
|
362
|
+
|
363
|
+
class TestActSiteBackup < Test::Unit::TestCase
|
364
|
+
include TestSession
|
365
|
+
|
366
|
+
def test_plg_tgz
|
367
|
+
ok_wi [:p, [:a, {:href=>'test.sitebackup'}, 'test.sitebackup']], '[[test.sitebackup]]'
|
368
|
+
ok_wi [:span, {:class=>'attribute'},
|
369
|
+
[:a, {:href=>'test.sitebackup'}, 'Site backup']], '{{sitebackup}}'
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_ext_tgz
|
373
|
+
t_add_user
|
374
|
+
|
375
|
+
# Add a page
|
376
|
+
page = @site.create_new
|
377
|
+
page.store '* Test'
|
378
|
+
|
379
|
+
# Wait to make time-lag between archive and site data
|
380
|
+
sleep 1
|
381
|
+
|
382
|
+
# Create backup
|
383
|
+
res = session '/test/test.sitebackup'
|
384
|
+
ok_title 'starting'
|
385
|
+
|
386
|
+
res = session '/test/test.sitebackup'
|
387
|
+
ok_title 'Download archive'
|
388
|
+
|
389
|
+
res = session '/test/test.tgz'
|
390
|
+
ok_eq 'application/gzip', res['Content-Type']
|
391
|
+
|
392
|
+
# Compare with cache file
|
393
|
+
content = (@site.cache_path + "test.tgz").read
|
394
|
+
ok_eq(content, res.body)
|
395
|
+
|
396
|
+
# Wait to make time-lag between archive and site data
|
397
|
+
sleep 1
|
398
|
+
|
399
|
+
# Attach a file
|
400
|
+
res = session('POST /test/1.files') {|req|
|
401
|
+
req.query.update('content'=>t_make_content('t.txt', 't'))
|
402
|
+
}
|
403
|
+
ok_title('File attachment completed')
|
404
|
+
|
405
|
+
# Remake backup
|
406
|
+
res = session '/test/test.sitebackup'
|
407
|
+
ok_title 'starting'
|
408
|
+
|
409
|
+
# Download again
|
410
|
+
res = session '/test/test.tgz'
|
411
|
+
ok_eq 'application/gzip', res['Content-Type']
|
412
|
+
|
413
|
+
# Compare with cache file
|
414
|
+
content = (@site.cache_path + "test.tgz").read
|
415
|
+
ok_eq(content, res.body)
|
416
|
+
end
|
417
|
+
|
418
|
+
end
|
419
|
+
end
|