From 038525403ebcc1d69436adad9bc1cfabb371dae1 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 4 Apr 2011 08:46:08 +0000 Subject: Fix performance and security issues reported by pagespeed and skipfish. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1088508 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/kernel/sstream.hpp | 6 +- sca-cpp/trunk/modules/edit/htdocs/app/index.html | 159 ++++++++++++++------- .../trunk/modules/edit/htdocs/dash/dashboard.html | 4 +- sca-cpp/trunk/modules/edit/htdocs/dash/index.html | 3 +- sca-cpp/trunk/modules/edit/htdocs/data/index.html | 4 +- sca-cpp/trunk/modules/edit/htdocs/graph/graph.html | 4 + sca-cpp/trunk/modules/edit/htdocs/graph/index.html | 3 +- sca-cpp/trunk/modules/edit/htdocs/home.png | Bin 19631 -> 9595 bytes sca-cpp/trunk/modules/edit/htdocs/index.html | 3 +- sca-cpp/trunk/modules/edit/htdocs/login/index.html | 10 +- .../trunk/modules/edit/htdocs/logout/index.html | 4 +- sca-cpp/trunk/modules/edit/htdocs/main.html | 4 +- sca-cpp/trunk/modules/edit/htdocs/menu.html | 6 +- sca-cpp/trunk/modules/edit/htdocs/page/index.html | 3 +- sca-cpp/trunk/modules/edit/htdocs/page/page.html | 12 +- sca-cpp/trunk/modules/edit/htdocs/props/index.html | 3 +- sca-cpp/trunk/modules/edit/htdocs/public/app.png | Bin 258 -> 147 bytes .../trunk/modules/edit/htdocs/public/iframe.html | 2 +- sca-cpp/trunk/modules/edit/htdocs/public/img.png | Bin 368 -> 357 bytes .../trunk/modules/edit/htdocs/public/notauth.html | 5 +- .../trunk/modules/edit/htdocs/public/notfound.html | 5 +- sca-cpp/trunk/modules/edit/htdocs/public/oops.html | 5 +- sca-cpp/trunk/modules/edit/htdocs/store/index.html | 3 +- sca-cpp/trunk/modules/edit/htdocs/store/store.html | 4 +- sca-cpp/trunk/modules/edit/ssl-start | 29 +++- sca-cpp/trunk/modules/edit/start | 17 ++- sca-cpp/trunk/modules/http/httpd-conf | 22 ++- sca-cpp/trunk/modules/http/httpd.hpp | 8 +- sca-cpp/trunk/modules/http/mod-openauth.cpp | 51 +++++++ sca-cpp/trunk/modules/js/htdocs/ui.css | 2 + sca-cpp/trunk/modules/server/mod-eval.hpp | 20 +-- sca-cpp/trunk/modules/server/mod-wiring.cpp | 2 + 32 files changed, 283 insertions(+), 120 deletions(-) (limited to 'sca-cpp') diff --git a/sca-cpp/trunk/kernel/sstream.hpp b/sca-cpp/trunk/kernel/sstream.hpp index 770c169e09..a638e2dcca 100644 --- a/sca-cpp/trunk/kernel/sstream.hpp +++ b/sca-cpp/trunk/kernel/sstream.hpp @@ -184,16 +184,16 @@ private: */ const list tokenize(const char* sep, const string& str) { struct nested { - static const list tokenize(const char* sep, const string& str, const size_t start = 0) { + static const list tokenize(const char* sep, const size_t slen, const string& str, const size_t start) { if (start >= length(str)) return list(); const size_t i = find(str, sep, start); if (i == length(str)) return mklist(string(substr(str, start))); - return cons(string(substr(str, start, i - start)), tokenize(sep, str, i + 1)); + return cons(string(substr(str, start, i - start)), tokenize(sep, slen, str, i + slen)); } }; - return nested::tokenize(sep, str, 0); + return nested::tokenize(sep, strlen(sep), str, 0); } /** 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 @@ App - + @@ -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 = ''; 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 = ''; - var domainlink = '' + name + '.' + window.location.hostname + ''; + var domainlink = '' + name + '.' + window.location.hostname + ''; var category = 'coolapps'; var updated = 'Feb 4, 2011'; var sharing = 'Public'; apps += ''; - apps += editlink + '' + ''; + apps += editlink + '' + ''; apps += ' ' + editlink + name + ''; apps += '' + domainlink + ''; apps += '' + category + ''; 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 @@ App Dashboard - + @@ -46,7 +46,6 @@ $('h1').innerHTML = domaintitle(window.location.hostname); $('dashboard').innerHTML = ''; -ui.showbody(); 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; - + @@ -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 = '' + @@ -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 @@ Composition - + @@ -62,7 +62,6 @@ function editapp(name) { // Display the editor for the current app editapp(appname); -ui.showbody(); diff --git a/sca-cpp/trunk/modules/edit/htdocs/home.png b/sca-cpp/trunk/modules/edit/htdocs/home.png index e091b99c9f..8f5a0b0d86 100644 Binary files a/sca-cpp/trunk/modules/edit/htdocs/home.png and b/sca-cpp/trunk/modules/edit/htdocs/home.png differ 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 @@ Home - + @@ -48,7 +48,6 @@ $('h1').innerHTML = domaintitle(window.location.hostname); // Load the main page ui.loadiframe('main', 'main.html'); -ui.showbody(); 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 @@ Sign in - + @@ -32,7 +32,7 @@

Sign in


-
+ @@ -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 @@ Sign out - + @@ -32,7 +32,7 @@

Sign out


- + 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 @@



- +

-

Get Started

+

Get Started




This module implements a simple App store to help you create and share Tuscany apps.
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/'))); 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 @@ Page - + @@ -62,7 +62,6 @@ function editapp(name) { editapp(appname); -ui.showbody(); 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 @@

Header1

Header2

-section +section - - + + checkbox - -
Username:
Password:
table...
......
+ +
table...
......
link text -frame ... +frame ... 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 @@ Settings - + @@ -59,7 +59,6 @@ function editapp(name) { // Display the editor for the current app editapp(appname); -ui.showbody(); diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/app.png b/sca-cpp/trunk/modules/edit/htdocs/public/app.png index d3bf372316..1f73274b76 100644 Binary files a/sca-cpp/trunk/modules/edit/htdocs/public/app.png and b/sca-cpp/trunk/modules/edit/htdocs/public/app.png differ 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 @@ frame - + diff --git a/sca-cpp/trunk/modules/edit/htdocs/public/img.png b/sca-cpp/trunk/modules/edit/htdocs/public/img.png index 42fcce9212..2363b25e8e 100644 Binary files a/sca-cpp/trunk/modules/edit/htdocs/public/img.png and b/sca-cpp/trunk/modules/edit/htdocs/public/img.png differ 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 @@ Sorry - + @@ -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 @@ Page not found - + @@ -43,7 +43,8 @@ if (!issubdomain(window.location.hostname)) $('h1').innerHTML = domaintitle(window.location.hostname); -ui.showbody(); +if (issubdomain(window.location.hostname)) + ui.showbody(); 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 @@ Oops - + @@ -42,7 +42,8 @@ if (!issubdomain(window.location.hostname)) $('h1').innerHTML = domaintitle(window.location.hostname); -ui.showbody(); +if (issubdomain(window.location.hostname)) + ui.showbody(); 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 @@ App Store - + @@ -51,7 +51,6 @@ if (isNil(category)) $('store').innerHTML = ''; -ui.showbody(); 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 = ''; + hreflink = ''; apps += '
' apps += ''; apps += ''; apps += '
'; - apps += '
' + hreflink + '' + '
'; + apps += '
' + hreflink + '' + '
'; apps += '
'; apps += '
'; 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 <>tmp/conf/dvhost.conf <>tmp/conf/httpd.conf <>tmp/conf/dvhost.conf < +# Enable compression + +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 + + # Listen on HTTP port Listen $listen @@ -158,6 +176,7 @@ cat >$root/conf/modules.conf < writeResult(const failable >& 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 writeResult(const failable >& 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 @@ -284,6 +284,55 @@ static int checkAuthn(request_rec *r) { return httpd::reportStatus(login(dc.login, 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(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. */ @@ -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 get(request_rec* r, const lambda&)>& // 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 get(request_rec* r, const lambda&)>& if (!isList(c)) { js::JSContext cx; if (isSymbol(c)) - return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("name", value(string(c))))), cx), "application/json", r); - return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("value", c))), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("name", value(string(c))))), cx), "application/json; charset=utf-8", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist(mklist("value", c))), cx), "application/json; charset=utf-8", r); } // Write an empty list as a JSON empty value if (isNil((list)c)) { js::JSContext cx; - return httpd::writeResult(json::writeJSON(list(), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(list(), cx), "application/json; charset=utf-8", r); } // Write content-type / content-list pair @@ -152,7 +152,7 @@ const failable get(request_rec* r, const lambda&)>& // Write an assoc value as a JSON result if (isSymbol(car(c)) && !isNil(cdr(c))) { js::JSContext cx; - return httpd::writeResult(json::writeJSON(valuesToElements(mklist(c)), cx), "application/json", r); + return httpd::writeResult(json::writeJSON(valuesToElements(mklist(c)), cx), "application/json; charset=utf-8", r); } // Convert list of values to element values @@ -164,15 +164,15 @@ const failable get(request_rec* r, const lambda&)>& const list el = car(e); if (isSymbol(car(el)) && car(el) == element && !isNil(cdr(el)) && isSymbol(cadr(el))) { if (cadr(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(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 post(request_rec* r, const lambda&)> return mkfailure(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 path(pathValues(r->uri)); + if (isNil(cdr(path))) + return HTTP_NOT_FOUND; const list impl(assoctree(cadr(path), usevh? vhc.vsc.implTree : sc.implTree)); if (isNil(impl)) { mkfailure(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 rpath(pathValues(r->uri)); + if (isNil(cdr(rpath))) + return HTTP_NOT_FOUND; const list comp(assoctree(cadr(rpath), sc.references)); if (isNil(comp)) return HTTP_NOT_FOUND; -- cgit v1.2.3