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.
|
||||
!
|
||||
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.
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
! Simple test applications
|
||||
IN: cont-examples
|
||||
USE: cont-responder
|
||||
USE: cont-html
|
||||
USE: html
|
||||
USE: stack
|
||||
USE: stdio
|
||||
USE: html
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
IN: live-updater-responder
|
||||
USE: live-updater
|
||||
USE: namespaces
|
||||
USE: cont-html
|
||||
USE: html
|
||||
USE: words
|
||||
USE: stdio
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue