diff --git a/app.js b/app.js
index f30756b..41dbe33 100644
--- a/app.js
+++ b/app.js
@@ -2,11 +2,9 @@ const express = require('express'),
cors = require("cors"),
app = express(),
helmet = require('helmet'),
- log = require("color-logs")(true, true, "Dryusdan.fr"),
+ log = require("color-logs")(true, true, "Nodezzarella app"),
fs = require("fs"),
- path = require('path'),
- promise = require('promise'),
- hbs = require('hbs');
+ promise = require('promise');
log.info("Application started and now preparing");
@@ -17,125 +15,61 @@ var corsOptions = {
"preflightContinue": false
};
-/**
- * Create menu html
- */
-const config = require("./config.json");
+global.config = require("./config.json");
+
+class Nodezzarella {
+ constructor(rootPath){
+ this.getDBType().then((configDB) => {
+ if(!configDB.flatFile){
+ var db = require('./lib/db/'+config.db+'/db');
+ new db().connectDB(configDB).then((connexion) => {
+ global.dbConnexion = connexion;
+ this.run();
+ });
+ }
+ else{
+ this.run();
+ }
+ }).catch((err) => {
+ console.log(err);
+ new Error("Nodezzarella can't initialize");
+ });
+ }
+
+ getDBType(){
+ return new Promise((resolve, reject) => {
+ fs.access("./lib/db/"+config.db+"/config.json", fs.constants.F_OK || fs.constants.R_OK, (error) => {
+ if(error){
+ reject(new Error("File not exist"));
+ }
+ else{
+ resolve(require("./lib/db/"+config.db+"/config.json"));
+ }
+ });
+ });
+ }
+
+ run(){
+ var routes = require("./lib/router");
+ log.info("HTTP server listening on port", config.appPort);
+ log.info("Application ready");
+ app.use(config.webroot || "/", routes);
+ app.use(function(req, res, next) {
+ res.status(404);
+ res.send({"data":{
+ code: 404,
+ error : 'Not Found'
+ }});
+ return;
+ });
-class App {
- constructor(rootPath, port){
-
/**
* Listen to http://0.0.0.0:port
*/
app.disable('x-powered-by');
- app.listen(port || 8888);
-
- useDB().then((configDB) => {
- if(!configDB.flatFile){
-
- }
- }).catch(() => {
-
- });
-
- /*log.info("HTTP server listening on port", port);
- log.info("Application ready");
- var template = new Template();
-
- app.get("/", function(req, res){
- var categories = new Categories();
- Promise.all([
- template.getNav(),
- categories.getHome(),
- categories.getDisclaimer()
- ]).then(data => {
- var nav = data[0];
- var content = data[1];
- var disclaimer = data[2];
- res.setHeader("Content-type", "text/html");
- var tplData = {
- "blogName": config.blogName,
- "title": config.homeTitle,
- "nav": nav,
- "content": content,
- "disclaimer": disclaimer
- };
- res.render('template.hbs', tplData);
- }).catch(err => {
- res.setHeader("Content-type", "text/plain");
-
- res.end("erreur");
- });
-
-
- });
- app.get("/:slug", function(req, res){
- var categories = new Categories();
- Promise.all([
- template.getNav(),
- categories.getListArticles(req.params.slug),
- categories.getCategorie(req.params.slug)
- ]).then(data => {
- var nav = data[0];
- var content = data[1];
- var dataCategories = data[2];
- res.setHeader("Content-type", "text/html");
- var tplData = {
- "blogName": config.blogName,
- "title": dataCategories.title+" - "+ config.blogName,
- "nav": nav,
- "content": content,
- "disclaimer": ''
- };
- res.render('template.hbs', tplData);
- }).catch(err => {
- res.setHeader("Content-type", "text/plain");
-
- res.end("erreur");
- });
- });
- app.get("/:categories/:slug", function(req, res){
- var categories = new Categories();
- var articles = new Articles();
- Promise.all([
- template.getNav(),
- categories.getCategorie(req.params.categories),
- articles.getArticle(req.params.categories, req.params.slug)
- ]).then(data => {
- var nav = data[0];
- var dataCategories = data[1];
- var content = data[2];
- res.setHeader("Content-type", "text/html");
- var tplData = {
- "blogName": config.blogName,
- "title": articles.title+" - "+dataCategories.title+" - "+ config.blogName,
- "nav": nav,
- "content": content,
- "disclaimer": ''
- };
- res.render('template.hbs', tplData);
- }).catch(err => {
- res.setHeader("Content-type", "text/plain");
- res.end("erreur");
- });
- });*/
- app.use(express.static("./public"));
- }
-
- useDB(){
- return new Promise((resolve, reject) => {
- fs.access("./plugins/db/"+config.db+"/config.json", fs.constants.F_OK || fs.constants.R_OK, (error) => {
- if(error){
- resolve(new Error("File not exist"));
- }
- else{
- resolve(require("./plugins/db/"+config.db+"/config.json"));
- }
- });
- });
+ app.listen(config.appPort || 8888);
}
}
-new App("/", config.appPort);
\ No newline at end of file
+new Nodezzarella("/");
\ No newline at end of file
diff --git a/plugins/core/blog/classes/Articles.class.js b/classes/Articles.class.js
similarity index 100%
rename from plugins/core/blog/classes/Articles.class.js
rename to classes/Articles.class.js
diff --git a/classes/Categorie.class.js b/classes/Categorie.class.js
new file mode 100644
index 0000000..134a7d2
--- /dev/null
+++ b/classes/Categorie.class.js
@@ -0,0 +1,48 @@
+const log = require('color-logs')(true, true, "Categories.class.js");
+
+var title,
+ uri,
+ description;
+
+class Categorie {
+
+ /**
+ *
+ * @param {string} title title of categorie
+ * @param {string} uri uri of categorie
+ * @param {string} description description of categorie
+ * @returns {nm$_Categorie.class.Categorie}
+ */
+ constructor(title, uri, description){
+ this.setTitle(title);
+ this.setUri(uri);
+ this.setDescription(description);
+ }
+
+ setTitle(title){
+ this.title = title;
+ }
+
+ setUri(uri){
+ this.uri = uri;
+ }
+
+ setDescription(description){
+ this.description = description;
+ }
+
+ getTitle(){
+ return this.title;
+ }
+
+ getUri(){
+ return this.uri;
+ }
+
+ getDescription(){
+ return this.description;
+ }
+
+}
+
+module.exports = Categorie;
\ No newline at end of file
diff --git a/plugins/core/blog/classes/Categories.class.js b/classes/Controllers/Categories.class.js
similarity index 73%
rename from plugins/core/blog/classes/Categories.class.js
rename to classes/Controllers/Categories.class.js
index c8d1c08..93052fa 100644
--- a/plugins/core/blog/classes/Categories.class.js
+++ b/classes/Controllers/Categories.class.js
@@ -1,131 +1,174 @@
-const log = require('color-logs')(true, true, "Categories.class.js"),
- path = require('path'),
- hbs = require('handlebars'),
- promise = require('promise'),
- fs = require("fs");
-
-hbs.registerHelper('listArticle', function(tabs, options) {
- var i = 1;
- var out = '';
- for(var x in options['data']['root']){
-
- out = out + "" + options.fn(options['data']['root'][x]) + "";
- if(i == 3){
- i= 1;
- out = out + "
";
- }
- else{
- i++;
- }
- }
- return out;
-});
-
-class Categories {
-
- /**
- * hydrate global var
- * @param {type} slug : url of categorie
- * @returns {Promise} data of categories
- */
- getCategorie(slug){
- return new Promise((resolve, reject) => {
- var path = "./ressources/"+slug+"/params.json";
- fs.access(path, fs.constants.F_OK || fs.constants.R_OK, (error) => {
- if(error)
- resolve(new Error("File not exist"));
- else
- resolve(require("."+path));
- });
- });
- }
-
- /**
- *
- * @returns {Promise} the list of article
- */
- getHome(){
- return new Promise((resolve, reject) => {
- fs.readFile('./views/articles/list.hbs', 'utf-8', (error, source) => {
- var data = require('../ressources/lastArticles.json');
- hbs.registerHelper('articles', (articles) =>{
- return articles;
- });
- var template = hbs.compile(source);
- var html = template(data);
- resolve(html);
- });
- });
- }
-
-
- getDisclaimer(){
- return new Promise((resolve, reject) => {
- fs.readFile('./views/articles/disclaimer.hbs', 'utf-8', (error, source) => {
- var data = require('../ressources/disclaimer.json');
- hbs.registerHelper('articles', (articles) =>{
- return articles;
- });
- var template = hbs.compile(source);
- var html = template(data);
- resolve(html);
- });
- });
- }
-
- /**
- *
- * @param {type} slug : url of categorie
- * @returns {Promise} the list of article in this categorie
- */
- getListArticles(slug){
- return new Promise((resolve, reject) => {
- fs.readFile('./views/articles/list.hbs', 'utf-8', (error, source) => {
- var pathOfArticles = "./ressources/"+slug+"";
- var dataObj = {};
- fs.readdir(pathOfArticles, (err, files)=> {
- if(err){
- resolve(new Error("File not exist"));
- }
- else{
- var i = 0;
- files.forEach((file) => {
- if(file != "params.json"){
- if(path.extname(file) == ".json"){
- dataObj[i] = require('.'+pathOfArticles+"/"+file);
- i++;
- }
- }
-
- });
- var objectSize = Object.keys(dataObj).length;
- var data = "{";
- for(var x in dataObj){
- if(x < objectSize-1){
- data += "\""+x+"\""+":"+JSON.stringify(dataObj[x])+',';
- }
- else{
- data += "\""+x+"\""+":"+JSON.stringify(dataObj[x])+'';
- }
- }
- data += "}";
- data = JSON.parse(data);
-
- hbs.registerHelper('articles', (articles) =>{
- return articles;
- });
-
- var template = hbs.compile(source);
- var html = template(data);
- resolve(html);
- }
- });
-
- });
- });
- }
-
-
-}
-
+const log = require('color-logs')(true, true, "Categories.class.js"),
+ path = require('path'),
+ hbs = require('handlebars'),
+ promise = require('promise'),
+ dbConnector = require('../../lib/db/'+config.db+"/db.js");
+ fs = require("fs");
+
+hbs.registerHelper('listArticle', function(tabs, options) {
+ var i = 1;
+ var out = '';
+ for(var x in options['data']['root']){
+
+ out = out + "" + options.fn(options['data']['root'][x]) + "";
+ if(i == 3){
+ i= 1;
+ out = out + "
";
+ }
+ else{
+ i++;
+ }
+ }
+ return out;
+});
+
+hbs.registerHelper('listNav', function(tabs, options) {
+ var out = '';
+ for(var x in options['data']['root']){
+ out = out + "" + options.fn(options['data']['root'][x]) + "";
+
+ }
+ return out;
+});
+
+class Categories {
+
+ getNav(){
+ var db = new dbConnector();
+ return db.get({
+ "select" : {
+ "categories" : [
+ "title",
+ "uri",
+ "description"
+ ]
+ },
+ "condition" : "",
+ "limit": ""
+ }).then((result) => {
+ return new Promise((resolve, reject) => {
+ fs.readFile('./views/_nav.hbs', 'utf-8', (error, source) => {
+ hbs.registerHelper('nav', (nav) =>{
+ return nav;
+ });
+ var template = hbs.compile(source);
+ log.Debug(result)
+ var html = template(result);
+ resolve(html);
+ });
+ });
+ log.Info("work");
+ }).catch((err) => {
+ log.error(err);
+ throw err;
+ });
+ }
+
+ /**
+ * hydrate global var
+ * @param {type} slug : url of categorie
+ * @returns {Promise} data of categories
+ */
+ getCategorie(slug){
+ return new Promise((resolve, reject) => {
+ var path = "./ressources/"+slug+"/params.json";
+ fs.access(path, fs.constants.F_OK || fs.constants.R_OK, (error) => {
+ if(error)
+ resolve(new Error("File not exist"));
+ else
+ resolve(require("."+path));
+ });
+ });
+ }
+
+ /**
+ *
+ * @returns {Promise} the list of article
+ */
+ getHome(){
+ return new Promise((resolve, reject) => {
+ fs.readFile('./views/articles/list.hbs', 'utf-8', (error, source) => {
+ var data = require('../ressources/lastArticles.json');
+ hbs.registerHelper('articles', (articles) =>{
+ return articles;
+ });
+ var template = hbs.compile(source);
+ var html = template(data);
+ resolve(html);
+ });
+ });
+ }
+
+
+ getDisclaimer(){
+ return new Promise((resolve, reject) => {
+ fs.readFile('./views/articles/disclaimer.hbs', 'utf-8', (error, source) => {
+ var data = require('../ressources/disclaimer.json');
+ hbs.registerHelper('articles', (articles) =>{
+ return articles;
+ });
+ var template = hbs.compile(source);
+ var html = template(data);
+ resolve(html);
+ });
+ });
+ }
+
+ /**
+ *
+ * @param {type} slug : url of categorie
+ * @returns {Promise} the list of article in this categorie
+ */
+ getListArticles(slug){
+ return new Promise((resolve, reject) => {
+ fs.readFile('./views/articles/list.hbs', 'utf-8', (error, source) => {
+ var pathOfArticles = "./ressources/"+slug+"";
+ var dataObj = {};
+ fs.readdir(pathOfArticles, (err, files)=> {
+ if(err){
+ resolve(new Error("File not exist"));
+ }
+ else{
+ var i = 0;
+ files.forEach((file) => {
+ if(file != "params.json"){
+ if(path.extname(file) == ".json"){
+ dataObj[i] = require('.'+pathOfArticles+"/"+file);
+ i++;
+ }
+ }
+
+ });
+ var objectSize = Object.keys(dataObj).length;
+ var data = "{";
+ for(var x in dataObj){
+ if(x < objectSize-1){
+ data += "\""+x+"\""+":"+JSON.stringify(dataObj[x])+',';
+ }
+ else{
+ data += "\""+x+"\""+":"+JSON.stringify(dataObj[x])+'';
+ }
+ }
+ data += "}";
+ data = JSON.parse(data);
+
+ hbs.registerHelper('articles', (articles) =>{
+ return articles;
+ });
+
+ var template = hbs.compile(source);
+ var html = template(data);
+ resolve(html);
+ }
+ });
+
+ });
+ });
+ }
+
+
+
+
+}
+
module.exports = Categories;
\ No newline at end of file
diff --git a/plugins/core/blog/classes/Template.class.js b/classes/Template.class.js
similarity index 90%
rename from plugins/core/blog/classes/Template.class.js
rename to classes/Template.class.js
index dca6a57..6615af1 100644
--- a/plugins/core/blog/classes/Template.class.js
+++ b/classes/Template.class.js
@@ -20,7 +20,9 @@ class Template {
* @returns {Promise} the navbar in html compiled
*/
- getNav(){
+
+
+ /*getNav(){
return new Promise((resolve, reject) => {
fs.readFile('./views/_nav.hbs', 'utf-8', (error, source) => {
const articles = require("../ressources/categories.json");
@@ -34,9 +36,10 @@ class Template {
});
}
+
getToot(){
- }
+ }*/
}
diff --git a/config.json b/config.json
index 5e55b0a..e026adf 100644
--- a/config.json
+++ b/config.json
@@ -1,9 +1,7 @@
{
"appPort": "8888",
- "sisteTitme": "Dryusdan",
+ "siteTitle": "Dryusdan",
"siteHomeTitle": "Dryusdan.fr, blog d'un passionné d'informatique",
- "plugins": [
- "core/blog"
- ],
- "db": "rethinkdb"
+ "db": "rethinkdb",
+ "webroot" : "/"
}
diff --git a/lib/db/jsonfile/config.json b/lib/db/jsonfile/config.json
new file mode 100644
index 0000000..680d5d0
--- /dev/null
+++ b/lib/db/jsonfile/config.json
@@ -0,0 +1,3 @@
+{
+ "flatFile": true
+}
diff --git a/lib/db/jsonfile/db.js b/lib/db/jsonfile/db.js
new file mode 100644
index 0000000..91ed10d
--- /dev/null
+++ b/lib/db/jsonfile/db.js
@@ -0,0 +1,21 @@
+class jsonFileDB{
+
+ get(){
+
+ }
+
+ post(){
+
+ }
+
+ update(){
+
+ }
+
+ remove(){
+
+ }
+
+}
+
+module.exports = jsonFileDB;
\ No newline at end of file
diff --git a/lib/db/rethinkdb/config.json b/lib/db/rethinkdb/config.json
new file mode 100644
index 0000000..65320f7
--- /dev/null
+++ b/lib/db/rethinkdb/config.json
@@ -0,0 +1,8 @@
+{
+ "flatFile": false,
+ "host":"172.20.1.2",
+ "port":"28015",
+ "username":"",
+ "password":"",
+ "dbName":"nodezzarella"
+}
diff --git a/lib/db/rethinkdb/db.js b/lib/db/rethinkdb/db.js
new file mode 100644
index 0000000..d916f77
--- /dev/null
+++ b/lib/db/rethinkdb/db.js
@@ -0,0 +1,104 @@
+const r = require("rethinkdb"),
+ promise = require('promise'),
+ fs = require('fs'),
+ log = require("color-logs")(true, true, "RethinDB connector");
+
+class rethinkdb{
+
+ static constructor(){
+
+ }
+
+ get(query){
+ return new Promise((resolve, reject) => {
+
+ var nbOfTable = Object.keys(query.select).length;
+
+ /**
+ * select table
+ */
+ var formatedQuery = r.table(Object.keys(query.select)[0]);
+
+ /**
+ * select collumn of table
+ */
+ for (var collumn in query.select){
+ if(query.select.hasOwnProperty(collumn)){
+ var selectCollumn = query.select[collumn];
+ break;
+ }
+ }
+
+ if(selectCollumn.length > 0){
+ formatedQuery = formatedQuery.pluck(selectCollumn)
+ }
+
+ /**
+ * make join query
+ */
+ if(nbOfTable > 1){
+
+ }
+
+ /**
+ * run query
+ */
+ formatedQuery.run(dbConnexion, (err, result) => {
+ if(err) throw err;
+ var jsonReturn = [];
+ result.each(function(err, row) {
+ if (err) throw err;
+ jsonReturn.push(row);
+ });
+ resolve(jsonReturn);
+ });
+ });
+ }
+
+ post(){
+ /*r.db("nodezzarella").table("categories").insert([{
+ "title": "global test",
+ "uri":"global-test",
+ "description":"desc"
+ },
+ {
+ "title": "test",
+ "uri":"test",
+ "description":"desc2"
+ }])*/
+ //https://www.rethinkdb.com/api/javascript/insert/
+ }
+
+ update(){
+
+ }
+
+ remove(){
+
+ }
+
+ getDBConfig(){
+ return new Promise((resolve, reject) => {
+ fs.access("./config.json", fs.constants.F_OK || fs.constants.R_OK, (error) => {
+ if(error){
+ reject(new Error("File not exist"));
+ }
+ else{
+ resolve(require("./config.json"));
+ }
+ });
+ });
+ }
+
+ connectDB(config){
+ log.info("Application connecting to database...");
+ return r.connect({
+ host: config.host,
+ port: config.port,
+ db: config.dbName
+ });
+ }
+
+}
+
+module.exports = rethinkdb;
\ No newline at end of file
diff --git a/lib/router.js b/lib/router.js
new file mode 100644
index 0000000..63394a4
--- /dev/null
+++ b/lib/router.js
@@ -0,0 +1,113 @@
+const express = require("express"),
+ router = express.Router(),
+ promise = require('promise'),
+ hbs = require('hbs'),
+ path = require('path'),
+ log = require("color-logs")(true, true, "Router"),
+ Template = require('../classes/Template.class.js'),
+ Articles = require('../classes/Articles.class.js'),
+ Categorie = require('../classes/Categorie.class.js'),
+ Categories = require('../classes/Controllers/Categories.class.js');
+
+var template = new Template();
+router.get("/", function(req, res){
+
+ var categories = new Categories();
+ Promise.all([
+ categories.getNav()
+ ]).then((data) => {
+ var nav = data[0];
+ var content = /*data[1]*/ "";
+ var disclaimer = /*data[2]*/ "";
+ res.setHeader("Content-type", "text/html");
+ var tplData = {
+ "blogName": config.siteTitle,
+ "title": config.siteHomeTitle,
+ "nav": nav,
+ "content": content,
+ "disclaimer": disclaimer
+ };
+ res.render('template.hbs', tplData);
+ }).catch((err) => {
+ console.log(err);
+ throw err;
+ });
+ /*Promise.all([
+ template.getNav(),
+ categories.getHome(),
+ categories.getDisclaimer()
+ ]).then(data => {
+ var nav = data[0];
+ var content = data[1];
+ var disclaimer = data[2];
+ res.setHeader("Content-type", "text/html");
+ var tplData = {
+ "blogName": config.blogName,
+ "title": config.homeTitle,
+ "nav": nav,
+ "content": content,
+ "disclaimer": disclaimer
+ };
+ res.render('template.hbs', tplData);
+ }).catch(err => {
+ res.setHeader("Content-type", "text/plain");
+
+ resp.send(res.end("erreur"));
+ });*/
+
+
+});
+/*router.get("/:slug", function(req, res){
+ var categories = new Categories();
+ Promise.all([
+ template.getNav(),
+ categories.getListArticles(req.params.slug),
+ categories.getCategorie(req.params.slug)
+ ]).then(data => {
+ var nav = data[0];
+ var content = data[1];
+ var dataCategories = data[2];
+ res.setHeader("Content-type", "text/html");
+ var tplData = {
+ "blogName": config.blogName,
+ "title": dataCategories.title+" - "+ config.blogName,
+ "nav": nav,
+ "content": content,
+ "disclaimer": ''
+ };
+ res.render('template.hbs', tplData);
+ }).catch(err => {
+ res.setHeader("Content-type", "text/plain");
+
+ res.end("erreur");
+ });
+});*/
+
+/*router.get("/:categories/:slug", function(req, res){
+ var categories = new Categories();
+ var articles = new Articles();
+ Promise.all([
+ template.getNav(),
+ categories.getCategorie(req.params.categories),
+ articles.getArticle(req.params.categories, req.params.slug)
+ ]).then(data => {
+ var nav = data[0];
+ var dataCategories = data[1];
+ var content = data[2];
+ res.setHeader("Content-type", "text/html");
+ var tplData = {
+ "blogName": config.blogName,
+ "title": articles.title+" - "+dataCategories.title+" - "+ config.blogName,
+ "nav": nav,
+ "content": content,
+ "disclaimer": ''
+ };
+ res.render('template.hbs', tplData);
+ }).catch(err => {
+ res.setHeader("Content-type", "text/plain");
+ res.end("erreur");
+ });
+});*/
+router.use(express.static("./public"));
+
+module.exports = router;
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 82fe6d1..f90faaf 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "nodezzarela",
+ "name": "nodezzarella",
"version": "1.0.0",
"lockfileVersion": 1,
"dependencies": {
@@ -33,6 +33,11 @@
"version": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
},
+ "bluebird": {
+ "version": "2.11.0",
+ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz",
+ "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE="
+ },
"camelcase": {
"version": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
@@ -385,6 +390,11 @@
"version": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
},
+ "rethinkdb": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/rethinkdb/-/rethinkdb-2.3.3.tgz",
+ "integrity": "sha1-PcZYbiL6HavuDSVOZL0ON5+tL3I="
+ },
"right-align": {
"version": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
"integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=",
diff --git a/package.json b/package.json
index 68884e3..53dde35 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "nodezzarela",
+ "name": "nodezzarella",
"version": "1.0.0",
"keywords": [
"util",
@@ -22,6 +22,7 @@
"hbs": "4.0.1",
"helmet": "^3.6.1",
"markdown": "^0.5.0",
- "promise": "^8.0.0"
+ "promise": "^8.0.0",
+ "rethinkdb": "^2.3.3"
}
}
diff --git a/plugins/core/blog/app.js b/plugins/core/blog/app.js
deleted file mode 100644
index 8a4eda9..0000000
--- a/plugins/core/blog/app.js
+++ /dev/null
@@ -1,81 +0,0 @@
-class Blog{
- constructor(express){
- express.get("/", function(req, res){
- var categories = new Categories();
- Promise.all([
- template.getNav(),
- categories.getHome(),
- categories.getDisclaimer()
- ]).then(data => {
- var nav = data[0];
- var content = data[1];
- var disclaimer = data[2];
- res.setHeader("Content-type", "text/html");
- var tplData = {
- "blogName": config.blogName,
- "title": config.homeTitle,
- "nav": nav,
- "content": content,
- "disclaimer": disclaimer
- };
- res.render('template.hbs', tplData);
- }).catch(err => {
- res.setHeader("Content-type", "text/plain");
-
- res.end("erreur");
- });
-
-
- });
- express.get("/:slug", function(req, res){
- var categories = new Categories();
- Promise.all([
- template.getNav(),
- categories.getListArticles(req.params.slug),
- categories.getCategorie(req.params.slug)
- ]).then(data => {
- var nav = data[0];
- var content = data[1];
- var dataCategories = data[2];
- res.setHeader("Content-type", "text/html");
- var tplData = {
- "blogName": config.blogName,
- "title": dataCategories.title+" - "+ config.blogName,
- "nav": nav,
- "content": content,
- "disclaimer": ''
- };
- res.render('template.hbs', tplData);
- }).catch(err => {
- res.setHeader("Content-type", "text/plain");
-
- res.end("erreur");
- });
- });
- express.get("/:categories/:slug", function(req, res){
- var categories = new Categories();
- var articles = new Articles();
- Promise.all([
- template.getNav(),
- categories.getCategorie(req.params.categories),
- articles.getArticle(req.params.categories, req.params.slug)
- ]).then(data => {
- var nav = data[0];
- var dataCategories = data[1];
- var content = data[2];
- res.setHeader("Content-type", "text/html");
- var tplData = {
- "blogName": config.blogName,
- "title": articles.title+" - "+dataCategories.title+" - "+ config.blogName,
- "nav": nav,
- "content": content,
- "disclaimer": ''
- };
- res.render('template.hbs', tplData);
- }).catch(err => {
- res.setHeader("Content-type", "text/plain");
- res.end("erreur");
- });
- });
- }
-}
\ No newline at end of file
diff --git a/plugins/core/blog/config.json b/plugins/core/blog/config.json
deleted file mode 100644
index cbba574..0000000
--- a/plugins/core/blog/config.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "require": [
- "db"
- ]
-}
diff --git a/plugins/core/blog/routes.js b/plugins/core/blog/routes.js
deleted file mode 100644
index 9facedf..0000000
--- a/plugins/core/blog/routes.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-
diff --git a/plugins/db/rethinkdb/app.js b/plugins/db/rethinkdb/app.js
deleted file mode 100644
index 9facedf..0000000
--- a/plugins/db/rethinkdb/app.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-
diff --git a/plugins/db/rethinkdb/config.json b/plugins/db/rethinkdb/config.json
deleted file mode 100644
index 8c7ca76..0000000
--- a/plugins/db/rethinkdb/config.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "flatFile": false,
- "host":"",
- "port":"",
- "username":"",
- "password":"",
- "dbName":""
-}