summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/edit
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-01-18 09:07:34 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-01-18 09:07:34 +0000
commit98a6c203285b86758f333b8dcff69f78e53e7f74 (patch)
tree84d966ffd9b7bf8967dbcfbb9d0940693c541151 /sca-cpp/trunk/modules/edit
parentcff1c7648d6041e15cf53741b742cb6d01427419 (diff)
Fix XML serialization issues with XHTML docs and add ability to save widgets.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1060250 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/edit')
-rw-r--r--sca-cpp/trunk/modules/edit/apps.py6
-rw-r--r--sca-cpp/trunk/modules/edit/apps/store/app.html2
-rw-r--r--sca-cpp/trunk/modules/edit/apps/store2/app.html2
-rw-r--r--sca-cpp/trunk/modules/edit/apps/store3/app.html2
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html43
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/graph.html4
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/page/page.html62
-rw-r--r--sca-cpp/trunk/modules/edit/pages.py7
-rwxr-xr-xsca-cpp/trunk/modules/edit/start2
9 files changed, 97 insertions, 33 deletions
diff --git a/sca-cpp/trunk/modules/edit/apps.py b/sca-cpp/trunk/modules/edit/apps.py
index 61cdfe07ef..fa3307bfca 100644
--- a/sca-cpp/trunk/modules/edit/apps.py
+++ b/sca-cpp/trunk/modules/edit/apps.py
@@ -27,12 +27,14 @@ def appid(id):
# Post a new app to the apps db
def post(collection, app, cache):
id = appid((str(uuid.uuid1()),))
- cache.put((id,), app)
+ comp = caddr(app)
+ cache.put((id,), comp)
return id
# Put an app into the apps db
def put(id, app, cache):
- cache.put(appid(id), app)
+ comp = caddr(app)
+ cache.put(appid(id), comp)
return True
# Get an app from the apps db
diff --git a/sca-cpp/trunk/modules/edit/apps/store/app.html b/sca-cpp/trunk/modules/edit/apps/store/app.html
index 542023613a..ba64d84958 100644
--- a/sca-cpp/trunk/modules/edit/apps/store/app.html
+++ b/sca-cpp/trunk/modules/edit/apps/store/app.html
@@ -27,6 +27,6 @@
<span id="checkout" style="position:absolute; left: 0px; top: 340px"><input type="button" value="Checkout"/></span>
<span id="empty" style="position:absolute; left: 120px; top: 340px"><input type="button" value="Empty"/></span>
-<span id="feed" style="position:absolute; left: 240px; top: 340px"><a href="shoppingCart/">(feed)</a></span>
+<span id="feed" style="position:absolute; left: 240px; top: 340px"><a href="shoppingCart/"><span>(feed)</span></a></span>
</div>
diff --git a/sca-cpp/trunk/modules/edit/apps/store2/app.html b/sca-cpp/trunk/modules/edit/apps/store2/app.html
index 542023613a..ba64d84958 100644
--- a/sca-cpp/trunk/modules/edit/apps/store2/app.html
+++ b/sca-cpp/trunk/modules/edit/apps/store2/app.html
@@ -27,6 +27,6 @@
<span id="checkout" style="position:absolute; left: 0px; top: 340px"><input type="button" value="Checkout"/></span>
<span id="empty" style="position:absolute; left: 120px; top: 340px"><input type="button" value="Empty"/></span>
-<span id="feed" style="position:absolute; left: 240px; top: 340px"><a href="shoppingCart/">(feed)</a></span>
+<span id="feed" style="position:absolute; left: 240px; top: 340px"><a href="shoppingCart/"><span>(feed)</span></a></span>
</div>
diff --git a/sca-cpp/trunk/modules/edit/apps/store3/app.html b/sca-cpp/trunk/modules/edit/apps/store3/app.html
index 542023613a..ba64d84958 100644
--- a/sca-cpp/trunk/modules/edit/apps/store3/app.html
+++ b/sca-cpp/trunk/modules/edit/apps/store3/app.html
@@ -27,6 +27,6 @@
<span id="checkout" style="position:absolute; left: 0px; top: 340px"><input type="button" value="Checkout"/></span>
<span id="empty" style="position:absolute; left: 120px; top: 340px"><input type="button" value="Empty"/></span>
-<span id="feed" style="position:absolute; left: 240px; top: 340px"><a href="shoppingCart/">(feed)</a></span>
+<span id="feed" style="position:absolute; left: 240px; top: 340px"><a href="shoppingCart/"><span>(feed)</span></a></span>
</div>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html b/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html
index b45c0ffe24..71f9c61c41 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/dash/dashboard.html
@@ -33,22 +33,25 @@
<form id="appsForm">
<div id="apps"></div>
<br/>
-&gt;<a href="" id="addAppLink">Add</a>&nbsp;<a href="" id="deleteAppLink">Delete</a>
+<input type="button" id="createAppButton" value="Create App"/>
</form>
<div id="newApp" style="visibility: hidden;">
<form id="newAppForm">
<table width="100%">
-<tr><th>Add a New App</th></tr>
-<tr><td>Add a new App to your dashboard.</td></tr>
+<tr><th>Create an App</th></tr>
+<tr><td></td></tr>
</table>
<br>
<table width="100%">
-<tr><td>App name:</td><td><input type="text" id="appName" size="10"/></td></tr>
-<tr><td>Title:</td><td><input type="text" id="appTitle" size="20"/></td></tr>
+<tr><td><b>App Name:</b></td></tr>
+<tr><td><input type="text" id="appName" size="10"/></td></tr>
+<tr><tr><td><b>App Title:</b></td></tr>
+<tr><td><input type="text" id="appTitle" size="20"/></td></tr>
</table>
-<input id="addAppButton" type="button" value="Add"/>
+<input id="createAppOKButton" type="button" style="font-weight: bold;" value="Create"/>
+<input id="createAppCancelButton" type="button" value="Cancel"/>
</form>
</div>
@@ -100,31 +103,46 @@ function getapps(sync) {
}
/**
- * Toggle new app form link event.
+ * Display create app form.
*/
-$('addAppLink').onclick = function() {
+$('createAppButton').onclick = function() {
var div = $('newApp');
- div.style.visibility = div.style.visibility == 'hidden'? 'visible' : 'hidden';
+ div.style.visibility = 'visible';
$('appName').focus();
return false;
};
/**
- * Add a new app button event.
+ * Create an app.
*/
-$('addAppButton').onclick = function() {
+$('createAppOKButton').onclick = function() {
var name = $('appName').value;
var title = $('appTitle').value;
var app = mklist(title, name, mklist());
var entry = atom.writeATOMEntry(app);
dashboard.put(name, car(entry));
+ $('appName').value = '';
+ $('appTitle').title = '';
getapps();
+ div.style.visibility = 'visible';
return false;
};
/**
- * Delete apps event.
+ * Cancel creating an app.
*/
+$('createAppCancelButton').onclick = function() {
+ var div = $('newApp');
+ div.style.visibility = 'hidden';
+ $('appName').value = '';
+ $('appTitle').title = '';
+ return false;
+};
+
+/**
+ * Delete an app.
+ */
+/*
$('deleteAppLink').onclick = function() {
var apps = $('appsForm').apps;
if (isNil(apps))
@@ -140,6 +158,7 @@ $('deleteAppLink').onclick = function() {
getapps();
return false;
};
+*/
// Get and display the list of apps
getapps(true);
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
index fd9ae694a7..5eb8c6cc1e 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
@@ -31,7 +31,7 @@
<body>
<table style="position: absolute; top: 0px; left: 0px;" width="100%">
-<tr><th style="width: 338px;">Palette</th><th>App</th></tr>
+<tr><th style="width: 338px;">Palette</th><th style="padding-top: 0px; padding-bottom: 0px;"><span>App</span><span style="position: absolute; top: 2px; right: 8px;"><input type="button" id="saveButton" style="font-weight: bold;" Value="Save"/></span></th></tr>
</table>
<script type="text/javascript">
@@ -40,7 +40,7 @@ var palettes = sca.reference(editWidget, "palettes");
var apps = sca.reference(editWidget, "apps");
// Setup remote log
-rconsole = sca.defun(sca.reference(editWidget, "log"), "log");
+//rconsole = sca.defun(sca.reference(editWidget, "log"), "log");
/**
* Return the current app name.
diff --git a/sca-cpp/trunk/modules/edit/htdocs/page/page.html b/sca-cpp/trunk/modules/edit/htdocs/page/page.html
index 0e0441b4c0..e2cd50088e 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/page/page.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/page/page.html
@@ -31,7 +31,7 @@
<body>
<table style="position: absolute; top: 0px; left: 0px;" width="100%">
-<tr><th style="width: 338px;">Palette</th><th>Page</th></tr>
+<tr><th style="width: 338px;">Palette</th><th style="padding-top: 0px; padding-bottom: 0px;"><span>Page</span><span style="position: absolute; top: 2px; right: 8px;"><input type="button" id="saveButton" style="font-weight: bold;" Value="Save"/></span></th></tr>
</table>
<div id="page" style="position: absolute; top: 60px; left: 0px; width: 5000px; height: 5000px;">
@@ -41,9 +41,9 @@
<span id="palette:button" style="position: absolute; left: 0px; top: 80px;"><input type="button" value="button"/></span>
<span id="palette:entry" style="position: absolute; left: 0px; top: 120px;"><input type="text" value="field" size="5"/></span>
<span id="palette:password" style="position: absolute; left: 0px; top: 160px;"><input type="password" value="password" size="5"/></span>
-<span id="palette:checkbox" style="position: absolute; left: 0px; top: 200px;"><input type="checkbox" value="checkbox"/>checkbox</span>
+<span id="palette:checkbox" style="position: absolute; left: 0px; top: 200px;"><input type="checkbox" value="checkbox"></input><span>checkbox</span></span>
<span id="palette:select" style="position: absolute; left: 0px; top: 240px;"><select><option value="list">list</option></select></span>
-<span id="palette:link" style="position: absolute; left: 0px; top: 280px;"><a href="">link</a></span>
+<span id="palette:link" style="position: absolute; left: 0px; top: 280px;"><a href="/"><span>link</span></a></span>
<span id="palette:text" style="position: absolute; left: 0px; top: 320px;"><span>text</span></span>
<span id="palette:img" style="position: absolute; left: 0px; top: 360px;"><img/></span>
@@ -75,32 +75,72 @@ function atompage(doc) {
/**
* Get and display an app page.
*/
-function getpage(name, e) {
+function getpage(name, edit) {
if (isNil(name))
return;
pages.get(name, function(doc) {
- // Convert the page to XML
- var x = writeStrings(writeXML(atompage(doc), false));
+ // Convert the page to XHTML
+ var xhtml = writeStrings(writeXML(atompage(doc), false));
// Prepare page DOM in hidden buffer
var buffer = $('buffer');
- buffer.innerHTML = x;
+ buffer.innerHTML = xhtml;
// Append page nodes to editor
map(function(e) {
e.style.left = ui.posn(e.style.left) + 350;
- pageedit.appendChild(e);
+ edit.appendChild(e);
return page.cover(e);
}, nodeList(buffer.childNodes[0].childNodes));
});
}
+/**
+ * Save the current edited page.
+ */
+$('saveButton').onclick = function(e) {
+ // Copy page DOM to hidden buffer
+ var edit = $('page');
+ var buffer = $('buffer');
+ buffer.innerHTML = '<div id="page"></div>'
+ var div = buffer.childNodes[0];
+ div.innerHTML = edit.innerHTML;
+
+ // Remove nodes from palette and editor artifacts, which are
+ // not part of the page, as well as nodes positioned out of
+ // the editing area
+ map(function(e) {
+ if (isNil(e.id) || e.id == '' || e.id.substr(0, 8) == 'palette:') {
+ div.removeChild(e);
+ return e;
+ }
+ var x = ui.posn(e.style.left) - 350;
+ if (x < 0 || ui.posn(e.style.top) < 0) {
+ div.removeChild(e);
+ return e;
+ }
+ e.style.left = x;
+ return e;
+ }, nodeList(div.childNodes));
+
+ // Convert the page to XHTML
+ var lxhtml = readXHTMLElement(div);
+ var xhtml = writeStrings(writeXML(lxhtml, false));
+
+ // Update the page ATOM entry
+ var name = appname();
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">' + name + '</title><id>' + name + '</id><content type="application/xml"><item>' +
+ xhtml + '</item></content></entry>';
+
+ pages.put(name, entry, function(e) {});
+};
+
// Initialize the page editor
-var pageedit = $('page');
-page.initpage(pageedit);
+var edit = $('page');
+page.initpage(edit);
// Get and display the current app page
-getpage(appname(), pageedit);
+getpage(appname(), edit);
</script>
</body>
diff --git a/sca-cpp/trunk/modules/edit/pages.py b/sca-cpp/trunk/modules/edit/pages.py
index 1e81a67332..e96e503730 100644
--- a/sca-cpp/trunk/modules/edit/pages.py
+++ b/sca-cpp/trunk/modules/edit/pages.py
@@ -18,6 +18,7 @@
# App pages collection implementation
import uuid
import sys
+from sys import stderr
from util import *
# Convert an id to an app id
@@ -27,12 +28,14 @@ def appid(id):
# Post a new app page to the apps db
def post(collection, app, cache):
id = appid((str(uuid.uuid1()),))
- cache.put((id,), app)
+ xhtml = caddr(app);
+ cache.put((id,), xhtml)
return id
# Put an app page into the apps db
def put(id, app, cache):
- cache.put(appid(id), app)
+ xhtml = caddr(app);
+ cache.put(appid(id), xhtml)
return True
# Get an app page from the apps db
diff --git a/sca-cpp/trunk/modules/edit/start b/sca-cpp/trunk/modules/edit/start
index fe5d039a4b..7750571423 100755
--- a/sca-cpp/trunk/modules/edit/start
+++ b/sca-cpp/trunk/modules/edit/start
@@ -17,7 +17,7 @@
# specific language governing permissions and limitations
# under the License.
-../http/httpd-conf tmp 10.1.1.62 8090 htdocs
+../http/httpd-conf tmp localhost 8090 htdocs
../server/server-conf tmp
../python/python-conf tmp
cat >>tmp/conf/httpd.conf <<EOF