Permalink
Browse files

html template and forms work

  • Loading branch information...
1 parent c9396b7 commit 56fc523d7c7411f37b0dd6b82fcc0a59caf03ce8 @thecolorblue committed Apr 23, 2011
Showing with 36 additions and 6 deletions.
  1. +1 −1 murray/ctypes/blogpost.js
  2. +21 −1 murray/index.js
  3. +8 −0 murray/setup.js
  4. +1 −0 murray/theme/template.html
  5. +5 −4 server.js
@@ -23,5 +23,5 @@ exports.View = '<div style="position:relative;" class="post"> \
</div>';
exports.Meta = {
title:'blogpost',
- engineer:'Brad Davis'
+ engineer:'Brad Davis,brad@braddavis.cc'
};
View
@@ -27,7 +27,12 @@ fs.readdir(pluginfolder,function(err,files){
}
}
});
-var htmlTemplate = '<!DOCTYPE html><html><head></head><body><: posts :><: sidbar :><: forms :></body></html>';
+
+var htmlTemplate = '';
+fs.readFile(__dirname + '/theme/template.html',encoding='utf8',function(err,data){
+ if(err) console.log(err);
+ htmlTemplate = data;
+});
var contenttype = {};
var ctype = {};
@@ -104,6 +109,21 @@ exports.getposts = function(req,res,options,callback){
});
}
};
+
+/*
+ * Get Form
+ *
+ */
+exports.getForm = function(res,options){
+ var forms = [];
+ var formType = options.ctype;
+ forms.forms = ctype[formType].form;
+ console.log(forms);
+ substitute(htmlTemplate,forms,function(html){
+ res.writeHead(200,{'Content-Type':'text/html'});
+ res.end(html);
+ });
+};
/*
* Create Post
* Looks for postcount for pid of new post
View
@@ -0,0 +1,8 @@
+
+if(process.argv[2] != undefined){
+ process.argv.forEach(function(val,index,array){
+ console.log(index + ':' + val);
+ });
+} else {
+ console.log('no arguments');
+}
@@ -0,0 +1 @@
+<!DOCTYPE html><html><head></head><body><: posts :><: sidbar :><: forms :></body></html>
View
@@ -13,6 +13,11 @@ app.get('/', function(req, res){
console.log(murray.ext);
murray.getposts(req,res);
});
+app.get('/new/:ctype', function(req,res){
+ var obj = {};
+ obj.ctype = req.params.ctype;
+ murray.getForm(res,obj);
+});
app.get('/:id/:value',function(req,res){
var obj = {};
obj[req.params.id] = req.params.value;
@@ -41,10 +46,6 @@ app.get('/admin/settings', function(req,res){
});
});
-app.get('/new', function(req,res){
- console.log(req);
- res.render('newpost.jade',{posts: '', logged: ''});
-});
app.post('/create/post', function(req, res){
murray.isIn(req.cookies,function(){
murray.createpost(req,res);

0 comments on commit 56fc523

Please sign in to comment.