mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 09:50:27 +00:00
Use this.wiki where applicable (#4601)
* Use state.wiki * use local wiki where available * fix a couple this vs self cases
This commit is contained in:
parent
48dfadd85b
commit
81f07cdf85
@ -71,7 +71,7 @@ Command.prototype.fetchFiles = function(options) {
|
||||
if(options.url) {
|
||||
urls = [options.url]
|
||||
} else if(options.urlFilter) {
|
||||
urls = $tw.wiki.filterTiddlers(options.urlFilter);
|
||||
urls = this.commander.wiki.filterTiddlers(options.urlFilter);
|
||||
} else {
|
||||
return "Missing URL";
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ Command.prototype.execute = function() {
|
||||
// Collect the skinny list data
|
||||
var pluginTiddlers = JSON.parse(tiddler.text),
|
||||
readmeContent = (pluginTiddlers.tiddlers[title + "/readme"] || {}).text,
|
||||
doesRequireReload = !!$tw.wiki.doesPluginInfoRequireReload(pluginTiddlers),
|
||||
doesRequireReload = !!self.commander.wiki.doesPluginInfoRequireReload(pluginTiddlers),
|
||||
iconTiddler = pluginTiddlers.tiddlers[title + "/icon"] || {},
|
||||
iconType = iconTiddler.type,
|
||||
iconText = iconTiddler.text,
|
||||
|
@ -37,13 +37,13 @@ exports.has = function(source,operator,options) {
|
||||
else if(operator.suffix === "index") {
|
||||
if(invert) {
|
||||
source(function(tiddler,title) {
|
||||
if(!tiddler || (tiddler && (!$tw.utils.hop($tw.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)))) {
|
||||
if(!tiddler || (tiddler && (!$tw.utils.hop(options.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)))) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
source(function(tiddler,title) {
|
||||
if(tiddler && $tw.utils.hop($tw.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)) {
|
||||
if(tiddler && $tw.utils.hop(options.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
|
@ -20,8 +20,8 @@ exports.path = /^\/recipes\/default\/tiddlers.json$/;
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
var filter = state.queryParameters.filter || DEFAULT_FILTER;
|
||||
if($tw.wiki.getTiddlerText("$:/config/Server/AllowAllExternalFilters") !== "yes") {
|
||||
if($tw.wiki.getTiddlerText("$:/config/Server/ExternalFilters/" + filter) !== "yes") {
|
||||
if(state.wiki.getTiddlerText("$:/config/Server/AllowAllExternalFilters") !== "yes") {
|
||||
if(state.wiki.getTiddlerText("$:/config/Server/ExternalFilters/" + filter) !== "yes") {
|
||||
console.log("Blocked attempt to GET /recipes/default/tiddlers.json with filter: " + filter);
|
||||
response.writeHead(403);
|
||||
response.end();
|
||||
|
@ -248,7 +248,7 @@ Server.prototype.listen = function(port,host,prefix) {
|
||||
port = process.env[port] || 8080;
|
||||
}
|
||||
// Warn if required plugins are missing
|
||||
if(!$tw.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !$tw.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) {
|
||||
if(!this.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !this.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) {
|
||||
$tw.utils.warning("Warning: Plugins required for client-server operation (\"tiddlywiki/filesystem\" and \"tiddlywiki/tiddlyweb\") are missing from tiddlywiki.info file");
|
||||
}
|
||||
// Create the server
|
||||
|
@ -127,7 +127,7 @@ function Syncer(options) {
|
||||
});
|
||||
}
|
||||
// Listen out for lazyLoad events
|
||||
if(!this.disableUI && $tw.wiki.getTiddlerText(this.titleSyncDisableLazyLoading) !== "yes") {
|
||||
if(!this.disableUI && this.wiki.getTiddlerText(this.titleSyncDisableLazyLoading) !== "yes") {
|
||||
this.wiki.addEventListener("lazyLoad",function(title) {
|
||||
self.handleLazyLoadEvent(title);
|
||||
});
|
||||
@ -204,7 +204,7 @@ Syncer.prototype.isDirty = function() {
|
||||
if(this.wiki.tiddlerExists(title)) {
|
||||
if(tiddlerInfo) {
|
||||
// If the tiddler is known on the server and has been modified locally then it needs to be saved to the server
|
||||
if($tw.wiki.getChangeCount(title) > tiddlerInfo.changeCount) {
|
||||
if(this.wiki.getChangeCount(title) > tiddlerInfo.changeCount) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
@ -526,7 +526,7 @@ Syncer.prototype.chooseNextTask = function() {
|
||||
tiddlerInfo = this.tiddlerInfo[title];
|
||||
if(tiddler) {
|
||||
// If the tiddler is not known on the server, or has been modified locally no more recently than the threshold then it needs to be saved to the server
|
||||
var hasChanged = !tiddlerInfo || $tw.wiki.getChangeCount(title) > tiddlerInfo.changeCount,
|
||||
var hasChanged = !tiddlerInfo || this.wiki.getChangeCount(title) > tiddlerInfo.changeCount,
|
||||
isReadyToSave = !tiddlerInfo || !tiddlerInfo.timestampLastSaved || tiddlerInfo.timestampLastSaved < thresholdLastSaved;
|
||||
if(hasChanged) {
|
||||
if(isReadyToSave) {
|
||||
|
@ -41,7 +41,7 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
||||
// Check if we're dealing with a plugin
|
||||
if(incomingTiddler && incomingTiddler["plugin-type"]) {
|
||||
// Check whether the plugin contains JS modules
|
||||
var requiresReload = $tw.wiki.doesPluginInfoRequireReload(JSON.parse(incomingTiddler.text)) ? ($tw.wiki.getTiddlerText("$:/language/ControlPanel/Plugins/PluginWillRequireReload") + " ") : "";
|
||||
var requiresReload = wiki.doesPluginInfoRequireReload(JSON.parse(incomingTiddler.text)) ? (wiki.getTiddlerText("$:/language/ControlPanel/Plugins/PluginWillRequireReload") + " ") : "";
|
||||
messages[title] = requiresReload;
|
||||
if(incomingTiddler.version) {
|
||||
// Upgrade the incoming plugin if it is in the upgrade library
|
||||
|
@ -1052,7 +1052,7 @@ exports.makeTranscludeWidget = function(title,options) {
|
||||
if(options.children) {
|
||||
parseTreeTransclude.children = options.children;
|
||||
}
|
||||
return $tw.wiki.makeWidget(parseTreeDiv,options);
|
||||
return this.makeWidget(parseTreeDiv,options);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -287,9 +287,10 @@ InnerWikiWidget.prototype.readTiddlerDataWidget = function(dataWidget) {
|
||||
titles = this.wiki.filterTiddlers(dataWidget.getAttribute("$filter"));
|
||||
}
|
||||
if(titles) {
|
||||
var self = this;
|
||||
var results = [];
|
||||
$tw.utils.each(titles,function(title,index) {
|
||||
var tiddler = $tw.wiki.getTiddler(title),
|
||||
var tiddler = self.wiki.getTiddler(title),
|
||||
fields;
|
||||
if(tiddler) {
|
||||
fields = tiddler.getFieldStrings();
|
||||
|
@ -40,7 +40,7 @@ RailroadWidget.prototype.render = function(parent,nextSibling) {
|
||||
var div = this.document.createElement("div");
|
||||
try {
|
||||
// Initialise options from the config tiddler or widget attributes
|
||||
var config = $tw.wiki.getTiddlerData(RAILROAD_OPTIONS,{});
|
||||
var config = this.wiki.getTiddlerData(RAILROAD_OPTIONS,{});
|
||||
var options = {
|
||||
arrow: this.getAttribute("arrow", config.arrow || "yes") === "yes",
|
||||
debug: this.getAttribute("debug", config.debug || "no") === "yes",
|
||||
|
@ -60,7 +60,7 @@ var WikiTextParser = function(type,text,options) {
|
||||
this.output = null;
|
||||
this.subWikify(this.children);
|
||||
// prepend tw2 macros locally to the content
|
||||
var parser = $tw.wiki.parseTiddler("$:/plugins/tiddlywiki/tw2parser/macrodefs",{parseAsInline:false});
|
||||
var parser = this.wiki.parseTiddler("$:/plugins/tiddlywiki/tw2parser/macrodefs",{parseAsInline:false});
|
||||
this.tree = [{
|
||||
type: "element",
|
||||
tag: "div",
|
||||
|
@ -18,9 +18,10 @@ var XLSX = require("$:/plugins/tiddlywiki/xlsx-utils/xlsx.js"),
|
||||
JSZip = require("$:/plugins/tiddlywiki/jszip/jszip.js");
|
||||
|
||||
var XLSXImporter = function(options) {
|
||||
this.wiki = options.wiki;
|
||||
this.filename = options.filename;
|
||||
this.text = options.text;
|
||||
this.importSpec = options.importSpec || $tw.wiki.getTiddlerText(DEFAULT_IMPORT_SPEC_TITLE);
|
||||
this.importSpec = options.importSpec || this.wiki.getTiddlerText(DEFAULT_IMPORT_SPEC_TITLE);
|
||||
this.logger = new $tw.utils.Logger("xlsx-utils");
|
||||
this.results = [];
|
||||
if(JSZip) {
|
||||
@ -40,7 +41,7 @@ XLSXImporter.prototype.processWorkbook = function() {
|
||||
this.workbook = XLSX.read(this.text,{type:"base64"});
|
||||
}
|
||||
// Read the root import specification
|
||||
this.rootImportSpec = $tw.wiki.getTiddler(this.importSpec);
|
||||
this.rootImportSpec = this.wiki.getTiddler(this.importSpec);
|
||||
if(this.rootImportSpec) {
|
||||
// Iterate through the sheets specified in the list field
|
||||
$tw.utils.each(this.rootImportSpec.fields.list || [],this.processSheet.bind(this));
|
||||
@ -49,7 +50,7 @@ XLSXImporter.prototype.processWorkbook = function() {
|
||||
|
||||
XLSXImporter.prototype.processSheet = function(sheetImportSpecTitle) {
|
||||
// Get the sheet import specifier
|
||||
this.sheetImportSpec = $tw.wiki.getTiddler(sheetImportSpecTitle);
|
||||
this.sheetImportSpec = this.wiki.getTiddler(sheetImportSpecTitle);
|
||||
if(this.sheetImportSpec) {
|
||||
this.sheetName = this.sheetImportSpec.fields["import-sheet-name"];
|
||||
this.sheet = this.workbook.Sheets[this.sheetName];
|
||||
@ -70,7 +71,7 @@ XLSXImporter.prototype.processSheet = function(sheetImportSpecTitle) {
|
||||
};
|
||||
|
||||
XLSXImporter.prototype.processRow = function(rowImportSpecTitle) {
|
||||
this.rowImportSpec = $tw.wiki.getTiddler(rowImportSpecTitle);
|
||||
this.rowImportSpec = this.wiki.getTiddler(rowImportSpecTitle);
|
||||
if(this.rowImportSpec) {
|
||||
this.tiddlerFields = {};
|
||||
this.skipTiddler = false;
|
||||
@ -116,7 +117,7 @@ XLSXImporter.prototype.processRowByField = function() {
|
||||
};
|
||||
|
||||
XLSXImporter.prototype.processField = function(fieldImportSpecTitle) {
|
||||
var fieldImportSpec = $tw.wiki.getTiddler(fieldImportSpecTitle);
|
||||
var fieldImportSpec = this.wiki.getTiddler(fieldImportSpecTitle);
|
||||
if(fieldImportSpec) {
|
||||
var fieldName = fieldImportSpec.fields["import-field-name"],
|
||||
value;
|
||||
|
@ -34,9 +34,10 @@ Command.prototype.execute = function() {
|
||||
XLSXImporter = require("$:/plugins/tiddlywiki/xlsx-utils/importer.js").XLSXImporter,
|
||||
importer = new XLSXImporter({
|
||||
filename: filename,
|
||||
importSpec: importSpec
|
||||
importSpec: importSpec,
|
||||
wiki: wiki
|
||||
});
|
||||
$tw.wiki.addTiddlers(importer.getResults());
|
||||
wiki.addTiddlers(importer.getResults());
|
||||
return null;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user