mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Add a hook to allow modifying the the behaviour creating tiddler paths (#5267)
* Add a hook to allow modifying the the behaviour creating tiddler paths This is needed for Bob to use the core to generate tiddler fileInfo I don't know if this is the best way to make the hook, but it works for what I need * update th-make-tiddler-path arguments the value is the current path, the parameter passed in is the original unmodified path so it is available to subsequent hooks
This commit is contained in:
parent
88e29b4558
commit
c1a1e272cc
@ -382,11 +382,13 @@ exports.generateTiddlerFilepath = function(title,options) {
|
||||
count++;
|
||||
} while(fs.existsSync(fullPath));
|
||||
//If the path does not start with the wikiPath directory or the wikiTiddlersPath directory, or if the last write failed
|
||||
var encode = !(fullPath.indexOf(path.resolve($tw.boot.wikiPath)) == 0 || fullPath.indexOf($tw.boot.wikiTiddlersPath) == 0) || ((options.fileInfo || {writeError: false}).writeError == true);
|
||||
var newPath = fullPath;
|
||||
var encode = !(fullPath.indexOf($tw.boot.wikiPath) == 0 || fullPath.indexOf($tw.boot.wikiTiddlersPath) == 0) || ((options.fileInfo || {writeError: false}).writeError == true);
|
||||
if(encode){
|
||||
//encodeURIComponent() and then resolve to tiddler directory
|
||||
fullPath = path.resolve(directory, encodeURIComponent(fullPath));
|
||||
newPath = path.resolve(directory, encodeURIComponent(fullPath));
|
||||
}
|
||||
fullPath = $tw.hooks.invokeHook("th-make-tiddler-path", newPath, fullPath);
|
||||
// Return the full path to the file
|
||||
return fullPath;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user