mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-08-23 19:28:54 +00:00
Compare commits
462
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
251871f9cf | ||
|
|
8e65fdc06a | ||
|
|
ceb0817176 | ||
|
|
2f578589a0 | ||
|
|
916df90cc9 | ||
|
|
ea18c85a4c | ||
|
|
abf134afe4 | ||
|
|
45d2ca948a | ||
|
|
94b046b8cb | ||
|
|
c710a56b21 | ||
|
|
e681096127 | ||
|
|
24b433211d | ||
|
|
a64bbeaf52 | ||
|
|
9fecc7b1d9 | ||
|
|
2bc7826b5e | ||
|
|
d6174f0c46 | ||
|
|
c6c29ec68e | ||
|
|
fd96e5c8cb | ||
|
|
52a36c01ff | ||
|
|
002fd550a8 | ||
|
|
c1d9b07b20 | ||
|
|
187849a6a9 | ||
|
|
d5f8a04230 | ||
|
|
73ad4f633b | ||
|
|
ea549f6e26 | ||
|
|
df80a42d13 | ||
|
|
07d5f55abe | ||
|
|
1dfa09267b | ||
|
|
a0ee17989b | ||
|
|
2578eac294 | ||
|
|
60f0d22777 | ||
|
|
503c60f666 | ||
|
|
abf8ffdbca | ||
|
|
97e27d0dad | ||
|
|
4259ce4979 | ||
|
|
855dc2fbb9 | ||
|
|
e1e34f4907 | ||
|
|
7196b9ee9b | ||
|
|
c0b3403f87 | ||
|
|
7f808bc64f | ||
|
|
be9dc59f73 | ||
|
|
3a2a64b877 | ||
|
|
4c193f5d21 | ||
|
|
7322f0c024 | ||
|
|
9c2a36cefe | ||
|
|
0ce2cba0b1 | ||
|
|
1103b733fe | ||
|
|
81d7283990 | ||
|
|
3dba0f2938 | ||
|
|
ff8b077b0e | ||
|
|
66b5d3f0fd | ||
|
|
ec5d73c3a8 | ||
|
|
b71c3044ce | ||
|
|
f09cc75fb6 | ||
|
|
df9074773c | ||
|
|
6a2670592f | ||
|
|
35ede09e0f | ||
|
|
3862082f64 | ||
|
|
b7d2cb9b78 | ||
|
|
29c3a8d412 | ||
|
|
546f95ad07 | ||
|
|
6d8bfe269c | ||
|
|
ed71c8262a | ||
|
|
2ececf21c7 | ||
|
|
7516d96eed | ||
|
|
4bf7e9d192 | ||
|
|
04cd3081e4 | ||
|
|
d27716c1e0 | ||
|
|
7f7f36d986 | ||
|
|
86a4e18134 | ||
|
|
304858c7c5 | ||
|
|
7ececf9e0f | ||
|
|
521e530e11 | ||
|
|
46ffd7ebf3 | ||
|
|
65605d7b72 | ||
|
|
b3f9690941 | ||
|
|
4c29dae4af | ||
|
|
038d9e474e | ||
|
|
f5317dc225 | ||
|
|
c952450c2e | ||
|
|
1eb7ec4402 | ||
|
|
9a0bbf831b | ||
|
|
a30854a4c7 | ||
|
|
869557f7d1 | ||
|
|
856057be81 | ||
|
|
c9f1154643 | ||
|
|
748f04c9e3 | ||
|
|
d391595836 | ||
|
|
967140a148 | ||
|
|
95e68b0437 | ||
|
|
8ddede1611 | ||
|
|
ceb200b08c | ||
|
|
00e5f48a59 | ||
|
|
ea0e9105bc | ||
|
|
51459815ba | ||
|
|
8c62935a01 | ||
|
|
839fa2417d | ||
|
|
1b8610e4d8 | ||
|
|
ca063cbe90 | ||
|
|
7d4328b2fb | ||
|
|
1ae224ab74 | ||
|
|
c308fc44c4 | ||
|
|
aa3fb85919 | ||
|
|
bd052a33f8 | ||
|
|
bb766c36c3 | ||
|
|
566a341328 | ||
|
|
9316234001 | ||
|
|
c1cb93c9df | ||
|
|
e46361fbc0 | ||
|
|
e730836d6f | ||
|
|
d050dd30cc | ||
|
|
635f6b5e76 | ||
|
|
40d0d542f7 | ||
|
|
a66d9a596c | ||
|
|
23063ea9c8 | ||
|
|
9c1f69e9c1 | ||
|
|
6abfcb631d | ||
|
|
14b11575d0 | ||
|
|
c9b1fbbb76 | ||
|
|
27c568e53e | ||
|
|
0023d3f6fa | ||
|
|
76ebe9d8e9 | ||
|
|
40444eade5 | ||
|
|
fe8723be49 | ||
|
|
56ea0789e1 | ||
|
|
fff648b959 | ||
|
|
e1cff6068c | ||
|
|
6721164f15 | ||
|
|
3c37aa267d | ||
|
|
a603146b3c | ||
|
|
f992f4ffab | ||
|
|
dfedd8594f | ||
|
|
ea84baa5a3 | ||
|
|
a4e4d36bf6 | ||
|
|
3ed481b2e2 | ||
|
|
27c60ff58d | ||
|
|
748ef8aa8d | ||
|
|
9cfa5a29fb | ||
|
|
5ea43ce212 | ||
|
|
df6bbbdedf | ||
|
|
37a461323e | ||
|
|
b29da7baac | ||
|
|
75b54457ed | ||
|
|
51f322c3c6 | ||
|
|
853af2d848 | ||
|
|
2c1cb33081 | ||
|
|
2f63abc12a | ||
|
|
5f80256576 | ||
|
|
aa837300d0 | ||
|
|
7f2baa17a9 | ||
|
|
39c6d8fb53 | ||
|
|
9afe5226f1 | ||
|
|
94aa37fe7e | ||
|
|
1e9c1ef82a | ||
|
|
6cde5e94ff | ||
|
|
fd0d3ccc27 | ||
|
|
1ad2e66cbc | ||
|
|
4699db9f89 | ||
|
|
d977b0ac5c | ||
|
|
7298684951 | ||
|
|
f78d8252af | ||
|
|
54260b5be8 | ||
|
|
95f12eb857 | ||
|
|
207a68cc59 | ||
|
|
b434b9d7ea | ||
|
|
b0013333de | ||
|
|
bcc30e305a | ||
|
|
34f4dfb903 | ||
|
|
32a3a3e478 | ||
|
|
c6520c4429 | ||
|
|
83d242fb2c | ||
|
|
ecafb7a4c0 | ||
|
|
0640e0abe2 | ||
|
|
a71ac56cc9 | ||
|
|
f518bdf27c | ||
|
|
0387b1100b | ||
|
|
c3a73fccd1 | ||
|
|
c25659d87c | ||
|
|
0c26a75472 | ||
|
|
a24dc0e9e8 | ||
|
|
a499ed0906 | ||
|
|
3cfb6b1202 | ||
|
|
ac769e5dcd | ||
|
|
ed01af8e47 | ||
|
|
92caa7312e | ||
|
|
478dce7009 | ||
|
|
f3c9cb2310 | ||
|
|
85fb634cae | ||
|
|
280701fbde | ||
|
|
01d3cde964 | ||
|
|
2ea3663ea7 | ||
|
|
78b6f6f442 | ||
|
|
3a4a8a206f | ||
|
|
aff5be7195 | ||
|
|
c4991a54a0 | ||
|
|
1d915389d9 | ||
|
|
f5b4b1781e | ||
|
|
65fcded29f | ||
|
|
962692c90c | ||
|
|
533414b1df | ||
|
|
ec27a4bf20 | ||
|
|
e1cf523e2c | ||
|
|
1ece822d7a | ||
|
|
b7a3418823 | ||
|
|
bb6d88f144 | ||
|
|
57c72756ef | ||
|
|
dda4c7fb10 | ||
|
|
fd3b96e2dd | ||
|
|
c07396c453 | ||
|
|
7fc255f90c | ||
|
|
4cd84a6ba1 | ||
|
|
fdfcd66c9b | ||
|
|
3983086b96 | ||
|
|
a61331e6ed | ||
|
|
8773a0433c | ||
|
|
846deb3039 | ||
|
|
111a168b0c | ||
|
|
02b4c04a56 | ||
|
|
9d5b5111d0 | ||
|
|
48cff401b2 | ||
|
|
7a866b93e3 | ||
|
|
b0d99f3bd3 | ||
|
|
91e7a62c13 | ||
|
|
9f7763710e | ||
|
|
b673651103 | ||
|
|
49faefcca5 | ||
|
|
75c26b46c6 | ||
|
|
add3d425b5 | ||
|
|
c23a0bedfd | ||
|
|
36b20e02a3 | ||
|
|
ab6172981c | ||
|
|
431b7fa3bf | ||
|
|
1c1f157079 | ||
|
|
ac19f300a9 | ||
|
|
9012b00806 | ||
|
|
a3acbaa2f1 | ||
|
|
07634d6595 | ||
|
|
785086e0a5 | ||
|
|
08f2b8bdf4 | ||
|
|
c305eb01eb | ||
|
|
71462143bf | ||
|
|
8cd6bbc075 | ||
|
|
6fc65c1560 | ||
|
|
ab29f17d35 | ||
|
|
5ae4770317 | ||
|
|
2dd9a2006d | ||
|
|
ebff5aa3db | ||
|
|
3bc2c5fabc | ||
|
|
d423aa926e | ||
|
|
fe708eefc6 | ||
|
|
a7525037fd | ||
|
|
15736bceb9 | ||
|
|
35b0108da6 | ||
|
|
59d23da97c | ||
|
|
3f654bccaa | ||
|
|
a45a8723c0 | ||
|
|
ae7d6da35b | ||
|
|
a8e056c88c | ||
|
|
5b0af905a2 | ||
|
|
eb8f69dd03 | ||
|
|
ef49828989 | ||
|
|
9b56734451 | ||
|
|
2f8d53d3f7 | ||
|
|
5b96929f4e | ||
|
|
829bb61378 | ||
|
|
421ecff30f | ||
|
|
c7511fc99f | ||
|
|
87f797b1ae | ||
|
|
8cc94d8ea7 | ||
|
|
dcaff6a243 | ||
|
|
e98aed6f6e | ||
|
|
d35e34b55e | ||
|
|
bb4d57e170 | ||
|
|
fd709afc37 | ||
|
|
93388bc3cc | ||
|
|
a8c4437587 | ||
|
|
6dc83386bd | ||
|
|
9641e6a2d0 | ||
|
|
3254544eb2 | ||
|
|
c707b9a432 | ||
|
|
3cab1571be | ||
|
|
502598bd25 | ||
|
|
8a18f92710 | ||
|
|
3353d0e005 | ||
|
|
fd85842036 | ||
|
|
b0dc46c9e9 | ||
|
|
5b0c923a82 | ||
|
|
ae33a4521d | ||
|
|
4b83e89d40 | ||
|
|
da41483172 | ||
|
|
39488f118b | ||
|
|
f9721b029e | ||
|
|
974904588c | ||
|
|
38457a4667 | ||
|
|
96ef5c8314 | ||
|
|
96d24756ea | ||
|
|
77c99b418f | ||
|
|
7f2a47f303 | ||
|
|
dcf0f449c4 | ||
|
|
a4c84d727c | ||
|
|
5335ebf044 | ||
|
|
e9d87fb551 | ||
|
|
54382d6666 | ||
|
|
e86eb28890 | ||
|
|
5897b82c51 | ||
|
|
5e27462acf | ||
|
|
4c95ae546f | ||
|
|
d42e3d36bc | ||
|
|
ee977def52 | ||
|
|
30016967b1 | ||
|
|
250ee90b07 | ||
|
|
624cf95197 | ||
|
|
8467fa333d | ||
|
|
75ba08556f | ||
|
|
93f954411b | ||
|
|
059e439702 | ||
|
|
2028420e3b | ||
|
|
8b05b725aa | ||
|
|
d7df7eddb1 | ||
|
|
0037813b39 | ||
|
|
377856c6a1 | ||
|
|
49969a2f1e | ||
|
|
09f8ab9962 | ||
|
|
422b092eb2 | ||
|
|
067a1a22c6 | ||
|
|
83c6223617 | ||
|
|
611adadaed | ||
|
|
28935a5856 | ||
|
|
71a144f6f9 | ||
|
|
92b7819259 | ||
|
|
d2204ae72e | ||
|
|
7da70ecf6a | ||
|
|
d8dfc10ea8 | ||
|
|
7df987803d | ||
|
|
4665bab700 | ||
|
|
e87aaff06b | ||
|
|
7c4938293e | ||
|
|
eba73eebcb | ||
|
|
1f4f164d5e | ||
|
|
bfea62b43b | ||
|
|
4c216646a4 | ||
|
|
4fe90a6c73 | ||
|
|
961b26a984 | ||
|
|
0d9ab2e2f6 | ||
|
|
796c33bc46 | ||
|
|
4d06ecd535 | ||
|
|
f9e4dd8fd3 | ||
|
|
6e4d7aa7f1 | ||
|
|
998d5c8d8f | ||
|
|
38865a40ad | ||
|
|
a5c4d90154 | ||
|
|
2e5a988bb3 | ||
|
|
0ee2f286aa | ||
|
|
30a7d61e56 | ||
|
|
c7f9dbfc29 | ||
|
|
c6bb2b51e6 | ||
|
|
a053f03818 | ||
|
|
6970ac24bf | ||
|
|
431149d20c | ||
|
|
a366d62358 | ||
|
|
a6a91d49b7 | ||
|
|
22cf3b25bd | ||
|
|
139b61fff1 | ||
|
|
c1fd82f50f | ||
|
|
effeed7ade | ||
|
|
546e438943 | ||
|
|
efcd23993e | ||
|
|
0c8aad49f9 | ||
|
|
317e1245c8 | ||
|
|
d2bbc56c78 | ||
|
|
8957424e55 | ||
|
|
0fd5b04b9a | ||
|
|
3ea7cd3bf7 | ||
|
|
7513e4426c | ||
|
|
0dfde0660a | ||
|
|
8c619fd86e | ||
|
|
407e58f837 | ||
|
|
9588b7f1a3 | ||
|
|
28c1e77b60 | ||
|
|
0baf395030 | ||
|
|
9681b0deda | ||
|
|
62fb916a68 | ||
|
|
3614236cfc | ||
|
|
c75f50e99a | ||
|
|
55d9e92032 | ||
|
|
2edcf0f46b | ||
|
|
69363bf7ef | ||
|
|
2b0c634fb8 | ||
|
|
28167adc22 | ||
|
|
bd4b3e4107 | ||
|
|
2cbd1080fa | ||
|
|
a4293068bf | ||
|
|
d1ce54806f | ||
|
|
6b39d6aa43 | ||
|
|
5d1cf251b9 | ||
|
|
c02c82557b | ||
|
|
b90b449ceb | ||
|
|
6a06df79c4 | ||
|
|
2558dc0b10 | ||
|
|
2eee3bfcd6 | ||
|
|
2685fa7c4e | ||
|
|
3c44532551 | ||
|
|
2640406f5b | ||
|
|
c1e36a1e5f | ||
|
|
ae1d9f5b86 | ||
|
|
1df0ac486b | ||
|
|
b1fcb18d9e | ||
|
|
5a6eea7fa2 | ||
|
|
6fe16bc71a | ||
|
|
6a66c49261 | ||
|
|
fc695e7a50 | ||
|
|
9efcad9360 | ||
|
|
cd5bbcda8d | ||
|
|
aa69c3ae91 | ||
|
|
76f2decf8b | ||
|
|
84bef54802 | ||
|
|
3507b0f952 | ||
|
|
b0828cc099 | ||
|
|
32ac67166a | ||
|
|
b2d0c22d75 | ||
|
|
cfabc92945 | ||
|
|
809465b6e2 | ||
|
|
8b59b6166e | ||
|
|
3faf9bae5c | ||
|
|
c2ee0727a5 | ||
|
|
7de5f40884 | ||
|
|
21cd3b86ad | ||
|
|
ad1b0fdddd | ||
|
|
1db8cf7fe5 | ||
|
|
46da1619af | ||
|
|
bad9517153 | ||
|
|
38d5daaf12 | ||
|
|
297ae7eccb | ||
|
|
b54d56ec47 | ||
|
|
4e2f2bebd0 | ||
|
|
f88915728f | ||
|
|
1be89a28bf | ||
|
|
250e57cd79 | ||
|
|
a4d930322e | ||
|
|
c3ce9cafb7 | ||
|
|
348f7177a7 | ||
|
|
c6074402bb | ||
|
|
23eccd1df6 | ||
|
|
ff5c846130 | ||
|
|
81b7bb4124 | ||
|
|
a8fb07137d | ||
|
|
85fa913b1c | ||
|
|
bc0fde6853 | ||
|
|
4f2754d16c | ||
|
|
4445111a08 | ||
|
|
151f61adc0 | ||
|
|
fc369415e4 | ||
|
|
b5a22e3e9e | ||
|
|
d372729ed0 | ||
|
|
96b85edfa2 | ||
|
|
4af573aaf9 | ||
|
|
1e5c69eb99 | ||
|
|
e1e73d2aa0 | ||
|
|
a23ee165d8 | ||
|
|
467a1a47cc | ||
|
|
93d1c05ca7 | ||
|
|
fb9c0d6a5a |
@@ -5,17 +5,17 @@ on:
|
|||||||
- master
|
- master
|
||||||
- tiddlywiki-com
|
- tiddlywiki-com
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: "22"
|
NODE_VERSION: "22.22"
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "${{ env.NODE_VERSION }}"
|
node-version: "${{ env.NODE_VERSION }}"
|
||||||
- run: "./bin/ci-test.sh"
|
- run: "./bin/ci-test.sh"
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v7
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: playwright-report
|
name: playwright-report
|
||||||
@@ -30,8 +30,8 @@ jobs:
|
|||||||
TW5_BUILD_MAIN_EDITION: "./editions/prerelease"
|
TW5_BUILD_MAIN_EDITION: "./editions/prerelease"
|
||||||
TW5_BUILD_OUTPUT: "./output/prerelease"
|
TW5_BUILD_OUTPUT: "./output/prerelease"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "${{ env.NODE_VERSION }}"
|
node-version: "${{ env.NODE_VERSION }}"
|
||||||
- run: "./bin/ci-pre-build.sh"
|
- run: "./bin/ci-pre-build.sh"
|
||||||
@@ -62,8 +62,8 @@ jobs:
|
|||||||
TW5_BUILD_OUTPUT: "./output"
|
TW5_BUILD_OUTPUT: "./output"
|
||||||
TW5_BUILD_ARCHIVE: "./output"
|
TW5_BUILD_ARCHIVE: "./output"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "${{ env.NODE_VERSION }}"
|
node-version: "${{ env.NODE_VERSION }}"
|
||||||
- run: "./bin/ci-pre-build.sh"
|
- run: "./bin/ci-pre-build.sh"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-size-check
|
- name: build-size-check
|
||||||
id: get_sizes
|
id: get_sizes
|
||||||
uses: TiddlyWiki/cerebrus@v6
|
uses: TiddlyWiki/cerebrus@v8.1
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ github.event.pull_request.number }}
|
pr_number: ${{ github.event.pull_request.number }}
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
@@ -52,4 +52,4 @@ jobs:
|
|||||||
pr_size: '${{ needs.calculate-build-size.outputs.pr_size }}',
|
pr_size: '${{ needs.calculate-build-size.outputs.pr_size }}',
|
||||||
base_size: '${{ needs.calculate-build-size.outputs.base_size }}'
|
base_size: '${{ needs.calculate-build-size.outputs.base_size }}'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Build and check size
|
- name: Build and check size
|
||||||
uses: TiddlyWiki/cerebrus@v6
|
uses: TiddlyWiki/cerebrus@v8.1
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ inputs.pr_number }}
|
pr_number: ${{ inputs.pr_number }}
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Step 1: Validate PR paths
|
# Step 1: Validate PR paths
|
||||||
- name: Validate PR Paths
|
- name: Validate PR Paths
|
||||||
uses: TiddlyWiki/cerebrus@v6
|
uses: TiddlyWiki/cerebrus@v8.1
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ github.event.pull_request.number }}
|
pr_number: ${{ github.event.pull_request.number }}
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
|
|
||||||
# Step 2: Validate change notes
|
# Step 2: Validate change notes
|
||||||
- name: Validate Change Notes
|
- name: Validate Change Notes
|
||||||
uses: TiddlyWiki/cerebrus@v6
|
uses: TiddlyWiki/cerebrus@v8.1
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ github.event.pull_request.number }}
|
pr_number: ${{ github.event.pull_request.number }}
|
||||||
repo: ${{ github.repository }}
|
repo: ${{ github.repository }}
|
||||||
|
|||||||
+11
-1
@@ -2,10 +2,20 @@
|
|||||||
.c9/
|
.c9/
|
||||||
.vs/
|
.vs/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.claude/
|
||||||
|
# TiddlyWiki
|
||||||
tmp/
|
tmp/
|
||||||
output/
|
output/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
$__StoryList.tid
|
||||||
|
# Playwright
|
||||||
/test-results/
|
/test-results/
|
||||||
/playwright-report/
|
/playwright-report/
|
||||||
|
/blob-report/
|
||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
$__StoryList.tid
|
/playwright/.auth/
|
||||||
|
test-screenshots/
|
||||||
|
test-output.txt
|
||||||
|
.playwright-mcp
|
||||||
|
# TiddlyWiki MPC
|
||||||
|
.tw-mcp
|
||||||
@@ -3,3 +3,4 @@
|
|||||||
tmp/
|
tmp/
|
||||||
output/
|
output/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.claude/
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
# Default to the current version number for building the plugin library
|
# Default to the current version number for building the plugin library
|
||||||
|
|
||||||
if [ -z "$TW5_BUILD_VERSION" ]; then
|
if [ -z "$TW5_BUILD_VERSION" ]; then
|
||||||
TW5_BUILD_VERSION=v5.4.0
|
TW5_BUILD_VERSION=v5.5.0.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
|
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ git clone --depth=1 --branch=main "https://github.com/TiddlyWiki/tiddlywiki.org-
|
|||||||
|
|
||||||
# Make the CNAME file that GitHub Pages requires
|
# Make the CNAME file that GitHub Pages requires
|
||||||
|
|
||||||
echo "tiddlywiki.org" > $TWORG_BUILD_OUTPUT/CNAME
|
# echo "tiddlywiki.org" > $TWORG_BUILD_OUTPUT/CNAME
|
||||||
|
|
||||||
# Delete any existing static content
|
# Delete any existing static content
|
||||||
|
|
||||||
|
|||||||
+32
-32
@@ -15,40 +15,40 @@ var fs = require("fs"),
|
|||||||
{ optimize } = require("svgo"),
|
{ optimize } = require("svgo"),
|
||||||
config = {
|
config = {
|
||||||
plugins: [
|
plugins: [
|
||||||
'cleanupAttrs',
|
"cleanupAttrs",
|
||||||
'removeDoctype',
|
"removeDoctype",
|
||||||
'removeXMLProcInst',
|
"removeXMLProcInst",
|
||||||
'removeComments',
|
"removeComments",
|
||||||
'removeMetadata',
|
"removeMetadata",
|
||||||
'removeTitle',
|
"removeTitle",
|
||||||
'removeDesc',
|
"removeDesc",
|
||||||
'removeUselessDefs',
|
"removeUselessDefs",
|
||||||
'removeEditorsNSData',
|
"removeEditorsNSData",
|
||||||
'removeEmptyAttrs',
|
"removeEmptyAttrs",
|
||||||
'removeHiddenElems',
|
"removeHiddenElems",
|
||||||
'removeEmptyText',
|
"removeEmptyText",
|
||||||
'removeEmptyContainers',
|
"removeEmptyContainers",
|
||||||
// 'removeViewBox',
|
// 'removeViewBox',
|
||||||
'cleanupEnableBackground',
|
"cleanupEnableBackground",
|
||||||
'convertStyleToAttrs',
|
"convertStyleToAttrs",
|
||||||
'convertColors',
|
"convertColors",
|
||||||
'convertPathData',
|
"convertPathData",
|
||||||
'convertTransform',
|
"convertTransform",
|
||||||
'removeUnknownsAndDefaults',
|
"removeUnknownsAndDefaults",
|
||||||
'removeNonInheritableGroupAttrs',
|
"removeNonInheritableGroupAttrs",
|
||||||
'removeUselessStrokeAndFill',
|
"removeUselessStrokeAndFill",
|
||||||
'removeUnusedNS',
|
"removeUnusedNS",
|
||||||
'cleanupIDs',
|
"cleanupIDs",
|
||||||
'cleanupNumericValues',
|
"cleanupNumericValues",
|
||||||
'moveElemsAttrsToGroup',
|
"moveElemsAttrsToGroup",
|
||||||
'moveGroupAttrsToElems',
|
"moveGroupAttrsToElems",
|
||||||
'collapseGroups',
|
"collapseGroups",
|
||||||
// 'removeRasterImages',
|
// 'removeRasterImages',
|
||||||
'mergePaths',
|
"mergePaths",
|
||||||
'convertShapeToPath',
|
"convertShapeToPath",
|
||||||
'sortAttrs',
|
"sortAttrs",
|
||||||
//'removeDimensions',
|
//'removeDimensions',
|
||||||
{name: 'removeAttrs', params: { attrs: '(stroke|fill)' } }
|
{name: "removeAttrs", params: { attrs: "(stroke|fill)" } }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ files.forEach(function(filename) {
|
|||||||
var newSVG = header.join("\n") + "\n\n" + result.data.replace("<<now "DD">>","<<now \"DD\">>");
|
var newSVG = header.join("\n") + "\n\n" + result.data.replace("<<now "DD">>","<<now \"DD\">>");
|
||||||
fs.writeFileSync(filepath,newSVG);
|
fs.writeFileSync(filepath,newSVG);
|
||||||
} else {
|
} else {
|
||||||
console.log("Error " + err + " with " + filename)
|
console.log("Error " + err + " with " + filename);
|
||||||
process.exit();
|
process.exit();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-38
@@ -12,8 +12,6 @@ On the server this file is executed directly to boot TiddlyWiki. In the browser,
|
|||||||
|
|
||||||
var _boot = (function($tw) {
|
var _boot = (function($tw) {
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global modules: false, $tw: false */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Include bootprefix if we're not given module data
|
// Include bootprefix if we're not given module data
|
||||||
@@ -37,7 +35,7 @@ if($tw.node) {
|
|||||||
$tw.boot.log = function(str) {
|
$tw.boot.log = function(str) {
|
||||||
$tw.boot.logMessages = $tw.boot.logMessages || [];
|
$tw.boot.logMessages = $tw.boot.logMessages || [];
|
||||||
$tw.boot.logMessages.push(str);
|
$tw.boot.logMessages.push(str);
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if an object has a property
|
Check if an object has a property
|
||||||
@@ -47,7 +45,14 @@ $tw.utils.hop = function(object,property) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** @deprecated Use Array.isArray instead */
|
/** @deprecated Use Array.isArray instead */
|
||||||
$tw.utils.isArray = value => Array.isArray(value);
|
$tw.utils.isArray = (value) => Array.isArray(value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Determine if a value is a date, even across VM boundaries
|
||||||
|
*/
|
||||||
|
$tw.utils.isDate = function(value) {
|
||||||
|
return Object.prototype.toString.call(value) === "[object Date]";
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if an array is equal by value and by reference.
|
Check if an array is equal by value and by reference.
|
||||||
@@ -126,9 +131,6 @@ $tw.utils.pushTop = function(array,value) {
|
|||||||
return array;
|
return array;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @deprecated Use instanceof Date instead */
|
|
||||||
$tw.utils.isDate = value => value instanceof Date;
|
|
||||||
|
|
||||||
/** @deprecated Use array iterative methods instead */
|
/** @deprecated Use array iterative methods instead */
|
||||||
$tw.utils.each = function(object,callback) {
|
$tw.utils.each = function(object,callback) {
|
||||||
if(object) {
|
if(object) {
|
||||||
@@ -138,7 +140,7 @@ $tw.utils.each = function(object,callback) {
|
|||||||
return next !== false;
|
return next !== false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Object.entries(object).every(entry => {
|
Object.entries(object).every((entry) => {
|
||||||
const next = callback(entry[1], entry[0], object);
|
const next = callback(entry[1], entry[0], object);
|
||||||
return next !== false;
|
return next !== false;
|
||||||
});
|
});
|
||||||
@@ -565,7 +567,7 @@ using a lowercase extension only.
|
|||||||
*/
|
*/
|
||||||
$tw.utils.getFileExtensionInfo = function(ext) {
|
$tw.utils.getFileExtensionInfo = function(ext) {
|
||||||
return ext ? $tw.config.fileExtensionInfo[ext.toLowerCase()] : null;
|
return ext ? $tw.config.fileExtensionInfo[ext.toLowerCase()] : null;
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Given an extension, get the correct encoding for that file.
|
Given an extension, get the correct encoding for that file.
|
||||||
@@ -588,7 +590,7 @@ var globalCheck =[
|
|||||||
" delete Object.prototype.__temp__;",
|
" delete Object.prototype.__temp__;",
|
||||||
" }",
|
" }",
|
||||||
" delete Object.prototype.__temp__;",
|
" delete Object.prototype.__temp__;",
|
||||||
].join('\n');
|
].join("\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Run code globally with specified context variables in scope
|
Run code globally with specified context variables in scope
|
||||||
@@ -616,7 +618,7 @@ $tw.utils.evalGlobal = function(code,context,filename,sandbox,allowGlobals) {
|
|||||||
fn = Function("return " + code + "\n\n//# sourceURL=" + filename)(); // See https://github.com/TiddlyWiki/TiddlyWiki5/issues/6839
|
fn = Function("return " + code + "\n\n//# sourceURL=" + filename)(); // See https://github.com/TiddlyWiki/TiddlyWiki5/issues/6839
|
||||||
} else {
|
} else {
|
||||||
if(sandbox){
|
if(sandbox){
|
||||||
fn = vm.runInContext(code,sandbox,filename)
|
fn = vm.runInContext(code,sandbox,filename);
|
||||||
} else {
|
} else {
|
||||||
fn = vm.runInThisContext(code,filename);
|
fn = vm.runInThisContext(code,filename);
|
||||||
}
|
}
|
||||||
@@ -727,7 +729,7 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
form.addEventListener("submit",function(event) {
|
form.addEventListener("submit",function(event) {
|
||||||
// Collect the form data
|
// Collect the form data
|
||||||
var data = {},t;
|
var data = {};
|
||||||
$tw.utils.each(form.elements,function(element) {
|
$tw.utils.each(form.elements,function(element) {
|
||||||
if(element.name && element.value) {
|
if(element.name && element.value) {
|
||||||
data[element.name] = element.value;
|
data[element.name] = element.value;
|
||||||
@@ -773,7 +775,7 @@ $tw.utils.PasswordPrompt.prototype.removePrompt = function(promptInfo) {
|
|||||||
promptInfo.form.parentNode.removeChild(promptInfo.form);
|
promptInfo.form.parentNode.removeChild(promptInfo.form);
|
||||||
this.setWrapperDisplay();
|
this.setWrapperDisplay();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Crypto helper object for encrypted content. It maintains the password text in a closure, and provides methods to change
|
Crypto helper object for encrypted content. It maintains the password text in a closure, and provides methods to change
|
||||||
@@ -812,7 +814,7 @@ $tw.utils.Crypto = function() {
|
|||||||
};
|
};
|
||||||
this.hasPassword = function() {
|
this.hasPassword = function() {
|
||||||
return !!currentPassword;
|
return !!currentPassword;
|
||||||
}
|
};
|
||||||
this.encrypt = function(text,password) {
|
this.encrypt = function(text,password) {
|
||||||
// set default ks:256 -- see: http://bitwiseshiftleft.github.io/sjcl/doc/convenience.js.html
|
// set default ks:256 -- see: http://bitwiseshiftleft.github.io/sjcl/doc/convenience.js.html
|
||||||
return callSjcl("encrypt",text,password,{v:1,iter:10000,ks:256,ts:64,mode:"ccm",adata:"",cipher:"aes"});
|
return callSjcl("encrypt",text,password,{v:1,iter:10000,ks:256,ts:64,mode:"ccm",adata:"",cipher:"aes"});
|
||||||
@@ -830,7 +832,7 @@ Execute the module named 'moduleName'. The name can optionally be relative to th
|
|||||||
$tw.modules.execute = function(moduleName,moduleRoot) {
|
$tw.modules.execute = function(moduleName,moduleRoot) {
|
||||||
var name = moduleName;
|
var name = moduleName;
|
||||||
if(moduleName.charAt(0) === ".") {
|
if(moduleName.charAt(0) === ".") {
|
||||||
name = $tw.utils.resolvePath(moduleName,moduleRoot)
|
name = $tw.utils.resolvePath(moduleName,moduleRoot);
|
||||||
}
|
}
|
||||||
if(!$tw.modules.titles[name]) {
|
if(!$tw.modules.titles[name]) {
|
||||||
if($tw.modules.titles[name + ".js"]) {
|
if($tw.modules.titles[name + ".js"]) {
|
||||||
@@ -891,7 +893,6 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
|
|||||||
if(!moduleInfo) {
|
if(!moduleInfo) {
|
||||||
// We could not find the module on this path
|
// We could not find the module on this path
|
||||||
// Try to defer to browserify etc, or node
|
// Try to defer to browserify etc, or node
|
||||||
var deferredModule;
|
|
||||||
if($tw.browser) {
|
if($tw.browser) {
|
||||||
if(window.require) {
|
if(window.require) {
|
||||||
try {
|
try {
|
||||||
@@ -1146,8 +1147,7 @@ enableIndexers - Array of indexer names to enable, or null to use all available
|
|||||||
*/
|
*/
|
||||||
$tw.Wiki = function(options) {
|
$tw.Wiki = function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var self = this,
|
var tiddlers = Object.create(null), // Hashmap of tiddlers
|
||||||
tiddlers = Object.create(null), // Hashmap of tiddlers
|
|
||||||
tiddlerTitles = null, // Array of tiddler titles
|
tiddlerTitles = null, // Array of tiddler titles
|
||||||
getTiddlerTitles = function() {
|
getTiddlerTitles = function() {
|
||||||
if(!tiddlerTitles) {
|
if(!tiddlerTitles) {
|
||||||
@@ -1201,7 +1201,7 @@ $tw.Wiki = function(options) {
|
|||||||
shadow: this.isShadowTiddler(title),
|
shadow: this.isShadowTiddler(title),
|
||||||
exists: this.tiddlerExists(title)
|
exists: this.tiddlerExists(title)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
// Save the new tiddler
|
// Save the new tiddler
|
||||||
tiddlers[title] = tiddler;
|
tiddlers[title] = tiddler;
|
||||||
// Check we've got the title
|
// Check we've got the title
|
||||||
@@ -1211,7 +1211,7 @@ $tw.Wiki = function(options) {
|
|||||||
tiddler: tiddler,
|
tiddler: tiddler,
|
||||||
shadow: this.isShadowTiddler(title),
|
shadow: this.isShadowTiddler(title),
|
||||||
exists: this.tiddlerExists(title)
|
exists: this.tiddlerExists(title)
|
||||||
}
|
};
|
||||||
// Update indexes
|
// Update indexes
|
||||||
this.clearCache(title);
|
this.clearCache(title);
|
||||||
this.clearGlobalCache();
|
this.clearGlobalCache();
|
||||||
@@ -1236,7 +1236,7 @@ $tw.Wiki = function(options) {
|
|||||||
shadow: this.isShadowTiddler(title),
|
shadow: this.isShadowTiddler(title),
|
||||||
exists: this.tiddlerExists(title)
|
exists: this.tiddlerExists(title)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
// Delete the tiddler
|
// Delete the tiddler
|
||||||
delete tiddlers[title];
|
delete tiddlers[title];
|
||||||
// Delete it from the list of titles
|
// Delete it from the list of titles
|
||||||
@@ -1251,7 +1251,7 @@ $tw.Wiki = function(options) {
|
|||||||
tiddler: this.getTiddler(title),
|
tiddler: this.getTiddler(title),
|
||||||
shadow: this.isShadowTiddler(title),
|
shadow: this.isShadowTiddler(title),
|
||||||
exists: this.tiddlerExists(title)
|
exists: this.tiddlerExists(title)
|
||||||
}
|
};
|
||||||
// Update indexes
|
// Update indexes
|
||||||
this.clearCache(title);
|
this.clearCache(title);
|
||||||
this.clearGlobalCache();
|
this.clearGlobalCache();
|
||||||
@@ -1439,8 +1439,7 @@ $tw.Wiki = function(options) {
|
|||||||
|
|
||||||
// Unregister the plugin tiddlers of a particular type, or null/undefined for any type, optionally restricting unregistering to an array of tiddler titles. Returns an array of the titles affected
|
// Unregister the plugin tiddlers of a particular type, or null/undefined for any type, optionally restricting unregistering to an array of tiddler titles. Returns an array of the titles affected
|
||||||
this.unregisterPluginTiddlers = function(pluginType,titles) {
|
this.unregisterPluginTiddlers = function(pluginType,titles) {
|
||||||
var self = this,
|
var unregisteredTitles = [];
|
||||||
unregisteredTitles = [];
|
|
||||||
// Remove any previous registered plugins of this type
|
// Remove any previous registered plugins of this type
|
||||||
for(var t=pluginTiddlers.length-1; t>=0; t--) {
|
for(var t=pluginTiddlers.length-1; t>=0; t--) {
|
||||||
var tiddler = pluginTiddlers[t];
|
var tiddler = pluginTiddlers[t];
|
||||||
@@ -1454,16 +1453,15 @@ $tw.Wiki = function(options) {
|
|||||||
|
|
||||||
// Unpack the currently registered plugins, creating shadow tiddlers for their constituent tiddlers
|
// Unpack the currently registered plugins, creating shadow tiddlers for their constituent tiddlers
|
||||||
this.unpackPluginTiddlers = function() {
|
this.unpackPluginTiddlers = function() {
|
||||||
var self = this;
|
|
||||||
// Sort the plugin titles by the `plugin-priority` field, if this field is missing, default to 1
|
// Sort the plugin titles by the `plugin-priority` field, if this field is missing, default to 1
|
||||||
pluginTiddlers.sort(function(a, b) {
|
pluginTiddlers.sort(function(a, b) {
|
||||||
var priorityA = "plugin-priority" in a.fields ? a.fields["plugin-priority"] : 1;
|
var priorityA = "plugin-priority" in a.fields ? a.fields["plugin-priority"] : 1;
|
||||||
var priorityB = "plugin-priority" in b.fields ? b.fields["plugin-priority"] : 1;
|
var priorityB = "plugin-priority" in b.fields ? b.fields["plugin-priority"] : 1;
|
||||||
if (priorityA !== priorityB) {
|
if(priorityA !== priorityB) {
|
||||||
return priorityA - priorityB;
|
return priorityA - priorityB;
|
||||||
} else if (a.fields.title < b.fields.title) {
|
} else if(a.fields.title < b.fields.title) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (a.fields.title === b.fields.title) {
|
} else if(a.fields.title === b.fields.title) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return +1;
|
return +1;
|
||||||
@@ -1570,7 +1568,7 @@ $tw.Wiki.prototype.processSafeMode = function() {
|
|||||||
// Assemble a report tiddler
|
// Assemble a report tiddler
|
||||||
var titleReportTiddler = "TiddlyWiki Safe Mode",
|
var titleReportTiddler = "TiddlyWiki Safe Mode",
|
||||||
report = [];
|
report = [];
|
||||||
report.push("TiddlyWiki has been started in [[safe mode|https://tiddlywiki.com/static/SafeMode.html]]. All plugins are temporarily disabled. Most customisations have been disabled by renaming the following tiddlers:")
|
report.push("TiddlyWiki has been started in [[safe mode|https://tiddlywiki.com/static/SafeMode.html]]. All plugins are temporarily disabled. Most customisations have been disabled by renaming the following tiddlers:");
|
||||||
// Delete the overrides
|
// Delete the overrides
|
||||||
overrides.forEach(function(title) {
|
overrides.forEach(function(title) {
|
||||||
var tiddler = self.getTiddler(title),
|
var tiddler = self.getTiddler(title),
|
||||||
@@ -1579,7 +1577,7 @@ $tw.Wiki.prototype.processSafeMode = function() {
|
|||||||
self.addTiddler(new $tw.Tiddler(tiddler, {title: newTitle}));
|
self.addTiddler(new $tw.Tiddler(tiddler, {title: newTitle}));
|
||||||
report.push("* [[" + title + "|" + newTitle + "]]");
|
report.push("* [[" + title + "|" + newTitle + "]]");
|
||||||
});
|
});
|
||||||
report.push()
|
report.push();
|
||||||
this.addTiddler(new $tw.Tiddler({title: titleReportTiddler, text: report.join("\n\n")}));
|
this.addTiddler(new $tw.Tiddler({title: titleReportTiddler, text: report.join("\n\n")}));
|
||||||
// Set $:/DefaultTiddlers to point to our report
|
// Set $:/DefaultTiddlers to point to our report
|
||||||
this.addTiddler(new $tw.Tiddler({title: "$:/DefaultTiddlers", text: "[[" + titleReportTiddler + "]]"}));
|
this.addTiddler(new $tw.Tiddler({title: "$:/DefaultTiddlers", text: "[[" + titleReportTiddler + "]]"}));
|
||||||
@@ -2013,7 +2011,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
|||||||
value = $tw.utils.stringifyList(path.relative(rootPath, filename).split(path.sep).slice(0, -1));
|
value = $tw.utils.stringifyList(path.relative(rootPath, filename).split(path.sep).slice(0, -1));
|
||||||
break;
|
break;
|
||||||
case "filepath":
|
case "filepath":
|
||||||
value = path.relative(rootPath, filename).split(path.sep).join('/');
|
value = path.relative(rootPath, filename).split(path.sep).join("/");
|
||||||
break;
|
break;
|
||||||
case "filename":
|
case "filename":
|
||||||
value = path.basename(filename);
|
value = path.basename(filename);
|
||||||
@@ -2066,7 +2064,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return arrayOfFiles;
|
return arrayOfFiles;
|
||||||
}
|
};
|
||||||
// Process the listed tiddlers
|
// Process the listed tiddlers
|
||||||
$tw.utils.each(filesInfo.tiddlers,function(tidInfo) {
|
$tw.utils.each(filesInfo.tiddlers,function(tidInfo) {
|
||||||
if(tidInfo.prefix && tidInfo.suffix) {
|
if(tidInfo.prefix && tidInfo.suffix) {
|
||||||
@@ -2175,7 +2173,7 @@ Returns the path of the plugin folder
|
|||||||
$tw.findLibraryItem = function(name,paths) {
|
$tw.findLibraryItem = function(name,paths) {
|
||||||
var pathIndex = 0;
|
var pathIndex = 0;
|
||||||
do {
|
do {
|
||||||
var pluginPath = path.resolve(paths[pathIndex],"./" + name)
|
var pluginPath = path.resolve(paths[pathIndex],"./" + name);
|
||||||
if(fs.existsSync(pluginPath) && fs.statSync(pluginPath).isDirectory()) {
|
if(fs.existsSync(pluginPath) && fs.statSync(pluginPath).isDirectory()) {
|
||||||
return pluginPath;
|
return pluginPath;
|
||||||
}
|
}
|
||||||
@@ -2534,7 +2532,7 @@ $tw.boot.initStartup = function(options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$tw.boot.loadStartup = function(options){
|
$tw.boot.loadStartup = function(options){
|
||||||
@@ -2551,7 +2549,7 @@ $tw.boot.loadStartup = function(options){
|
|||||||
}
|
}
|
||||||
// Give hooks a chance to modify the store
|
// Give hooks a chance to modify the store
|
||||||
$tw.hooks.invokeHook("th-boot-tiddlers-loaded");
|
$tw.hooks.invokeHook("th-boot-tiddlers-loaded");
|
||||||
}
|
};
|
||||||
$tw.boot.execStartup = function(options){
|
$tw.boot.execStartup = function(options){
|
||||||
// Unpack plugin tiddlers
|
// Unpack plugin tiddlers
|
||||||
$tw.wiki.readPluginInfo();
|
$tw.wiki.readPluginInfo();
|
||||||
@@ -2581,7 +2579,7 @@ $tw.boot.execStartup = function(options){
|
|||||||
$tw.boot.disabledStartupModules = $tw.boot.disabledStartupModules || [];
|
$tw.boot.disabledStartupModules = $tw.boot.disabledStartupModules || [];
|
||||||
// Repeatedly execute the next eligible task
|
// Repeatedly execute the next eligible task
|
||||||
$tw.boot.executeNextStartupTask(options.callback);
|
$tw.boot.executeNextStartupTask(options.callback);
|
||||||
}
|
};
|
||||||
/*
|
/*
|
||||||
Startup TiddlyWiki
|
Startup TiddlyWiki
|
||||||
*/
|
*/
|
||||||
@@ -2600,7 +2598,7 @@ $tw.addUnloadTask = function(task) {
|
|||||||
if($tw.unloadTasks.indexOf(task) === -1) {
|
if($tw.unloadTasks.indexOf(task) === -1) {
|
||||||
$tw.unloadTasks.push(task);
|
$tw.unloadTasks.push(task);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Execute the remaining eligible startup tasks
|
Execute the remaining eligible startup tasks
|
||||||
@@ -2647,7 +2645,7 @@ $tw.boot.executeNextStartupTask = function(callback) {
|
|||||||
}
|
}
|
||||||
taskIndex++;
|
taskIndex++;
|
||||||
}
|
}
|
||||||
if(typeof callback === 'function') {
|
if(typeof callback === "function") {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
|||||||
created: 20250909171928024
|
created: 20250909171928024
|
||||||
modified: 20251110133437795
|
modified: 20251110133437795
|
||||||
tags: Community/Team
|
tags: Community/Team
|
||||||
|
leader: @kjharcombe
|
||||||
team: @MotovunJack
|
team: @MotovunJack
|
||||||
title: Infrastructure Team
|
title: Infrastructure Team
|
||||||
|
|
||||||
@@ -12,4 +13,4 @@ The infrastructure includes:
|
|||||||
* github.com/TiddlyWiki
|
* github.com/TiddlyWiki
|
||||||
* tiddlywiki.com DNS
|
* tiddlywiki.com DNS
|
||||||
* Netlify account for PR previews
|
* Netlify account for PR previews
|
||||||
* edit.tiddlywiki.com
|
* edit.tiddlywiki.com
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
title: TiddlyWiki Team
|
||||||
|
tags: Community/Team
|
||||||
|
modified: 20260708095630754
|
||||||
|
created: 20260708095630754
|
||||||
|
leader: @BurningTreeC
|
||||||
|
team:
|
||||||
|
|
||||||
|
The TiddlyDesktop development repository is at https://github.com/TiddlyWiki/TiddlyDesktop
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -103,7 +103,7 @@ Commander.prototype.executeNextCommand = function() {
|
|||||||
c = new command.Command(params,this);
|
c = new command.Command(params,this);
|
||||||
err = c.execute();
|
err = c.execute();
|
||||||
if(err && typeof err.then === "function") {
|
if(err && typeof err.then === "function") {
|
||||||
err.then(e => { e ? this.callback(e) : this.executeNextCommand(); });
|
err.then((e) => { e ? this.callback(e) : this.executeNextCommand(); });
|
||||||
} else if(err) {
|
} else if(err) {
|
||||||
this.callback(err);
|
this.callback(err);
|
||||||
} else {
|
} else {
|
||||||
@@ -120,7 +120,7 @@ Commander.prototype.executeNextCommand = function() {
|
|||||||
});
|
});
|
||||||
err = c.execute();
|
err = c.execute();
|
||||||
if(err && typeof err.then === "function") {
|
if(err && typeof err.then === "function") {
|
||||||
err.then(e => { if(e) this.callback(e); });
|
err.then((e) => { if(e) this.callback(e); });
|
||||||
} else if(err) {
|
} else if(err) {
|
||||||
this.callback(err);
|
this.callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ Command.prototype.execute = function() {
|
|||||||
if(!filter) {
|
if(!filter) {
|
||||||
return "No filter specified";
|
return "No filter specified";
|
||||||
}
|
}
|
||||||
var commands = this.commander.wiki.filterTiddlers(filter)
|
var commands = this.commander.wiki.filterTiddlers(filter);
|
||||||
if(commands.length === 0) {
|
if(commands.length === 0) {
|
||||||
return "No tiddlers found for filter '" + filter + "'";
|
return "No tiddlers found for filter '" + filter + "'";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ Command.prototype.execute = function() {
|
|||||||
if(this.params.length < 1) {
|
if(this.params.length < 1) {
|
||||||
return "Missing filter";
|
return "Missing filter";
|
||||||
}
|
}
|
||||||
var self = this,
|
var wiki = this.commander.wiki,
|
||||||
wiki = this.commander.wiki,
|
|
||||||
filter = this.params[0],
|
filter = this.params[0],
|
||||||
tiddlers = wiki.filterTiddlers(filter);
|
tiddlers = wiki.filterTiddlers(filter);
|
||||||
$tw.utils.each(tiddlers,function(title) {
|
$tw.utils.each(tiddlers,function(title) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ Command.prototype.fetchFiles = function(options) {
|
|||||||
// Get the list of URLs
|
// Get the list of URLs
|
||||||
var urls;
|
var urls;
|
||||||
if(options.url) {
|
if(options.url) {
|
||||||
urls = [options.url]
|
urls = [options.url];
|
||||||
} else if(options.urlFilter) {
|
} else if(options.urlFilter) {
|
||||||
urls = this.commander.wiki.filterTiddlers(options.urlFilter);
|
urls = this.commander.wiki.filterTiddlers(options.urlFilter);
|
||||||
} else {
|
} else {
|
||||||
@@ -96,30 +96,30 @@ Command.prototype.fetchFile = function(url,options,callback,redirectCount) {
|
|||||||
var self = this,
|
var self = this,
|
||||||
lib = url.substr(0,8) === "https://" ? require("https") : require("http");
|
lib = url.substr(0,8) === "https://" ? require("https") : require("http");
|
||||||
lib.get(url).on("response",function(response) {
|
lib.get(url).on("response",function(response) {
|
||||||
var type = (response.headers["content-type"] || "").split(";")[0],
|
var type = (response.headers["content-type"] || "").split(";")[0],
|
||||||
data = [];
|
data = [];
|
||||||
self.commander.write("Reading " + url + ": ");
|
self.commander.write("Reading " + url + ": ");
|
||||||
response.on("data",function(chunk) {
|
response.on("data",function(chunk) {
|
||||||
data.push(chunk);
|
data.push(chunk);
|
||||||
self.commander.write(".");
|
self.commander.write(".");
|
||||||
});
|
});
|
||||||
response.on("end",function() {
|
response.on("end",function() {
|
||||||
self.commander.write("\n");
|
self.commander.write("\n");
|
||||||
if(response.statusCode === 200) {
|
if(response.statusCode === 200) {
|
||||||
self.processBody(Buffer.concat(data),type,options,url);
|
self.processBody(Buffer.concat(data),type,options,url);
|
||||||
callback(null);
|
callback(null);
|
||||||
} else {
|
} else {
|
||||||
if(response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
|
if(response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
|
||||||
return self.fetchFile(response.headers.location,options,callback,redirectCount + 1);
|
return self.fetchFile(response.headers.location,options,callback,redirectCount + 1);
|
||||||
} else {
|
} else {
|
||||||
return callback("Error " + response.statusCode + " retrieving " + url)
|
return callback("Error " + response.statusCode + " retrieving " + url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
response.on("error",function(e) {
|
response.on("error",function(e) {
|
||||||
console.log("Error on GET request: " + e);
|
console.log("Error on GET request: " + e);
|
||||||
callback(e);
|
callback(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -153,18 +153,18 @@ Command.prototype.processBody = function(body,type,options,url) {
|
|||||||
if(options.transformFilter) {
|
if(options.transformFilter) {
|
||||||
var transformedTitle = (incomingWiki.filterTiddlers(options.transformFilter,null,self.commander.wiki.makeTiddlerIterator([title])) || [""])[0];
|
var transformedTitle = (incomingWiki.filterTiddlers(options.transformFilter,null,self.commander.wiki.makeTiddlerIterator([title])) || [""])[0];
|
||||||
if(transformedTitle) {
|
if(transformedTitle) {
|
||||||
self.commander.log("Importing " + title + " as " + transformedTitle)
|
self.commander.log("Importing " + title + " as " + transformedTitle);
|
||||||
newTiddler = new $tw.Tiddler(tiddler,{title: transformedTitle});
|
newTiddler = new $tw.Tiddler(tiddler,{title: transformedTitle});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.commander.log("Importing " + title)
|
self.commander.log("Importing " + title);
|
||||||
newTiddler = tiddler;
|
newTiddler = tiddler;
|
||||||
}
|
}
|
||||||
self.commander.wiki.importTiddler(newTiddler);
|
self.commander.wiki.importTiddler(newTiddler);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.commander.log("Imported " + count + " tiddlers")
|
self.commander.log("Imported " + count + " tiddlers");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Command = Command;
|
exports.Command = Command;
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ var Command = function(params,commander,callback) {
|
|||||||
|
|
||||||
Command.prototype.execute = function() {
|
Command.prototype.execute = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
fs = require("fs"),
|
fs = require("fs");
|
||||||
path = require("path");
|
|
||||||
if(this.params.length < 2) {
|
if(this.params.length < 2) {
|
||||||
return "Missing parameters";
|
return "Missing parameters";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ var Command = function(params,commander) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.execute = function() {
|
Command.prototype.execute = function() {
|
||||||
var fs = require("fs"),
|
var fs = require("fs");
|
||||||
path = require("path");
|
|
||||||
// Check that we don't already have a valid wiki folder
|
// Check that we don't already have a valid wiki folder
|
||||||
if($tw.boot.wikiTiddlersPath || ($tw.utils.isDirectory($tw.boot.wikiPath) && !$tw.utils.isDirectoryEmpty($tw.boot.wikiPath))) {
|
if($tw.boot.wikiTiddlersPath || ($tw.utils.isDirectory($tw.boot.wikiPath) && !$tw.utils.isDirectoryEmpty($tw.boot.wikiPath))) {
|
||||||
return "Wiki folder is not empty";
|
return "Wiki folder is not empty";
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ exports.info = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var Command = function(params,commander,callback) {
|
var Command = function(params,commander,callback) {
|
||||||
var self = this;
|
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.commander = commander;
|
this.commander = commander;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ var Command = function(params,commander,callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.execute = function() {
|
Command.prototype.execute = function() {
|
||||||
var self = this,
|
var self = this;
|
||||||
fs = require("fs"),
|
|
||||||
path = require("path");
|
|
||||||
if(this.params.length < 1) {
|
if(this.params.length < 1) {
|
||||||
return "Missing filename";
|
return "Missing filename";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ var Command = function(params,commander,callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.execute = function() {
|
Command.prototype.execute = function() {
|
||||||
var fs = require("fs"),
|
var path = require("path");
|
||||||
path = require("path");
|
|
||||||
if(this.params.length < 1) {
|
if(this.params.length < 1) {
|
||||||
return "Missing output path";
|
return "Missing output path";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,59 +7,57 @@ Render individual tiddlers and save the results to the specified files
|
|||||||
|
|
||||||
\*/
|
\*/
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js");
|
exports.info = {
|
||||||
|
name: "render",
|
||||||
|
synchronous: true
|
||||||
|
};
|
||||||
|
|
||||||
exports.info = {
|
var Command = function(params,commander,callback) {
|
||||||
name: "render",
|
this.params = params;
|
||||||
synchronous: true
|
this.commander = commander;
|
||||||
};
|
this.callback = callback;
|
||||||
|
};
|
||||||
|
|
||||||
var Command = function(params,commander,callback) {
|
Command.prototype.execute = function() {
|
||||||
this.params = params;
|
if(this.params.length < 1) {
|
||||||
this.commander = commander;
|
return "Missing tiddler filter";
|
||||||
this.callback = callback;
|
}
|
||||||
};
|
var self = this,
|
||||||
|
fs = require("fs"),
|
||||||
Command.prototype.execute = function() {
|
path = require("path"),
|
||||||
if(this.params.length < 1) {
|
wiki = this.commander.wiki,
|
||||||
return "Missing tiddler filter";
|
tiddlerFilter = this.params[0],
|
||||||
|
filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]",
|
||||||
|
type = this.params[2] || "text/html",
|
||||||
|
template = this.params[3],
|
||||||
|
variableList = this.params.slice(4),
|
||||||
|
tiddlers = wiki.filterTiddlers(tiddlerFilter),
|
||||||
|
variables = Object.create(null);
|
||||||
|
while(variableList.length >= 2) {
|
||||||
|
variables[variableList[0]] = variableList[1];
|
||||||
|
variableList = variableList.slice(2);
|
||||||
|
}
|
||||||
|
$tw.utils.each(tiddlers,function(title) {
|
||||||
|
var filenameResults = wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]));
|
||||||
|
if(filenameResults.length > 0) {
|
||||||
|
var filepath = path.resolve(self.commander.outputPath,filenameResults[0]);
|
||||||
|
if(self.commander.verbose) {
|
||||||
|
console.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
|
||||||
|
}
|
||||||
|
var parser = wiki.parseTiddler(template || title),
|
||||||
|
widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title,storyTiddler: title})}),
|
||||||
|
container = $tw.fakeDocument.createElement("div");
|
||||||
|
widgetNode.render(container,null);
|
||||||
|
var text = type === "text/html" ? container.innerHTML : container.textContent;
|
||||||
|
$tw.utils.createFileDirectories(filepath);
|
||||||
|
fs.writeFileSync(filepath,text,"utf8");
|
||||||
|
} else {
|
||||||
|
console.log("Not rendering \"" + title + "\" because the filename filter returned an empty result");
|
||||||
}
|
}
|
||||||
var self = this,
|
});
|
||||||
fs = require("fs"),
|
return null;
|
||||||
path = require("path"),
|
};
|
||||||
wiki = this.commander.wiki,
|
|
||||||
tiddlerFilter = this.params[0],
|
|
||||||
filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]",
|
|
||||||
type = this.params[2] || "text/html",
|
|
||||||
template = this.params[3],
|
|
||||||
variableList = this.params.slice(4),
|
|
||||||
tiddlers = wiki.filterTiddlers(tiddlerFilter),
|
|
||||||
variables = Object.create(null);
|
|
||||||
while(variableList.length >= 2) {
|
|
||||||
variables[variableList[0]] = variableList[1];
|
|
||||||
variableList = variableList.slice(2);
|
|
||||||
}
|
|
||||||
$tw.utils.each(tiddlers,function(title) {
|
|
||||||
var filenameResults = wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]));
|
|
||||||
if(filenameResults.length > 0) {
|
|
||||||
var filepath = path.resolve(self.commander.outputPath,filenameResults[0]);
|
|
||||||
if(self.commander.verbose) {
|
|
||||||
console.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
|
|
||||||
}
|
|
||||||
var parser = wiki.parseTiddler(template || title),
|
|
||||||
widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title,storyTiddler: title})}),
|
|
||||||
container = $tw.fakeDocument.createElement("div");
|
|
||||||
widgetNode.render(container,null);
|
|
||||||
var text = type === "text/html" ? container.innerHTML : container.textContent;
|
|
||||||
$tw.utils.createFileDirectories(filepath);
|
|
||||||
fs.writeFileSync(filepath,text,"utf8");
|
|
||||||
} else {
|
|
||||||
console.log("Not rendering \"" + title + "\" because the filename filter returned an empty result");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Command = Command;
|
exports.Command = Command;
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ Command to render several tiddlers to a folder of files
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js");
|
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
name: "rendertiddlers",
|
name: "rendertiddlers",
|
||||||
synchronous: true
|
synchronous: true
|
||||||
|
|||||||
@@ -7,57 +7,56 @@ Saves individual tiddlers in their raw text or binary format to the specified fi
|
|||||||
|
|
||||||
\*/
|
\*/
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
name: "save",
|
name: "save",
|
||||||
synchronous: true
|
synchronous: true
|
||||||
};
|
};
|
||||||
|
|
||||||
var Command = function(params,commander,callback) {
|
var Command = function(params,commander,callback) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.commander = commander;
|
this.commander = commander;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.execute = function() {
|
Command.prototype.execute = function() {
|
||||||
if(this.params.length < 1) {
|
if(this.params.length < 1) {
|
||||||
return "Missing filename filter";
|
return "Missing filename filter";
|
||||||
}
|
}
|
||||||
var self = this,
|
var self = this,
|
||||||
fs = require("fs"),
|
path = require("path"),
|
||||||
path = require("path"),
|
result = null,
|
||||||
result = null,
|
wiki = this.commander.wiki,
|
||||||
wiki = this.commander.wiki,
|
tiddlerFilter = this.params[0],
|
||||||
tiddlerFilter = this.params[0],
|
filenameFilter = this.params[1] || "[is[tiddler]]",
|
||||||
filenameFilter = this.params[1] || "[is[tiddler]]",
|
tiddlers = wiki.filterTiddlers(tiddlerFilter);
|
||||||
tiddlers = wiki.filterTiddlers(tiddlerFilter);
|
$tw.utils.each(tiddlers,function(title) {
|
||||||
$tw.utils.each(tiddlers,function(title) {
|
if(!result) {
|
||||||
if(!result) {
|
var tiddler = self.commander.wiki.getTiddler(title);
|
||||||
var tiddler = self.commander.wiki.getTiddler(title);
|
if(tiddler) {
|
||||||
if(tiddler) {
|
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
||||||
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
directory: path.resolve(self.commander.outputPath),
|
||||||
directory: path.resolve(self.commander.outputPath),
|
pathFilters: [filenameFilter],
|
||||||
pathFilters: [filenameFilter],
|
wiki: wiki,
|
||||||
wiki: wiki,
|
fileInfo: {
|
||||||
fileInfo: {
|
overwrite: true
|
||||||
overwrite: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(self.commander.verbose) {
|
|
||||||
console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\"");
|
|
||||||
}
|
}
|
||||||
try {
|
});
|
||||||
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
|
if(self.commander.verbose) {
|
||||||
} catch (err) {
|
console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\"");
|
||||||
result = "Error saving tiddler \"" + title + "\", to file: \"" + fileInfo.filepath + "\"";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = "Tiddler '" + title + "' not found";
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
|
||||||
|
} catch (err) {
|
||||||
|
result = "Error saving tiddler \"" + title + "\", to file: \"" + fileInfo.filepath + "\"";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = "Tiddler '" + title + "' not found";
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return result;
|
});
|
||||||
};
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
exports.Command = Command;
|
exports.Command = Command;
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ Command to save several tiddlers to a folder of files
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js");
|
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
name: "savetiddlers",
|
name: "savetiddlers",
|
||||||
synchronous: true
|
synchronous: true
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Command.prototype.execute = function() {
|
|||||||
namedParames,
|
namedParames,
|
||||||
tiddlerFilter,
|
tiddlerFilter,
|
||||||
options = {};
|
options = {};
|
||||||
if (regFilter.test(this.params[1])) {
|
if(regFilter.test(this.params[1])) {
|
||||||
namedParames = this.commander.extractNamedParameters(this.params.slice(1));
|
namedParames = this.commander.extractNamedParameters(this.params.slice(1));
|
||||||
tiddlerFilter = namedParames.filter || "[all[tiddlers]]";
|
tiddlerFilter = namedParames.filter || "[all[tiddlers]]";
|
||||||
} else {
|
} else {
|
||||||
@@ -177,13 +177,13 @@ WikiFolderMaker.prototype.saveCustomPlugin = function(pluginTiddler) {
|
|||||||
$tw.utils.each(pluginTiddlers,function(tiddler,title) {
|
$tw.utils.each(pluginTiddlers,function(tiddler,title) {
|
||||||
if(!tiddler.title) {
|
if(!tiddler.title) {
|
||||||
tiddler.title = title;
|
tiddler.title = title;
|
||||||
}
|
}
|
||||||
self.saveTiddler(directory,new $tw.Tiddler(tiddler));
|
self.saveTiddler(directory,new $tw.Tiddler(tiddler));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
WikiFolderMaker.prototype.saveTiddler = function(directory,tiddler) {
|
WikiFolderMaker.prototype.saveTiddler = function(directory,tiddler) {
|
||||||
var title = tiddler.fields.title, fileInfo, pathFilters, extFilters;
|
var fileInfo, pathFilters, extFilters;
|
||||||
if(this.wiki.tiddlerExists("$:/config/FileSystemPaths")) {
|
if(this.wiki.tiddlerExists("$:/config/FileSystemPaths")) {
|
||||||
pathFilters = this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n");
|
pathFilters = this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ exports.info = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var Command = function(params,commander,callback) {
|
var Command = function(params,commander,callback) {
|
||||||
var self = this;
|
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.commander = commander;
|
this.commander = commander;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ Command to modify selected tiddlers to set a field to the text of a template tid
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js");
|
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
name: "setfield",
|
name: "setfield",
|
||||||
synchronous: true
|
synchronous: true
|
||||||
@@ -26,8 +24,7 @@ Command.prototype.execute = function() {
|
|||||||
if(this.params.length < 4) {
|
if(this.params.length < 4) {
|
||||||
return "Missing parameters";
|
return "Missing parameters";
|
||||||
}
|
}
|
||||||
var self = this,
|
var wiki = this.commander.wiki,
|
||||||
wiki = this.commander.wiki,
|
|
||||||
filter = this.params[0],
|
filter = this.params[0],
|
||||||
fieldname = this.params[1] || "text",
|
fieldname = this.params[1] || "text",
|
||||||
templatetitle = this.params[2],
|
templatetitle = this.params[2],
|
||||||
|
|||||||
+47
-20
@@ -26,7 +26,7 @@ exports.getSubdirectories = function(dirPath) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return subdirs;
|
return subdirs;
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Recursively (and synchronously) copy a directory and all its content
|
Recursively (and synchronously) copy a directory and all its content
|
||||||
@@ -46,8 +46,7 @@ exports.copyDirectory = function(srcPath,dstPath) {
|
|||||||
}
|
}
|
||||||
// Function to copy a folder full of files
|
// Function to copy a folder full of files
|
||||||
var copy = function(srcPath,dstPath) {
|
var copy = function(srcPath,dstPath) {
|
||||||
var srcStats = fs.lstatSync(srcPath),
|
var srcStats = fs.lstatSync(srcPath);
|
||||||
dstExists = fs.existsSync(dstPath);
|
|
||||||
if(srcStats.isFile()) {
|
if(srcStats.isFile()) {
|
||||||
$tw.utils.copyFile(srcPath,dstPath);
|
$tw.utils.copyFile(srcPath,dstPath);
|
||||||
} else if(srcStats.isDirectory()) {
|
} else if(srcStats.isDirectory()) {
|
||||||
@@ -83,7 +82,7 @@ exports.copyFile = function(srcPath,dstPath) {
|
|||||||
dstFile = fs.openSync(dstPath,"w"),
|
dstFile = fs.openSync(dstPath,"w"),
|
||||||
bytesRead = 1,
|
bytesRead = 1,
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while (bytesRead > 0) {
|
while(bytesRead > 0) {
|
||||||
bytesRead = fs.readSync(srcFile,fileBuffer,0,FILE_BUFFER_LENGTH,pos);
|
bytesRead = fs.readSync(srcFile,fileBuffer,0,FILE_BUFFER_LENGTH,pos);
|
||||||
fs.writeSync(dstFile,fileBuffer,0,bytesRead);
|
fs.writeSync(dstFile,fileBuffer,0,bytesRead);
|
||||||
pos += bytesRead;
|
pos += bytesRead;
|
||||||
@@ -148,7 +147,7 @@ exports.deleteDirectory = function(dirPath) {
|
|||||||
fs.unlinkSync(currPath);
|
fs.unlinkSync(currPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.rmdirSync(dirPath);
|
fs.rmdirSync(dirPath);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -218,6 +217,11 @@ exports.generateTiddlerFileInfo = function(tiddler,options) {
|
|||||||
fileInfo.isEditableFile = true;
|
fileInfo.isEditableFile = true;
|
||||||
fileInfo.originalpath = options.fileInfo.originalpath;
|
fileInfo.originalpath = options.fileInfo.originalpath;
|
||||||
}
|
}
|
||||||
|
// Propagate the pinFilepath flag (so generateTiddlerFilepath can short-circuit
|
||||||
|
// FileSystemPaths and write back to the original location)
|
||||||
|
if(options.fileInfo && !!options.fileInfo.pinFilepath) {
|
||||||
|
fileInfo.pinFilepath = true;
|
||||||
|
}
|
||||||
// Check if the tiddler has any unsafe fields that can't be expressed in a .tid or .meta file: containing control characters, or leading/trailing whitespace
|
// Check if the tiddler has any unsafe fields that can't be expressed in a .tid or .meta file: containing control characters, or leading/trailing whitespace
|
||||||
var hasUnsafeFields = false;
|
var hasUnsafeFields = false;
|
||||||
$tw.utils.each(tiddler.getFieldStrings(),function(value,fieldName) {
|
$tw.utils.each(tiddler.getFieldStrings(),function(value,fieldName) {
|
||||||
@@ -255,7 +259,7 @@ exports.generateTiddlerFileInfo = function(tiddler,options) {
|
|||||||
// Overriding to the .tid extension needs special handling
|
// Overriding to the .tid extension needs special handling
|
||||||
fileInfo.type = "application/x-tiddler";
|
fileInfo.type = "application/x-tiddler";
|
||||||
fileInfo.hasMetaFile = false;
|
fileInfo.hasMetaFile = false;
|
||||||
} else if (metaExt === ".json") {
|
} else if(metaExt === ".json") {
|
||||||
// Overriding to the .json extension needs special handling
|
// Overriding to the .json extension needs special handling
|
||||||
fileInfo.type = "application/json";
|
fileInfo.type = "application/json";
|
||||||
fileInfo.hasMetaFile = false;
|
fileInfo.hasMetaFile = false;
|
||||||
@@ -320,9 +324,16 @@ exports.generateTiddlerFilepath = function(title,options) {
|
|||||||
extension = options.extension || "",
|
extension = options.extension || "",
|
||||||
originalpath = (options.fileInfo && options.fileInfo.originalpath) ? options.fileInfo.originalpath : "",
|
originalpath = (options.fileInfo && options.fileInfo.originalpath) ? options.fileInfo.originalpath : "",
|
||||||
overwrite = options.fileInfo && options.fileInfo.overwrite || false,
|
overwrite = options.fileInfo && options.fileInfo.overwrite || false,
|
||||||
|
pinFilepath = !!(options.fileInfo && options.fileInfo.pinFilepath),
|
||||||
filepath;
|
filepath;
|
||||||
|
// If the tiddler's filepath is pinned via tiddlywiki.files, the originalpath
|
||||||
|
// wins and the path filters are skipped entirely.
|
||||||
|
if(pinFilepath && originalpath) {
|
||||||
|
var pinnedExt = path.extname(originalpath);
|
||||||
|
filepath = originalpath.substring(0,originalpath.length - pinnedExt.length);
|
||||||
|
}
|
||||||
// Check if any of the pathFilters applies
|
// Check if any of the pathFilters applies
|
||||||
if(options.pathFilters && options.wiki) {
|
if(!filepath && options.pathFilters && options.wiki) {
|
||||||
$tw.utils.each(options.pathFilters,function(filter) {
|
$tw.utils.each(options.pathFilters,function(filter) {
|
||||||
if(!filepath) {
|
if(!filepath) {
|
||||||
var source = options.wiki.makeTiddlerIterator([title]),
|
var source = options.wiki.makeTiddlerIterator([title]),
|
||||||
@@ -337,26 +348,42 @@ exports.generateTiddlerFilepath = function(title,options) {
|
|||||||
//Use the originalpath without the extension
|
//Use the originalpath without the extension
|
||||||
var ext = path.extname(originalpath);
|
var ext = path.extname(originalpath);
|
||||||
filepath = originalpath.substring(0,originalpath.length - ext.length);
|
filepath = originalpath.substring(0,originalpath.length - ext.length);
|
||||||
|
// normalise "\" to "/" so the sanitiser keeps subdirectories
|
||||||
|
// (it strips "\", not "/") instead of flattening them.
|
||||||
|
filepath = filepath.split(path.sep).join("/");
|
||||||
} else if(!filepath) {
|
} else if(!filepath) {
|
||||||
filepath = title;
|
filepath = title;
|
||||||
// Remove any forward or backward slashes so we don't create directories
|
// Remove any forward or backward slashes so we don't create directories
|
||||||
filepath = filepath.replace(/\/|\\/g,"_");
|
filepath = filepath.replace(/\/|\\/g,"_");
|
||||||
}
|
}
|
||||||
// Replace any Windows control codes
|
|
||||||
filepath = filepath.replace(/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i,"_$1_");
|
|
||||||
// Replace any leading spaces with the same number of underscores
|
// Replace any leading spaces with the same number of underscores
|
||||||
filepath = filepath.replace(/^ +/,function (u) { return u.replace(/ /g, "_")});
|
filepath = filepath.replace(/^ +/,function (u) { return u.replace(/ /g, "_");});
|
||||||
//If the path does not start with "." or ".." && a path seperator, then
|
//If the path does not start with "." or ".." && a path seperator, then
|
||||||
if(!/^\.{1,2}[/\\]/g.test(filepath)) {
|
if(!/^\.{1,2}[/\\]/g.test(filepath)) {
|
||||||
// Don't let the filename start with any dots because such files are invisible on *nix
|
// Don't let the filename start with any dots because such files are invisible on *nix
|
||||||
filepath = filepath.replace(/^\.+/g,function (u) { return u.replace(/\./g, "_")});
|
filepath = filepath.replace(/^\.+/g,function (u) { return u.replace(/\./g, "_");});
|
||||||
}
|
}
|
||||||
// Replace any Unicode control codes
|
// Replace any Unicode control codes
|
||||||
filepath = filepath.replace(/[\x00-\x1f\x80-\x9f]/g,"_");
|
filepath = filepath.replace(/[\x00-\x1f\x80-\x9f]/g,"_");
|
||||||
// Replace any characters that can't be used in cross-platform filenames
|
// Replace any characters that can't be used in cross-platform filenames.
|
||||||
filepath = $tw.utils.transliterate(filepath.replace(/<|>|~|\:|\"|\||\?|\*|\^/g,"_"));
|
if(!pinFilepath) {
|
||||||
|
filepath = $tw.utils.transliterate(filepath.replace(/<|>|~|\:|\"|\||\?|\*|\^|\\/g,"_"));
|
||||||
|
}
|
||||||
|
// Per segment (catches "sub/CON"), MUST be after transliterate which can create a
|
||||||
|
// reserved name. Reserved names are wrapped on every path incl pinned;
|
||||||
|
// trailing dots/spaces (Windows strips) fixed for generated names, not pinned.
|
||||||
|
filepath = filepath.split("/").map(function(segment) {
|
||||||
|
if(segment === "" || segment === "." || segment === "..") {
|
||||||
|
return segment;
|
||||||
|
}
|
||||||
|
segment = segment.replace(/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i,"_$1_");
|
||||||
|
if(!pinFilepath) {
|
||||||
|
segment = segment.replace(/[. ]+$/,function(u) { return u.replace(/[. ]/g,"_"); });
|
||||||
|
}
|
||||||
|
return segment;
|
||||||
|
}).join("/");
|
||||||
// Replace any dots or spaces at the end of the extension with the same number of underscores
|
// Replace any dots or spaces at the end of the extension with the same number of underscores
|
||||||
extension = extension.replace(/[\. ]+$/, function (u) { return u.replace(/[\. ]/g, "_")});
|
extension = extension.replace(/[\. ]+$/, function (u) { return u.replace(/[\. ]/g, "_");});
|
||||||
// Truncate the extension if it is too long
|
// Truncate the extension if it is too long
|
||||||
if(extension.length > 32) {
|
if(extension.length > 32) {
|
||||||
extension = extension.substr(0,32);
|
extension = extension.substr(0,32);
|
||||||
@@ -382,9 +409,9 @@ exports.generateTiddlerFilepath = function(title,options) {
|
|||||||
}
|
}
|
||||||
// Add a uniquifier if the file already exists (default)
|
// Add a uniquifier if the file already exists (default)
|
||||||
var fullPath = path.resolve(directory, filepath + extension);
|
var fullPath = path.resolve(directory, filepath + extension);
|
||||||
if (!overwrite) {
|
if(!overwrite) {
|
||||||
var oldPath = (options.fileInfo) ? options.fileInfo.filepath : undefined,
|
var oldPath = (options.fileInfo) ? options.fileInfo.filepath : undefined,
|
||||||
count = 0;
|
count = 0;
|
||||||
do {
|
do {
|
||||||
fullPath = path.resolve(directory,filepath + (count ? "_" + count : "") + extension);
|
fullPath = path.resolve(directory,filepath + (count ? "_" + count : "") + extension);
|
||||||
if(oldPath && oldPath == fullPath) break;
|
if(oldPath && oldPath == fullPath) break;
|
||||||
@@ -401,7 +428,7 @@ exports.generateTiddlerFilepath = function(title,options) {
|
|||||||
writePath.indexOf(path.resolve(directory)) == 0 ||
|
writePath.indexOf(path.resolve(directory)) == 0 ||
|
||||||
writePath.indexOf(path.resolve($tw.boot.wikiPath)) == 0 ||
|
writePath.indexOf(path.resolve($tw.boot.wikiPath)) == 0 ||
|
||||||
writePath.indexOf(path.resolve($tw.boot.wikiTiddlersPath,originalpath)) == 0 );
|
writePath.indexOf(path.resolve($tw.boot.wikiTiddlersPath,originalpath)) == 0 );
|
||||||
}
|
}
|
||||||
if(encode) {
|
if(encode) {
|
||||||
writePath = path.resolve(directory,$tw.utils.encodeURIComponentExtended(fullPath));
|
writePath = path.resolve(directory,$tw.utils.encodeURIComponentExtended(fullPath));
|
||||||
}
|
}
|
||||||
@@ -521,12 +548,12 @@ Cleanup old files on disk, by comparing the options values:
|
|||||||
*/
|
*/
|
||||||
exports.cleanupTiddlerFiles = function(options,callback) {
|
exports.cleanupTiddlerFiles = function(options,callback) {
|
||||||
var adaptorInfo = options.adaptorInfo || {},
|
var adaptorInfo = options.adaptorInfo || {},
|
||||||
bootInfo = options.bootInfo || {},
|
bootInfo = options.bootInfo || {},
|
||||||
title = options.title || "undefined";
|
title = options.title || "undefined";
|
||||||
if(adaptorInfo.filepath && bootInfo.filepath && adaptorInfo.filepath !== bootInfo.filepath) {
|
if(adaptorInfo.filepath && bootInfo.filepath && adaptorInfo.filepath !== bootInfo.filepath) {
|
||||||
$tw.utils.deleteTiddlerFile(adaptorInfo,function(err) {
|
$tw.utils.deleteTiddlerFile(adaptorInfo,function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
|
if((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
|
||||||
// Error deleting the previous file on disk, should fail gracefully
|
// Error deleting the previous file on disk, should fail gracefully
|
||||||
$tw.syncer.displayError("Server desynchronized. Error cleaning up previous file for tiddler: \""+title+"\"",err);
|
$tw.syncer.displayError("Server desynchronized. Error cleaning up previous file for tiddler: \""+title+"\"",err);
|
||||||
return callback(null,bootInfo);
|
return callback(null,bootInfo);
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ Authenticator for WWW basic authentication
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if($tw.node) {
|
if($tw.node) {
|
||||||
var util = require("util"),
|
var fs = require("fs"),
|
||||||
fs = require("fs"),
|
|
||||||
url = require("url"),
|
|
||||||
path = require("path");
|
path = require("path");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ exports.info = {
|
|||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler")),
|
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler")),
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
"Content-Type": state.server.get("root-serve-type")
|
"Content-Type": state.server.get("root-serve-type")
|
||||||
};
|
};
|
||||||
state.sendResponse(200,responseHeaders,text);
|
state.sendResponse(200,responseHeaders,text);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ exports.info = {
|
|||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var title = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
var title = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||||
fields = $tw.utils.parseJSONSafe(state.data);
|
fields = $tw.utils.parseJSONSafe(state.data);
|
||||||
// Pull up any subfields in the `fields` object
|
// Pull up any subfields in the `fields` object
|
||||||
if(fields.fields) {
|
if(fields.fields) {
|
||||||
$tw.utils.each(fields.fields,function(field,name) {
|
$tw.utils.each(fields.fields,function(field,name) {
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ Serve tiddlers over http
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
let fs, path, crypto, zlib, URL;
|
||||||
|
|
||||||
if($tw.node) {
|
if($tw.node) {
|
||||||
var util = require("util"),
|
fs = require("fs"),
|
||||||
fs = require("fs"),
|
path = require("path"),
|
||||||
url = require("url"),
|
crypto = require("crypto"),
|
||||||
path = require("path"),
|
zlib = require("zlib");
|
||||||
querystring = require("querystring"),
|
URL = require("url").URL;
|
||||||
crypto = require("crypto"),
|
|
||||||
zlib = require("zlib");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -41,7 +41,7 @@ function Server(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Setup the default required plugins
|
// Setup the default required plugins
|
||||||
this.requiredPlugins = this.get("required-plugins").split(',');
|
this.requiredPlugins = this.get("required-plugins").split(",");
|
||||||
// Initialise CORS
|
// Initialise CORS
|
||||||
this.corsEnable = this.get("cors-enable") === "yes";
|
this.corsEnable = this.get("cors-enable") === "yes";
|
||||||
// Initialise CSRF
|
// Initialise CSRF
|
||||||
@@ -62,9 +62,9 @@ function Server(options) {
|
|||||||
this.authorizationPrincipals = {
|
this.authorizationPrincipals = {
|
||||||
readers: (this.get("readers") || authorizedUserName).split(",").map($tw.utils.trim),
|
readers: (this.get("readers") || authorizedUserName).split(",").map($tw.utils.trim),
|
||||||
writers: (this.get("writers") || authorizedUserName).split(",").map($tw.utils.trim)
|
writers: (this.get("writers") || authorizedUserName).split(",").map($tw.utils.trim)
|
||||||
}
|
};
|
||||||
if(this.get("admin") || authorizedUserName !== "(anon)") {
|
if(this.get("admin") || authorizedUserName !== "(anon)") {
|
||||||
this.authorizationPrincipals["admin"] = (this.get("admin") || authorizedUserName).split(',').map($tw.utils.trim)
|
this.authorizationPrincipals["admin"] = (this.get("admin") || authorizedUserName).split(",").map($tw.utils.trim);
|
||||||
}
|
}
|
||||||
// Load and initialise authenticators
|
// Load and initialise authenticators
|
||||||
$tw.modules.forEachModuleOfType("authenticator", function(title,authenticatorDefinition) {
|
$tw.modules.forEachModuleOfType("authenticator", function(title,authenticatorDefinition) {
|
||||||
@@ -91,7 +91,7 @@ function Server(options) {
|
|||||||
this.listenOptions = {
|
this.listenOptions = {
|
||||||
key: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsKeyFilepath),"utf8"),
|
key: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsKeyFilepath),"utf8"),
|
||||||
cert: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsCertFilepath),"utf8"),
|
cert: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsCertFilepath),"utf8"),
|
||||||
passphrase: tlsPassphrase || ''
|
passphrase: tlsPassphrase || ""
|
||||||
};
|
};
|
||||||
this.protocol = "https";
|
this.protocol = "https";
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ encoding: the encoding of the data to send (passed to the end method of the resp
|
|||||||
*/
|
*/
|
||||||
function sendResponse(request,response,statusCode,headers,data,encoding) {
|
function sendResponse(request,response,statusCode,headers,data,encoding) {
|
||||||
if(this.enableBrowserCache && (statusCode == 200)) {
|
if(this.enableBrowserCache && (statusCode == 200)) {
|
||||||
var hash = crypto.createHash('md5');
|
var hash = crypto.createHash("md5");
|
||||||
// Put everything into the hash that could change and invalidate the data that
|
// Put everything into the hash that could change and invalidate the data that
|
||||||
// the browser already stored. The headers the data and the encoding.
|
// the browser already stored. The headers the data and the encoding.
|
||||||
hash.update(data);
|
hash.update(data);
|
||||||
@@ -211,7 +211,6 @@ Server.prototype.addAuthenticator = function(AuthenticatorClass) {
|
|||||||
Server.prototype.findMatchingRoute = function(request,state) {
|
Server.prototype.findMatchingRoute = function(request,state) {
|
||||||
for(var t=0; t<this.routes.length; t++) {
|
for(var t=0; t<this.routes.length; t++) {
|
||||||
var potentialRoute = this.routes[t],
|
var potentialRoute = this.routes[t],
|
||||||
pathRegExp = potentialRoute.path,
|
|
||||||
pathname = state.urlInfo.pathname,
|
pathname = state.urlInfo.pathname,
|
||||||
match;
|
match;
|
||||||
if(state.pathPrefix) {
|
if(state.pathPrefix) {
|
||||||
@@ -250,7 +249,7 @@ Check whether a given user is authorized for the specified authorizationType ("r
|
|||||||
Server.prototype.isAuthorized = function(authorizationType,username) {
|
Server.prototype.isAuthorized = function(authorizationType,username) {
|
||||||
var principals = this.authorizationPrincipals[authorizationType] || [];
|
var principals = this.authorizationPrincipals[authorizationType] || [];
|
||||||
return principals.indexOf("(anon)") !== -1 || (username && (principals.indexOf("(authenticated)") !== -1 || principals.indexOf(username) !== -1));
|
return principals.indexOf("(anon)") !== -1 || (username && (principals.indexOf("(authenticated)") !== -1 || principals.indexOf(username) !== -1));
|
||||||
}
|
};
|
||||||
|
|
||||||
Server.prototype.requestHandler = function(request,response,options) {
|
Server.prototype.requestHandler = function(request,response,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@@ -260,8 +259,8 @@ Server.prototype.requestHandler = function(request,response,options) {
|
|||||||
state.wiki = options.wiki || self.wiki;
|
state.wiki = options.wiki || self.wiki;
|
||||||
state.boot = options.boot || self.boot;
|
state.boot = options.boot || self.boot;
|
||||||
state.server = self;
|
state.server = self;
|
||||||
state.urlInfo = url.parse(request.url);
|
state.urlInfo = new URL(request.url, "http://localhost");
|
||||||
state.queryParameters = querystring.parse(state.urlInfo.query);
|
state.queryParameters = Object.fromEntries(state.urlInfo.searchParams);
|
||||||
state.pathPrefix = options.pathPrefix || this.get("path-prefix") || "";
|
state.pathPrefix = options.pathPrefix || this.get("path-prefix") || "";
|
||||||
// Enable CORS
|
// Enable CORS
|
||||||
if(this.corsEnable) {
|
if(this.corsEnable) {
|
||||||
@@ -337,7 +336,7 @@ Server.prototype.requestHandler = function(request,response,options) {
|
|||||||
request.on("end",function() {
|
request.on("end",function() {
|
||||||
state.data = Buffer.concat(data);
|
state.data = Buffer.concat(data);
|
||||||
route.handler(request,response,state);
|
route.handler(request,response,state);
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
response.writeHead(400,"Invalid bodyFormat " + route.bodyFormat + " in route " + route.method + " " + route.path.source);
|
response.writeHead(400,"Invalid bodyFormat " + route.bodyFormat + " in route " + route.method + " " + route.path.source);
|
||||||
response.end();
|
response.end();
|
||||||
@@ -362,8 +361,8 @@ Server.prototype.listen = function(port,host,prefix) {
|
|||||||
}
|
}
|
||||||
// Warn if required plugins are missing
|
// Warn if required plugins are missing
|
||||||
var missing = [];
|
var missing = [];
|
||||||
for (var index=0; index<this.requiredPlugins.length; index++) {
|
for(var index=0; index<this.requiredPlugins.length; index++) {
|
||||||
if (!this.wiki.getTiddler(this.requiredPlugins[index])) {
|
if(!this.wiki.getTiddler(this.requiredPlugins[index])) {
|
||||||
missing.push(this.requiredPlugins[index]);
|
missing.push(this.requiredPlugins[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,22 +9,22 @@ Base64 UTF-8 utlity functions.
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const{ TextEncoder, TextDecoder } = require("node:util");
|
const { TextEncoder, TextDecoder } = require("node:util");
|
||||||
|
|
||||||
exports.btoa = binstr => Buffer.from(binstr, "binary").toString("base64");
|
exports.btoa = (binstr) => Buffer.from(binstr, "binary").toString("base64");
|
||||||
|
|
||||||
exports.atob = b64 => Buffer.from(b64, "base64").toString("binary");
|
exports.atob = (b64) => Buffer.from(b64, "base64").toString("binary");
|
||||||
|
|
||||||
function base64ToBytes(base64) {
|
function base64ToBytes(base64) {
|
||||||
const binString = exports.atob(base64);
|
const binString = exports.atob(base64);
|
||||||
return Uint8Array.from(binString, m => m.codePointAt(0));
|
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
||||||
};
|
};
|
||||||
|
|
||||||
function bytesToBase64(bytes) {
|
function bytesToBase64(bytes) {
|
||||||
const binString = Array.from(bytes, byte => String.fromCodePoint(byte)).join("");
|
const binString = Array.from(bytes, (byte) => String.fromCodePoint(byte)).join("");
|
||||||
return exports.btoa(binString);
|
return exports.btoa(binString);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.base64EncodeUtf8 = str => bytesToBase64(new TextEncoder().encode(str));
|
exports.base64EncodeUtf8 = (str) => bytesToBase64(new TextEncoder().encode(str));
|
||||||
|
|
||||||
exports.base64DecodeUtf8 = str => new TextDecoder().decode(base64ToBytes(str));
|
exports.base64DecodeUtf8 = (str) => new TextDecoder().decode(base64ToBytes(str));
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ ignoreEnvironmentVariables: defaults to false
|
|||||||
*/
|
*/
|
||||||
exports.getAllPlugins = function(options) {
|
exports.getAllPlugins = function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var fs = require("fs"),
|
var path = require("path"),
|
||||||
path = require("path"),
|
|
||||||
tiddlers = {};
|
tiddlers = {};
|
||||||
// Collect up the library plugins
|
// Collect up the library plugins
|
||||||
var collectPlugins = function(folder) {
|
var collectPlugins = function(folder) {
|
||||||
|
|||||||
@@ -58,10 +58,14 @@ LayoutSwitcher/Caption: Layout
|
|||||||
LoadedModules/Caption: Loaded Modules
|
LoadedModules/Caption: Loaded Modules
|
||||||
LoadedModules/Hint: These are the currently loaded tiddler modules linked to their source tiddlers. Any italicised modules lack a source tiddler, typically because they were setup during the boot process.
|
LoadedModules/Hint: These are the currently loaded tiddler modules linked to their source tiddlers. Any italicised modules lack a source tiddler, typically because they were setup during the boot process.
|
||||||
Palette/Caption: Palette
|
Palette/Caption: Palette
|
||||||
|
Palette/Customisations/Prompt: Customisations for the current palette: <<palette-link>>
|
||||||
|
Palette/Customisations/Reset/Caption: reset customisations
|
||||||
|
Palette/Editor/Customised/Prompt: This palette has customisations that override the entries marked below
|
||||||
|
Palette/Editor/Customised/Entry: overridden by a customisation
|
||||||
Palette/Editor/Clone/Caption: clone
|
Palette/Editor/Clone/Caption: clone
|
||||||
Palette/Editor/Clone/Prompt: It is recommended that you clone this shadow palette before editing it
|
Palette/Editor/Clone/Prompt: It is recommended that you clone this shadow palette before editing it
|
||||||
Palette/Editor/Delete/Hint: delete this entry from the current palette
|
Palette/Editor/Delete/Hint: delete this entry from the current palette
|
||||||
Palette/Editor/Names/External/Show: Show color names that are not part of the current palette
|
Palette/Editor/Names/External/Show: Show inherited palette entries
|
||||||
Palette/Editor/Prompt/Modified: This shadow palette has been modified
|
Palette/Editor/Prompt/Modified: This shadow palette has been modified
|
||||||
Palette/Editor/Prompt: Editing
|
Palette/Editor/Prompt: Editing
|
||||||
Palette/Editor/Reset/Caption: reset
|
Palette/Editor/Reset/Caption: reset
|
||||||
@@ -255,4 +259,5 @@ ViewTemplateTags/Caption: View Template Tags
|
|||||||
ViewTemplateTags/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the tags area of a tiddler.
|
ViewTemplateTags/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the tags area of a tiddler.
|
||||||
WikiInformation/Caption: Wiki Information
|
WikiInformation/Caption: Wiki Information
|
||||||
WikiInformation/Hint: This page summarises high level information about the configuration of this ~TiddlyWiki. It is designed to enable users to quickly share relevant aspects of the configuration of their ~TiddlyWiki with others, for example when seeking help in one of the forums. No private or personal information is included, and nothing is shared without being explicitly copied and pasted elsewhere
|
WikiInformation/Hint: This page summarises high level information about the configuration of this ~TiddlyWiki. It is designed to enable users to quickly share relevant aspects of the configuration of their ~TiddlyWiki with others, for example when seeking help in one of the forums. No private or personal information is included, and nothing is shared without being explicitly copied and pasted elsewhere
|
||||||
WikiInformation/Drag/Caption: Drag this link to copy this tool to another wiki
|
WikiInformation/Drag/Caption: Drag this link to copy this tool to another wiki
|
||||||
|
WikiInformation/Generate/Caption: Click to generate wiki information report
|
||||||
@@ -15,6 +15,8 @@ Listing/Preview/TextRaw: Text (Raw)
|
|||||||
Listing/Preview/Fields: Fields
|
Listing/Preview/Fields: Fields
|
||||||
Listing/Preview/Diff: Diff
|
Listing/Preview/Diff: Diff
|
||||||
Listing/Preview/DiffFields: Diff (Fields)
|
Listing/Preview/DiffFields: Diff (Fields)
|
||||||
|
Listing/ImportOptions/Caption: Import options
|
||||||
|
Listing/ImportOptions/NoMatch: No import options apply to these files.
|
||||||
Listing/Rename/Tooltip: Rename tiddler before importing
|
Listing/Rename/Tooltip: Rename tiddler before importing
|
||||||
Listing/Rename/Prompt: Rename to:
|
Listing/Rename/Prompt: Rename to:
|
||||||
Listing/Rename/ConfirmRename: Rename tiddler
|
Listing/Rename/ConfirmRename: Rename tiddler
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ Error/DeserializeOperator/MissingOperand: Filter Error: Missing operand for 'des
|
|||||||
Error/DeserializeOperator/UnknownDeserializer: Filter Error: Unknown deserializer provided as operand for the 'deserialize' operator
|
Error/DeserializeOperator/UnknownDeserializer: Filter Error: Unknown deserializer provided as operand for the 'deserialize' operator
|
||||||
Error/Filter: Filter error
|
Error/Filter: Filter error
|
||||||
Error/FilterSyntax: Syntax error in filter expression
|
Error/FilterSyntax: Syntax error in filter expression
|
||||||
|
Error/FilterPragma: Filter Error: Unknown filter pragma
|
||||||
|
Error/FilterPragmaPosition: Filter Error: Filter pragmas are only allowed at the start of a filter
|
||||||
Error/FilterRunPrefix: Filter Error: Unknown prefix for filter run
|
Error/FilterRunPrefix: Filter Error: Unknown prefix for filter run
|
||||||
Error/IsFilterOperator: Filter Error: Unknown parameter for the 'is' filter operator
|
Error/IsFilterOperator: Filter Error: Unknown parameter for the 'is' filter operator
|
||||||
Error/FormatFilterOperator: Filter Error: Unknown suffix for the 'format' filter operator
|
Error/FormatFilterOperator: Filter Error: Unknown suffix for the 'format' filter operator
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Advanced/ShadowInfo/Shadow/Hint: The tiddler <$link to=<<infoTiddler>>><$text te
|
|||||||
Advanced/ShadowInfo/Shadow/Source: It is defined in the plugin <$link to=<<pluginTiddler>>><$text text=<<pluginTiddler>>/></$link>
|
Advanced/ShadowInfo/Shadow/Source: It is defined in the plugin <$link to=<<pluginTiddler>>><$text text=<<pluginTiddler>>/></$link>
|
||||||
Advanced/ShadowInfo/OverriddenShadow/Hint: It is overridden by an ordinary tiddler
|
Advanced/ShadowInfo/OverriddenShadow/Hint: It is overridden by an ordinary tiddler
|
||||||
Advanced/CascadeInfo/Heading: Cascade Details
|
Advanced/CascadeInfo/Heading: Cascade Details
|
||||||
Advanced/CascadeInfo/Hint: These are the view template segments (tagged <<tag "$:/tags/ViewTemplate">>) using a cascade filter and their resulting template for the current tiddler.
|
Advanced/CascadeInfo/Hint: These are the view template segments that are resolved for each of the system view template cascades
|
||||||
Advanced/CascadeInfo/Detail/View: View
|
Advanced/CascadeInfo/Detail/View: View
|
||||||
Advanced/CascadeInfo/Detail/ActiveCascadeFilter: Active cascade filter
|
Advanced/CascadeInfo/Detail/ActiveCascadeFilter: Active cascade filter
|
||||||
Advanced/CascadeInfo/Detail/Template: Template
|
Advanced/CascadeInfo/Detail/Template: Template
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ class BackgroundActionDispatcher {
|
|||||||
// Track the filter for the background actions
|
// Track the filter for the background actions
|
||||||
this.filterTracker.track({
|
this.filterTracker.track({
|
||||||
filterString: "[all[tiddlers+shadows]tag[$:/tags/BackgroundAction]!is[draft]]",
|
filterString: "[all[tiddlers+shadows]tag[$:/tags/BackgroundAction]!is[draft]]",
|
||||||
fnEnter: title => this.trackFilter(title),
|
fnEnter: (title) => this.trackFilter(title),
|
||||||
fnLeave: (title, enterValue) => this.untrackFilter(enterValue),
|
fnLeave: (title, enterValue) => this.untrackFilter(enterValue),
|
||||||
fnChange: (title, enterValue) => {
|
fnChange: (title, enterValue) => {
|
||||||
this.untrackFilter(enterValue);
|
this.untrackFilter(enterValue);
|
||||||
return this.trackFilter(title);
|
return this.trackFilter(title);
|
||||||
},
|
},
|
||||||
fnProcess: changes => this.process(changes)
|
fnProcess: (changes) => this.process(changes)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +75,9 @@ class BackgroundActionTracker {
|
|||||||
filterString: this.trackFilter,
|
filterString: this.trackFilter,
|
||||||
fnEnter: () => { this.hasChanged = true; },
|
fnEnter: () => { this.hasChanged = true; },
|
||||||
fnLeave: () => { this.hasChanged = true; },
|
fnLeave: () => { this.hasChanged = true; },
|
||||||
fnProcess: changes => {
|
fnProcess: (changes) => {
|
||||||
if(this.hasChanged) {
|
if(this.hasChanged) {
|
||||||
this.hasChanged = false;
|
this.hasChanged = false;
|
||||||
console.log("Processing background action", this.title);
|
|
||||||
const tiddler = this.wiki.getTiddler(this.title);
|
const tiddler = this.wiki.getTiddler(this.title);
|
||||||
let doActions = true;
|
let doActions = true;
|
||||||
if(tiddler && tiddler.fields.platforms) {
|
if(tiddler && tiddler.fields.platforms) {
|
||||||
@@ -89,6 +88,7 @@ class BackgroundActionTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(doActions) {
|
if(doActions) {
|
||||||
|
console.log("Processing background action", this.title);
|
||||||
this.wiki.invokeActionString(
|
this.wiki.invokeActionString(
|
||||||
this.actions,
|
this.actions,
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ function FramedEngine(options) {
|
|||||||
this.parentNode.insertBefore(this.iframeNode,this.nextSibling);
|
this.parentNode.insertBefore(this.iframeNode,this.nextSibling);
|
||||||
this.iframeDoc = this.iframeNode.contentWindow.document;
|
this.iframeDoc = this.iframeNode.contentWindow.document;
|
||||||
// (Firefox requires us to put some empty content in the iframe)
|
// (Firefox requires us to put some empty content in the iframe)
|
||||||
var paletteTitle = this.widget.wiki.getTiddlerText("$:/palette");
|
var colorScheme = (this.widget.wiki.getTiddler("$:/temp/palette-colours") || {fields: {}}).fields["color-scheme"] || "light";
|
||||||
var colorScheme = (this.widget.wiki.getTiddler(paletteTitle) || {fields: {}}).fields["color-scheme"] || "light";
|
|
||||||
this.iframeDoc.open();
|
this.iframeDoc.open();
|
||||||
this.iframeDoc.write("<!DOCTYPE html><html><head><meta name='color-scheme' content='" + colorScheme + "'></head><body></body></html>");
|
this.iframeDoc.write("<!DOCTYPE html><html><head><meta name='color-scheme' content='" + colorScheme + "'></head><body></body></html>");
|
||||||
this.iframeDoc.close();
|
this.iframeDoc.close();
|
||||||
@@ -156,14 +155,13 @@ Fix the height of textarea to fit content
|
|||||||
FramedEngine.prototype.fixHeight = function() {
|
FramedEngine.prototype.fixHeight = function() {
|
||||||
// Make sure styles are updated
|
// Make sure styles are updated
|
||||||
this.copyStyles();
|
this.copyStyles();
|
||||||
// If .editRows is initialised, it takes precedence
|
if(this.widget.editTag === "textarea") {
|
||||||
if(this.widget.editTag === "textarea" && !this.widget.editRows) {
|
|
||||||
if(this.widget.editAutoHeight) {
|
if(this.widget.editAutoHeight) {
|
||||||
if(this.domNode && !this.domNode.isTiddlyWikiFakeDom) {
|
if(this.domNode && !this.domNode.isTiddlyWikiFakeDom) {
|
||||||
var newHeight = $tw.utils.resizeTextAreaToFit(this.domNode,this.widget.editMinHeight);
|
var newHeight = $tw.utils.resizeTextAreaToFit(this.domNode,this.widget.editMinHeight);
|
||||||
this.iframeNode.style.height = newHeight + "px";
|
this.iframeNode.style.height = newHeight + "px";
|
||||||
}
|
}
|
||||||
} else {
|
} else if(!this.widget.editRows) {
|
||||||
var fixedHeight = parseInt(this.widget.wiki.getTiddlerText(HEIGHT_VALUE_TITLE,"400px"),10);
|
var fixedHeight = parseInt(this.widget.wiki.getTiddlerText(HEIGHT_VALUE_TITLE,"400px"),10);
|
||||||
fixedHeight = Math.max(fixedHeight,20);
|
fixedHeight = Math.max(fixedHeight,20);
|
||||||
this.domNode.style.height = fixedHeight + "px";
|
this.domNode.style.height = fixedHeight + "px";
|
||||||
@@ -197,7 +195,7 @@ FramedEngine.prototype.handleFocusEvent = function(event) {
|
|||||||
Handle a keydown event
|
Handle a keydown event
|
||||||
*/
|
*/
|
||||||
FramedEngine.prototype.handleKeydownEvent = function(event) {
|
FramedEngine.prototype.handleKeydownEvent = function(event) {
|
||||||
if ($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) {
|
if($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ function SimpleEngine(options) {
|
|||||||
if(this.widget.editTag === "textarea") {
|
if(this.widget.editTag === "textarea") {
|
||||||
this.domNode.appendChild(this.widget.document.createTextNode(this.value));
|
this.domNode.appendChild(this.widget.document.createTextNode(this.value));
|
||||||
} else {
|
} else {
|
||||||
this.domNode.value = this.value;
|
if(this.widget.editType === "color") {
|
||||||
|
// The <input type="color"> element requires a six digit hex value
|
||||||
|
this.domNode.value = $tw.utils.convertCSSColorToRGBString(this.value);
|
||||||
|
} else {
|
||||||
|
this.domNode.value = this.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Set the attributes
|
// Set the attributes
|
||||||
if(this.widget.editType && this.widget.editTag !== "textarea") {
|
if(this.widget.editType && this.widget.editTag !== "textarea") {
|
||||||
@@ -83,6 +88,9 @@ Update the DomNode with the new text
|
|||||||
*/
|
*/
|
||||||
SimpleEngine.prototype.updateDomNodeText = function(text) {
|
SimpleEngine.prototype.updateDomNodeText = function(text) {
|
||||||
try {
|
try {
|
||||||
|
if(this.widget.editType === "color") {
|
||||||
|
text = $tw.utils.convertCSSColorToRGBString(text);
|
||||||
|
}
|
||||||
this.domNode.value = text;
|
this.domNode.value = text;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
@@ -100,13 +108,12 @@ SimpleEngine.prototype.getText = function() {
|
|||||||
Fix the height of textarea to fit content
|
Fix the height of textarea to fit content
|
||||||
*/
|
*/
|
||||||
SimpleEngine.prototype.fixHeight = function() {
|
SimpleEngine.prototype.fixHeight = function() {
|
||||||
// If .editRows is initialised, it takes precedence
|
if(this.widget.editTag === "textarea") {
|
||||||
if((this.widget.editTag === "textarea") && !this.widget.editRows) {
|
|
||||||
if(this.widget.editAutoHeight) {
|
if(this.widget.editAutoHeight) {
|
||||||
if(this.domNode && !this.domNode.isTiddlyWikiFakeDom) {
|
if(this.domNode && !this.domNode.isTiddlyWikiFakeDom) {
|
||||||
$tw.utils.resizeTextAreaToFit(this.domNode,this.widget.editMinHeight);
|
$tw.utils.resizeTextAreaToFit(this.domNode,this.widget.editMinHeight);
|
||||||
}
|
}
|
||||||
} else {
|
} else if(!this.widget.editRows) {
|
||||||
var fixedHeight = parseInt(this.widget.wiki.getTiddlerText(HEIGHT_VALUE_TITLE,"400px"),10);
|
var fixedHeight = parseInt(this.widget.wiki.getTiddlerText(HEIGHT_VALUE_TITLE,"400px"),10);
|
||||||
fixedHeight = Math.max(fixedHeight,20);
|
fixedHeight = Math.max(fixedHeight,20);
|
||||||
this.domNode.style.height = fixedHeight + "px";
|
this.domNode.style.height = fixedHeight + "px";
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
var editInfo = this.getEditInfo(),
|
var editInfo = this.getEditInfo(),
|
||||||
Engine = this.editShowToolbar ? toolbarEngine : nonToolbarEngine;
|
Engine = this.editShowToolbar ? toolbarEngine : nonToolbarEngine;
|
||||||
this.engine = new Engine({
|
this.engine = new Engine({
|
||||||
widget: this,
|
widget: this,
|
||||||
value: editInfo.value,
|
value: editInfo.value,
|
||||||
type: editInfo.type,
|
type: editInfo.type,
|
||||||
parentNode: parent,
|
parentNode: parent,
|
||||||
nextSibling: nextSibling
|
nextSibling: nextSibling
|
||||||
});
|
});
|
||||||
// Call the postRender hook
|
// Call the postRender hook
|
||||||
if(this.postRender) {
|
if(this.postRender) {
|
||||||
this.postRender();
|
this.postRender();
|
||||||
@@ -217,10 +217,11 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
EditTextWidget.prototype.refresh = function(changedTiddlers) {
|
EditTextWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
var changedAttributes = this.computeAttributes();
|
var changedAttributes = this.computeAttributes();
|
||||||
// Completely rerender if any of our attributes have changed
|
// Completely rerender if any of our attributes have changed
|
||||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) {
|
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else if (changedTiddlers[this.editRefreshTitle]) {
|
} else if(changedAttributes["default"] || changedTiddlers[this.editRefreshTitle]) {
|
||||||
|
this.editDefault = this.getAttribute("default");
|
||||||
this.engine.updateDomNodeText(this.getEditInfo().value);
|
this.engine.updateDomNodeText(this.getEditInfo().value);
|
||||||
} else if(changedTiddlers[this.editTitle]) {
|
} else if(changedTiddlers[this.editTitle]) {
|
||||||
var editInfo = this.getEditInfo();
|
var editInfo = this.getEditInfo();
|
||||||
@@ -274,8 +275,8 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
});
|
});
|
||||||
if($tw.keyboardManager.checkKeyDescriptors(event,keyInfoArray)) {
|
if($tw.keyboardManager.checkKeyDescriptors(event,keyInfoArray)) {
|
||||||
var clickEvent = this.document.createEvent("Events");
|
var clickEvent = this.document.createEvent("Events");
|
||||||
clickEvent.initEvent("click",true,false);
|
clickEvent.initEvent("click",true,false);
|
||||||
el.dispatchEvent(clickEvent);
|
el.dispatchEvent(clickEvent);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Text editor operation to excise the selection to a new tiddler
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function isMarkdown(mediaType) {
|
function isMarkdown(mediaType) {
|
||||||
return mediaType === 'text/markdown' || mediaType === 'text/x-markdown';
|
return mediaType === "text/markdown" || mediaType === "text/x-markdown";
|
||||||
}
|
}
|
||||||
|
|
||||||
exports["excise"] = function(event,operation) {
|
exports["excise"] = function(event,operation) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ exports["wrap-lines"] = function(event,operation) {
|
|||||||
operation.cutStart = operation.selStart - (prefix.length + 1);
|
operation.cutStart = operation.selStart - (prefix.length + 1);
|
||||||
operation.cutEnd = operation.selEnd + suffix.length + 1;
|
operation.cutEnd = operation.selEnd + suffix.length + 1;
|
||||||
// Also cut the following newline (if there is any)
|
// Also cut the following newline (if there is any)
|
||||||
if (operation.text[operation.cutEnd] === "\n") {
|
if(operation.text[operation.cutEnd] === "\n") {
|
||||||
operation.cutEnd++;
|
operation.cutEnd++;
|
||||||
}
|
}
|
||||||
// Replace with selection
|
// Replace with selection
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ exports["wrap-selection"] = function(event,operation) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
|
|
||||||
function togglePrefixSuffix() {
|
function togglePrefixSuffix() {
|
||||||
if(o.text.substring(o.selStart - prefix.length, o.selStart + suffix.length) === prefix + suffix) {
|
if(o.text.substring(o.selStart - prefix.length, o.selStart + suffix.length) === prefix + suffix) {
|
||||||
|
|||||||
@@ -69,17 +69,17 @@ class FilterTracker {
|
|||||||
if(!tracker) return;
|
if(!tracker) return;
|
||||||
const results = [];
|
const results = [];
|
||||||
// Evaluate the filter and remove duplicate results
|
// Evaluate the filter and remove duplicate results
|
||||||
$tw.utils.each(this.wiki.filterTiddlers(tracker.filterString), title => {
|
$tw.utils.each(this.wiki.filterTiddlers(tracker.filterString), (title) => {
|
||||||
$tw.utils.pushTop(results, title);
|
$tw.utils.pushTop(results, title);
|
||||||
});
|
});
|
||||||
// Process the newly entered results
|
// Process the newly entered results
|
||||||
results.forEach(title => {
|
results.forEach((title) => {
|
||||||
if(!tracker.previousResults.includes(title) && !tracker.resultValues[title] && tracker.fnEnter) {
|
if(!tracker.previousResults.includes(title) && !tracker.resultValues[title] && tracker.fnEnter) {
|
||||||
tracker.resultValues[title] = tracker.fnEnter(title) || true;
|
tracker.resultValues[title] = tracker.fnEnter(title) || true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Process the results that have just left
|
// Process the results that have just left
|
||||||
tracker.previousResults.forEach(title => {
|
tracker.previousResults.forEach((title) => {
|
||||||
if(!results.includes(title) && tracker.resultValues[title] && tracker.fnLeave) {
|
if(!results.includes(title) && tracker.resultValues[title] && tracker.fnLeave) {
|
||||||
tracker.fnLeave(title, tracker.resultValues[title]);
|
tracker.fnLeave(title, tracker.resultValues[title]);
|
||||||
delete tracker.resultValues[title];
|
delete tracker.resultValues[title];
|
||||||
@@ -91,7 +91,7 @@ class FilterTracker {
|
|||||||
|
|
||||||
processChanges(changes) {
|
processChanges(changes) {
|
||||||
for(const tracker of this.trackers.values()) {
|
for(const tracker of this.trackers.values()) {
|
||||||
Object.keys(changes).forEach(title => {
|
Object.keys(changes).forEach((title) => {
|
||||||
if(title && tracker.previousResults.includes(title) && tracker.fnChange) {
|
if(title && tracker.previousResults.includes(title) && tracker.fnChange) {
|
||||||
tracker.resultValues[title] = tracker.fnChange(title, tracker.resultValues[title]) || tracker.resultValues[title];
|
tracker.resultValues[title] = tracker.fnChange(title, tracker.resultValues[title]) || tracker.resultValues[title];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ exports.cascade = function(operationSubFunction,options) {
|
|||||||
}
|
}
|
||||||
var output = filterFnList[index](options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
var output = filterFnList[index](options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
||||||
"currentTiddler": "" + title,
|
"currentTiddler": "" + title,
|
||||||
"..currentTiddler": widget.getVariable("currentTiddler","")
|
"..currentTiddler": widget.getVariable("currentTiddler",{defaultValue:""})
|
||||||
}));
|
}));
|
||||||
if(output.length !== 0) {
|
if(output.length !== 0) {
|
||||||
result = output[0];
|
result = output[0];
|
||||||
@@ -34,5 +34,5 @@ exports.cascade = function(operationSubFunction,options) {
|
|||||||
results.push(result);
|
results.push(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ exports.filter = function(operationSubFunction,options) {
|
|||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
||||||
"currentTiddler": "" + title,
|
"currentTiddler": "" + title,
|
||||||
"..currentTiddler": widget.getVariable("currentTiddler",""),
|
"..currentTiddler": widget.getVariable("currentTiddler",{defaultValue:""}),
|
||||||
"index": "" + index,
|
"index": "" + index,
|
||||||
"revIndex": "" + (results.length - 1 - index),
|
"revIndex": "" + (results.length - 1 - index),
|
||||||
"length": "" + results.length
|
"length": "" + results.length
|
||||||
@@ -30,5 +30,5 @@ exports.filter = function(operationSubFunction,options) {
|
|||||||
});
|
});
|
||||||
results.remove(resultsToRemove);
|
results.remove(resultsToRemove);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,14 +13,15 @@ Export our filter prefix function
|
|||||||
exports.intersection = function(operationSubFunction) {
|
exports.intersection = function(operationSubFunction) {
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
if(results.length !== 0) {
|
if(results.length !== 0) {
|
||||||
var secondRunResults = operationSubFunction(source,widget);
|
const secondRunResults = operationSubFunction(source,widget),
|
||||||
var firstRunResults = results.toArray();
|
secondRunSet = new Set(secondRunResults),
|
||||||
|
firstRunResults = results.toArray();
|
||||||
results.clear();
|
results.clear();
|
||||||
$tw.utils.each(firstRunResults,function(title) {
|
firstRunResults.forEach((title) => {
|
||||||
if(secondRunResults.indexOf(title) !== -1) {
|
if(secondRunSet.has(title)) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -7,8 +7,6 @@ Assign a value to a variable
|
|||||||
|
|
||||||
\*/
|
\*/
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ exports.map = function(operationSubFunction,options) {
|
|||||||
$tw.utils.each(inputTitles,function(title) {
|
$tw.utils.each(inputTitles,function(title) {
|
||||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
||||||
"currentTiddler": "" + title,
|
"currentTiddler": "" + title,
|
||||||
"..currentTiddler": widget.getVariable("currentTiddler",""),
|
"..currentTiddler": widget.getVariable("currentTiddler",{defaultValue:""}),
|
||||||
"index": "" + index,
|
"index": "" + index,
|
||||||
"revIndex": "" + (inputTitles.length - 1 - index),
|
"revIndex": "" + (inputTitles.length - 1 - index),
|
||||||
"length": "" + inputTitles.length
|
"length": "" + inputTitles.length
|
||||||
@@ -28,12 +28,12 @@ exports.map = function(operationSubFunction,options) {
|
|||||||
if(filtered.length && flatten) {
|
if(filtered.length && flatten) {
|
||||||
$tw.utils.each(filtered,function(value) {
|
$tw.utils.each(filtered,function(value) {
|
||||||
results.push(value);
|
results.push(value);
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
results.push(filtered[0]||"");
|
results.push(filtered[0]||"");
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ exports.reduce = function(operationSubFunction,options) {
|
|||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
||||||
"currentTiddler": "" + title,
|
"currentTiddler": "" + title,
|
||||||
"..currentTiddler": widget.getVariable("currentTiddler"),
|
"..currentTiddler": widget.getVariable("currentTiddler",{defaultValue:""}),
|
||||||
"index": "" + index,
|
"index": "" + index,
|
||||||
"revIndex": "" + (results.length - 1 - index),
|
"revIndex": "" + (results.length - 1 - index),
|
||||||
"length": "" + results.length,
|
"length": "" + results.length,
|
||||||
@@ -31,5 +31,5 @@ exports.reduce = function(operationSubFunction,options) {
|
|||||||
results.clear();
|
results.clear();
|
||||||
results.push(accumulator);
|
results.push(accumulator);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,35 +13,30 @@ Export our filter prefix function
|
|||||||
exports.sort = function(operationSubFunction,options) {
|
exports.sort = function(operationSubFunction,options) {
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
if(results.length > 0) {
|
if(results.length > 0) {
|
||||||
var suffixes = options.suffixes,
|
const suffixes = options.suffixes,
|
||||||
sortType = (suffixes[0] && suffixes[0][0]) ? suffixes[0][0] : "string",
|
sortType = (suffixes[0] && suffixes[0][0]) ? suffixes[0][0] : "string",
|
||||||
invert = suffixes[1] ? (suffixes[1].indexOf("reverse") !== -1) : false,
|
invert = suffixes[1] ? suffixes[1].includes("reverse") : false,
|
||||||
isCaseSensitive = suffixes[1] ? (suffixes[1].indexOf("casesensitive") !== -1) : false,
|
isCaseSensitive = suffixes[1] ? suffixes[1].includes("casesensitive") : false,
|
||||||
inputTitles = results.toArray(),
|
inputTitles = results.toArray(),
|
||||||
sortKeys = [],
|
sortKeys = [],
|
||||||
indexes = new Array(inputTitles.length),
|
compareFn = $tw.utils.makeCompareFunction(sortType,{defaultType: "string", invert:invert, isCaseSensitive:isCaseSensitive});
|
||||||
compareFn;
|
results.each((title) => {
|
||||||
results.each(function(title) {
|
const key = operationSubFunction(
|
||||||
var key = operationSubFunction(options.wiki.makeTiddlerIterator([title]),widget.makeFakeWidgetWithVariables({
|
options.wiki.makeTiddlerIterator([title]),
|
||||||
"currentTiddler": "" + title,
|
widget.makeFakeWidgetWithVariables({
|
||||||
"..currentTiddler": widget.getVariable("currentTiddler")
|
"currentTiddler": "" + title,
|
||||||
}));
|
"..currentTiddler": widget.getVariable("currentTiddler",{defaultValue:""})
|
||||||
|
})
|
||||||
|
);
|
||||||
sortKeys.push(key[0] || "");
|
sortKeys.push(key[0] || "");
|
||||||
});
|
});
|
||||||
results.clear();
|
results.clear();
|
||||||
// Prepare an array of indexes to sort
|
// Prepare an array of indexes to sort
|
||||||
for(var t=0; t<inputTitles.length; t++) {
|
let indexes = Array.from(inputTitles.keys());
|
||||||
indexes[t] = t;
|
indexes.sort((a,b) => compareFn(sortKeys[a],sortKeys[b]));
|
||||||
}
|
indexes.forEach((index) => {
|
||||||
// Sort the indexes
|
|
||||||
compareFn = $tw.utils.makeCompareFunction(sortType,{defaultType: "string", invert:invert, isCaseSensitive:isCaseSensitive});
|
|
||||||
indexes = indexes.sort(function(a,b) {
|
|
||||||
return compareFn(sortKeys[a],sortKeys[b]);
|
|
||||||
});
|
|
||||||
// Add to results in correct order
|
|
||||||
$tw.utils.each(indexes,function(index) {
|
|
||||||
results.push(inputTitles[index]);
|
results.push(inputTitles[index]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+106
-64
@@ -43,7 +43,7 @@ function parseFilterOperation(operators,filterString,p) {
|
|||||||
var bracket = filterString.charAt(nextBracketPos);
|
var bracket = filterString.charAt(nextBracketPos);
|
||||||
operator.operator = filterString.substring(p,nextBracketPos);
|
operator.operator = filterString.substring(p,nextBracketPos);
|
||||||
// Any suffix?
|
// Any suffix?
|
||||||
var colon = operator.operator.indexOf(':');
|
var colon = operator.operator.indexOf(":");
|
||||||
if(colon > -1) {
|
if(colon > -1) {
|
||||||
// The raw suffix for older filters
|
// The raw suffix for older filters
|
||||||
operator.suffix = operator.operator.substring(colon + 1);
|
operator.suffix = operator.operator.substring(colon + 1);
|
||||||
@@ -67,7 +67,7 @@ function parseFilterOperation(operators,filterString,p) {
|
|||||||
operator.operands = [];
|
operator.operands = [];
|
||||||
var parseOperand = function(bracketType) {
|
var parseOperand = function(bracketType) {
|
||||||
var operand = {};
|
var operand = {};
|
||||||
switch (bracketType) {
|
switch(bracketType) {
|
||||||
case "{": // Curly brackets
|
case "{": // Curly brackets
|
||||||
operand.indirect = true;
|
operand.indirect = true;
|
||||||
nextBracketPos = filterString.indexOf("}",p);
|
nextBracketPos = filterString.indexOf("}",p);
|
||||||
@@ -88,8 +88,8 @@ function parseFilterOperation(operators,filterString,p) {
|
|||||||
rexMatch = rex.exec(filterString.substring(p));
|
rexMatch = rex.exec(filterString.substring(p));
|
||||||
if(rexMatch) {
|
if(rexMatch) {
|
||||||
operator.regexp = new RegExp(rexMatch[1], rexMatch[2]);
|
operator.regexp = new RegExp(rexMatch[1], rexMatch[2]);
|
||||||
// DEPRECATION WARNING
|
// DEPRECATION WARNING
|
||||||
console.log("WARNING: Filter",operator.operator,"has a deprecated regexp operand",operator.regexp);
|
console.log("WARNING: Filter",operator.operator,"has a deprecated regexp operand",operator.regexp);
|
||||||
nextBracketPos = p + rex.lastIndex - 1;
|
nextBracketPos = p + rex.lastIndex - 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -108,7 +108,7 @@ function parseFilterOperation(operators,filterString,p) {
|
|||||||
}
|
}
|
||||||
operator.operands.push(operand);
|
operator.operands.push(operand);
|
||||||
p = nextBracketPos + 1;
|
p = nextBracketPos + 1;
|
||||||
}
|
};
|
||||||
|
|
||||||
p = nextBracketPos + 1;
|
p = nextBracketPos + 1;
|
||||||
parseOperand(bracket);
|
parseOperand(bracket);
|
||||||
@@ -146,14 +146,16 @@ exports.parseFilter = function(filterString) {
|
|||||||
match;
|
match;
|
||||||
var whitespaceRegExp = /(\s+)/mg,
|
var whitespaceRegExp = /(\s+)/mg,
|
||||||
// Groups:
|
// Groups:
|
||||||
// 1 - entire filter run prefix
|
// 1 - pragma
|
||||||
// 2 - filter run prefix itself
|
// 2 - pragma suffix
|
||||||
// 3 - filter run prefix suffixes
|
// 3 - entire filter run prefix
|
||||||
// 4 - opening square bracket following filter run prefix
|
// 4 - filter run prefix name
|
||||||
// 5 - double quoted string following filter run prefix
|
// 5 - filter run prefix suffixes
|
||||||
// 6 - single quoted string following filter run prefix
|
// 6 - opening square bracket following filter run prefix
|
||||||
// 7 - anything except for whitespace and square brackets
|
// 7 - double quoted string following filter run prefix
|
||||||
operandRegExp = /((?:\+|\-|~|(?:=>?)|\:(\w+)(?:\:([\w\:, ]*))?)?)(?:(\[)|(?:"([^"]*)")|(?:'([^']*)')|([^\s\[\]]+))/mg;
|
// 8 - single quoted string following filter run prefix
|
||||||
|
// 9 - anything except for whitespace and square brackets
|
||||||
|
operandRegExp = /(?:::(\w+)(?:\:(\w+))?(?=\s|$)|((?:\+|\-|~|(?:=>?)|:(\w+)(?:\:([\w\:, ]*))?)?)(?:(\[)|(?:"([^"]*)")|(?:'([^']*)')|([^\s\[\]]+)))/mg;
|
||||||
while(p < filterString.length) {
|
while(p < filterString.length) {
|
||||||
// Skip any whitespace
|
// Skip any whitespace
|
||||||
whitespaceRegExp.lastIndex = p;
|
whitespaceRegExp.lastIndex = p;
|
||||||
@@ -170,18 +172,23 @@ exports.parseFilter = function(filterString) {
|
|||||||
};
|
};
|
||||||
match = operandRegExp.exec(filterString);
|
match = operandRegExp.exec(filterString);
|
||||||
if(match && match.index === p) {
|
if(match && match.index === p) {
|
||||||
// If there is a filter run prefix
|
|
||||||
if(match[1]) {
|
if(match[1]) {
|
||||||
operation.prefix = match[1];
|
// If there is a filter pragma
|
||||||
|
operation.pragma = match[1];
|
||||||
|
operation.suffix = match[2];
|
||||||
|
p = match.index + match[0].length;
|
||||||
|
} else if(match[3]) {
|
||||||
|
// If there is a filter run prefix
|
||||||
|
operation.prefix = match[3];
|
||||||
p = p + operation.prefix.length;
|
p = p + operation.prefix.length;
|
||||||
// Name for named prefixes
|
// Name for named prefixes
|
||||||
if(match[2]) {
|
if(match[4]) {
|
||||||
operation.namedPrefix = match[2];
|
operation.namedPrefix = match[4];
|
||||||
}
|
}
|
||||||
// Suffixes for filter run prefix
|
// Suffixes for filter run prefix
|
||||||
if(match[3]) {
|
if(match[5]) {
|
||||||
operation.suffixes = [];
|
operation.suffixes = [];
|
||||||
$tw.utils.each(match[3].split(":"),function(subsuffix) {
|
$tw.utils.each(match[5].split(":"),function(subsuffix) {
|
||||||
operation.suffixes.push([]);
|
operation.suffixes.push([]);
|
||||||
$tw.utils.each(subsuffix.split(","),function(entry) {
|
$tw.utils.each(subsuffix.split(","),function(entry) {
|
||||||
entry = $tw.utils.trim(entry);
|
entry = $tw.utils.trim(entry);
|
||||||
@@ -193,7 +200,7 @@ exports.parseFilter = function(filterString) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Opening square bracket
|
// Opening square bracket
|
||||||
if(match[4]) {
|
if(match[6]) {
|
||||||
p = parseFilterOperation(operation.operators,filterString,p);
|
p = parseFilterOperation(operation.operators,filterString,p);
|
||||||
} else {
|
} else {
|
||||||
p = match.index + match[0].length;
|
p = match.index + match[0].length;
|
||||||
@@ -203,9 +210,9 @@ exports.parseFilter = function(filterString) {
|
|||||||
p = parseFilterOperation(operation.operators,filterString,p);
|
p = parseFilterOperation(operation.operators,filterString,p);
|
||||||
}
|
}
|
||||||
// Quoted strings and unquoted title
|
// Quoted strings and unquoted title
|
||||||
if(match[5] || match[6] || match[7]) { // Double quoted string, single quoted string or unquoted title
|
if(match[7] || match[8] || match[9]) { // Double quoted string, single quoted string or unquoted title
|
||||||
operation.operators.push(
|
operation.operators.push(
|
||||||
{operator: "title", operands: [{text: match[5] || match[6] || match[7]}]}
|
{operator: "title", operands: [{text: match[7] || match[8] || match[9]}]}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
results.push(operation);
|
results.push(operation);
|
||||||
@@ -228,25 +235,28 @@ exports.getFilterRunPrefixes = function() {
|
|||||||
$tw.modules.applyMethods("filterrunprefix",this.filterRunPrefixes);
|
$tw.modules.applyMethods("filterrunprefix",this.filterRunPrefixes);
|
||||||
}
|
}
|
||||||
return this.filterRunPrefixes;
|
return this.filterRunPrefixes;
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.filterTiddlers = function(filterString,widget,source) {
|
exports.filterTiddlers = function(filterString,widget,source,options) {
|
||||||
var fn = this.compileFilter(filterString);
|
var fn = this.compileFilter(filterString,options);
|
||||||
return fn.call(this,source,widget);
|
return fn.call(this,source,widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compile a filter into a function with the signature fn(source,widget) where:
|
Compile a filter into a function with the signature fn(source,widget,options) where:
|
||||||
source: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)
|
source: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)
|
||||||
widget: an optional widget node for retrieving the current tiddler etc.
|
widget: an optional widget node for retrieving the current tiddler etc.
|
||||||
*/
|
*/
|
||||||
exports.compileFilter = function(filterString) {
|
exports.compileFilter = function(filterString,options) {
|
||||||
|
var defaultFilterRunPrefix = (options || {}).defaultFilterRunPrefix || "or",
|
||||||
|
seenNonPragmaOperation = false;
|
||||||
|
var cacheKey = filterString + "|" + defaultFilterRunPrefix;
|
||||||
if(!this.filterCache) {
|
if(!this.filterCache) {
|
||||||
this.filterCache = Object.create(null);
|
this.filterCache = Object.create(null);
|
||||||
this.filterCacheCount = 0;
|
this.filterCacheCount = 0;
|
||||||
}
|
}
|
||||||
if(this.filterCache[filterString] !== undefined) {
|
if(this.filterCache[cacheKey] !== undefined) {
|
||||||
return this.filterCache[filterString];
|
return this.filterCache[cacheKey];
|
||||||
}
|
}
|
||||||
var filterParseTree;
|
var filterParseTree;
|
||||||
try {
|
try {
|
||||||
@@ -296,7 +306,7 @@ exports.compileFilter = function(filterString) {
|
|||||||
var varTree = $tw.utils.parseFilterVariable(operand.text);
|
var varTree = $tw.utils.parseFilterVariable(operand.text);
|
||||||
var resultList = widgetClass.evaluateVariable(widget,varTree.name,{params: varTree.params, source: source});
|
var resultList = widgetClass.evaluateVariable(widget,varTree.name,{params: varTree.params, source: source});
|
||||||
if((resultList.length > 0 && resultList[0] !== undefined) || resultList.length === 0) {
|
if((resultList.length > 0 && resultList[0] !== undefined) || resultList.length === 0) {
|
||||||
operand.multiValue = widgetClass.evaluateVariable(widget,varTree.name,{params: varTree.params, source: source}) || [];
|
operand.multiValue = resultList || [];
|
||||||
operand.value = operand.multiValue[0] || "";
|
operand.value = operand.multiValue[0] || "";
|
||||||
} else {
|
} else {
|
||||||
operand.value = "";
|
operand.value = "";
|
||||||
@@ -314,19 +324,20 @@ exports.compileFilter = function(filterString) {
|
|||||||
|
|
||||||
// Invoke the appropriate filteroperator module
|
// Invoke the appropriate filteroperator module
|
||||||
results = operatorFunction(accumulator,{
|
results = operatorFunction(accumulator,{
|
||||||
operator: operator.operator,
|
operator: operator.operator,
|
||||||
operand: operands.length > 0 ? operands[0] : undefined,
|
operand: operands.length > 0 ? operands[0] : undefined,
|
||||||
operands: operands,
|
operands: operands,
|
||||||
multiValueOperands: multiValueOperands,
|
multiValueOperands: multiValueOperands,
|
||||||
isMultiValueOperand: isMultiValueOperand,
|
isMultiValueOperand: isMultiValueOperand,
|
||||||
prefix: operator.prefix,
|
prefix: operator.prefix,
|
||||||
suffix: operator.suffix,
|
suffix: operator.suffix,
|
||||||
suffixes: operator.suffixes,
|
suffixes: operator.suffixes,
|
||||||
regexp: operator.regexp
|
regexp: operator.regexp
|
||||||
},{
|
},{
|
||||||
wiki: self,
|
wiki: self,
|
||||||
widget: widget
|
widget: widget,
|
||||||
});
|
defaultFilterRunPrefix: defaultFilterRunPrefix
|
||||||
|
});
|
||||||
if($tw.utils.isArray(results)) {
|
if($tw.utils.isArray(results)) {
|
||||||
accumulator = self.makeTiddlerIterator(results);
|
accumulator = self.makeTiddlerIterator(results);
|
||||||
} else {
|
} else {
|
||||||
@@ -346,29 +357,60 @@ exports.compileFilter = function(filterString) {
|
|||||||
var filterRunPrefixes = self.getFilterRunPrefixes();
|
var filterRunPrefixes = self.getFilterRunPrefixes();
|
||||||
// Wrap the operator functions in a wrapper function that depends on the prefix
|
// Wrap the operator functions in a wrapper function that depends on the prefix
|
||||||
operationFunctions.push((function() {
|
operationFunctions.push((function() {
|
||||||
var options = {wiki: self, suffixes: operation.suffixes || []};
|
if(operation.pragma) {
|
||||||
switch(operation.prefix || "") {
|
// Pragmas are only allowed at the start of a filter, before any runs
|
||||||
case "": // No prefix means that the operation is unioned into the result
|
if(seenNonPragmaOperation) {
|
||||||
return filterRunPrefixes["or"](operationSubFunction, options);
|
return function(results,source,widget) {
|
||||||
case "=": // The results of the operation are pushed into the result without deduplication
|
results.clear();
|
||||||
return filterRunPrefixes["all"](operationSubFunction, options);
|
results.push($tw.language.getString("Error/FilterPragmaPosition"));
|
||||||
case "-": // The results of this operation are removed from the main result
|
};
|
||||||
return filterRunPrefixes["except"](operationSubFunction, options);
|
}
|
||||||
case "+": // This operation is applied to the main results so far
|
switch(operation.pragma) {
|
||||||
return filterRunPrefixes["and"](operationSubFunction, options);
|
case "defaultprefix":
|
||||||
case "~": // This operation is unioned into the result only if the main result so far is empty
|
defaultFilterRunPrefix = operation.suffix || "or";
|
||||||
return filterRunPrefixes["else"](operationSubFunction, options);
|
break;
|
||||||
case "=>": // This operation is applied to the main results so far, and the results are assigned to a variable
|
default:
|
||||||
return filterRunPrefixes["let"](operationSubFunction, options);
|
|
||||||
default:
|
|
||||||
if(operation.namedPrefix && filterRunPrefixes[operation.namedPrefix]) {
|
|
||||||
return filterRunPrefixes[operation.namedPrefix](operationSubFunction, options);
|
|
||||||
} else {
|
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
results.clear();
|
results.clear();
|
||||||
results.push($tw.language.getString("Error/FilterRunPrefix"));
|
results.push($tw.language.getString("Error/FilterPragma"));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
return function(results,source,widget) {
|
||||||
|
// Dummy response
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
seenNonPragmaOperation = true;
|
||||||
|
var options = {wiki: self, suffixes: operation.suffixes || []};
|
||||||
|
switch(operation.prefix || "") {
|
||||||
|
case "": // Use the default filter run prefix if none is specified
|
||||||
|
if(filterRunPrefixes[defaultFilterRunPrefix]) {
|
||||||
|
return filterRunPrefixes[defaultFilterRunPrefix](operationSubFunction, options);
|
||||||
|
} else {
|
||||||
|
return function(results,source,widget) {
|
||||||
|
results.clear();
|
||||||
|
results.push($tw.language.getString("Error/FilterRunPrefix"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case "=": // The results of the operation are pushed into the result without deduplication
|
||||||
|
return filterRunPrefixes["all"](operationSubFunction, options);
|
||||||
|
case "-": // The results of this operation are removed from the main result
|
||||||
|
return filterRunPrefixes["except"](operationSubFunction, options);
|
||||||
|
case "+": // This operation is applied to the main results so far
|
||||||
|
return filterRunPrefixes["and"](operationSubFunction, options);
|
||||||
|
case "~": // This operation is unioned into the result only if the main result so far is empty
|
||||||
|
return filterRunPrefixes["else"](operationSubFunction, options);
|
||||||
|
case "=>": // This operation is applied to the main results so far, and the results are assigned to a variable
|
||||||
|
return filterRunPrefixes["let"](operationSubFunction, options);
|
||||||
|
default:
|
||||||
|
if(operation.namedPrefix && filterRunPrefixes[operation.namedPrefix]) {
|
||||||
|
return filterRunPrefixes[operation.namedPrefix](operationSubFunction, options);
|
||||||
|
} else {
|
||||||
|
return function(results,source,widget) {
|
||||||
|
results.clear();
|
||||||
|
results.push($tw.language.getString("Error/FilterRunPrefix"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})());
|
})());
|
||||||
});
|
});
|
||||||
@@ -407,7 +449,7 @@ exports.compileFilter = function(filterString) {
|
|||||||
this.filterCache = Object.create(null);
|
this.filterCache = Object.create(null);
|
||||||
this.filterCacheCount = 0;
|
this.filterCacheCount = 0;
|
||||||
}
|
}
|
||||||
this.filterCache[filterString] = fnMeasured;
|
this.filterCache[cacheKey] = fnMeasured;
|
||||||
this.filterCacheCount++;
|
this.filterCacheCount++;
|
||||||
return fnMeasured;
|
return fnMeasured;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/changecount.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operator for retrieving the changecount for each title in the list.
|
||||||
|
|
||||||
|
\*/
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter function
|
||||||
|
*/
|
||||||
|
exports.changecount = function(source,operator,options) {
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
results.push(options.wiki.getChangeCount(title) + "");
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/colour-ops.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operators for colour operations
|
||||||
|
|
||||||
|
\*/
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var Color = require("$:/core/modules/utils/dom/color.js").Color,
|
||||||
|
colourSpacesList = Object.keys(Color.spaces),
|
||||||
|
hueAdjustersList = ["raw","increasing","decreasing","longer","shorter"];
|
||||||
|
|
||||||
|
exports["colour-lighten"] = makeSerialColourOperator(function (colour, operator, options) {
|
||||||
|
return colour.lighten($tw.utils.parseNumber(operator.operand)).display().toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-darken"] = makeSerialColourOperator(function (colour, operator, options) {
|
||||||
|
return colour.darken($tw.utils.parseNumber(operator.operand)).display().toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-get-oklch"] = makeSerialColourOperator(function (colour, operator, options) {
|
||||||
|
var prop = ((operator.suffixes || [])[0] || ["l"])[0];
|
||||||
|
if(["l","c","h"].indexOf(prop) !== -1) {
|
||||||
|
colour = colour.oklch[prop];
|
||||||
|
// Hue is null for achromatic colours
|
||||||
|
if(colour === null || colour === undefined || Number.isNaN(colour)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return colour.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-set-oklch"] = makeSerialColourOperator(function (colour, operator, options) {
|
||||||
|
var prop = ((operator.suffixes || [])[0] || ["l"])[0];
|
||||||
|
if(["l","c","h"].indexOf(prop) !== -1) {
|
||||||
|
colour.oklch[prop] = $tw.utils.parseNumber(operator.operand);
|
||||||
|
}
|
||||||
|
return colour.display().toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-set-alpha"] = makeSerialColourOperator(function (colour, operator, options) {
|
||||||
|
colour.alpha = $tw.utils.parseNumber(operator.operand);
|
||||||
|
return colour.display().toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-composite"] = makeSerialColourOperator(function (colour, operator, options) {
|
||||||
|
// Composite each translucent input colour over the backdrop given in the operand
|
||||||
|
var backdrop = $tw.utils.parseCSSColorObject(operator.operand);
|
||||||
|
if(backdrop && colour.alpha < 1) {
|
||||||
|
var alpha = colour.alpha;
|
||||||
|
colour.alpha = 1;
|
||||||
|
colour = backdrop.mix(colour,alpha,{space: "srgb"});
|
||||||
|
}
|
||||||
|
return colour.display().toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-contrast"] = makeParallelColourOperator(function (colours, operator, options) {
|
||||||
|
var colourContrasts = [];
|
||||||
|
$tw.utils.each(colours,function(colour,index) {
|
||||||
|
if(!colour) {
|
||||||
|
colour = $tw.utils.parseCSSColorObject("white");
|
||||||
|
colours[index] = colour;
|
||||||
|
}
|
||||||
|
if(index > 0) {
|
||||||
|
colourContrasts.push(colour.contrast(colours[index - 1],"DeltaPhi").toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return colourContrasts;
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-best-contrast"] = makeParallelColourOperator(function (colours, operator, options, originalColours) {
|
||||||
|
var bestContrast = 0,
|
||||||
|
bestColour = null;
|
||||||
|
if(colours.length < 2) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var targetColour = colours[colours.length - 1];
|
||||||
|
if(!targetColour) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
for(var t=0; t<colours.length; t++) {
|
||||||
|
var colour = colours[t];
|
||||||
|
if(colour) {
|
||||||
|
var contrast = colour.contrast(targetColour,"DeltaPhi");
|
||||||
|
if(contrast > bestContrast) {
|
||||||
|
bestContrast = contrast;
|
||||||
|
bestColour = originalColours[t];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(bestColour) {
|
||||||
|
return [bestColour];
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exports["colour-interpolate"] = function(source,operator,options) {
|
||||||
|
// Get the colour space suffix
|
||||||
|
var space = ((((operator.suffixes || [])[0] || ["srgb"])[0]) || "").toLowerCase();
|
||||||
|
if(colourSpacesList.indexOf(space) === -1) {
|
||||||
|
space = "lch";
|
||||||
|
}
|
||||||
|
// Get the hue adjuster suffix
|
||||||
|
var hueAdjuster = ((((operator.suffixes || [])[1] || ["shorter"])[0]) || "").toLowerCase();
|
||||||
|
if(hueAdjustersList.indexOf(hueAdjuster) === -1) {
|
||||||
|
hueAdjuster = "shorter";
|
||||||
|
}
|
||||||
|
// Get the colours
|
||||||
|
if(operator.operands.length < 2) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var colourA = $tw.utils.parseCSSColorObject(operator.operands[0]),
|
||||||
|
colourB = $tw.utils.parseCSSColorObject(operator.operands[1]);
|
||||||
|
if(!colourA || !colourB) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var rangefn = colourA.range(colourB,{space: space, hue: hueAdjuster});
|
||||||
|
// Cycle through the weights
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
var index = $tw.utils.parseNumber(title);
|
||||||
|
var colour = rangefn(index);
|
||||||
|
results.push(colour.display().toString());
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
function makeSerialColourOperator(fn) {
|
||||||
|
return function (source, operator, options) {
|
||||||
|
var results = [];
|
||||||
|
source(function (tiddler, title) {
|
||||||
|
var c = $tw.utils.parseCSSColorObject(title);
|
||||||
|
if(c) {
|
||||||
|
c = fn(c, operator, options);
|
||||||
|
results.push(c);
|
||||||
|
} else {
|
||||||
|
results.push("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeParallelColourOperator(fn) {
|
||||||
|
return function (source, operator, options) {
|
||||||
|
var originalColours = [],
|
||||||
|
colours = [];
|
||||||
|
source(function (tiddler, title) {
|
||||||
|
originalColours.push(title);
|
||||||
|
colours.push($tw.utils.parseCSSColorObject(title));
|
||||||
|
});
|
||||||
|
return fn(colours, operator, options, originalColours);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -32,4 +32,4 @@ var modes = {
|
|||||||
"gt": function(value) {return value > 0;},
|
"gt": function(value) {return value > 0;},
|
||||||
"lteq": function(value) {return value <= 0;},
|
"lteq": function(value) {return value <= 0;},
|
||||||
"lt": function(value) {return value < 0;}
|
"lt": function(value) {return value < 0;}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -31,4 +31,4 @@ exports["deserialize"] = function(source,operator,options) {
|
|||||||
return [$tw.language.getString("Error/DeserializeOperator/MissingOperand")];
|
return [$tw.language.getString("Error/DeserializeOperator/MissingOperand")];
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.each = function(source,operator,options) {
|
exports.each = function(source,operator,options) {
|
||||||
var results =[] ,
|
var results =[] ,
|
||||||
value,values = {},
|
value,values = {},
|
||||||
field = operator.operand || "title";
|
field = operator.operand || "title";
|
||||||
if(operator.suffix === "value" && field === "title") {
|
if(operator.suffix === "value" && field === "title") {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(!$tw.utils.hop(values,title)) {
|
if(!$tw.utils.hop(values,title)) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ exports.field = function(source,operator,options) {
|
|||||||
if(source.byField && operator.operand) {
|
if(source.byField && operator.operand) {
|
||||||
indexedResults = source.byField(fieldname,operator.operand);
|
indexedResults = source.byField(fieldname,operator.operand);
|
||||||
if(indexedResults) {
|
if(indexedResults) {
|
||||||
return indexedResults
|
return indexedResults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ exports.fields = function(source,operator,options) {
|
|||||||
for(fieldName in tiddler.fields) {
|
for(fieldName in tiddler.fields) {
|
||||||
(operand.indexOf(fieldName) !== -1) ? $tw.utils.pushTop(results,fieldName) : "";
|
(operand.indexOf(fieldName) !== -1) ? $tw.utils.pushTop(results,fieldName) : "";
|
||||||
}
|
}
|
||||||
} else if (suffixes.indexOf("exclude") !== -1) {
|
} else if(suffixes.indexOf("exclude") !== -1) {
|
||||||
for(fieldName in tiddler.fields) {
|
for(fieldName in tiddler.fields) {
|
||||||
(operand.indexOf(fieldName) !== -1) ? "" : $tw.utils.pushTop(results,fieldName);
|
(operand.indexOf(fieldName) !== -1) ? "" : $tw.utils.pushTop(results,fieldName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ Filter operator returning those input titles that pass a subfilter
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.filter = function(source,operator,options) {
|
exports.filter = function(source,operator,options) {
|
||||||
var filterFn = options.wiki.compileFilter(operator.operand),
|
var suffixes = operator.suffixes || [],
|
||||||
|
defaultFilterRunPrefix = (suffixes[0] && suffixes[0][0]) || options.defaultFilterRunPrefix || "or",
|
||||||
|
filterFn = options.wiki.compileFilter(operator.operand,{defaultFilterRunPrefix}),
|
||||||
results = [],
|
results = [],
|
||||||
target = operator.prefix !== "!";
|
target = operator.prefix !== "!";
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),options.widget.makeFakeWidgetWithVariables({
|
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),options.widget.makeFakeWidgetWithVariables({
|
||||||
"currentTiddler": "" + title,
|
"currentTiddler": "" + title,
|
||||||
"..currentTiddler": options.widget.getVariable("currentTiddler","")
|
"..currentTiddler": options.widget.getVariable("currentTiddler",{defaultValue:""})
|
||||||
}));
|
}));
|
||||||
if((list.length > 0) === target) {
|
if((list.length > 0) === target) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Export our filter function
|
|||||||
exports.timestamp = function(source,operand,options) {
|
exports.timestamp = function(source,operand,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if (title.match(/^-?\d+$/)) {
|
if(title.match(/^-?\d+$/)) {
|
||||||
var value = new Date(Number(title));
|
var value = new Date(Number(title));
|
||||||
results.push($tw.utils.formatDateString(value,operand || "[UTC]YYYY0MM0DD0hh0mm0ss0XXX"));
|
results.push($tw.utils.formatDateString(value,operand || "[UTC]YYYY0MM0DD0hh0mm0ss0XXX"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ returns the value at a given index of datatiddlers
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.getindex = function(source,operator,options) {
|
exports.getindex = function(source,operator,options) {
|
||||||
var data,title,results = [];
|
var data,results = [];
|
||||||
if(operator.operand){
|
if(operator.operand){
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
title = tiddler ? tiddler.fields.title : title;
|
title = tiddler ? tiddler.fields.title : title;
|
||||||
|
|||||||
@@ -157,13 +157,13 @@ function convertDataItemValueToStrings(item) {
|
|||||||
if(item === undefined) {
|
if(item === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else if(item === null) {
|
} else if(item === null) {
|
||||||
return ["null"]
|
return ["null"];
|
||||||
} else if(typeof item === "object") {
|
} else if(typeof item === "object") {
|
||||||
var results = [],i,t;
|
var results = [],i,t;
|
||||||
if(Array.isArray(item)) {
|
if(Array.isArray(item)) {
|
||||||
// Return all the items in arrays recursively
|
// Return all the items in arrays recursively
|
||||||
for(i=0; i<item.length; i++) {
|
for(i=0; i<item.length; i++) {
|
||||||
t = convertDataItemValueToStrings(item[i])
|
t = convertDataItemValueToStrings(item[i]);
|
||||||
if(t !== undefined) {
|
if(t !== undefined) {
|
||||||
results.push.apply(results,t);
|
results.push.apply(results,t);
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ function getItemAtIndex(item,index) {
|
|||||||
return item[index];
|
return item[index];
|
||||||
} else if(Array.isArray(item)) {
|
} else if(Array.isArray(item)) {
|
||||||
index = $tw.utils.parseInt(index);
|
index = $tw.utils.parseInt(index);
|
||||||
if(index < 0) { index = index + item.length };
|
if(index < 0) { index = index + item.length; };
|
||||||
return item[index]; // Will be undefined if index was out-of-bounds
|
return item[index]; // Will be undefined if index was out-of-bounds
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -289,7 +289,7 @@ function setDataItem(data,indexes,value) {
|
|||||||
var lastIndex = indexes[indexes.length - 1];
|
var lastIndex = indexes[indexes.length - 1];
|
||||||
if(Array.isArray(current)) {
|
if(Array.isArray(current)) {
|
||||||
lastIndex = $tw.utils.parseInt(lastIndex);
|
lastIndex = $tw.utils.parseInt(lastIndex);
|
||||||
if(lastIndex < 0) { lastIndex = lastIndex + current.length };
|
if(lastIndex < 0) { lastIndex = lastIndex + current.length; };
|
||||||
}
|
}
|
||||||
// Only set indexes on objects and arrays
|
// Only set indexes on objects and arrays
|
||||||
if(typeof current === "object") {
|
if(typeof current === "object") {
|
||||||
@@ -316,7 +316,7 @@ function deleteDataItem(data,indexes) {
|
|||||||
var lastIndex = indexes[indexes.length - 1];
|
var lastIndex = indexes[indexes.length - 1];
|
||||||
if(Array.isArray(current) && current !== null) {
|
if(Array.isArray(current) && current !== null) {
|
||||||
lastIndex = $tw.utils.parseInt(lastIndex);
|
lastIndex = $tw.utils.parseInt(lastIndex);
|
||||||
if(lastIndex < 0) { lastIndex = lastIndex + current.length };
|
if(lastIndex < 0) { lastIndex = lastIndex + current.length; };
|
||||||
// Check if index is valid before splicing
|
// Check if index is valid before splicing
|
||||||
if(lastIndex >= 0 && lastIndex < current.length) {
|
if(lastIndex >= 0 && lastIndex < current.length) {
|
||||||
current.splice(lastIndex,1);
|
current.splice(lastIndex,1);
|
||||||
|
|||||||
@@ -9,69 +9,56 @@ Filter operators for manipulating the current selection list
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Fetch titles from the current list
|
||||||
|
*/
|
||||||
|
const prepare_results = (source) => {
|
||||||
|
const results = [];
|
||||||
|
source((tiddler,title) => results.push(title));
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Order a list
|
Order a list
|
||||||
*/
|
*/
|
||||||
exports.order = function(source,operator,options) {
|
exports.order = function(source,operator,options) {
|
||||||
var results = [];
|
const results = prepare_results(source);
|
||||||
if(operator.operand.toLowerCase() === "reverse") {
|
return operator.operand.toLowerCase() === "reverse" ?
|
||||||
source(function(tiddler,title) {
|
results.reverse() :
|
||||||
results.unshift(title);
|
results;
|
||||||
});
|
|
||||||
} else {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reverse list
|
Reverse list
|
||||||
*/
|
*/
|
||||||
exports.reverse = function(source,operator,options) {
|
exports.reverse = function(source,operator,options) {
|
||||||
var results = [];
|
return prepare_results(source).reverse();
|
||||||
source(function(tiddler,title) {
|
|
||||||
results.unshift(title);
|
|
||||||
});
|
|
||||||
return results;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
First entry/entries in list
|
First entry/entries in list
|
||||||
*/
|
*/
|
||||||
exports.first = function(source,operator,options) {
|
exports.first = function(source,operator,options) {
|
||||||
var count = $tw.utils.getInt(operator.operand,1),
|
const count = $tw.utils.getInt(operator.operand,1);
|
||||||
results = [];
|
return prepare_results(source).slice(0,count);
|
||||||
source(function(tiddler,title) {
|
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
return results.slice(0,count);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Last entry/entries in list
|
Last entry/entries in list
|
||||||
*/
|
*/
|
||||||
exports.last = function(source,operator,options) {
|
exports.last = function(source,operator,options) {
|
||||||
var count = $tw.utils.getInt(operator.operand,1),
|
const count = $tw.utils.getInt(operator.operand,1);
|
||||||
results = [];
|
return count === 0 ?
|
||||||
if(count === 0) return results;
|
[] :
|
||||||
source(function(tiddler,title) {
|
prepare_results(source).slice(-count);
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
return results.slice(-count);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
All but the first entry/entries of the list
|
All but the first entry/entries of the list
|
||||||
*/
|
*/
|
||||||
exports.rest = function(source,operator,options) {
|
exports.rest = function(source,operator,options) {
|
||||||
var count = $tw.utils.getInt(operator.operand,1),
|
const count = $tw.utils.getInt(operator.operand,1);
|
||||||
results = [];
|
return prepare_results(source).slice(count);
|
||||||
source(function(tiddler,title) {
|
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
return results.slice(count);
|
|
||||||
};
|
};
|
||||||
exports.butfirst = exports.rest;
|
exports.butfirst = exports.rest;
|
||||||
exports.bf = exports.rest;
|
exports.bf = exports.rest;
|
||||||
@@ -80,12 +67,9 @@ exports.bf = exports.rest;
|
|||||||
All but the last entry/entries of the list
|
All but the last entry/entries of the list
|
||||||
*/
|
*/
|
||||||
exports.butlast = function(source,operator,options) {
|
exports.butlast = function(source,operator,options) {
|
||||||
var count = $tw.utils.getInt(operator.operand,1),
|
const count = $tw.utils.getInt(operator.operand,1),
|
||||||
results = [];
|
results = prepare_results(source),
|
||||||
source(function(tiddler,title) {
|
index = count === 0 ? results.length : -count;
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
var index = count === 0 ? results.length : -count;
|
|
||||||
return results.slice(0,index);
|
return results.slice(0,index);
|
||||||
};
|
};
|
||||||
exports.bl = exports.butlast;
|
exports.bl = exports.butlast;
|
||||||
@@ -94,22 +78,14 @@ exports.bl = exports.butlast;
|
|||||||
The nth member of the list
|
The nth member of the list
|
||||||
*/
|
*/
|
||||||
exports.nth = function(source,operator,options) {
|
exports.nth = function(source,operator,options) {
|
||||||
var count = $tw.utils.getInt(operator.operand,1),
|
const count = $tw.utils.getInt(operator.operand,1);
|
||||||
results = [];
|
return prepare_results(source).slice(count - 1,count);
|
||||||
source(function(tiddler,title) {
|
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
return results.slice(count - 1,count);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The zero based nth member of the list
|
The zero based nth member of the list
|
||||||
*/
|
*/
|
||||||
exports.zth = function(source,operator,options) {
|
exports.zth = function(source,operator,options) {
|
||||||
var count = $tw.utils.getInt(operator.operand,0),
|
const count = $tw.utils.getInt(operator.operand,0);
|
||||||
results = [];
|
return prepare_results(source).slice(count,count + 1);
|
||||||
source(function(tiddler,title) {
|
};
|
||||||
results.push(title);
|
|
||||||
});
|
|
||||||
return results.slice(count,count + 1);
|
|
||||||
};
|
|
||||||
@@ -25,7 +25,7 @@ exports.lookup = function(source,operator,options) {
|
|||||||
indexSuffix = (suffixes[1] && suffixes[1][0] === "index") ? true : false,
|
indexSuffix = (suffixes[1] && suffixes[1][0] === "index") ? true : false,
|
||||||
target;
|
target;
|
||||||
if(operator.operands.length == 2) {
|
if(operator.operands.length == 2) {
|
||||||
target = operator.operands[1]
|
target = operator.operands[1];
|
||||||
} else {
|
} else {
|
||||||
target = indexSuffix ? "0": "text";
|
target = indexSuffix ? "0": "text";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,35 +17,35 @@ Note that strings are converted to numbers automatically. Trailing non-digits ar
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports.negate = makeNumericBinaryOperator(
|
exports.negate = makeNumericBinaryOperator(
|
||||||
function(a) {return -a}
|
function(a) {return -a;}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.abs = makeNumericBinaryOperator(
|
exports.abs = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.abs(a)}
|
function(a) {return Math.abs(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.ceil = makeNumericBinaryOperator(
|
exports.ceil = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.ceil(a)}
|
function(a) {return Math.ceil(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.floor = makeNumericBinaryOperator(
|
exports.floor = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.floor(a)}
|
function(a) {return Math.floor(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.round = makeNumericBinaryOperator(
|
exports.round = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.round(a)}
|
function(a) {return Math.round(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.trunc = makeNumericBinaryOperator(
|
exports.trunc = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.trunc(a)}
|
function(a) {return Math.trunc(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.untrunc = makeNumericBinaryOperator(
|
exports.untrunc = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.ceil(Math.abs(a)) * Math.sign(a)}
|
function(a) {return Math.ceil(Math.abs(a)) * Math.sign(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.sign = makeNumericBinaryOperator(
|
exports.sign = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.sign(a)}
|
function(a) {return Math.sign(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.add = makeNumericBinaryOperator(
|
exports.add = makeNumericBinaryOperator(
|
||||||
@@ -103,29 +103,29 @@ exports.log = makeNumericBinaryOperator(
|
|||||||
);
|
);
|
||||||
|
|
||||||
exports.sum = makeNumericReducingOperator(
|
exports.sum = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return accumulator + value},
|
function(accumulator,value) {return accumulator + value;},
|
||||||
0 // Initial value
|
0 // Initial value
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.product = makeNumericReducingOperator(
|
exports.product = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return accumulator * value},
|
function(accumulator,value) {return accumulator * value;},
|
||||||
1 // Initial value
|
1 // Initial value
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.maxall = makeNumericReducingOperator(
|
exports.maxall = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return Math.max(accumulator,value)},
|
function(accumulator,value) {return Math.max(accumulator,value);},
|
||||||
-Infinity // Initial value
|
-Infinity // Initial value
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.minall = makeNumericReducingOperator(
|
exports.minall = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return Math.min(accumulator,value)},
|
function(accumulator,value) {return Math.min(accumulator,value);},
|
||||||
Infinity // Initial value
|
Infinity // Initial value
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.median = makeNumericArrayOperator(
|
exports.median = makeNumericArrayOperator(
|
||||||
function(values) {
|
function(values) {
|
||||||
var len = values.length, median;
|
var len = values.length, median;
|
||||||
values.sort(function(a,b) {return a-b});
|
values.sort(function(a,b) {return a-b;});
|
||||||
if(len % 2) {
|
if(len % 2) {
|
||||||
// Odd, return the middle number
|
// Odd, return the middle number
|
||||||
median = values[(len - 1) / 2];
|
median = values[(len - 1) / 2];
|
||||||
@@ -138,7 +138,7 @@ exports.median = makeNumericArrayOperator(
|
|||||||
);
|
);
|
||||||
|
|
||||||
exports.average = makeNumericReducingOperator(
|
exports.average = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return accumulator + value},
|
function(accumulator,value) {return accumulator + value;},
|
||||||
0, // Initial value
|
0, // Initial value
|
||||||
function(finalValue,numberOfValues) {
|
function(finalValue,numberOfValues) {
|
||||||
return finalValue/numberOfValues;
|
return finalValue/numberOfValues;
|
||||||
@@ -146,7 +146,7 @@ exports.average = makeNumericReducingOperator(
|
|||||||
);
|
);
|
||||||
|
|
||||||
exports.variance = makeNumericReducingOperator(
|
exports.variance = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return accumulator + value},
|
function(accumulator,value) {return accumulator + value;},
|
||||||
0,
|
0,
|
||||||
function(finalValue,numberOfValues,originalValues) {
|
function(finalValue,numberOfValues,originalValues) {
|
||||||
return getVarianceFromArray(originalValues,finalValue/numberOfValues);
|
return getVarianceFromArray(originalValues,finalValue/numberOfValues);
|
||||||
@@ -154,7 +154,7 @@ exports.variance = makeNumericReducingOperator(
|
|||||||
);
|
);
|
||||||
|
|
||||||
exports["standard-deviation"] = makeNumericReducingOperator(
|
exports["standard-deviation"] = makeNumericReducingOperator(
|
||||||
function(accumulator,value) {return accumulator + value},
|
function(accumulator,value) {return accumulator + value;},
|
||||||
0,
|
0,
|
||||||
function(finalValue,numberOfValues,originalValues) {
|
function(finalValue,numberOfValues,originalValues) {
|
||||||
var variance = getVarianceFromArray(originalValues,finalValue/numberOfValues);
|
var variance = getVarianceFromArray(originalValues,finalValue/numberOfValues);
|
||||||
@@ -164,31 +164,31 @@ exports["standard-deviation"] = makeNumericReducingOperator(
|
|||||||
|
|
||||||
//trigonometry
|
//trigonometry
|
||||||
exports.cos = makeNumericBinaryOperator(
|
exports.cos = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.cos(a)}
|
function(a) {return Math.cos(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.sin = makeNumericBinaryOperator(
|
exports.sin = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.sin(a)}
|
function(a) {return Math.sin(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.tan = makeNumericBinaryOperator(
|
exports.tan = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.tan(a)}
|
function(a) {return Math.tan(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.acos = makeNumericBinaryOperator(
|
exports.acos = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.acos(a)}
|
function(a) {return Math.acos(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.asin = makeNumericBinaryOperator(
|
exports.asin = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.asin(a)}
|
function(a) {return Math.asin(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.atan = makeNumericBinaryOperator(
|
exports.atan = makeNumericBinaryOperator(
|
||||||
function(a) {return Math.atan(a)}
|
function(a) {return Math.atan(a);}
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.atan2 = makeNumericBinaryOperator(
|
exports.atan2 = makeNumericBinaryOperator(
|
||||||
function(a,b) {return Math.atan2(a,b)}
|
function(a,b) {return Math.atan2(a,b);}
|
||||||
);
|
);
|
||||||
|
|
||||||
//Calculate the variance of a population of numbers in an array given its mean
|
//Calculate the variance of a population of numbers in an array given its mean
|
||||||
@@ -222,8 +222,8 @@ function makeNumericReducingOperator(fnCalc,initialValue,fnFinal) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var value = result.reduce(function(accumulator,currentValue) {
|
var value = result.reduce(function(accumulator,currentValue) {
|
||||||
return fnCalc(accumulator,currentValue);
|
return fnCalc(accumulator,currentValue);
|
||||||
},initialValue);
|
},initialValue);
|
||||||
if(fnFinal) {
|
if(fnFinal) {
|
||||||
value = fnFinal(value,result.length,result);
|
value = fnFinal(value,result.length,result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,37 +13,22 @@ Filter operator for checking if a title starts with a prefix
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.prefix = function(source,operator,options) {
|
exports.prefix = function(source,operator,options) {
|
||||||
var results = [],
|
const results = [],
|
||||||
suffixes = (operator.suffixes || [])[0] || [];
|
suffixes = (operator.suffixes || [])[0] || [],
|
||||||
if(suffixes.indexOf("caseinsensitive") !== -1) {
|
caseInsensitive = suffixes.includes("caseinsensitive"),
|
||||||
var operand = operator.operand.toLowerCase();
|
negate = operator.prefix === "!";
|
||||||
if(operator.prefix === "!") {
|
|
||||||
source(function(tiddler,title) {
|
const operand = caseInsensitive ?
|
||||||
if(title.toLowerCase().substr(0,operand.length) !== operand) {
|
operator.operand.toLowerCase() :
|
||||||
results.push(title);
|
operator.operand;
|
||||||
}
|
|
||||||
});
|
source((tiddler,title) => {
|
||||||
} else {
|
const value = caseInsensitive ? title.toLowerCase() : title,
|
||||||
source(function(tiddler,title) {
|
matches = value.startsWith(operand);
|
||||||
if(title.toLowerCase().substr(0,operand.length) === operand) {
|
if(negate ? !matches : matches) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
if(operator.prefix === "!") {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(title.substr(0,operator.operand.length) !== operator.operand) {
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(title.substr(0,operator.operand.length) === operator.operand) {
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
@@ -21,7 +21,7 @@ exports.range = function(source,operator,options) {
|
|||||||
}
|
}
|
||||||
// Process the parts
|
// Process the parts
|
||||||
var beg, end, inc, i, fixed = 0;
|
var beg, end, inc, i, fixed = 0;
|
||||||
for (i=0; i<parts.length; i++) {
|
for(i=0; i<parts.length; i++) {
|
||||||
// Validate real number
|
// Validate real number
|
||||||
if(!/^\s*[+-]?((\d+(\.\d*)?)|(\.\d+))\s*$/.test(parts[i])) {
|
if(!/^\s*[+-]?((\d+(\.\d*)?)|(\.\d+))\s*$/.test(parts[i])) {
|
||||||
return ["range: bad number \"" + parts[i] + "\""];
|
return ["range: bad number \"" + parts[i] + "\""];
|
||||||
@@ -36,10 +36,10 @@ exports.range = function(source,operator,options) {
|
|||||||
switch(parts.length) {
|
switch(parts.length) {
|
||||||
case 1:
|
case 1:
|
||||||
end = parts[0];
|
end = parts[0];
|
||||||
if (end >= 1) {
|
if(end >= 1) {
|
||||||
beg = 1;
|
beg = 1;
|
||||||
}
|
}
|
||||||
else if (end <= -1) {
|
else if(end <= -1) {
|
||||||
beg = -1;
|
beg = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -72,7 +72,7 @@ exports.range = function(source,operator,options) {
|
|||||||
end += direction * 0.5 * Math.pow(0.1,fixed);
|
end += direction * 0.5 * Math.pow(0.1,fixed);
|
||||||
var safety = 10010;
|
var safety = 10010;
|
||||||
// Enumerate the range
|
// Enumerate the range
|
||||||
if (end<beg) {
|
if(end<beg) {
|
||||||
for(i=beg; i>end; i+=inc) {
|
for(i=beg; i>end; i+=inc) {
|
||||||
results.push(i.toFixed(fixed));
|
results.push(i.toFixed(fixed));
|
||||||
if(--safety<0) {
|
if(--safety<0) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Export our filter function
|
|||||||
exports.removesuffix = function(source,operator,options) {
|
exports.removesuffix = function(source,operator,options) {
|
||||||
var results = [],
|
var results = [],
|
||||||
suffixes = (operator.suffixes || [])[0] || [];
|
suffixes = (operator.suffixes || [])[0] || [];
|
||||||
if (!operator.operand) {
|
if(!operator.operand) {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,31 +14,31 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.sort = function(source,operator,options) {
|
exports.sort = function(source,operator,options) {
|
||||||
var results = prepare_results(source);
|
var results = prepare_results(source);
|
||||||
options.wiki.sortTiddlers(results,operator.operands[0] || "title",operator.prefix === "!",false,false,undefined,operator.operands[1]);
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",false,false);
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.nsort = function(source,operator,options) {
|
exports.nsort = function(source,operator,options) {
|
||||||
var results = prepare_results(source);
|
var results = prepare_results(source);
|
||||||
options.wiki.sortTiddlers(results,operator.operands[0] || "title",operator.prefix === "!",false,true,undefined,operator.operands[1]);
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",false,true);
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.sortan = function(source, operator, options) {
|
exports.sortan = function(source, operator, options) {
|
||||||
var results = prepare_results(source);
|
var results = prepare_results(source);
|
||||||
options.wiki.sortTiddlers(results, operator.operands[0] || "title", operator.prefix === "!",false,false,true,operator.operands[1]);
|
options.wiki.sortTiddlers(results, operator.operand || "title", operator.prefix === "!",false,false,true);
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.sortcs = function(source,operator,options) {
|
exports.sortcs = function(source,operator,options) {
|
||||||
var results = prepare_results(source);
|
var results = prepare_results(source);
|
||||||
options.wiki.sortTiddlers(results,operator.operands[0] || "title",operator.prefix === "!",true,false,undefined,operator.operands[1]);
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",true,false);
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.nsortcs = function(source,operator,options) {
|
exports.nsortcs = function(source,operator,options) {
|
||||||
var results = prepare_results(source);
|
var results = prepare_results(source);
|
||||||
options.wiki.sortTiddlers(results,operator.operands[0] || "title",operator.prefix === "!",true,true,undefined,operator.operands[1]);
|
options.wiki.sortTiddlers(results,operator.operand || "title",operator.prefix === "!",true,true);
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.sortsub = function(source,operator,options) {
|
exports.sortsub = function(source,operator,options) {
|
||||||
// Compile the subfilter
|
// Compile the subfilter
|
||||||
var filterFn = options.wiki.compileFilter(operator.operand);
|
let filterFn = options.wiki.compileFilter(operator.operand);
|
||||||
// Collect the input titles and the corresponding sort keys
|
// Collect the input titles and the corresponding sort keys
|
||||||
var inputTitles = [],
|
let inputTitles = [],
|
||||||
sortKeys = [];
|
sortKeys = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
inputTitles.push(title);
|
inputTitles.push(title);
|
||||||
var r = filterFn.call(options.wiki,function(iterator) {
|
let r = filterFn.call(options.wiki,function(iterator) {
|
||||||
iterator(options.wiki.getTiddler(title),title);
|
iterator(options.wiki.getTiddler(title),title);
|
||||||
},options.widget.makeFakeWidgetWithVariables({
|
},options.widget.makeFakeWidgetWithVariables({
|
||||||
"currentTiddler": "" + title,
|
"currentTiddler": "" + title,
|
||||||
@@ -29,17 +29,12 @@ exports.sortsub = function(source,operator,options) {
|
|||||||
sortKeys.push(r[0] || "");
|
sortKeys.push(r[0] || "");
|
||||||
});
|
});
|
||||||
// Rather than sorting the titles array, we'll sort the indexes so that we can consult both arrays
|
// Rather than sorting the titles array, we'll sort the indexes so that we can consult both arrays
|
||||||
var indexes = new Array(inputTitles.length);
|
let indexes = Array.from(inputTitles.keys());
|
||||||
for(var t=0; t<inputTitles.length; t++) {
|
|
||||||
indexes[t] = t;
|
|
||||||
}
|
|
||||||
// Sort the indexes
|
// Sort the indexes
|
||||||
var compareFn = $tw.utils.makeCompareFunction(operator.suffix,{defaultType: "string",invert: operator.prefix === "!"});
|
let compareFn = $tw.utils.makeCompareFunction(operator.suffix,{defaultType: "string",invert: operator.prefix === "!"});
|
||||||
indexes = indexes.sort(function(a,b) {
|
indexes = indexes.sort((a,b) => compareFn(sortKeys[a],sortKeys[b]));
|
||||||
return compareFn(sortKeys[a],sortKeys[b]);
|
|
||||||
});
|
|
||||||
// Make the results array in order
|
// Make the results array in order
|
||||||
var results = [];
|
let results = [];
|
||||||
$tw.utils.each(indexes,function(index) {
|
$tw.utils.each(indexes,function(index) {
|
||||||
results.push(inputTitles[index]);
|
results.push(inputTitles[index]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -91,22 +91,35 @@ function diffLineWordMode(text1,text2,mode) {
|
|||||||
return diffs;
|
return diffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.makepatches = function(source,operator,options) {
|
exports.makepatches = function(source, operator, options) {
|
||||||
var suffix = operator.suffix || "",
|
const suffixes = operator.suffixes || [],
|
||||||
result = [];
|
[modeArg = [], formatArg = []] = suffixes,
|
||||||
|
modeSuffix = modeArg[0] || operator.suffix || "",
|
||||||
source(function(tiddler,title) {
|
mode = ["lines", "words"].includes(modeSuffix) ? modeSuffix : "",
|
||||||
let diffs, patches;
|
isJson = formatArg[0] === "json",
|
||||||
if(suffix === "lines" || suffix === "words") {
|
results = [];
|
||||||
diffs = diffLineWordMode(title,operator.operand,suffix);
|
|
||||||
patches = dmp.patchMake(title,diffs);
|
source((tiddler, title) => {
|
||||||
|
if (isJson) {
|
||||||
|
const diffs = (mode === "lines" || mode === "words")
|
||||||
|
? diffLineWordMode(title, operator.operand, mode)
|
||||||
|
: dmp.diffMain(title, operator.operand);
|
||||||
|
|
||||||
|
const jsonOutput = diffs.map(([typeCode, text]) => ({
|
||||||
|
type: typeCode === 1 ? "insert" : (typeCode === -1 ? "delete" : "equal"),
|
||||||
|
text
|
||||||
|
}));
|
||||||
|
results.push(JSON.stringify(jsonOutput));
|
||||||
} else {
|
} else {
|
||||||
patches = dmp.patchMake(title,operator.operand);
|
const patches = (mode === "lines" || mode === "words")
|
||||||
|
? dmp.patchMake(title, diffLineWordMode(title, operator.operand, mode))
|
||||||
|
: dmp.patchMake(title, operator.operand);
|
||||||
|
|
||||||
|
results.push(dmp.patchToText(patches));
|
||||||
}
|
}
|
||||||
Array.prototype.push.apply(result,[dmp.patchToText(patches)]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.applypatches = makeStringBinaryOperator(
|
exports.applypatches = makeStringBinaryOperator(
|
||||||
@@ -235,4 +248,4 @@ exports.charcode = function(source,operator,options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return [chars.join("")];
|
return [chars.join("")];
|
||||||
};
|
};
|
||||||
@@ -13,11 +13,14 @@ Filter operator returning its operand evaluated as a filter
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.subfilter = function(source,operator,options) {
|
exports.subfilter = function(source,operator,options) {
|
||||||
var list = options.wiki.filterTiddlers(operator.operand,options.widget,source);
|
var suffixes = operator.suffixes || [],
|
||||||
|
defaultFilterRunPrefix = (suffixes[0] && suffixes[0][0]) || options.defaultFilterRunPrefix || "or";
|
||||||
|
var list = options.wiki.filterTiddlers(operator.operand,options.widget,source,{defaultFilterRunPrefix});
|
||||||
if(operator.prefix === "!") {
|
if(operator.prefix === "!") {
|
||||||
var results = [];
|
const results = [],
|
||||||
source(function(tiddler,title) {
|
listSet = new Set(list);
|
||||||
if(list.indexOf(title) === -1) {
|
source((tiddler,title) => {
|
||||||
|
if(!listSet.has(title)) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,41 +13,27 @@ Filter operator for checking if a title ends with a suffix
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.suffix = function(source,operator,options) {
|
exports.suffix = function(source,operator,options) {
|
||||||
var results = [],
|
const results = [],
|
||||||
suffixes = (operator.suffixes || [])[0] || [];
|
suffixes = (operator.suffixes || [])[0] || [];
|
||||||
if (!operator.operand) {
|
|
||||||
source(function(tiddler,title) {
|
if(!operator.operand) {
|
||||||
|
source((tiddler,title) => {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
});
|
});
|
||||||
} else if(suffixes.indexOf("caseinsensitive") !== -1) {
|
return results;
|
||||||
var operand = operator.operand.toLowerCase();
|
|
||||||
if(operator.prefix === "!") {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(title.toLowerCase().substr(-operand.length) !== operand) {
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(title.toLowerCase().substr(-operand.length) === operand) {
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(operator.prefix === "!") {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(title.substr(-operator.operand.length) !== operator.operand) {
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(title.substr(-operator.operand.length) === operator.operand) {
|
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const caseInsensitive = suffixes.indexOf("caseinsensitive") !== -1,
|
||||||
|
negate = operator.prefix === "!",
|
||||||
|
operand = caseInsensitive ? operator.operand.toLowerCase() : operator.operand;
|
||||||
|
|
||||||
|
source((tiddler,title) => {
|
||||||
|
const value = caseInsensitive ? title.toLowerCase() : title,
|
||||||
|
matches = value.endsWith(operand);
|
||||||
|
if(negate ? !matches : matches) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,12 +22,11 @@ exports.tag = function(source,operator,options) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Old semantics:
|
// Old semantics:
|
||||||
var tiddlers;
|
|
||||||
if(operator.prefix === "!") {
|
if(operator.prefix === "!") {
|
||||||
// Returns a copy of the input if operator.operand is missing
|
// Returns a copy of the input if operator.operand is missing
|
||||||
tiddlers = options.wiki.getTiddlersWithTag(operator.operand);
|
const excludeTagSet = new Set(options.wiki.getTiddlersWithTag(operator.operand));
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddlers.indexOf(title) === -1) {
|
if(!excludeTagSet.has(title)) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -39,9 +38,9 @@ exports.tag = function(source,operator,options) {
|
|||||||
return indexedResults;
|
return indexedResults;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tiddlers = options.wiki.getTiddlersWithTag(operator.operand);
|
const includeTagSet = new Set(options.wiki.getTiddlersWithTag(operator.operand));
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddlers.indexOf(title) !== -1) {
|
if(includeTagSet.has(title)) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ exports.variables = function(source,operator,options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return names.sort();
|
return names.sort();
|
||||||
};
|
};
|
||||||
+168
-179
@@ -7,224 +7,213 @@ Extended filter operators to manipulate the current list.
|
|||||||
|
|
||||||
\*/
|
\*/
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Fetch titles from the current list
|
Fetch titles from the current list
|
||||||
*/
|
*/
|
||||||
var prepare_results = function (source) {
|
const prepare_results = (source) => {
|
||||||
var results = [];
|
const results = [];
|
||||||
source(function (tiddler, title) {
|
source((tiddler,title) => results.push(title));
|
||||||
results.push(title);
|
return results;
|
||||||
});
|
};
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Moves a number of items from the tail of the current list before the item named in the operand
|
Moves a number of items from the tail of the current list before the item named in the operand
|
||||||
*/
|
*/
|
||||||
exports.putbefore = function (source, operator) {
|
exports.putbefore = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
index = results.indexOf(operator.operand),
|
index = results.indexOf(operator.operand),
|
||||||
count = $tw.utils.getInt(operator.suffix,1);
|
count = $tw.utils.getInt(operator.suffix,1);
|
||||||
return (index === -1) ?
|
return (index === -1) ?
|
||||||
results.slice(0, -1) :
|
results.slice(0, -1) :
|
||||||
results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index, -count));
|
results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index, -count));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Moves a number of items from the tail of the current list after the item named in the operand
|
Moves a number of items from the tail of the current list after the item named in the operand
|
||||||
*/
|
*/
|
||||||
exports.putafter = function (source, operator) {
|
exports.putafter = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
index = results.indexOf(operator.operand),
|
index = results.indexOf(operator.operand),
|
||||||
count = $tw.utils.getInt(operator.suffix,1);
|
count = $tw.utils.getInt(operator.suffix,1);
|
||||||
return (index === -1) ?
|
return (index === -1) ?
|
||||||
results.slice(0, -1) :
|
results.slice(0, -1) :
|
||||||
results.slice(0, index + 1).concat(results.slice(-count)).concat(results.slice(index + 1, -count));
|
results.slice(0, index + 1).concat(results.slice(-count)).concat(results.slice(index + 1, -count));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Replaces the item named in the operand with a number of items from the tail of the current list
|
Replaces the item named in the operand with a number of items from the tail of the current list
|
||||||
*/
|
*/
|
||||||
exports.replace = function (source, operator) {
|
exports.replace = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
index = results.indexOf(operator.operand),
|
index = results.indexOf(operator.operand),
|
||||||
count = $tw.utils.getInt(operator.suffix,1);
|
count = $tw.utils.getInt(operator.suffix,1);
|
||||||
return (index === -1) ?
|
return (index === -1) ?
|
||||||
results.slice(0, -count) :
|
results.slice(0, -count) :
|
||||||
results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index + 1, -count));
|
results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index + 1, -count));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Moves a number of items from the tail of the current list to the head of the list
|
Moves a number of items from the tail of the current list to the head of the list
|
||||||
*/
|
*/
|
||||||
exports.putfirst = function (source, operator) {
|
exports.putfirst = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
count = $tw.utils.getInt(operator.suffix,1);
|
count = $tw.utils.getInt(operator.suffix,1);
|
||||||
return results.slice(-count).concat(results.slice(0, -count));
|
return [...results.slice(-count), ...results.slice(0, -count)];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Moves a number of items from the head of the current list to the tail of the list
|
Moves a number of items from the head of the current list to the tail of the list
|
||||||
*/
|
*/
|
||||||
exports.putlast = function (source, operator) {
|
exports.putlast = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
count = $tw.utils.getInt(operator.suffix,1);
|
count = $tw.utils.getInt(operator.suffix,1);
|
||||||
return results.slice(count).concat(results.slice(0, count));
|
return [...results.slice(count), ...results.slice(0, count)];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Moves the item named in the operand a number of places forward or backward in the list
|
Moves the item named in the operand a number of places forward or backward in the list
|
||||||
*/
|
*/
|
||||||
exports.move = function (source, operator) {
|
exports.move = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
index = results.indexOf(operator.operand),
|
index = results.indexOf(operator.operand),
|
||||||
count = $tw.utils.getInt(operator.suffix,1),
|
count = $tw.utils.getInt(operator.suffix,1),
|
||||||
marker = results.splice(index, 1),
|
marker = results.splice(index, 1),
|
||||||
offset = (index + count) > 0 ? index + count : 0;
|
offset = (index + count) > 0 ? index + count : 0;
|
||||||
return results.slice(0, offset).concat(marker).concat(results.slice(offset));
|
return results.slice(0, offset).concat(marker).concat(results.slice(offset));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns the items from the current list that are after the item named in the operand
|
Returns the items from the current list that are after the item named in the operand
|
||||||
*/
|
*/
|
||||||
exports.allafter = function (source, operator) {
|
exports.allafter = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
index = results.indexOf(operator.operand);
|
index = results.indexOf(operator.operand);
|
||||||
return (index === -1) ? [] :
|
return (index === -1) ? [] :
|
||||||
(operator.suffix) ? results.slice(index) :
|
(operator.suffix) ? results.slice(index) :
|
||||||
results.slice(index + 1);
|
results.slice(index + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns the items from the current list that are before the item named in the operand
|
Returns the items from the current list that are before the item named in the operand
|
||||||
*/
|
*/
|
||||||
exports.allbefore = function (source, operator) {
|
exports.allbefore = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
index = results.indexOf(operator.operand);
|
index = results.indexOf(operator.operand);
|
||||||
return (index === -1) ? [] :
|
return (index === -1) ? [] :
|
||||||
(operator.suffix) ? results.slice(0, index + 1) :
|
(operator.suffix) ? results.slice(0, index + 1) :
|
||||||
results.slice(0, index);
|
results.slice(0, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Appends the items listed in the operand array to the tail of the current list
|
Appends the items listed in the operand array to the tail of the current list
|
||||||
*/
|
*/
|
||||||
exports.append = function (source, operator) {
|
exports.append = function(source,operator) {
|
||||||
var append = $tw.utils.parseStringArray(operator.operand, "true"),
|
const append = $tw.utils.parseStringArray(operator.operand,"true"),
|
||||||
results = prepare_results(source),
|
results = prepare_results(source),
|
||||||
count = parseInt(operator.suffix) || append.length;
|
count = parseInt(operator.suffix) || append.length;
|
||||||
return (append.length === 0) ? results :
|
return (append.length === 0) ? results :
|
||||||
(operator.prefix) ? results.concat(append.slice(-count)) :
|
(operator.prefix) ? results.concat(append.slice(-count)) :
|
||||||
results.concat(append.slice(0, count));
|
results.concat(append.slice(0, count));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Prepends the items listed in the operand array to the head of the current list
|
Prepends the items listed in the operand array to the head of the current list
|
||||||
*/
|
*/
|
||||||
exports.prepend = function (source, operator) {
|
exports.prepend = function(source,operator) {
|
||||||
var prepend = $tw.utils.parseStringArray(operator.operand, "true"),
|
const prepend = $tw.utils.parseStringArray(operator.operand,"true"),
|
||||||
results = prepare_results(source),
|
results = prepare_results(source),
|
||||||
count = $tw.utils.getInt(operator.suffix,prepend.length);
|
count = $tw.utils.getInt(operator.suffix,prepend.length);
|
||||||
return (prepend.length === 0) ? results :
|
return (prepend.length === 0) ? results :
|
||||||
(operator.prefix) ? prepend.slice(-count).concat(results) :
|
(operator.prefix) ? prepend.slice(-count).concat(results) :
|
||||||
prepend.slice(0, count).concat(results);
|
prepend.slice(0, count).concat(results);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns all items from the current list except the items listed in the operand array
|
Returns all items from the current list except the items listed in the operand array
|
||||||
*/
|
*/
|
||||||
exports.remove = function (source, operator) {
|
exports.remove = function(source, operator) {
|
||||||
var array = $tw.utils.parseStringArray(operator.operand, "true"),
|
const array = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||||
results = prepare_results(source),
|
results = prepare_results(source);
|
||||||
count = parseInt(operator.suffix) || array.length,
|
|
||||||
p,
|
|
||||||
len,
|
|
||||||
index;
|
|
||||||
len = array.length - 1;
|
|
||||||
for (p = 0; p < count; ++p) {
|
|
||||||
if (operator.prefix) {
|
|
||||||
index = results.indexOf(array[len - p]);
|
|
||||||
} else {
|
|
||||||
index = results.indexOf(array[p]);
|
|
||||||
}
|
|
||||||
if (index !== -1) {
|
|
||||||
results.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
if(array.length === 0) {
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
const count = parseInt(operator.suffix, 10) || array.length,
|
||||||
|
targetItems = operator.prefix ? array.slice(-count).reverse() : array.slice(0, count);
|
||||||
|
|
||||||
|
for(const item of targetItems) {
|
||||||
|
const index = results.indexOf(item);
|
||||||
|
if(index !== -1) {
|
||||||
|
results.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
Returns all items from the current list sorted in the order of the items in the operand array
|
Returns all items from the current list sorted in the order of the items in the operand array
|
||||||
*/
|
*/
|
||||||
exports.sortby = function (source, operator) {
|
exports.sortby = function(source,operator) {
|
||||||
var results = prepare_results(source);
|
const results = prepare_results(source);
|
||||||
if (!results || results.length < 2) {
|
if(!results || results.length < 2) {
|
||||||
return results;
|
|
||||||
}
|
|
||||||
var lookup = $tw.utils.parseStringArray(operator.operand, "true");
|
|
||||||
results.sort(function (a, b) {
|
|
||||||
return lookup.indexOf(a) - lookup.indexOf(b);
|
|
||||||
});
|
|
||||||
return results;
|
return results;
|
||||||
};
|
}
|
||||||
|
const lookup = $tw.utils.parseStringArray(operator.operand,"true");
|
||||||
|
return results.sort((a,b) => lookup.indexOf(a) - lookup.indexOf(b));
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
|
/*
|
||||||
Removes all duplicate items from the current list
|
Removes all duplicate items from the current list
|
||||||
*/
|
*/
|
||||||
exports.unique = function (source, operator) {
|
exports.unique = function(source, operator) {
|
||||||
var results = prepare_results(source);
|
return Array.from(new Set(prepare_results(source)));
|
||||||
var set = results.reduce(function (a, b) {
|
};
|
||||||
if (a.indexOf(b) < 0) {
|
|
||||||
a.push(b);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}, []);
|
|
||||||
return set;
|
|
||||||
};
|
|
||||||
|
|
||||||
var cycleValueInArray = function(results,operands,stepSize) {
|
const cycleValueInArray = function(results,operands,stepSize) {
|
||||||
var resultsIndex,
|
let resultsIndex,
|
||||||
step = stepSize || 1,
|
step = stepSize || 1,
|
||||||
i = 0,
|
i = 0,
|
||||||
opLength = operands.length,
|
nextOperandIndex;
|
||||||
nextOperandIndex;
|
const opLength = operands.length;
|
||||||
for(i; i < opLength; i++) {
|
|
||||||
resultsIndex = results.indexOf(operands[i]);
|
for(; i < opLength; i++) {
|
||||||
if(resultsIndex !== -1) {
|
resultsIndex = results.indexOf(operands[i]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(resultsIndex !== -1) {
|
if(resultsIndex !== -1) {
|
||||||
i = i + step;
|
break;
|
||||||
nextOperandIndex = (i < opLength ? i : i % opLength);
|
}
|
||||||
if(operands.length > 1) {
|
}
|
||||||
results.splice(resultsIndex,1,operands[nextOperandIndex]);
|
if(resultsIndex !== -1) {
|
||||||
} else {
|
i = i + step;
|
||||||
results.splice(resultsIndex,1);
|
nextOperandIndex = (i < opLength ? i : i % opLength);
|
||||||
}
|
if(operands.length > 1) {
|
||||||
|
results.splice(resultsIndex,1,operands[nextOperandIndex]);
|
||||||
} else {
|
} else {
|
||||||
results.push(operands[0]);
|
results.splice(resultsIndex,1);
|
||||||
}
|
}
|
||||||
return results;
|
} else {
|
||||||
|
results.push(operands[0]);
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Toggles an item in the current list.
|
Toggles an item in the current list.
|
||||||
*/
|
*/
|
||||||
exports.toggle = function(source,operator) {
|
exports.toggle = function(source,operator) {
|
||||||
return cycleValueInArray(prepare_results(source),operator.operands);
|
return cycleValueInArray(prepare_results(source),operator.operands);
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.cycle = function(source,operator) {
|
exports.cycle = function(source,operator) {
|
||||||
var results = prepare_results(source),
|
const results = prepare_results(source),
|
||||||
operands = (operator.operand.length ? $tw.utils.parseStringArray(operator.operand, "true") : [""]),
|
operands = operator.operand.length ? $tw.utils.parseStringArray(operator.operand,"true") : [""];
|
||||||
step = $tw.utils.getInt(operator.operands[1]||"",1);
|
let step = $tw.utils.getInt(operator.operands[1] || "",1);
|
||||||
if(step < 0) {
|
|
||||||
operands.reverse();
|
if(step < 0) {
|
||||||
step = Math.abs(step);
|
operands.reverse();
|
||||||
}
|
step = Math.abs(step);
|
||||||
return cycleValueInArray(results,operands,step);
|
|
||||||
}
|
}
|
||||||
|
return cycleValueInArray(results,operands,step);
|
||||||
|
};
|
||||||
@@ -46,7 +46,7 @@ function BackSubIndexer(indexer,extractor) {
|
|||||||
BackSubIndexer.prototype.init = function() {
|
BackSubIndexer.prototype.init = function() {
|
||||||
// lazy init until first lookup
|
// lazy init until first lookup
|
||||||
this.index = null;
|
this.index = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
BackSubIndexer.prototype._init = function() {
|
BackSubIndexer.prototype._init = function() {
|
||||||
this.index = Object.create(null);
|
this.index = Object.create(null);
|
||||||
@@ -60,11 +60,11 @@ BackSubIndexer.prototype._init = function() {
|
|||||||
self.index[target][sourceTitle] = true;
|
self.index[target][sourceTitle] = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
BackSubIndexer.prototype.rebuild = function() {
|
BackSubIndexer.prototype.rebuild = function() {
|
||||||
this.index = null;
|
this.index = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get things that is being referenced in the text, e.g. tiddler names in the link syntax.
|
* Get things that is being referenced in the text, e.g. tiddler names in the link syntax.
|
||||||
@@ -78,7 +78,7 @@ BackSubIndexer.prototype._getTarget = function(tiddler) {
|
|||||||
return this.wiki[this.extractor](parser.tree, tiddler.fields.title);
|
return this.wiki[this.extractor](parser.tree, tiddler.fields.title);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
};
|
||||||
|
|
||||||
BackSubIndexer.prototype.update = function(updateDescriptor) {
|
BackSubIndexer.prototype.update = function(updateDescriptor) {
|
||||||
// lazy init/update until first lookup
|
// lazy init/update until first lookup
|
||||||
@@ -86,12 +86,13 @@ BackSubIndexer.prototype.update = function(updateDescriptor) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newTargets = [],
|
var newTargets = [],
|
||||||
oldTargets = [],
|
oldTargets = [],
|
||||||
self = this;
|
self = this;
|
||||||
if(updateDescriptor.old.exists) {
|
// System tiddlers are never indexed as sources, matching the _init() scan
|
||||||
|
if(updateDescriptor.old.exists && !this.wiki.isSystemTiddler(updateDescriptor.old.tiddler.fields.title)) {
|
||||||
oldTargets = this._getTarget(updateDescriptor.old.tiddler);
|
oldTargets = this._getTarget(updateDescriptor.old.tiddler);
|
||||||
}
|
}
|
||||||
if(updateDescriptor.new.exists) {
|
if(updateDescriptor.new.exists && !this.wiki.isSystemTiddler(updateDescriptor.new.tiddler.fields.title)) {
|
||||||
newTargets = this._getTarget(updateDescriptor.new.tiddler);
|
newTargets = this._getTarget(updateDescriptor.new.tiddler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ BackSubIndexer.prototype.update = function(updateDescriptor) {
|
|||||||
}
|
}
|
||||||
self.index[target][updateDescriptor.new.tiddler.fields.title] = true;
|
self.index[target][updateDescriptor.new.tiddler.fields.title] = true;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
BackSubIndexer.prototype.lookup = function(title) {
|
BackSubIndexer.prototype.lookup = function(title) {
|
||||||
if(!this.index) {
|
if(!this.index) {
|
||||||
@@ -117,6 +118,6 @@ BackSubIndexer.prototype.lookup = function(title) {
|
|||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.BackIndexer = BackIndexer;
|
exports.BackIndexer = BackIndexer;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ FieldIndexer.prototype.init = function() {
|
|||||||
this.index = null;
|
this.index = null;
|
||||||
this.maxIndexedValueLength = DEFAULT_MAXIMUM_INDEXED_VALUE_LENGTH;
|
this.maxIndexedValueLength = DEFAULT_MAXIMUM_INDEXED_VALUE_LENGTH;
|
||||||
this.addIndexMethods();
|
this.addIndexMethods();
|
||||||
}
|
};
|
||||||
|
|
||||||
// Provided for testing
|
// Provided for testing
|
||||||
FieldIndexer.prototype.setMaxIndexedValueLength = function(length) {
|
FieldIndexer.prototype.setMaxIndexedValueLength = function(length) {
|
||||||
@@ -33,14 +33,14 @@ FieldIndexer.prototype.addIndexMethods = function() {
|
|||||||
this.wiki.each.byField = function(name,value) {
|
this.wiki.each.byField = function(name,value) {
|
||||||
var lookup = self.lookup(name,value);
|
var lookup = self.lookup(name,value);
|
||||||
return lookup && lookup.filter(function(title) {
|
return lookup && lookup.filter(function(title) {
|
||||||
return self.wiki.tiddlerExists(title)
|
return self.wiki.tiddlerExists(title);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// get shadow tiddlers, including shadow tiddlers that is overwritten
|
// get shadow tiddlers, including shadow tiddlers that is overwritten
|
||||||
this.wiki.eachShadow.byField = function(name,value) {
|
this.wiki.eachShadow.byField = function(name,value) {
|
||||||
var lookup = self.lookup(name,value);
|
var lookup = self.lookup(name,value);
|
||||||
return lookup && lookup.filter(function(title) {
|
return lookup && lookup.filter(function(title) {
|
||||||
return self.wiki.isShadowTiddler(title)
|
return self.wiki.isShadowTiddler(title);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
this.wiki.eachTiddlerPlusShadows.byField = function(name,value) {
|
this.wiki.eachTiddlerPlusShadows.byField = function(name,value) {
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) {
|
|||||||
this.updateCallback = updateCallback;
|
this.updateCallback = updateCallback;
|
||||||
this.resizeHandlers = new Map();
|
this.resizeHandlers = new Map();
|
||||||
this.dimensionsInfo = [
|
this.dimensionsInfo = [
|
||||||
["outer/width", win => win.outerWidth],
|
["outer/width", (win) => win.outerWidth],
|
||||||
["outer/height", win => win.outerHeight],
|
["outer/height", (win) => win.outerHeight],
|
||||||
["inner/width", win => win.innerWidth],
|
["inner/width", (win) => win.innerWidth],
|
||||||
["inner/height", win => win.innerHeight],
|
["inner/height", (win) => win.innerHeight],
|
||||||
["client/width", win => win.document.documentElement.clientWidth],
|
["client/width", (win) => win.document.documentElement.clientWidth],
|
||||||
["client/height", win => win.document.documentElement.clientHeight]
|
["client/height", (win) => win.document.documentElement.clientHeight]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-16
@@ -140,7 +140,7 @@ function KeyboardManager(options) {
|
|||||||
this.shortcutParsedList = []; // Stores the parsed key descriptors
|
this.shortcutParsedList = []; // Stores the parsed key descriptors
|
||||||
this.shortcutPriorityList = []; // Stores the parsed shortcut priority
|
this.shortcutPriorityList = []; // Stores the parsed shortcut priority
|
||||||
this.lookupNames = ["shortcuts"];
|
this.lookupNames = ["shortcuts"];
|
||||||
this.lookupNames.push($tw.platform.isMac ? "shortcuts-mac" : "shortcuts-not-mac")
|
this.lookupNames.push($tw.platform.isMac ? "shortcuts-mac" : "shortcuts-not-mac");
|
||||||
this.lookupNames.push($tw.platform.isWindows ? "shortcuts-windows" : "shortcuts-not-windows");
|
this.lookupNames.push($tw.platform.isWindows ? "shortcuts-windows" : "shortcuts-not-windows");
|
||||||
this.lookupNames.push($tw.platform.isLinux ? "shortcuts-linux" : "shortcuts-not-linux");
|
this.lookupNames.push($tw.platform.isLinux ? "shortcuts-linux" : "shortcuts-not-linux");
|
||||||
this.updateShortcutLists(this.getShortcutTiddlerList());
|
this.updateShortcutLists(this.getShortcutTiddlerList());
|
||||||
@@ -161,7 +161,7 @@ KeyboardManager.prototype.getModifierKeys = function() {
|
|||||||
91, // Meta (left)
|
91, // Meta (left)
|
||||||
93, // Meta (right)
|
93, // Meta (right)
|
||||||
224 // Meta (Firefox)
|
224 // Meta (Firefox)
|
||||||
]
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -187,8 +187,7 @@ KeyboardManager.prototype.parseKeyDescriptor = function(keyDescriptor,options) {
|
|||||||
metaKey: false
|
metaKey: false
|
||||||
};
|
};
|
||||||
for(var t=0; t<components.length; t++) {
|
for(var t=0; t<components.length; t++) {
|
||||||
var s = components[t].toLowerCase(),
|
var s = components[t].toLowerCase();
|
||||||
c = s.charCodeAt(0);
|
|
||||||
// Look for modifier keys
|
// Look for modifier keys
|
||||||
if(s === "ctrl") {
|
if(s === "ctrl") {
|
||||||
info.ctrlKey = true;
|
info.ctrlKey = true;
|
||||||
@@ -266,7 +265,7 @@ KeyboardManager.prototype.getPrintableShortcuts = function(keyInfoArray) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.checkKeyDescriptor = function(event,keyInfo) {
|
KeyboardManager.prototype.checkKeyDescriptor = function(event,keyInfo) {
|
||||||
return keyInfo &&
|
return keyInfo &&
|
||||||
@@ -293,15 +292,15 @@ KeyboardManager.prototype.getMatchingKeyDescriptor = function(event,keyInfoArray
|
|||||||
KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) {
|
KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) {
|
||||||
return event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey ? "ctrl" :
|
return event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey ? "ctrl" :
|
||||||
event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ? "shift" :
|
event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ? "shift" :
|
||||||
event.ctrlKey && event.shiftKey && !event.altKey && !event.metaKey ? "ctrl-shift" :
|
event.ctrlKey && event.shiftKey && !event.altKey && !event.metaKey ? "ctrl-shift" :
|
||||||
event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey ? "alt" :
|
event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey ? "alt" :
|
||||||
event.altKey && event.shiftKey && !event.ctrlKey && !event.metaKey ? "alt-shift" :
|
event.altKey && event.shiftKey && !event.ctrlKey && !event.metaKey ? "alt-shift" :
|
||||||
event.altKey && event.ctrlKey && !event.shiftKey && !event.metaKey ? "ctrl-alt" :
|
event.altKey && event.ctrlKey && !event.shiftKey && !event.metaKey ? "ctrl-alt" :
|
||||||
event.altKey && event.shiftKey && event.ctrlKey && !event.metaKey ? "ctrl-alt-shift" :
|
event.altKey && event.shiftKey && event.ctrlKey && !event.metaKey ? "ctrl-alt-shift" :
|
||||||
event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey ? "meta" :
|
event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey ? "meta" :
|
||||||
event.metaKey && event.ctrlKey && !event.shiftKey && !event.altKey ? "meta-ctrl" :
|
event.metaKey && event.ctrlKey && !event.shiftKey && !event.altKey ? "meta-ctrl" :
|
||||||
event.metaKey && event.ctrlKey && event.shiftKey && !event.altKey ? "meta-ctrl-shift" :
|
event.metaKey && event.ctrlKey && event.shiftKey && !event.altKey ? "meta-ctrl-shift" :
|
||||||
event.metaKey && event.ctrlKey && event.shiftKey && event.altKey ? "meta-ctrl-alt-shift" : "normal";
|
event.metaKey && event.ctrlKey && event.shiftKey && event.altKey ? "meta-ctrl-alt-shift" : "normal";
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.getShortcutTiddlerList = function() {
|
KeyboardManager.prototype.getShortcutTiddlerList = function() {
|
||||||
@@ -371,8 +370,8 @@ KeyboardManager.prototype.handleShortcutChanges = function(changedTiddlers) {
|
|||||||
var newList = this.getShortcutTiddlerList();
|
var newList = this.getShortcutTiddlerList();
|
||||||
var hasChanged = $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers) ? true :
|
var hasChanged = $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers) ? true :
|
||||||
($tw.utils.hopArray(changedTiddlers,newList) ? true :
|
($tw.utils.hopArray(changedTiddlers,newList) ? true :
|
||||||
(this.detectNewShortcuts(changedTiddlers))
|
(this.detectNewShortcuts(changedTiddlers))
|
||||||
);
|
);
|
||||||
// Re-cache shortcuts if something changed
|
// Re-cache shortcuts if something changed
|
||||||
if(hasChanged) {
|
if(hasChanged) {
|
||||||
this.updateShortcutLists(newList);
|
this.updateShortcutLists(newList);
|
||||||
|
|||||||
@@ -26,25 +26,26 @@ exports.params = [
|
|||||||
Run the macro
|
Run the macro
|
||||||
*/
|
*/
|
||||||
exports.run = function(target,fallbackTarget,colourA,colourB) {
|
exports.run = function(target,fallbackTarget,colourA,colourB) {
|
||||||
var rgbTarget = $tw.utils.parseCSSColor(target) || $tw.utils.parseCSSColor(fallbackTarget);
|
var rgbTarget = $tw.utils.parseCSSColorObject(target) || $tw.utils.parseCSSColorObject(fallbackTarget);
|
||||||
if(!rgbTarget) {
|
if(!rgbTarget) {
|
||||||
return colourA;
|
return colourA;
|
||||||
}
|
}
|
||||||
var rgbColourA = $tw.utils.parseCSSColor(colourA),
|
var rgbColourA = $tw.utils.parseCSSColorObject(colourA),
|
||||||
rgbColourB = $tw.utils.parseCSSColor(colourB);
|
rgbColourB = $tw.utils.parseCSSColorObject(colourB);
|
||||||
if(rgbColourA && !rgbColourB) {
|
if(rgbColourA && !rgbColourB) {
|
||||||
return rgbColourA;
|
return colourA;
|
||||||
}
|
}
|
||||||
if(rgbColourB && !rgbColourA) {
|
if(rgbColourB && !rgbColourA) {
|
||||||
return rgbColourB;
|
return colourB;
|
||||||
}
|
}
|
||||||
if(!rgbColourA && !rgbColourB) {
|
if(!rgbColourA && !rgbColourB) {
|
||||||
// If neither colour is readable, return a crude inverse of the target
|
// If neither colour is readable, return a crude inverse of the target
|
||||||
return [255 - rgbTarget[0],255 - rgbTarget[1],255 - rgbTarget[2],rgbTarget[3]];
|
rgbTarget.srgb.r = 1 - rgbTarget.srgb.r;
|
||||||
|
rgbTarget.srgb.g = 1 - rgbTarget.srgb.g;
|
||||||
|
rgbTarget.srgb.b = 1 - rgbTarget.srgb.b;
|
||||||
|
return rgbTarget.display();
|
||||||
}
|
}
|
||||||
// Colour brightness formula derived from http://www.w3.org/WAI/ER/WD-AERT/#color-contrast
|
var aContrast = rgbColourA.contrast(rgbTarget,"DeltaPhi"),
|
||||||
var brightnessTarget = rgbTarget[0] * 0.299 + rgbTarget[1] * 0.587 + rgbTarget[2] * 0.114,
|
bContrast = rgbColourB.contrast(rgbTarget,"DeltaPhi");
|
||||||
brightnessA = rgbColourA[0] * 0.299 + rgbColourA[1] * 0.587 + rgbColourA[2] * 0.114,
|
return aContrast > bContrast ? colourA : colourB;
|
||||||
brightnessB = rgbColourB[0] * 0.299 + rgbColourB[1] * 0.587 + rgbColourB[2] * 0.114;
|
|
||||||
return Math.abs(brightnessTarget - brightnessA) > Math.abs(brightnessTarget - brightnessB) ? colourA : colourB;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ exports.params = [
|
|||||||
Run the macro
|
Run the macro
|
||||||
*/
|
*/
|
||||||
exports.run = function(filter,format) {
|
exports.run = function(filter,format) {
|
||||||
var self = this,
|
var tiddlers = this.wiki.filterTiddlers(filter),
|
||||||
tiddlers = this.wiki.filterTiddlers(filter),
|
|
||||||
tiddler,
|
tiddler,
|
||||||
fields = [],
|
fields = [],
|
||||||
t,f;
|
t,f;
|
||||||
@@ -46,24 +45,24 @@ exports.run = function(filter,format) {
|
|||||||
var p = fields.indexOf(value);
|
var p = fields.indexOf(value);
|
||||||
if(p !== -1) {
|
if(p !== -1) {
|
||||||
fields.splice(p,1);
|
fields.splice(p,1);
|
||||||
fields.unshift(value)
|
fields.unshift(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Output the column headings
|
// Output the column headings
|
||||||
var output = [], row = [];
|
var output = [], row = [];
|
||||||
fields.forEach(function(value) {
|
fields.forEach(function(value) {
|
||||||
row.push(quoteAndEscape(value))
|
row.push(quoteAndEscape(value));
|
||||||
});
|
});
|
||||||
output.push(row.join(","));
|
output.push(row.join(","));
|
||||||
// Output each tiddler
|
// Output each tiddler
|
||||||
for(var t=0;t<tiddlers.length; t++) {
|
for(var t=0;t<tiddlers.length; t++) {
|
||||||
row = [];
|
row = [];
|
||||||
tiddler = this.wiki.getTiddler(tiddlers[t]);
|
tiddler = this.wiki.getTiddler(tiddlers[t]);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
for(f=0; f<fields.length; f++) {
|
for(f=0; f<fields.length; f++) {
|
||||||
row.push(quoteAndEscape(tiddler ? tiddler.getFieldString(fields[f]) || "" : ""));
|
row.push(quoteAndEscape(tiddler ? tiddler.getFieldString(fields[f]) || "" : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output.push(row.join(","));
|
output.push(row.join(","));
|
||||||
}
|
}
|
||||||
return output.join("\n");
|
return output.join("\n");
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ exports.run = function(shortcuts,prefix,separator,suffix) {
|
|||||||
}));
|
}));
|
||||||
if(shortcutArray.length > 0) {
|
if(shortcutArray.length > 0) {
|
||||||
shortcutArray.sort(function(a,b) {
|
shortcutArray.sort(function(a,b) {
|
||||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||||
})
|
});
|
||||||
return prefix + shortcutArray.join(separator) + suffix;
|
return prefix + shortcutArray.join(separator) + suffix;
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -7,19 +7,17 @@ The audio parser parses an audio tiddler into an embeddable HTML element
|
|||||||
|
|
||||||
\*/
|
\*/
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var AudioParser = function(type,text,options) {
|
var AudioParser = function(type,text,options) {
|
||||||
var element = {
|
var element = {
|
||||||
type: "element",
|
type: "element",
|
||||||
tag: "$audio", // Using $audio to enable widget interception
|
tag: "$audio", // Using $audio to enable widget interception
|
||||||
attributes: {
|
attributes: {
|
||||||
controls: {type: "string", value: "controls"},
|
controls: {type: "string", value: "controls"},
|
||||||
style: {type: "string", value: "width: 100%; object-fit: contain"}
|
style: {type: "string", value: "width: 100%; object-fit: contain"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Pass through source information
|
// Pass through source information
|
||||||
if(options._canonical_uri) {
|
if(options._canonical_uri) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ var BinaryParser = function(type,text,options) {
|
|||||||
class: {type: "string", value: "tc-binary-warning"}
|
class: {type: "string", value: "tc-binary-warning"}
|
||||||
},
|
},
|
||||||
children: [warn, link]
|
children: [warn, link]
|
||||||
}
|
};
|
||||||
this.tree = [element];
|
this.tree = [element];
|
||||||
this.source = text;
|
this.source = text;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ var CsvParser = function(type,text,options) {
|
|||||||
row.children.push({
|
row.children.push({
|
||||||
"type": "element", "tag": tag, "children": [{
|
"type": "element", "tag": tag, "children": [{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": columns[column] || ''
|
"text": columns[column] || ""
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+162
-125
@@ -45,7 +45,7 @@ exports.parseWhiteSpace = function(source,pos) {
|
|||||||
type: "whitespace",
|
type: "whitespace",
|
||||||
start: pos,
|
start: pos,
|
||||||
end: p
|
end: p
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ exports.parseStringLiteral = function(source,pos) {
|
|||||||
type: "string",
|
type: "string",
|
||||||
start: pos
|
start: pos
|
||||||
};
|
};
|
||||||
var reString = /(?:"""([\s\S]*?)"""|"([^"]*)")|(?:'([^']*)')|\[\[((?:[^\]]|\](?!\]))*)\]\]/g;
|
var reString = /(?:"""([\s\S]*?)"""|"([^"]*)")|(?:'([^']*)')|\[\[((?:[^\]]|\](?!\]))*)\]\]/y;
|
||||||
reString.lastIndex = pos;
|
reString.lastIndex = pos;
|
||||||
var match = reString.exec(source);
|
var match = reString.exec(source);
|
||||||
if(match && match.index === pos) {
|
if(match && match.index === pos) {
|
||||||
@@ -170,7 +170,7 @@ exports.parseMacroParameters = function(node,source,pos) {
|
|||||||
}
|
}
|
||||||
node.end = pos;
|
node.end = pos;
|
||||||
return node;
|
return node;
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Look for a macro invocation parameter. Returns null if not found, or {type: "macro-parameter", name:, value:, start:, end:}
|
Look for a macro invocation parameter. Returns null if not found, or {type: "macro-parameter", name:, value:, start:, end:}
|
||||||
@@ -192,16 +192,16 @@ exports.parseMacroParameter = function(source,pos) {
|
|||||||
pos = token.end;
|
pos = token.end;
|
||||||
// Get the parameter details
|
// Get the parameter details
|
||||||
node.value = token.match[2] !== undefined ? token.match[2] : (
|
node.value = token.match[2] !== undefined ? token.match[2] : (
|
||||||
token.match[3] !== undefined ? token.match[3] : (
|
token.match[3] !== undefined ? token.match[3] : (
|
||||||
token.match[4] !== undefined ? token.match[4] : (
|
token.match[4] !== undefined ? token.match[4] : (
|
||||||
token.match[5] !== undefined ? token.match[5] : (
|
token.match[5] !== undefined ? token.match[5] : (
|
||||||
token.match[6] !== undefined ? token.match[6] : (
|
token.match[6] !== undefined ? token.match[6] : (
|
||||||
""
|
""
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
if(token.match[1]) {
|
if(token.match[1]) {
|
||||||
node.name = token.match[1];
|
node.name = token.match[1];
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ exports.parseMacroInvocationAsTransclusion = function(source,pos) {
|
|||||||
orderedAttributes: []
|
orderedAttributes: []
|
||||||
};
|
};
|
||||||
// Define our regexps
|
// Define our regexps
|
||||||
var reVarName = /([^\s>"'=:]+)/g;
|
var reVarName = /([^\s>"'=:]+)/y;
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||||
// Look for a double opening angle bracket
|
// Look for a double opening angle bracket
|
||||||
@@ -237,9 +237,11 @@ exports.parseMacroInvocationAsTransclusion = function(source,pos) {
|
|||||||
}
|
}
|
||||||
$tw.utils.addAttributeToParseTreeNode(node,"$variable",token.match[1]);
|
$tw.utils.addAttributeToParseTreeNode(node,"$variable",token.match[1]);
|
||||||
pos = token.end;
|
pos = token.end;
|
||||||
// Check that the tag is terminated by a space or >>
|
// Check that the tag is terminated by a space or >>, and that there is a closing >> somewhere ahead
|
||||||
if(!$tw.utils.parseWhiteSpace(source,pos) && !(source.charAt(pos) === ">" && source.charAt(pos + 1) === ">") ) {
|
if(!(source.charAt(pos) === ">" && source.charAt(pos + 1) === ">") ) {
|
||||||
return null;
|
if(source.indexOf(">>",pos) === -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Process attributes
|
// Process attributes
|
||||||
pos = $tw.utils.parseMacroParametersAsAttributes(node,source,pos);
|
pos = $tw.utils.parseMacroParametersAsAttributes(node,source,pos);
|
||||||
@@ -267,7 +269,7 @@ exports.parseMVVReferenceAsTransclusion = function(source,pos) {
|
|||||||
orderedAttributes: []
|
orderedAttributes: []
|
||||||
};
|
};
|
||||||
// Define our regexps
|
// Define our regexps
|
||||||
var reVarName = /([^\s>"'=:)]+)/g;
|
var reVarName = /([^\s>"'=:)]+)/y;
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||||
// Look for a double opening parenthesis
|
// Look for a double opening parenthesis
|
||||||
@@ -323,18 +325,24 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
|
|||||||
start: pos
|
start: pos
|
||||||
};
|
};
|
||||||
// Define our regexps
|
// Define our regexps
|
||||||
var reAttributeName = /([^\/\s>"'`=:]+)/g,
|
var reAttributeName = /([^\/\s>"'`=:]+)/y,
|
||||||
reUnquotedAttribute = /((?:(?:>(?!>))|[^\s>"'])+)/g,
|
reStrictIdentifier = /^[A-Za-z0-9\-_]+$/,
|
||||||
reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/g,
|
reUnquotedAttribute = /(?!<<)((?:(?:>(?!>))|[^\s>"'])+)/y,
|
||||||
reIndirectValue = /\{\{([^\}]+)\}\}/g,
|
reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/y,
|
||||||
reSubstitutedValue = /(?:```([\s\S]*?)```|`([^`]|[\S\s]*?)`)/g;
|
reIndirectValue = /\{\{([^\}]+)\}\}/y,
|
||||||
|
reSubstitutedValue = /(?:```([\s\S]*?)```|`([^`]|[\S\s]*?)`)/y;
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||||
// Get the attribute name and the separator token
|
// Get the attribute name and the separator token
|
||||||
var nameToken = $tw.utils.parseTokenRegExp(source,pos,reAttributeName),
|
var nameToken = $tw.utils.parseTokenRegExp(source,pos,reAttributeName),
|
||||||
namePos = nameToken && $tw.utils.skipWhiteSpace(source,nameToken.end),
|
namePos = nameToken && $tw.utils.skipWhiteSpace(source,nameToken.end),
|
||||||
separatorToken = nameToken && $tw.utils.parseTokenRegExp(source,namePos,/=|:/g),
|
separatorToken = nameToken && $tw.utils.parseTokenRegExp(source,namePos,/=|:/y),
|
||||||
isNewStyleSeparator = false; // If there is no separator then we don't allow new style values
|
isNewStyleSeparator = false; // If there is no separator then we don't allow new style values
|
||||||
|
// Colon separator requires a strict identifier name to avoid mis-parsing values like $:/foo
|
||||||
|
if(nameToken && separatorToken && separatorToken.match[0] === ":" && !reStrictIdentifier.test(nameToken.match[1])) {
|
||||||
|
nameToken = null;
|
||||||
|
separatorToken = null;
|
||||||
|
}
|
||||||
// If we have a name and a separator then we have a named attribute
|
// If we have a name and a separator then we have a named attribute
|
||||||
if(nameToken && separatorToken) {
|
if(nameToken && separatorToken) {
|
||||||
node.name = nameToken.match[1];
|
node.name = nameToken.match[1];
|
||||||
@@ -345,64 +353,78 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
|
|||||||
}
|
}
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||||
// Look for a string literal
|
|
||||||
var stringLiteral = $tw.utils.parseStringLiteral(source,pos);
|
do {
|
||||||
if(stringLiteral) {
|
// Look for a string literal
|
||||||
pos = stringLiteral.end;
|
var stringLiteral = $tw.utils.parseStringLiteral(source,pos);
|
||||||
node.type = "string";
|
if(stringLiteral) {
|
||||||
node.value = stringLiteral.value;
|
pos = stringLiteral.end;
|
||||||
// Mark the value as having been quoted in the source
|
node.type = "string";
|
||||||
node.quoted = true;
|
node.value = stringLiteral.value;
|
||||||
} else {
|
// Mark the value as having been quoted in the source
|
||||||
// Look for a filtered value
|
node.quoted = true;
|
||||||
var filteredValue = $tw.utils.parseTokenRegExp(source,pos,reFilteredValue);
|
break;
|
||||||
if(filteredValue && isNewStyleSeparator) {
|
}
|
||||||
pos = filteredValue.end;
|
|
||||||
node.type = "filtered";
|
if(isNewStyleSeparator) {
|
||||||
node.filter = filteredValue.match[1];
|
// Look for a filtered value
|
||||||
} else {
|
var filteredValue = $tw.utils.parseTokenRegExp(source,pos,reFilteredValue);
|
||||||
|
if(filteredValue) {
|
||||||
|
pos = filteredValue.end;
|
||||||
|
node.type = "filtered";
|
||||||
|
node.filter = filteredValue.match[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Look for an indirect value
|
// Look for an indirect value
|
||||||
var indirectValue = $tw.utils.parseTokenRegExp(source,pos,reIndirectValue);
|
var indirectValue = $tw.utils.parseTokenRegExp(source,pos,reIndirectValue);
|
||||||
if(indirectValue && isNewStyleSeparator) {
|
if(indirectValue) {
|
||||||
pos = indirectValue.end;
|
pos = indirectValue.end;
|
||||||
node.type = "indirect";
|
node.type = "indirect";
|
||||||
node.textReference = indirectValue.match[1];
|
node.textReference = indirectValue.match[1];
|
||||||
} else {
|
break;
|
||||||
// Look for a macro invocation value
|
}
|
||||||
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
|
|
||||||
if(macroInvocation && isNewStyleSeparator) {
|
// Look for a macro invocation value
|
||||||
pos = macroInvocation.end;
|
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
|
||||||
node.type = "macro";
|
if(macroInvocation) {
|
||||||
node.value = macroInvocation;
|
pos = macroInvocation.end;
|
||||||
} else {
|
node.type = "macro";
|
||||||
// Look for an MVV reference value
|
node.value = macroInvocation;
|
||||||
var mvvReference = $tw.utils.parseMVVReferenceAsTransclusion(source,pos);
|
break;
|
||||||
if(mvvReference && isNewStyleSeparator) {
|
}
|
||||||
pos = mvvReference.end;
|
|
||||||
node.type = "macro";
|
// Look for an MVV reference value
|
||||||
node.value = mvvReference;
|
var mvvReference = $tw.utils.parseMVVReferenceAsTransclusion(source,pos);
|
||||||
node.isMVV = true;
|
if(mvvReference) {
|
||||||
} else {
|
pos = mvvReference.end;
|
||||||
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
|
node.type = "macro";
|
||||||
if(substitutedValue && isNewStyleSeparator) {
|
node.value = mvvReference;
|
||||||
pos = substitutedValue.end;
|
node.isMVV = true;
|
||||||
node.type = "substituted";
|
break;
|
||||||
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
|
}
|
||||||
} else {
|
|
||||||
// Look for a unquoted value
|
// Look for a substituted value
|
||||||
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
|
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
|
||||||
if(unquotedValue) {
|
if(substitutedValue) {
|
||||||
pos = unquotedValue.end;
|
pos = substitutedValue.end;
|
||||||
node.type = "string";
|
node.type = "substituted";
|
||||||
node.value = unquotedValue.match[1];
|
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
|
||||||
} else {
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Look for a unquoted value
|
||||||
|
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
|
||||||
|
if(unquotedValue) {
|
||||||
|
pos = unquotedValue.end;
|
||||||
|
node.type = "string";
|
||||||
|
node.value = unquotedValue.match[1];
|
||||||
|
break; // redundant, but leaving for consistency
|
||||||
|
}
|
||||||
|
|
||||||
|
} while(false);
|
||||||
|
|
||||||
// Bail if we don't have a value
|
// Bail if we don't have a value
|
||||||
if(!node.type) {
|
if(!node.type) {
|
||||||
return null;
|
return null;
|
||||||
@@ -506,64 +528,79 @@ exports.parseAttribute = function(source,pos) {
|
|||||||
pos = token.end;
|
pos = token.end;
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||||
// Look for a string literal
|
do {
|
||||||
var stringLiteral = $tw.utils.parseStringLiteral(source,pos);
|
// Look for a string literal
|
||||||
if(stringLiteral) {
|
var stringLiteral = $tw.utils.parseStringLiteral(source,pos);
|
||||||
pos = stringLiteral.end;
|
if(stringLiteral) {
|
||||||
node.type = "string";
|
pos = stringLiteral.end;
|
||||||
node.value = stringLiteral.value;
|
node.type = "string";
|
||||||
} else {
|
node.value = stringLiteral.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Look for a filtered value
|
// Look for a filtered value
|
||||||
var filteredValue = $tw.utils.parseTokenRegExp(source,pos,reFilteredValue);
|
var filteredValue = $tw.utils.parseTokenRegExp(source,pos,reFilteredValue);
|
||||||
if(filteredValue) {
|
if(filteredValue) {
|
||||||
pos = filteredValue.end;
|
pos = filteredValue.end;
|
||||||
node.type = "filtered";
|
node.type = "filtered";
|
||||||
node.filter = filteredValue.match[1];
|
node.filter = filteredValue.match[1];
|
||||||
} else {
|
break;
|
||||||
// Look for an indirect value
|
|
||||||
var indirectValue = $tw.utils.parseTokenRegExp(source,pos,reIndirectValue);
|
|
||||||
if(indirectValue) {
|
|
||||||
pos = indirectValue.end;
|
|
||||||
node.type = "indirect";
|
|
||||||
node.textReference = indirectValue.match[1];
|
|
||||||
} else {
|
|
||||||
// Look for a macro invocation value
|
|
||||||
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
|
|
||||||
if(macroInvocation) {
|
|
||||||
pos = macroInvocation.end;
|
|
||||||
node.type = "macro";
|
|
||||||
node.value = macroInvocation;
|
|
||||||
} else {
|
|
||||||
// Look for an MVV reference value
|
|
||||||
var mvvReference = $tw.utils.parseMVVReferenceAsTransclusion(source,pos);
|
|
||||||
if(mvvReference) {
|
|
||||||
pos = mvvReference.end;
|
|
||||||
node.type = "macro";
|
|
||||||
node.value = mvvReference;
|
|
||||||
node.isMVV = true;
|
|
||||||
} else {
|
|
||||||
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
|
|
||||||
if(substitutedValue) {
|
|
||||||
pos = substitutedValue.end;
|
|
||||||
node.type = "substituted";
|
|
||||||
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
|
|
||||||
} else {
|
|
||||||
// Look for a unquoted value
|
|
||||||
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
|
|
||||||
if(unquotedValue) {
|
|
||||||
pos = unquotedValue.end;
|
|
||||||
node.type = "string";
|
|
||||||
node.value = unquotedValue.match[1];
|
|
||||||
} else {
|
|
||||||
node.type = "string";
|
|
||||||
node.value = "true";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Look for an indirect value
|
||||||
|
var indirectValue = $tw.utils.parseTokenRegExp(source,pos,reIndirectValue);
|
||||||
|
if(indirectValue) {
|
||||||
|
pos = indirectValue.end;
|
||||||
|
node.type = "indirect";
|
||||||
|
node.textReference = indirectValue.match[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for a macro invocation value
|
||||||
|
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
|
||||||
|
if(macroInvocation) {
|
||||||
|
pos = macroInvocation.end;
|
||||||
|
node.type = "macro";
|
||||||
|
node.value = macroInvocation;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for an MVV reference value
|
||||||
|
var mvvReference = $tw.utils.parseMVVReferenceAsTransclusion(source,pos);
|
||||||
|
if(mvvReference) {
|
||||||
|
pos = mvvReference.end;
|
||||||
|
node.type = "macro";
|
||||||
|
node.value = mvvReference;
|
||||||
|
node.isMVV = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for a substituted value
|
||||||
|
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
|
||||||
|
if(substitutedValue) {
|
||||||
|
pos = substitutedValue.end;
|
||||||
|
node.type = "substituted";
|
||||||
|
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for a unquoted value
|
||||||
|
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
|
||||||
|
if(unquotedValue) {
|
||||||
|
pos = unquotedValue.end;
|
||||||
|
node.type = "string";
|
||||||
|
node.value = unquotedValue.match[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.charAt(pos) === "<" && source.charAt(pos + 1) === "<" && source.indexOf(">>",pos) !== -1) {
|
||||||
|
// Value looks like a macro invocation (starts with << with a closing >> ahead) but does not parse as one. Return null so the enclosing tag fails to parse rather than silently binding the attribute to "true" and treating the remainder as further attributes (restores v5.3.8 behaviour)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
node.type = "string";
|
||||||
|
node.value = "true";
|
||||||
|
} while(false);
|
||||||
} else {
|
} else {
|
||||||
// If there is no equals sign or colon, then this is an attribute with no value, defaulting to "true"
|
// If there is no equals sign or colon, then this is an attribute with no value, defaulting to "true"
|
||||||
node.type = "string";
|
node.type = "string";
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ The PDF parser embeds a PDF viewer
|
|||||||
|
|
||||||
var ImageParser = function(type,text,options) {
|
var ImageParser = function(type,text,options) {
|
||||||
var element = {
|
var element = {
|
||||||
type: "element",
|
type: "element",
|
||||||
tag: "iframe",
|
tag: "iframe",
|
||||||
attributes: {}
|
attributes: {}
|
||||||
},
|
};
|
||||||
src;
|
|
||||||
if(options._canonical_uri) {
|
if(options._canonical_uri) {
|
||||||
element.attributes.src = {type: "string", value: options._canonical_uri};
|
element.attributes.src = {type: "string", value: options._canonical_uri};
|
||||||
} else if(text) {
|
} else if(text) {
|
||||||
|
|||||||
@@ -11,14 +11,13 @@ The video parser parses a video tiddler into an embeddable HTML element
|
|||||||
|
|
||||||
var VideoParser = function(type,text,options) {
|
var VideoParser = function(type,text,options) {
|
||||||
var element = {
|
var element = {
|
||||||
type: "element",
|
type: "element",
|
||||||
tag: "video",
|
tag: "video",
|
||||||
attributes: {
|
attributes: {
|
||||||
controls: {type: "string", value: "controls"},
|
controls: {type: "string", value: "controls"},
|
||||||
style: {type: "string", value: "width: 100%; object-fit: contain"}
|
style: {type: "string", value: "width: 100%; object-fit: contain"}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
src;
|
|
||||||
if(options._canonical_uri) {
|
if(options._canonical_uri) {
|
||||||
element.attributes.src = {type: "string", value: options._canonical_uri};
|
element.attributes.src = {type: "string", value: options._canonical_uri};
|
||||||
} else if(text) {
|
} else if(text) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ exports.init = function(parser) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.parse = function() {
|
exports.parse = function() {
|
||||||
var reEnd = /(\r?\n```$)/mg;
|
var reEnd = /(^|\r?\n)```$/mg;
|
||||||
var languageStart = this.parser.pos + 3,
|
var languageStart = this.parser.pos + 3,
|
||||||
languageEnd = languageStart + this.match[1].length;
|
languageEnd = languageStart + this.match[1].length;
|
||||||
// Move past the match
|
// Move past the match
|
||||||
@@ -46,10 +46,10 @@ exports.parse = function() {
|
|||||||
}
|
}
|
||||||
// Return the $codeblock widget
|
// Return the $codeblock widget
|
||||||
return [{
|
return [{
|
||||||
type: "codeblock",
|
type: "codeblock",
|
||||||
attributes: {
|
attributes: {
|
||||||
code: {type: "string", value: text, start: codeStart, end: this.parser.pos},
|
code: {type: "string", value: text, start: codeStart, end: this.parser.pos},
|
||||||
language: {type: "string", value: this.match[1], start: languageStart, end: languageEnd}
|
language: {type: "string", value: this.match[1], start: languageStart, end: languageEnd}
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,13 +31,16 @@ exports.parse = function() {
|
|||||||
reEnd.lastIndex = this.parser.pos;
|
reEnd.lastIndex = this.parser.pos;
|
||||||
var match = reEnd.exec(this.parser.source),
|
var match = reEnd.exec(this.parser.source),
|
||||||
text,
|
text,
|
||||||
start = this.parser.pos;
|
start = this.parser.pos,
|
||||||
|
textEnd;
|
||||||
// Process the text
|
// Process the text
|
||||||
if(match) {
|
if(match) {
|
||||||
text = this.parser.source.substring(this.parser.pos,match.index);
|
text = this.parser.source.substring(this.parser.pos,match.index);
|
||||||
|
textEnd = match.index;
|
||||||
this.parser.pos = match.index + match[0].length;
|
this.parser.pos = match.index + match[0].length;
|
||||||
} else {
|
} else {
|
||||||
text = this.parser.source.substr(this.parser.pos);
|
text = this.parser.source.substr(this.parser.pos);
|
||||||
|
textEnd = this.parser.sourceLength;
|
||||||
this.parser.pos = this.parser.sourceLength;
|
this.parser.pos = this.parser.sourceLength;
|
||||||
}
|
}
|
||||||
return [{
|
return [{
|
||||||
@@ -47,7 +50,7 @@ exports.parse = function() {
|
|||||||
type: "text",
|
type: "text",
|
||||||
text: text,
|
text: text,
|
||||||
start: start,
|
start: start,
|
||||||
end: this.parser.pos
|
end: textEnd
|
||||||
}]
|
}]
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ exports.parse = function() {
|
|||||||
var commentStart = this.match.index;
|
var commentStart = this.match.index;
|
||||||
var commentEnd = this.endMatch.index + this.endMatch[0].length;
|
var commentEnd = this.endMatch.index + this.endMatch[0].length;
|
||||||
return [{
|
return [{
|
||||||
type: "void",
|
type: "void",
|
||||||
children: [],
|
children: [],
|
||||||
text: this.parser.source.slice(commentStart, commentEnd),
|
text: this.parser.source.slice(commentStart, commentEnd),
|
||||||
start: commentStart,
|
start: commentStart,
|
||||||
end: commentEnd
|
end: commentEnd
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user