mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-11 19:28:05 +00:00
allow us to import formerly blocked system tiddlers (#5479)
This commit is contained in:
@@ -23,7 +23,11 @@ Upgrader/Plugins/Suppressed/Incompatible: Blocked incompatible or obsolete plugi
|
|||||||
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> not being newer than existing <<existing>>).
|
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> not being newer than existing <<existing>>).
|
||||||
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>.
|
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>.
|
||||||
Upgrader/State/Suppressed: Blocked temporary state tiddler.
|
Upgrader/State/Suppressed: Blocked temporary state tiddler.
|
||||||
|
Upgrader/System/Disabled: Disabled system tiddler.
|
||||||
Upgrader/System/Suppressed: Blocked system tiddler.
|
Upgrader/System/Suppressed: Blocked system tiddler.
|
||||||
Upgrader/System/Warning: Core module tiddler.
|
Upgrader/System/Warning: Core module tiddler.
|
||||||
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable.
|
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable.
|
||||||
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
|
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
|
||||||
|
Upgrader/Tiddler/Disabled: Disabled tiddler.
|
||||||
|
Upgrader/Tiddler/Selected: User selected.
|
||||||
|
Upgrader/Tiddler/Unselected: Unselected tiddler.
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ Upgrader module that suppresses certain system tiddlers that shouldn't be import
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var DONT_IMPORT_LIST = ["$:/StoryList","$:/HistoryList"],
|
var DONT_IMPORT_LIST = ["$:/Import"],
|
||||||
DONT_IMPORT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/Import"],
|
UNSELECT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/StoryList","$:/HistoryList"],
|
||||||
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
|
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
|
||||||
|
|
||||||
exports.upgrade = function(wiki,titles,tiddlers) {
|
exports.upgrade = function(wiki,titles,tiddlers) {
|
||||||
@@ -26,11 +26,10 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
|||||||
tiddlers[title] = Object.create(null);
|
tiddlers[title] = Object.create(null);
|
||||||
messages[title] = $tw.language.getString("Import/Upgrader/System/Suppressed");
|
messages[title] = $tw.language.getString("Import/Upgrader/System/Suppressed");
|
||||||
} else {
|
} else {
|
||||||
for(var t=0; t<DONT_IMPORT_PREFIX_LIST.length; t++) {
|
for(var t=0; t<UNSELECT_PREFIX_LIST.length; t++) {
|
||||||
var prefix = DONT_IMPORT_PREFIX_LIST[t];
|
var prefix = UNSELECT_PREFIX_LIST[t];
|
||||||
if(title.substr(0,prefix.length) === prefix) {
|
if(title.substr(0,prefix.length) === prefix) {
|
||||||
tiddlers[title] = Object.create(null);
|
messages[title] = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
|
||||||
messages[title] = $tw.language.getString("Import/Upgrader/State/Suppressed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {
|
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {
|
||||||
|
|||||||
@@ -522,10 +522,15 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
|||||||
});
|
});
|
||||||
// Give the active upgrader modules a chance to process the incoming tiddlers
|
// Give the active upgrader modules a chance to process the incoming tiddlers
|
||||||
var messages = this.wiki.invokeUpgraders(incomingTiddlers,importData.tiddlers);
|
var messages = this.wiki.invokeUpgraders(incomingTiddlers,importData.tiddlers);
|
||||||
|
// Deselect any disabled, but _not_ suppressed tiddlers
|
||||||
|
var systemMessage = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
|
||||||
$tw.utils.each(messages,function(message,title) {
|
$tw.utils.each(messages,function(message,title) {
|
||||||
newFields["message-" + title] = message;
|
newFields["message-" + title] = message;
|
||||||
|
if (message.indexOf(systemMessage) !== -1) {
|
||||||
|
newFields["selection-" + title] = "unchecked";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Deselect any suppressed tiddlers
|
// Deselect suppressed tiddlers ... they have been removed and can't be selected anymore
|
||||||
$tw.utils.each(importData.tiddlers,function(tiddler,title) {
|
$tw.utils.each(importData.tiddlers,function(tiddler,title) {
|
||||||
if($tw.utils.count(tiddler) === 0) {
|
if($tw.utils.count(tiddler) === 0) {
|
||||||
newFields["selection-" + title] = "unchecked";
|
newFields["selection-" + title] = "unchecked";
|
||||||
|
|||||||
@@ -12,6 +12,24 @@ title: $:/core/ui/ImportListing
|
|||||||
</$list>
|
</$list>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
|
\define selectionInfo()
|
||||||
|
\whitespace trim
|
||||||
|
<$set name="escUnselected" value={{{[{$:/language/Import/Upgrader/Tiddler/Unselected}escaperegexp[]addprefix[(?g)]]}}}>
|
||||||
|
<$list filter="[all[current]get<messageField>regexp<escUnselected>]" variable="ignore">
|
||||||
|
<$text text={{{[all[current]get<selectionField>match[checked]then{$:/language/Import/Upgrader/Tiddler/Selected}else[]]}}}/>
|
||||||
|
</$list>
|
||||||
|
</$set>
|
||||||
|
\end
|
||||||
|
|
||||||
|
\define libraryInfo()
|
||||||
|
\whitespace trim
|
||||||
|
<$set name="escUnselected" value={{{[{$:/language/Import/Upgrader/Tiddler/Unselected}escaperegexp[]addprefix[(?g)]]}}}>
|
||||||
|
<$list filter="[all[current]get<messageField>!regexp<escUnselected>]" variable="ignore">
|
||||||
|
<$text text={{{[all[current]get<messageField>]}}}/>
|
||||||
|
</$list>
|
||||||
|
</$set>
|
||||||
|
\end
|
||||||
|
|
||||||
\define selectionField() selection-$(payloadTiddler)$
|
\define selectionField() selection-$(payloadTiddler)$
|
||||||
|
|
||||||
\define renameField() rename-$(payloadTiddler)$
|
\define renameField() rename-$(payloadTiddler)$
|
||||||
@@ -69,7 +87,8 @@ title: $:/core/ui/ImportListing
|
|||||||
</$reveal>
|
</$reveal>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<$view field=<<messageField>>/>
|
<<selectionInfo>>
|
||||||
|
<<libraryInfo>>
|
||||||
<<overWriteWarning>>
|
<<overWriteWarning>>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user