From 04d26e6fae20671a6d455e113f7b0afedabc7122 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 27 Oct 2014 21:50:25 +0000 Subject: [PATCH] First pass at an `--editions` command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also added a “description” field for wiki folders. Right now there’s too many editions listed. I think we should by default only list editions whose `tiddlywiki.info` file has `showInListings` set to `true`, and have an `--editions all` command that lists everything. @pmario please could you check that the editions in your `TIDDLYWIKI_EDITION_PATH` are correctly listed? --- core/language/en-GB/Help/editions.tid | 8 +++ core/language/en-GB/Help/init.tid | 2 +- core/modules/commands/editions.js | 62 ++++++++++++++++++++++ editions/classicparserdemo/tiddlywiki.info | 1 + editions/codemirrordemo/tiddlywiki.info | 1 + editions/d3demo/tiddlywiki.info | 1 + editions/de-AT-server/tiddlywiki.info | 1 + editions/de-AT/tiddlywiki.info | 1 + editions/de-DE/tiddlywiki.info | 1 + editions/dev/tiddlywiki.info | 1 + editions/empty/tiddlywiki.info | 1 + editions/fr-FR/tiddlywiki.info | 1 + editions/highlightdemo/tiddlywiki.info | 1 + editions/katexdemo/tiddlywiki.info | 1 + editions/markdowndemo/tiddlywiki.info | 1 + editions/prerelease/tiddlywiki.info | 1 + editions/server/tiddlywiki.info | 1 + editions/tahoelafs/tiddlywiki.info | 1 + editions/test/tiddlywiki.info | 1 + editions/testcommonjs/tiddlywiki.info | 1 + editions/translators/tiddlywiki.info | 1 + editions/tw2/tiddlywiki.info | 1 + editions/tw5.com-server/tiddlywiki.info | 1 + editions/tw5.com/tiddlywiki.info | 1 + editions/tw5tank/tiddlywiki.info | 1 + editions/tw5tiddlyweb/tiddlywiki.info | 1 + editions/upgrade/tiddlywiki.info | 1 + editions/zh-Hans/tiddlywiki.info | 1 + editions/zh-Hant/tiddlywiki.info | 1 + languages/de-DE/Help/init.tid | 2 +- languages/fr-FR/Help/init.tid | 2 +- languages/it-IT/Help/init.tid | 2 +- languages/ja-JP/Help/init.tid | 2 +- languages/ru-RU/Help/init.tid | 2 +- languages/zh-Hans/Help/init.tid | 2 +- languages/zh-Hant/Help/init.tid | 2 +- 36 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 core/language/en-GB/Help/editions.tid create mode 100644 core/modules/commands/editions.js diff --git a/core/language/en-GB/Help/editions.tid b/core/language/en-GB/Help/editions.tid new file mode 100644 index 000000000..42ccab998 --- /dev/null +++ b/core/language/en-GB/Help/editions.tid @@ -0,0 +1,8 @@ +title: $:/language/Help/editions +description: Lists the available editions of TiddlyWiki + +Lists the names and descriptions of the available editions. You can create a new wiki of a specified edition with the `--init` command. + +``` +--editions +``` diff --git a/core/language/en-GB/Help/init.tid b/core/language/en-GB/Help/init.tid index 71a7be224..c144b0d68 100644 --- a/core/language/en-GB/Help/init.tid +++ b/core/language/en-GB/Help/init.tid @@ -20,4 +20,4 @@ Note: * The init command will fail if the wiki folder is not empty * The init command removes any `includeWikis` definitions in the edition's `tiddlywiki.info` file * When multiple editions are specified, editions initialised later will overwrite any files shared with earlier editions (so, the final `tiddlywiki.info` file will be copied from the last edition) -* `--help editions` returns a list of available editions +* `--editions` returns a list of available editions diff --git a/core/modules/commands/editions.js b/core/modules/commands/editions.js new file mode 100644 index 000000000..271b62e71 --- /dev/null +++ b/core/modules/commands/editions.js @@ -0,0 +1,62 @@ +/*\ +title: $:/core/modules/commands/editions.js +type: application/javascript +module-type: command + +Command to list the available editions + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.info = { + name: "editions", + synchronous: true +}; + +var Command = function(params,commander) { + this.params = params; + this.commander = commander; +}; + +Command.prototype.execute = function() { + var fs = require("fs"), + path = require("path"), + self = this; + // Enumerate the edition paths + var editionPaths = $tw.getLibraryItemSearchPaths($tw.config.editionsPath,$tw.config.editionsEnvVar), + editions = {}; + for(var editionIndex=0; editionIndex