1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-02-14 05:59:48 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
jeremy@jermolene.com
19c052d138 Make prettierignore consistent with eslintignore
@pmario do you happen to know if there's a way to avoid the duplication here? Can we make prettier use the ignore list from eslint?
2023-04-05 17:51:43 +01:00
jeremy@jermolene.com
169a36a5cb Ensure sjcl.js isn't prettified 2023-04-05 17:46:49 +01:00
jeremy@jermolene.com
d203239f6f Initial Commit
This commit installs and configures Prettier, and adds it to our test suite. We do not yet apply Prettier
2023-04-05 17:36:19 +01:00
9 changed files with 1929 additions and 150 deletions

View File

@@ -6,3 +6,6 @@
/core/modules/utils/diff-match-patch/diff_match_patch_uncompressed.js
/core/modules/utils/dom/csscolorparser.js
/plugins/tiddlywiki/*/files/
/tmp/
/output/

10
.prettierignore Normal file
View File

@@ -0,0 +1,10 @@
# Ignore "third party" code whose style we will not change.
/boot/sjcl.js
/core/modules/utils/base64-utf8/base64-utf8.module.js
/core/modules/utils/base64-utf8/base64-utf8.module.min.js
/core/modules/utils/diff-match-patch/diff_match_patch.js
/core/modules/utils/diff-match-patch/diff_match_patch_uncompressed.js
/core/modules/utils/dom/csscolorparser.js
/plugins/tiddlywiki/*/files/
/tmp/
/output/

1
.prettierrc.json Normal file
View File

@@ -0,0 +1 @@
{}

View File

@@ -2,6 +2,10 @@
# test TiddlyWiki5 for tiddlywiki.com
# Let Prettier check formatting
npm run prettier-check || exit 1
# Run the test edition to run the node.js tests and to generate test.html for tests in the browser
node ./tiddlywiki.js \

View File

@@ -96,42 +96,34 @@ Push entries onto an array, removing them first if they already exist in the arr
$tw.utils.pushTop = function(array,value) {
var t,p;
if($tw.utils.isArray(value)) {
if($tw.config._temp_allowDuplicates) {
Array.prototype.push.apply(array,value);
} else {
// Remove any array entries that are duplicated in the new values
if(value.length !== 0) {
if(array.length !== 0) {
if(value.length < array.length) {
for(t=0; t<value.length; t++) {
p = array.indexOf(value[t]);
if(p !== -1) {
array.splice(p,1);
}
// Remove any array entries that are duplicated in the new values
if(value.length !== 0) {
if(array.length !== 0) {
if(value.length < array.length) {
for(t=0; t<value.length; t++) {
p = array.indexOf(value[t]);
if(p !== -1) {
array.splice(p,1);
}
} else {
for(t=array.length-1; t>=0; t--) {
p = value.indexOf(array[t]);
if(p !== -1) {
array.splice(t,1);
}
}
} else {
for(t=array.length-1; t>=0; t--) {
p = value.indexOf(array[t]);
if(p !== -1) {
array.splice(t,1);
}
}
}
// Push the values on top of the main array
Array.prototype.push.apply(array,value);
}
}
// Push the values on top of the main array
array.push.apply(array,value);
}
} else {
if($tw.config._temp_allowDuplicates) {
array.push(value);
} else {
p = array.indexOf(value);
if(p !== -1) {
array.splice(p,1);
}
array.push(value);
p = array.indexOf(value);
if(p !== -1) {
array.splice(p,1);
}
array.push(value);
}
return array;
};
@@ -405,7 +397,7 @@ $tw.utils.parseStringArray = function(value, allowDuplicate) {
match = memberRegExp.exec(value);
if(match) {
var item = match[1] || match[2];
if(item !== undefined && (!$tw.utils.hop(names,item) || allowDuplicate || $tw.config._temp_allowDuplicates)) {
if(item !== undefined && (!$tw.utils.hop(names,item) || allowDuplicate)) {
results.push(item);
names[item] = true;
}
@@ -2313,25 +2305,14 @@ $tw.loadTiddlersNode = function() {
Startup TiddlyWiki
*/
$tw.boot.initStartup = function(options) {
var _temp_allowDuplicates;
options = options || {};
// Get the URL hash and check for safe mode
$tw.locationHash = "#";
if($tw.browser && !$tw.node) {
if(location.hash === "#:safe") {
$tw.safeMode = true;
} else if(location.hash === "#dupes") {
_temp_allowDuplicates = true;
$tw.locationHash = $tw.utils.getLocationHash();
} else {
$tw.locationHash = $tw.utils.getLocationHash();
}
} else {
var p = $tw.boot.argv.indexOf("--dupes");
if(p !== -1) {
_temp_allowDuplicates = true;
$tw.boot.argv.splice(p,1);
}
}
// Initialise some more $tw properties
$tw.utils.deepDefaults($tw,{
@@ -2340,7 +2321,6 @@ $tw.boot.initStartup = function(options) {
types: {} // hashmap by module type of hashmap of exports
},
config: { // Configuration overridables
_temp_allowDuplicates: _temp_allowDuplicates,
pluginsPath: "../plugins/",
themesPath: "../themes/",
languagesPath: "../languages/",
@@ -2493,14 +2473,6 @@ $tw.boot.execStartup = function(options){
if($tw.crypto) {
$tw.crypto.updateCryptoStateTiddler();
}
// Warn if using duplicates mode
console.log("\x1b[0;31m--------=====>>>>>> " + $tw.wiki.getTiddler("$:/core/_temp_allowDuplicates/Heading").fields.text + "\x1b[0m");
console.log("\x1b[0;34m--------=====>>>>>> " + $tw.wiki.getTiddler("$:/core/_temp_allowDuplicates/Warning").fields.text + "\x1b[0m");
if($tw.config._temp_allowDuplicates) {
console.log("\x1b[0;31m--------=====>>>>>> " + $tw.wiki.getTiddler("$:/core/_temp_allowDuplicates/StatusOn").fields.text + "\x1b[0m");
} else {
console.log("\x1b[0;32m--------=====>>>>>> " + $tw.wiki.getTiddler("$:/core/_temp_allowDuplicates/StatusOff").fields.text + "\x1b[0m");
}
// Gather up any startup modules
$tw.boot.remainingStartupModules = []; // Array of startup modules
$tw.modules.forEachModuleOfType("startup",function(title,module) {

View File

@@ -1,92 +0,0 @@
title: $:/core/_temp_allowDuplicates
tags: $:/tags/AboveStory
<div class="marching-ants-box" style="
position: fixed;
top: 100px;
left: -4px;
max-width: 50%;
z-index: 1000;
padding: 1em;
border-top-right-radius: 16px;
border-bottom-right-radius: 16px;
color: #fff;">
<$reveal type="match" state="$:/state/_temp_allowDuplicatesWarning" text="hide" default="show">
<$button set="$:/state/_temp_allowDuplicatesWarning" setTo="show" class="tc-btn-invisible" style="
width: 100%;
text-align: left;
fill: #ff0;">
{{$:/core/images/warning}}
</$button>
</$reveal>
<$reveal type="nomatch" state="$:/state/_temp_allowDuplicatesWarning" text="hide" default="show">
<$button set="$:/state/_temp_allowDuplicatesWarning" setTo="hide" class="tc-btn-invisible" style="
width: 100%;
text-align: left;
fill: #ff0;">
<span style="float:right;">{{$:/core/images/chevron-left}}</span> {{$:/core/images/warning}}
</$button>
<div style="
font-weight: bold;">
{{$:/core/_temp_allowDuplicates/Heading}}
</div>
<div style="">
{{$:/core/_temp_allowDuplicates/Warning}}
</div>
<$list filter="1 1 1 1 +[butfirst[]limit[1]]" emptyMessage="""
<div style="
font-weight: bold;
color: #0f0;">
{{$:/core/_temp_allowDuplicates/StatusOff}}
//Append `#dupes` to the browser address bar to enable//
</div>
""">
<div style="
font-weight: bold;
color: #fff;
font-size: 1.5em;
padding: 4px;" class="marching-ants-box">
{{$:/core/_temp_allowDuplicates/StatusOn}}
//Remove `#dupes` from the browser address bar to disable//
</div>
</$list>
</$reveal>
</div>
<style>
@keyframes marching-ants { to { background-position: 100% 100% } }
.marching-ants-box {
border: 4px solid transparent;
background: linear-gradient(#d85858, #d85858) padding-box,
repeating-linear-gradient(-45deg, #f00 0, #f00 25%, transparent 0, transparent 50%) 0 / 12px 12px;
animation: marching-ants 12s linear infinite;
}
</style>

View File

@@ -1,6 +0,0 @@
title: $:/core/_temp_allowDuplicates/
Heading: Important Warning
Warning: This is a special prerelease version of TW5 for experimenting with a potentially incompatible change to the core logic of filter processing. It is only intended to be used for evaluation and testing
StatusOff: The allow duplicates setting is currently: OFF
StatusOn: The allow duplicates setting is currently: ON

1882
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,8 @@
"wiki"
],
"devDependencies": {
"eslint": "^7.32.0"
"eslint": "^8.37.0",
"prettier": "^2.8.7"
},
"bundleDependencies": [],
"license": "BSD",
@@ -32,6 +33,10 @@
"node": ">=0.8.2"
},
"scripts": {
"lint": "eslint ."
"lint": "eslint .",
"prettier-check": "npx prettier --check .",
"prettier-write": "npx prettier --write ."
},
"dependencies": {
}
}