Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added content pages in the admin and route on the frontend. Gravatar …

…option in preferences. Added helper library file.
  • Loading branch information...
commit 74b6cae0b14af6dcd393c742fcbbed728f5c5063 1 parent 443d6c6
@astalker authored
View
27 lib/helper.js
@@ -0,0 +1,27 @@
+var db = require('./mongoose')
+ , Crypto = require('crypto');
+
+exports.md5 = function(str, callback){
+ var hash = Crypto.createHash('md5');
+ hash.update(str, 'utf-8');
+ callback(hash.digest('hex'));
+}
+
+exports.gravatar = function(email, callback){
+ exports.md5(email, function(hash){
+ callback('http://www.gravatar.com/avatar/' + hash + '?s=40');
+ });
+};
+
+exports.prefs = function(params, callback){
+ db.projectPreferences(params, function(err, prefs){
+ if (prefs.gravatar){
+ exports.gravatar(prefs.email, function(g){
+ prefs.gravatar_url = g;
+ });
+ } else {
+ prefs.gravatar_url = '';
+ }
+ callback(prefs);
+ });
+}
View
121 lib/mongoose.js
@@ -23,18 +23,32 @@ var ArticleSchema = new Schema({
});
var PrefsSchema = new Schema({
name: String,
- items: Number,
+ email: String,
+ items: Number,
description : String,
- keywords: String
+ keywords: String,
+ gravatar: Boolean
+});
+var PagesSchema = new Schema({
+ ts : { type: Date, default: Date.now },
+ page : String,
+ content: String,
+ description : String,
+ keywords : String,
+ alias : String
});
-mongoose.model('Article', ArticleSchema);
-var Article = mongoose.model('Article');
+mongoose.model('Articles', ArticleSchema);
+var Article = mongoose.model('Articles');
mongoose.model('Prefs', PrefsSchema);
var Prefs = mongoose.model('Prefs');
+mongoose.model('Pages', PagesSchema);
+var Pages = mongoose.model('Pages');
+
exports.emptyArticle = { "_id": "", title: "", article: "", alias: "", description: "", keywords: "" };
+exports.emptyPage = { "_id": "", page: "", content: "", alias: "", description: "", keywords: "" };
exports.add = function(title, ts, article, description, keywords, alias, callback) {
var newArticle = new Article();
@@ -57,6 +71,27 @@ exports.add = function(title, ts, article, description, keywords, alias, callbac
callback(null);
});
}
+exports.addpage = function(page, ts, content, description, keywords, alias, callback) {
+ var newPage = new Pages();
+ newPage.page = page;
+ if (ts !== '') {
+ var date_fields = ts.split("/");
+ newPage.ts = new Date(date_fields[2], date_fields[0]-1, date_fields[1]);
+ } else {
+ newPage.ts = new Date();
+ }
+ newPage.content = content;
+ newPage.description = description;
+ newPage.keywords = keywords;
+ newPage.alias = alias;
+ newPage.save(function(err) {
+ if (err) {
+ util.log('FATAL '+ err);
+ callback(err);
+ } else
+ callback(null);
+ });
+}
exports.delete = function(id, callback) {
exports.findArticleById(id, function(err, doc) {
@@ -69,6 +104,17 @@ exports.delete = function(id, callback) {
}
});
}
+exports.deletePage = function(id, callback) {
+ exports.findPageById(id, function(err, doc) {
+ if (err)
+ callback(err);
+ else {
+ util.log(util.inspect(doc));
+ doc.remove();
+ callback(null);
+ }
+ });
+}
exports.countArticles = function(callback) {
Article.count({}, function(err, doc) {
@@ -107,9 +153,46 @@ exports.edit = function(id, title, ts, article, description, keywords, alias, ca
});
}
+exports.editpage = function(id, page, ts, content, description, keywords, alias, callback) {
+ exports.findPageById(id, function(err, doc) {
+ if (err)
+ callback(err);
+ else {
+ if (ts !== undefined) {
+ var date_fields = ts.split("/");
+ doc.ts = new Date(date_fields[2], date_fields[0]-1, date_fields[1]);
+ } else {
+ doc.ts = new Date();
+ }
+ doc.page = page;
+ doc.content = content;
+ doc.description = description;
+ doc.keywords = keywords;
+ doc.alias = alias;
+ doc.save(function(err) {
+ if (err) {
+ util.log('FATAL '+ err);
+ callback(err);
+ } else
+ callback(null);
+ });
+ }
+ });
+}
+
+exports.allArticlesPages = function(num, callback) {
+ exports.allArticles(num, function(err, articles){
+ exports.allPages(num, function(err, pages){
+ callback(err, articles, pages);
+ })
+ });
+}
exports.allArticles = function(num, callback) {
Article.find({}).limit(num).sort("-ts").execFind(callback);
}
+exports.allPages = function(num, callback) {
+ Pages.find({}).limit(num).sort("-ts").execFind(callback);
+}
exports.allArticlesPaged = function(num, page, callback) {
var skip = 0;
if (page > 0){
@@ -138,24 +221,26 @@ exports.projectPreferences = function(params, callback){
callback(err, null);
}
if (doc===null){
- doc = { name: params.config.project, items: params.config.per_page, description: "", keywords: "" };
+ doc = { name: params.config.project, email: "", items: params.config.per_page, description: "", keywords: "" };
}
callback(null, doc);
});
}
-exports.save = function(name, items, description, keywords, callback) {
+exports.save = function(name, email, items, description, keywords, gravatar, callback) {
Prefs.findOne({ }, function(err, doc) {
if (err) {
util.log('FATAL '+ err);
callback(err);
} else {
if (doc===null){
- exports.newPref(name, items, description, keywords, callback);
+ exports.newPref(name, email, items, description, keywords, gravatar, callback);
} else {
doc.name = name;
+ doc.email = email;
doc.items = items;
doc.description = description;
doc.keywords = keywords;
+ doc.gravatar = gravatar;
doc.save(function(err) {
if (err) {
util.log('FATAL '+ err);
@@ -168,12 +253,14 @@ exports.save = function(name, items, description, keywords, callback) {
});
}
-exports.newPref = function(name, items, description, keywords, callback) {
+exports.newPref = function(name, email, items, description, keywords, callback) {
var newPrefs = new Prefs();
newPrefs.name = name;
+ newPrefs.email = email;
newPrefs.items = items;
newPrefs.description = description;
newPrefs.keywords = keywords;
+ newPrefs.gravatar = gravatar;
newPrefs.save(function(err) {
if (err) {
util.log('FATAL '+ err);
@@ -192,6 +279,24 @@ var findArticleById = exports.findArticleById = function(id, callback) {
callback(null, doc);
});
}
+var findPageById = exports.findPageById = function(id, callback) {
+ Pages.findOne({ _id: id }, function(err, doc) {
+ if (err) {
+ util.log('FATAL '+ err);
+ callback(err, null);
+ }
+ callback(null, doc);
+ });
+}
+var findPageByAlias = exports.findPageByAlias = function(alias, callback) {
+ Pages.findOne({ alias: alias }, function(err, doc) {
+ if (err) {
+ util.log('FATAL '+ err);
+ callback(err, null);
+ }
+ callback(null, doc);
+ });
+}
var findArticleByDate = exports.findArticleByDate = function(year, month, day, title, callback) {
var start = new Date(year, month-1, day); //months are 0 based so Jan equals 0
var end = new Date(year, month-1, day);
View
281 lib/nblog.js
@@ -3,6 +3,7 @@ var db = require('./mongoose')
, moment = require('moment')
, Crypto = require('crypto')
, querystring = require('querystring')
+ , helper = require('./helper')
;
var username, password, params, next;
@@ -44,7 +45,7 @@ exports.index = function(req, res){
exports.nextArticles(req, res, 1, function(n){
next=n;
});
- db.projectPreferences(params, function(err, prefs){
+ helper.prefs(params, function(prefs){
db.allArticles(prefs.items, function(err, articles) {
if (err) {
util.log('ERROR ' + err);
@@ -59,6 +60,7 @@ exports.index = function(req, res){
prev: 0,
next: next,
params: params,
+ prefs: prefs,
loggedin: exports.checkLoggedIn(req, res)
});
});
@@ -69,7 +71,7 @@ exports.page = function(req, res){
exports.nextArticles(req, res, req.params.p, function(n){
next=n;
});
- db.projectPreferences(params, function(err, prefs){
+ helper.prefs(params, function(prefs){
db.allArticlesPaged(prefs.items, req.params.p, function(err, articles) {
if (err) {
util.log('ERROR ' + err);
@@ -84,6 +86,7 @@ exports.page = function(req, res){
prev: parseInt(req.params.p) -1,
next: next,
params: params,
+ prefs: prefs,
loggedin: exports.checkLoggedIn(req, res)
});
}
@@ -91,31 +94,58 @@ exports.page = function(req, res){
});
};
+exports.content = function(req, res){
+ helper.prefs(params, function(prefs){
+ db.findPageByAlias(
+ req.params.c,
+ function(error, content) {
+ if (error) throw error;
+ res.render('content', {
+ title: prefs.name,
+ description: content.description,
+ keywords: content.keywords,
+ postpath: '/edit',
+ content: content,
+ moment: moment,
+ params: params,
+ prefs: prefs,
+ loggedin: exports.checkLoggedIn(req, res)
+ });
+ });
+ });
+};
+
exports.articles = function(req, res){
- db.allArticles(100000, function(err, articles) {
- if (err) {
- util.log('ERROR ' + err);
- throw err;
- } else
- res.render('articles', {
- title: "Articles",
- articles: articles,
- moment: moment,
- count: 1,
- querystring: querystring,
- description: "Articles",
- keywords: "Articles",
- params: params,
- loggedin: exports.checkLoggedIn(req, res)
+ helper.prefs(params, function(prefs){
+ db.allArticles(100000, function(err, articles) {
+ if (err) {
+ util.log('ERROR ' + err);
+ throw err;
+ } else
+ res.render('articles', {
+ title: "Articles",
+ articles: articles,
+ moment: moment,
+ count: 1,
+ querystring: querystring,
+ description: "Articles",
+ keywords: "Articles",
+ params: params,
+ prefs: prefs,
+ loggedin: exports.checkLoggedIn(req, res)
+ });
});
});
};
exports.login = function(req, res){
- res.render('login', { title: 'Login',
- description: "Login",
- keywords: "",
- params: params,
- loggedin: false
+ helper.prefs(params, function(prefs){
+ res.render('login', { title: 'Login',
+ description: "Login",
+ keywords: "",
+ params: params,
+ prefs: prefs,
+ loggedin: false
+ });
});
};
exports.loginpost = function(req, res){
@@ -129,15 +159,18 @@ exports.logout = function(req, res){
res.redirect('/');
};
exports.add = function(req, res){
- res.render('edit', { title: 'Add',
- postpath: '/add',
- moment: moment,
- ts: '',
- item: db.emptyArticle, // blank item so the template works
- description: "",
- keywords: "",
- params: params,
- loggedin: true
+ helper.prefs(params, function(prefs){
+ res.render('edit', { title: 'Add',
+ postpath: '/add',
+ moment: moment,
+ ts: '',
+ item: db.emptyArticle, // blank item so the template works
+ description: "",
+ keywords: "",
+ params: params,
+ prefs: prefs,
+ loggedin: true
+ });
});
};
exports.addpost = function(req, res){
@@ -159,61 +192,107 @@ exports.addpost = function(req, res){
res.redirect('/admin?add=1');
});
};
+exports.addpage = function(req, res){
+ helper.prefs(params, function(prefs){
+ res.render('edit-page', { title: 'Add',
+ postpath: '/add-page',
+ ts: '',
+ item: db.emptyPage, // blank item so the template works
+ description: "",
+ keywords: "",
+ params: params,
+ prefs: prefs,
+ loggedin: true
+ });
+ });
+};
+exports.addpagepost = function(req, res){
+ if (req.body.page=='')
+ throw error;
+ db.addpage(
+ req.body.page,
+ req.body.ts,
+ req.body.content,
+ req.body.description,
+ req.body.keywords,
+ req.body.alias,
+ function(error) {
+ if (error) throw error;
+ res.redirect('/admin?addp=1');
+ });
+};
exports.admin = function(req, res){
- db.allArticles(100000, function(err, articles) {
- if (err) {
- util.log('ERROR ' + err);
- throw err;
- } else
- {
- var msg = null;
- if (req.query["edit"])
- msg = 'Article updated';
- else if (req.query["add"])
- msg = 'Article added';
- else if (req.query["pref"])
- msg = 'Settings saved';
- else if (req.query["del"])
- msg = 'Article deleted';
-
- var del_id = null;
- if (req.query["confirm"])
- del_id = req.query["confirm"];
+ helper.prefs(params, function(prefs){
+ db.allArticlesPages(100000, function(err, articles, pages) {
+ if (err) {
+ util.log('ERROR ' + err);
+ throw err;
+ } else
+ {
+ var msg = null;
+ if (req.query["edit"])
+ msg = 'Article updated';
+ else if (req.query["add"])
+ msg = 'Article added';
+ else if (req.query["pref"])
+ msg = 'Settings saved';
+ else if (req.query["del"])
+ msg = 'Article deleted';
+ else if (req.query["addp"])
+ msg = 'Page added';
+ else if (req.query["editp"])
+ msg = 'Page updated';
+ else if (req.query["del-page"])
+ msg = 'Page deleted';
+
+ var del_id = null;
+ if (req.query["confirm"])
+ del_id = req.query["confirm"];
+ var del_page_id = null;
+ if (req.query["confirm-page"])
+ del_page_id = req.query["confirm-page"];
- res.render('admin', {
- title: "Admin",
- articles: articles,
+ res.render('admin', {
+ title: "Admin",
+ articles: articles,
+ pages: pages,
+ moment: moment,
+ description: "",
+ keywords: "",
+ params: params,
+ prefs: prefs,
+ loggedin: true,
+ flash: msg,
+ delete_notice: del_id,
+ delete_page_notice: del_page_id
+ });
+ }
+ });
+ });
+};
+
+exports.edit = function(req, res){
+ helper.prefs(params, function(prefs){
+ db.findArticleById(req.query["id"], function(error, article) {
+ if (error) throw error;
+ res.render('edit', {
+ title: "Edit",
+ postpath: '/edit',
+ item: article,
+ ts: moment(new Date(article.ts)).format("MM/DD/YYYY"),
moment: moment,
description: "",
keywords: "",
params: params,
- loggedin: true,
- flash: msg,
- delete_notice: del_id
+ prefs: prefs,
+ loggedin: true
});
- }
- });
-};
-
-exports.edit = function(req, res){
- db.findArticleById(req.query["id"], function(error, article) {
- if (error) throw error;
- res.render('edit', {
- title: "Edit",
- postpath: '/edit',
- item: article,
- ts: moment(new Date(article.ts)).format("MM/DD/YYYY"),
- moment: moment,
- description: "",
- keywords: "",
- params: params,
- loggedin: true
});
});
};
exports.article = function(req, res){
- db.projectPreferences(params, function(err, prefs){
+ helper.prefs(params, function(prefs){
db.findArticleByDate(
req.params.year,
req.params.month,
@@ -229,6 +308,7 @@ exports.article = function(req, res){
article: article,
moment: moment,
params: params,
+ prefs: prefs,
loggedin: exports.checkLoggedIn(req, res)
});
});
@@ -260,6 +340,17 @@ exports.delconfirm = function(req, res){
res.redirect('/admin?del=1');
});
};
+exports.delpage = function(req, res){
+ res.redirect('/admin?confirm-page='+req.query["id"]);
+};
+
+exports.delpageconfirm = function(req, res){
+ db.deletePage(req.query["id"],
+ function(error) {
+ if (error) throw error;
+ res.redirect('/admin?del-page=1');
+ });
+};
nextArticles = exports.nextArticles = function(req, res, page, callback) {
db.countArticles(function (err, num){
@@ -272,12 +363,13 @@ nextArticles = exports.nextArticles = function(req, res, page, callback) {
}
exports.preferences = function(req, res){
- db.projectPreferences(params, function(err, prefs){
+ helper.prefs(params, function(prefs){
res.render('preferences', {
title: 'Preferences',
project: prefs,
description: '',
keywords: '',
+ prefs: prefs,
loggedin: true
});
})
@@ -286,11 +378,48 @@ exports.preferences = function(req, res){
exports.save = function(req, res) {
db.save(
req.body.name,
+ req.body.email,
req.body.items,
req.body.description,
req.body.keywords,
+ req.body.gravatar,
function(error) {
if (error) throw error;
res.redirect('/admin?pref=1');
});
-};
+};
+
+exports.editpage = function(req, res){
+ helper.prefs(params, function(prefs){
+ db.findPageById(req.query["id"], function(error, page) {
+ if (error) throw error;
+ res.render('edit-page', {
+ title: "Edit",
+ postpath: '/edit-page',
+ item: page,
+ ts: moment(new Date(page.ts)).format("MM/DD/YYYY"),
+ moment: moment,
+ description: "",
+ keywords: "",
+ params: params,
+ prefs: prefs,
+ loggedin: true
+ });
+ });
+ });
+};
+exports.editpagepost = function(req, res) {
+ db.editpage(
+ req.body.id,
+ req.body.page,
+ req.body.ts,
+ req.body.content,
+ req.body.description,
+ req.body.keywords,
+ req.body.alias,
+ function(error) {
+ if (error) throw error;
+ res.redirect('/admin?editp=1');
+ });
+};
+
View
39 lib/routes.js
@@ -1,20 +1,27 @@
module.exports = function(app, nblog)
{
- app.get('/', nblog.index);
- app.get('/admin', nblog.checkAccess, nblog.admin);
- app.get('/login', nblog.login);
- app.post('/login', nblog.loginpost);
- app.get('/logout', nblog.checkAccess, nblog.logout);
- app.get('/:year/:month/:day/:title', nblog.article);
- app.get('/articles', nblog.articles);
- app.get('/add', nblog.checkAccess, nblog.add);
- app.post('/add', nblog.checkAccess, nblog.addpost);
- app.get('/edit', nblog.checkAccess, nblog.edit);
- app.post('/edit', nblog.checkAccess, nblog.editpost);
- app.get('/del', nblog.checkAccess, nblog.del);
- app.get('/delconfirm', nblog.checkAccess, nblog.delconfirm);
- app.get('/page/:p', nblog.page);
- app.get('/preferences', nblog.checkAccess, nblog.preferences);
- app.post('/save', nblog.checkAccess, nblog.save);
+ app.get('/', nblog.index);
+ app.get('/admin', nblog.checkAccess, nblog.admin);
+ app.get('/login', nblog.login);
+ app.post('/login', nblog.loginpost);
+ app.get('/logout', nblog.checkAccess, nblog.logout);
+ app.get('/:year/:month/:day/:title', nblog.article);
+ app.get('/articles', nblog.articles);
+ app.get('/add', nblog.checkAccess, nblog.add);
+ app.post('/add', nblog.checkAccess, nblog.addpost);
+ app.get('/add-page', nblog.checkAccess, nblog.addpage);
+ app.post('/add-page', nblog.checkAccess, nblog.addpagepost);
+ app.get('/edit', nblog.checkAccess, nblog.edit);
+ app.post('/edit', nblog.checkAccess, nblog.editpost);
+ app.get('/edit-page', nblog.checkAccess, nblog.editpage);
+ app.post('/edit-page', nblog.checkAccess, nblog.editpagepost);
+ app.get('/del', nblog.checkAccess, nblog.del);
+ app.get('/delconfirm', nblog.checkAccess, nblog.delconfirm);
+ app.get('/del-page', nblog.checkAccess, nblog.delpage);
+ app.get('/del-page-confirm', nblog.checkAccess, nblog.delpageconfirm);
+ app.get('/page/:p', nblog.page);
+ app.get('/content/:c', nblog.content);
+ app.get('/preferences', nblog.checkAccess, nblog.preferences);
+ app.post('/save', nblog.checkAccess, nblog.save);
}
View
4 public/stylesheets/styles.css
@@ -35,3 +35,7 @@ body {
margin-bottom: 15px;
padding: 7px 9px;
}
+.gravatar {
+ float: left;
+ margin: 5px 10px 0 0;
+}
View
37 views/admin.ejs
@@ -7,7 +7,7 @@
<% } %>
<% if (delete_notice){ %>
<div class="alert">
- <strong>Warning</strong> are you sure you want to delete this Article?.
+ <strong>Warning</strong> are you sure you want to delete this Article?
<a href="/admin" class="btn">No</a>
<form method="GET" action="/delconfirm" class="edit_form" style="display:inline;margin:0 10px">
<input type="submit" value="Delete" class="btn btn-danger" />
@@ -15,11 +15,46 @@
</form>
</div>
<% } %>
+<% if (delete_page_notice){ %>
+ <div class="alert">
+ <strong>Warning</strong> are you sure you want to delete this Page?
+ <a href="/admin" class="btn">No</a>
+ <form method="GET" action="/del-page-confirm" class="edit_form" style="display:inline;margin:0 10px">
+ <input type="submit" value="Delete" class="btn btn-danger" />
+ <input type="hidden" name="id" value="<%= delete_page_notice %>">
+ </form>
+ </div>
+<% } %>
<h4>Preferences</h4>
<div class="btn-group">
<a class="btn" href="/preferences">Edit Preferences</a>
<a class="btn" href="/add">New Article</a>
+ <a class="btn" href="/add-page">New Page</a>
</div>
+
+<h4>Existing pages</h4>
+<table class="table table-hover">
+ <tbody>
+ <% pages.forEach(function(page) { %>
+ <tr>
+ <td><%= page.page %></td>
+ <td><%= moment(new Date(page.ts)).format("Do MMM YYYY") %></td>
+ <td>
+ <div class="btn-group">
+ <form method="GET" action="/edit-page" class="edit_form" style="display:inline">
+ <input type="submit" value="Edit" class="btn" />
+ <input type="hidden" name="id" value="<%= page._id %>" class="btn">
+ </form>
+ <form method="GET" action="/del-page" class="edit_form" style="display:inline;margin:0 10px">
+ <input type="submit" value="Delete" class="btn btn-danger" />
+ <input type="hidden" name="id" value="<%= page._id %>">
+ </form>
+ </div>
+ </td>
+ </tr>
+ <% }); %>
+ </tbody>
+</table>
<h4>Existing articles</h4>
<table class="table table-hover">
<tbody>
View
9 views/content.ejs
@@ -0,0 +1,9 @@
+<% include head %>
+
+ <article>
+ <h2><%= content.page %></h2>
+ <h5><%= moment(new Date(content.ts)).format("Do MMM YYYY") %></h5>
+ <p><%- content.content %></p>
+ </article>
+
+<% include foot %>
View
32 views/edit-page.ejs
@@ -0,0 +1,32 @@
+<% include head %>
+
+ <script>
+ $(function() {
+ $("#datepicker").datepicker();
+ });
+ $(document).ready(function(){
+ $('#articleForm').submit(function() {
+ return $(this).validate();
+ });
+ });
+ </script>
+
+<form method="POST" action="<%= postpath %>" id="articleForm">
+ <% if (item) { %><input type="hidden" name="id" value="<%= item._id %>"><% } %>
+ <label>Title</label>
+ <input type="text" name="page" value="<%= item.page %>" data-validation="required" />
+ <label>Date</label>
+ <input type="text" name="ts" value="<%= ts %>" data-validation="required" id="datepicker" />
+ <label>Alias</label>
+ <input type="text" name="alias" value="<%= item.alias %>" class="input" id="alias" />
+ <label>Content</label>
+ <textarea rows="3" cols="40" name="content"><%= item.content %></textarea>
+ <label>Description</label>
+ <textarea rows="3" cols="40" name="description" data-validation="required"><%= item.description %></textarea>
+ <label>Keywords</label>
+ <textarea rows="3" cols="40" name="keywords"><%= item.keywords %></textarea>
+ <label></label>
+ <input type="submit" value="Submit" class="btn" />
+</form>
+
+<% include foot %>
View
2  views/foot.ejs
@@ -1,6 +1,6 @@
<hr>
- <p>&copy;<%= params.config.copyrightyear %> <%= params.config.project %></p>
+ <p>&copy;<%= params.config.copyrightyear %> <%= prefs.name %></p>
</div>
</body>
View
37 views/head.ejs
@@ -18,22 +18,27 @@
</head>
<body>
- <div class="container-narrow">
+ <div class="container-narrow">
- <div class="masthead">
- <ul class="nav nav-pills pull-right">
- <li<% if (title==='Home'){ %> class="active"<% } %>><a href="/">Home</a></li>
- <li<% if (title==='Articles'){ %> class="active"<% } %>><a href="/articles">Articles</a></li>
- <% if (loggedin){ %>
- <li<% if (title==='Admin' || title==='Edit' || title==='Preferences'){ %> class="active"<% } %>><a href='/admin'>Admin</a></li>
- <li><a href='/logout'>Logout</a></li>
- <% } else { %>
- <li><a href='/login'>Login</a></li>
- <% } %>
- </ul>
- <h3 class="muted"><%= title %></h3>
- </div>
+ <div class="masthead">
+ <ul class="nav nav-pills pull-right">
+ <li<% if (title==='Home'){ %> class="active"<% } %>><a href="/">Home</a></li>
+ <li<% if (title==='Articles'){ %> class="active"<% } %>><a href="/articles">Articles</a></li>
+ <% if (loggedin){ %>
+ <li<% if (title==='Admin' || title==='Edit' || title==='Preferences'){ %> class="active"<% } %>><a href='/admin'>Admin</a></li>
+ <li><a href='/logout'>Logout</a></li>
+ <% } else { %>
+ <li><a href='/login'>Login</a></li>
+ <% } %>
+ </ul>
+ <% if (prefs.gravatar_url!=''){ %>
+ <div class="gravatar">
+ <img src="<%= prefs.gravatar_url %>" />
+ </div>
+ <% } %>
+ <h3 class="muted"><%= title %></h3>
+ </div>
- <hr>
+ <hr>
- <div class="row-fluid">
+ <div class="row-fluid">
View
4 views/preferences.ejs
@@ -11,12 +11,16 @@
<form method="POST" action="/save" id="articleForm">
<label for="name">Site Name</label>
<input type="text" name="name" value="<%= project.name %>" class="input" id="project-name" data-validation="required" />
+ <label for="email">Email address</label>
+ <input type="text" name="email" value="<%= project.email %>" class="input" id="project-email" />
<label for="items">Articles per page</label>
<input type="text" name="items" value="<%= project.items %>" class="input" id="project-items" data-validation="required" />
<label for="description">Meta Description</label>
<textarea rows="3" cols="60" name="description" data-validation="required"><%= project.description %></textarea>
<label for="keywords">Meta Keywords</label>
<textarea rows="3" cols="60" name="keywords"><%= project.keywords %></textarea>
+ <label for="gravatar">Display Gravatar</label>
+ <input type="checkbox" name="gravatar" value="1"<% if (project.gravatar){ %> checked="checked"<% } %>/>
<label for="submit"></label>
<input name="submit" type="submit" value="Submit" class="btn btn-primary" />
</form>
Please sign in to comment.
Something went wrong with that request. Please try again.