Commit 368387cb authored by Bas Lijnse's avatar Bas Lijnse

Did a full cleanup of the communication parts of the iData library. It still...

Did a full cleanup of the communication parts of the iData library. It still needs some tweaking, but is ready to be alpha tested during iTask development.

Changes include:
 - Removal of dirty low level parsing in the EncodeDecode library
 - Removal of embedded javascript fragments scattered across the clean code
 - Centralization of all javascript functionality into one javascript library that is alway available
 - Addition of a method for serving shared static resources (images, javascript, css etc.) from a central
   location. (Libraries/iData/Resources/)
 - Moving of flag macros that have to be set during different compile runs to a separate module (iDataCompileOptions).
- Change to the type of doHtmlClient to allow for switching between client and server compilation without changing any sources.

 And many small tweaks and cleanups everywhere in the codebase


git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@143 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 6a6784ba
......@@ -25,22 +25,20 @@ import iDataFormData
| UpdS String // new piece of text
encodeTriplet :: !Triplet -> String // encoding of triplets
encodeInputId :: !Triplet -> String
encodeString :: !String -> String // encoding of string
decodeString :: !String -> *String
urlEncode :: !String -> String
urlDecode :: !String -> *String
// Form submission handling
callClean :: !(Script -> ElementEvents) !Mode !String !Lifespan !Bool -> [ElementEvents]
submitscript :: BodyTag
initscript :: BodyTag
globalstateform :: !Value !Value -> BodyTag
// serializing, de-serializing of iData states to strings stored in the html page
EncodeHtmlStates :: ![HtmlState] -> String
DecodeHtmlStatesAndUpdate :: (Maybe [(String, String)]) -> (![HtmlState],!Triplets,!String) // hidden state stored in Client + triplets
DecodeHtmlStatesAndUpdate :: [(String, String)] -> (![HtmlState],!Triplets,!String) // hidden state stored in Client + triplets
// serializing, de-serializing of iData state stored in files
......@@ -50,12 +48,10 @@ deleteStateFile :: !String !*NWorld -> *NWorld
// constants that maybe useful
traceHtmlInput :: !(Maybe [(String, String)]) -> BodyTag // for debugging showing the information received from browser
trace_to_file :: !String !*World -> *World // for storing debug information to file
traceHtmlInput :: [(String, String)] -> BodyTag // for debugging showing the information received from browser
trace_to_file :: !String !*World -> *World // for storing debug information to file
globalFormName :== "CleanForm" // name of hidden Html form in which iData state information is stored
updateInpName :== "UD" // marks update information
globalInpName :== "GS" // marks global state information
selectorInpName :== "CS_" // marks constructor update
focusInpName :== "FS" // marks the focus of the cursor at the time the form was sent
This diff is collapsed.
......@@ -37,6 +37,9 @@ derive gHpr Int, Real, Bool, String, Char, []
print_to_stdout :: !a !*HtmlStream -> *HtmlStream | gHpr{|*|} a
// instance of toString for an html stream.
instance toString [# String !]
// handy utility print routines
print :: !String -> FoF
......
......@@ -44,6 +44,31 @@ where
myfold file [x:xs] = myfold (gHlist file x) xs
myfold file [] = file
// instance of toString for an html stream.
instance toString [# String !]
where
toString stream
# n_chars = count_chars stream 0
= copy_strings stream n_chars (createArray n_chars '\0')
where
count_chars [|] n = n
count_chars [|s:l] n = count_chars l (n+size s)
copy_strings [|e:l] i s
# size_e = size e
# i = i-size_e
= copy_strings l i (copy_chars e 0 i size_e s)
copy_strings [|] 0 s
= s
copy_chars :: !{#Char} !Int !Int !Int !*{#Char} -> *{#Char}
copy_chars s_s s_i d_i n d_s
| s_i<n
# d_s = {d_s & [d_i]=s_s.[s_i]}
= copy_chars s_s (s_i+1) (d_i+1) n d_s
= d_s
// utility print functions based on gHpr
print :: !String -> FoF
......
body {
background-image: url('../img/clean-background.jpg');
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
font-weight: normal;
font-size: 14pt;
color: white;
}
form {
display: inline;
}
h1 {
text-align: center;
border-bottom: 1px solid;
}
.EditBox {
font-family: Arial, Helvetica, sans-serif;
font-size: 12pt;
}
.DisplayBox {
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
font-weight: normal;
font-size: 12pt;
color: white;
background-color: #32729D;
}
.Label {
color: yellow;
font-weight: bold;
}
.MainLabel {
color: red;
font-weight: bold;
}
.HighLight {
color: aqua;
font-weight: bold;
}
.LowLight {
color: aqua;
}
.Trace {
color: silver;
font-weight: bold;
}
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff is collapsed.
......@@ -6,13 +6,13 @@ definition module iDataButtons
import iDataHandler
import GenLexOrd
derive gForm (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gUpd (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gPrint (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gParse (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gerda (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive read (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, PasswordBox
derive write (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, PullDownMenu, TextInput, TextArea, PasswordBox
derive gForm (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gUpd (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gPrint (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gParse (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive gerda (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, HTML, PasswordBox
derive read (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, PasswordBox
derive write (<->), <|>, HtmlDate, HtmlTime, DisplayMode, Button, CheckBox, RadioButton, RadioGroup, PullDownMenu, TextInput, TextArea, PasswordBox
instance toBool CheckBox, Button, RadioButton // True if checkbox checked, button pressed
instance toInt PullDownMenu // Current index in pull down list
......@@ -45,9 +45,15 @@ instance - HtmlTime
| LButton Int String // label button, size in pixels, label of button
| PButton (Int,Int) String // picture button, (height,width), reference to picture
:: CheckBox = CBChecked String // checkbox checked
| CBNotChecked String // checkbox not checked
| CBNotChecked String // checkbox not checked
//OBSOLETE: use RadioGroup instead whenever possible
:: RadioButton = RBChecked String // radiobutton checked
| RBNotChecked String // radiobutton not checked
:: RadioGroup = RadioGroup (Int,[String]) // radiobutton group (item chosen, label list)
:: PullDownMenu = PullDown (Int,Int) (Int,[String]) // pulldownmenu (number visible,width) (item chosen,menulist)
:: TextInput = TI Int Int // Input box of size Size for Integers
| TR Int Real // Input box of size Size for Reals
......
This diff is collapsed.
definition module iDataCompileOptions
IF_Client cl no_cl :== no_cl // Generate code for the Server; IF_ClientServer should be set as well
\ No newline at end of file
implementation module iDataCompileOptions
\ No newline at end of file
definition module iDataCompileOptions
IF_Client cl no_cl :== cl //Generate code for the Client (Sapl); IF_ClientServer should be set as well
\ No newline at end of file
definition module iDataCompileOptions
IF_Client cl no_cl :== no_cl // Generate code for the Server; IF_ClientServer should be set as well
\ No newline at end of file
......@@ -36,7 +36,7 @@ import GenEq
| Display // a non-editable form
| NoForm // do not generate a form, only a value
:: HBimap d v // swiss army nife allowing to make a distinction between data and view domain
:: HBimap d v // swiss army knife allowing to make a distinction between data and view domain
= { toForm :: Init d (Maybe v) -> v // converts data to view domain, given current view
, updForm :: Changed v -> v // update function, True when the form is edited
, fromForm :: Changed v -> d // converts view back to data domain, True when form is edited
......
......@@ -572,8 +572,8 @@ where
openWindowScript :: !String !Int !Int !Bool !Bool !Bool !Bool !Bool !Bool !Html -> Script
openWindowScript scriptname height width toolbar menubar scrollbars resizable location status html
= FScript( \file -> file <+
"\rfunction " <+ scriptname <+ "\r" <+
"{\rOpenWindow=window.open(\"\", \"newwin\", \"" <+
"function " <+ scriptname <+
"{var OpenWindow = window.open(\"\", \"newwin\", \"" <+
"height=" <+ height <+
",width=" <+ width <+
",toolbar=" <+ yn toolbar <+
......@@ -581,10 +581,10 @@ openWindowScript scriptname height width toolbar menubar scrollbars resizable lo
",scrollbars=" <+ yn scrollbars <+
",resizable=" <+ yn resizable <+
",location=" <+ yn location <+
",status=" <+ yn status <+ "\");\r" <+
"OpenWindow.document.write(\"" <+ html <+ "</HTML>\");\r" <+
"OpenWindow.document.close();\r" <+
"}\r")
",status=" <+ yn status <+ "\"); " <+
"OpenWindow.document.write('" <+ html <+ "'); " <+
"OpenWindow.document.close(); " <+
"}")
where
yn bool = if bool "yes" "no"
......
......@@ -23,7 +23,8 @@ derive write Inline
:: *HSt = { cntr :: !Int // counts position in expression
, submits :: !Bool // True if we are in submitting mode
, states :: !*FormStates // all form states are collected here ...
, states :: !*FormStates // all form states are collected here ...
, request :: !HTTPRequest // to enable access to the current HTTP request
, world :: *NWorld // to enable all other kinds of I/O
}
......@@ -31,14 +32,15 @@ derive write Inline
:: UserPage :== .(*HSt -> .(!Bool,Html,!*HSt))
// doHtmlServer main wrapper for generating & handling of an Html form
// depending on the option set (see iDataSettings) it will either
// - link in an http 1.0 server
// - administrate itself as subserver to an http 1.1 server
// doHtmlServer & doHtmlClient main wrappers for generating & handling of Html forms
doHtmlWrapper :: UserPage !*World -> *World //Combined wrapper which starts the server or client wrapper
doHtmlServer :: UserPage !*World -> *World //Server-side engine
doHtmlClient :: UserPage !*World -> *World //Client-side engine (SAPL)
//doHtmlServer2 :: ![(String,UserPage)] !*World -> *World
doHtmlServer :: UserPage !*World -> *World
doHtmlServer2 :: ![(String,UserPage)] !*World -> *World
doHtmlClient :: !*World !UserPage !String -> String
// mkViewForm is the *swiss army knife* function creating stateful interactive forms with a view v of data d.
// Make sure that all editors have a unique identifier!
......
This diff is collapsed.
......@@ -668,7 +668,7 @@ None :== [NoAttr]
| `Tr_Events [ElementEvents]
:: TxtA_Attr = Txa_Cols Int // number of columns visible in the text-area
| Txa_Disabled // disables the text-area when it is first displayed
| Txa_Disabled Disabled // disables the text-area when it is first displayed
| Txa_Name String // name for the text-area
| Txa_Readonly // the user cannot modify the content in the text-area
| Txa_Rows Int // number of rows visible in the text-area
......@@ -692,4 +692,4 @@ None :== [NoAttr]
import PrintUtil
derive gHpr Html, BodyTag, ColorOption, TxtDir, Rest
derive gHpr Html, BodyTag, ColorOption, TxtDir, Rest
\ No newline at end of file
......@@ -141,12 +141,12 @@ gHpr{|Value|} prev (RV real) = prev <+ printToString real
gHpr{|Value|} prev (BV bool) = prev <+ printToString bool
gHpr{|Value|} prev (NQV string) = prev <+ string
gHpr{|ScriptType|} prev (TypeEcmascript) = prev <+ "\"text/Emacscript\""
gHpr{|ScriptType|} prev (TypeJavascript) = prev <+ "\"text/Javascript\""
gHpr{|ScriptType|} prev (Typejscript) = prev <+ "\"text/jscript\""
gHpr{|ScriptType|} prev (TypeVbscript) = prev <+ "\"text/Vbscript\""
gHpr{|ScriptType|} prev (TypeVbs) = prev <+ "\"text/Vbs\""
gHpr{|ScriptType|} prev (TypeXml) = prev <+ "\"text/Xml\""
gHpr{|ScriptType|} prev (TypeEcmascript) = prev <+ "text/emacscript"
gHpr{|ScriptType|} prev (TypeJavascript) = prev <+ "text/javascript"
gHpr{|ScriptType|} prev (Typejscript) = prev <+ "text/jscript"
gHpr{|ScriptType|} prev (TypeVbscript) = prev <+ "text/vbscript"
gHpr{|ScriptType|} prev (TypeVbs) = prev <+ "text/vbs"
gHpr{|ScriptType|} prev (TypeXml) = prev <+ "text/xml"
gHpr{|SizeOption|} prev (Pixels num) = prev <+ num
gHpr{|SizeOption|} prev (Percent num) = prev <+ num <+ "%"
......
......@@ -4,8 +4,10 @@ definition module iDataSettings
// Concept & Programming (c) 2005 - 2007 Rinus Plasmeijer
import iDataHandler
import iDataCompileOptions
import Gerda // OPTION: GEneRic Database Access to a standard relational database, made by Arjen van Weelden
import DataFile // OPTION: A fast generic database stored in a file, made by Arjen van Weelden
import HttpServer
// Global settings of iData applications
......@@ -29,8 +31,6 @@ IF_Ajax aj no_aj :== no_aj // Otherwise
//IF_ClientServer cs no_cs :== cs // If you want to have a client server architecture (with Sapl running on the client)
IF_ClientServer cs no_cs :== no_cs // Otherwise
//IF_Client cl no_cl :== cl // If you want to generatecode for the Client (Sapl); IF_ClientServer should be set as well//
IF_Client cl no_cl :== no_cl // If you want to generatecode for the Sever ; IF_ClientServer should be set as well
IF_ClientTasks :: .a .a -> .a // Follows IF_Client setting
......@@ -70,6 +70,7 @@ class iSpecialStore a
:: ServerType
= Internal // Default: The application is linked with a Clean http 1.0 server
| CGI // The application is used through an external server with the Common Gateway Interface
| External // The application runs as a subserver connected to a http 1.1 server
| TestMode // The application is tested with Gast (in collaboration with Gast)
......@@ -78,15 +79,25 @@ instance == ServerType
// Set here the kind of server you want to use and the port number to use for the communication
ServerKind :== Internal // Enable this one for developing an iData or iTask application
//ServerKind :== CGI // or: Enable this one for running the final version through CGI
//ServerKind :== External // or: Enable this one for the final version using an http 1.1 server
SocketNr :== 80 // Socket you wnat to work on, default = 80
ServerOptions :== [HTTPServerOptPort 80] //Options for the internal HTTP server.
//ServerOptions :== [] //Options for the CGI wrapper
//ServerOptions :== [HTTPSubServerOptPort 80] //Options for the external subserver.
// Global Settings determining where files are stored
ThisExe :: String // name of this executable (without .exe)
MyAbsDir :: String // absolute path name of directory in which this execuatble is located in
// absolute path name of directory where static resources (css,js,img etc.) are stored
//ResourceDir :== MyAbsDir +++ ThisExe
ResourceDir :== "C:\\Documents and Settings\\Bas Lijnse\\My Documents\\Clean\\Libraries\\iData\\Resources\\"
iDataStorageDir :== MyAbsDir +++ ThisExe +++ "-iStore" // directory name where iData and iTask files are stored
ODCBDataBaseName :== ThisExe +++ "-ODCB" // name of ODCB Database being used by iData applications
......@@ -96,13 +107,10 @@ TraceFile :== MyAbsDir +++ ThisExe +++ "-traceSubServer.txt" // name of file
// Debug switches
TraceInput :== False // show what kind of information is received from Client
TraceInput :== True // show what kind of information is received from Client
TraceOutput :== False // show what kind of information is stored when application is finished
TraceThreads :== True // show the threadtable
TraceHttp10 :== True // show what kind of information is received by the Clean http 1.0 HtmlServer
TraceHttp11 :== False // show what kind of information is received by the Clean http 1.1 SubServer, stored in TraceFile
// separators
iDataIdSeparator :== "." // used for combining iData form id's
......
......@@ -20,6 +20,7 @@ instance == ServerType
where
(==) Internal Internal = True
(==) External External = True
(==) CGI CGI = True
(==) TestMode TestMode = True
(==) _ _ = False
......
......@@ -26,8 +26,8 @@ changeLifetimeStates :: !String !Lifespan !Lifespan !*FormStates *NWorld -> (*Fo
// storage and retrieval of FormStates
retrieveFormStates :: (Maybe [(String, String)]) *NWorld -> (*FormStates,*NWorld) // retrieves all form states hidden in the html page
storeFormStates :: !FormStates *NWorld -> (BodyTag,*NWorld)
retrieveFormStates :: [(String, String)] *NWorld -> (*FormStates,*NWorld) // retrieves all form states hidden in the html page
storeFormStates :: !FormStates *NWorld -> (String, String, *NWorld)
getTriplets :: !String !*FormStates -> (Triplets,!*FormStates) // retrieve triplets matching given id
......
......@@ -303,7 +303,7 @@ where
//
// De-serialize information from server to the internally used form states
retrieveFormStates :: (Maybe [(String, String)]) *NWorld -> (*FormStates,*NWorld) // retrieves all form states hidden in the html page
retrieveFormStates :: [(String, String)] *NWorld -> (*FormStates,*NWorld) // retrieves all form states hidden in the html page
retrieveFormStates args world
= ({ fstates = retrieveFStates, triplets = triplets, updateid = calc_updateid triplets, focusid = focus},world)
where
......@@ -327,17 +327,13 @@ where
// Serialize all states in FormStates that have to be remembered to either hidden encoded Html Code
// or store them in a persistent file, all depending on the kind of states
storeFormStates :: !FormStates *NWorld -> (BodyTag,*NWorld)
storeFormStates :: !FormStates *NWorld -> (String, String, *NWorld)
storeFormStates {fstates = allFormStates, focusid = focus} world
# world = writeAllTxtFileStates allFormStates world // first write all persistens states
= (BodyTag
[ IF_Ajax EmptyBody submitscript // submitscript defined in ajaxscript
, initscript // initscript does page initialization in javascript
, globalstateform (SV encodedglobalstate) (SV focus)
],world)
where
encodedglobalstate = EncodeHtmlStates (FStateToHtmlState allFormStates [])
# world = writeAllTxtFileStates allFormStates world // first write all persistens states
# encodedpagestate = EncodeHtmlStates (FStateToHtmlState allFormStates []) // encode states in the page
= (encodedpagestate, focus, world)
where
FStateToHtmlState :: !(Tree_ (String,.FormState)) *[HtmlState] -> *[HtmlState]
FStateToHtmlState Leaf_ accu = accu
FStateToHtmlState (Node_ left x right) accu
......
......@@ -7,7 +7,7 @@ import iDataStyleDef, StdInt, iDataSettings
StyleSheetIntern :== False // True, if the internlly defined CleanStyles are being used, otherwise use styles defined externally
InternalCleanStyles :: [Style] // Internal styles defined in this module
ExternalCleanStyles :== ThisExe +++ "\/clean.css" // External styles can be found here
ExternalCleanStyles :== ThisExe +++ "/css/clean.css" // External styles can be found here
......
......@@ -8,7 +8,6 @@ import StdMaybe, StdGeneric, StdOverloaded
mkString :: ![Char] -> *String
mkList :: !String -> [Char]
FindSubstr :: .[a] !.[a] -> (!Bool,!Int) | == a
stl :: !u:[.a] -> v:[.a], [u <= v]
// Useful string concatenation function
......
......@@ -12,17 +12,6 @@ mkString listofchar = {c \\ c <- listofchar }
mkList :: !String -> [Char]
mkList string = [c \\ c <-: string ]
FindSubstr :: .[a] !.[a] -> (!Bool,!Int) | == a
FindSubstr substr list = FindSubstr` list 0
where
lsubstr = length substr
FindSubstr` list=:[] _ = (False,0)
FindSubstr` list=:[x:xs] index
| substr == take lsubstr list = (True,index)
| otherwise = FindSubstr` xs (index + 1)
stl :: !u:[.a] -> v:[.a], [u <= v]
stl [] = []
stl [x:xs] = xs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment