markdown enabled
This commit is contained in:
+3
-10
@@ -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
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user