summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/edit/htdocs
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-11-10 02:36:40 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-11-10 02:36:40 +0000
commit52cd682405f7a052d45d83b66cc75f19316ceffe (patch)
tree6b76eeddb2d4682db61f8e38462413bc40b59a3d /sca-cpp/trunk/modules/edit/htdocs
parent629c1f267e5f7a835891e36ebdae8404740f13e2 (diff)
Enable multiple apps to co-exist under different paths in a single Virtual Host and Internet domain.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1200105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf1
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/app/index.html59
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/clone/index.html20
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/create/index.html5
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/index.html20
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/notauth/index.html2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/notfound/index.html2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/notyet/index.html2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/oops/index.html2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/page/index.html14
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/stats/index.html15
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/store/index.html15
12 files changed, 59 insertions, 98 deletions
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 0be3e662d7..b478c7cd3d 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf
+++ b/sca-cpp/trunk/modules/edit/htdocs/app/cache-manifest.cmf
@@ -3,7 +3,6 @@ CACHE MANIFEST
# Version 5
# App resources
-/
/favicon.ico
/notauth/
/notfound/
diff --git a/sca-cpp/trunk/modules/edit/htdocs/app/index.html b/sca-cpp/trunk/modules/edit/htdocs/app/index.html
index 773d2adf90..97ea0a3f79 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/app/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/app/index.html
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
-->
-<html manifest="/cache-manifest.cmf">
+<html manifest="cache-manifest.cmf">
<head>
<title></title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
@@ -87,8 +87,13 @@ $('headdiv').appendChild(ui.declareScript(appcache.get('/headconfig-min.js')));
<script type="text/javascript">
-// Set the document title
-document.title = location.hostname.split('.')[0];
+/**
+ * Get the app name
+ */
+var appname = location.pathname.split('/')[1];
+
+// Set page title
+document.title = appname;
/**
* The main page div.
@@ -98,12 +103,13 @@ var contentdiv = $('content');
/**
* 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');
-var animationcomp = sca.httpclient('animation', '/animation');
-var locationcomp = sca.httpclient('location', '/location');
+var appWidget = sca.component('AppWidget');
+var pagecomp = sca.reference(appWidget, 'pages');
+var startcomp = sca.httpclient('start', '/' + appname + '/start');
+var stopcomp = sca.httpclient('stop', '/' + appname + '/stop');
+var timercomp = sca.httpclient('timer', '/' + appname + '/timer');
+var animationcomp = sca.httpclient('animation', '/' + appname + '/animation');
+var locationcomp = sca.httpclient('location', '/' + appname + '/location');
/**
* Pre-fetch app resources.
@@ -414,11 +420,11 @@ function docdata(doc) {
/**
* Bind a handler to a widget.
*/
-function bindwidgethandler(e) {
+function bindwidgethandler(e, appname) {
if (e.className == 'button') {
var b = car(childElements(e));
b.name = e.id;
- b.onclick = function() { return buttonClickHandler(b.value); };
+ b.onclick = function() { return buttonClickHandler(b.value, appname); };
return e;
}
if (e.className == 'link') {
@@ -427,7 +433,7 @@ function bindwidgethandler(e) {
if (hr.substring(0, 5) == 'link:' && hr.indexOf('://') == -1) {
var f = function(e) {
e.preventDefault();
- return buttonClickHandler(hr.substring(5));
+ return buttonClickHandler(hr.substring(5), appname);
};
l.ontouchstart = l.onclick = f;
l.href = 'javascript:void()';
@@ -528,7 +534,7 @@ function initwidget(e) {
/**
* Get app data from the main app page component.
*/
-function getpagedata() {
+function getpagedata(appname) {
try {
// Display component data on the page
@@ -552,7 +558,7 @@ function getpagedata() {
function setupwidget(e) {
initwidget(e);
fixupwidget(e);
- bindwidgethandler(e);
+ bindwidgethandler(e, appname);
}
// Setup the widgets
@@ -634,10 +640,10 @@ function compquery() {
/**
* Handle a button click event.
*/
-function buttonClickHandler(id) {
+function buttonClickHandler(id, appname) {
try {
var uri = compquery();
- return sca.component(id).get(uri, function(doc, e) {
+ return sca.component(id, appname).get(uri, function(doc, e) {
if (isNil(doc)) {
log('error on get(button, ' + uri + ')', e);
return false;
@@ -824,8 +830,21 @@ function setupLocationHandler() {
return true;
}
+/**
+ * Return the page in an ATOM entry.
+ */
+function atompage(doc) {
+ var entry = atom.readATOMEntry(mklist(doc));
+ if (isNil(entry))
+ return mklist();
+ var content = namedElementChild("'content", car(entry));
+ if (content == null)
+ return mklist();
+ return elementChildren(content);
+}
+
// Load the app page
-pagecomp.get('app.html', function(doc, e) {
+pagecomp.get(appname, function(doc, e) {
//log('page get');
if (isNil(doc)) {
log('error getting app page', e);
@@ -833,10 +852,12 @@ pagecomp.get('app.html', function(doc, e) {
}
// Set the app HTML page into the content div
- contentdiv.innerHTML = doc;
+ //log('page', doc);
+ var el = atompage(doc);
+ contentdiv.innerHTML = writeStrings(writeXML(el, false));
// Merge in the app data
- getpagedata();
+ getpagedata(appname);
});
/**
diff --git a/sca-cpp/trunk/modules/edit/htdocs/clone/index.html b/sca-cpp/trunk/modules/edit/htdocs/clone/index.html
index dd041e591e..3642634ed6 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/clone/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/clone/index.html
@@ -35,7 +35,7 @@
<form id="cloneAppForm">
<table style="width: 100%;">
<tr><td><b>New App Name:</b></td></tr>
-<tr><td><input type="text" id="appName" size="15" autocapitalize="off" placeholder="Your app name"/>&nbsp;<span id="appDomain"></span></td></tr>
+<tr><td><input type="text" id="appName" size="15" autocapitalize="off" placeholder="Your app name"/></td></tr>
<tr><tr><td style="padding-top: 6px;"><b>App Icon:</b></td></tr>
<tr><td><img id="appimg" style="width: 50px; height: 50px; vertical-align: top;"></td></tr>
<tr><tr><td style="padding-top: 6px;"><b>Sharing:</b></td></tr>
@@ -56,23 +56,10 @@
// Get the app name
var appname = ui.fragmentParams(location)['app'];
-/**
- * Return the link to an app.
- */
-function applink(appname) {
- var protocol = location.protocol;
- var host = location.hostname;
- var port = ':' + location.port;
- if (port == ':80' || port == ':443' || port == ':')
- port = '';
- var link = protocol + '//' + appname + '.' + host + port + '/';
- return link;
-}
-
// Set page titles
var tclone = isNil(config.clone)? 'Clone' : config.clone;
document.title = ui.windowtitle(location.hostname) + ' - ' + tclone + ' - ' + appname;
-$('appNameHeader').innerHTML = '<a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
+$('appNameHeader').innerHTML = '<a href=\"/' + appname + '/\" target=\"' + '_blank' + '\">' + appname + '</a>';
$('th').innerHTML = tclone + ' this App';
$('cloneAppOKButton').value = tclone;
$('cloneAppOKButton').title = tclone + ' this app';
@@ -80,9 +67,6 @@ $('cloneAppOKButton').title = tclone + ' this app';
// Set images
$('appimg').src = ui.b64img(appcache.get('/public/app.b64'));
-// Init form
-$('appDomain').innerHTML = '.' + location.hostname;
-
// Init service references
var editWidget = sca.component("EditWidget");
var dashboards = sca.reference(editWidget, "dashboards");
diff --git a/sca-cpp/trunk/modules/edit/htdocs/create/index.html b/sca-cpp/trunk/modules/edit/htdocs/create/index.html
index c74c00950d..6097053cd6 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/create/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/create/index.html
@@ -35,7 +35,7 @@
<form id="createAppForm">
<table style="width: 100%;">
<tr><td><b>App Name:</b></td></tr>
-<tr><td><input type="text" id="appName" size="15" autocapitalize="off" placeholder="Your app name"/>&nbsp;<span id="appDomain"></span></td></tr>
+<tr><td><input type="text" id="appName" size="15" autocapitalize="off" placeholder="Your app name"/></td></tr>
<tr><tr><td style="padding-top: 6px;"><b>App Icon:</b></td></tr>
<tr><td><img id="appimg" style="width: 50px; height: 50px; vertical-align: top;"></td></tr>
<tr><tr><td style="padding-top: 6px;"><b>Sharing:</b></td></tr>
@@ -60,9 +60,6 @@ $('h1').innerHTML = ui.hometitle(location.hostname);
// Set images
$('appimg').src = ui.b64img(appcache.get('/public/app.b64'));
-// Init form
-$('appDomain').innerHTML = '.' + location.hostname;
-
// Init service references
var editWidget = sca.component("EditWidget");
var dashboards = sca.reference(editWidget, "dashboards");
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
index 77fa1d4888..1732590079 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
@@ -68,22 +68,9 @@ if (isNil(appname)) {
ispalette = true;
}
-/**
- * Return the link to an app.
- */
-function applink(appname) {
- var protocol = location.protocol;
- var host = location.hostname;
- var port = ':' + location.port;
- if (port == ':80' || port == ':443' || port == ':')
- port = '';
- var link = protocol + '//' + appname + '.' + host + port + '/';
- return link;
-}
-
// Set page titles
document.title = ui.windowtitle(location.hostname) + ' - ' + (isNil(config.compose)? 'Composition' : config.compose) + ' - ' + appname;
-$('appNameHeader').innerHTML = '<a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
+$('appNameHeader').innerHTML = '<a href=\"/' + appname + '/\" target=\"' + '_blank' + '\">' + appname + '</a>';
/**
* Component value field, add, delete and play buttons.
@@ -2060,7 +2047,7 @@ function complink(appname, cname) {
var port = ':' + location.port;
if (port == ':80' || port == ':443' || port == ':')
port = '';
- var link = protocol + '//' + appname + '.' + host + port + '/c/' + cname;
+ var link = protocol + '//' + host + port + '/' + appname + '/c/' + cname;
return link;
}
@@ -2090,8 +2077,7 @@ function showdata(gcomp) {
return true;
if (isNil(gcomp))
return true;
- var clink = complink(appname, gcomp.id);
- cvalue.value = clink;
+ cvalue.value = complink(appname, gcomp.id);
cplay.innerHTML = '&lt;';
gvisible = false;
pdiv.innerHTML = '';
diff --git a/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html b/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html
index 4665e9f571..b44ccb26e9 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/notauth/index.html
@@ -113,7 +113,7 @@ function showmenu(mdiv) {
mklist(ui.menu('Account', '/#view=account', '_view', false), ui.menu('Sign out', '/logout/', '_self', false)));
}
-showmenu($('menu'));
+showmenu(mdiv);
cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
/**
diff --git a/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html b/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html
index 8601fbfea6..6b3bb09824 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/notfound/index.html
@@ -115,7 +115,7 @@ function showmenu(mdiv) {
}
showmenu(mdiv);
-div.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
+cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
/**
* Handle orientation change.
diff --git a/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html b/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html
index 60c774d8ea..d01e535299 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/notyet/index.html
@@ -114,7 +114,7 @@ function showmenu(mdiv) {
mklist(ui.menu('Account', '/#view=account', '_view', false), ui.menu('Sign out', '/logout/', '_self', false)));
}
-showmenu($('menu'));
+showmenu(mdiv);
cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
/**
diff --git a/sca-cpp/trunk/modules/edit/htdocs/oops/index.html b/sca-cpp/trunk/modules/edit/htdocs/oops/index.html
index 67408d8d62..aeb5ae5d2c 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/oops/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/oops/index.html
@@ -113,7 +113,7 @@ function showmenu(mdiv) {
mklist(ui.menu('Account', '/#view=account', '_view', false), ui.menu('Sign out', '/logout/', '_self', false)));
}
-showmenu($('menu'));
+showmenu(mdiv);
cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
/**
diff --git a/sca-cpp/trunk/modules/edit/htdocs/page/index.html b/sca-cpp/trunk/modules/edit/htdocs/page/index.html
index 7df8a1a1d9..9482cb4e32 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/page/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/page/index.html
@@ -100,13 +100,13 @@ function applink(appname) {
var port = ':' + location.port;
if (port == ':80' || port == ':443' || port == ':')
port = '';
- var link = protocol + '//' + appname + '.' + host + port + '/';
+ var link = protocol + '//' + host + port + '/' + appname + '/';
return link;
}
// Set page titles
document.title = ui.windowtitle(location.hostname) + ' - Page - ' + appname;
-$('appNameHeader').innerHTML = '<a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
+$('appNameHeader').innerHTML = '<a href=\"/' + appname + '/\" target=\"' + '_blank' + '\">' + appname + '</a>';
/**
* Page editor area, widget value field, add, delete and play page buttons.
@@ -149,8 +149,8 @@ resizeFields();
window.onresize = resizeFields;
// Init component references
-var editWidget = sca.component("EditWidget");
-var pages = sca.reference(editWidget, "pages");
+var editWidget = sca.component('EditWidget');
+var pages = sca.reference(editWidget, 'pages');
/**
* Page editing functions.
@@ -763,7 +763,7 @@ function getpage(name, ediv) {
if (isNil(el))
buffer.innerHTML = '<div id="page"></div>';
else
- buffer.innerHTML = writeStrings(writeXML(atompage(doc), false));
+ buffer.innerHTML = writeStrings(writeXML(el, false));
// Remove any existing page nodes from the editor div
var fnodes = filter(function(e) {
@@ -941,8 +941,8 @@ function playpage() {
evisible = false;
pdiv.style.visibility = 'visible';
pdiv.innerHTML = '';
- pdiv.innerHTML = '<iframe id="playappframe" style="position: relative; height: 5000px; width: 2500px; border: 0px;" scrolling="no" frameborder="0" src="' +
- applink(appname) + '"></iframe>';
+ pdiv.innerHTML = '<iframe id="playappframe" style="position: relative; height: 5000px; width: 2500px; border: 0px;" scrolling="no" frameborder="0" src="/' +
+ appname + '"></iframe>';
setTimeout(function() {
ediv.style.visibility = 'hidden'
}, 0);
diff --git a/sca-cpp/trunk/modules/edit/htdocs/stats/index.html b/sca-cpp/trunk/modules/edit/htdocs/stats/index.html
index f049bea8a5..81f06c95e4 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/stats/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/stats/index.html
@@ -56,22 +56,9 @@
// Get the app name
var appname = ui.fragmentParams(location)['app'];
-/**
- * Return the link to an app.
- */
-function applink(appname) {
- var protocol = location.protocol;
- var host = location.hostname;
- var port = ':' + location.port;
- if (port == ':80' || port == ':443' || port == ':')
- port = '';
- var link = protocol + '//' + appname + '.' + host + port + '/';
- return link;
-}
-
// Set page titles
document.title = ui.windowtitle(location.hostname) + ' - Stats - ' + appname;
-$('appNameHeader').innerHTML = '<a href=\"' + applink(appname) + '\" target=\"' + '_blank' + '\">' + appname + '</a>';
+$('appNameHeader').innerHTML = '<a href=\"/' + appname + '/\" target=\"' + '_blank' + '\">' + appname + '</a>';
var tclone = isNil(config.clone)? 'Clone' : config.clone;
$('cloneApp').value = tclone;
$('cloneApp').title = tclone + ' this app';
diff --git a/sca-cpp/trunk/modules/edit/htdocs/store/index.html b/sca-cpp/trunk/modules/edit/htdocs/store/index.html
index e82d675f22..bcb3ba7c85 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/store/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/store/index.html
@@ -78,19 +78,6 @@ var store = sca.reference(editWidget, "store");
var dashboards = sca.reference(editWidget, "dashboards");
/**
- * Return the link to an app.
- */
-function applink(appname) {
- var protocol = location.protocol;
- var host = location.hostname;
- var port = ':' + location.port;
- if (port == ':80' || port == ':443' || port == ':')
- port = '';
- var link = protocol + '//' + appname + '.' + host + port + '/';
- return link;
-}
-
-/**
* Edit an app.
*/
function editApp(appname) {
@@ -151,7 +138,7 @@ function getapps(category) {
apps += '<div>' + ui.ahref('/#view=stats&app=' + name, '_view', '<img src="' + appimg + '" width="50" height="50" style="height: 50px; width: 50px; vertical-align: top; margin: 0px; padding: 0px;"></img>') + '</div>';
apps += '</td>';
apps += '<td class="tdw">';
- apps += '<div style="font-weight: bold">' + ui.ahref(applink(name), '_blank', name) + '</div>';
+ apps += '<div style="font-weight: bold">' + ui.ahref('/' + name + '/', '_blank', name) + '</div>';
if (category == 'myapps')
apps += '<div style="color: #808080;">Shared</div>';
else