From 59e7b3cb8d7eabfe9c6ea0bdfaaf1e1a0ae5e648 Mon Sep 17 00:00:00 2001 From: Dryusdan Date: Wed, 21 Jun 2017 00:39:50 +0200 Subject: [PATCH] Categories listing done --- .gitignore | 3 ++- app.js | 31 ++++++++++++++++++------------- classes/Categories.class.js | 20 +++++++++----------- classes/Template.class.js | 2 -- package-lock.json | 2 +- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index a6fac3f..9d73704 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules/ /nbproject/ -/rethink.sh \ No newline at end of file +/rethink.sh +/ressources/ \ No newline at end of file diff --git a/app.js b/app.js index 109c3f0..da63dd5 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,8 @@ const express = require('express'), cors = require("cors"), app = express(), log = require("color-logs")(true, true, "Dryusdan.fr"), + fs = require("fs"), + path = require('path'), hbs = require('hbs'); log.info("Application started and now preparing"); @@ -14,17 +16,14 @@ var corsOptions = { "preflightContinue": false }; -hbs.registerHelper('list', function(items, options) { - //console.log(items); +hbs.registerHelper('list', function(tabs, options) { + var out = ''; - var l=items.length; - for(var i=0; i fs.lstatSync(path.join(srcpath, file)).isDirectory()); + var listCtg = {}; + for(var x = 0; x < listDir.length; x++){ + var params = JSON.parse(fs.readFileSync(srcpath+'/'+listDir[x]+'/params.json', 'utf8')); + listCtg[x] = [{'title': params.title, 'slug': listDir[x]}] + } + callback(listCtg); } } diff --git a/classes/Template.class.js b/classes/Template.class.js index 032d9dc..2c7cbd1 100644 --- a/classes/Template.class.js +++ b/classes/Template.class.js @@ -6,8 +6,6 @@ const log = require('color-logs')(true, true, "Template.class.js"), var Categories = require('../classes/Categories.class.js'); class Template { - constructor(){ - } getNav(callback){ var categories = new Categories(); diff --git a/package-lock.json b/package-lock.json index 15134de..7e63068 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "blog", + "name": "nodezzarela", "version": "1.0.0", "lockfileVersion": 1, "dependencies": {