Merge backlog of changes from master branch

This is too easy. I'm worried.
This commit is contained in:
Jeremy Ruston
2013-11-08 08:33:27 +00:00
38 changed files with 578 additions and 53 deletions
+14 -1
View File
@@ -379,7 +379,7 @@ exports.findNextTag = function(source,pos,options) {
// Try to parse the candidate as a tag
var tag = this.parseTag(source,match.index,options);
// Return success
if(tag) {
if(tag && this.isLegalTag(tag.tag)) {
return tag;
}
// Look for the next match
@@ -390,4 +390,17 @@ exports.findNextTag = function(source,pos,options) {
return null;
};
exports.isLegalTag = function(tag) {
// If it starts with a $ then we'll let anything go
if(tag.charAt(0) === "$") {
return true;
// If it starts with a dash then it's not legal
} else if(tag.charAt(0) === "-") {
return false;
} else {
// Otherwise it's OK
return true;
}
};
})();
+16 -14
View File
@@ -875,38 +875,40 @@ exports.search = function(text,options) {
// Function to check a given tiddler for the search term
var searchTiddler = function(title) {
if(!searchTermsRegExps) {
return !options.invert;
return false;
}
var tiddler = self.getTiddler(title);
if(!tiddler) {
tiddler = new $tw.Tiddler({title: title, text: "", type: "text/vnd.tiddlywiki"});
}
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type];
if(contentTypeInfo ? contentTypeInfo.encoding === "utf8" : true) {
var match = true;
for(var t=0; t<searchTermsRegExps.length; t++) {
// Search title and body
if(match) {
var tags = tiddler.fields.tags ? tiddler.fields.tags.join("\0") : "";
match = searchTermsRegExps[t].test(tiddler.fields.title) || searchTermsRegExps[t].test(tags) || searchTermsRegExps[t].test(tiddler.fields.text);
}
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type] || $tw.config.contentTypeInfo["text/vnd.tiddlywiki"],
match;
for(var t=0; t<searchTermsRegExps.length; t++) {
// Search title, tags and body
match = false;
if(contentTypeInfo.encoding === "utf8") {
match = match || searchTermsRegExps[t].test(tiddler.fields.text);
}
var tags = tiddler.fields.tags ? tiddler.fields.tags.join("\0") : "";
match = match || searchTermsRegExps[t].test(tags) || searchTermsRegExps[t].test(tiddler.fields.title);
if(!match) {
return false;
}
return options.invert ? !match : match;
}
return false;
return true;
};
// Loop through all the tiddlers doing the search
var results = [];
if($tw.utils.isArray(options.titles)) {
for(t=0; t<options.titles.length; t++) {
if(searchTiddler(options.titles[t])) {
if(!!searchTiddler(options.titles[t]) === !options.invert) {
results.push(options.titles[t]);
}
}
} else {
var source = options.titles || this.tiddlers;
for(t in source) {
if(searchTiddler(t)) {
if(!!searchTiddler(t) === !options.invert) {
results.push(t);
}
}