Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kin filter: Recursively looking for kinship between tiddler titles #3511

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f5790f0
Filter operator that gathering "family" of tiddler
bimlas Oct 17, 2018
fff1ca0
Remove unneeded code
bimlas Oct 19, 2018
c8dee83
Do not use global `$tw`
bimlas Oct 19, 2018
5890ea9
Use as a real filter
bimlas Oct 19, 2018
304937d
List the kindred of input tiddles if there is no operand
bimlas Oct 24, 2018
de6bf92
Add negation option
bimlas Oct 26, 2018
55a28ef
Use to/with/from instead of up/both/down
bimlas Oct 25, 2018
bb0aa4e
Add documentation
bimlas Oct 27, 2018
7d3834a
Rename from `kindred` to `kin`
bimlas Oct 27, 2018
fdfe6de
Visualization of the filter results in the examples
bimlas Oct 31, 2018
05b9a53
Solve the problem with cyclical connections
bimlas Nov 1, 2018
f31afea
Modify examples, clarify documentation
bimlas Nov 1, 2018
ccc4d87
Change indentation, make it more readable
bimlas Nov 6, 2018
8a84087
Modify to suit to coding style
bimlas Nov 6, 2018
1d71b34
Merge remote-tracking branch 'upstream/master' into kin-filter
bimlas Nov 7, 2018
0ae7bf2
Use the new, builtin syntax for suffixes
bimlas Nov 7, 2018
dbc2d75
Prepare code to allow additional suffix options
bimlas Nov 7, 2018
152c903
Add `depth` option to specify max depth (0 means no limit)
bimlas Nov 7, 2018
2814191
Update documentation, be more verbose
bimlas Nov 7, 2018
3750994
Flip arrows on the picture; purpose of trees in examples
bimlas Nov 8, 2018
6437124
Use "older" standards; add tests
bimlas Nov 9, 2018
d6ae19b
Rename `findListingsOfTiddler` to `findTiddlersByField`
bimlas Nov 9, 2018
1832e43
Drop `describe` block of `kin` test, `it` is enough
bimlas Nov 9, 2018
ea5ab1e
Found a usage of `includes()`, changed to `indexOf()`
bimlas Nov 9, 2018
881bc32
Additional tests
bimlas Nov 9, 2018
e37596a
Accidentally changed DefaultTiddlers
bimlas Nov 20, 2018
1906752
Increment in a separate statement
bimlas Nov 20, 2018
cbbc88d
Keep `findListingsOfTiddler()` as alias of `findTiddlersByField()`
bimlas Nov 20, 2018
717e6f5
Use cache mechanism
bimlas Nov 20, 2018
660b4d3
Revert accidentally changed whitespace
bimlas Dec 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions core/modules/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports.deleteTextReference = function(textRef,currTiddlerTitle) {
exports.addEventListener = function(type,listener) {
this.eventListeners = this.eventListeners || {};
this.eventListeners[type] = this.eventListeners[type] || [];
this.eventListeners[type].push(listener);
this.eventListeners[type].push(listener);
};

exports.removeEventListener = function(type,listener) {
Expand Down Expand Up @@ -186,8 +186,8 @@ exports.generateNewTitle = function(baseTitle,options) {
var c = 0,
title = baseTitle;
while(this.tiddlerExists(title) || this.isShadowTiddler(title) || this.findDraft(title)) {
title = baseTitle +
(options.prefix || " ") +
title = baseTitle +
(options.prefix || " ") +
(++c);
}
return title;
Expand All @@ -203,7 +203,7 @@ exports.isTemporaryTiddler = function(title) {

exports.isImageTiddler = function(title) {
var tiddler = this.getTiddler(title);
if(tiddler) {
if(tiddler) {
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/vnd.tiddlywiki"];
return !!contentTypeInfo && contentTypeInfo.flags.indexOf("image") !== -1;
} else {
Expand Down Expand Up @@ -334,7 +334,7 @@ exports.sortTiddlers = function(titles,sortField,isDescending,isCaseSensitive,is
titles.sort(function(a,b) {
var x,y,
compareNumbers = function(x,y) {
var result =
var result =
isNaN(x) && !isNaN(y) ? (isDescending ? -1 : 1) :
!isNaN(x) && isNaN(y) ? (isDescending ? 1 : -1) :
(isDescending ? y - x : x - y);
Expand Down Expand Up @@ -670,7 +670,7 @@ exports.getTiddlerDataCached = function(titleOrTiddler,defaultData) {
var self = this,
tiddler = titleOrTiddler;
if(!(tiddler instanceof $tw.Tiddler)) {
tiddler = this.getTiddler(tiddler);
tiddler = this.getTiddler(tiddler);
}
if(tiddler) {
return this.getCacheForTiddler(tiddler.fields.title,"data",function() {
Expand All @@ -691,7 +691,7 @@ exports.getTiddlerData = function(titleOrTiddler,defaultData) {
var tiddler = titleOrTiddler,
data;
if(!(tiddler instanceof $tw.Tiddler)) {
tiddler = this.getTiddler(tiddler);
tiddler = this.getTiddler(tiddler);
}
if(tiddler && tiddler.fields.text) {
switch(tiddler.fields.type) {
Expand Down Expand Up @@ -821,7 +821,7 @@ exports.initParsers = function(moduleType) {
if(!$tw.utils.hop($tw.Wiki.parsers,type) && $tw.config.contentTypeInfo[type].encoding === "base64") {
$tw.Wiki.parsers[type] = $tw.Wiki.parsers["application/octet-stream"];
}
});
});
}
};

Expand Down Expand Up @@ -885,7 +885,7 @@ exports.parseTextReference = function(title,field,index,options) {
}
if(field === "text" || (!field && !index)) {
if(tiddler && tiddler.fields) {
return this.parseText(tiddler.fields.type,tiddler.fields.text,options);
return this.parseText(tiddler.fields.type,tiddler.fields.text,options);
} else {
return null;
}
Expand Down Expand Up @@ -1083,7 +1083,7 @@ exports.search = function(text,options) {
searchTermsRegExps = [new RegExp("(" + terms.join("\\s+") + ")",flags)];
} else if(options.regexp) {
try {
searchTermsRegExps = [new RegExp("(" + text + ")",flags)];
searchTermsRegExps = [new RegExp("(" + text + ")",flags)];
} catch(e) {
searchTermsRegExps = null;
console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e);
Expand All @@ -1105,7 +1105,7 @@ exports.search = function(text,options) {
if($tw.utils.isArray(options.field)) {
$tw.utils.each(options.field,function(fieldName) {
if(fieldName) {
fields.push(fieldName);
fields.push(fieldName);
}
});
} else {
Expand Down