Skip to content

Commit

Permalink
Merge branch 'release-1.14.5'
Browse files Browse the repository at this point in the history
* release-1.14.5:
  Update version info.
  output: decrease indent width
  fulltext: rework search syntax
  output: rework search syntax
  output: fix double quote escaping
  fulltext: fix double quote escaping
  lang: revise zh-TW
  • Loading branch information
danny0838 committed Dec 8, 2017
2 parents 8af7753 + 79ed193 commit 68d4174
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 177 deletions.
161 changes: 76 additions & 85 deletions chrome/content/scrapbook/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,13 @@ var sbOutputService = {
+ ' "re": false,\n'
+ ' "default": this.config["default_field"]\n'
+ ' };\n'
+ ' keyStr.replace(/(\\-?[A-Za-z]+:|\\-)(?:"((?:\\\\"|[^"])*)"|([^ "\\u3000]*))|(?:"((?:""|[^"])*)"|([^ "\\u3000]+))/g, function(match, cmd, qterm, term, qterm2, term2){\n'
+ ' keyStr.replace(/(-?[A-Za-z]+:|-)(?:"((?:""|[^"])*)"|([^"\\s]*))|(?:"((?:""|[^"])*)"|([^"\\s]+))/g, function(match, cmd, qterm, term, qterm2, term2){\n'
+ ' if (cmd) {\n'
+ ' var term = qterm ? qterm.replace(/""/g, \'"\') : term;\n'
+ ' var term = (qterm !== undefined) ? qterm.replace(/""/g, \'"\') : term;\n'
+ ' }\n'
+ ' else {\n'
+ ' var term = qterm2 ? qterm2.replace(/""/g, \'"\') : term2;\n'
+ ' var term = (qterm2 !== undefined) ? qterm2.replace(/""/g, \'"\') : term2;\n'
+ ' }\n'
+ ' // commands that don\'t require a term\n'
+ ' // the term will then be reguarded as a "tcc include"\n'
+ ' switch (cmd) {\n'
+ ' case "mc:":\n'
+ ' key.mc = true;\n'
Expand All @@ -546,87 +544,78 @@ var sbOutputService = {
+ ' case "-re:":\n'
+ ' key.re = false;\n'
+ ' break;\n'
+ ' case "type:":\n'
+ ' addRule("type", "include", term);\n'
+ ' term = false;\n'
+ ' break;\n'
+ ' case "-type:":\n'
+ ' addRule("type", "exclude", term);\n'
+ ' term = false;\n'
+ ' break;\n'
+ ' case "sort:":\n'
+ ' addSort(term, 1);\n'
+ ' term = false;\n'
+ ' break;\n'
+ ' case "-sort:":\n'
+ ' addSort(term, -1);\n'
+ ' term = false;\n'
+ ' break;\n'
+ ' }\n'
+ ' // commands that require a term\n'
+ ' if (term) {\n'
+ ' switch (cmd) {\n'
+ ' case "id:":\n'
+ ' addRule("id", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-id:":\n'
+ ' addRule("id", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "file:":\n'
+ ' addRule("file", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-file:":\n'
+ ' addRule("file", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "source:":\n'
+ ' addRule("source", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-source:":\n'
+ ' addRule("source", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "tcc:":\n'
+ ' addRule("tcc", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-tcc:":\n'
+ ' addRule("tcc", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "title:":\n'
+ ' addRule("title", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-title:":\n'
+ ' addRule("title", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "comment:":\n'
+ ' addRule("comment", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-comment:":\n'
+ ' addRule("comment", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "content:":\n'
+ ' addRule("content", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-content:":\n'
+ ' addRule("content", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "create:":\n'
+ ' addRule("create", "include", parseDate(term));\n'
+ ' break;\n'
+ ' case "-create:":\n'
+ ' addRule("create", "exclude", parseDate(term));\n'
+ ' break;\n'
+ ' case "modify:":\n'
+ ' addRule("modify", "include", parseDate(term));\n'
+ ' break;\n'
+ ' case "-modify:":\n'
+ ' addRule("modify", "exclude", parseDate(term));\n'
+ ' break;\n'
+ ' case "-":\n'
+ ' addRule(key["default"], "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' default:\n'
+ ' addRule(key["default"], "include", parseStr(term));\n'
+ ' break;\n'
+ ' }\n'
+ ' case "type:":\n'
+ ' addRule("type", "include", parseStr(term, true));\n'
+ ' break;\n'
+ ' case "-type:":\n'
+ ' addRule("type", "exclude", parseStr(term, true));\n'
+ ' break;\n'
+ ' case "id:":\n'
+ ' addRule("id", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-id:":\n'
+ ' addRule("id", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "file:":\n'
+ ' addRule("file", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-file:":\n'
+ ' addRule("file", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "source:":\n'
+ ' addRule("source", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-source:":\n'
+ ' addRule("source", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "tcc:":\n'
+ ' addRule("tcc", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-tcc:":\n'
+ ' addRule("tcc", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "title:":\n'
+ ' addRule("title", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-title:":\n'
+ ' addRule("title", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "comment:":\n'
+ ' addRule("comment", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-comment:":\n'
+ ' addRule("comment", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "content:":\n'
+ ' addRule("content", "include", parseStr(term));\n'
+ ' break;\n'
+ ' case "-content:":\n'
+ ' addRule("content", "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' case "create:":\n'
+ ' addRule("create", "include", parseDate(term));\n'
+ ' break;\n'
+ ' case "-create:":\n'
+ ' addRule("create", "exclude", parseDate(term));\n'
+ ' break;\n'
+ ' case "modify:":\n'
+ ' addRule("modify", "include", parseDate(term));\n'
+ ' break;\n'
+ ' case "-modify:":\n'
+ ' addRule("modify", "exclude", parseDate(term));\n'
+ ' break;\n'
+ ' case "-":\n'
+ ' addRule(key["default"], "exclude", parseStr(term));\n'
+ ' break;\n'
+ ' default:\n'
+ ' addRule(key["default"], "include", parseStr(term));\n'
+ ' break;\n'
+ ' }\n'
+ ' return "";\n'
+ '\n'
Expand All @@ -647,7 +636,7 @@ var sbOutputService = {
+ ' key.error.push(msg);\n'
+ ' }\n'
+ '\n'
+ ' function parseStr(term) {\n'
+ ' function parseStr(term, exactMatch) {\n'
+ ' var options = key.mc ? "m" : "im";\n'
+ ' if (key.re) {\n'
+ ' try {\n'
Expand All @@ -658,7 +647,9 @@ var sbOutputService = {
+ ' }\n'
+ ' }\n'
+ ' else {\n'
+ ' var regex = new RegExp(that.escapeRegExp(term), options);\n'
+ ' var q = that.escapeRegExp(term);\n'
+ ' if (exactMatch) q = "^" + q + "$";\n'
+ ' var regex = new RegExp(q, options);\n'
+ ' }\n'
+ ' return regex;\n'
+ ' }\n'
Expand Down Expand Up @@ -722,16 +713,16 @@ var sbOutputService = {
+ ' },\n'
+ '\n'
+ ' _match_type: function(keyitem, data) {\n'
+ ' var type = data.item.type;\n'
+ ' var text = data.item.type;\n'
+ ' for (var i=0, len=keyitem.exclude.length; i<len; i++) {\n'
+ ' if (type == keyitem.exclude[i]) {\n'
+ ' if (keyitem.exclude[i].test(text)) {\n'
+ ' return false;\n'
+ ' }\n'
+ ' }\n'
+ ' // uses "or" clause\n'
+ ' if (!keyitem.include.length) return true;\n'
+ ' for (var i=0, len=keyitem.include.length; i<len; i++) {\n'
+ ' if (type == keyitem.include[i]) {\n'
+ ' if (keyitem.include[i].test(text)) {\n'
+ ' return true;\n'
+ ' }\n'
+ ' }\n'
Expand Down
Loading

0 comments on commit 68d4174

Please sign in to comment.