|
@ -20,37 +20,35 @@ module.exports= |
|
|
{ |
|
|
{ |
|
|
return new Promise(function (resolve, reject) |
|
|
return new Promise(function (resolve, reject) |
|
|
{ |
|
|
{ |
|
|
res.write("<div class=\"w3-card-4 w3-margin w3-white\">"); |
|
|
|
|
|
|
|
|
var html = "<div class=\"w3-card-4 w3-margin w3-white\">"; |
|
|
//image
|
|
|
//image
|
|
|
if(!(post.picture_url ==="n/a")) |
|
|
|
|
|
|
|
|
if(!(post.picture_url === "n/a")) |
|
|
{ |
|
|
{ |
|
|
res.write("<img src=\"/img/posts/" + post.picture_url + "\" alt=\"Nature\" style=\"width:100%\">"); |
|
|
|
|
|
|
|
|
html +="<img src=\"/img/posts/" + post.picture_url + "\" alt=\"Nature\" style=\"width:100%\">"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
res.write("<div class=\"w3-container\">"); |
|
|
|
|
|
|
|
|
html += "<div class=\"w3-container\">"; |
|
|
//title
|
|
|
//title
|
|
|
res.write("<h3><b>" + post.name + "</b></h3>"); |
|
|
|
|
|
|
|
|
html += "<h3><b>" + post.name + "</b></h3>"; |
|
|
//date
|
|
|
//date
|
|
|
res.write("<h5><span class=\"w3-opacity\">" + post.published.toDateString() + "</span></h5>"); |
|
|
|
|
|
res.write("</div>"); |
|
|
|
|
|
|
|
|
html += "<h5><span class=\"w3-opacity\">" + post.published.toDateString() + "</span></h5>"; |
|
|
|
|
|
html +="</div>"; |
|
|
|
|
|
|
|
|
res.write("<div class=\"w3-container\">"); |
|
|
|
|
|
|
|
|
html += "<div class=\"w3-container\">"; |
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
sql.getCategory(post.category_id).then(function(category) |
|
|
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("<code>").join("<pre><code>"); |
|
|
html = html.split("<code>").join("<pre><code>"); |
|
|
html = html.split("</code>").join("</code></pre>"); |
|
|
html = html.split("</code>").join("</code></pre>"); |
|
|
html = html.split("\\`\\`\\`").join("```"); |
|
|
html = html.split("\\`\\`\\`").join("```"); |
|
|
html = html.split("![](media/").join("![](" + "entries/" + category.url + "/media/"); |
|
|
html = html.split("![](media/").join("![](" + "entries/" + category.url + "/media/"); |
|
|
|
|
|
html += "</div></div>"; |
|
|
res.write(html); |
|
|
res.write(html); |
|
|
|
|
|
|
|
|
res.write("</div></div>"); |
|
|
|
|
|
resolve() |
|
|
resolve() |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|