markdown enabled

This commit is contained in:
Christian Müller
2015-09-25 22:57:44 +02:00
parent 83360b48bb
commit 36c166d10b
5 changed files with 19 additions and 21 deletions
+3 -10
View File
@@ -1,16 +1,9 @@
var LRU = require("lru-cache"),
marked = require("marked"),
fs = require("fs");
var marked = require("marked");
var fs = require("fs");
var CACHE = new LRU(30); // create LRU cache of size 30
var template = fs.readFileSync("resources/template.html", "utf-8");
var buildHTML = (title, content) => template
.replace("%TITLE%", title)
.replace("%CONTENT%", content);
module.exports.build = id => {
if (CACHE.has(id)) return CACHE.get(id);
var content = "This is page " + id;
CACHE.set(id, content);
return content;
};
module.exports.build = note => buildHTML(note.title, marked(note.text));
+4 -3
View File
@@ -28,6 +28,7 @@ var Link = sequelize.define('Link', {
Note.hasMany(Link);
Link.belongsTo(Note);
module.exports.getNote = linkId => Link.findById(linkId).then(link => {
return Note.findById(link.NoteId);
});
module.exports.getNote = linkId => {
console.log("resolving note", linkId);
return Link.findById(linkId).then(link => Note.findById(link.NoteId));
}