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