file-responder now supports .fhtml files, which are piped through contrib/embedded.factor

slava 2006-07-06 00:34:50 +00:00
parent 81a9a2f977
commit 6e112b6ef8
5 changed files with 25 additions and 20 deletions

View File

@ -9,7 +9,6 @@
- multiple listener-run-files is broken - multiple listener-run-files is broken
- roundoff is still not quite right with tracks - roundoff is still not quite right with tracks
- httpd search tools - httpd search tools
- get embedded factor templates in httpd working better
- docs: slice: if sequence or seq start is changed, abstraction violation - docs: slice: if sequence or seq start is changed, abstraction violation
tathi: hrm. wish I knew more about OpenGL. tathi: hrm. wish I knew more about OpenGL.
[2:45pm] tathi: Factor's text display is a bit odd sometimes, until you mouse over (or click, if there's no "live" text) [2:45pm] tathi: Factor's text display is a bit odd sometimes, until you mouse over (or click, if there's no "live" text)
@ -28,7 +27,6 @@ tathi: hrm. wish I knew more about OpenGL.
+ ui: + ui:
- xref f and \ f together
- grid slows down with 2000 lines - grid slows down with 2000 lines
- f should be clickable - f should be clickable
- clickable vocabs - clickable vocabs

View File

@ -49,7 +49,7 @@ USING: sequences kernel parser math namespaces io ;
: parse-embedded ( string -- quot ) : parse-embedded ( string -- quot )
#! simple example: "numbers: <% 3 [ 1 + pprint ] each %>" #! simple example: "numbers: <% 3 [ 1 + pprint ] each %>"
#! => "\"numbers: \" write 3 [ 1 + pprint ] each" #! => "\"numbers: \" write 3 [ 1 + pprint ] each"
[ embedded>factor ] f make ; [ embedded>factor ] [ ] make ;
: eval-embedded ( string -- ) parse-embedded call ; : eval-embedded ( string -- ) parse-embedded call ;
@ -66,8 +66,6 @@ USING: sequences kernel parser math namespaces io ;
[ eval-embedded ] with-embedded-file ; [ eval-embedded ] with-embedded-file ;
: embedded-convert ( infile outfile -- ) : embedded-convert ( infile outfile -- )
<file-writer> [ <file-writer> [ run-embedded-file ] with-stream ;
run-embedded-file
] with-stream ;
PROVIDE: embedded ; PROVIDE: embedded ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2004, 2006 Slava Pestov. ! Copyright (C) 2004, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: file-responder IN: file-responder
USING: html httpd io kernel math namespaces USING: embedded html httpd io kernel math namespaces parser
parser sequences strings ; sequences strings ;
: serving-path ( filename -- filename ) : serving-path ( filename -- filename )
[ "" ] unless* "doc-root" get swap append ; [ "" ] unless* "doc-root" get swap append ;
@ -20,12 +20,17 @@ parser sequences strings ;
<file-reader> stdio get stream-copy <file-reader> stdio get stream-copy
] if ; ] if ;
SYMBOL: page
: run-page ( filename -- )
[ dup page set run-embedded-file ] with-scope ;
: include-page ( filename -- )
"doc-root" get swap path+ run-page ;
: serve-file ( filename -- ) : serve-file ( filename -- )
dup mime-type dup "application/x-factor-server-page" = [ dup mime-type dup "application/x-factor-server-page" =
drop run-file [ drop serving-html run-page ] [ serve-static ] if ;
] [
serve-static
] if ;
: list-directory ( directory -- ) : list-directory ( directory -- )
serving-html serving-html
@ -35,13 +40,15 @@ parser sequences strings ;
"request" get [ dup log-message directory. ] simple-html-document "request" get [ dup log-message directory. ] simple-html-document
] if ; ] if ;
: find-index ( filename -- path )
{ "index.html" "index.fhtml" }
[ dupd path+ exists? ] find nip
dup [ path+ ] [ nip ] if ;
: serve-directory ( filename -- ) : serve-directory ( filename -- )
dup "/" tail? [ dup "/" tail? [
dup "index.html" append dup exists? [ dup find-index
nip serve-file [ serve-file ] [ list-directory ] ?if
] [
drop list-directory
] if
] [ ] [
drop directory-no/ drop directory-no/
] if ; ] if ;

View File

@ -1,5 +1,7 @@
USING: io ; USING: io ;
REQUIRES: embedded ;
PROVIDE: httpd { PROVIDE: httpd {
"mime.factor" "mime.factor"
"xml.factor" "xml.factor"

View File

@ -30,5 +30,5 @@ H{
{ "pdf" "application/pdf" } { "pdf" "application/pdf" }
{ "factor" "text/plain" } { "factor" "text/plain" }
{ "factsp" "application/x-factor-server-page" } { "fhtml" "application/x-factor-server-page" }
} "mime-types" global set-hash } "mime-types" global set-hash