summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/edit
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-10-26 08:11:35 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-10-26 08:11:35 +0000
commite156872419a6979ceaee6cf97c5b900ef167292a (patch)
treefea3587cf95a91d09af7319624ed20db46a9a53c /sca-cpp/trunk/modules/edit
parent0f3b340da7acffba93de0618d80d6018097e98ee (diff)
Use Page Speed to minify Web resources at build time, and a few more improvements to the offline support.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1189069 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/edit')
-rw-r--r--sca-cpp/trunk/modules/edit/Makefile.am14
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/app/index.html195
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/cache-manifest.cmf2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/index.html2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/index.html10
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/notauth/index.html4
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/notfound/index.html4
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/notyet/index.html4
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/oops/index.html4
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/page/index.html4
11 files changed, 163 insertions, 82 deletions
diff --git a/sca-cpp/trunk/modules/edit/Makefile.am b/sca-cpp/trunk/modules/edit/Makefile.am
index 55eca3ed7e..241d06d3f0 100644
--- a/sca-cpp/trunk/modules/edit/Makefile.am
+++ b/sca-cpp/trunk/modules/edit/Makefile.am
@@ -21,6 +21,20 @@ moddir = $(prefix)/modules/edit
dist_mod_SCRIPTS = start stop ssl-start mkapplinks
nobase_dist_mod_DATA = edit.composite *.py htdocs/*.html htdocs/*.js htdocs/*.cmf htdocs/*.ico htdocs/home/*.png htdocs/home/*.b64 htdocs/*.txt htdocs/account/*.html htdocs/create/*.html htdocs/clone/*.html htdocs/app/*.html htdocs/store/*.html htdocs/stats/*.html htdocs/graph/*.html htdocs/home/*.html htdocs/page/*.html htdocs/login/*.html htdocs/logout/*.html htdocs/notauth/*.html htdocs/notfound/*.html htdocs/oops/*.html htdocs/public/*.html htdocs/public/*.png htdocs/public/*.b64 palettes/*/palette.composite apps/*/app.composite apps/*/app.stats apps/*/htdocs/app.html dashboards/*/user.apps store/*/store.apps
+
EXTRA_DIST = edit.composite *.py htdocs/*.html htdocs/*.js htdocs/*.cmf htdocs/*.ico htdocs/home/*.png htdocs/home/*.b64 htdocs/*.txt htdocs/account/*.html htdocs/create/*.html htdocs/clone/*.html htdocs/app/*.html htdocs/store/*.html htdocs/stats/*.html htdocs/graph/*.html htdocs/home/*.html htdocs/page/*.html htdocs/login/*.html htdocs/logout/*.html htdocs/notauth/*.html htdocs/notfound/*.html htdocs/oops/*.html htdocs/public/*.html htdocs/public/*.png htdocs/public/*.b64 palettes/*/palette.composite apps/*/app.composite apps/*/app.stats apps/*/htdocs/app.html dashboards/*/user.apps store/*/store.apps
+BUILT_SOURCES = minify_html.stamp minify_js.stamp
+minify_html.stamp: htdocs/*.html htdocs/*/*.html
+ find htdocs -name "*-min.html" -exec rm {} \;
+ find htdocs -name "*.html" -exec ../http/minify-html {} \;
+ touch minify_html.stamp
+
+minify_js.stamp: htdocs/*.js
+ find htdocs -name "*-min.js" -exec rm {} \;
+ find htdocs -name "*.js" -exec ../http/minify-js {} \;
+ touch minify_js.stamp
+
+CLEANFILES = *.stamp
+
endif
diff --git a/sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf b/sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf
index 4f3358edef..0be3e662d7 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf
+++ b/sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf
@@ -9,7 +9,7 @@ CACHE MANIFEST
/notfound/
/notyet/
/oops/
-/public/iframe.html
+/public/iframe-min.html
/public/img.png
/public/touchicon.png
diff --git a/sca-cpp/trunk/modules/edit/htdocs/app/index.html b/sca-cpp/trunk/modules/edit/htdocs/app/index.html
index cb89cd0ced..9309c7cebe 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/app/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/app/index.html
@@ -77,7 +77,7 @@ appcache.get = function(uri) {
<div id="headdiv" class="hsection">
<script type="text/javascript">
(function() {
-$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig.js')));
+$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
})();
</script>
</div>
@@ -96,8 +96,9 @@ document.title = location.hostname.split('.')[0];
var contentdiv = $('content');
/**
- * Start, stop, timer, animation and location components.
+ * Initialize the app HTTP clients.
*/
+var pagecomp = sca.httpclient('page', '');
var startcomp = sca.httpclient('start', '/start');
var stopcomp = sca.httpclient('stop', '/stop');
var timercomp = sca.httpclient('timer', '/timer');
@@ -109,10 +110,9 @@ var locationcomp = sca.httpclient('location', '/location');
*/
var appresources = [
['/all-min.js'],
- ['/app.html'],
['/ui-min.css'],
- ['/footconfig.js'],
- ['/headconfig.js'],
+ ['/footconfig-min.js'],
+ ['/headconfig-min.js'],
];
/**
@@ -266,12 +266,12 @@ function setwidgetvalue(e, dv) {
// Define the stylesheet
if (s != '') {
- var esheet = contentdiv.getElementById('style_' + e.id);
+ var esheet = ui.elementByID(contentdiv, 'style_' + e.id);
if (isNil(esheet)) {
var nesheet = document.createElement('style');
nesheet.id = 'style_' + e.id;
nesheet.type = 'text/css';
- contentdiv.getElementsByTagName('head')[0].appendChild(nesheet);
+ document.head.appendChild(nesheet);
nesheet.innerHTML = s;
} else {
esheet.innerHTML = s;
@@ -526,18 +526,6 @@ function initwidget(e) {
}
/**
- * Get document from a component.
- */
-function getdoc(comp, name, uri) {
- try {
- return comp.getnocache(uri);
- } catch(e) {
- log('exception on get(' + name + ', ' + uri + ')', e);
- return null;
- }
-}
-
-/**
* Get app data from the main app page component.
*/
function getpagedata() {
@@ -567,19 +555,48 @@ function getpagedata() {
bindwidgethandler(e);
}
- // Get the component app data
- var doc = getdoc(startcomp, 'start', location.search);
-
// Setup the widgets
map(setupwidget, filter(function(e) { return !isNil(e.id); }, nodeList(ui.elementByID(contentdiv, 'page').childNodes)));
- // Display data on the page
- displaypage(doc);
+ // Get the component app data
+ startcomp.get(location.search, function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(start, ' + location.search + ')', e);
+ return false;
+ }
+
+ // Display data on the page
+ displaypage(doc);
+ });
// Get and eval the optional timer, animation and location watch setup scripts
- evalcompinit(getdoc(timercomp, 'timer', 'setup'));
- evalcompinit(getdoc(animationcomp, 'animation', 'setup'));
- evalcompinit(getdoc(locationcomp, 'location', 'setup'));
+ timercomp.get('setup', function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(timer, setup)', e);
+ return false;
+ }
+
+ // Evaluate the component init expression
+ return evalcompinit(doc);
+ });
+ animationcomp.get('setup', function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(animation, setup)', e);
+ return false;
+ }
+
+ // Evaluate the component init expression
+ return evalcompinit(doc);
+ });
+ locationcomp.get('setup', function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(location, setup)', e);
+ return false;
+ }
+
+ // Evaluate the component init expression
+ return evalcompinit(doc);
+ });
return true;
@@ -619,7 +636,16 @@ function compquery() {
*/
function buttonClickHandler(id) {
try {
- return updatepage(docdata(getdoc(sca.component(id), 'button', compquery())));
+ var uri = compquery();
+ return sca.component(id).get(uri, function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(button, ' + uri + ')', e);
+ return false;
+ }
+
+ // Inject data into the page
+ updatepage(docdata(doc));
+ });
} catch(e) {
log('exception in buttonClickHandler()', e);
return true;
@@ -631,7 +657,16 @@ function buttonClickHandler(id) {
*/
function intervalHandler() {
try {
- return updatepage(docdata(getdoc(timercomp, 'timer', compquery())));
+ var uri = compquery();
+ return timercomp.get(uri, function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(timer, ' + uri + ')', e);
+ return false;
+ }
+
+ // Inject data into the page
+ updatepage(docdata(doc));
+ });
} catch(e) {
log('exception in intervalHandler()', e);
return true;
@@ -655,50 +690,64 @@ function setupIntervalHandler(msec) {
* Handle an animation event.
*/
var animationData = null;
+var gettingAnimationData = false;
var currentAnimationData = null;
var animationLoop = 0;
var currentAnimationLoop = 0;
function animationHandler() {
try {
- // Get animation data if necessary
- if (isNil(animationData)) {
- animationData = docdata(getdoc(animationcomp, 'animation', compquery()));
- if (isNil(animationData)) {
- // Retry later
- return true;
- }
- currentAnimationData = animationData;
- currentAnimationLoop = animationLoop;
- }
+ function applyAnimation() {
+ // Update page with current animation data
+ updatepage(car(currentAnimationData));
+
+ // End of animation?
+ if (isNil(cdr(currentAnimationData))) {
+ if (currentAnimationLoop == -1) {
+ // Repeat current animation forever
+ currentAnimationData = animationData;
+ return true;
+ }
- // Update page with animation data
- updatepage(car(currentAnimationData));
+ currentAnimationLoop = currentAnimationLoop - 1;
+ if (currentAnimationLoop <= 0) {
+ // Get next animation data
+ currentAnimationData = null;
+ animationData = null;
+ return true;
+ }
- // End of animation?
- if (isNil(cdr(currentAnimationData))) {
- if (currentAnimationLoop == -1) {
- // Repeat current animation forever
+ // Repeat animation
currentAnimationData = animationData;
return true;
}
- currentAnimationLoop = currentAnimationLoop - 1;
- if (currentAnimationLoop <= 0) {
- // Get next animation data
- currentAnimationData = null;
- animationData = null;
+ // Move to the next animation frame
+ currentAnimationData = cdr(currentAnimationData);
+ return true;
+ }
+
+ // Get new animation data if necessary
+ if (isNil(animationData)) {
+ if (gettingAnimationData)
return true;
- }
+ var uri = compquery();
+ return animationcomp.get(uri, function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(animation, ' + uri + ')', e);
+ return false;
+ }
- // Repeat animation
- currentAnimationData = animationData;
- return true;
+ // Apply the new animation
+ currentAnimationData = docdata(doc);
+ currentAnimationLoop = animationLoop;
+ gettingAnimationData = false;
+ applyAnimation();
+ });
}
- // Move to the next animation frame
- currentAnimationData = cdr(currentAnimationData);
- return true;
+ // Apply the current animation
+ return applyAnimation();
} catch(e) {
log('exception in animationHandler()', e);
@@ -729,9 +778,18 @@ var geoposition = null;
function locationHandler(pos) {
try {
geoposition = pos;
- return updatepage(docdata(getdoc(locationcomp, 'location', compquery())));
+ var uri = compquery();
+ return locationcomp.get(uri, function(doc, e) {
+ if (isNil(doc)) {
+ log('exception on get(location, ' + uri + ')', e);
+ return false;
+ }
+
+ // Inject data into the page
+ updatepage(docdata(doc));
+ });
} catch(e) {
- locationErrorHandler(e);
+ return locationErrorHandler(e);
}
}
@@ -758,6 +816,7 @@ function setupLocationHandler() {
} catch(e) {
log('exception in installLocationHandler()', e);
}
+ return true;
}
installLocationHandler();
@@ -766,11 +825,19 @@ function setupLocationHandler() {
}
// Load the app page
-var appcontent = appcache.get('/app.html');
-contentdiv.innerHTML = appcontent;
+pagecomp.get('app.html', function(doc, e) {
+ log('page get');
+ if (isNil(doc)) {
+ log('exception getting app page', e);
+ return false;
+ }
+
+ // Set the app HTML page into the content div
+ contentdiv.innerHTML = doc;
-// Merge in the app data
-getpagedata();
+ // Merge in the app data
+ getpagedata();
+});
/**
* Document load post processing.
@@ -791,7 +858,7 @@ function onload() {
<div id="footdiv" class="fsection">
<script type="text/javascript">
(function() {
-$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig.js')));
+$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig-min.js')));
})();
</script>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/cache-manifest.cmf b/sca-cpp/trunk/modules/edit/htdocs/cache-manifest.cmf
index 4f3358edef..0be3e662d7 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/cache-manifest.cmf
+++ b/sca-cpp/trunk/modules/edit/htdocs/cache-manifest.cmf
@@ -9,7 +9,7 @@ CACHE MANIFEST
/notfound/
/notyet/
/oops/
-/public/iframe.html
+/public/iframe-min.html
/public/img.png
/public/touchicon.png
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
index 730506c9a1..3cc735971c 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
@@ -2092,7 +2092,7 @@ function showdata(gcomp) {
// Get the component result data
var comp = sca.component(gcomp.id, appname);
- comp.getnocache('', function(doc) {
+ comp.get('', function(doc) {
function displaydata(t, w) {
pdiv.style.width = w;
pdiv.innerHTML = t;
diff --git a/sca-cpp/trunk/modules/edit/htdocs/index.html b/sca-cpp/trunk/modules/edit/htdocs/index.html
index bba70baa61..869ae30628 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/index.html
@@ -77,7 +77,7 @@ appcache.get = function(uri) {
<div id="headdiv" class="hsection">
<script type="text/javascript">
(function() {
-$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig.js')));
+$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
})();
</script>
</div>
@@ -117,15 +117,15 @@ var appresources = [
['/account/', 'flip'],
['/clone/', 'flip'],
['/create/', 'flip'],
- ['/footconfig.js'],
+ ['/footconfig-min.js'],
['/graph/', 'flip'],
- ['/headconfig.js'],
+ ['/headconfig-min.js'],
['/home/', 'right'],
['/home/home.b64'],
['/page/', 'flip'],
['/public/app.b64'],
['/public/grid72.b64'],
- ['/public/iframe.html'],
+ ['/public/iframe-min.html'],
['/public/img.b64'],
['/public/user.b64'],
['/stats/', 'flip'],
@@ -427,7 +427,7 @@ function onload() {
<div id="footdiv" class="fsection">
<script type="text/javascript">
(function() {
-$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig.js')));
+$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig-min.js')));
})();
</script>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html b/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html
index 4b6eb7e3f0..4827238435 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html
@@ -76,7 +76,7 @@ appcache.get = function(uri) {
<div id="headdiv" class="hsection">
<script type="text/javascript">
(function() {
-$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig.js')));
+$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
})();
</script>
</div>
@@ -133,7 +133,7 @@ function onload() {
<div id="footdiv" class="fsection">
<script type="text/javascript">
(function() {
-$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig.js')));
+$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig-min.js')));
})();
</script>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html b/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html
index 4d11a1a7dc..743ae59a84 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html
@@ -76,7 +76,7 @@ appcache.get = function(uri) {
<div id="headdiv" class="hsection">
<script type="text/javascript">
(function() {
-$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig.js')));
+$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
})();
</script>
</div>
@@ -134,7 +134,7 @@ function onload() {
<div id="footdiv" class="fsection">
<script type="text/javascript">
(function() {
-$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig.js')));
+$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig-min.js')));
})();
</script>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html b/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html
index 2f9f7751d1..fba173f0d2 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html
@@ -76,7 +76,7 @@ appcache.get = function(uri) {
<div id="headdiv" class="hsection">
<script type="text/javascript">
(function() {
-$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig.js')));
+$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
})();
</script>
</div>
@@ -134,7 +134,7 @@ function onload() {
<div id="footdiv" class="fsection">
<script type="text/javascript">
(function() {
-$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig.js')));
+$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig-min.js')));
})();
</script>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/oops/index.html b/sca-cpp/trunk/modules/edit/htdocs/oops/index.html
index 70fe3994a2..1e9ea06687 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/oops/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/oops/index.html
@@ -76,7 +76,7 @@ appcache.get = function(uri) {
<div id="headdiv" class="hsection">
<script type="text/javascript">
(function() {
-$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig.js')));
+$('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
})();
</script>
</div>
@@ -133,7 +133,7 @@ function onload() {
<div id="footdiv" class="fsection">
<script type="text/javascript">
(function() {
-$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig.js')));
+$('footdiv').appendChild(ui.declareScript(appcache.get('/footconfig-min.js')));
})();
</script>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/page/index.html b/sca-cpp/trunk/modules/edit/htdocs/page/index.html
index dd33f34ac2..1b4c455ff7 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/page/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/page/index.html
@@ -75,7 +75,7 @@
</span>
<span class="link" id="palette:link" style="position: absolute; left: 0px; top: 340px;"><a href="/"><span>link</span></a></span>
<span class="text" id="palette:text" style="position: absolute; left: 0px; top: 370px;"><span>text</span></span>
-<span class="iframe fakeframe" id="palette:iframe" style="position: absolute; left: 0px; top: 400px; width: 200px;"><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: 400px; width: 200px;"><a href="/public/iframe-min.html"><span class="fakeframe"><span>frame ...</span></span></a></span>
<span class="img" id="palette:img" style="position: absolute; left: 0px; top: 430px;"><img id="imgimg"/></span>
</div>
@@ -555,7 +555,7 @@ page.settext = function(e, t) {
return t;
}
if (e.className == 'iframe') {
- car(childElements(e)).href = isNil(c)? '/public/iframe.html' : car(c);
+ car(childElements(e)).href = isNil(c)? '/public/iframe-min.html' : car(c);
return t;
}
return '';