Skip to content
Browse files

New config show_author & enable pagination.

show_author determines if the author should be displayed in the article
title.  It is disabled by default.

Fixes issue #5
  • Loading branch information...
1 parent ccdcc76 commit 5d56f0122062b4884818c1985e2a932ad9c67d6e Guy Halford-Thompson committed
Showing with 12 additions and 7 deletions.
  1. +1 −0 README.md
  2. +2 −1 glog_config.sample.json
  3. +9 −6 lib/glog.js
View
1 README.md
@@ -90,6 +90,7 @@ These options should be placed in glog_cofig.json and should be valid JSON
base_url - (Optional) Base URL for the blog. Defaults to '/'
cache_time - (Optional) Time in seconds to cache each page
article_per_page - (Optional) Number of articles to display on a page. Defaults to 10
+ show_author - (Optional) Display the author name in the article title. Defaults to false
# Running the tests
View
3 glog_config.sample.json
@@ -5,5 +5,6 @@
"port" : 8080,
"base_url" : "",
"cache_time" : 28800,
- "articles_per_page" : 10
+ "articles_per_page" : 10,
+ "show_author" : false
}
View
15 lib/glog.js
@@ -29,7 +29,8 @@ Glog.prototype.load_configs = function(cb) {
// Set defaults
var options = {
blog_title : 'Glog Blog',
- articles_per_page : 10
+ articles_per_page : 10,
+ show_author : false
},
fn = this,
key;
@@ -174,14 +175,15 @@ Glog.prototype.render_blog = function(options, articles, cb) {
for(i = 0; i < len; i++) {
start = (per_page * i);
- end = articles.length < (per_page * (i + 1)) - 1 ? articles.length : (per_page * (i + 1));
+ end = articles.length < (per_page * (i + 1)) ? articles.length : (per_page * (i + 1));
fn.pages['_page' + (i+1)] = ja({
- 'title' : options.blog_title,
+ 'title' : options.blog_title,
'analytics_code' : options.analytics_code || null,
- 'base_url' : options.base_url || '',
- 'articles' : articles.slice(start, end),
- 'page_num' : end === articles.length ? -1 : (i+1) // If we are on the last page, pass -1 so we know there are no more pages
+ 'base_url' : options.base_url || '',
+ 'show_author' : options.show_author,
+ 'articles' : articles.slice(start, end),
+ 'page_num' : end === articles.length ? -1 : (i+1) // If we are on the last page, pass -1 so we know there are no more pages
});
// pages[/] === pages[_page1]
@@ -199,6 +201,7 @@ Glog.prototype.render_blog = function(options, articles, cb) {
'disqus_id' : options.disqus_id || -1,
'analytics_code' : options.analytics_code || null,
'base_url' : options.base_url || '',
+ 'show_author' : options.show_author,
'single' : true
});
}

0 comments on commit 5d56f01

Please sign in to comment.
Something went wrong with that request. Please try again.