2014-07-12 08:09:36 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/upgraders/system.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: upgrader
|
|
|
|
|
|
|
|
Upgrader module that suppresses certain system tiddlers that shouldn't be imported
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2024-08-03 12:16:05 +00:00
|
|
|
var DONT_IMPORT_LIST = ["$:/Import", "$:/build"],
|
2021-05-25 21:21:57 +00:00
|
|
|
UNSELECT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/StoryList","$:/HistoryList"],
|
2018-12-10 21:32:32 +00:00
|
|
|
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
|
2014-07-12 08:09:36 +00:00
|
|
|
|
|
|
|
exports.upgrade = function(wiki,titles,tiddlers) {
|
|
|
|
var self = this,
|
2018-12-10 21:32:32 +00:00
|
|
|
messages = {},
|
|
|
|
showAlert = false;
|
2014-07-12 08:09:36 +00:00
|
|
|
// Check for tiddlers on our list
|
|
|
|
$tw.utils.each(titles,function(title) {
|
|
|
|
if(DONT_IMPORT_LIST.indexOf(title) !== -1) {
|
|
|
|
tiddlers[title] = Object.create(null);
|
|
|
|
messages[title] = $tw.language.getString("Import/Upgrader/System/Suppressed");
|
2014-08-20 12:52:59 +00:00
|
|
|
} else {
|
2021-05-25 21:21:57 +00:00
|
|
|
for(var t=0; t<UNSELECT_PREFIX_LIST.length; t++) {
|
|
|
|
var prefix = UNSELECT_PREFIX_LIST[t];
|
2014-08-20 12:52:59 +00:00
|
|
|
if(title.substr(0,prefix.length) === prefix) {
|
2021-05-25 21:21:57 +00:00
|
|
|
messages[title] = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
|
2014-08-20 12:52:59 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-10 21:32:32 +00:00
|
|
|
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {
|
|
|
|
var prefix = WARN_IMPORT_PREFIX_LIST[t];
|
2019-08-28 13:44:46 +00:00
|
|
|
if(title.substr(0,prefix.length) === prefix && wiki.isShadowTiddler(title)) {
|
2018-12-10 21:32:32 +00:00
|
|
|
showAlert = true;
|
|
|
|
messages[title] = $tw.language.getString("Import/Upgrader/System/Warning");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-12 08:09:36 +00:00
|
|
|
});
|
2019-08-28 13:44:46 +00:00
|
|
|
if(showAlert) {
|
|
|
|
var logger = new $tw.utils.Logger("import");
|
|
|
|
logger.alert($tw.language.getString("Import/Upgrader/System/Alert"));
|
|
|
|
}
|
2014-07-12 08:09:36 +00:00
|
|
|
return messages;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|