Skip to content

Commit

Permalink
New template variables for first and last page on index pages
Browse files Browse the repository at this point in the history
  • Loading branch information
fboes committed Sep 29, 2017
1 parent ecebb91 commit 3e5856d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Change log

For detailed information check [Blogophon's releases on Github](https://github.com/fboes/blogophon/releases).

* [x] New template variables for first and last page on index pages
* [x] Switched to `8fold-marked`
* [x] Removed AMP pages from sitemap as of https://twitter.com/JohnMu/status/786588362706673664
* [x] Adding INI syntax highlighting
Expand Down
2 changes: 1 addition & 1 deletion htdocs/themes/default/templates/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>{{#i18n}}All tags{{/i18n}}</h2>
<nav>
<ul>
{{#index}}
<li><a rel="tag" href="{{url}}" title="{{#i18n}}More articles with &bdquo;{{title}}&rdquo;{{/i18n}}">{{title}}</a></li>
<li><a href="{{url}}" title="{{#i18n}}More articles with &bdquo;{{title}}&rdquo;{{/i18n}}">{{title}}</a></li>
{{/index}}
</ul>
</nav>
Expand Down
6 changes: 4 additions & 2 deletions src/blogophon-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,14 @@ var blogophonIndex = function() {
curPage = Math.round(curPage);
maxPage = Math.round(maxPage);
return {
firstUrl: (maxPage > 1) ? external.getPageName(0, maxPage, reverse, path) : null,
prevUrl: external.getPageName(curPage-1, maxPage, reverse, path),
currentUrl: external.getPageName(curPage, maxPage, reverse, path),
nextUrl: external.getPageName(curPage+1, maxPage, reverse, path),
prevUrl: external.getPageName(curPage-1, maxPage, reverse, path),
lastUrl: external.getPageName(maxPage - 1, maxPage, reverse, path),
currentPage: (curPage+1),
nextPage: ((curPage+2 < maxPage) ? curPage+2 : null),
prevPage: ((curPage > 0) ? curPage : null),
nextPage: ((curPage+2 < maxPage) ? curPage+2 : null),
maxPages: maxPage
};
};
Expand Down
4 changes: 4 additions & 0 deletions src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,21 @@ var Generator = function(config) {
absoluteUrl: curUrlObj.absoluteUrl(),
absoluteUrlDirname: curUrlObj.absoluteUrlDirname()
};
curPageObj.firstUrl = indexUrl(curPageObj.firstUrl).relativeUrl();
curPageObj.prevUrl = indexUrl(curPageObj.prevUrl).relativeUrl();
curPageObj.nextUrl = indexUrl(curPageObj.nextUrl).relativeUrl();
curPageObj.lastUrl = indexUrl(curPageObj.lastUrl).relativeUrl();
if (config.specialFeatures.acceleratedmobilepages) {
curPageObj.meta.AbsoluteUrlAmp = curUrlObj.absoluteUrl('amp');
}
promises.push(fs.writeFileAsync(indexUrl(curPageObj.currentUrl).filename(), Mustache.renderExtra(Mustache.themeTemplates.indexHtml, curPageObj, Mustache.themePartials)));

if (config.specialFeatures.acceleratedmobilepages) {
curPageObj.ampCss = Mustache.ampCss;
curPageObj.firstUrl = indexUrl(curPageObj.firstUrl).relativeUrl('amp');
curPageObj.prevUrl = indexUrl(curPageObj.prevUrl).relativeUrl('amp');
curPageObj.nextUrl = indexUrl(curPageObj.nextUrl).relativeUrl('amp');
curPageObj.lastUrl = indexUrl(curPageObj.lastUrl).relativeUrl('amp');
curPageObj.consolidatedProperties = ampify.getConsolidatedProperties(curPageObj.index);

promises.push(fs.writeFileAsync(
Expand Down
5 changes: 1 addition & 4 deletions test/blogophon-index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict';

exports.testGeneralFunctionality = function(test) {
//test.expect(2);
test.expect(1);

var index = require('../src/blogophon-index');

test.ok(index(), 'Index does compile');

//test.throws(function() {translations('xx');}, Error);
//test.throws(function() {translations('de').getString('xx');}, Error);

test.done();
};

0 comments on commit 3e5856d

Please sign in to comment.