Another web challenge: state

stephen barncard stephenREVOLUTION2 at barncard.com
Fri Sep 23 22:54:29 EDT 2011


I don't use !important but use a lot of inline css for special cases and use
css as a sheet or in the header for more general specs (for a one-pager).
I pass the state of the app through POST or GET which gets trapped at the
beginning and "decides" which 'page' to display.

With the new two pass compiler it's possible to make the code more
organized.  One can locate most parts anywhere on the document now, except
for variable declaration. I put html sections in handlers like this (not
complete code sample):

on startupHTML
-- this is an HTML5 page
?>
<!DOCTYPE html>
<html>
  <?rev
end startupHTML

on startHEAD
  ?>
  <head>
  <META http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title><?rev put gDataA["title"] ?></title>
  <?rev
end startHEAD

on midHEAD
?>
 <?rev startStyle ?>
<?rev
end midHEAD

on endHEAD
?>
</head>
<?rev
end endHEAD

and so forth

--------------------------> and control the sections at the top like this:

on decisiontree pAdd
-- decide the function and page
get $_POST_RAW
if it is empty
then
stage_one
else
--         there is data in POST
--         CHECK FOR ERRORS
put validateMailArray($_POST_BINARY) into a
replace return with br in a
--          RAW Examine $_POST
if a is empty
then
-- no errors - send email
--contactmailSend
 if diagnoseflag is true
then
stage_diagnostic
else
stage_send
end if
else
-- we have errors, present to correct
stage_two a
end if
end if
end decisiontree

on stage_one
-- stage one
-- FIRST RUN NO POST DATA
-- THERE MIGHT BE GET DATA
get $_GET["realname"]
if it is empty
then
-- assign default name
put "Joe User" into gDataA["realname"]
else
put $_GET["realname"] into gDataA["realname"]
end if
setuserspecs
 startupHTML
starthead
midhead
endhead
 put "Welcome - please fill out all fields, then click SEND to transmit your
message. I will respond soon. " & br & br & "<em>" & gDataA["realname"] &
"</em>" into gDataA["prompt1"]
put "all fields need to be filled .." into gDataA["prompt2"]
put "20110828 livecode contact form ©  house of cubes sf" into
gDataA["copyright"]

showbodymasthead
entryform2
showfooter
w3cHTML5Link
enddocument
end stage_one

stage two and three reuses some of the handlers and adds others.

and put the sections that won't need much attention at the bottom.

It makes it easier to create and manually debug (without a debugger) one
page apps "BY HAND"

the complete app can be seen
here<http://barncard.com/contact/index.irev?realname=Stephen%20Barncard>


On 23 September 2011 19:30, Chipp Walters <chipp at chipp.com> wrote:

> Richard,
>
> Actually, I think a decent first step is to just create apps which run on a
> single page. This removes much if not all the necessary session information
> and works pretty much like typical AJAX apps do now.
>

Stephen Barncard
San Francisco Ca. USA

more about sqb  <http://www.google.com/profiles/sbarncar>



More information about the use-livecode mailing list