From 17a594a97ad5655142c834dfd5fa68855a61d201 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 29 Oct 2014 11:43:43 +0000 Subject: [PATCH] Add unpackplugin command Needed for the translators edition --- core/language/en-GB/Help/unpackplugin.tid | 8 ++++ core/modules/commands/unpackplugin.js | 44 +++++++++++++++++++ .../commands/UnpackPluginsCommand.tid | 8 ++++ 3 files changed, 60 insertions(+) create mode 100644 core/language/en-GB/Help/unpackplugin.tid create mode 100644 core/modules/commands/unpackplugin.js create mode 100644 editions/tw5.com/tiddlers/commands/UnpackPluginsCommand.tid diff --git a/core/language/en-GB/Help/unpackplugin.tid b/core/language/en-GB/Help/unpackplugin.tid new file mode 100644 index 000000000..83bb59225 --- /dev/null +++ b/core/language/en-GB/Help/unpackplugin.tid @@ -0,0 +1,8 @@ +title: $:/language/Help/unpackplugin +description: Unpack the payload tiddlers from a plugin + +Extract the payload tiddlers from a plugin, creating them as ordinary tiddlers: + +``` +--unpackplugin +``` diff --git a/core/modules/commands/unpackplugin.js b/core/modules/commands/unpackplugin.js new file mode 100644 index 000000000..abc754bcb --- /dev/null +++ b/core/modules/commands/unpackplugin.js @@ -0,0 +1,44 @@ +/*\ +title: $:/core/modules/commands/unpackplugin.js +type: application/javascript +module-type: command + +Command to extract the shadow tiddlers from within a plugin + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.info = { + name: "unpackplugin", + synchronous: true +}; + +var Command = function(params,commander,callback) { + this.params = params; + this.commander = commander; + this.callback = callback; +}; + +Command.prototype.execute = function() { + if(this.params.length < 1) { + return "Missing plugin name"; + } + var self = this, + title = this.params[0], + pluginData = this.commander.wiki.getTiddlerData(title); + if(!pluginData) { + return "Plugin '" + title + "' not found"; + } + $tw.utils.each(pluginData.tiddlers,function(tiddler) { + self.commander.wiki.addTiddler(new $tw.Tiddler(tiddler)); + }); + return null; +}; + +exports.Command = Command; + +})(); diff --git a/editions/tw5.com/tiddlers/commands/UnpackPluginsCommand.tid b/editions/tw5.com/tiddlers/commands/UnpackPluginsCommand.tid new file mode 100644 index 000000000..5812bb098 --- /dev/null +++ b/editions/tw5.com/tiddlers/commands/UnpackPluginsCommand.tid @@ -0,0 +1,8 @@ +created: 20141029114305697 +modified: 20141029114305697 +tags: Commands +title: UnpackPluginsCommand +type: text/vnd.tiddlywiki +caption: output + +{{$:/language/Help/unpackplugins}}