From 9b6db6b0e32f890d948be8b78e32be6b29cf19ad Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Sep 2010 17:24:53 -0700 Subject: [PATCH] webapps.mason: add action to update docs --- extra/webapps/mason/docs-update/authors.txt | 1 + .../mason/docs-update/docs-update.factor | 29 +++++++++++++++++++ extra/webapps/mason/mason.factor | 8 +++-- .../mason/status-update/status-update.factor | 4 +-- extra/webapps/mason/utils/utils.factor | 9 ++++-- 5 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 extra/webapps/mason/docs-update/authors.txt create mode 100644 extra/webapps/mason/docs-update/docs-update.factor diff --git a/extra/webapps/mason/docs-update/authors.txt b/extra/webapps/mason/docs-update/authors.txt new file mode 100644 index 0000000000..1901f27a24 --- /dev/null +++ b/extra/webapps/mason/docs-update/authors.txt @@ -0,0 +1 @@ +Slava Pestov diff --git a/extra/webapps/mason/docs-update/docs-update.factor b/extra/webapps/mason/docs-update/docs-update.factor new file mode 100644 index 0000000000..e7c0ecda9b --- /dev/null +++ b/extra/webapps/mason/docs-update/docs-update.factor @@ -0,0 +1,29 @@ +! Copyright (C) 2010 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors continuations furnace.actions help.html +http.server.responses io.directories io.directories.hierarchy +io.launcher io.files io.pathnames kernel memoize +webapps.mason.utils ; +IN: webapps.mason.docs-update + +: update-docs ( -- ) + home [ + "newdocs" make-directory + "newdocs" [ { "tar" "xvf" "../docs.tar.gz" } try-process ] with-directory + + "docs" exists? [ "docs" "docs.old" move-file ] when + "newdocs/docs" "docs" move-file + + "newdocs" delete-directory + "docs.old" exists? [ "docs.old" delete-tree ] when + + \ load-index reset-memoized + ] with-directory ; + +: ( -- action ) + + [ validate-secret ] >>validate + [ + update-docs + "OK" "text/plain" + ] >>submit ; diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index a878513594..9e871c48a9 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -4,8 +4,9 @@ USING: accessors furnace.actions furnace.auth furnace.db http.server.dispatchers mason.server webapps.mason.grids webapps.mason.package webapps.mason.release webapps.mason.report webapps.mason.downloads webapps.mason.counter -webapps.mason.status-update webapps.mason.dashboard -webapps.mason.make-release webapps.mason.increment-counter ; +webapps.mason.status-update webapps.mason.docs-update +webapps.mason.dashboard webapps.mason.make-release +webapps.mason.increment-counter ; IN: webapps.mason TUPLE: mason-app < dispatcher ; @@ -39,6 +40,9 @@ build-engineer? define-capability "status-update" add-responder + + "docs-update" add-responder + "counter" add-responder diff --git a/extra/webapps/mason/status-update/status-update.factor b/extra/webapps/mason/status-update/status-update.factor index 94965dc4dd..2344218856 100644 --- a/extra/webapps/mason/status-update/status-update.factor +++ b/extra/webapps/mason/status-update/status-update.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors calendar combinators db.tuples furnace.actions furnace.redirection html.forms http.server.responses io kernel -mason.config mason.server namespaces validators ; +mason.server namespaces validators webapps.mason.utils ; IN: webapps.mason.status-update : find-builder ( -- builder ) @@ -59,7 +59,7 @@ IN: webapps.mason.status-update { "secret" [ v-one-line ] } } validate-params - "secret" value status-secret get = [ validation-failed ] unless + validate-secret ] >>validate [ diff --git a/extra/webapps/mason/utils/utils.factor b/extra/webapps/mason/utils/utils.factor index b26fd5e5bb..e7c88eaec0 100644 --- a/extra/webapps/mason/utils/utils.factor +++ b/extra/webapps/mason/utils/utils.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs db.tuples furnace.actions -furnace.utilities html.forms kernel mason.server -mason.version.data sequences validators xml.syntax urls ; +furnace.utilities html.forms kernel mason.config mason.server +mason.version.data namespaces sequences validators xml.syntax +urls ; IN: webapps.mason.utils : link ( url label -- xml ) @@ -53,3 +54,7 @@ IN: webapps.mason.utils [ os>> "os" set-query-param ] [ cpu>> "cpu" set-query-param ] bi adjust-url ; + +: validate-secret ( -- ) + "secret" value status-secret get = + [ validation-failed ] unless ;