diff options
Diffstat (limited to '')
31 files changed, 280 insertions, 117 deletions
diff --git a/sca-cpp/trunk/modules/edit/htdocs/app/index.html b/sca-cpp/trunk/modules/edit/htdocs/app/index.html index bc8eb78e7d..458ba4c00e 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/app/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/app/index.html @@ -21,7 +21,7 @@ <title>App</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <script type="text/javascript"> document.title = window.location.hostname.split('.')[0]; </script> @@ -63,8 +63,24 @@ function datavalue(l, id) { if (isNil(l)) return null; var e = car(l); - if (id == elementName(e)) - return e; + + // Element matches id segment + if (car(id) == elementName(e)) { + log('match', car(id)); + + // Found element matching the whole id path + if (isNil(cdr(id))) + return e; + + // Search for next id segments in child elements + if (!elementHasValue(e)) { + var v = datavalue(elementChildren(e), cdr(id)); + if (v != null) + return v; + } + } + + // Search for id through the whole element tree if (!elementHasValue(e)) { var v = datavalue(elementChildren(e), id); if (v != null) @@ -161,7 +177,7 @@ function displaydata(l) { // Update the widgets values function updatewidget(e) { - var dv = datavalue(l, "'" + e.id); + var dv = datavalue(l, map(function(t) { return "'" + t; }, e.id.split('.'))); if (dv == null || isNil(dv)) return e; setwidgetvalue(e, dv); @@ -221,6 +237,14 @@ function fixupwidget(e) { e.innerHTML = '<iframe src="' + f.href + '" frameborder="no" scrolling="no"></iframe>'; return e; } + if (e.className == 'section') { + e.style.width = '100%'; + return e; + } + if (e.className == 'table') { + car(childElements(e)).style.width = '100%'; + return e; + } return e; } @@ -228,50 +252,61 @@ function fixupwidget(e) { * Get app data from the main app page component. */ function getpagedata() { + try { - // Display component data on the page - function displaypage(doc) { - if (!isNil(doc)) - displaydoc(doc); - - // Reveal the page - ui.showbody(); - return true; - } + // Display component data on the page + function displaypage(doc) { + if (!isNil(doc)) + displaydoc(doc); - // Eval a component init script - function evalcompinit(doc) { - if (isNil(doc)) + // Reveal the page + ui.showbody(); return true; - var js = car(json.readJSON(mklist(doc))); - if (!elementHasValue(js)) + } + + // Eval a component init script + function evalcompinit(doc) { + log('comp init', doc); + if (isNil(doc)) + return true; + var js = car(json.readJSON(mklist(doc))); + if (!elementHasValue(js)) + return true; + eval(elementValue(js)); return true; - eval(elementValue(js)); - return true; - } - - // Initial setup of a widget - function setupwidget(e) { - fixupwidget(e); - bindwidgethandler(e); + } + + // Initial setup of a widget + function setupwidget(e) { + fixupwidget(e); + bindwidgethandler(e); + } + + // Get the component app data + var doc = pagecomp.get(window.location.search, function(doc) { + log('page return', doc); + try { + $('app').innerHTML = $('appFrame').contentDocument.body.innerHTML; + + // Initial setup of the widgets + map(setupwidget, filter(function(e) { return !isNil(e.id); }, nodeList(ui.elementByID($('app'), 'page').childNodes))); + + // Display data on the page + displaypage(doc); + + // Get and eval the optional timer and location watch setup scripts + everycomp.get('setup', evalcompinit); + locationcomp.get('setup', evalcompinit); + return true; + + } catch(e) { + log('exception on pagecomp.get()', e); + } + }); + + } catch(e) { + log('exception in getpagedata()', e); } - - // Get the component app data - var doc = pagecomp.get(window.location.search, function(doc) { - $('app').innerHTML = $('appFrame').contentDocument.body.innerHTML; - - // Initial setup of the widgets - map(setupwidget, filter(function(e) { return !isNil(e.id); }, nodeList(ui.elementByID($('app'), 'page').childNodes))); - - // Display data on the page - displaypage(doc); - - // Get and eval the optional timer and location watch setup scripts - everycomp.get('setup', evalcompinit); - locationcomp.get('setup', evalcompinit); - return true; - }); - return true; } @@ -280,6 +315,7 @@ function getpagedata() { */ function getcompdata(comp, qs) { var doc = comp.get(qs, function(doc) { + log('comp data', doc); return displaydoc(doc); }); return true; @@ -310,21 +346,33 @@ function compquery() { * Handle a button click event. */ function buttonClickHandler(id) { - return getcompdata(sca.component(id), compquery()); + try { + return getcompdata(sca.component(id), compquery()); + } catch(e) { + log('exception in buttonClickHandler()', e); + } } /** * Handle a timer interval event. */ function intervalHandler() { - return getcompdata(everycomp, compquery()); + try { + return getcompdata(everycomp, compquery()); + } catch(e) { + log('exception in intervalHandler()', e); + } } /** * Setup an interval timer. */ function setupIntervalHandler(sec) { - return setInterval(intervalHandler, sec); + try { + return setInterval(intervalHandler, sec); + } catch(e) { + log('exception in setupIntervalHandler()', e); + } } /** @@ -333,11 +381,17 @@ function setupIntervalHandler(sec) { var geoposition; function locationHandler(pos) { - geoposition = pos; - return getcompdata(locationcomp, compquery()); + log('location pos', pos); + try { + geoposition = pos; + return getcompdata(locationcomp, compquery()); + } catch(e) { + log('exception in locationHandler()', e); + } } function locationErrorHandler(e) { + log('location error', e); return true; } @@ -345,8 +399,13 @@ function locationErrorHandler(e) { * Setup a location watch handler. */ function setupLocationHandler() { - navigator.geolocation.getCurrentPosition(locationHandler, locationErrorHandler); - navigator.geolocation.watchPosition(locationHandler, locationErrorHandler); + log('setup location'); + try { + navigator.geolocation.getCurrentPosition(locationHandler, locationErrorHandler); + navigator.geolocation.watchPosition(locationHandler, locationErrorHandler); + } catch(e) { + log('exception in setupLocationHandler()', e); + } return true; } diff --git a/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html b/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html index d2bebe5114..44a971fb14 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html +++ b/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html @@ -104,13 +104,13 @@ function getapps(sync) { var title = cadr(assoc("'title", entry)) var name = cadr(assoc("'id", entry)) var editlink = '<a href=\"' + '/graph/?app=' + name + '\" target=\"_parent\">'; - var domainlink = '<a href=\"' + applink(name) + '\" target=\"_' + name + '\">' + name + '.' + window.location.hostname + '</a>'; + var domainlink = '<a href=\"' + applink(name) + '\" target=\"' + '_blank' + '\">' + name + '.' + window.location.hostname + '</a>'; var category = 'coolapps'; var updated = 'Feb 4, 2011'; var sharing = 'Public'; apps += '<tr class="trb"><td>'; - apps += editlink + '<img src="/public/app.png" style="width: 50px; height: 50px; margin-right: 10px; vertical-align: middle;"></img>' + '</a>'; + apps += editlink + '<img src="/public/app.png" width="50" height="50" style="width: 50px; height: 50px; margin-right: 10px; vertical-align: middle;"></img>' + '</a>'; apps += ' ' + editlink + name + '</a></td>'; apps += '<td>' + domainlink + '</td>'; apps += '<td>' + category + '</td>'; diff --git a/sca-cpp/trunk/modules/edit/htdocs/dash/index.html b/sca-cpp/trunk/modules/edit/htdocs/dash/index.html index ea1b2f03b6..a2f317175d 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/dash/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/dash/index.html @@ -21,7 +21,7 @@ <title>App Dashboard</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -46,7 +46,6 @@ $('h1').innerHTML = domaintitle(window.location.hostname); $('dashboard').innerHTML = '<iframe id="dashboardFrame" style="height: 5000px; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="dashboard.html"></iframe>'; -ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/data/index.html b/sca-cpp/trunk/modules/edit/htdocs/data/index.html index 8a7a63e798..6f5db2ba8b 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/data/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/data/index.html @@ -25,7 +25,7 @@ document.title = 'View - ' + window.location.hostname.split('.')[0] + '/' + cn; </script> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"> <script type="text/javascript" src="/util.js"></script> @@ -81,7 +81,9 @@ function mkdoctable(doc) { * Get and display the contents of the current component. */ function getdata() { + log('comp', comp.uri); comp.get('', function(doc) { + log('doc', doc); if (json.isJSON(mklist(doc))) return display(datatable(json.readJSON(mklist(doc)))); diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html index 604892fa27..7d9d472856 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html +++ b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html @@ -161,6 +161,7 @@ $('saveButton').onclick = function(e) { * Save the current composite. */ function save() { + log('saving'); $('saveButton').value = 'Saving'; savedcomposxml = car(writeXML(composite, false)); var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' + @@ -184,6 +185,8 @@ function oncomposchange() { // Autosave after 3 seconds setTimeout(function() { + log('savedcomposxml', savedcomposxml); + log('newddcomposxml', car(writeXML(composite, false))); if (savedcomposxml == car(writeXML(composite, false))) return false; return save(); @@ -307,6 +310,7 @@ installpalette('http', pos.rmove(0, 40), g, bg, spalette, gpalettes); installpalette('talk', pos.rmove(0, 40), g, bg, spalette, gpalettes); installpalette('social', pos.rmove(0, 40), g, bg, spalette, gpalettes); installpalette('search', pos.rmove(0, 40), g, bg, spalette, gpalettes); +installpalette('database', pos.rmove(0, 40), g, bg, spalette, gpalettes); installpalette('logic', pos.rmove(0, 40), g, bg, spalette, gpalettes); installpalette('math', pos.rmove(0, 40), g, bg, spalette, gpalettes); installpalette('python', pos.rmove(0, 40), g, bg, spalette, gpalettes); diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html index 9cda960f6e..f9daa45770 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html @@ -21,7 +21,7 @@ <title>Composition</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -62,7 +62,6 @@ function editapp(name) { // Display the editor for the current app editapp(appname); -ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/home.png b/sca-cpp/trunk/modules/edit/htdocs/home.png Binary files differindex e091b99c9f..8f5a0b0d86 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/home.png +++ b/sca-cpp/trunk/modules/edit/htdocs/home.png diff --git a/sca-cpp/trunk/modules/edit/htdocs/index.html b/sca-cpp/trunk/modules/edit/htdocs/index.html index 278f6ec260..7ff2bc7e9f 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/index.html @@ -21,7 +21,7 @@ <title>Home</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -48,7 +48,6 @@ $('h1').innerHTML = domaintitle(window.location.hostname); // Load the main page ui.loadiframe('main', 'main.html'); -ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/login/index.html b/sca-cpp/trunk/modules/edit/htdocs/login/index.html index 89dbd4a1c3..2cbb389718 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/login/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/login/index.html @@ -22,7 +22,7 @@ <title>Sign in</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -32,7 +32,7 @@ <h1>Sign in</h1> <br/> -<form name="formSignin" method="POST" action="/login/dologin"> +<form name="formSignin" method="POST" action="/login/dologin/"> <table border="0"> <tr><td>Username:</td><td><input type="text" id="httpd_username" name="httpd_username" value=""/></td></tr> <tr><td>Password:</td><td><input type="password" name="httpd_password" value=""/></td></tr> @@ -56,7 +56,7 @@ function queryParams() { function oauthReferrer() { r = queryParams()['openauth_referrer']; if (typeof(r) == 'undefined') - return r; + return '/'; s = r.indexOf('//'); if (s > 0) r = r.substring(s + 2); @@ -66,10 +66,6 @@ function oauthReferrer() { return r; } -if (typeof(oauthReferrer()) == 'undefined') { - document.location = '/'; -} - function submitFormSignin() { var reset = 'TuscanyOpenAuth=;expires=' + new Date(1970,01,01).toGMTString() + ';domain=.' + domainname(window.location.hostname) + ';path=/;secure=TRUE'; document.cookie = reset; diff --git a/sca-cpp/trunk/modules/edit/htdocs/logout/index.html b/sca-cpp/trunk/modules/edit/htdocs/logout/index.html index bf6623dc70..e17b325eb3 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/logout/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/logout/index.html @@ -22,7 +22,7 @@ <title>Sign out</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -32,7 +32,7 @@ <h1>Sign out</h1> <br/> -<form name="signout" action="/login" method="GET"> +<form name="signout" action="/" method="GET"> <input type="submit" onclick="submitSignout()" id="signOut" value="Sign out"/> </form> diff --git a/sca-cpp/trunk/modules/edit/htdocs/main.html b/sca-cpp/trunk/modules/edit/htdocs/main.html index 105dda9fe8..c9cdf37145 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/main.html +++ b/sca-cpp/trunk/modules/edit/htdocs/main.html @@ -29,11 +29,11 @@ <div style="margin-left: auto; margin-right: auto; text-align: center;"> <br/><br/><br/> -<a href="dash" target="_parent"><img src="home.png" style="width: 426px; height: 145px;"/></a> +<a href="/dash/" target="_parent"><img src="home.png" width="426" height="145" style="width: 426px; height: 145px;"/></a> <br/><br/> -<h1><a href="dash" target="_parent">Get Started</a></h1> +<h1><a href="/dash/" target="_parent">Get Started</a></h1> <br/><br/><br/> <div>This module implements a simple App store to help you create and share Tuscany apps.</div> diff --git a/sca-cpp/trunk/modules/edit/htdocs/menu.html b/sca-cpp/trunk/modules/edit/htdocs/menu.html index 0b9b7ddd8a..fe3e228c62 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/menu.html +++ b/sca-cpp/trunk/modules/edit/htdocs/menu.html @@ -68,9 +68,9 @@ function applink(appname) { var mdiv = $('menu'); var name = appname(); mdiv.innerHTML = ui.menubar( - append(mklist(ui.menu('Home', '/'), ui.menu('Store', '/store'), ui.menu('Dashboard', '/dash')), - (isNil(name) || name == 'undefined')? mklist() : mklist(ui.menu('Composition', '/graph/?app=' + name), ui.menu('Page', '/page/?app=' + name), ui.menu('Settings', '/props/?app=' + name), ui.menu(name + '.' + window.location.hostname, applink(name), '_' + name))), - mklist(userMenu(), ui.menu('Account', '/account'), ui.menu('Sign out', '/logout'))); + append(mklist(ui.menu('Home', '/'), ui.menu('Store', '/store/'), ui.menu('Dashboard', '/dash/')), + (isNil(name) || name == 'undefined')? mklist() : mklist(ui.menu('Composition', '/graph/?app=' + name), ui.menu('Page', '/page/?app=' + name), ui.menu('Settings', '/props/?app=' + name), ui.menu(name + '.' + window.location.hostname, applink(name), '_blank'))), + mklist(userMenu(), ui.menu('Account', '/account/'), ui.menu('Sign out', '/logout/'))); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/page/index.html b/sca-cpp/trunk/modules/edit/htdocs/page/index.html index bacd801429..e26231475e 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/page/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/page/index.html @@ -21,7 +21,7 @@ <title>Page</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -62,7 +62,6 @@ function editapp(name) { editapp(appname); -ui.showbody(); </script> </body> </html> diff --git a/sca-cpp/trunk/modules/edit/htdocs/page/page.html b/sca-cpp/trunk/modules/edit/htdocs/page/page.html index 219374a3d1..2766fe6bfa 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/page/page.html +++ b/sca-cpp/trunk/modules/edit/htdocs/page/page.html @@ -53,18 +53,18 @@ <span class="h1" id="palette:h1" style="position: absolute; left: 0px; top: 0px;"><h1>Header1</h1></span> <span class="h2" id="palette:h2" style="position: absolute; left: 0px; top: 35px;"><h2>Header2</h2></span> -<span class="section" id="palette:section" style="position: absolute; left: 0px; top: 70px;"><span class="section">section</span></span> +<span class="section" id="palette:section" style="position: absolute; left: 0px; top: 70px; width: 200px;"><span class="section">section</span></span> <span class="button" id="palette:button" style="position: absolute; left: 0px; top: 100px;"><input type="button" value="button"/></span> -<span class="entry" id="palette:entry" style="position: absolute; left: 0px; top: 130px;"><input type="text" value="field" size="10"/></span> -<span class="password" id="palette:password" style="position: absolute; left: 0px; top: 160px;"><input type="password" value="password" size="10"/></span> +<span class="entry" id="palette:entry" style="position: absolute; left: 0px; top: 130px;"><input type="text" value="field" size="20"/></span> +<span class="password" id="palette:password" style="position: absolute; left: 0px; top: 160px;"><input type="password" value="password" size="20"/></span> <span class="checkbox" id="palette:checkbox" style="position: absolute; left: 0px; top: 190px;"><input type="checkbox" value="checkbox"/><span>checkbox</span></span> <span class="list" id="palette:list" style="position: absolute; left: 0px; top: 220px;"><select><option value="list">list</option></select></span> -<span class="table" id="palette:table" style="position: absolute; left: 0px; top: 250px;"> -<table class="datatable"><tr><td class="datatdl">table</td><td class="datatdr">...</td></tr><tr><td class="datatdl">...</td><td class="datatdr">...</td></tr></table> +<span class="table" id="palette:table" style="position: absolute; left: 0px; top: 250px; width: 200px;"> +<table class="datatable" style="width: 200px;"><tr><td class="datatdl">table</td><td class="datatdr">...</td></tr><tr><td class="datatdl">...</td><td class="datatdr">...</td></tr></table> </span> <span class="link" id="palette:link" style="position: absolute; left: 0px; top: 300px;"><a href="/"><span>link</span></a></span> <span class="text" id="palette:text" style="position: absolute; left: 0px; top: 330px;"><span>text</span></span> -<span class="iframe" id="palette:iframe" style="position: absolute; left: 0px; top: 360px;"><a href="/public/iframe.html"><span class="fakeframe"><span>frame ...</span></span></a></span> +<span class="iframe fakeframe" id="palette:iframe" style="position: absolute; left: 0px; top: 360px; width: 200px;"><a href="/public/iframe.html"><span class="fakeframe"><span>frame ...</span></span></a></span> <span class="img" id="palette:img" style="position: absolute; left: 0px; top: 390px;"><img src="/public/img.png"/></span> </div> diff --git a/sca-cpp/trunk/modules/edit/htdocs/props/index.html b/sca-cpp/trunk/modules/edit/htdocs/props/index.html index 9c7553bef2..8236c77153 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/props/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/props/index.html @@ -21,7 +21,7 @@ <title>Settings</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -59,7 +59,6 @@ function editapp(name) { // Display the editor for the current app editapp(appname); -ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/app.png b/sca-cpp/trunk/modules/edit/htdocs/public/app.png Binary files differindex d3bf372316..1f73274b76 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/public/app.png +++ b/sca-cpp/trunk/modules/edit/htdocs/public/app.png diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html b/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html index 140ff48b8b..8c5bc03a91 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html +++ b/sca-cpp/trunk/modules/edit/htdocs/public/iframe.html @@ -21,7 +21,7 @@ <title>frame</title> <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> </head> <body style="margin:3px; padding: 0px; background-color: #dcdcdc;"> diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/img.png b/sca-cpp/trunk/modules/edit/htdocs/public/img.png Binary files differindex 42fcce9212..2363b25e8e 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/public/img.png +++ b/sca-cpp/trunk/modules/edit/htdocs/public/img.png diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html b/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html index a4c808deb7..c34f4b1f03 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html +++ b/sca-cpp/trunk/modules/edit/htdocs/public/notauth.html @@ -21,7 +21,7 @@ <title>Sorry</title> <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> <script type="text/javascript" src="/ui.js"></script> @@ -45,7 +45,8 @@ if (!issubdomain(window.location.hostname)) $('h1').innerHTML = domaintitle(window.location.hostname); -ui.showbody(); +if (issubdomain(window.location.hostname)) + ui.showbody(); function submitSignout() { var reset = 'TuscanyOpenAuth=;expires=' + new Date(1970,01,01).toGMTString() + ';domain=.' + domainname(window.location.hostname) + ';path=/;secure=TRUE'; diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html b/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html index a69cd7dd6e..ecd0a160fd 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html +++ b/sca-cpp/trunk/modules/edit/htdocs/public/notfound.html @@ -21,7 +21,7 @@ <title>Page not found</title> <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> <script type="text/javascript" src="/ui.js"></script> @@ -43,7 +43,8 @@ if (!issubdomain(window.location.hostname)) $('h1').innerHTML = domaintitle(window.location.hostname); -ui.showbody(); +if (issubdomain(window.location.hostname)) + ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/oops.html b/sca-cpp/trunk/modules/edit/htdocs/public/oops.html index e7e5085db5..bd1e488c5e 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/public/oops.html +++ b/sca-cpp/trunk/modules/edit/htdocs/public/oops.html @@ -21,7 +21,7 @@ <title>Oops</title> <meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> <script type="text/javascript" src="/ui.js"></script> @@ -42,7 +42,8 @@ if (!issubdomain(window.location.hostname)) $('h1').innerHTML = domaintitle(window.location.hostname); -ui.showbody(); +if (issubdomain(window.location.hostname)) + ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/store/index.html b/sca-cpp/trunk/modules/edit/htdocs/store/index.html index 849600d84e..6037746383 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/store/index.html +++ b/sca-cpp/trunk/modules/edit/htdocs/store/index.html @@ -21,7 +21,7 @@ <title>App Store</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/> <meta name="apple-mobile-web-app-capable" content="yes"/> -<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/> +<meta name="apple-mobile-web-app-status-bar-style" content="black"/> <link rel="apple-touch-icon" href="/public/touchicon.png"/> <link rel="stylesheet" type="text/css" href="/ui.css"/> <script type="text/javascript" src="/util.js"></script> @@ -51,7 +51,6 @@ if (isNil(category)) $('store').innerHTML = '<iframe id="storeFrame" style="height: 5000px; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="store.html?category=' + category + '"></iframe>'; -ui.showbody(); </script> </body> diff --git a/sca-cpp/trunk/modules/edit/htdocs/store/store.html b/sca-cpp/trunk/modules/edit/htdocs/store/store.html index 79717a01ef..33285d9145 100644 --- a/sca-cpp/trunk/modules/edit/htdocs/store/store.html +++ b/sca-cpp/trunk/modules/edit/htdocs/store/store.html @@ -101,12 +101,12 @@ function getapps(category, sync) { title = cadr(assoc("'title", entry)) name = cadr(assoc("'id", entry)) author = 'joe@localhost'; - hreflink = '<a href=\"' + applink(name) + '\" target=\"' + name + '\">'; + hreflink = '<a href=\"' + applink(name) + '\" target=\"' + '_blank' + '\">'; apps += '<div class="box" style="width: 250px; display: inline-block; border: 1px; border-style: solid; border-color: #dcdcdc; border-collapse: collapse; margin: 5px; padding: 10px; vertical-align: top;">' apps += '<table><tr>'; apps += '<td>'; - apps += '<div>' + hreflink + '<img src="/public/app.png" style="height: 50px; width: 50px; vertical-align: top; margin-right: 10px; margin-bottom: 5px;"></img>' + '</a></div>'; + apps += '<div>' + hreflink + '<img src="/public/app.png" width="50" height="50" style="height: 50px; width: 50px; vertical-align: top; margin-right: 10px; margin-bottom: 5px;"></img>' + '</a></div>'; apps += '<div><input type="button" id="cloneApp" value="Clone" title="Clone this app"></div>'; apps += '</td>'; apps += '<td class="tdw">'; diff --git a/sca-cpp/trunk/modules/edit/ssl-start b/sca-cpp/trunk/modules/edit/ssl-start index def40de019..36bef12413 100755 --- a/sca-cpp/trunk/modules/edit/ssl-start +++ b/sca-cpp/trunk/modules/edit/ssl-start @@ -54,19 +54,35 @@ EOF # Configure app home pages cat >>tmp/conf/dvhost-ssl.conf <<EOF -# Redirect to app home page -RewriteEngine On -RewriteRule ^/$ /index.html [R] - -# Error pages +# App error pages ErrorDocument 404 /public/notfound.html ErrorDocument 401 /public/notauth.html ErrorDocument 500 /public/oops.html +# Redirect www to main home page +RewriteEngine on +RewriteCond %{HTTP_HOST} ^www\.sca-store\.com [NC] +RewriteCond %{SERVER_PORT} !^443$ +RewriteRule .* https://sca-store.com:%{SERVER_PORT}%{REQUEST_URI} [L,R] +RewriteCond %{HTTP_HOST} ^www\.sca-store\.com [NC] +RewriteRule .* https://sca-store.com%{REQUEST_URI} [L,R] + +EOF + +cat >>tmp/conf/dvhost.conf <<EOF +# Redirect www to main home page +RewriteEngine on +RewriteCond %{HTTP_HOST} ^www\.sca-store\.com [NC] +RewriteCond %{SERVER_PORT} !^80$ +RewriteRule .* http://sca-store.com:%{SERVER_PORT}%{REQUEST_URI} [L,R] +RewriteCond %{HTTP_HOST} ^www\.sca-store\.com [NC] +RewriteRule .* http://sca-store.com%{REQUEST_URI} [L,R] + EOF # Configure SCA contributions cat >>tmp/conf/httpd.conf <<EOF + # Configure SCA Composite SCAContribution `pwd`/ SCAComposite edit.composite @@ -87,6 +103,9 @@ EOF # Create app links and sub-directories if needed ./mkapplinks +# Create application database directories +mkdir -p tmp/appdata/filedb + # Start memcached ../../components/cache/memcached-start diff --git a/sca-cpp/trunk/modules/edit/start b/sca-cpp/trunk/modules/edit/start index e377299c92..9b6f1ed21d 100755 --- a/sca-cpp/trunk/modules/edit/start +++ b/sca-cpp/trunk/modules/edit/start @@ -42,15 +42,19 @@ EOF # Configure app home pages cat >>tmp/conf/dvhost.conf <<EOF -# Redirect to app home page -RewriteEngine On -RewriteRule ^/$ /index.html [R] - -# Error pages +# App error pages ErrorDocument 404 /public/notfound.html ErrorDocument 401 /public/notauth.html ErrorDocument 500 /public/oops.html +# Redirect www to main home page +RewriteEngine on +RewriteCond %{HTTP_HOST} ^www\.sca-store\.com [NC] +RewriteCond %{SERVER_PORT} !^80$ +RewriteRule .* http://sca-store.com:%{SERVER_PORT}%{REQUEST_URI} [L,R] +RewriteCond %{HTTP_HOST} ^www\.sca-store\.com [NC] +RewriteRule .* http://sca-store.com%{REQUEST_URI} [L,R] + EOF # Configure SCA contributions @@ -75,6 +79,9 @@ EOF # Create app links and sub-directories if needed ./mkapplinks +# Create application database directories +mkdir -p tmp/appdata/filedb + # Start memcached ../../components/cache/memcached-start 11211 diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf index 46a8fc3cce..cfa3952521 100755 --- a/sca-cpp/trunk/modules/http/httpd-conf +++ b/sca-cpp/trunk/modules/http/httpd-conf @@ -75,8 +75,16 @@ CustomLog $root/logs/access_log combined CookieTracking on CookieName TuscanyVisitorId -# Configure Mime types +# Configure Mime types and default charsets TypesConfig $here/conf/mime.types +AddDefaultCharset utf-8 +AddCharset utf-8 .js .css + +# Configure cache control +SetEnvIf Request_URI "^/app.html$" must-revalidate +Header onsuccess merge Cache-Control public +Header onsuccess merge Cache-Control max-age=31536000 +Header onsuccess merge Cache-Control must-revalidate env=must-revalidate # Set default document root DocumentRoot $htdocs @@ -114,6 +122,16 @@ AuthType None Require all granted </Location> +# Enable compression +<Location /> +SetOutputFilter DEFLATE +BrowserMatch ^Mozilla/4 gzip-only-text/html +BrowserMatch ^Mozilla/4\.0[678] no-gzip +BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html +SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary +Header append Vary User-Agent env=!dont-vary +</Location> + # Listen on HTTP port Listen $listen @@ -158,6 +176,7 @@ cat >$root/conf/modules.conf <<EOF # Load a minimal set of modules, the load order is important # (e.g. load mod_headers before mod_rewrite, so its hooks execute # after mod_rewrite's hooks) +LoadModule headers_module ${modules_prefix}/modules/mod_headers.so LoadModule alias_module ${modules_prefix}/modules/mod_alias.so LoadModule authn_file_module ${modules_prefix}/modules/mod_authn_file.so LoadModule authn_core_module ${modules_prefix}/modules/mod_authn_core.so @@ -176,7 +195,6 @@ LoadModule proxy_connect_module ${modules_prefix}/modules/mod_proxy_connect.so LoadModule proxy_http_module ${modules_prefix}/modules/mod_proxy_http.so LoadModule proxy_balancer_module ${modules_prefix}/modules/mod_proxy_balancer.so LoadModule lbmethod_byrequests_module ${modules_prefix}/modules/mod_lbmethod_byrequests.so -LoadModule headers_module ${modules_prefix}/modules/mod_headers.so LoadModule ssl_module ${modules_prefix}/modules/mod_ssl.so LoadModule socache_shmcb_module ${modules_prefix}/modules/mod_socache_shmcb.so LoadModule rewrite_module ${modules_prefix}/modules/mod_rewrite.so diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index d9570ce5bd..0dd7920f65 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -326,10 +326,10 @@ const failable<int> writeResult(const failable<list<string> >& ls, const string& ostringstream os; write(content(ls), os); const string ob(str(os)); - debug(ob, "httpd::writeResult"); // Make sure browsers come back and check for updated dynamic content apr_table_setn(r->headers_out, "Expires", "Tue, 01 Jan 1980 00:00:00 GMT"); + apr_table_setn(r->headers_out, "Cache-Control", "must-revalidate"); // Compute and return an Etag for the returned content const string etag(ap_md5(r->pool, (const unsigned char*)c_str(ob))); @@ -339,10 +339,14 @@ const failable<int> writeResult(const failable<list<string> >& ls, const string& const char* match = apr_table_get(r->headers_in, "If-None-Match"); apr_table_setn(r->headers_out, "ETag", apr_pstrdup(r->pool, c_str(etag))); if (match != NULL && etag == match) { - r->status = HTTP_NOT_MODIFIED; + debug(r->status, "httpd::writeResult::status"); return OK; } + + debug(r->status, "httpd::writeResult::status"); + debug(ct, "httpd::writeResult::contentType"); + debug(ob, "httpd::writeResult::content"); ap_set_content_type(r, apr_pstrdup(r->pool, c_str(ct))); ap_rwrite(c_str(ob), (int)length(ob), r); return OK; diff --git a/sca-cpp/trunk/modules/http/mod-openauth.cpp b/sca-cpp/trunk/modules/http/mod-openauth.cpp index 6917c8862c..9fd6579265 100644 --- a/sca-cpp/trunk/modules/http/mod-openauth.cpp +++ b/sca-cpp/trunk/modules/http/mod-openauth.cpp @@ -285,6 +285,55 @@ static int checkAuthn(request_rec *r) { } /** + * Fixup cache control. + */ +bool filterCacheControl(const string& tok) { + return tok != "no-cache"; +} + +static apr_status_t outputFilter(ap_filter_t * f, apr_bucket_brigade * in) { + request_rec *r = f->r->main; + if (!r) + r = f->r; + for (; r != NULL; r = r->next) { + if (r->status != HTTP_OK && r->status != HTTP_NOT_MODIFIED) { + + // Don't cache errors and redirects + debug("no-cache", "modopenauth::outputFilter::nokCacheControl"); + apr_table_set(r->headers_out, "Cache-Control", "no-cache"); + continue; + } + + // Cache OK content + const char* cc = apr_table_get(r->headers_out, "Cache-Control"); + if (cc == NULL) { + debug("modopenauth::outputFilter::noCacheControl"); + continue; + } + debug(cc, "modopenauth::outputFilter::cacheControl"); + const string ncc = join(", ", filter<string>(filterCacheControl, tokenize(", ", cc))); + if (length(ncc) == 0) { + debug("modopenauth::outputFilter::noCacheControl"); + apr_table_unset(r->headers_out, "Cache-Control"); + continue; + } + + debug(ncc, "modopenauth::outputFilter::okCacheControl"); + apr_table_set(r->headers_out, "Cache-Control", c_str(ncc)); + } + + ap_remove_output_filter(f); + return ap_pass_brigade(f->next, in); +} + +/** + * Insert our cache control output filter. + */ +static void insertOutputFilter(request_rec * r) { + ap_add_output_filter("mod_openauth", NULL, r, r->connection); +} + +/** * Process the module configuration. */ int postConfigMerge(ServerConf& mainsc, server_rec* s) { @@ -349,6 +398,8 @@ void registerHooks(unused apr_pool_t *p) { ap_hook_post_config(postConfig, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_child_init(childInit, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_check_authn(checkAuthn, NULL, NULL, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF); + ap_register_output_filter("mod_openauth", outputFilter, NULL, AP_FTYPE_CONTENT_SET); + ap_hook_insert_filter(insertOutputFilter, NULL, NULL, APR_HOOK_LAST); } } diff --git a/sca-cpp/trunk/modules/js/htdocs/ui.css b/sca-cpp/trunk/modules/js/htdocs/ui.css index d3089c8ff3..7800217060 100644 --- a/sca-cpp/trunk/modules/js/htdocs/ui.css +++ b/sca-cpp/trunk/modules/js/htdocs/ui.css @@ -218,8 +218,10 @@ padding-left: 2px; padding-top: 0px; padding-bottom: 0px; padding-right: 2px; ve background-color: #598edd; color: #e5ecf9; } +/* v\: * { behavior:url(#default#VML); display:inline-block; } +*/ diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 27657dd587..637956321a 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -120,7 +120,7 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>& // Return JSON result js::JSContext cx; - return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc", r); + return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc; charset=utf-8", r); } // Evaluate the GET expression @@ -135,14 +135,14 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>& if (!isList(c)) { js::JSContext cx; if (isSymbol(c)) - return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(mklist<value>("name", value(string(c))))), cx), "application/json", r); - return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(mklist<value>("value", c))), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(mklist<value>("name", value(string(c))))), cx), "application/json; charset=utf-8", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(mklist<value>("value", c))), cx), "application/json; charset=utf-8", r); } // Write an empty list as a JSON empty value if (isNil((list<value>)c)) { js::JSContext cx; - return httpd::writeResult(json::writeJSON(list<value>(), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(list<value>(), cx), "application/json; charset=utf-8", r); } // Write content-type / content-list pair @@ -152,7 +152,7 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>& // Write an assoc value as a JSON result if (isSymbol(car<value>(c)) && !isNil(cdr<value>(c))) { js::JSContext cx; - return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(c)), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(c)), cx), "application/json; charset=utf-8", r); } // Convert list of values to element values @@ -164,15 +164,15 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>& const list<value> el = car<value>(e); if (isSymbol(car<value>(el)) && car<value>(el) == element && !isNil(cdr<value>(el)) && isSymbol(cadr<value>(el))) { if (cadr<value>(el) == atom::feed) - return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml", r); + return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml; charset=utf-8", r); if (cadr<value>(el) == atom::entry) - return httpd::writeResult(atom::writeATOMEntry(e), "application/atom+xml", r); + return httpd::writeResult(atom::writeATOMEntry(e), "application/atom+xml; charset=utf-8", r); } } // Write any other compound value as a JSON value js::JSContext cx; - return httpd::writeResult(json::writeJSON(e, cx), "application/json", r); + return httpd::writeResult(json::writeJSON(e, cx), "application/json; charset=utf-8", r); } /** @@ -206,7 +206,7 @@ const failable<int> post(request_rec* r, const lambda<value(const list<value>&)> return mkfailure<int>(reason(val)); // Return JSON result - return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc", r); + return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc; charset=utf-8", r); } // Evaluate an ATOM POST request and return the location of the corresponding created resource @@ -714,6 +714,8 @@ int handler(request_rec *r) { // Get the component implementation lambda const list<value> path(pathValues(r->uri)); + if (isNil(cdr(path))) + return HTTP_NOT_FOUND; const list<value> impl(assoctree<value>(cadr(path), usevh? vhc.vsc.implTree : sc.implTree)); if (isNil(impl)) { mkfailure<int>(string("Couldn't find component implementation: ") + cadr(path)); diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp index ac9e621177..8bc4504155 100644 --- a/sca-cpp/trunk/modules/server/mod-wiring.cpp +++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp @@ -90,6 +90,8 @@ int translateReference(const ServerConf& sc, request_rec *r) { // Find the requested component const list<value> rpath(pathValues(r->uri)); + if (isNil(cdr(rpath))) + return HTTP_NOT_FOUND; const list<value> comp(assoctree(cadr(rpath), sc.references)); if (isNil(comp)) return HTTP_NOT_FOUND; |