Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2009-02-13 15:48:17 -06:00
commit 001a3eb8f1
7 changed files with 36 additions and 17 deletions

View File

@ -38,7 +38,7 @@ $nl
"If all you want to do is serve files from a directory, the following phrase does the trick:"
{ $code
"USING: namespaces http.server http.server.static ;"
"/var/www/mysite.com/ <static> main-responder set"
"\"/var/www/mysite.com/\" <static> main-responder set"
"8080 httpd"
}
{ $subsection "http.server.static.extend" } ;

View File

@ -45,9 +45,8 @@ TUPLE: file-responder root hook special allow-listings ;
[ file-responder get hook>> call ] [ 2drop <304> ] if ;
: serving-path ( filename -- filename )
file-responder get root>> trim-tail-separators
"/"
rot "" or trim-head-separators 3append ;
[ file-responder get root>> trim-tail-separators "/" ] dip
"" or trim-head-separators 3append ;
: serve-file ( filename -- response )
dup mime-type

View File

@ -1,9 +1,11 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators io io.encodings.binary io.files kernel
pack endian constructors sequences arrays math.order math.parser
prettyprint classes io.binary assocs math math.bitwise byte-arrays
grouping images compression.lzw fry strings ;
USING: accessors arrays assocs byte-arrays classes combinators
compression.lzw constructors endian fry grouping images io
io.binary io.encodings.ascii io.encodings.binary
io.encodings.string io.encodings.utf8 io.files kernel math
math.bitwise math.order math.parser pack prettyprint sequences
strings ;
IN: images.tiff
TUPLE: tiff-image < image ;
@ -249,13 +251,13 @@ ERROR: bad-small-ifd-type n ;
{ 283 [ first y-resolution ] }
{ 284 [ planar-configuration ] }
{ 296 [ lookup-resolution-unit resolution-unit ] }
{ 305 [ >string software ] }
{ 306 [ >string date-time ] }
{ 305 [ ascii decode software ] }
{ 306 [ ascii decode date-time ] }
{ 317 [ lookup-predictor predictor ] }
{ 330 [ sub-ifd ] }
{ 338 [ lookup-extra-samples extra-samples ] }
{ 339 [ lookup-sample-format sample-format ] }
{ 700 [ >string xmp ] }
{ 700 [ utf8 decode xmp ] }
{ 34377 [ photoshop ] }
{ 34665 [ exif-ifd ] }
{ 33723 [ iptc ] }

View File

@ -174,6 +174,8 @@ PRIVATE>
: [XML
"XML]" [ string>chunk ] parse-def ; parsing
<PRIVATE
: remove-blanks ( seq -- newseq )
[ { [ string? not ] [ [ blank? ] all? not ] } 1|| ] filter ;
@ -241,3 +243,5 @@ M: interpolated [undo-xml]
[undo-xml] '[ H{ } clone [ _ bind ] keep >enum ] ;
\ interpolate-xml 1 [ undo-xml ] define-pop-inverse
PRIVATE>

View File

@ -3,7 +3,7 @@
IN: xml.tests
USING: kernel xml tools.test io namespaces make sequences
xml.errors xml.entities.html parser strings xml.data io.files
xml.traversal continuations assocs
xml.traversal continuations assocs io.encodings.binary
sequences.deep accessors io.streams.string ;
! This is insufficient
@ -12,8 +12,14 @@ sequences.deep accessors io.streams.string ;
\ string>xml must-infer
SYMBOL: xml-file
[ ] [ "resource:basis/xml/tests/test.xml"
[ file>xml ] with-html-entities xml-file set ] unit-test
[ ] [
"resource:basis/xml/tests/test.xml"
[ file>xml ] with-html-entities xml-file set
] unit-test
[ t ] [
"resource:basis/xml/tests/test.xml" binary file-contents
[ bytes>xml ] with-html-entities xml-file get =
] unit-test
[ "1.0" ] [ xml-file get prolog>> version>> ] unit-test
[ f ] [ xml-file get prolog>> standalone>> ] unit-test
[ "a" ] [ xml-file get space>> ] unit-test

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2009 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license.
USING: help.markup help.syntax xml.data io strings ;
USING: help.markup help.syntax xml.data io strings byte-arrays ;
IN: xml
HELP: string>xml
@ -16,7 +16,11 @@ HELP: file>xml
{ $values { "filename" string } { "xml" xml } }
{ $description "Opens the given file, reads it in as XML, closes the file and returns the corresponding XML tree. The encoding is automatically detected." } ;
{ string>xml read-xml file>xml } related-words
HELP: bytes>xml
{ $values { "byte-array" byte-array } { "xml" xml } }
{ $description "Parses a byte array as an XML document. The encoding is automatically detected." } ;
{ string>xml read-xml file>xml bytes>xml } related-words
HELP: read-xml-chunk
{ $values { "stream" "an input stream" } { "seq" "a sequence of elements" } }
@ -68,6 +72,7 @@ ARTICLE: { "xml" "reading" } "Reading XML"
{ $subsection read-xml-chunk }
{ $subsection string>xml-chunk }
{ $subsection file>xml }
{ $subsection bytes>xml }
"To read a DTD:"
{ $subsection read-dtd }
{ $subsection file>dtd }

View File

@ -4,7 +4,7 @@ USING: accessors arrays io io.encodings.binary io.files
io.streams.string kernel namespaces sequences strings io.encodings.utf8
xml.data xml.errors xml.elements ascii xml.entities
xml.writer xml.state xml.autoencoding assocs xml.tokenize
combinators.short-circuit xml.name splitting ;
combinators.short-circuit xml.name splitting io.streams.byte-array ;
IN: xml
<PRIVATE
@ -184,6 +184,9 @@ PRIVATE>
: file>xml ( filename -- xml )
binary <file-reader> read-xml ;
: bytes>xml ( byte-array -- xml )
binary <byte-reader> read-xml ;
: read-dtd ( stream -- dtd )
[
H{ } clone extra-entities set