mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Warn when importing core tiddlers
See https://groups.google.com/d/msg/tiddlywiki/YZlPGP0qX1o/3tUpyoHXDgAJ
This commit is contained in:
parent
c4b39af052
commit
38b088eabf
@ -19,3 +19,4 @@ Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>
|
||||
Upgrader/State/Suppressed: Blocked temporary state tiddler
|
||||
Upgrader/System/Suppressed: Blocked system tiddler
|
||||
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!
|
||||
|
@ -485,7 +485,8 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
|
||||
// Import JSON tiddlers into a pending import tiddler
|
||||
NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
// Get the tiddlers
|
||||
var tiddlers = [];
|
||||
var tiddlers = [],
|
||||
warning = [];
|
||||
try {
|
||||
tiddlers = JSON.parse(event.param);
|
||||
} catch(e) {
|
||||
@ -506,10 +507,26 @@ 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