Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work to hook up the admin

  • Loading branch information...
commit 96d0fa087220cc0f679e82ca61c18a0b6f45a768 1 parent ec575e2
@robrighter authored
Showing with 45 additions and 11 deletions.
  1. +2 −1  datastore.js
  2. +38 −7 index.js
  3. +5 −3 static/admin/views/edit.ejs
View
3  datastore.js
@@ -73,7 +73,8 @@
save: function(fn){
this.updated_at = new Date();
this.__super__(fn);
- }
+ },
+ getProperties: function(){return properties;}
},
(details.hasOwnProperty('methods')?details.methods:{}))
});
View
45 index.js
@@ -32,13 +32,12 @@
//main admin page loader route
server.get(new RegExp("^\/_admin\/([a-zA-Z0-9\-\/]*)$"), function(req,res,next){
findContentOrPassToNext(req.params[0], next, function(result){
- res.render(settings.AdminAssetsFilePath + '/views/edit.ejs', {
- layout: false,
- locals : {
- adminassets: settings.AdminAssetsWebPath,
- title: result.content.title,
- article: result.content.article
- }
+ prepareModelResultForAdmin(result, function(locals){
+ locals.adminassets = settings.AdminAssetsWebPath;
+ res.render(settings.AdminAssetsFilePath + '/views/edit.ejs', {
+ layout: false,
+ locals : locals
+ });
});
});
});
@@ -49,6 +48,38 @@
//admin update existing item route
}
+
+ function prepareModelResultForAdmin(result, callback){
+ var toreturn = {};
+ toreturn.content = result.content;
+ toreturn.location = result.location;
+ //get children from location
+ result.location.getChildren(function(children){
+ toreturn.children = children;
+ //run the preRenderingTasks if the model creator made them
+ if(result.content.hasOwnProperty('preRenderingTasks')){
+ result.content.preRenderingTasks(function(taskresults){
+ toreturn.prerendertasks = taskresults;
+ //setup form inputs
+ callback(prepareAdminInputs(toreturn,result.content.getProperties()));
+ });
+ }
+ else{
+ callback(toreturn);
+ }
+ });
+ }
+
+ function prepareModelResultForFrontEnd(result,callback){
+ //grab navigation lists
+
+ //preRenderingTasks
+ }
+
+ function prepareAdminInputs(info, contentproperties){
+ info.prerendertasks = [];
+ return info;
+ }
function findContentOrPassToNext(path, next, callback){
View
8 static/admin/views/edit.ejs
@@ -13,17 +13,19 @@
<div id="container">
<div id='closer'>X</div>
<div id="main">
- <h1><%= title %></h1>
+ <h1><%= content.title %></h1>
<h2>Folder</h2>
<div class='section'>
<form method="post" action="">
+ <% [1,2,3,4,5,6,7,8,9].forEach(function(item){ %>
<div class='inputgroup'>
<div class='label'>Title</div>
<input class="prop" type='text' name='thename' value='<%= title %>'/>
</div>
+ <%});%>
<div class='inputgroup'>
<div class='label'>Teaser</div>
- <textarea class="prop" name='thename' /></textarea>
+ <textarea class="prop" name='thename' /><%= content.teaser%></textarea>
</div>
<div class='inputgroup'>
<div class='label'>Photo</div>
@@ -31,7 +33,7 @@
</div>
<div class='inputgroup'>
<div class='label'>Article</div>
- <textarea class="prop" name='thename' value='<%= article %>'/></textarea>
+ <textarea class="prop" name='thename' /><%= content.article %></textarea>
</div>
<input class="cta" type="submit" value="Save" />
</form>
Please sign in to comment.
Something went wrong with that request. Please try again.