From 3153c588ecddfdc97cc8289720d36b1fb15ef236 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 26 Oct 2020 17:28:57 +0000 Subject: [PATCH 1/7] Disable autosave in the upgrade wizard To address @pmario's suggestion here: https://github.com/Jermolene/TiddlyWiki5/issues/4879#issuecomment-704320381 --- core/modules/saver-handler.js | 2 +- plugins/tiddlywiki/upgrade/config.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/modules/saver-handler.js b/core/modules/saver-handler.js index 44dc130ff..a4b7f4a4e 100644 --- a/core/modules/saver-handler.js +++ b/core/modules/saver-handler.js @@ -153,7 +153,7 @@ SaverHandler.prototype.saveWiki = function(options) { var self = this, method = options.method || "save"; // Ignore autosave if disabled - if(method === "autosave" && this.wiki.getTiddlerText(this.titleAutoSave,"yes") !== "yes") { + if(method === "autosave" && ($tw.config.disableAutoSave || this.wiki.getTiddlerText(this.titleAutoSave,"yes") !== "yes")) { return false; } var variables = options.variables || {}, diff --git a/plugins/tiddlywiki/upgrade/config.js b/plugins/tiddlywiki/upgrade/config.js index 97d71f9cc..0c50f1fa7 100644 --- a/plugins/tiddlywiki/upgrade/config.js +++ b/plugins/tiddlywiki/upgrade/config.js @@ -20,6 +20,7 @@ exports.synchronous = true; exports.startup = function() { // See $tw.utils.decryptStoreAreaInteractive() in $:/core/modules/utils/crypto.js $tw.config.usePasswordVault = true; + $tw.config.disableAutoSave = true; }; })(); From 83f976ea5485f399b5930b4f82fe93b9ac5b4bb6 Mon Sep 17 00:00:00 2001 From: saqimtiaz Date: Mon, 26 Oct 2020 18:36:50 +0100 Subject: [PATCH 2/7] Extended tiddlywiki.files to allow optionally saving changes to a tiddler back to the original file location (#4914) --- boot/boot.js | 10 +++++++--- .../tw5.com/tiddlers/nodejs/tiddlywiki.files_Files.tid | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 969a8c567..456cceb14 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1824,7 +1824,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) { // Read the specification var filesInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8")); // Helper to process a file - var processFile = function(filename,isTiddlerFile,fields) { + var processFile = function(filename,isTiddlerFile,fields,isEditableFile) { var extInfo = $tw.config.fileExtensionInfo[path.extname(filename)], type = (extInfo || {}).type || fields.type || "text/plain", typeInfo = $tw.config.contentTypeInfo[type] || {}, @@ -1877,7 +1877,11 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) { } }); }); - tiddlers.push({tiddlers: fileTiddlers}); + if(isEditableFile) { + tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, tiddlers: fileTiddlers}); + } else { + tiddlers.push({tiddlers: fileTiddlers}); + } }; // Process the listed tiddlers $tw.utils.each(filesInfo.tiddlers,function(tidInfo) { @@ -1907,7 +1911,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) { for(var t=0; t> ** ''fields'' - (required) an object containing values that override or customise the fields provided in the tiddler file (see above) Fields can be overridden for particular files by creating a file with the same name plus the suffix `.meta` -- see TiddlerFiles. From 4c6de2271124fc3a4b01e4324a0d5e401500cca2 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 26 Oct 2020 17:47:19 +0000 Subject: [PATCH 3/7] Recognise the image/jpg content type, even though it's not really legal Browsers also respect it. Fixes #4571 --- boot/boot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/boot.js b/boot/boot.js index 456cceb14..80032b4f5 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -2264,6 +2264,7 @@ $tw.boot.initStartup = function(options) { $tw.utils.registerFileType("application/zip","base64",".zip"); $tw.utils.registerFileType("application/x-zip-compressed","base64",".zip"); $tw.utils.registerFileType("image/jpeg","base64",[".jpg",".jpeg"],{flags:["image"]}); + $tw.utils.registerFileType("image/jpg","base64",[".jpg",".jpeg"],{flags:["image"]}); $tw.utils.registerFileType("image/png","base64",".png",{flags:["image"]}); $tw.utils.registerFileType("image/gif","base64",".gif",{flags:["image"]}); $tw.utils.registerFileType("image/webp","base64",".webp",{flags:["image"]}); From aa7a00d080da0179c7c6dbf6a1ab1f7de8efa55c Mon Sep 17 00:00:00 2001 From: Rob Hoelz Date: Mon, 26 Oct 2020 12:52:25 -0500 Subject: [PATCH 4/7] Add eslint plus very tolerant starting config (#4872) * Add eslint plus very tolerant starting config Addresses GH #1865 This adds eslint as a developer dependency, plus a generated eslint config that doesn't take a very strong stance on much of anything. The goal here to get started using automated style checking, add eslint checking to the testing flow, and gradually introduce stricter checks over time. * eslint: Fix ecmaVersion See https://github.com/Jermolene/TiddlyWiki5/pull/4421#issuecomment-587002325, where @Jermolene declared TiddlyWiki targets EcmaScript 5 --- .eslintignore | 15 +++ .eslintrc.yml | 267 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +- 3 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.yml diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..30a0dae7c --- /dev/null +++ b/.eslintignore @@ -0,0 +1,15 @@ +# Known minified files +/boot/sjcl.js +/core/modules/utils/base64-utf8/base64-utf8.module.min.js +/core/modules/utils/diff-match-patch/diff_match_patch.js +/plugins/tiddlywiki/async/files/async.min.v1.5.0.js +/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js +/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js +/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js +/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js +/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js +/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js +/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/closebrackets.js +/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js +/plugins/tiddlywiki/codemirror-closetag/files/addon/edit/closetag.js +/plugins/tiddlywiki/codemirror-closetag/files/addon/fold/xml-fold.js diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 000000000..105ca829e --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,267 @@ +env: + browser: true + commonjs: true + es2021: true + node: true +extends: 'eslint:recommended' +globals: + "$tw": "writable" # temporary +parserOptions: + ecmaVersion: 5 +rules: + array-bracket-newline: 'off' + array-bracket-spacing: 'off' + array-callback-return: 'off' + array-element-newline: 'off' + arrow-body-style: error + arrow-parens: + - error + - as-needed + arrow-spacing: + - error + - after: true + before: true + block-scoped-var: 'off' + block-spacing: 'off' + brace-style: 'off' + callback-return: 'off' + camelcase: 'off' + capitalized-comments: 'off' + class-methods-use-this: error + comma-dangle: 'off' + comma-spacing: 'off' + comma-style: 'off' + complexity: 'off' + computed-property-spacing: 'off' + consistent-return: 'off' + consistent-this: 'off' + curly: 'off' + default-case: 'off' + default-case-last: error + default-param-last: error + dot-location: 'off' + dot-notation: 'off' + eol-last: 'off' + eqeqeq: 'off' + func-call-spacing: 'off' + func-name-matching: 'off' + func-names: 'off' + func-style: 'off' + function-call-argument-newline: 'off' + function-paren-newline: 'off' + generator-star-spacing: error + global-require: 'off' + grouped-accessor-pairs: error + guard-for-in: 'off' + handle-callback-err: 'off' + id-blacklist: error + id-denylist: error + id-length: 'off' + id-match: error + implicit-arrow-linebreak: error + indent: 'off' + indent-legacy: 'off' + init-declarations: 'off' + jsx-quotes: error + key-spacing: 'off' + keyword-spacing: 'off' + line-comment-position: 'off' + linebreak-style: 'off' + lines-around-comment: 'off' + lines-around-directive: 'off' + lines-between-class-members: error + max-classes-per-file: error + max-depth: 'off' + max-len: 'off' + max-lines: 'off' + max-lines-per-function: 'off' + max-nested-callbacks: error + max-params: 'off' + max-statements: 'off' + max-statements-per-line: 'off' + multiline-comment-style: 'off' + multiline-ternary: 'off' + new-parens: 'off' + newline-after-var: 'off' + newline-before-return: 'off' + newline-per-chained-call: 'off' + no-alert: 'off' + no-array-constructor: 'off' + no-await-in-loop: error + no-bitwise: 'off' + no-buffer-constructor: 'off' + no-caller: error + no-catch-shadow: 'off' + no-confusing-arrow: error + no-console: 'off' + no-constant-condition: + - error + - checkLoops: false + no-constructor-return: error + no-continue: 'off' + no-div-regex: 'off' + no-duplicate-imports: error + no-else-return: 'off' + no-empty-function: 'off' + no-eq-null: 'off' + no-eval: 'off' + no-extend-native: 'off' + no-extra-bind: 'off' + no-extra-label: 'off' + no-extra-parens: 'off' + no-floating-decimal: 'off' + no-implicit-coercion: + - error + - boolean: false + number: false + string: false + no-implicit-globals: 'off' + no-implied-eval: error + no-inline-comments: 'off' + no-invalid-this: 'off' + no-iterator: error + no-label-var: 'off' + no-labels: 'off' + no-lone-blocks: 'off' + no-lonely-if: 'off' + no-loop-func: 'off' + no-loss-of-precision: error + no-magic-numbers: 'off' + no-mixed-operators: 'off' + no-mixed-requires: 'off' + no-multi-assign: 'off' + no-multi-spaces: 'off' + no-multi-str: error + no-multiple-empty-lines: 'off' + no-native-reassign: 'off' + no-negated-condition: 'off' + no-negated-in-lhs: error + no-nested-ternary: 'off' + no-new: 'off' + no-new-func: 'off' + no-new-object: 'off' + no-new-require: error + no-new-wrappers: error + no-octal-escape: error + no-param-reassign: 'off' + no-path-concat: error + no-plusplus: 'off' + no-process-env: 'off' + no-process-exit: 'off' + no-promise-executor-return: error + no-proto: 'off' + no-restricted-exports: error + no-restricted-globals: error + no-restricted-imports: error + no-restricted-modules: error + no-restricted-properties: error + no-restricted-syntax: error + no-return-assign: 'off' + no-return-await: error + no-script-url: 'off' + no-self-compare: 'off' + no-sequences: 'off' + no-shadow: 'off' + no-spaced-func: 'off' + no-sync: 'off' + no-tabs: 'off' + no-template-curly-in-string: error + no-ternary: 'off' + no-throw-literal: 'off' + no-trailing-spaces: 'off' + no-undef-init: 'off' + no-undefined: 'off' + no-underscore-dangle: 'off' + no-unmodified-loop-condition: 'off' + no-unneeded-ternary: 'off' + no-unreachable-loop: error + no-unused-expressions: 'off' + no-use-before-define: 'off' + no-useless-backreference: error + no-useless-call: 'off' + no-useless-computed-key: error + no-useless-concat: 'off' + no-useless-constructor: error + no-useless-rename: error + no-useless-return: 'off' + no-var: 'off' + no-void: 'off' + no-warning-comments: 'off' + no-whitespace-before-property: error + nonblock-statement-body-position: + - error + - any + object-curly-newline: 'off' + object-curly-spacing: 'off' + object-property-newline: 'off' + object-shorthand: 'off' + one-var: 'off' + one-var-declaration-per-line: 'off' + operator-assignment: 'off' + operator-linebreak: 'off' + padded-blocks: 'off' + padding-line-between-statements: error + prefer-arrow-callback: 'off' + prefer-const: 'off' + prefer-destructuring: 'off' + prefer-exponentiation-operator: 'off' + prefer-named-capture-group: 'off' + prefer-numeric-literals: error + prefer-object-spread: 'off' + prefer-promise-reject-errors: error + prefer-reflect: 'off' + prefer-regex-literals: 'off' + prefer-rest-params: 'off' + prefer-spread: 'off' + prefer-template: 'off' + quote-props: 'off' + quotes: 'off' + radix: 'off' + require-atomic-updates: error + require-await: error + require-jsdoc: 'off' + require-unicode-regexp: 'off' + rest-spread-spacing: error + semi: 'off' + semi-spacing: 'off' + semi-style: 'off' + sort-imports: error + sort-keys: 'off' + sort-vars: 'off' + space-before-blocks: 'off' + space-before-function-paren: 'off' + space-in-parens: 'off' + space-infix-ops: 'off' + space-unary-ops: 'off' + spaced-comment: 'off' + strict: 'off' + switch-colon-spacing: 'off' + symbol-description: error + template-curly-spacing: error + template-tag-spacing: error + unicode-bom: + - error + - never + valid-jsdoc: 'off' + valid-typeof: + - error + - requireStringLiterals: false + vars-on-top: 'off' + wrap-iife: 'off' + wrap-regex: 'off' + yield-star-spacing: error + yoda: 'off' + + # temporary rules + no-useless-escape: 'off' + no-unused-vars: 'off' + no-empty: 'off' + no-extra-semi: 'off' + no-redeclare: 'off' + no-control-regex: "off" + no-mixed-spaces-and-tabs: "off" + no-extra-boolean-cast: "off" + no-prototype-builtins: "off" + no-undef: "off" + no-unreachable: "off" + no-self-assign: "off" diff --git a/package.json b/package.json index 5d93e5274..ff7af3897 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "wiki" ], "dependencies": {}, - "devDependencies": {}, + "devDependencies": { + "eslint": "^7.10.0" + }, "bundleDependencies": [], "license": "BSD", "engines": { From f6938d6abbce6a9b3cd99be96ed549d59891075f Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Mon, 26 Oct 2020 18:36:46 +0000 Subject: [PATCH 5/7] Fix external-attachments plugin relative path bug Fixes #4549 --- .../external-attachments/startup.js | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/tiddlywiki/external-attachments/startup.js b/plugins/tiddlywiki/external-attachments/startup.js index 4967921c5..9478c6e2a 100644 --- a/plugins/tiddlywiki/external-attachments/startup.js +++ b/plugins/tiddlywiki/external-attachments/startup.js @@ -94,7 +94,7 @@ function makePathRelative(sourcepath,rootpath,options) { return sourcepath; } // Move up a directory for each directory left in the root - for(p = c; p < rootParts.length; p++) { + for(p = c; p < rootParts.length - 1; p++) { outputParts.push(".."); } // Add on the remaining parts of the source path @@ -106,19 +106,22 @@ function makePathRelative(sourcepath,rootpath,options) { function test_makePathRelative() { var test = function(sourcepath,rootpath,result,options) { - if(makePathRelative(sourcepath,rootpath,options) !== result) { - throw "makePathRelative test failed: makePathRelative(" + sourcepath + "," + rootpath + "," + JSON.stringify(options) + ") is not equal to " + result; + var actualResult = makePathRelative(sourcepath,rootpath,options); + if(actualResult !== result) { + console.log("makePathRelative test failed: makePathRelative(" + sourcepath + "," + rootpath + "," + JSON.stringify(options) + ") is " + actualResult + " and not equal to " + result); } }; - test("/Users/me/something/file.png","/Users/you/something","../../me/something/file.png"); - test("/Users/me/something/file.png","/Users/you/something","/Users/me/something/file.png",{useAbsoluteForNonDescendents: true}); - test("/Users/me/something/else/file.png","/Users/me/something","else/file.png"); - test("/Users/me/something/file.png","/Users/me/something/new","../file.png"); - test("/Users/me/something/file.png","/Users/me/something/new","/Users/me/something/file.png",{useAbsoluteForNonDescendents: true}); - test("/Users/me/something/file.png","/Users/me/something","file.png"); - test("C:\\Users\\me\\something\\file.png","/C:/Users/me/something","file.png",{isWindows: true}); - test("\\\\SHARE\\Users\\me\\something\\file.png","/SHARE/Users/me/somethingelse","../something/file.png",{isWindows: true}); - test("\\\\SHARE\\Users\\me\\something\\file.png","/C:/Users/me/something","/SHARE/Users/me/something/file.png",{isWindows: true}); + test("/Users/me/something/file.png","/Users/you/something/index.html","../../me/something/file.png"); + test("/Users/me/something/file.png","/Users/you/something/index.html","/Users/me/something/file.png",{useAbsoluteForNonDescendents: true}); + test("/Users/me/something/else/file.png","/Users/me/something/index.html","else/file.png"); + test("/Users/me/something/file.png","/Users/me/something/new/index.html","../file.png"); + test("/Users/me/something/file.png","/Users/me/something/new/index.html","/Users/me/something/file.png",{useAbsoluteForNonDescendents: true}); + test("/Users/me/something/file.png","/Users/me/something/index.html","file.png"); + test("/Users/jeremyruston/Downloads/Screenshot 2020-10-18 at 15.33.40.png","/Users/jeremyruston/git/Jermolene/TiddlyWiki5/editions/prerelease/output/index.html","../../../../../../Downloads/Screenshot%202020-10-18%20at%2015.33.40.png"); + test("/Users/me/nothing/image.png","/Users/me/something/a/b/c/d/e/index.html","../../../../../../nothing/image.png"); + test("C:\\Users\\me\\something\\file.png","/C:/Users/me/something/index.html","file.png",{isWindows: true}); + test("\\\\SHARE\\Users\\me\\something\\file.png","/SHARE/Users/me/somethingelse/index.html","../something/file.png",{isWindows: true}); + test("\\\\SHARE\\Users\\me\\something\\file.png","/C:/Users/me/something/index.html","/SHARE/Users/me/something/file.png",{isWindows: true}); } From 3843c61132bfe45dfe5ecfbdf77892caa3bb84f9 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Tue, 27 Oct 2020 10:03:34 +0100 Subject: [PATCH 6/7] Add ability to cycle Advanced-search tabs by keyboard ... (#4909) * Update AdvancedSearch.tid * Update System.tid * Update Standard.tid * Update Filter.tid * Update Shadows.tid * Update search.tid * Update shortcuts.multids * Update ShortcutInfo.multids * Update Misc.multids * Update ShortcutInfo.multids * Update search.tid --- core/language/en-GB/Misc.multids | 1 + core/ui/AdvancedSearch.tid | 2 +- core/ui/AdvancedSearch/Filter.tid | 6 ++++++ core/ui/AdvancedSearch/Shadows.tid | 5 +++++ core/ui/AdvancedSearch/Standard.tid | 5 +++++ core/ui/AdvancedSearch/System.tid | 5 +++++ core/ui/SideBarSegments/search.tid | 8 +++++--- core/wiki/config/ShortcutInfo.multids | 1 + core/wiki/config/shortcuts/shortcuts.multids | 1 + 9 files changed, 30 insertions(+), 4 deletions(-) diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index 3ef0f5dc2..14e353689 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -63,6 +63,7 @@ OfficialPluginLibrary: Official ~TiddlyWiki Plugin Library OfficialPluginLibrary/Hint: The official ~TiddlyWiki plugin library at tiddlywiki.com. Plugins, themes and language packs are maintained by the core team. PluginReloadWarning: Please save {{$:/core/ui/Buttons/save-wiki}} and reload {{$:/core/ui/Buttons/refresh}} to allow changes to ~JavaScript plugins to take effect RecentChanges/DateFormat: DDth MMM YYYY +Shortcuts/Input/AdvancedSearch/Hint: Open the AdvancedSearch panel from within the sidebar search field Shortcuts/Input/Accept/Hint: Accept the selected item Shortcuts/Input/AcceptVariant/Hint: Accept the selected item (variant) Shortcuts/Input/Cancel/Hint: Clear the input field diff --git a/core/ui/AdvancedSearch.tid b/core/ui/AdvancedSearch.tid index e7b4827e3..38982c002 100644 --- a/core/ui/AdvancedSearch.tid +++ b/core/ui/AdvancedSearch.tid @@ -3,5 +3,5 @@ icon: $:/core/images/advanced-search-button color: #bbb diff --git a/core/ui/AdvancedSearch/Filter.tid b/core/ui/AdvancedSearch/Filter.tid index 55de251d6..e55e9e03b 100644 --- a/core/ui/AdvancedSearch/Filter.tid +++ b/core/ui/AdvancedSearch/Filter.tid @@ -3,10 +3,16 @@ tags: $:/tags/AdvancedSearch caption: {{$:/language/Search/Filter/Caption}} \define lingo-base() $:/language/Search/ +\define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/advanced-search-results" tag="$:/tags/AdvancedSearch" beforeafter="$beforeafter$" defaultState="$:/core/ui/AdvancedSearch/System" actions="""<$action-setfield $tiddler="$:/state/advancedsearch/currentTab" text=<>/>"""/> +<$linkcatcher to="$:/temp/advancedsearch"> <> diff --git a/core/ui/AdvancedSearch/Shadows.tid b/core/ui/AdvancedSearch/Shadows.tid index 9dcf5d67e..3a220d1a8 100644 --- a/core/ui/AdvancedSearch/Shadows.tid +++ b/core/ui/AdvancedSearch/Shadows.tid @@ -3,12 +3,17 @@ tags: $:/tags/AdvancedSearch caption: {{$:/language/Search/Shadows/Caption}} \define lingo-base() $:/language/Search/ +\define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/advanced-search-results" tag="$:/tags/AdvancedSearch" beforeafter="$beforeafter$" defaultState="$:/core/ui/AdvancedSearch/System" actions="""<$action-setfield $tiddler="$:/state/advancedsearch/currentTab" text=<>/>"""/> <$linkcatcher to="$:/temp/advancedsearch"> <>