cvs
Slava Pestov 2005-09-01 20:37:32 +00:00
parent e6a24eb355
commit bd9c30b367
13 changed files with 27 additions and 99 deletions

View File

@ -1,6 +1,3 @@
- reader syntax for arrays, byte arrays, displaced aliens
- out of memory error when printing global namespace
- removing unneeded #label
- finish scrollbars
- fix up the min thumb size hack
@ -54,6 +51,7 @@
+ compiler:
- removing unneeded #label
- flushing optimization
- compile-byte/cell: instantiating aliens
- fix fixnum<< and /i overflow on PowerPC
@ -71,6 +69,8 @@
+ kernel:
- reader syntax for arrays, byte arrays, displaced aliens
- out of memory error when printing global namespace
- first time hash/vector is grown, set size to something big
- merge timers with sleeping tasks
- what about tasks and timers between image restarts

View File

@ -4392,7 +4392,6 @@ Key&Description\\
\ttindex{underline}&A boolean\\
\ttindex{presented}&If set, a presentation for this object is output\\
\ttindex{file}&If set, a hyperlink to that file is output\\
\ttindex{icon}&If set, the icon named by this resource path is output\\
\end{tabular}
All keys are symbols in the \verb|styles| vocabulary.

View File

@ -69,7 +69,6 @@ sequences io vectors words ;
"/library/io/string-streams.factor"
"/library/io/c-streams.factor"
"/library/io/files.factor"
"/library/io/directories.factor"
"/library/io/binary.factor"
"/library/syntax/parse-words.factor"

View File

@ -10,19 +10,15 @@ test-responder ;
global [
{{ }} clone responders set
! Runs all unit tests and dumps result to the client. This uses
! a lot of server resources, so disable it on a busy server.
[
"test" "responder" set
[ test-responder ] "get" set
] make-responder
! 404 error message pages are served by this guy
[
"404" "responder" set
[ drop no-such-responder ] "get" set
] make-responder
! Servers Factor word definitions from the image.
"browser" [ browser-responder ] install-cont-responder
! Serves files from a directory stored in the "doc-root"
! variable. You can set the variable in the global namespace,
! or inside the responder.
@ -34,15 +30,6 @@ global [
[ file-responder ] "head" set
] make-responder
! Serves Factor source code
[
"resource" "responder" set
[ resource-responder ] "get" set
] make-responder
! Servers Factor word definitions from the image.
"browser" [ browser-responder ] install-cont-responder
! The root directory is served by...
"file" set-default-responder

View File

@ -27,6 +27,18 @@ io strings ;
serve-static
] ifte ;
: file-link. ( text path -- )
file swons unit format ;
: file-type. ( path -- )
directory? "[DIR ] " "[FILE] " ? write ;
: file. ( dir name -- )
tuck path+ [ file-type. ] keep file-link. ;
: directory. ( dir -- )
dup directory [ file. terpri ] each-with ;
: list-directory ( directory -- )
serving-html
"method" get "head" = [

View File

@ -91,16 +91,6 @@ presentation sequences strings styles words ;
drop call
] ifte ;
: icon-tag ( string style quot -- )
over icon swap assoc dup [
<img src= "/responder/resource/" swap append img/>
#! Ignore the quotation, since no further style
#! can be applied
3drop
] [
drop call
] ifte ;
TUPLE: html-stream ;
M: html-stream stream-write1 ( char stream -- )
@ -110,12 +100,10 @@ M: html-stream stream-write1 ( char stream -- )
M: html-stream stream-format ( str style stream -- )
[
[
[
[
[ drop chars>entities write ] span-tag
] file-link-tag
] icon-tag
] browser-link-tag
] with-wrapper ;
@ -131,7 +119,6 @@ C: html-stream ( stream -- stream )
#! font-style
#! font-size
#! underline
#! icon
#! file
#! word
#! vocab

View File

@ -7,8 +7,6 @@ USING: kernel parser sequences io ;
"/library/httpd/responder.factor"
"/library/httpd/httpd.factor"
"/library/httpd/file-responder.factor"
"/library/httpd/test-responder.factor"
"/library/httpd/resource-responder.factor"
"/library/httpd/cont-responder.factor"
"/library/httpd/browser-responder.factor"
"/library/httpd/default-responders.factor"

View File

@ -1,21 +0,0 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: resource-responder
USING: httpd kernel lists namespaces io ;
: resource-response ( mime-type -- )
"Content-Type" swons unit "200 OK" response terpri ;
: serve-resource ( filename mime-type -- )
dup mime-type resource-response "method" get "head" = [
drop
] [
<resource-stream> stdio get stream-copy
] ifte ;
: resource-responder ( filename -- )
"resource-path" get [
serve-resource
] [
drop "404 resource-path not set" httpd-error
] ifte ;

View File

@ -1,9 +0,0 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: test-responder
USING: html httpd kernel test ;
: test-responder ( argument -- )
drop
serving-html
"Factor Test Suite" [ all-tests ] simple-html-document ;

View File

@ -1,24 +0,0 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: io
USING: hashtables kernel lists namespaces presentation sequences
strings styles ;
! Hyperlinked directory listings.
: dir-icon "/library/icons/Folder.png" ;
: file-icon "/library/icons/File.png" ;
: file-icon. directory? dir-icon file-icon ? write-icon ;
: file-link. ( dir name -- )
tuck path+ file swons unit format ;
: file. ( dir name -- )
#! If "doc-root" set, create links relative to it.
2dup path+ file-icon. " " write file-link. terpri ;
: directory. ( dir -- )
#! If "doc-root" set, create links relative to it.
dup directory [
dup [ "." ".." ] member? [ 2drop ] [ file. ] ifte
] each-with ;

View File

@ -6,10 +6,16 @@ USING: kernel lists namespaces sequences strings ;
! Words for accessing filesystem meta-data.
: path+ ( path path -- path ) "/" swap append3 ;
: exists? ( file -- ? ) stat >boolean ;
: directory? ( file -- ? ) stat car ;
: directory ( dir -- list ) (directory) string-sort ;
: directory ( dir -- list )
(directory) { "." ".." } swap seq-diff string-sort ;
: file-length ( file -- length ) stat third ;
: file-extension ( filename -- extension )
"." split cdr dup [ peek ] when ;

View File

@ -14,10 +14,6 @@ USING: errors generic kernel lists namespaces strings styles ;
: terpri ( -- ) stdio get stream-terpri ;
: close ( -- ) stdio get stream-close ;
: write-icon ( resource -- )
#! Write an icon. Eg, /library/icons/File.png
icon swons unit "" swap format ;
: write-object ( string object -- )
presented swons unit format ;

View File

@ -27,7 +27,5 @@ SYMBOL: bold-italic
SYMBOL: underline
SYMBOL: icon
SYMBOL: presented
SYMBOL: file