mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 23:03:50 +00:00
Cleaning up recipe file access code
This commit is contained in:
parent
1411b8a12a
commit
f6faa156a5
@ -36,12 +36,12 @@ exports["application/vnd.tiddlywiki2-recipe"] = function(text,fields) {
|
|||||||
var ext = path.extname(sourcePath),
|
var ext = path.extname(sourcePath),
|
||||||
extensionInfo = $tw.config.fileExtensionInfo[ext],
|
extensionInfo = $tw.config.fileExtensionInfo[ext],
|
||||||
typeInfo = extensionInfo ? $tw.config.contentTypeInfo[extensionInfo.type] : null,
|
typeInfo = extensionInfo ? $tw.config.contentTypeInfo[extensionInfo.type] : null,
|
||||||
data = fs.readFileSync(sourcePath).toString(typeInfo ? typeInfo.encoding : "utf8"),
|
data = fs.readFileSync(sourcePath,typeInfo ? typeInfo.encoding : "utf8"),
|
||||||
fields = {title: sourcePath},
|
fields = {title: sourcePath},
|
||||||
tids = self.deserializeTiddlers(ext,data,fields),
|
tids = self.deserializeTiddlers(ext,data,fields),
|
||||||
metafile = sourcePath + ".meta";
|
metafile = sourcePath + ".meta";
|
||||||
if(ext !== ".json" && tids.length === 1 && fs.existsSync(metafile)) {
|
if(ext !== ".json" && tids.length === 1 && fs.existsSync(metafile)) {
|
||||||
var metadata = fs.readFileSync(metafile).toString("utf8");
|
var metadata = fs.readFileSync(metafile,"utf8");
|
||||||
if(metadata) {
|
if(metadata) {
|
||||||
tids = [$tw.utils.parseFields(metadata,tids[0])];
|
tids = [$tw.utils.parseFields(metadata,tids[0])];
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ exports["application/vnd.tiddlywiki2-recipe"] = function(text,fields) {
|
|||||||
for(var t=0; t<recipe.length; t++) {
|
for(var t=0; t<recipe.length; t++) {
|
||||||
if(recipe[t].name === "recipe") {
|
if(recipe[t].name === "recipe") {
|
||||||
var recipeFile = path.resolve(path.dirname(sourcePath),recipe[t].value);
|
var recipeFile = path.resolve(path.dirname(sourcePath),recipe[t].value);
|
||||||
processRecipe(recipeFile,fs.readFileSync(recipeFile));
|
processRecipe(recipeFile,fs.readFileSync(recipeFile,"utf8"));
|
||||||
} else {
|
} else {
|
||||||
var tiddlerFile = path.resolve(path.dirname(sourcePath),recipe[t].value);
|
var tiddlerFile = path.resolve(path.dirname(sourcePath),recipe[t].value);
|
||||||
loadTiddlersFromFile(tiddlerFile,"{" + recipe[t].name + "}");
|
loadTiddlersFromFile(tiddlerFile,"{" + recipe[t].name + "}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user