r9692 - in helma-ng/trunk/apps/googlestore: . skins
[email protected] Wed, 29 Apr 2009 19:31:23 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090429173123.A51C23D0D6@mia> |
Author: hannes
Date: 2009-04-29 19:31:23 +0200 (Wed, 29 Apr 2009)
New Revision: 9692
Modified:
helma-ng/trunk/apps/googlestore/main.js
helma-ng/trunk/apps/googlestore/skins/index.html
Log:
Add remove page with post confirmation form to stop googlebot from deleting my books.
Details at http://dev.helma.org/trac/helma/changeset/9692
Modified: helma-ng/trunk/apps/googlestore/main.js
===================================================================
--- helma-ng/trunk/apps/googlestore/main.js 2009-04-29 17:31:21 UTC (rev 9691)
+++ helma-ng/trunk/apps/googlestore/main.js 2009-04-29 17:31:23 UTC (rev 9692)
@@ -1,7 +1,7 @@
include('helma/webapp/response');
include('./model');
-export('index', 'edit');
+export('index', 'edit', 'remove');
// the main action is invoked for http://localhost:8080/
// this also shows simple skin rendering
@@ -9,9 +9,6 @@
if (req.params.save) {
return createBook(req);
}
- if (req.params.remove) {
- return removeBook(req);
- }
return SkinnedResponse(getResource('./skins/index.html'), {
title: 'Storage',
books: Book.all(),
@@ -36,6 +33,18 @@
})
}
+function remove(req, id) {
+ var book = Book.get(id);
+ if (req.params.remove && req.isPost) {
+ return removeBook(req, book);
+ }
+ return SkinnedResponse(getResource('./skins/remove.html'), {
+ title: 'Storage',
+ book: book,
+ action: req.path
+ })
+}
+
function createBook(req) {
var author = new Author({name: req.params.author});
author.save(); // no cascading save yet
@@ -44,10 +53,9 @@
return new RedirectResponse(req.path);
}
-function removeBook(req) {
- var book = Book.get(req.params.remove);
+function removeBook(req, book) {
// no cascading delete
book.author.remove();
book.remove();
- return new RedirectResponse(req.path);
+ return new RedirectResponse("../");
}
Modified: helma-ng/trunk/apps/googlestore/skins/index.html
===================================================================
--- helma-ng/trunk/apps/googlestore/skins/index.html 2009-04-29 17:31:21 UTC (rev 9691)
+++ helma-ng/trunk/apps/googlestore/skins/index.html 2009-04-29 17:31:23 UTC (rev 9692)
@@ -11,12 +11,14 @@
</form>
<h3>Available Books</h3>
-<p>
+<table cellspacing="0" cellpadding="3">
<% for book in <% books %> render book %>
-</p>
+</table>
<% subskin 'book' ----------------------------------- %>
-<div><% book.author.name %>: <% book.title %>
- <a href="edit/<% book.getId %>">[edit]</a>
- <a href="?remove=<% book.getId %>">[remove]</a>
-</div>
+<tr style="<% ifEven 'background-color: #eee;' %>">
+ <td><% book.author.name %></td>
+ <td><% book.title %></td>
+ <td><a href="edit/<% book.getId %>">[edit]</a></td>
+ <td><a href="remove/<% book.getId %>">[remove]</a></td>
+</tr>