]> gitweb.factorcode.org Git - factor.git/commitdiff
help.html: copy image resources to output directory.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 22 May 2020 02:17:56 +0000 (19:17 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 22 May 2020 02:17:56 +0000 (19:17 -0700)
This helps avoid needing so many different static responders in
webapps.help, and makes the documentation more self-contained.

basis/help/html/html.factor
extra/webapps/help/help.factor

index 426847aea1070a0805266b5fed55357dcdd3fb0b..3a6b65b1520a6facb2ff202dcbfc23ffb27ec6dd 100644 (file)
@@ -143,25 +143,20 @@ M: pathname url-of
         ] [ drop ] if
     ] each classes sort-values css-classes body ;
 
-: img@2x ( body -- body' )
+: retina-image ( path -- path' )
+    "@2x" over subseq? [ "." split1-last "@2x." glue ] unless ;
+
+: ?copy-file ( from to -- )
+    dup exists? [ 2drop ] [ copy-file ] if ;
+
+: cache-images ( body -- body' )
     dup [
         dup xml-chunk? [
             seq>> [
                 T{ name { main "img" } } over tag-named? [
                     dup "src" attr
-
-                    ! use @2x retina images
-                    "@2x" over subseq? [
-                        "." split1-last "@2x." glue
-                    ] unless
-
-                    ! src mapping for webapps.help
-                    "vocab:definitions/icons/" ?head
-                    [ "/icons/" prepend ] when
-
-                    "vocab:ui/tools/error-list/icons/" ?head
-                    [ "/icons2/" prepend ] when
-
+                    retina-image dup file-name
+                    [ ?copy-file ] keep
                     "src" set-attr
                 ] [ drop ] if
             ] deep-each
@@ -171,7 +166,8 @@ M: pathname url-of
 : help>html ( topic -- xml )
     [ article-title " - Factor Documentation" append ]
     [
-        [ print-topic ] with-html-writer css-styles-to-classes img@2x
+        [ print-topic ] with-html-writer
+        css-styles-to-classes cache-images
         [ help-stylesheet help-meta prepend help-navbar ] dip
         [XML <div id="container"><-><div class="page"><-></div></div> XML]
     ] bi simple-page ;
index e09dee4c876c7c6b09a3f3cebfaa4989deba27bf..f0af5fb4ba4df126ad6e9a3d3b5667066a3f1324 100644 (file)
@@ -39,9 +39,7 @@ TUPLE: help-webapp < dispatcher ;
     help-webapp new-dispatcher
         <main-action> <secure-only> "" add-responder
         help-dir <search-action> <secure-only> "search" add-responder
-        help-dir <static> <secure-only> "content" add-responder
-        "resource:basis/definitions/icons/" <static> <secure-only> "icons" add-responder
-        "resource:basis/ui/tools/error-list/icons/" <static> <secure-only> "icons2" add-responder ;
+        help-dir <static> <secure-only> "content" add-responder ;
 
 : run-help-webapp ( -- )
     "docs" cache-file <help-webapp>