]> gitweb.factorcode.org Git - factor.git/commitdiff
http.server.responses: adding <html-content>, use it.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Apr 2014 20:47:25 +0000 (13:47 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Apr 2014 20:47:25 +0000 (13:47 -0700)
21 files changed:
basis/furnace/actions/actions.factor
basis/furnace/furnace-tests.factor
basis/furnace/sessions/sessions-tests.factor
basis/http/server/responses/responses-docs.factor
basis/http/server/responses/responses.factor
basis/http/server/static/static.factor
basis/tools/deploy/deploy-tests.factor
basis/xmode/code2html/responder/responder.factor
extra/fastcgi/fastcgi.factor
extra/webapps/benchmark/benchmark.factor
extra/webapps/fjsc/fjsc.factor
extra/webapps/mason/counter/counter.factor
extra/webapps/mason/docs-update/docs-update.factor
extra/webapps/mason/grids/grids.factor
extra/webapps/mason/increment-counter/increment-counter.factor
extra/webapps/mason/make-release/make-release.factor
extra/webapps/mason/report/report.factor
extra/webapps/mason/status-update/status-update.factor
extra/webapps/pastebin/pastebin.factor
unmaintained/cont-responder/callbacks-tests.factor
unmaintained/tangle/tangle.factor

index 19491acfc3f00aad2ca8feedf0c5ec76279adda1..e01fb9e6e77b1ea8878af3de4ace37c4a5475a5c 100644 (file)
@@ -113,7 +113,7 @@ M: action modify-form
 TUPLE: page-action < action template ;\r
 \r
 : <chloe-content> ( path -- response )\r
-    resolve-template-path <chloe> "text/html" <content> ;\r
+    resolve-template-path <chloe> <html-content> ;\r
 \r
 : <page-action> ( -- page )\r
     page-action new-action\r
index 6fe2633031ae934eda8f2700f726371347b014d3..ca1faa7729e9cdbe0deb6553dc1f127b7ca14707 100644 (file)
@@ -14,7 +14,7 @@ C: <base-path-check-responder> base-path-check-responder
 M: base-path-check-responder call-responder*
     2drop
     "$funny-dispatcher" resolve-base-path
-    "text/plain" <content> ;
+    <text-content> ;
 
 [ ] [
     <dispatcher>
index 1ac3dbd51aee7c8b9581e4d37c625eb2f8ad74c9..5e9e10591f2947c19d8603f26053625602ae4847 100644 (file)
@@ -20,7 +20,7 @@ M: foo init-session* drop 0 "x" sset ;
 M: foo call-responder*\r
     2drop\r
     "x" [ 1 + ] schange\r
-    "x" sget number>string "text/html" <content> ;\r
+    "x" sget number>string <html-content> ;\r
 \r
 : url-responder-mock-test ( -- string )\r
     [\r
@@ -47,7 +47,7 @@ M: foo call-responder*
 \r
 : <exiting-action> ( -- action )\r
     <action>\r
-        [ [ ] "text/plain" <content> exit-with ] >>display ;\r
+        [ [ ] <text-content> exit-with ] >>display ;\r
 \r
 [ "auth-test.db" temp-file delete-file ] ignore-errors\r
 \r
index 3ca276695a614efc64a8a82c66edc319c08d5a01..d4bbd4c986289a86f8dcc2e3b1cd2747958d6a5d 100644 (file)
@@ -8,7 +8,13 @@ HELP: <content>
 
 HELP: <text-content>
 { $values { "body" "a response body" } { "response" response } }
-{ $description "Creates a plain text response." } ;
+{ $description "Creates a response with content type " { $snippet "text/plain" } "." } ;
+
+HELP: <html-content>
+{ $values { "body" "a response body" } { "response" response } }
+{ $description "Creates a response with content type " { $snippet "text/html" } "." } ;
+
+{ <content> <text-content> <html-content> } related-words
 
 HELP: <trivial-response>
 { $values { "code" integer } { "message" string } { "response" response } }
@@ -26,9 +32,8 @@ ARTICLE: "http.server.responses" "Canned HTTP responses"
 { $subsections
     <content>
     <text-content>
+    <html-content>
 }
-
-{ $vocab-link "furnace.json" } " implements " { $link <json-content> } "." $nl
 "For errors:"
 { $subsections
     <304>
index db7f9618b3d1cedf59e69d1d24a3454a8dd85604..9bade222ff40ed03e79b4eb8cc482cf49d9a08eb 100644 (file)
@@ -14,7 +14,10 @@ IN: http.server.responses
 
 : <text-content> ( body -- response )
     "text/plain" <content> ;
-    
+
+: <html-content> ( body -- response )
+    "text/html" <content> ;
+
 : trivial-response-body ( code message -- )
     <XML
         <html>
@@ -26,7 +29,7 @@ IN: http.server.responses
 
 : <trivial-response> ( code message -- response )
     2dup [ trivial-response-body ] with-string-writer
-    "text/html" <content>
+    <html-content>
         swap >>message
         swap >>code ;
 
index 294c3d7a0d1de65e27e711bf91673098cb72d0ed..01b085e1aeaa58170663b2b32ed96a644392c57b 100644 (file)
@@ -71,7 +71,7 @@ TUPLE: file-responder root hook special index-names allow-listings ;
 \r
 : list-directory ( directory -- response )\r
     file-responder get allow-listings>> [\r
-        directory>html "text/html" <content>\r
+        directory>html <html-content>\r
     ] [\r
         drop <403>\r
     ] if ;\r
@@ -105,7 +105,7 @@ M: file-responder call-responder* ( path responder -- response )
     index-names>> adjoin ;\r
 \r
 : serve-fhtml ( path -- response )\r
-    <fhtml> "text/html" <content> ;\r
+    <fhtml> <html-content> ;\r
 \r
 : enable-fhtml ( responder -- responder )\r
     [ serve-fhtml ] "application/x-factor-server-page" pick special>> set-at\r
index e71b4a8a39269e8cf1aaf0ad1e335e0d548b3a7e..95e64f3b965343bdbfa8a311770af54aaae7dfc0 100644 (file)
@@ -71,7 +71,7 @@ http.server.responses http.server.static io.servers ;
 SINGLETON: quit-responder
 
 M: quit-responder call-responder*
-    2drop stop-this-server "Goodbye" "text/html" <content> ;
+    2drop stop-this-server "Goodbye" <html-content> ;
 
 : add-quot-responder ( responder -- responder )
     quit-responder "quit" add-responder ;
index 39ff627b8460748ba10ea75ba273a3fb7fce32a7..74ef3ece83cf326f423f7ab33bf4e3fed0cefa34 100644 (file)
@@ -12,5 +12,5 @@ IN: xmode.code2html.responder
             _ utf8 [\r
                 _ file-name input-stream get htmlize-stream\r
             ] with-file-reader\r
-        ] "text/html" <content>\r
+        ] <html-content>\r
     ] <file-responder> ;\r
index 50cf02f131dccdd5d945220d05f9954a79a1f9e7..7c4da7d50ada616eaa96c690bf81c10ed4f6d041 100644 (file)
@@ -209,7 +209,7 @@ ENUM: fcgi-protocol-status
 
 TUPLE: test-responder ;
 C: <test-responder> test-responder
-M: test-responder call-responder* 2drop test-output "text/html" <content> ;
+M: test-responder call-responder* 2drop test-output <html-content> ;
 
 : do-it ( -- )
     <test-responder> main-responder set
index 2291d341866dcdb749b7be8c148efa3303135766..02af19e419d1566c0c3dd0e44f248fdd1b0c44a5 100644 (file)
@@ -9,7 +9,7 @@ IN: webapps.benchmark
 
 : <hello-action> ( -- action )
     <page-action>
-        [ "Hello, world!" "text/plain" <content> ] >>display ;
+        [ "Hello, world!" <text-content> ] >>display ;
 
 TUPLE: benchmark < dispatcher ;
 
index 52227ade16be4541abf58f3c4df43a4f1045111e..67e27fc63f974179dfbde90114957e7ec7c324ef 100644 (file)
@@ -33,12 +33,15 @@ TUPLE: fjsc < dispatcher ;
     over "/" head? [ "/" append ] unless 
     swap append  ;
 
+: <javascript-content> ( body -- content )
+    "application/javascript" <content> ;
+
 : do-compile-url ( url -- response )
     [
         absolute-url http-get nip 'expression' parse
         fjsc-compile write "();" write
     ] with-string-writer
-    "application/javascript" <content> ;
+    <javascript-content> ;
 
 : v-local ( string -- string )
     dup "http:" head? [ "Unable to compile code from remote sites" throw ] when ;
@@ -55,10 +58,10 @@ TUPLE: fjsc < dispatcher ;
         [ validate-compile-url "url" value do-compile-url ] >>display ;
 
 : do-compile ( code -- response )
-    [ 
+    [
         'expression' parse fjsc-compile write
     ] with-string-writer
-    "application/javascript" <content> ;
+    <javascript-content> ;
 
 : validate-compile ( -- )
     {
index b0ef5a80058e1d29bf5ff39bb7057a3f57807668..0926a59bf7d375354d0046ff15a3b00022ccef81 100644 (file)
@@ -9,6 +9,6 @@ IN: webapps.mason.counter
     [
         [
             counter-value number>string
-            "text/plain" <content>
+            <text-content>
         ] with-mason-db
     ] >>display ;
index 2df1f9ee8395e2374bc48800a011fd3632f64fae..dd4798c803e5230c73554ef12f345fb5d0086300 100644 (file)
@@ -30,5 +30,5 @@ IN: webapps.mason.docs-update
     [ validate-secret ] >>validate
     [
         [ update-docs ] "Documentation update" spawn drop
-        "OK" "text/plain" <content>
+        "OK" <text-content>
     ] >>submit ;
index 8c888b501c7a2d6a34611877fc40c0fb4ab2ca73..26d7a0a94ab11136b73584721302df563c2c3078 100644 (file)
@@ -60,7 +60,7 @@ CONSTANT: cpus
     [
         [
             package-grid xml>string
-            "text/html" <content>
+            <html-content>
         ] with-mason-db
     ] >>display ;
 
@@ -82,6 +82,6 @@ CONSTANT: cpus
     [
         [
             release-grid xml>string
-            "text/html" <content>
+            <html-content>
         ] with-mason-db
     ] >>display ;
index 8cc6be0aadaaebce5690d742e92708db894918d8..d38615e7932cefb56b68038028ebe7688607990d 100644 (file)
@@ -9,6 +9,6 @@ IN: webapps.mason.increment-counter
     [
         [
             increment-counter-value
-            number>string "text/plain" <content>
+            number>string <text-content>
         ] with-mason-db
     ] >>submit ;
index e0b4c13a1a1443ec3180992403f8b3e4aeab9f97..15c3a772fd3e734c1b08aecd2b7d3edcf7fe7119 100644 (file)
@@ -16,6 +16,6 @@ IN: webapps.mason.make-release
     [
         [
             "version" value "announcement-url" value do-release
-            "OK" "text/html" <content>
+            "OK" <text-content>
         ] with-mason-db
     ] >>submit ;
index 64511d7f05fb2e5aafbbd544fa1d45eb038a7bff..6d3a126a84357044b52a6ade3bc78b6dd256db82 100644 (file)
@@ -10,7 +10,7 @@ IN: webapps.mason.report
         [
             [
                 current-builder last-report>>
-                "text/html" <content>
+                <html-content>
             ] with-mason-db
         ] >>display ;
 
index 668db6ebd37a7d0f2d145466819034ee207de03a..d1c60895d9ee4f604d9b0b3bce974f20ae0e7429 100644 (file)
@@ -90,5 +90,5 @@ IN: webapps.mason.status-update
             find-builder
             [ update-builder ] [ update-tuple ] bi
         ] with-mason-db
-        "OK" "text/plain" <content>
+        "OK" <text-content>
     ] >>submit ;
index bfceb65103e7918fb7e3c8b0efd08227701b4572..562639404adffcdf0cca6a0450afbfcbff1337db 100644 (file)
@@ -143,7 +143,7 @@ M: annotation entity-url
 : <raw-paste-action> ( -- action )
     <action>
         [ validate-integer-id "id" value paste from-object ] >>init
-        [ "contents" value "text/plain" <content> ] >>display ;
+        [ "contents" value <text-content> ] >>display ;
 
 : <paste-feed-action> ( -- action )
     <feed-action>
@@ -227,7 +227,7 @@ M: annotation entity-url
 : <raw-annotation-action> ( -- action )
     <action>
         [ validate-integer-id "id" value lookup-annotation from-object ] >>init
-        [ "contents" value "text/plain" <content> ] >>display ;
+        [ "contents" value <text-content> ] >>display ;
 
 : <delete-annotation-action> ( -- action )
     <action>
index db6f43c5155760759bcb595c2b1214d6cf97ac2b..605109a0d6ce0cb88f582affe4c308dca1abf958 100644 (file)
@@ -21,7 +21,7 @@ IN: furnace.callbacks.tests
     <action> [\r
         [\r
             "hello" print\r
-            "text/html" <content>\r
+            <html-content>\r
         ] show-page\r
         "byebye" print\r
         [ 123 ] show-final\r
index 1f567a5f0d2c66f66221a44264b452bf49cc04e6..f20ed52b3c526fdeebd09f8b9577a805ee5984d3 100644 (file)
@@ -24,7 +24,7 @@ C: <tangle> tangle
     [ [ db>> ] [ seq>> ] bi ] dip with-db ;
 
 : node-response ( id -- response )
-    load-node [ node-content "text/plain" <content> ] [ <404> ] if* ;
+    load-node [ node-content <text-content> ] [ <404> ] if* ;
 
 : display-node ( params -- response )
     [
@@ -40,7 +40,7 @@ C: <tangle> tangle
 : submit-node ( params -- response )
     [
         "node_content" swap at* [
-            create-node id>> number>string "text/plain" <content>
+            create-node id>> number>string <text-content>
         ] [
             drop <400>
         ] if
@@ -56,7 +56,7 @@ TUPLE: path-responder ;
 C: <path-responder> path-responder
 
 M: path-responder call-responder* ( path responder -- response )
-    drop path>file [ node-content "text/plain" <content> ] [ <404> ] if* ;
+    drop path>file [ node-content <text-content> ] [ <404> ] if* ;
 
 TUPLE: tangle-dispatcher < dispatcher tangle ;