mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #495 from cobbspur/rename
rename helpers paginate -> pagination, dateFormat -> date
This commit is contained in:
commit
1d0c41d0e8
4 changed files with 12 additions and 12 deletions
|
@ -2,7 +2,7 @@
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
Handlebars.registerHelper('dateFormat', function (context, block) {
|
Handlebars.registerHelper('date', function (context, block) {
|
||||||
var f = block.hash.format || "MMM Do, YYYY",
|
var f = block.hash.format || "MMM Do, YYYY",
|
||||||
timeago = block.hash.timeago,
|
timeago = block.hash.timeago,
|
||||||
date;
|
date;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<section class="entry-meta">
|
<section class="entry-meta">
|
||||||
<time datetime="2013-01-04" class="date">
|
<time datetime="2013-01-04" class="date">
|
||||||
{{#if published}}
|
{{#if published}}
|
||||||
Published {{dateFormat published_at timeago="True"}}
|
Published {{date published_at timeago="True"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="status-draft">Draft</span>
|
<span class="status-draft">Draft</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -17,7 +17,7 @@ coreHelpers = function (ghost) {
|
||||||
* @param {*} options
|
* @param {*} options
|
||||||
* @return {Object} A Moment time / date object
|
* @return {Object} A Moment time / date object
|
||||||
*/
|
*/
|
||||||
ghost.registerThemeHelper('dateFormat', function (context, options) {
|
ghost.registerThemeHelper('date', function (context, options) {
|
||||||
var f = options.hash.format || "MMM Do, YYYY",
|
var f = options.hash.format || "MMM Do, YYYY",
|
||||||
timeago = options.hash.timeago,
|
timeago = options.hash.timeago,
|
||||||
date;
|
date;
|
||||||
|
@ -168,10 +168,10 @@ coreHelpers = function (ghost) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// ### Pagination Helper
|
// ### Pagination Helper
|
||||||
// `{{paginate}}`
|
// `{{pagination}}`
|
||||||
// Outputs previous and next buttons, along with info about the current page
|
// Outputs previous and next buttons, along with info about the current page
|
||||||
paginationHelper = ghost.loadTemplate('pagination').then(function (templateFn) {
|
paginationHelper = ghost.loadTemplate('pagination').then(function (templateFn) {
|
||||||
ghost.registerThemeHelper('paginate', function (options) {
|
ghost.registerThemeHelper('pagination', function (options) {
|
||||||
if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) {
|
if (!_.isObject(this.pagination) || _.isFunction(this.pagination)) {
|
||||||
errors.logAndThrowError('pagination data is not an object or is a function');
|
errors.logAndThrowError('pagination data is not an object or is a function');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -99,14 +99,14 @@ describe('Core Helpers', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Pagination helper", function () {
|
describe("Pagination helper", function () {
|
||||||
it('has loaded paginate helper', function () {
|
it('has loaded pagination helper', function () {
|
||||||
should.exist(handlebars.helpers.paginate);
|
should.exist(handlebars.helpers.pagination);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can render single page with no pagination necessary', function (done) {
|
it('can render single page with no pagination necessary', function (done) {
|
||||||
var rendered;
|
var rendered;
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.paginate.call({pagination: {page: 1, prev: undefined, next: undefined, limit: 15, total: 8, pages: 1}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 1, prev: undefined, next: undefined, limit: 15, total: 8, pages: 1}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 1<span class="extended"> of 1</span></div>\n \n</nav>');
|
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 1<span class="extended"> of 1</span></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
|
@ -116,7 +116,7 @@ describe('Core Helpers', function () {
|
||||||
it('can render first page of many with older posts link', function (done) {
|
it('can render first page of many with older posts link', function (done) {
|
||||||
var rendered;
|
var rendered;
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.paginate.call({pagination: {page: 1, prev: undefined, next: 2, limit: 15, total: 8, pages: 3}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 1, prev: undefined, next: 2, limit: 15, total: 8, pages: 3}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/2/">Older Posts →</a></div>\n \n <div class="page-number">Page 1<span class="extended"> of 3</span></div>\n \n</nav>');
|
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/2/">Older Posts →</a></div>\n \n <div class="page-number">Page 1<span class="extended"> of 3</span></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
|
@ -126,7 +126,7 @@ describe('Core Helpers', function () {
|
||||||
it('can render middle pages of many with older and newer posts link', function (done) {
|
it('can render middle pages of many with older and newer posts link', function (done) {
|
||||||
var rendered;
|
var rendered;
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.paginate.call({pagination: {page: 2, prev: 1, next: 3, limit: 15, total: 8, pages: 3}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 2, prev: 1, next: 3, limit: 15, total: 8, pages: 3}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/3/">Older Posts →</a></div>\n \n <div class="page-number">Page 2<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/1/">← Newer Posts</a></div>\n \n</nav>');
|
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="previous-page"><a href="/page/3/">Older Posts →</a></div>\n \n <div class="page-number">Page 2<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/1/">← Newer Posts</a></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
|
@ -136,7 +136,7 @@ describe('Core Helpers', function () {
|
||||||
it('can render last page of many with newer posts link', function (done) {
|
it('can render last page of many with newer posts link', function (done) {
|
||||||
var rendered;
|
var rendered;
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
rendered = handlebars.helpers.paginate.call({pagination: {page: 3, prev: 2, next: undefined, limit: 15, total: 8, pages: 3}});
|
rendered = handlebars.helpers.pagination.call({pagination: {page: 3, prev: 2, next: undefined, limit: 15, total: 8, pages: 3}});
|
||||||
should.exist(rendered);
|
should.exist(rendered);
|
||||||
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 3<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/2/">← Newer Posts</a></div>\n \n</nav>');
|
rendered.string.should.equal('\n<nav id="pagination" role="pagination">\n \n <div class="page-number">Page 3<span class="extended"> of 3</span></div>\n \n <div class="next-page"><a href="/page/2/">← Newer Posts</a></div>\n \n</nav>');
|
||||||
done();
|
done();
|
||||||
|
@ -147,7 +147,7 @@ describe('Core Helpers', function () {
|
||||||
helpers.loadCoreHelpers(ghost).then(function () {
|
helpers.loadCoreHelpers(ghost).then(function () {
|
||||||
var runErrorTest = function (data) {
|
var runErrorTest = function (data) {
|
||||||
return function () {
|
return function () {
|
||||||
handlebars.helpers.paginate.call(data);
|
handlebars.helpers.pagination.call(data);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue