Browse Source

Created the template file for the pagination.

pull/60/head
jrtechs 5 years ago
parent
commit
cc01a851b9
4 changed files with 72 additions and 16 deletions
  1. +1
    -0
      includes/includes.js
  2. +6
    -0
      sites/blog.js
  3. +20
    -16
      templates/blog/blogMain.html
  4. +45
    -0
      templates/blog/paginationBar.html

+ 1
- 0
includes/includes.js View File

@ -142,6 +142,7 @@ module.exports =
}, },
fetchTemplate: function(templateName) fetchTemplate: function(templateName)
{ {
return utils.include("templates/" + templateName); return utils.include("templates/" + templateName);

+ 6
- 0
sites/blog.js View File

@ -9,6 +9,10 @@ const whiskers = require('whiskers');
const TEMPLATE_FILE="blog/blogMain.html"; const TEMPLATE_FILE="blog/blogMain.html";
const PAGINATION_TEMPLATE_KEY = "paginationTemplate";
const PAGINATION_TEMPLATE_FILE = "blog/paginationBar.html";
//caching program to make the application run faster //caching program to make the application run faster
const cache = require('memory-cache'); const cache = require('memory-cache');
@ -74,8 +78,10 @@ module.exports=
// cache is not tricked into storing same blog post a ton of times // cache is not tricked into storing same blog post a ton of times
} }
} }
var templateContext = Object(); var templateContext = Object();
Promise.all([includes.fetchTemplate(TEMPLATE_FILE), Promise.all([includes.fetchTemplate(TEMPLATE_FILE),
utils.includeInObject(PAGINATION_TEMPLATE_KEY, templateContext, "templates/" + PAGINATION_TEMPLATE_FILE),
includes.printHeader(templateContext), includes.printHeader(templateContext),
includes.printFooter(templateContext), includes.printFooter(templateContext),
require(file).main(filename, request, templateContext), require(file).main(filename, request, templateContext),

+ 20
- 16
templates/blog/blogMain.html View File

@ -32,23 +32,27 @@
<br><br> <br><br>
{/for} {/for}
<div class="row"> <div class="row">
<div class="col-6">
{if newPostsURL}
<button class="btn btn-secondary btn-l" onclick="location.href='{newPostsURL}'">
<b>Older Posts &raquo;</b>
</button>
{/if}
</div>
<div class="col-6">
{if oldPostsURL}
<span class="float-right">
<button class="btn btn-secondary btn-l" onclick="location.href='{oldPostsURL}'">
<b>Older Posts &raquo;</b>
</button>
</span>
{/if}
</div>
{>paginationTemplate}
<!--<div class="col-6">-->
<!--{if newPostsURL}-->
<!--<button class="btn btn-secondary btn-l" onclick="location.href='{newPostsURL}'">-->
<!--<b>Older Posts &raquo;</b>-->
<!--</button>-->
<!--{/if}-->
<!--</div>-->
<!--<div class="col-6">-->
<!--{if oldPostsURL}-->
<!--<span class="float-right">-->
<!--<button class="btn btn-secondary btn-l" onclick="location.href='{oldPostsURL}'">-->
<!--<b>Older Posts &raquo;</b>-->
<!--</button>-->
<!--</span>-->
<!--{/if}-->
<!--</div>-->
</div> </div>
<br> <br>
</div> </div>

+ 45
- 0
templates/blog/paginationBar.html View File

@ -0,0 +1,45 @@
<nav aria-label="...">
<ul class="pagination">
{if pagination.previous}
<li class="page-item">
<a class="page-link" href="{pagination.previous.url}">
Previous
</a>
</li>
{else}
<li class="page-item disabled">
<span class="page-link">
Previous
</span>
</li>
{/if}
{for page in pagination.pages}
<li class="page-item active">
{if page.isCurrent}
<span class="page-link">
{page.number}
<span class="sr-only">(current)</span>
</span>
{else}
<a class="page-link" href="{page.url}">
{page.number}
</a>
{/if}
</li>
{/for}
{if pagination.next}
<li class="page-item">
<a class="page-link" href="{pagination.next.url}">
Next
</a>
</li>
{else}
<li class="page-item disabled">
<span class="page-link">
Next
</span>
</li>
{/if}
</ul>
</nav>

Loading…
Cancel
Save