From: Björn Lindqvist Date: Mon, 3 Nov 2014 17:47:22 +0000 (+0100) Subject: furnace.utilities: use a method based on where instead of vocab-path to find dir... X-Git-Tag: unmaintained~3433 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=b29aa88f3c9ff4f52181837333cece7753ea942e furnace.utilities: use a method based on where instead of vocab-path to find dir of vocab --- diff --git a/basis/furnace/utilities/utilities-tests.factor b/basis/furnace/utilities/utilities-tests.factor new file mode 100644 index 0000000000..426288af38 --- /dev/null +++ b/basis/furnace/utilities/utilities-tests.factor @@ -0,0 +1,22 @@ +USING: furnace.utilities io.encodings.utf8 io.files io.files.temp kernel +multiline parser tools.test webapps.counter ; +IN: furnace.utilities.tests + +<< +STRING: dummy-vocab +IN: dummy-vocab + +: dummy-word ( -- ) ; +; + +dummy-vocab "dummy.factor" temp-file [ utf8 set-file-contents ] keep run-file +>> + +{ t } [ + USE: dummy-vocab + { dummy-word "index" } resolve-template-path "index" temp-file = +] unit-test + +{ "resource:extra/webapps/counter/counter" } [ + { counter-app "counter" } resolve-template-path +] unit-test diff --git a/basis/furnace/utilities/utilities.factor b/basis/furnace/utilities/utilities.factor index 61547131fc..e42213b31e 100644 --- a/basis/furnace/utilities/utilities.factor +++ b/basis/furnace/utilities/utilities.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: namespaces make assocs sequences kernel classes splitting +USING: definitions namespaces make assocs sequences kernel classes splitting words vocabs.loader accessors strings combinators arrays continuations present fry urls http http.server xml.syntax xml.writer -http.server.redirection http.server.remapping ; +http.server.redirection http.server.remapping io.pathnames ; IN: furnace.utilities : word>string ( word -- string ) @@ -41,13 +41,11 @@ ERROR: no-such-responder responder ; ] "" make ] when ; -: vocab-path ( vocab -- path ) - dup vocab-dir vocab-append-path ; +: resolve-word-path ( word -- path/f ) + where [ first parent-directory but-last ] [ f ] if* ; : resolve-template-path ( pair -- path ) - [ - first2 [ vocabulary>> vocab-path % ] [ "/" % % ] bi* - ] "" make ; + [ first2 [ resolve-word-path % ] dip "/" % % ] "" make ; GENERIC: modify-query ( query responder -- query' )