mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 06:14:44 +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 = {
|
$tw.config.typeInfo = {
|
||||||
"text/vnd.tiddlywiki": {
|
"text/vnd.tiddlywiki": {
|
||||||
fileType: "application/x-tiddler",
|
fileType: "application/x-tiddler",
|
||||||
extension: ".tid"},
|
extension: ".tid",
|
||||||
|
template: "$:/core/templates/tid-tiddler"
|
||||||
|
},
|
||||||
"image/jpeg" : {
|
"image/jpeg" : {
|
||||||
fileType: "application/x-tiddler-binary",
|
fileType: "application/x-tiddler-binary",
|
||||||
hasMetaFile: true
|
hasMetaFile: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$tw.config.typeTemplates = {
|
||||||
|
"application/x-tiddler": "$:/core/templates/tid-tiddler"
|
||||||
|
};
|
||||||
|
|
||||||
FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
||||||
// See if we've already got information about this file
|
// See if we've already got information about this file
|
||||||
var self = this,
|
var self = this,
|
||||||
@ -96,7 +102,9 @@ FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(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) {
|
fs.writeFile(fileInfo.filepath,content,{encoding: "utf8"},function (err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user