diff --git a/basis/html/html.factor b/basis/html/html.factor index e446c66d8c..12cf3549f4 100644 --- a/basis/html/html.factor +++ b/basis/html/html.factor @@ -22,3 +22,6 @@ IN: html : simple-link ( xml url -- xml' ) url-encode swap [XML ><-> XML] ; + +: simple-image ( url -- xml ) + url-encode [XML /> XML] ; \ No newline at end of file diff --git a/basis/html/streams/streams.factor b/basis/html/streams/streams.factor index 26a3d5f391..0ddc09bf54 100644 --- a/basis/html/streams/streams.factor +++ b/basis/html/streams/streams.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2004, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel assocs io io.styles math math.order math.parser -sequences strings make words combinators macros xml.syntax html fry -destructors ; +USING: accessors assocs combinators destructors fry html io +io.backend io.pathnames io.styles kernel macros make math +math.order math.parser namespaces sequences strings words xml +xml.syntax ; IN: html.streams GENERIC: url-of ( object -- url ) @@ -87,9 +88,22 @@ MACRO: make-css ( pairs -- str ) : emit-html ( quot stream -- ) dip data>> push ; inline +: image-resource-path ( path -- images-path ) + normalize-path current-directory get drop-prefix drop + "/images" prepend ; + +: img-tag ( xml style -- xml ) + image swap at [ nip image-resource-path simple-image ] when* ; + : format-html-span ( string style stream -- ) - [ [ span-tag ] [ href-link-tag ] [ object-link-tag ] tri ] - emit-html ; + [ + { + [ span-tag ] + [ href-link-tag ] + [ object-link-tag ] + [ img-tag ] + } cleave + ] emit-html ; TUPLE: html-span-stream < html-sub-stream ;