]> gitweb.factorcode.org Git - factor.git/commitdiff
replace string formatting with new make-string system and use html
authorChris Double <chris.double@double.co.nz>
Sun, 14 Nov 2004 21:57:28 +0000 (21:57 +0000)
committerChris Double <chris.double@double.co.nz>
Sun, 14 Nov 2004 21:57:28 +0000 (21:57 +0000)
instead of cont-html. remove cont-html.factor file as it is
supercontents of the html vocabulary in the standard library. remove
unneeded test function from todo example. removed requirement for
parser combinator library from todo cont-responder example.

contrib/cont-responder/browser.factor
contrib/cont-responder/cont-examples.factor
contrib/cont-responder/cont-responder.factor
contrib/cont-responder/cont-utils.factor
contrib/cont-responder/eval-responder.factor
contrib/cont-responder/live-updater-responder.factor
contrib/cont-responder/live-updater.factor
contrib/cont-responder/load.factor
contrib/cont-responder/todo-example.factor

index 79b89fdbad9538456ec574aaaea4c65a50414afd..abfd6b080618742e89989a999699c26dc29b1f91 100644 (file)
@@ -25,7 +25,7 @@
 ! cont-responder facilities.
 !
 IN: browser
-USE: cont-html
+USE: html
 USE: cont-responder
 USE: cont-utils
 USE: stack
@@ -170,9 +170,9 @@ USE: logging
   #! Build a string that can evaluate the string 'to-eval'
   #! by first doing an 'IN: vocab' and a 'USE:' of all
   #! necessary vocabs for existing words in that vocab.
-  <% >r "IN: " % dup % "\n" %
-     vocabulary-uses [ "USE: " % % "\n" % ] each
-     r> % "\n" % %> ;
+  [ >r "IN: " , dup , "\n" ,
+     vocabulary-uses [ "USE: " , , "\n" , ] each
+     r> , "\n" , ] make-string ;
 
 : show-parse-error ( error -- )
   #! Show an error page describing the parse error.
index bc2ea066f2e372be4ebcebd8d27e696271e70afc..3d392c1f09b26bbc45f1c82c925b4ed356d71e77 100644 (file)
@@ -24,7 +24,7 @@
 ! Simple test applications
 IN: cont-examples
 USE: cont-responder
-USE: cont-html
+USE: html
 USE: stack
 USE: stdio
 USE: html
index a95de9fe3e9555d0cc4c8dc2869623928591b1eb..19f1b134edea83a817c6cc6f4e84a3f6180e7e8d 100644 (file)
@@ -1,4 +1,4 @@
-! cont-responder v0.6
+! cont-responder 
 !
 ! Copyright (C) 2004 Chris Double.
 ! 
@@ -29,7 +29,6 @@ USE: httpd-responder
 USE: math
 USE: random
 USE: continuations
-USE: format
 USE: namespaces
 USE: stack
 USE: combinators
@@ -39,7 +38,7 @@ USE: strings
 USE: html
 USE: kernel
 USE: logic
-USE: cont-html
+USE: html
 USE: logging
 USE: url-encoding
 USE: unparser
@@ -60,7 +59,7 @@ USE: hashtables
 
 : get-random-id ( -- id ) 
   #! Generate a random id to use for continuation URL's
-  <% 16 [ random-digit unparse % ] times %> ;
+  [ 16 [ random-digit unparse , ] times ] make-string ;
 
 : continuation-table ( -- <namespace> ) 
   #! Return the global table of continuations
@@ -212,8 +211,8 @@ DEFER: show
   ] [
     [ 
       t swap register-continuation 
-      <% "HTTP/1.1 302 Document Moved\nLocation: " % % "\n" % 
-        "Content-Length: 0\nContent-Type: text/plain\n\n" % %>
+      [ "HTTP/1.1 302 Document Moved\nLocation: " , , "\n" , 
+        "Content-Length: 0\nContent-Type: text/plain\n\n" , ] make-string
       call-exit-continuation 
     ] callcc1 drop 
   ] ifte ;
index dbf1eefe98e3b1a5adf37f434c7b9cbdcba0758d..999e199759975c325acc4c4ae6d942b9c97a2d6f 100644 (file)
@@ -24,7 +24,7 @@
 ! General purpose words for display pages using the continuation 
 ! based responder.
 IN: cont-utils
-USE: cont-html
+USE: html
 USE: cont-responder
 USE: lists
 USE: stdio
index 6b33aae75c6ff29f1b6cd54e0971c58033a9b2a1..8b25706ef04a042461c94db057ceec3349054a19 100644 (file)
@@ -24,7 +24,6 @@
 ! An httpd responder that allows executing simple definitions.
 !
 IN: eval-responder
-USE: cont-html
 USE: html
 USE: cont-responder
 USE: cont-utils
@@ -77,7 +76,7 @@ USE: words
 : make-eval-javascript ( string -- string )
   #! Give a string return some javascript that when
   #! executed will set the eval textarea to that string.
-  <% "document.forms.main.eval.value=\"" % escape-quotes % "\"" % %> ;
+  [ "document.forms.main.eval.value=\"" , escape-quotes , "\"" , ] make-string ;
 
 : write-eval-link ( string -- )
   #! Given text to evaluate, create an A HREF link which when
index 5ff051e78380b13c3830767339ca1ffc8fea60a8..016b3a55278d5c3b02043b57fae4ec1e8cbc98c9 100644 (file)
@@ -27,7 +27,6 @@
 IN: live-updater-responder
 USE: live-updater
 USE: namespaces
-USE: cont-html
 USE: html
 USE: words
 USE: stdio
index f8ab74f14d75f55fd7bf121dcbb6c45ebcf13ef0..98c642f930ce24e4ff8555b8e500c43052a96465 100644 (file)
@@ -27,7 +27,7 @@ IN: live-updater
 USE: stack
 USE: streams
 USE: strings
-USE: cont-html
+USE: html
 USE: cont-responder
 USE: stdio
 USE: namespaces
@@ -36,11 +36,11 @@ USE: combinators
 
 : get-live-updater-js* ( stream -- string )
   #! Read all lines from the stream, creating a string of the result.
-  dup freadln dup [ % "\n" % get-live-updater-js* ] [ drop fclose ] ifte ;
+  dup freadln dup [ , "\n" , get-live-updater-js* ] [ drop fclose ] ifte ;
 
 : get-live-updater-js ( filename -- string )
   #! Return the liveUpdater javascript code as a string.
-  <filecr> <% get-live-updater-js* %> ;
+  <filecr> [ get-live-updater-js* ] make-string ;
 
 : live-updater-url ( -- url )
   #! Generate an URL to the liveUpdater.js code.
index 76f958cf3c65193fdcd3caf8e7d7c189b13b4551..a8a6e302e2df2e1b6b6404e0734bbacbb3e85462 100644 (file)
@@ -35,9 +35,6 @@ USE: stdio
 USE: parser
 
 : l1  
-  "../parser-combinators/lazy.factor" run-file
-  "../parser-combinators/parser-combinators.factor" run-file
-  "cont-html.factor" run-file  
   "cont-responder.factor" run-file 
   "cont-utils.factor" run-file ;
 : l2 
index 5d02acb8f08969e23168080a922925c019240016..bb9af6300865de4086cb32e5ae49a553b80fa45f 100644 (file)
@@ -28,7 +28,7 @@
 ! filesystem with the users name.
 IN: todo-example
 USE: cont-responder
-USE: cont-html
+USE: html
 USE: cont-utils
 USE: html
 USE: stdio
@@ -45,70 +45,68 @@ USE: todo
 USE: math
 USE: logic
 USE: kernel
-USE: lazy
-USE: parser-combinators
  
 : todo-stylesheet ( -- string )
   #! Return the stylesheet for the todo list
-  <% 
-    "table.list {" %
-    "  text-align:center;" %
-    "  font-family: Verdana;" %
-    "  font-weight: normal;" %
-    "  font-size: 11px;" %
-    "  color: #404040;" %
-    "  background-color: #fafafa;" %
-    "  border: 1px #6699cc solid;" %
-    "  border-collapse: collapse;" %
-    "  boder-spacing: 0px;" %
-    "}" %
-    "tr.heading {" %
-    "  border-bottom: 2px solid #6699cc;" %
-    "  border-left: 1px solix #6699cc;" %
-    "  background-color: #BEC8D1;" %
-    "  text-align: left;" %
-    "  text-indent: 0px;" %
-    "  font-family: verdana;" %
-    "  font-weight: bold;" %
-    "  color: #404040;" %
-    "}" %
-    "tr.item {" %
-    "  border-bottom: 1px solid #9cf;" %
-    "  border-top: 0px;" %
-    "  border-left: 1px solid #9cf;" %
-    "  border-right: 0px;" %
-    "  text-align: left;" %
-    "  text-indent: 2px;" %
-    "  font-family: verdana, sans-serif, arial;" %
-    "  font-weight: normal;" %
-    "  color: #404040;" %
-    "  background-color: #fafafa;" %
-    "}" %
-    "tr.complete {" %
-    "  border-bottom: 1px solid #9cf;" %
-    "  border-top: 0px;" %
-    "  border-left: 1px solid #9cf;" %
-    "  border-right: 0px;" %
-    "  text-align: left;" %
-    "  text-indent: 2px;" %
-    "  font-family: verdana, sans-serif, arial;" %
-    "  font-weight: normal;" %
-    "  color: #404040;" %
-    "  background-color: #ccc;" %
-    "}" %
-    "td.lbl {" %
-    "  font-weight: bold; text-align: right;" %
-    "}" %
-    "tr.required {" %
-    "  background: #FCC;" %
-    "}" %
-    "input:focus {" %
-    "  background: yellow;" %
-    "}" %
-    "textarea:focus {" %
-    "  background: yellow;" %
-    "}" %
-  %> ;
+  [ 
+    "table.list {" ,
+    "  text-align:center;" ,
+    "  font-family: Verdana;" ,
+    "  font-weight: normal;" ,
+    "  font-size: 11px;" ,
+    "  color: #404040;" ,
+    "  background-color: #fafafa;" ,
+    "  border: 1px #6699cc solid;" ,
+    "  border-collapse: collapse;" ,
+    "  boder-spacing: 0px;" ,
+    "}" ,
+    "tr.heading {" ,
+    "  border-bottom: 2px solid #6699cc;" ,
+    "  border-left: 1px solix #6699cc;" ,
+    "  background-color: #BEC8D1;" ,
+    "  text-align: left;" ,
+    "  text-indent: 0px;" ,
+    "  font-family: verdana;" ,
+    "  font-weight: bold;" ,
+    "  color: #404040;" ,
+    "}" ,
+    "tr.item {" ,
+    "  border-bottom: 1px solid #9cf;" ,
+    "  border-top: 0px;" ,
+    "  border-left: 1px solid #9cf;" ,
+    "  border-right: 0px;" ,
+    "  text-align: left;" ,
+    "  text-indent: 2px;" ,
+    "  font-family: verdana, sans-serif, arial;" ,
+    "  font-weight: normal;" ,
+    "  color: #404040;" ,
+    "  background-color: #fafafa;" ,
+    "}" ,
+    "tr.complete {" ,
+    "  border-bottom: 1px solid #9cf;" ,
+    "  border-top: 0px;" ,
+    "  border-left: 1px solid #9cf;" ,
+    "  border-right: 0px;" ,
+    "  text-align: left;" ,
+    "  text-indent: 2px;" ,
+    "  font-family: verdana, sans-serif, arial;" ,
+    "  font-weight: normal;" ,
+    "  color: #404040;" ,
+    "  background-color: #ccc;" ,
+    "}" ,
+    "td.lbl {" ,
+    "  font-weight: bold; text-align: right;" ,
+    "}" ,
+    "tr.required {" ,
+    "  background: #FCC;" ,
+    "}" ,
+    "input:focus {" ,
+    "  background: yellow;" ,
+    "}" ,
+    "textarea:focus {" ,
+    "  background: yellow;" ,
+    "}" ,
+  ] make-string ;
 
 : todo-stylesheet-url ( -- url )
   #! Generate an URL for the stylesheet.
@@ -209,8 +207,6 @@ USE: parser-combinators
     ] ifte 
   ] str-map ;
 
-: testx ( string -- b ) dup replace-invalid-username-chars = ;
-
 : is-valid-username? ( username -- bool )
   #! Return true if the username parses correctly
   dup replace-invalid-username-chars = ;
@@ -235,7 +231,7 @@ USE: parser-combinators
    
 : get-todo-filename ( database-path <todo> -- filename )
   #! Get the filename containing the todo list details.
-  <% swap % todo-username % ".todo" % %> ;
+  [ swap , todo-username , ".todo" , ] make-string ;
   
 : add-default-todo-item ( <todo> -- )
   #! Add a default todo item. This is a workaround for the 
@@ -332,13 +328,14 @@ USE: parser-combinators
     ] form 
   ] bind ;
   
-: priority-parser ( -- parser )
-  #! Return a parser for parsing priorities
-  [ digit? ] satisfy just ;
+: priority-valid? ( string -- bool )
+  #! Test the string containing a priority to see if it is 
+  #! valid. It should be a single digit from 0-9.
+  dup str-length 1 = [ 0 swap str-nth digit? ] [ drop f ] ifte ;
 
 : todo-details-valid? ( priority description -- bool )
   #! Return true if a valid priority and description were entered.
-  str-length 0 > swap priority-parser call and ;
+  str-length 0 > [ priority-valid? ] [ drop f ] ifte ;
 
 : get-new-todo-item ( -- <todo-item> )
   #! Enter a new item to the current todo list.
@@ -473,7 +470,7 @@ USE: parser-combinators
 : show-todo-list ( -- )
   #! Show the current todo list.
   [
-    <% "todo" get todo-username % "'s To Do list" % %>
+    [ "todo" get todo-username , "'s To Do list" , ] make-string
     [ include-todo-stylesheet ]
     [
       drop