Commit 81fdcada authored by Bas Lijnse's avatar Bas Lijnse

Removed the builtin bootstrap html page and replaced it with a static html...

Removed the builtin bootstrap html page and replaced it with a static html page that can be easily customised.
parent 52dd2f98
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<title></title>
<link rel="stylesheet" href="itasks-theme-gray/itasks-theme.css" type="text/css" >
<!-- Sapl dependencies -->
<script type="text/javascript" src="/utils.js"></script>
<script type="text/javascript" src="/itask.js"></script>
<script type="text/javascript" src="/builtin.js"></script>
<script type="text/javascript" src="/dynamic.js"></script>
<script type="text/javascript" src="/sapl-rt.js"></script>
<script type="text/javascript" src="/sapl-support.js"></script>
<script type="text/javascript" src="/db.js"></script>
<script type="text/javascript" src="/debug.js"></script>
<script type="text/javascript" src="/itasks-js-interface.js"></script>
<!-- iTasks framework -->
<script type="text/javascript" src="/itasks-core.js"></script>
<script type="text/javascript" src="/itasks-components-raw.js"></script>
<script type="text/javascript" src="/itasks-components-form.js"></script>
<script type="text/javascript" src="/itasks-components-display.js"></script>
<script type="text/javascript" src="/itasks-components-selection.js"></script>
<script type="text/javascript" src="/itasks-components-container.js"></script>
<!-- load iTasks viewport -->
<script type="text/javascript">
window.onload = function() {
itasks.viewport({syncTitle: true}, document.body);
};
</script>
</head>
<body style="width: 100%; height: 100%">
</body>
</html>
......@@ -388,6 +388,7 @@ itasks.Loader = {
};
itasks.Viewport = {
cssCls: 'viewport',
syncTitle: false,
initComponent:function() {
var me = this;
......@@ -422,7 +423,22 @@ itasks.Viewport = {
me.service.doEditEvent(taskId, editorId, value);
},
onInstanceUIChange: function(change) {
this.children[0].onUIChange(change);
var me = this;
me.children[0].onUIChange(change);
//Sync title of the top level element
if(me.syncTitle) {
if(change.type == 'replace' && change.definition.title) {
document.title = change.definition.title;
}
if(change.type == 'change' && change.attributes.length > 0) {
change.attributes.forEach(function(change) {
if(change.name == 'title') {
document.title = change.value;
}
});
}
}
}
};
......@@ -431,7 +447,6 @@ itasks.viewport = function(spec,domEl) {
return Object.assign(Object.create(itasks.Component), itasks.Viewport, spec, {domEl:domEl}).init();
};
//Web service proxy/multiplexer class
//This is is a singleton because all itask component objects need to share their
//connections with the server in order to limit the number of connections.
......
......@@ -7,6 +7,7 @@ import iTasks.API.Extensions.Admin.WorkflowAdmin
import iTasks.API.Extensions.Admin.TonicAdmin
import iTasks._Framework.Tonic
import iTasks.API.Extensions.GIS.GoogleMap
import iTasks.UI.Definition
import Text, Text.HTML, StdArray
//import ligrettoTOP
//import iTaskGraphics, editletGraphics, edgehog
......@@ -90,9 +91,11 @@ basicAPIExamples =
Start :: *World -> *World
Start world
= startEngine [ publish "/" (\_ -> loginAndManageWorkList "iTasks Example Collection" basicAPIExamples)
= startEngine [ publish "/" (\_ -> loginAndManageWorkList title basicAPIExamples <<@ ApplyLayout (setAttributes (titleAttr title)))
, publish "/persons" (const enterPersons)
] world
where
title = "iTasks Example Collection"
//* utility functions
......
......@@ -163,18 +163,19 @@ background iworld
# iworld = snd (removeOutdatedSessions iworld)
= iworld
// The iTasks engine consist of a set of HTTP request handlers
// The iTasks engine consist of a set of HTTP WebService
engine :: publish -> [(!String -> Bool
,!Bool
,!(HTTPRequest (Map InstanceNo (Queue UIChange)) *IWorld -> (!HTTPResponse,!Maybe ConnectionType, !Maybe (Map InstanceNo (Queue UIChange)), !*IWorld))
,!(HTTPRequest (Map InstanceNo (Queue UIChange)) (Maybe {#Char}) ConnectionType *IWorld -> (![{#Char}], !Bool, !ConnectionType, !Maybe (Map InstanceNo (Queue UIChange)), !*IWorld))
,!(HTTPRequest (Map InstanceNo (Queue UIChange)) ConnectionType *IWorld -> (!Maybe (Map InstanceNo (Queue UIChange)), !*IWorld))
)] | Publishable publish
engine publishable
= taskHandlers (publishAll publishable) ++ defaultHandlers
engine publishable = [taskWebService url task \\ {PublishedTask|url,task=TaskWrapper task} <- published]
++ [staticResourceService [url \\ {PublishedTask|url} <- published]]
++ [sdsService]
where
taskHandlers published = [taskWebService url task \\ {url,task=TaskWrapper task} <- published]
defaultHandlers = [sdsService,staticResourceService]
published = publishAll publishable
publish :: String (HTTPRequest -> Task a) -> PublishedTask | iTask a
publish url task = {url = url, task = TaskWrapper (withFinalSessionLayout task)}
......
......@@ -33,7 +33,7 @@ taskWebService :: !String !(HTTPRequest -> Task a) ->
,!(HTTPRequest ChangeQueues ConnectionType *IWorld -> (!Maybe ChangeQueues, !*IWorld))
) | iTask a
staticResourceService ::
staticResourceService :: [String] ->
(!(String -> Bool)
,!Bool
,!(HTTPRequest r *IWorld -> (HTTPResponse, Maybe loc, Maybe w ,*IWorld))
......
......@@ -59,7 +59,6 @@ where
matchFun :: String String -> Bool
matchFun matchUrl reqUrl = startsWith matchUrl reqUrl && isTaskUrl (reqUrl % (size matchUrl,size reqUrl))
where
isTaskUrl "" = True
isTaskUrl s = case dropWhile ((==)"") (split "/" s) of // Ignore slashes at the beginning of the path
["new"] = True // Creation of new instances
["gui-events"] = True // Events for multiple instances
......@@ -98,8 +97,6 @@ where
# headers = [("Upgrade","websocket"), ("Connection","Upgrade")
,("Sec-WebSocket-Accept",secWebSocketAccept),("Sec-WebSocket-Protocol","itwc")]
= ({newHTTPResponse 101 "Switching Protocols" & rsp_headers = headers, rsp_data = ""}, Just (WebSocketConnection []),Nothing,iworld)
| urlSpec == ""
= (itwcStartResponse url serverName customCSS, Nothing, Nothing, iworld)
| otherwise
= case dropWhile ((==)"") (split "/" urlSpec) of
["new"]
......@@ -122,8 +119,6 @@ where
# (_,iworld) = updateInstanceConnect req.client_name instances iworld
# (messages,output) = dequeueOutput instances output //TODO: Check keys
= (eventsResponse messages, Just (EventSourceConnection instances), Just output, iworld)
[instanceNo,instanceKey]
= (itwcStartResponse url serverName customCSS, Nothing, Nothing, iworld)
[instanceNo,instanceKey,"gui"]
//Load task instance and edit / evaluate
# instanceNo = toInt instanceNo
......@@ -199,42 +194,6 @@ where
where
format (instanceNo,change) = "data: {\"instance\":" +++toString instanceNo+++",\"change\":" +++ toString (encodeUIChange change) +++ "}\n\n"
itwcStartResponse path appName customCSS = {okResponse & rsp_data = toString itwcStartPage}
where
itwcStartPage = HtmlTag [] [head,body]
head = HeadTag [] [MetaTag [CharsetAttr "UTF-8"] []
,MetaTag [NameAttr "viewport",ContentAttr "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui"] []
,MetaTag [NameAttr "mobile-web-app-capable",ContentAttr "yes"] []
,MetaTag [NameAttr "apple-mobile-web-app-capable",ContentAttr "yes"] []
,TitleTag [] [Text appName], startUrlScript : styles ++ scripts]
body = BodyTag [StyleAttr "width: 100%; height: 100%"] []
startUrlScript = ScriptTag [TypeAttr "text/javascript"]
[RawText "window.onload = function() { itasks.viewport({}, document.body); };"
]
styles = [LinkTag [RelAttr "stylesheet", HrefAttr file, TypeAttr "text/css"] [] \\ file <- stylefiles]
scripts = [ScriptTag [SrcAttr file, TypeAttr "text/javascript"] [] \\ file <- scriptfiles]
stylefiles =
["itasks-theme-gray/itasks-theme.css"
: if customCSS [appName +++ ".css"] []]
scriptfiles = saplScripts ++ itaskScripts
saplScripts =
["/utils.js","/itask.js"
,"/builtin.js","/dynamic.js"
,"/sapl-rt.js","/sapl-support.js"
,"/db.js", "/debug.js","/itasks-js-interface.js"
]
itaskScripts =
["/itasks-core.js"
,"/itasks-components-raw.js"
,"/itasks-components-form.js"
,"/itasks-components-display.js"
,"/itasks-components-selection.js"
,"/itasks-components-container.js"
]
createDocumentsFromUploads [] iworld = ([],iworld)
createDocumentsFromUploads [(n,u):us] iworld
# (mbD,iworld) = createDocument u.upl_filename u.upl_mimetype u.upl_content iworld
......@@ -348,13 +307,14 @@ where
where
addDefault headers hdr val = if (('DL'.lookup hdr headers) =: Nothing) [(hdr,val):headers] headers
// Request handler which serves static resources from the application directory,
// or a system wide default directory if it is not found locally.
// This request handler is used for serving system wide javascript, css, images, etc...
staticResourceService ::(!(String -> Bool),!Bool,!(HTTPRequest r *IWorld -> (HTTPResponse, Maybe loc, Maybe w ,*IWorld))
staticResourceService :: [String] -> (!(String -> Bool),!Bool,!(HTTPRequest r *IWorld -> (HTTPResponse, Maybe loc, Maybe w ,*IWorld))
,!(HTTPRequest r (Maybe {#Char}) loc *IWorld -> (![{#Char}], !Bool, loc, Maybe w ,!*IWorld))
,!(HTTPRequest r loc *IWorld -> (!Maybe w,!*IWorld)))
staticResourceService = (const True,True,initFun,dataFun,lostFun)
staticResourceService taskPaths = (const True,True,initFun,dataFun,lostFun)
where
initFun req _ env
# (rsp,env) = handleStaticResourceRequest req env
......@@ -370,10 +330,12 @@ where
serveStaticResource req [] iworld
= (notFoundResponse req,iworld)
serveStaticResource req [d:ds] iworld=:{IWorld|world}
# filename = d +++ filePath req.HTTPRequest.req_path
# filename = if (isMember req.HTTPRequest.req_path taskPaths) //Check if one of the published tasks is requested, then serve bootstrap page
(d +++ filePath "/index.html")
(d +++ filePath req.HTTPRequest.req_path)
# type = mimeType filename
# (exists, world) = fileExists filename world
| not exists
# (mbInfo,world) = getFileInfo filename world
| case mbInfo of (Ok info) = info.directory ; _ = True
= serveStaticResource req ds {IWorld|iworld & world = world}
# (mbContent, world) = readFile filename world
= case mbContent of
......
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