diff --git a/entries/testing-my-server.md b/entries/Java/testing-my-server.md
similarity index 100%
rename from entries/testing-my-server.md
rename to entries/Java/testing-my-server.md
diff --git a/posts/category.js b/posts/category.js
index 7909e31..26a34d3 100644
--- a/posts/category.js
+++ b/posts/category.js
@@ -21,8 +21,7 @@ var renderPosts = function(result, resultURL)
promises.push(new Promise(function(res, rej)
{
require("../posts/singlePost.js")
- .renderPost(result, p)
- .then(function()
+ .renderPost(result, p).then(function()
{
res();
});
@@ -60,7 +59,6 @@ module.exports=
*/
main: function(res, requestURL, request)
{
- console.log("category page");
return new Promise(function(resolve, reject)
{
renderPosts(res, requestURL).then(function()
diff --git a/posts/singlePost.js b/posts/singlePost.js
index c940583..22e4f6b 100644
--- a/posts/singlePost.js
+++ b/posts/singlePost.js
@@ -20,37 +20,35 @@ module.exports=
{
return new Promise(function (resolve, reject)
{
- res.write("
");
+ var html = "
";
//image
- if(!(post.picture_url ==="n/a"))
+ if(!(post.picture_url === "n/a"))
{
- res.write("
");
+ html +="
";
}
- res.write("
");
+ html += "
";
//title
- res.write("
" + post.name + "
");
+ html += "" + post.name + "
";
//date
- res.write("" + post.published.toDateString() + "
");
- res.write("");
+ html += "
" + post.published.toDateString() + "
";
+ html +="
";
- res.write("
");
+ html += "
";
try
{
sql.getCategory(post.category_id).then(function(category)
{
- var pathName = "entries/" + category.url + "/" + post.url + ".md";
-
- var html = markdown.toHTML(utils.getFileContents(pathName).toString());
+ var pathName = "entries/" + category[0].url + "/" + post.url + ".md";
+ html += markdown.toHTML(utils.getFileContents(pathName).toString());
html = html.split("
").join("");
html = html.split("
").join("
");
html = html.split("\\`\\`\\`").join("```");
html = html.split("![](media/").join("![](" + "entries/" + category.url + "/media/");
+ html += "
";
res.write(html);
-
- res.write("
");
resolve()
});
}
diff --git a/server.js b/server.js
index 686dc2f..9891a30 100644
--- a/server.js
+++ b/server.js
@@ -33,8 +33,7 @@ var app = express();
// cert: cert,
// ca: ca
// };
-
-app.use(session({ secret: utils.getFileContents('../../session_secret'), cookie: { maxAge: 6000000 }}));
+app.use(session({ secret: utils.getFileLine('../session_secret'), cookie: { maxAge: 6000000 }}));
app.use(function(request, res)
{
@@ -55,7 +54,7 @@ app.use(function(request, res)
var file = "";
if(filename === '' || filename === '/')
- filename = '/category/projects';
+ filename = '/category/Java';
var urlSplit = filename.split("/");
diff --git a/sidebar/sidebar.html b/sidebar/sidebar.html
index 40eb8a4..1dae84a 100644
--- a/sidebar/sidebar.html
+++ b/sidebar/sidebar.html
@@ -1,3 +1,4 @@
+
\ No newline at end of file
diff --git a/utils/sql.js b/utils/sql.js
index 2b19be1..b824600 100644
--- a/utils/sql.js
+++ b/utils/sql.js
@@ -10,13 +10,14 @@ const qs = require('querystring');
const utils = require('../utils/utils.js');
-const con = mysql.createConnection({
+var con = mysql.createConnection({
host: "localhost",
user: "blog_user",
- password: utils.getFileContents('../../sql_secret'),
+ password: utils.getFileLine('../sql_secret'),
database: "blog_name"
});
+
con.connect(function(err) {
if (err) throw err;
});
diff --git a/utils/utils.js b/utils/utils.js
index 6e4573c..be877a4 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -50,6 +50,24 @@ module.exports=
return 0;
},
+ /**
+ *
+ * @param fileName
+ * @return {*}
+ */
+ getFileLine: function(fileName)
+ {
+ try
+ {
+ return fs.readFileSync(fileName, "utf8").split('\n').join('');
+ }
+ catch (e)
+ {
+ console.log("Could not find " + fileName);
+ }
+ return 0;
+ },
+
/**
* Function which is responsible for returning all post data.