furnace.utilities: use a method based on where instead of vocab-path to find dir of vocab

db4
Björn Lindqvist 2014-11-03 18:47:22 +01:00 committed by John Benediktsson
parent 9905b52f15
commit b29aa88f3c
2 changed files with 27 additions and 7 deletions

View File

@ -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

View File

@ -1,9 +1,9 @@
! Copyright (C) 2008, 2010 Slava Pestov. ! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! 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 words vocabs.loader accessors strings combinators arrays
continuations present fry urls http http.server xml.syntax xml.writer 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 IN: furnace.utilities
: word>string ( word -- string ) : word>string ( word -- string )
@ -41,13 +41,11 @@ ERROR: no-such-responder responder ;
] "" make ] "" make
] when ; ] when ;
: vocab-path ( vocab -- path ) : resolve-word-path ( word -- path/f )
dup vocab-dir vocab-append-path ; where [ first parent-directory but-last ] [ f ] if* ;
: resolve-template-path ( pair -- path ) : resolve-template-path ( pair -- path )
[ [ first2 [ resolve-word-path % ] dip "/" % % ] "" make ;
first2 [ vocabulary>> vocab-path % ] [ "/" % % ] bi*
] "" make ;
GENERIC: modify-query ( query responder -- query' ) GENERIC: modify-query ( query responder -- query' )