mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Implement in $:/core/upgraders instead of navigator.js
The core module tiddlers are not blocked, they are only marked.
This commit is contained in:
parent
38b088eabf
commit
18ed2faf82
@ -18,5 +18,6 @@ Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>
|
||||
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>
|
||||
Upgrader/State/Suppressed: Blocked temporary state tiddler
|
||||
Upgrader/System/Suppressed: Blocked system tiddler
|
||||
Upgrader/System/Warning: Warning: Core module tiddler
|
||||
Upgrader/System/Alert: You are about importing core module tiddlers. It is strongly recommend in the strongest terms NOT to use any hack that requires overwriting a core module, because it is likely to make the system unusable. Never import such tiddlers into an important wiki, just into a testing environment!
|
||||
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>
|
||||
Warning/Core: You are about importing risky tiddlers (<<titles>>). It is strongly recommend in the strongest terms NOT to use any hack that requires overwriting a core module, because it is likely to make the system unusable. Never import such tiddlers into an important wiki, just into a testing environment!
|
||||
|
@ -13,11 +13,13 @@ Upgrader module that suppresses certain system tiddlers that shouldn't be import
|
||||
"use strict";
|
||||
|
||||
var DONT_IMPORT_LIST = ["$:/StoryList","$:/HistoryList"],
|
||||
DONT_IMPORT_PREFIX_LIST = ["$:/temp/","$:/state/"];
|
||||
DONT_IMPORT_PREFIX_LIST = ["$:/temp/","$:/state/"],
|
||||
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
|
||||
|
||||
exports.upgrade = function(wiki,titles,tiddlers) {
|
||||
var self = this,
|
||||
messages = {};
|
||||
messages = {},
|
||||
showAlert = false;
|
||||
// Check for tiddlers on our list
|
||||
$tw.utils.each(titles,function(title) {
|
||||
if(DONT_IMPORT_LIST.indexOf(title) !== -1) {
|
||||
@ -31,6 +33,17 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
||||
messages[title] = $tw.language.getString("Import/Upgrader/State/Suppressed");
|
||||
}
|
||||
}
|
||||
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {
|
||||
var prefix = WARN_IMPORT_PREFIX_LIST[t];
|
||||
if(title.substr(0,prefix.length) === prefix) {
|
||||
showAlert = true;
|
||||
messages[title] = $tw.language.getString("Import/Upgrader/System/Warning");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(showAlert) {
|
||||
var logger = new $tw.utils.Logger("import");
|
||||
logger.alert($tw.language.getString("Import/Upgrader/System/Alert"));
|
||||
}
|
||||
});
|
||||
return messages;
|
||||
|
@ -485,8 +485,7 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
|
||||
// Import JSON tiddlers into a pending import tiddler
|
||||
NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
// Get the tiddlers
|
||||
var tiddlers = [],
|
||||
warning = [];
|
||||
var tiddlers = [];
|
||||
try {
|
||||
tiddlers = JSON.parse(event.param);
|
||||
} catch(e) {
|
||||
@ -507,26 +506,10 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
tiddlerFields.title = $tw.utils.trim(tiddlerFields.title);
|
||||
var title = tiddlerFields.title;
|
||||
if(title) {
|
||||
if(title.indexOf('$:/core/') === 0) {
|
||||
warning.push(title);
|
||||
}
|
||||
incomingTiddlers.push(title);
|
||||
importData.tiddlers[title] = tiddlerFields;
|
||||
}
|
||||
});
|
||||
// Show warning about risky tiddlers
|
||||
if(warning.length) {
|
||||
var titles = [];
|
||||
$tw.utils.each(warning,function(title) {
|
||||
titles.push(title);
|
||||
});
|
||||
var logger = new $tw.utils.Logger("import");
|
||||
logger.alert($tw.language.getString(
|
||||
"Import/Warning/Core",
|
||||
{variables: {
|
||||
"titles": titles.join(", "),
|
||||
}}));
|
||||
}
|
||||
// Give the active upgrader modules a chance to process the incoming tiddlers
|
||||
var messages = this.wiki.invokeUpgraders(incomingTiddlers,importData.tiddlers);
|
||||
$tw.utils.each(messages,function(message,title) {
|
||||
|
Loading…
Reference in New Issue
Block a user