mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Parameterise the template for saving tiddlers
This commit is contained in:
parent
692b8b4b15
commit
19b62c30d8
@ -26,13 +26,19 @@ FileSystemAdaptor.prototype.getTiddlerInfo = function(tiddler) {
|
||||
$tw.config.typeInfo = {
|
||||
"text/vnd.tiddlywiki": {
|
||||
fileType: "application/x-tiddler",
|
||||
extension: ".tid"},
|
||||
extension: ".tid",
|
||||
template: "$:/core/templates/tid-tiddler"
|
||||
},
|
||||
"image/jpeg" : {
|
||||
fileType: "application/x-tiddler-binary",
|
||||
hasMetaFile: true
|
||||
}
|
||||
};
|
||||
|
||||
$tw.config.typeTemplates = {
|
||||
"application/x-tiddler": "$:/core/templates/tid-tiddler"
|
||||
};
|
||||
|
||||
FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
||||
// See if we've already got information about this file
|
||||
var self = this,
|
||||
@ -96,7 +102,9 @@ FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
var content = $tw.wiki.renderTiddler("text/plain","$:/core/templates/tid-tiddler",{tiddlerTitle: tiddler.fields.title});
|
||||
var template = $tw.config.typeTemplates[fileInfo.type];
|
||||
console.log(fileInfo,template)
|
||||
var content = $tw.wiki.renderTiddler("text/plain",template,{tiddlerTitle: tiddler.fields.title});
|
||||
fs.writeFile(fileInfo.filepath,content,{encoding: "utf8"},function (err) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
|
Loading…
Reference in New Issue
Block a user