mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 10:37:20 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
e6daa6c4f0
@ -20,9 +20,15 @@ $tw = $tw || Object.create(null);
|
||||
$tw.boot = $tw.boot || Object.create(null);
|
||||
|
||||
// Detect platforms
|
||||
if(!("browser" in $tw)) {
|
||||
$tw.browser = typeof(window) !== "undefined" ? {} : null;
|
||||
}
|
||||
if(!("node" in $tw)) {
|
||||
$tw.node = typeof(process) === "object" ? {} : null;
|
||||
}
|
||||
if(!("nodeWebKit" in $tw)) {
|
||||
$tw.nodeWebKit = $tw.node && global.window && global.window.nwDispatcher ? {} : null;
|
||||
}
|
||||
|
||||
// Set default boot tasks
|
||||
$tw.boot.tasks = {
|
||||
|
@ -23,35 +23,12 @@ var Command = function(params,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<editionPaths.length; editionIndex++) {
|
||||
var editionPath = editionPaths[editionIndex];
|
||||
// Enumerate the folders
|
||||
var entries = fs.readdirSync(editionPath);
|
||||
for(var entryIndex=0; entryIndex<entries.length; entryIndex++) {
|
||||
var entry = entries[entryIndex];
|
||||
// Check if directories have a valid tiddlywiki.info
|
||||
if(!editions[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
|
||||
var info;
|
||||
try {
|
||||
info = JSON.parse(fs.readFileSync(path.resolve(editionPath,entry,"tiddlywiki.info"),"utf8"));
|
||||
} catch(ex) {
|
||||
}
|
||||
if(info) {
|
||||
editions[entry] = info.description || "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var self = this;
|
||||
// Output the list
|
||||
this.commander.streams.output.write("Available editions:\n\n");
|
||||
$tw.utils.each(editions,function(description,name) {
|
||||
self.commander.streams.output.write(" " + name + ": " + description + "\n");
|
||||
var editionInfo = $tw.utils.getEditionInfo();
|
||||
$tw.utils.each(editionInfo,function(info,name) {
|
||||
self.commander.streams.output.write(" " + name + ": " + info.description + "\n");
|
||||
});
|
||||
this.commander.streams.output.write("\n");
|
||||
return null;
|
||||
|
31
core/modules/filters/editiondescription.js
Normal file
31
core/modules/filters/editiondescription.js
Normal file
@ -0,0 +1,31 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/editiondescription.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the descriptions of the specified edition names
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.editiondescription = function(source,operator,options) {
|
||||
var results = [],
|
||||
editionInfo = $tw.utils.getEditionInfo();
|
||||
if(editionInfo) {
|
||||
source(function(tiddler,title) {
|
||||
if($tw.utils.hop(editionInfo,title)) {
|
||||
results.push(editionInfo[title].description || "");
|
||||
}
|
||||
});
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
30
core/modules/filters/editions.js
Normal file
30
core/modules/filters/editions.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/editions.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the names of the available editions in this wiki
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.editions = function(source,operator,options) {
|
||||
var results = [],
|
||||
editionInfo = $tw.utils.getEditionInfo();
|
||||
if(editionInfo) {
|
||||
$tw.utils.each(editionInfo,function(info,name) {
|
||||
results.push(name);
|
||||
});
|
||||
}
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
48
core/modules/utils/edition-info.js
Normal file
48
core/modules/utils/edition-info.js
Normal file
@ -0,0 +1,48 @@
|
||||
/*\
|
||||
title: $:/core/modules/utils/edition-info.js
|
||||
type: application/javascript
|
||||
module-type: utils-node
|
||||
|
||||
Information about the available editions
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path");
|
||||
|
||||
var editionInfo;
|
||||
|
||||
exports.getEditionInfo = function() {
|
||||
if(!editionInfo) {
|
||||
// Enumerate the edition paths
|
||||
var editionPaths = $tw.getLibraryItemSearchPaths($tw.config.editionsPath,$tw.config.editionsEnvVar);
|
||||
editionInfo = {};
|
||||
for(var editionIndex=0; editionIndex<editionPaths.length; editionIndex++) {
|
||||
var editionPath = editionPaths[editionIndex];
|
||||
// Enumerate the folders
|
||||
var entries = fs.readdirSync(editionPath);
|
||||
for(var entryIndex=0; entryIndex<entries.length; entryIndex++) {
|
||||
var entry = entries[entryIndex];
|
||||
// Check if directories have a valid tiddlywiki.info
|
||||
if(!editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
|
||||
var info;
|
||||
try {
|
||||
info = JSON.parse(fs.readFileSync(path.resolve(editionPath,entry,"tiddlywiki.info"),"utf8"));
|
||||
} catch(ex) {
|
||||
}
|
||||
if(info) {
|
||||
editionInfo[entry] = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return editionInfo;
|
||||
};
|
||||
|
||||
})();
|
@ -42,10 +42,13 @@ BrowseWidget.prototype.render = function(parent,nextSibling) {
|
||||
if(this.tooltip) {
|
||||
domNode.setAttribute("title",this.tooltip);
|
||||
}
|
||||
if(this.nwsaveas) {
|
||||
domNode.setAttribute("nwsaveas",this.nwsaveas);
|
||||
}
|
||||
// Add a click event handler
|
||||
domNode.addEventListener("change",function (event) {
|
||||
if(self.message) {
|
||||
self.dispatchEvent({type: self.message, param: event.target.files});
|
||||
self.dispatchEvent({type: self.message, param: self.param, files: event.target.files});
|
||||
} else {
|
||||
self.wiki.readFiles(event.target.files,function(tiddlerFieldsArray) {
|
||||
self.dispatchEvent({type: "tm-import-tiddlers", param: JSON.stringify(tiddlerFieldsArray)});
|
||||
@ -65,7 +68,9 @@ Compute the internal state of the widget
|
||||
BrowseWidget.prototype.execute = function() {
|
||||
this.browseMultiple = this.getAttribute("multiple");
|
||||
this.message = this.getAttribute("message");
|
||||
this.param = this.getAttribute("param");
|
||||
this.tooltip = this.getAttribute("tooltip");
|
||||
this.nwsaveas = this.getAttribute("nwsaveas");
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -0,0 +1,10 @@
|
||||
created: 20150111145738451
|
||||
modified: 20150111145738451
|
||||
tags: Filters
|
||||
caption: editiondescription
|
||||
title: FilterOperator: editiondescription
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The ''editiondescription'' filter operator returns a description string for each edition name in the current results. It is only available under Node.js.
|
||||
|
||||
Also see [[FilterOperator: editions]].
|
8
editions/prerelease/tiddlers/FilterOperator editions.tid
Normal file
8
editions/prerelease/tiddlers/FilterOperator editions.tid
Normal file
@ -0,0 +1,8 @@
|
||||
created: 20150111145738451
|
||||
modified: 20150111145738451
|
||||
tags: Filters
|
||||
caption: editions
|
||||
title: FilterOperator: editions
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The ''editions'' filter operator returns the names of all the available editions. It is only available under Node.js.
|
Loading…
Reference in New Issue
Block a user