mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-01-24 03:44:41 +00:00
Compare commits
535 Commits
full-text-
...
publishing
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbdf9bae89 | ||
|
|
0924ca6365 | ||
|
|
39fec2decf | ||
|
|
dbfd45814d | ||
|
|
d455072f13 | ||
|
|
155525708b | ||
|
|
fdca11dec3 | ||
|
|
f83875331d | ||
|
|
be6deb054e | ||
|
|
b0604a9bf5 | ||
|
|
30925ee7bf | ||
|
|
7204f442cd | ||
|
|
23fec9e390 | ||
|
|
8d9dc0cd29 | ||
|
|
a1d9464011 | ||
|
|
0b71f25f74 | ||
|
|
315464372f | ||
|
|
56068d8215 | ||
|
|
1b55eb9eee | ||
|
|
3094e06236 | ||
|
|
f87b3bfcdb | ||
|
|
a0a0df9655 | ||
|
|
31c1584b9a | ||
|
|
f1f951e849 | ||
|
|
041c3e817c | ||
|
|
70e60cd93f | ||
|
|
a6990128f1 | ||
|
|
338b7c92a2 | ||
|
|
a409536ad0 | ||
|
|
c9af04d0e5 | ||
|
|
076a04fbfb | ||
|
|
83ee363cb4 | ||
|
|
63fa0c4fa4 | ||
|
|
644062fc21 | ||
|
|
021e9b8c4d | ||
|
|
afa653a7aa | ||
|
|
0b56d5fd37 | ||
|
|
2da7ae0b73 | ||
|
|
9c0d6a46cc | ||
|
|
06318b7617 | ||
|
|
8f9e8c1dee | ||
|
|
3cd80de5bb | ||
|
|
f2e26927c1 | ||
|
|
960160b3a2 | ||
|
|
4f33d2f35c | ||
|
|
b5db488438 | ||
|
|
6dd1887f0b | ||
|
|
219beb13cc | ||
|
|
c18b7527a7 | ||
|
|
2f1806ab6a | ||
|
|
afa4ea3d03 | ||
|
|
2b911ac11f | ||
|
|
056e6541a1 | ||
|
|
753bf8fe62 | ||
|
|
4f9dd50382 | ||
|
|
2e695801b1 | ||
|
|
f1d76a1eee | ||
|
|
55c522ab8f | ||
|
|
9faaa31299 | ||
|
|
582b156d5f | ||
|
|
652e8b1262 | ||
|
|
82ec63e711 | ||
|
|
51fd02d9b6 | ||
|
|
1a6d3e686b | ||
|
|
e694145eec | ||
|
|
3a740b23bb | ||
|
|
082aeb92ac | ||
|
|
903cfd98a6 | ||
|
|
eaf1da66b6 | ||
|
|
c6ed4aa84e | ||
|
|
123666c240 | ||
|
|
68930ceb1b | ||
|
|
fcea51bb95 | ||
|
|
8d7930f660 | ||
|
|
7a41283c6b | ||
|
|
c30ce544d1 | ||
|
|
dcba17fc5f | ||
|
|
2ab0474e14 | ||
|
|
61714cbda3 | ||
|
|
8fbf52e419 | ||
|
|
3fe5b77770 | ||
|
|
485779f5b2 | ||
|
|
3fc7895af2 | ||
|
|
bf25c4d34a | ||
|
|
10b20657cc | ||
|
|
0003d70132 | ||
|
|
81b5fe944a | ||
|
|
270ead4701 | ||
|
|
1ddc3ab037 | ||
|
|
160c154ef1 | ||
|
|
05d38054c8 | ||
|
|
c7f6cedc43 | ||
|
|
ec1df7edf0 | ||
|
|
dbd3f835bf | ||
|
|
fe12a4adbf | ||
|
|
b267a71f2d | ||
|
|
e7b3f69162 | ||
|
|
f4d7b2c7f7 | ||
|
|
e699cf1fe8 | ||
|
|
d8ac00a108 | ||
|
|
cf56a17f28 | ||
|
|
3f98686153 | ||
|
|
cb44cc0f2b | ||
|
|
44df6fe52f | ||
|
|
cb34c695b5 | ||
|
|
07caa16e87 | ||
|
|
30d23196b6 | ||
|
|
bf773eb39a | ||
|
|
4a99e0cc7d | ||
|
|
e2379b599e | ||
|
|
8203ee06c3 | ||
|
|
ac15334bb0 | ||
|
|
8849ed0d46 | ||
|
|
ca1cf7bb41 | ||
|
|
80133895ba | ||
|
|
5e236d35a5 | ||
|
|
85ba7ac041 | ||
|
|
a725da2b39 | ||
|
|
7878e77e96 | ||
|
|
c325380231 | ||
|
|
a6a2535c3a | ||
|
|
caec6bc3fe | ||
|
|
ac022ec79f | ||
|
|
89546b3357 | ||
|
|
184083ad1a | ||
|
|
9c62bd8030 | ||
|
|
55173c17a3 | ||
|
|
b7419dec3a | ||
|
|
02d390a673 | ||
|
|
c4cdb1ed8c | ||
|
|
5fcff1f1a3 | ||
|
|
7f3fed2f50 | ||
|
|
eced60853f | ||
|
|
b9647b2c48 | ||
|
|
a8770d7645 | ||
|
|
953fb9f237 | ||
|
|
df2a3fdefd | ||
|
|
b90aad9cea | ||
|
|
a8c248eb3d | ||
|
|
96103d5d4c | ||
|
|
a025bce21f | ||
|
|
45cdd7bdf7 | ||
|
|
e2d35751e2 | ||
|
|
fdf89f83c2 | ||
|
|
509356c696 | ||
|
|
dce425ecb8 | ||
|
|
55735d7552 | ||
|
|
a8fe653e3c | ||
|
|
013218b852 | ||
|
|
c976aad5e0 | ||
|
|
28521d82f3 | ||
|
|
54d3782167 | ||
|
|
ef6307a64e | ||
|
|
3b35411aba | ||
|
|
d6ea369f5e | ||
|
|
55e44a9554 | ||
|
|
860568136f | ||
|
|
85835ebe42 | ||
|
|
3d608892bd | ||
|
|
5be647b610 | ||
|
|
a2e7cc51b5 | ||
|
|
c3955c3cf9 | ||
|
|
226df2ad7d | ||
|
|
8d763f7682 | ||
|
|
f5887d9e25 | ||
|
|
7f202f35b4 | ||
|
|
42e10d030a | ||
|
|
9c31ff1fb1 | ||
|
|
0beac47243 | ||
|
|
99bef2614c | ||
|
|
a44a8c31f0 | ||
|
|
8aad7b00ab | ||
|
|
a38dc17300 | ||
|
|
9af68297cd | ||
|
|
80ee5adb14 | ||
|
|
743d9c56c0 | ||
|
|
427eb6d085 | ||
|
|
715ce6b603 | ||
|
|
a6958bfe85 | ||
|
|
7b1a0c6e6a | ||
|
|
e157d16b72 | ||
|
|
05acf3dce4 | ||
|
|
37fd52e6c9 | ||
|
|
85646e5db3 | ||
|
|
9eda02868f | ||
|
|
8980927b54 | ||
|
|
c69a3e827a | ||
|
|
3c9ee052a3 | ||
|
|
81546c5bf4 | ||
|
|
5e4430dbf9 | ||
|
|
93f4b5dac9 | ||
|
|
b58e4236b7 | ||
|
|
60e40b5af9 | ||
|
|
6e93770459 | ||
|
|
d56e8764a1 | ||
|
|
e84c87ef37 | ||
|
|
ef76349c37 | ||
|
|
010fa140c7 | ||
|
|
625ea364c4 | ||
|
|
5ad1193eb6 | ||
|
|
0ed32fded9 | ||
|
|
50d0b6ee50 | ||
|
|
c0dc2669c0 | ||
|
|
40d21f607a | ||
|
|
bfa062f23d | ||
|
|
9f9ce6595b | ||
|
|
12f1847475 | ||
|
|
f2aba29d94 | ||
|
|
6a55069609 | ||
|
|
3eefb3cce6 | ||
|
|
2b41661721 | ||
|
|
a360adbba9 | ||
|
|
4c7dcb83d1 | ||
|
|
010158db81 | ||
|
|
45355a7fcf | ||
|
|
f77015ea18 | ||
|
|
8bab081c9e | ||
|
|
4667139864 | ||
|
|
2e47f277ac | ||
|
|
ea12994f47 | ||
|
|
b4605e3573 | ||
|
|
674d55db06 | ||
|
|
678ec7b3dd | ||
|
|
53ebfffedf | ||
|
|
1ec532ea50 | ||
|
|
3c3f1b60c6 | ||
|
|
ae273a08f1 | ||
|
|
36de5f65ff | ||
|
|
7be1e7e5f8 | ||
|
|
b205da2007 | ||
|
|
ffc8feea0c | ||
|
|
ce8c03250c | ||
|
|
82b7167d55 | ||
|
|
afa490a0c1 | ||
|
|
8344d13efb | ||
|
|
17b4f53ba2 | ||
|
|
a8457f7f9e | ||
|
|
ca95f1069f | ||
|
|
65ffe96cc2 | ||
|
|
b8a9826f23 | ||
|
|
65932a9b21 | ||
|
|
af897361c7 | ||
|
|
4858b24cfe | ||
|
|
5125b91b3f | ||
|
|
b632cea6b7 | ||
|
|
eadbd62e6d | ||
|
|
e280f89ca5 | ||
|
|
87b9dbcda1 | ||
|
|
5832002feb | ||
|
|
6a98106679 | ||
|
|
d5175e4fdc | ||
|
|
58010e089f | ||
|
|
6edcbfd0cd | ||
|
|
be70e5851d | ||
|
|
6f62c4fc7f | ||
|
|
4fe411be80 | ||
|
|
ac40ee4246 | ||
|
|
bbe94f3544 | ||
|
|
03626bc142 | ||
|
|
69e595abf9 | ||
|
|
e96a54c753 | ||
|
|
a8639c3129 | ||
|
|
3ae27cab9e | ||
|
|
9434e95396 | ||
|
|
fecf622616 | ||
|
|
d25e540dd2 | ||
|
|
4ee3ded04a | ||
|
|
87704b1770 | ||
|
|
493b45706f | ||
|
|
0ea89970d1 | ||
|
|
c2c8892aa5 | ||
|
|
7ec6d37031 | ||
|
|
24646e1993 | ||
|
|
1e1b52088f | ||
|
|
ac8f521303 | ||
|
|
2ab5fd9abb | ||
|
|
f6339d437e | ||
|
|
8e61e37f2b | ||
|
|
2632ed0078 | ||
|
|
7cb6dc0e4f | ||
|
|
8620b77b45 | ||
|
|
03ad396db1 | ||
|
|
9e70e89a84 | ||
|
|
2f8a100bab | ||
|
|
a9a36b641a | ||
|
|
625c3de6f7 | ||
|
|
ddda9a34ae | ||
|
|
c0a56e790d | ||
|
|
dc83ee411d | ||
|
|
3c003364d2 | ||
|
|
1e9cc2b747 | ||
|
|
f968130696 | ||
|
|
e046d5ad76 | ||
|
|
3c3cd4673e | ||
|
|
d50f6b406e | ||
|
|
c1a1e272cc | ||
|
|
81947edd5c | ||
|
|
88e29b4558 | ||
|
|
8798ebadbd | ||
|
|
a17fa35c28 | ||
|
|
0911d99813 | ||
|
|
93309b0b7d | ||
|
|
c0dd13d446 | ||
|
|
ae61b08ae5 | ||
|
|
f60d0ef109 | ||
|
|
6ca89304a1 | ||
|
|
78c2beb640 | ||
|
|
e34a88e3e4 | ||
|
|
0d2b6cf837 | ||
|
|
1af1f6621a | ||
|
|
50d8325d4c | ||
|
|
3016b3d094 | ||
|
|
da5d12d6fb | ||
|
|
cd5d9bd5b9 | ||
|
|
1e1aeefd93 | ||
|
|
1d7091e637 | ||
|
|
4334de88a0 | ||
|
|
bb6d41f3dd | ||
|
|
a878d82c7a | ||
|
|
85ff47366c | ||
|
|
ce5d20b8fc | ||
|
|
2c76cfa67a | ||
|
|
90f05295a2 | ||
|
|
5df0225356 | ||
|
|
c3e34b469c | ||
|
|
e8815b79ff | ||
|
|
958f57f2c0 | ||
|
|
43a3228200 | ||
|
|
96d4f87e78 | ||
|
|
a8c1e6a3bd | ||
|
|
36fe519eff | ||
|
|
b2d270a7e8 | ||
|
|
005f7c55b6 | ||
|
|
122306fc24 | ||
|
|
0b1a05d10d | ||
|
|
b0f6d50b60 | ||
|
|
a3a7d6450d | ||
|
|
a857b4ab9a | ||
|
|
c4dcf510ef | ||
|
|
7fd24de372 | ||
|
|
396703c478 | ||
|
|
bfc4b447da | ||
|
|
d957b3e4e6 | ||
|
|
f798eab33f | ||
|
|
fbe5bb229a | ||
|
|
ae5d78b4dd | ||
|
|
9825b5b4a0 | ||
|
|
8799911162 | ||
|
|
813e28e1ea | ||
|
|
911e23ee6d | ||
|
|
046746ba20 | ||
|
|
8ffe138942 | ||
|
|
15be409c42 | ||
|
|
c92f9dd404 | ||
|
|
2bbcc94b4d | ||
|
|
1f5e1205ec | ||
|
|
6b03105bed | ||
|
|
9d5babc248 | ||
|
|
e620aaed80 | ||
|
|
552843369c | ||
|
|
f0eba7fdc6 | ||
|
|
9871c1a6a9 | ||
|
|
a1ef66ec6d | ||
|
|
fc797f3722 | ||
|
|
c6bb783308 | ||
|
|
c3055f92a9 | ||
|
|
4079f72310 | ||
|
|
cc1f32067f | ||
|
|
880930da8b | ||
|
|
68cb08749f | ||
|
|
13b69a9c10 | ||
|
|
b63049b4df | ||
|
|
6a91dbfe2f | ||
|
|
dde4182830 | ||
|
|
abe9af1369 | ||
|
|
6f09a5ee65 | ||
|
|
706fc3e06e | ||
|
|
6a319940d3 | ||
|
|
fe8606759e | ||
|
|
1de747b182 | ||
|
|
3406b98af6 | ||
|
|
80191903b6 | ||
|
|
367854c81b | ||
|
|
4f13848ca2 | ||
|
|
fd3e77d38f | ||
|
|
8fc6910c03 | ||
|
|
4623c45d29 | ||
|
|
5cbe4c5317 | ||
|
|
4d9e6831bb | ||
|
|
5887c6621e | ||
|
|
ce937595d7 | ||
|
|
cc850d7151 | ||
|
|
a21428a33a | ||
|
|
12bb938463 | ||
|
|
e54f3368e9 | ||
|
|
eb7f59a855 | ||
|
|
b3cbd7d733 | ||
|
|
28724138d1 | ||
|
|
62a2a0e579 | ||
|
|
98e60758a9 | ||
|
|
c655ec5469 | ||
|
|
7d2703bffb | ||
|
|
09d7a77f1b | ||
|
|
8005c91e79 | ||
|
|
86a9f922bf | ||
|
|
2175be27b0 | ||
|
|
9637a29e55 | ||
|
|
8320a55fef | ||
|
|
2267e31546 | ||
|
|
e3bf1f43cf | ||
|
|
64ac29adca | ||
|
|
94ffb50e04 | ||
|
|
3e3f185562 | ||
|
|
6c98bb706a | ||
|
|
4f88d79d8b | ||
|
|
0e247c991d | ||
|
|
ce27492b96 | ||
|
|
a9d583b85e | ||
|
|
5769cf9784 | ||
|
|
c854e518fa | ||
|
|
7327a3fb92 | ||
|
|
50a3c5526f | ||
|
|
77971ff720 | ||
|
|
e0f4d82214 | ||
|
|
af72fdf245 | ||
|
|
519962b4a9 | ||
|
|
c9a77c5877 | ||
|
|
3d93790573 | ||
|
|
cb62c8c96d | ||
|
|
aa6f152d35 | ||
|
|
72b32946aa | ||
|
|
60850ee69b | ||
|
|
8c4d67ba2b | ||
|
|
3c195b05cb | ||
|
|
530b4308e3 | ||
|
|
fa63ac5d1e | ||
|
|
51ca14861e | ||
|
|
d2f87d6200 | ||
|
|
a0f145197c | ||
|
|
c97003238b | ||
|
|
4f07539164 | ||
|
|
5945506169 | ||
|
|
483fd941f5 | ||
|
|
1339c23b3a | ||
|
|
89541edcff | ||
|
|
fd14e94610 | ||
|
|
f591a78f37 | ||
|
|
e2bea854b6 | ||
|
|
0d434583ec | ||
|
|
a81b7fc9f4 | ||
|
|
da66323dc5 | ||
|
|
0be778fc27 | ||
|
|
37f4421ed1 | ||
|
|
f61906501d | ||
|
|
1a8c6fdc4b | ||
|
|
6f8dca956b | ||
|
|
061b75741b | ||
|
|
d181b96518 | ||
|
|
527638d5e6 | ||
|
|
b95f9e6000 | ||
|
|
6d5ea90bfd | ||
|
|
eae3da0e9d | ||
|
|
684f13fbcb | ||
|
|
8cd13e2f89 | ||
|
|
3b75297168 | ||
|
|
2b60ab1fdc | ||
|
|
d6e055368d | ||
|
|
fc1721709a | ||
|
|
43061e64a6 | ||
|
|
d8d88c67e3 | ||
|
|
ffd6a8cce7 | ||
|
|
a637f7fb60 | ||
|
|
ca4cdc81dd | ||
|
|
13499557bf | ||
|
|
a2b2e117e3 | ||
|
|
d9b8a800c6 | ||
|
|
2aa6e761fd | ||
|
|
7078ca2c1e | ||
|
|
04bf6e0fd8 | ||
|
|
bb6fee4e1c | ||
|
|
f087a62c99 | ||
|
|
1b31c25ea7 | ||
|
|
02a956b1bb | ||
|
|
cc3462999b | ||
|
|
b63c90e401 | ||
|
|
497b334d60 | ||
|
|
fa373a1c6f | ||
|
|
1eac5c051f | ||
|
|
568990409a | ||
|
|
09f7ad84b2 | ||
|
|
445c15e719 | ||
|
|
27bed615ab | ||
|
|
1ec8b7877e | ||
|
|
59c6f4447e | ||
|
|
343207fc35 | ||
|
|
519ce3e89d | ||
|
|
71194d8767 | ||
|
|
480e4e2ce9 | ||
|
|
db48ce5f2c | ||
|
|
4d85d267a1 | ||
|
|
98f67373b1 | ||
|
|
e574cb4724 | ||
|
|
e72d90c227 | ||
|
|
c729115506 | ||
|
|
9854a4fc08 | ||
|
|
9fe4c4889a | ||
|
|
750f56a235 | ||
|
|
66636d1a86 | ||
|
|
2a7cdb22c0 | ||
|
|
b69b84b38e | ||
|
|
ee250bf6c9 | ||
|
|
de69ab0d0e | ||
|
|
cf58dcf116 | ||
|
|
53922d3558 | ||
|
|
c41e34793d | ||
|
|
5aa4e4cb68 | ||
|
|
2b31c7a509 | ||
|
|
0bd866e2f9 | ||
|
|
93e7380188 | ||
|
|
9003c81039 | ||
|
|
900a29fbb3 | ||
|
|
b3d0303139 | ||
|
|
feefc4cceb | ||
|
|
d51975b183 | ||
|
|
15e8772170 | ||
|
|
bc5143f190 | ||
|
|
458460354e | ||
|
|
78c72b85fb | ||
|
|
22e25c05eb | ||
|
|
4394b8e723 | ||
|
|
c0b021f509 | ||
|
|
4914208011 | ||
|
|
9eec6ff915 | ||
|
|
15338e60e8 | ||
|
|
7686be7b14 |
5
.github/ISSUE_TEMPLATE/bug_report.md
vendored
5
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -23,6 +23,11 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**TiddlyWiki Configuration (please complete the following information):**
|
||||
- Version [e.g. v5.1.24]
|
||||
- Saving mechanism [e.g. Node.js, TiddlyDesktop, TiddlyHost etc]
|
||||
- Plugins installed [e.g. Freelinks, TiddlyMap]
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# Default to the current version number for building the plugin library
|
||||
|
||||
if [ -z "$TW5_BUILD_VERSION" ]; then
|
||||
TW5_BUILD_VERSION=v5.1.23
|
||||
TW5_BUILD_VERSION=v5.2.0
|
||||
fi
|
||||
|
||||
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
|
||||
@@ -107,7 +107,7 @@ node $TW5_BUILD_TIDDLYWIKI \
|
||||
# /empty.html Empty
|
||||
# /empty.hta For Internet Explorer
|
||||
node $TW5_BUILD_TIDDLYWIKI \
|
||||
./editions/empty \
|
||||
$TW5_BUILD_MAIN_EDITION \
|
||||
--verbose \
|
||||
--output $TW5_BUILD_OUTPUT \
|
||||
--build empty \
|
||||
|
||||
@@ -5,52 +5,52 @@ Optimise the SVGs in ./core/images using SVGO from https://github.com/svg/svgo
|
||||
|
||||
Install SVGO with the following command in the root of the repo:
|
||||
|
||||
npm install svgo
|
||||
npm install svgo@2.3.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
SVGO = require("svgo"),
|
||||
svgo = new SVGO({
|
||||
{ optimize } = require("svgo"),
|
||||
config = {
|
||||
plugins: [
|
||||
{cleanupAttrs: true},
|
||||
{removeDoctype: true},
|
||||
{removeXMLProcInst: true},
|
||||
{removeComments: true},
|
||||
{removeMetadata: true},
|
||||
{removeTitle: true},
|
||||
{removeDesc: true},
|
||||
{removeUselessDefs: true},
|
||||
{removeEditorsNSData: true},
|
||||
{removeEmptyAttrs: true},
|
||||
{removeHiddenElems: true},
|
||||
{removeEmptyText: true},
|
||||
{removeEmptyContainers: true},
|
||||
{removeViewBox: false},
|
||||
{cleanupEnableBackground: true},
|
||||
{convertStyleToAttrs: true},
|
||||
{convertColors: true},
|
||||
{convertPathData: true},
|
||||
{convertTransform: true},
|
||||
{removeUnknownsAndDefaults: true},
|
||||
{removeNonInheritableGroupAttrs: true},
|
||||
{removeUselessStrokeAndFill: true},
|
||||
{removeUnusedNS: true},
|
||||
{cleanupIDs: true},
|
||||
{cleanupNumericValues: true},
|
||||
{moveElemsAttrsToGroup: true},
|
||||
{moveGroupAttrsToElems: true},
|
||||
{collapseGroups: true},
|
||||
{removeRasterImages: false},
|
||||
{mergePaths: true},
|
||||
{convertShapeToPath: true},
|
||||
{sortAttrs: true},
|
||||
{removeDimensions: false},
|
||||
{removeAttrs: {attrs: "(stroke|fill)"}}
|
||||
'cleanupAttrs',
|
||||
'removeDoctype',
|
||||
'removeXMLProcInst',
|
||||
'removeComments',
|
||||
'removeMetadata',
|
||||
'removeTitle',
|
||||
'removeDesc',
|
||||
'removeUselessDefs',
|
||||
'removeEditorsNSData',
|
||||
'removeEmptyAttrs',
|
||||
'removeHiddenElems',
|
||||
'removeEmptyText',
|
||||
'removeEmptyContainers',
|
||||
// 'removeViewBox',
|
||||
'cleanupEnableBackground',
|
||||
'convertStyleToAttrs',
|
||||
'convertColors',
|
||||
'convertPathData',
|
||||
'convertTransform',
|
||||
'removeUnknownsAndDefaults',
|
||||
'removeNonInheritableGroupAttrs',
|
||||
'removeUselessStrokeAndFill',
|
||||
'removeUnusedNS',
|
||||
'cleanupIDs',
|
||||
'cleanupNumericValues',
|
||||
'moveElemsAttrsToGroup',
|
||||
'moveGroupAttrsToElems',
|
||||
'collapseGroups',
|
||||
// 'removeRasterImages',
|
||||
'mergePaths',
|
||||
'convertShapeToPath',
|
||||
'sortAttrs',
|
||||
//'removeDimensions',
|
||||
{name: 'removeAttrs', params: { attrs: '(stroke|fill)' } }
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
var basepath = "./core/images/",
|
||||
files = fs.readdirSync(basepath).sort();
|
||||
@@ -66,12 +66,14 @@ files.forEach(function(filename) {
|
||||
fakeSVG = body.join("\n");
|
||||
// A hack to make the new-journal-button work
|
||||
fakeSVG = fakeSVG.replace("<<now \"DD\">>","<<now "DD">>");
|
||||
svgo.optimize(fakeSVG, {path: filepath}).then(function(result) {
|
||||
config.path = filepath;
|
||||
var result = optimize(fakeSVG,config);
|
||||
if(result) {
|
||||
var newSVG = header.join("\n") + "\n\n" + result.data.replace("<<now "DD">>","<<now \"DD\">>");
|
||||
fs.writeFileSync(filepath,newSVG);
|
||||
},function(err) {
|
||||
} else {
|
||||
console.log("Error " + err + " with " + filename)
|
||||
process.exit();
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
178
boot/boot.js
178
boot/boot.js
@@ -305,13 +305,21 @@ $tw.utils.stringifyDate = function(value) {
|
||||
// Parse a date from a UTC YYYYMMDDHHMMSSmmm format string
|
||||
$tw.utils.parseDate = function(value) {
|
||||
if(typeof value === "string") {
|
||||
return new Date(Date.UTC(parseInt(value.substr(0,4),10),
|
||||
var negative = 1;
|
||||
if(value.charAt(0) === "-") {
|
||||
negative = -1;
|
||||
value = value.substr(1);
|
||||
}
|
||||
var year = parseInt(value.substr(0,4),10) * negative,
|
||||
d = new Date(Date.UTC(year,
|
||||
parseInt(value.substr(4,2),10)-1,
|
||||
parseInt(value.substr(6,2),10),
|
||||
parseInt(value.substr(8,2)||"00",10),
|
||||
parseInt(value.substr(10,2)||"00",10),
|
||||
parseInt(value.substr(12,2)||"00",10),
|
||||
parseInt(value.substr(14,3)||"000",10)));
|
||||
d.setUTCFullYear(year); // See https://stackoverflow.com/a/5870822
|
||||
return d;
|
||||
} else if($tw.utils.isDate(value)) {
|
||||
return value;
|
||||
} else {
|
||||
@@ -749,7 +757,12 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
|
||||
tiddler = $tw.wiki.getTiddler(name),
|
||||
_exports = {},
|
||||
sandbox = {
|
||||
module: {exports: _exports},
|
||||
module: {
|
||||
exports: _exports,
|
||||
setStringHandler: function(handler) {
|
||||
moduleInfo.stringHandler = handler;
|
||||
}
|
||||
},
|
||||
//moduleInfo: moduleInfo,
|
||||
exports: _exports,
|
||||
console: console,
|
||||
@@ -813,7 +826,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
|
||||
moduleInfo.definition(moduleInfo,moduleInfo.exports,sandbox.require);
|
||||
} else if(typeof moduleInfo.definition === "string") { // String
|
||||
moduleInfo.exports = _exports;
|
||||
$tw.utils.evalSandboxed(moduleInfo.definition,sandbox,tiddler.fields.title);
|
||||
$tw.utils.evalSandboxed(moduleInfo.definition,sandbox,name);
|
||||
if(sandbox.module.exports) {
|
||||
moduleInfo.exports = sandbox.module.exports; //more codemirror workaround
|
||||
}
|
||||
@@ -884,6 +897,19 @@ $tw.modules.applyMethods = function(moduleType,targetObject) {
|
||||
return targetObject;
|
||||
};
|
||||
|
||||
/*
|
||||
Return a class created from a modules. The module should export the properties to be added to those of the optional base class
|
||||
*/
|
||||
$tw.modules.createClassFromModule = function(moduleExports,baseClass) {
|
||||
var newClass = function() {};
|
||||
if(baseClass) {
|
||||
newClass.prototype = new baseClass();
|
||||
newClass.prototype.constructor = baseClass;
|
||||
}
|
||||
$tw.utils.extend(newClass.prototype,moduleExports);
|
||||
return newClass;
|
||||
};
|
||||
|
||||
/*
|
||||
Return an array of classes created from the modules of a specified type. Each module should export the properties to be added to those of the optional base class
|
||||
*/
|
||||
@@ -891,18 +917,26 @@ $tw.modules.createClassesFromModules = function(moduleType,subType,baseClass) {
|
||||
var classes = Object.create(null);
|
||||
$tw.modules.forEachModuleOfType(moduleType,function(title,moduleExports) {
|
||||
if(!subType || moduleExports.types[subType]) {
|
||||
var newClass = function() {};
|
||||
if(baseClass) {
|
||||
newClass.prototype = new baseClass();
|
||||
newClass.prototype.constructor = baseClass;
|
||||
}
|
||||
$tw.utils.extend(newClass.prototype,moduleExports);
|
||||
classes[moduleExports.name] = newClass;
|
||||
classes[moduleExports.name] = $tw.modules.createClassFromModule(moduleExports,baseClass);
|
||||
}
|
||||
});
|
||||
return classes;
|
||||
};
|
||||
|
||||
/*
|
||||
Return a specified module string for a module, null if the module or string is missing
|
||||
*/
|
||||
$tw.modules.getModuleString = function(moduleName,stringName,language) {
|
||||
if(moduleName in $tw.modules.titles) {
|
||||
$tw.modules.execute(moduleName);
|
||||
var stringHandler = $tw.modules.titles[moduleName].stringHandler;
|
||||
if(stringHandler) {
|
||||
return stringHandler(stringName,language);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/////////////////////////// Barebones tiddler object
|
||||
|
||||
/*
|
||||
@@ -1139,7 +1173,7 @@ $tw.Wiki = function(options) {
|
||||
var index = tiddlerTitles.indexOf(title);
|
||||
if(index !== -1) {
|
||||
tiddlerTitles.splice(index,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Record the new tiddler state
|
||||
updateDescriptor["new"] = {
|
||||
@@ -1286,7 +1320,7 @@ $tw.Wiki = function(options) {
|
||||
}
|
||||
} else {
|
||||
if(pluginInfo[title]) {
|
||||
delete pluginInfo[title];
|
||||
delete pluginInfo[title];
|
||||
results.deletedPlugins.push(title);
|
||||
}
|
||||
}
|
||||
@@ -1709,13 +1743,20 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/dom","tiddlerdeserializer",{
|
||||
},
|
||||
t,result = [];
|
||||
if(node) {
|
||||
for(t = 0; t < node.childNodes.length; t++) {
|
||||
var type = (node.getAttribute && node.getAttribute("type")) || null;
|
||||
if(type) {
|
||||
// A new-style container with an explicit deserialization type
|
||||
result = $tw.wiki.deserializeTiddlers(type,node.textContent);
|
||||
} else {
|
||||
// An old-style container of classic DIV-based tiddlers
|
||||
for(t = 0; t < node.childNodes.length; t++) {
|
||||
var childNode = node.childNodes[t],
|
||||
tiddlers = extractTextTiddlers(childNode);
|
||||
tiddlers = tiddlers || extractModuleTiddlers(childNode);
|
||||
if(tiddlers) {
|
||||
result.push.apply(result,tiddlers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -1724,17 +1765,23 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/dom","tiddlerdeserializer",{
|
||||
|
||||
$tw.loadTiddlersBrowser = function() {
|
||||
// In the browser, we load tiddlers from certain elements
|
||||
var containerIds = [
|
||||
"libraryModules",
|
||||
"modules",
|
||||
"bootKernelPrefix",
|
||||
"bootKernel",
|
||||
"styleArea",
|
||||
"storeArea",
|
||||
"systemArea"
|
||||
var containerSelectors = [
|
||||
// IDs for old-style v5.1.x tiddler stores
|
||||
"#libraryModules",
|
||||
"#modules",
|
||||
"#bootKernelPrefix",
|
||||
"#bootKernel",
|
||||
"#styleArea",
|
||||
"#storeArea",
|
||||
"#systemArea",
|
||||
// Classes for new-style v5.2.x JSON tiddler stores
|
||||
"script.tiddlywiki-tiddler-store"
|
||||
];
|
||||
for(var t=0; t<containerIds.length; t++) {
|
||||
$tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",document.getElementById(containerIds[t])));
|
||||
for(var t=0; t<containerSelectors.length; t++) {
|
||||
var nodes = document.querySelectorAll(containerSelectors[t]);
|
||||
for(var n=0; n<nodes.length; n++) {
|
||||
$tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",nodes[n]));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1886,7 +1933,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
||||
});
|
||||
});
|
||||
if(isEditableFile) {
|
||||
tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, tiddlers: fileTiddlers});
|
||||
tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, isEditableFile: true, tiddlers: fileTiddlers});
|
||||
} else {
|
||||
tiddlers.push({tiddlers: fileTiddlers});
|
||||
}
|
||||
@@ -1912,15 +1959,21 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
||||
}
|
||||
} else {
|
||||
// Process directory specifier
|
||||
var dirPath = path.resolve(filepath,dirSpec.path),
|
||||
files = fs.readdirSync(dirPath),
|
||||
fileRegExp = new RegExp(dirSpec.filesRegExp || "^.*$"),
|
||||
metaRegExp = /^.*\.meta$/;
|
||||
for(var t=0; t<files.length; t++) {
|
||||
var filename = files[t];
|
||||
if(filename !== "tiddlywiki.files" && !metaRegExp.test(filename) && fileRegExp.test(filename)) {
|
||||
processFile(dirPath + path.sep + filename,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile);
|
||||
var dirPath = path.resolve(filepath,dirSpec.path);
|
||||
if(fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()) {
|
||||
var files = fs.readdirSync(dirPath),
|
||||
fileRegExp = new RegExp(dirSpec.filesRegExp || "^.*$"),
|
||||
metaRegExp = /^.*\.meta$/;
|
||||
for(var t=0; t<files.length; t++) {
|
||||
var filename = files[t];
|
||||
if(filename !== "tiddlywiki.files" && !metaRegExp.test(filename) && fileRegExp.test(filename)) {
|
||||
processFile(dirPath + path.sep + filename,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("Warning: a directory in a tiddlywiki.files file does not exist.");
|
||||
console.log("dirPath: " + dirPath);
|
||||
console.log("tiddlywiki.files location: " + filepath);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1964,7 +2017,7 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
|
||||
pluginInfo.dependents = pluginInfo.dependents || [];
|
||||
pluginInfo.type = "application/json";
|
||||
// Set plugin text
|
||||
pluginInfo.text = JSON.stringify({tiddlers: pluginInfo.tiddlers},null,4);
|
||||
pluginInfo.text = JSON.stringify({tiddlers: pluginInfo.tiddlers});
|
||||
delete pluginInfo.tiddlers;
|
||||
// Deserialise array fields (currently required for the dependents field)
|
||||
for(var field in pluginInfo) {
|
||||
@@ -2060,6 +2113,11 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
// Save the path to the tiddlers folder for the filesystemadaptor
|
||||
var config = wikiInfo.config || {};
|
||||
if($tw.boot.wikiPath == wikiPath) {
|
||||
$tw.boot.wikiTiddlersPath = path.resolve($tw.boot.wikiPath,config["default-tiddler-location"] || $tw.config.wikiTiddlersSubDir);
|
||||
}
|
||||
// Load any parent wikis
|
||||
if(wikiInfo.includeWikis) {
|
||||
parentPaths = parentPaths.slice(0);
|
||||
@@ -2093,27 +2151,31 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
|
||||
$tw.boot.files[tiddler.title] = {
|
||||
filepath: tiddlerFile.filepath,
|
||||
type: tiddlerFile.type,
|
||||
hasMetaFile: tiddlerFile.hasMetaFile
|
||||
hasMetaFile: tiddlerFile.hasMetaFile,
|
||||
isEditableFile: config["retain-original-tiddler-path"] || tiddlerFile.isEditableFile || tiddlerFile.filepath.indexOf($tw.boot.wikiTiddlersPath) !== 0
|
||||
};
|
||||
});
|
||||
}
|
||||
$tw.wiki.addTiddlers(tiddlerFile.tiddlers);
|
||||
});
|
||||
// Save the original tiddler file locations if requested
|
||||
var config = wikiInfo.config || {};
|
||||
if(config["retain-original-tiddler-path"]) {
|
||||
var output = {}, relativePath;
|
||||
if ($tw.boot.wikiPath == wikiPath) {
|
||||
// Save the original tiddler file locations if requested
|
||||
var output = {}, relativePath, fileInfo;
|
||||
for(var title in $tw.boot.files) {
|
||||
relativePath = path.relative(resolvedWikiPath,$tw.boot.files[title].filepath);
|
||||
output[title] =
|
||||
path.sep === "/" ?
|
||||
relativePath :
|
||||
relativePath.split(path.sep).join("/");
|
||||
fileInfo = $tw.boot.files[title];
|
||||
if(fileInfo.isEditableFile) {
|
||||
relativePath = path.relative($tw.boot.wikiTiddlersPath,fileInfo.filepath);
|
||||
fileInfo.originalpath = relativePath;
|
||||
output[title] =
|
||||
path.sep === "/" ?
|
||||
relativePath :
|
||||
relativePath.split(path.sep).join("/");
|
||||
}
|
||||
}
|
||||
if(Object.keys(output).length > 0){
|
||||
$tw.wiki.addTiddler({title: "$:/config/OriginalTiddlerPaths", type: "application/json", text: JSON.stringify(output)});
|
||||
}
|
||||
$tw.wiki.addTiddler({title: "$:/config/OriginalTiddlerPaths", type: "application/json", text: JSON.stringify(output)});
|
||||
}
|
||||
// Save the path to the tiddlers folder for the filesystemadaptor
|
||||
$tw.boot.wikiTiddlersPath = path.resolve($tw.boot.wikiPath,config["default-tiddler-location"] || $tw.config.wikiTiddlersSubDir);
|
||||
// Load any plugins within the wiki folder
|
||||
var wikiPluginsPath = path.resolve(wikiPath,$tw.config.wikiPluginsSubDir);
|
||||
if(fs.existsSync(wikiPluginsPath)) {
|
||||
@@ -2160,7 +2222,7 @@ $tw.loadTiddlersNode = function() {
|
||||
// Load any extra plugins
|
||||
$tw.utils.each($tw.boot.extraPlugins,function(name) {
|
||||
if(name.charAt(0) === "+") { // Relative path to plugin
|
||||
var pluginFields = $tw.loadPluginFolder(name.substring(1));;
|
||||
var pluginFields = $tw.loadPluginFolder(name.substring(1));
|
||||
if(pluginFields) {
|
||||
$tw.wiki.addTiddler(pluginFields);
|
||||
}
|
||||
@@ -2169,7 +2231,7 @@ $tw.loadTiddlersNode = function() {
|
||||
type = parts[0];
|
||||
if(parts.length === 3 && ["plugins","themes","languages"].indexOf(type) !== -1) {
|
||||
$tw.loadPlugins([parts[1] + "/" + parts[2]],$tw.config[type + "Path"],$tw.config[type + "EnvVar"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Load the tiddlers from the wiki directory
|
||||
@@ -2279,6 +2341,7 @@ $tw.boot.initStartup = function(options) {
|
||||
$tw.utils.registerFileType("image/heic","base64",".heic",{flags:["image"]});
|
||||
$tw.utils.registerFileType("image/heif","base64",".heif",{flags:["image"]});
|
||||
$tw.utils.registerFileType("image/svg+xml","utf8",".svg",{flags:["image"]});
|
||||
$tw.utils.registerFileType("image/vnd.microsoft.icon","base64",".ico",{flags:["image"]});
|
||||
$tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]});
|
||||
$tw.utils.registerFileType("application/font-woff","base64",".woff");
|
||||
$tw.utils.registerFileType("application/x-font-ttf","base64",".woff");
|
||||
@@ -2436,16 +2499,29 @@ $tw.boot.executeNextStartupTask = function(callback) {
|
||||
};
|
||||
|
||||
/*
|
||||
Returns true if we are running on one platforms specified in a task modules `platforms` array
|
||||
Returns true if we are running on one of the platforms specified in taskModule's
|
||||
`platforms` array; or if `platforms` property is not defined.
|
||||
*/
|
||||
$tw.boot.doesTaskMatchPlatform = function(taskModule) {
|
||||
var platforms = taskModule.platforms;
|
||||
if(platforms) {
|
||||
for(var t=0; t<platforms.length; t++) {
|
||||
if((platforms[t] === "browser" && !$tw.browser) || (platforms[t] === "node" && !$tw.node)) {
|
||||
return false;
|
||||
switch (platforms[t]) {
|
||||
case "browser":
|
||||
if ($tw.browser) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case "node":
|
||||
if ($tw.node) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$tw.utils.error("Module " + taskModule.name + ": '" + platforms[t] + "' in export.platforms invalid");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@ type: text/plain
|
||||
TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)
|
||||
|
||||
Copyright (c) 2004-2007, Jeremy Ruston
|
||||
Copyright (c) 2007-2020, UnaMesa Association
|
||||
Copyright (c) 2007-2021, UnaMesa Association
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
4
core/images/minus-button.tid
Normal file
4
core/images/minus-button.tid
Normal file
@@ -0,0 +1,4 @@
|
||||
title: $:/core/images/minus-button
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" class="tc-image-minus-button tc-image-button" viewBox="0 0 128 128"><path d="M64 0c35.346 0 64 28.654 64 64 0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64C0 28.654 28.654 0 64 0zm.332 16c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"/><rect width="80" height="16" x="24" y="56" rx="8"/></svg>
|
||||
@@ -1,4 +1,4 @@
|
||||
title: $:/core/images/plugin-generic-language
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M61.207 68.137c-4.324 2.795-6.999 6.656-6.999 10.921 0 7.906 9.19 14.424 21.042 15.336 2.162 3.902 8.598 6.785 16.318 7.01-5.126-1.125-9.117-3.742-10.62-7.01C92.805 93.487 102 86.967 102 79.059c0-8.53-10.699-15.445-23.896-15.445-6.599 0-12.572 1.729-16.897 4.524zm12.794-14.158c-4.324 2.795-10.298 4.524-16.897 4.524-2.619 0-5.14-.272-7.497-.775-3.312 2.25-8.383 3.69-14.067 3.69l-.255-.002c4.119-.892 7.511-2.747 9.478-5.13-6.925-2.704-11.555-7.617-11.555-13.228 0-8.53 10.699-15.445 23.896-15.445C70.301 27.613 81 34.528 81 43.058c0 4.265-2.675 8.126-6.999 10.921zM64 0l54.56 32v64L64 128 9.44 96V32L64 0z"/></svg>
|
||||
<svg width="22pt" height="22pt" viewBox="0 0 128 128" class="tc-image-plugin-generic-language tc-image-button"><path fill-rule="evenodd" d="M61.207 68.137c-4.324 2.795-6.999 6.656-6.999 10.921 0 7.906 9.19 14.424 21.042 15.336 2.162 3.902 8.598 6.785 16.318 7.01-5.126-1.125-9.117-3.742-10.62-7.01C92.805 93.487 102 86.967 102 79.059c0-8.53-10.699-15.445-23.896-15.445-6.599 0-12.572 1.729-16.897 4.524zm12.794-14.158c-4.324 2.795-10.298 4.524-16.897 4.524-2.619 0-5.14-.272-7.497-.775-3.312 2.25-8.383 3.69-14.067 3.69l-.255-.002c4.119-.892 7.511-2.747 9.478-5.13-6.925-2.704-11.555-7.617-11.555-13.228 0-8.53 10.699-15.445 23.896-15.445C70.301 27.613 81 34.528 81 43.058c0 4.265-2.675 8.126-6.999 10.921zM64 0l54.56 32v64L64 128 9.44 96V32L64 0z"/></svg>
|
||||
@@ -1,4 +1,4 @@
|
||||
title: $:/core/images/plugin-generic-plugin
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M40.397 76.446V95.34h14.12l-.001-.005a6.912 6.912 0 005.364-11.593l.046-.023a6.912 6.912 0 119.979.526l.086.055a6.914 6.914 0 004.408 10.948l-.023.092h21.32V75.568l-.15.038a6.912 6.912 0 00-11.593-5.364l-.022-.046a6.912 6.912 0 11.526-9.979l.055-.086a6.914 6.914 0 0010.948-4.408c.079.018.158.038.236.059v-15.74h-21.32l.023-.094a6.914 6.914 0 01-4.408-10.947 10.23 10.23 0 00-.086-.055 6.912 6.912 0 10-9.979-.526l-.046.023a6.912 6.912 0 01-5.364 11.593l.001.005h-14.12v12.847A6.912 6.912 0 0129.5 59.843l-.054.086a6.912 6.912 0 10-.526 9.979l.023.046a6.912 6.912 0 0111.455 6.492zM64 0l54.56 32v64L64 128 9.44 96V32L64 0z"/></svg>
|
||||
<svg width="22pt" height="22pt" viewBox="0 0 128 128" class="tc-image-plugin-generic-plugin tc-image-button"><path fill-rule="evenodd" d="M40.397 76.446V95.34h14.12l-.001-.005a6.912 6.912 0 005.364-11.593l.046-.023a6.912 6.912 0 119.979.526l.086.055a6.914 6.914 0 004.408 10.948l-.023.092h21.32V75.568l-.15.038a6.912 6.912 0 00-11.593-5.364l-.022-.046a6.912 6.912 0 11.526-9.979l.055-.086a6.914 6.914 0 0010.948-4.408c.079.018.158.038.236.059v-15.74h-21.32l.023-.094a6.914 6.914 0 01-4.408-10.947 10.23 10.23 0 00-.086-.055 6.912 6.912 0 10-9.979-.526l-.046.023a6.912 6.912 0 01-5.364 11.593l.001.005h-14.12v12.847A6.912 6.912 0 0129.5 59.843l-.054.086a6.912 6.912 0 10-.526 9.979l.023.046a6.912 6.912 0 0111.455 6.492zM64 0l54.56 32v64L64 128 9.44 96V32L64 0z"/></svg>
|
||||
@@ -1,4 +1,4 @@
|
||||
title: $:/core/images/plugin-generic-theme
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M29.408 91.472L51.469 69.41l-.004-.005a2.22 2.22 0 01.004-3.146c.87-.87 2.281-.872 3.147-.005l9.465 9.464a2.22 2.22 0 01-.005 3.147c-.87.87-2.28.871-3.147.005l-.005-.005-22.061 22.062a6.686 6.686 0 11-9.455-9.455zM60.802 66.38c-2.436-2.704-4.465-5.091-5.817-6.869-6.855-9.014-10.313-4.268-14.226 0-3.913 4.268 1.03 7.726-2.683 10.741-3.713 3.015-3.484 4.06-9.752-1.455-6.267-5.516-6.7-7.034-3.823-10.181 2.877-3.147 5.281 1.808 11.159-3.785 5.877-5.593.94-10.55.94-10.55s12.237-25.014 28.588-23.167c16.351 1.848-6.186-2.392-11.792 17.226-2.4 8.4.447 6.42 4.998 9.968 1.394 1.086 6.03 4.401 11.794 8.685l20.677-20.676 1.615-4.766 7.84-4.689 3.151 3.152-4.688 7.84-4.766 1.615-20.224 20.223c12.663 9.547 28.312 22.146 28.312 26.709 0 7.217-3.071 11.526-9.535 9.164-4.693-1.715-18.768-15.192-28.753-25.897l-2.893 2.893-3.151-3.152 3.029-3.029zM63.953 0l54.56 32v64l-54.56 32-54.56-32V32l54.56-32z"/></svg>
|
||||
<svg width="22pt" height="22pt" viewBox="0 0 128 128" class="tc-image-plugin-generic-theme tc-image-button"><path fill-rule="evenodd" d="M29.408 91.472L51.469 69.41l-.004-.005a2.22 2.22 0 01.004-3.146c.87-.87 2.281-.872 3.147-.005l9.465 9.464a2.22 2.22 0 01-.005 3.147c-.87.87-2.28.871-3.147.005l-.005-.005-22.061 22.062a6.686 6.686 0 11-9.455-9.455zM60.802 66.38c-2.436-2.704-4.465-5.091-5.817-6.869-6.855-9.014-10.313-4.268-14.226 0-3.913 4.268 1.03 7.726-2.683 10.741-3.713 3.015-3.484 4.06-9.752-1.455-6.267-5.516-6.7-7.034-3.823-10.181 2.877-3.147 5.281 1.808 11.159-3.785 5.877-5.593.94-10.55.94-10.55s12.237-25.014 28.588-23.167c16.351 1.848-6.186-2.392-11.792 17.226-2.4 8.4.447 6.42 4.998 9.968 1.394 1.086 6.03 4.401 11.794 8.685l20.677-20.676 1.615-4.766 7.84-4.689 3.151 3.152-4.688 7.84-4.766 1.615-20.224 20.223c12.663 9.547 28.312 22.146 28.312 26.709 0 7.217-3.071 11.526-9.535 9.164-4.693-1.715-18.768-15.192-28.753-25.897l-2.893 2.893-3.151-3.152 3.029-3.029zM63.953 0l54.56 32v64l-54.56 32-54.56-32V32l54.56-32z"/></svg>
|
||||
4
core/images/plus-button.tid
Normal file
4
core/images/plus-button.tid
Normal file
@@ -0,0 +1,4 @@
|
||||
title: $:/core/images/plus-button
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" class="tc-image-plus-button tc-image-button" viewBox="0 0 128 128"><path d="M64-.333c35.346 0 64 28.654 64 64 0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64zM64 16c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"/><rect width="80" height="16" x="24" y="56" rx="8"/><rect width="16" height="80" x="56" y="24" rx="8"/></svg>
|
||||
7
core/images/publish.tid
Normal file
7
core/images/publish.tid
Normal file
@@ -0,0 +1,7 @@
|
||||
title: $:/core/images/publish
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg width="22pt" height="22pt" class="tc-image-publish tc-image-button" viewBox="0 0 128 128"><g fill-rule="evenodd">
|
||||
<path d="M64.0434107,46.2358498 C65.8048912,45.8955184 67.6195684,46.7809274 68.4102078,48.4458716 L68.4937877,48.6340507 L98.8972485,122.034498 C99.7426494,124.075476 98.7734424,126.415349 96.7324641,127.26075 C94.7552664,128.079732 92.4975633,127.195747 91.5897922,125.284145 L91.5062123,125.095966 L88.403,117.605598 L79.5048497,126.50485 C78.775871,127.233828 77.8355254,127.622617 76.8810886,127.671216 L76.6764226,127.676423 C75.6527333,127.676423 74.6290441,127.285898 73.8479955,126.50485 L63.999,116.656598 L54.1520045,126.50485 C53.4230259,127.233828 52.4826802,127.622617 51.5282434,127.671216 L51.3235774,127.676423 C50.2998881,127.676423 49.2761989,127.285898 48.4951503,126.50485 L39.596,117.605598 L36.4937877,125.095966 C35.6483868,127.136944 33.3085142,128.106151 31.2675359,127.26075 C29.2265576,126.415349 28.2573506,124.075476 29.1027515,122.034498 L59.5062123,48.6340507 C60.2518688,46.8338766 62.1601511,45.867488 64.0005148,46.2445933 L64.0434107,46.2358498 Z M77.679,102.976598 L69.656,110.999598 L76.676,118.018598 L84.699,109.996598 L77.679,102.976598 Z M50.326,102.983598 L43.307,110.002598 L51.323,118.018598 L58.342,110.999598 L50.326,102.983598 Z M64.006,89.3035977 L55.983,97.3265977 L63.999,105.342598 L72.022,97.3195977 L64.006,89.3035977 Z M55.035,80.3325977 L50.348,91.6475977 L58.349,83.6465977 L55.035,80.3325977 Z M72.968,80.3415977 L69.663,83.6465977 L77.642,91.6255977 L72.968,80.3415977 Z M64,58.6895977 L58.3344072,72.3699713 C58.4295481,72.4423583 58.5221874,72.5195778 58.6119911,72.6016299 L58.7445283,72.7283325 L64.006,77.9895977 L69.2684411,72.7283325 C69.3957231,72.6010505 69.5294489,72.4841397 69.6685683,72.3775999 L64,58.6895977 Z M38.5026635,2.59571369 C40.7118025,2.59571369 42.5026635,4.38657469 42.5026635,6.59571369 C42.5026635,7.7643162 42.0015346,8.8158738 41.2024517,9.54721162 L41.372583,9.372583 C35.581722,15.163444 32,23.163444 32,32 C32,40.8370609 35.5821314,48.8374703 41.3735757,54.6284097 C42.0884306,55.3520538 42.531226,56.3471171 42.531226,57.4456008 C42.531226,59.6547398 40.740365,61.4456008 38.531226,61.4456008 C37.4327422,61.4456008 36.4376789,61.0028055 35.7147885,60.2859673 L35.7048234,60.2963403 C28.472656,53.0586276 24,43.0631255 24,32.0229786 C24,21.1046577 28.3744907,11.2080539 35.4664167,3.99022262 C36.2004724,3.13678606 37.2883808,2.59571369 38.5026635,2.59571369 Z M89.3688013,2.48959773 C90.5097745,2.48959773 91.5391719,2.96731026 92.2678917,3.73363348 L92.2733617,3.72780197 C99.5183488,10.9672382 104,20.9717355 104,32.0229786 C104,42.8488024 99.6993143,52.6701472 92.7132398,59.8717162 C91.9816831,60.8152368 90.8371876,61.4223982 89.5508819,61.4223982 C87.3417429,61.4223982 85.5508819,59.6315372 85.5508819,57.4223982 C85.5508819,56.3502862 85.9726717,55.3766885 86.6593633,54.6584932 L86.627417,54.627417 C92.418278,48.836556 96,40.836556 96,32 C96,23.2702193 92.5043135,15.3568999 86.8363661,9.5834674 C85.9399594,8.85136737 85.3688013,7.73718311 85.3688013,6.48959773 C85.3688013,4.28045873 87.1596623,2.48959773 89.3688013,2.48959773 Z M50.0871028,13.6297119 C52.2962418,13.6297119 54.0871028,15.4205729 54.0871028,17.6297119 C54.0871028,18.8506134 53.5401157,19.9437593 52.6778337,20.6774573 L52.6862915,20.6862915 C49.790861,23.581722 48,27.581722 48,32 C48,36.4187838 49.791271,40.4191937 52.6872859,43.3147028 L52.6777105,43.3251493 C53.4423082,44.0537041 53.918794,45.0819221 53.918794,46.2214294 C53.918794,48.4305684 52.127933,50.2214294 49.918794,50.2214294 C48.6900999,50.2214294 47.5907975,49.6674376 46.8570439,48.7956109 L47.0304281,48.9715536 C42.6867001,44.6283295 40,38.627921 40,32 C40,25.372583 42.6862915,19.372583 47.0294373,15.0294373 L47.0395567,15.0387468 C47.7732533,14.1766 48.8663118,13.6297119 50.0871028,13.6297119 Z M77.9823819,13.700452 C79.1679628,13.700452 80.2330731,14.2162483 80.9655529,15.0356811 L80.9715536,15.0304281 C85.314117,19.3734956 88,25.373087 88,32 C88,38.4619387 85.4461804,44.3274009 81.2927766,48.6421512 L80.9933974,48.9476975 C80.2638884,49.7186971 79.2309977,50.2000547 78.08568,50.2000547 C75.876541,50.2000547 74.08568,48.4091937 74.08568,46.2000547 C74.08568,45.0665777 74.557136,44.0432152 75.314649,43.3153662 L75.3137085,43.3137085 C78.209139,40.418278 80,36.418278 80,32 C80,27.5822253 78.209547,23.5826334 75.314698,20.6872811 C74.4981782,19.9511432 73.9823819,18.8860329 73.9823819,17.700452 C73.9823819,15.491313 75.7732429,13.700452 77.9823819,13.700452 Z M64,24 C68.418278,24 72,27.581722 72,32 C72,36.418278 68.418278,40 64,40 C59.581722,40 56,36.418278 56,32 C56,27.581722 59.581722,24 64,24 Z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
@@ -32,6 +32,8 @@ ExportTiddler/Caption: export tiddler
|
||||
ExportTiddler/Hint: Export tiddler
|
||||
ExportTiddlers/Caption: export tiddlers
|
||||
ExportTiddlers/Hint: Export tiddlers
|
||||
ExportTiddlyWikiCore/Caption: export TiddlyWiki core
|
||||
ExportTiddlyWikiCore/Hint: Export the ~TiddlyWiki core code for running with external ~JavaScript
|
||||
SidebarSearch/Hint: Select the sidebar search field
|
||||
Fold/Caption: fold tiddler
|
||||
Fold/Hint: Fold the body of this tiddler
|
||||
@@ -83,6 +85,8 @@ Permaview/Caption: permaview
|
||||
Permaview/Hint: Set browser address bar to a direct link to all the tiddlers in this story
|
||||
Print/Caption: print page
|
||||
Print/Hint: Print the current page
|
||||
Publish/Caption: publish
|
||||
Publish/Hint: Publish from the wiki
|
||||
Refresh/Caption: refresh
|
||||
Refresh/Hint: Perform a full refresh of the wiki
|
||||
Save/Caption: ok
|
||||
|
||||
@@ -17,6 +17,8 @@ Basics/NewJournal/Tags/Prompt: Tags for new journal tiddlers
|
||||
Basics/NewTiddler/Title/Prompt: Title of new tiddlers
|
||||
Basics/NewTiddler/Tags/Prompt: Tags for new tiddlers
|
||||
Basics/OverriddenShadowTiddlers/Prompt: Number of overridden shadow tiddlers
|
||||
Basics/RemoveTags: Update to current format
|
||||
Basics/RemoveTags/Hint: Update the tags configuration to the latest format
|
||||
Basics/ShadowTiddlers/Prompt: Number of shadow tiddlers
|
||||
Basics/Subtitle/Prompt: Subtitle
|
||||
Basics/SystemTiddlers/Prompt: Number of system tiddlers
|
||||
@@ -44,6 +46,7 @@ KeyboardShortcuts/Platform/Linux: Linux platform only
|
||||
KeyboardShortcuts/Platform/NonLinux: Non-Linux platforms only
|
||||
KeyboardShortcuts/Platform/Windows: Windows platform only
|
||||
KeyboardShortcuts/Platform/NonWindows: Non-Windows platforms only
|
||||
LayoutSwitcher/Caption: Layout
|
||||
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.
|
||||
Palette/Caption: Palette
|
||||
@@ -93,6 +96,8 @@ Plugins/Updates/Caption: Updates
|
||||
Plugins/Updates/Hint: Available updates to installed plugins
|
||||
Plugins/Updates/UpdateAll/Caption: Update <<update-count>> plugins
|
||||
Plugins/SubPluginPrompt: With <<count>> sub-plugins available
|
||||
Publishing/Caption: Publishing
|
||||
Publishing/Hint: Settings used for publishing extracts from this TiddlyWiki as separate files through a "publisher" module
|
||||
Saving/Caption: Saving
|
||||
Saving/DownloadSaver/AutoSave/Description: Permit automatic saving for the download saver
|
||||
Saving/DownloadSaver/AutoSave/Hint: Enable Autosave for Download Saver
|
||||
@@ -120,11 +125,12 @@ Saving/TiddlySpot/BackupDir: Backup Directory
|
||||
Saving/TiddlySpot/ControlPanel: ~TiddlySpot Control Panel
|
||||
Saving/TiddlySpot/Backups: Backups
|
||||
Saving/TiddlySpot/Caption: ~TiddlySpot Saver
|
||||
Saving/TiddlySpot/Description: These settings are only used when saving to http://tiddlyspot.com or a compatible remote server
|
||||
Saving/TiddlySpot/Description: These settings are only used when saving to [[TiddlySpot|http://tiddlyspot.com]], [[TiddlyHost|https://tiddlyhost.com]], or a compatible remote server. See [[here|https://github.com/simonbaird/tiddlyhost/wiki/TiddlySpot-Saver-configuration-for-Tiddlyhost-and-Tiddlyspot]] for information on ~TiddlySpot and ~TiddlyHost saving configuration.
|
||||
Saving/TiddlySpot/Filename: Upload Filename
|
||||
Saving/TiddlySpot/Heading: ~TiddlySpot
|
||||
Saving/TiddlySpot/Hint: //The server URL defaults to `http://<wikiname>.tiddlyspot.com/store.cgi` and can be changed to use a custom server address, e.g. `http://example.com/store.php`.//
|
||||
Saving/TiddlySpot/Password: Password
|
||||
Saving/TiddlySpot/ReadOnly: Note that [[TiddlySpot|http://tiddlyspot.com]] no longer allows the creation of new sites. For new sites, you can use [[TiddlyHost|https://tiddlyhost.com]], a new hosting service that replaces ~TiddlySpot.
|
||||
Saving/TiddlySpot/ServerURL: Server URL
|
||||
Saving/TiddlySpot/UploadDir: Upload Directory
|
||||
Saving/TiddlySpot/UserName: Wiki Name
|
||||
|
||||
@@ -23,6 +23,7 @@ tiddlerfield: Defines the behaviour of an individual tiddler field.
|
||||
tiddlermethod: Adds methods to the `$tw.Tiddler` prototype.
|
||||
upgrader: Applies upgrade processing to tiddlers during an upgrade/import.
|
||||
utils: Adds methods to `$tw.utils`.
|
||||
utils-browser: Adds browser-specific methods to `$tw.utils`.
|
||||
utils-node: Adds Node.js-specific methods to `$tw.utils`.
|
||||
widget: Widgets encapsulate DOM rendering and refreshing.
|
||||
wikimethod: Adds methods to `$tw.Wiki`.
|
||||
|
||||
@@ -3,6 +3,8 @@ title: $:/language/EditTemplate/
|
||||
Body/External/Hint: This tiddler shows content stored outside of the main TiddlyWiki file. You can edit the tags and fields but cannot directly edit the content itself
|
||||
Body/Placeholder: Type the text for this tiddler
|
||||
Body/Preview/Type/Output: output
|
||||
Body/Preview/Type/DiffShadow: differences from shadow (if any)
|
||||
Body/Preview/Type/DiffCurrent: differences from current
|
||||
Field/Remove/Caption: remove field
|
||||
Field/Remove/Hint: Remove field
|
||||
Field/Dropdown/Caption: field list
|
||||
@@ -19,6 +21,8 @@ Shadow/OverriddenWarning: This is a modified shadow tiddler. You can revert to t
|
||||
Tags/Add/Button: add
|
||||
Tags/Add/Button/Hint: add tag
|
||||
Tags/Add/Placeholder: tag name
|
||||
Tags/ClearInput/Caption: clear input
|
||||
Tags/ClearInput/Hint: Clear tag input
|
||||
Tags/Dropdown/Caption: tag list
|
||||
Tags/Dropdown/Hint: Show tag list
|
||||
Title/BadCharacterWarning: Warning: avoid using any of the characters <<bad-chars>> in tiddler titles
|
||||
|
||||
@@ -19,9 +19,11 @@ All parameters are optional with safe defaults, and can be specified in any orde
|
||||
* ''username'' - optional username for basic authentication
|
||||
* ''password'' - optional password for basic authentication
|
||||
* ''authenticated-user-header'' - optional name of header to be used for trusted authentication
|
||||
* ''readers'' - comma separated list of principals allowed to read from this wiki
|
||||
* ''writers'' - comma separated list of principals allowed to write to this wiki
|
||||
* ''readers'' - comma-separated list of principals allowed to read from this wiki
|
||||
* ''writers'' - comma-separated list of principals allowed to write to this wiki
|
||||
* ''csrf-disable'' - set to "yes" to disable CSRF checks (defaults to "no")
|
||||
* ''sse-enabled'' - set to "yes" to enable Server-sent events (defaults to "no")
|
||||
* ''sitemap'' - optional sitemap describing how the tiddlers will be served. See [[Publishing]] for more details
|
||||
* ''root-tiddler'' - the tiddler to serve at the root (defaults to "$:/core/save/all")
|
||||
* ''root-render-type'' - the content type to which the root tiddler should be rendered (defaults to "text/plain")
|
||||
* ''root-serve-type'' - the content type with which the root tiddler should be served (defaults to "text/html")
|
||||
@@ -29,6 +31,7 @@ All parameters are optional with safe defaults, and can be specified in any orde
|
||||
* ''tls-key'' - pathname of TLS key file (relative to wiki folder)
|
||||
* ''debug-level'' - optional debug level; set to "debug" to view request details (defaults to "none")
|
||||
* ''gzip'' - set to "yes" to enable gzip compression for some http endpoints (defaults to "no")
|
||||
* ''use-browser-cache'' - set to "yes" to allow the browser to cache responses to save bandwidth (defaults to "no")
|
||||
|
||||
For information on opening up your instance to the entire local network, and possible security concerns, see the WebServer tiddler at TiddlyWiki.com.
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@ Optionally, the title of a template tiddler can be specified. In this case, inst
|
||||
A name and value for an additional variable may optionally also be specified.
|
||||
|
||||
```
|
||||
--render <tiddler-filter> [<filename-filter>] [<render-type>] [<template>] [<name>] [<value>]
|
||||
--render <tiddler-filter> [<filename-filter>] [<render-type>] [<template>] [ [<name>] [<value>] ]*
|
||||
```
|
||||
|
||||
* ''tiddler-filter'': A filter identifying the tiddler(s) to be rendered
|
||||
* ''filename-filter'': Optional filter transforming tiddler titles into pathnames. If omitted, defaults to `[is[tiddler]addsuffix[.html]]`, which uses the unchanged tiddler title as the filename
|
||||
* ''render-type'': Optional render type: `text/html` (the default) returns the full HTML text and `text/plain` just returns the text content (ie it ignores HTML tags and other unprintable material)
|
||||
* ''template'': Optional template through which each tiddler is rendered
|
||||
* ''name'': Name of optional variable
|
||||
* ''value'': Value of optional variable
|
||||
* ''name'': Name of optional variables
|
||||
* ''value'': Value of optional variables
|
||||
|
||||
By default, the filename is resolved relative to the `output` subdirectory of the edition directory. The `--output` command can be used to direct output to a different directory.
|
||||
|
||||
@@ -24,8 +24,9 @@ Notes:
|
||||
|
||||
* The output directory is not cleared of any existing files
|
||||
* Any missing directories in the path to the filename are automatically created.
|
||||
* When referring to a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets : `--render "[[Motovun Jack.jpg]]"`
|
||||
* When referring to a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets: `--render "[[Motovun Jack.jpg]]"`
|
||||
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being rendered, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
||||
* Multiple ''name''/''value'' pairs can be used to pass more than one variable
|
||||
* The `--render` command is a more flexible replacement for both the `--rendertiddler` and `--rendertiddlers` commands, which are deprecated
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -16,7 +16,7 @@ Notes:
|
||||
|
||||
* The output directory is not cleared of any existing files
|
||||
* Any missing directories in the path to the filename are automatically created.
|
||||
* When saving a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets : `--save "[[Motovun Jack.jpg]]"`
|
||||
* When saving a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets: `--save "[[Motovun Jack.jpg]]"`
|
||||
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being saved, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
||||
* The `--save` command is a more flexible replacement for both the `--savetiddler` and `--savetiddlers` commands, which are deprecated
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
title: $:/language/Import/
|
||||
|
||||
Editor/Import/Heading: Import images and insert them into the editor.
|
||||
Imported/Hint: The following tiddlers were imported:
|
||||
Listing/Cancel/Caption: Cancel
|
||||
Listing/Cancel/Warning: Do you wish to cancel the import?
|
||||
Listing/Hint: These tiddlers are ready to import:
|
||||
Listing/Import/Caption: Import
|
||||
Listing/Select/Caption: Select
|
||||
@@ -18,11 +20,15 @@ Listing/Rename/Prompt: Rename to:
|
||||
Listing/Rename/ConfirmRename: Rename tiddler
|
||||
Listing/Rename/CancelRename: Cancel
|
||||
Listing/Rename/OverwriteWarning: A tiddler with this title already exists.
|
||||
Upgrader/Plugins/Suppressed/Incompatible: Blocked incompatible or obsolete plugin
|
||||
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> being older than existing <<existing>>)
|
||||
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>
|
||||
Upgrader/State/Suppressed: Blocked temporary state tiddler
|
||||
Upgrader/System/Suppressed: Blocked system tiddler
|
||||
Upgrader/System/Warning: Core module tiddler
|
||||
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable
|
||||
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>
|
||||
Upgrader/Plugins/Suppressed/Incompatible: Blocked incompatible or obsolete plugin.
|
||||
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> not being newer than existing <<existing>>).
|
||||
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>.
|
||||
Upgrader/State/Suppressed: Blocked temporary state tiddler.
|
||||
Upgrader/System/Disabled: Disabled system tiddler.
|
||||
Upgrader/System/Suppressed: Blocked system tiddler.
|
||||
Upgrader/System/Warning: Core module tiddler.
|
||||
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable.
|
||||
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
|
||||
Upgrader/Tiddler/Disabled: Disabled tiddler.
|
||||
Upgrader/Tiddler/Selected: User selected.
|
||||
Upgrader/Tiddler/Unselected: Unselected tiddler.
|
||||
|
||||
@@ -10,6 +10,7 @@ ConfirmCancelTiddler: Do you wish to discard changes to the tiddler "<$text text
|
||||
ConfirmDeleteTiddler: Do you wish to delete the tiddler "<$text text=<<title>>/>"?
|
||||
ConfirmOverwriteTiddler: Do you wish to overwrite the tiddler "<$text text=<<title>>/>"?
|
||||
ConfirmEditShadowTiddler: You are about to edit a ShadowTiddler. Any changes will override the default system making future upgrades non-trivial. Are you sure you want to edit "<$text text=<<title>>/>"?
|
||||
ConfirmAction: Do you wish to proceed?
|
||||
Count: count
|
||||
DefaultNewTiddlerTitle: New Tiddler
|
||||
Diffs/CountMessage: <<diff-count>> differences
|
||||
@@ -23,7 +24,6 @@ Encryption/RepeatPassword: Repeat password
|
||||
Encryption/PasswordNoMatch: Passwords do not match
|
||||
Encryption/SetPassword: Set password
|
||||
Error/Caption: Error
|
||||
Error/EditConflict: File changed on server
|
||||
Error/Filter: Filter error
|
||||
Error/FilterSyntax: Syntax error in filter expression
|
||||
Error/FilterRunPrefix: Filter Error: Unknown prefix for filter run
|
||||
@@ -31,6 +31,9 @@ Error/IsFilterOperator: Filter Error: Unknown operand for the 'is' filter operat
|
||||
Error/FormatFilterOperator: Filter Error: Unknown suffix for the 'format' filter operator
|
||||
Error/LoadingPluginLibrary: Error loading plugin library
|
||||
Error/NetworkErrorAlert: `<h2>''Network Error''</h2>It looks like the connection to the server has been lost. This may indicate a problem with your network connection. Please attempt to restore network connectivity before continuing.<br><br>''Any unsaved changes will be automatically synchronised when connectivity is restored''.`
|
||||
Error/PutEditConflict: File changed on server
|
||||
Error/PutForbidden: Permission denied
|
||||
Error/PutUnauthorized: Authentication required
|
||||
Error/RecursiveTransclusion: Recursive transclusion error in transclude widget
|
||||
Error/RetrievingSkinny: Error retrieving skinny tiddler list
|
||||
Error/SavingToTWEdit: Error saving to TWEdit
|
||||
@@ -38,7 +41,7 @@ Error/WhileSaving: Error while saving
|
||||
Error/XMLHttpRequest: XMLHttpRequest error code
|
||||
InternalJavaScriptError/Title: Internal JavaScript Error
|
||||
InternalJavaScriptError/Hint: Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
|
||||
InvalidFieldName: Illegal characters in field name "<$text text=<<fieldName>>/>". Fields can only contain lowercase letters, digits and the characters underscore (`_`), hyphen (`-`) and period (`.`)
|
||||
LayoutSwitcher/Description: Open the layout switcher
|
||||
LazyLoadingWarning: <p>Trying to load external content from ''<$text text={{!!_canonical_uri}}/>''</p><p>If this message doesn't disappear, either the tiddler content type doesn't match the type of the external content, or you may be using a browser that doesn't support external content for wikis loaded as standalone files. See https://tiddlywiki.com/#ExternalText</p>
|
||||
LoginToTiddlySpace: Login to TiddlySpace
|
||||
Manager/Controls/FilterByTag/None: (none)
|
||||
@@ -62,6 +65,8 @@ MissingTiddler/Hint: Missing tiddler "<$text text=<<currentTiddler>>/>" -- click
|
||||
No: No
|
||||
OfficialPluginLibrary: Official ~TiddlyWiki Plugin Library
|
||||
OfficialPluginLibrary/Hint: The official ~TiddlyWiki plugin library at tiddlywiki.com. Plugins, themes and language packs are maintained by the core team.
|
||||
PageTemplate/Description: the default ~TiddlyWiki layout
|
||||
PageTemplate/Name: Default ~PageTemplate
|
||||
PluginReloadWarning: Please save {{$:/core/ui/Buttons/save-wiki}} and reload {{$:/core/ui/Buttons/refresh}} to allow changes to ~JavaScript plugins to take effect
|
||||
RecentChanges/DateFormat: DDth MMM YYYY
|
||||
Shortcuts/Input/AdvancedSearch/Hint: Open the ~AdvancedSearch panel from within the sidebar search field
|
||||
@@ -73,6 +78,10 @@ Shortcuts/Input/Tab-Left/Hint: Select the previous Tab
|
||||
Shortcuts/Input/Tab-Right/Hint: Select the next Tab
|
||||
Shortcuts/Input/Up/Hint: Select the previous item
|
||||
Shortcuts/SidebarLayout/Hint: Change the sidebar layout
|
||||
Switcher/Subtitle/theme: Switch Theme
|
||||
Switcher/Subtitle/layout: Switch Layout
|
||||
Switcher/Subtitle/language: Switch Language
|
||||
Switcher/Subtitle/palette: Switch Palette
|
||||
SystemTiddler/Tooltip: This is a system tiddler
|
||||
SystemTiddlers/Include/Prompt: Include system tiddlers
|
||||
TagManager/Colour/Heading: Colour
|
||||
|
||||
5
core/language/en-GB/Publishing/Modal.tid
Normal file
5
core/language/en-GB/Publishing/Modal.tid
Normal file
@@ -0,0 +1,5 @@
|
||||
title: $:/language/Publishing/Modal
|
||||
subtitle: Publishing: ''<$transclude field="caption"><$view field="title"/></$transclude>''
|
||||
footer: <$button message="tm-close-tiddler">Cancel</$button>
|
||||
|
||||
Publishing <$text text=<<totalFiles>>/> files via the "{{!!publisher}}" publisher.
|
||||
@@ -14,7 +14,7 @@ List/Caption: List
|
||||
List/Empty: This tiddler does not have a list
|
||||
Listed/Caption: Listed
|
||||
Listed/Empty: This tiddler is not listed by any others
|
||||
References/Caption: References
|
||||
References/Caption: Backlinks
|
||||
References/Empty: No tiddlers link to this one
|
||||
Tagging/Caption: Tagging
|
||||
Tagging/Empty: No tiddlers are tagged with this one
|
||||
|
||||
@@ -154,7 +154,7 @@ Commander.prototype.extractNamedParameters = function(params,mandatoryParameters
|
||||
if(errors.length > 0) {
|
||||
return errors.join(" and\n");
|
||||
} else {
|
||||
return paramsByName;
|
||||
return paramsByName;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ Command.prototype.fetchFile = function(url,options,callback,redirectCount) {
|
||||
if(response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
|
||||
return self.fetchFile(response.headers.location,options,callback,redirectCount + 1);
|
||||
} else {
|
||||
return callback("Error " + response.statusCode + " retrieving " + url)
|
||||
return callback("Error " + response.statusCode + " retrieving " + url)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
46
core/modules/commands/publish.js
Normal file
46
core/modules/commands/publish.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/*\
|
||||
title: $:/core/modules/commands/publish.js
|
||||
type: application/javascript
|
||||
module-type: command
|
||||
|
||||
Publish static files
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.info = {
|
||||
name: "publish",
|
||||
synchronous: false
|
||||
};
|
||||
|
||||
var Command = function(params,commander,callback) {
|
||||
this.params = params;
|
||||
this.commander = commander;
|
||||
this.callback = callback;
|
||||
};
|
||||
|
||||
Command.prototype.execute = function() {
|
||||
if(this.params.length < 1) {
|
||||
return "Missing filename filter";
|
||||
}
|
||||
var self = this,
|
||||
wiki = this.commander.wiki,
|
||||
jobTiddler = this.params[0],
|
||||
variableList = this.params.slice(1),
|
||||
variables = Object.create(null);
|
||||
while(variableList.length >= 2) {
|
||||
variables[variableList[0]] = variableList[1];
|
||||
variableList = variableList.slice(2);
|
||||
}
|
||||
$tw.publisherHandler.publish(jobTiddler,this.callback,{commander: this.commander,variables: variables});
|
||||
return null;
|
||||
};
|
||||
|
||||
exports.Command = Command;
|
||||
|
||||
})();
|
||||
|
||||
@@ -37,16 +37,16 @@ Command.prototype.execute = function() {
|
||||
filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]",
|
||||
type = this.params[2] || "text/html",
|
||||
template = this.params[3],
|
||||
varName = this.params[4],
|
||||
varValue = this.params[5],
|
||||
tiddlers = wiki.filterTiddlers(tiddlerFilter);
|
||||
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 parser = wiki.parseTiddler(template || title),
|
||||
variables = {currentTiddler: title};
|
||||
if(varName) {
|
||||
variables[varName] = varValue || "";
|
||||
}
|
||||
var widgetNode = wiki.makeWidget(parser,{variables: variables}),
|
||||
var parser = wiki.parseTiddler(template || title);
|
||||
var widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title})}),
|
||||
container = $tw.fakeDocument.createElement("div");
|
||||
widgetNode.render(container,null);
|
||||
var text = type === "text/html" ? container.innerHTML : container.textContent,
|
||||
|
||||
@@ -36,7 +36,7 @@ Command.prototype.execute = function() {
|
||||
filter = this.params[0],
|
||||
template = this.params[1],
|
||||
outputPath = this.commander.outputPath,
|
||||
pathname = path.resolve(outputPath,this.params[2]),
|
||||
pathname = path.resolve(outputPath,this.params[2]),
|
||||
type = this.params[3] || "text/html",
|
||||
extension = this.params[4] || ".html",
|
||||
deleteDirectory = (this.params[5] || "").toLowerCase() !== "noclean",
|
||||
|
||||
@@ -97,7 +97,7 @@ WikiFolderMaker.prototype.save = function() {
|
||||
// A custom plugin
|
||||
self.log("Processing custom plugin: " + title);
|
||||
self.saveCustomPlugin(tiddler);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Ordinary tiddler
|
||||
self.saveTiddler("tiddlers",tiddler);
|
||||
@@ -158,11 +158,25 @@ WikiFolderMaker.prototype.saveCustomPlugin = function(pluginTiddler) {
|
||||
};
|
||||
|
||||
WikiFolderMaker.prototype.saveTiddler = function(directory,tiddler) {
|
||||
var title = tiddler.fields.title, fileInfo, pathFilters, extFilters;
|
||||
if(this.wiki.tiddlerExists("$:/config/FileSystemPaths")) {
|
||||
pathFilters = this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n");
|
||||
}
|
||||
if(this.wiki.tiddlerExists("$:/config/FileSystemExtensions")) {
|
||||
extFilters = this.wiki.getTiddlerText("$:/config/FileSystemExtensions","").split("\n");
|
||||
}
|
||||
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
||||
directory: path.resolve(this.wikiFolderPath,directory),
|
||||
wiki: this.wiki
|
||||
pathFilters: pathFilters,
|
||||
extFilters: extFilters,
|
||||
wiki: this.wiki,
|
||||
fileInfo: {}
|
||||
});
|
||||
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
|
||||
try {
|
||||
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
|
||||
} catch (err) {
|
||||
console.log("SaveWikiFolder: Error saving file '" + fileInfo.filepath + "', tiddler: '" + tiddler.fields.title);
|
||||
}
|
||||
};
|
||||
|
||||
WikiFolderMaker.prototype.saveJSONFile = function(filename,json) {
|
||||
|
||||
@@ -34,7 +34,7 @@ exports.htmlEntities = {quot:34, amp:38, apos:39, lt:60, gt:62, nbsp:160, iexcl:
|
||||
|
||||
exports.htmlVoidElements = "area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",");
|
||||
|
||||
exports.htmlBlockElements = "address,article,aside,audio,blockquote,canvas,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,noscript,ol,output,p,pre,section,table,tfoot,ul,video".split(",");
|
||||
exports.htmlBlockElements = "address,article,aside,audio,blockquote,canvas,dd,details,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,nav,ol,p,pre,section,summary,table,tfoot,ul,video".split(",");
|
||||
|
||||
exports.htmlUnsafeElements = "script".split(",");
|
||||
|
||||
|
||||
@@ -12,6 +12,124 @@ Functions to deserialise tiddlers from a block of text
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports["application/x-tiddler-html-div"] = function(text,fields) {
|
||||
return [deserializeTiddlerDiv(text,fields)];
|
||||
};
|
||||
|
||||
exports["application/json"] = function(text,fields) {
|
||||
var incoming,
|
||||
results = [];
|
||||
try {
|
||||
incoming = JSON.parse(text);
|
||||
} catch(e) {
|
||||
incoming = [{
|
||||
title: "JSON error: " + e,
|
||||
text: ""
|
||||
}]
|
||||
}
|
||||
if(!$tw.utils.isArray(incoming)) {
|
||||
incoming = [incoming];
|
||||
}
|
||||
for(var t=0; t<incoming.length; t++) {
|
||||
var incomingFields = incoming[t],
|
||||
fields = {};
|
||||
for(var f in incomingFields) {
|
||||
if(typeof incomingFields[f] === "string") {
|
||||
fields[f] = incomingFields[f];
|
||||
}
|
||||
}
|
||||
results.push(fields);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
/*
|
||||
Parse an HTML file into tiddlers. There are three possibilities:
|
||||
# A TiddlyWiki classic HTML file containing `text/x-tiddlywiki` tiddlers
|
||||
# A TiddlyWiki5 HTML file containing `text/vnd.tiddlywiki` tiddlers
|
||||
# An ordinary HTML file
|
||||
*/
|
||||
exports["text/html"] = function(text,fields) {
|
||||
var results = [];
|
||||
// Check if we've got an old-style store area
|
||||
var storeAreaMarkerRegExp = /<div id=["']?storeArea['"]?( style=["']?display:none;["']?)?>/gi,
|
||||
storeAreaMatch = storeAreaMarkerRegExp.exec(text);
|
||||
if(storeAreaMatch) {
|
||||
// If so, we've got tiddlers in classic TiddlyWiki format or unencrypted old-style TW5 format
|
||||
results.push.apply(results,deserializeStoreArea(text,storeAreaMarkerRegExp.lastIndex,!!storeAreaMatch[1],fields));
|
||||
}
|
||||
// Check for new-style store areas
|
||||
var newStoreAreaMarkerRegExp = /<script class="tiddlywiki-tiddler-store" type="([^"]*)">/gi,
|
||||
newStoreAreaMatch = newStoreAreaMarkerRegExp.exec(text),
|
||||
haveHadNewStoreArea = !!newStoreAreaMatch;
|
||||
while(newStoreAreaMatch) {
|
||||
results.push.apply(results,deserializeNewStoreArea(text,newStoreAreaMarkerRegExp.lastIndex,newStoreAreaMatch[1],fields));
|
||||
newStoreAreaMatch = newStoreAreaMarkerRegExp.exec(text);
|
||||
}
|
||||
// Return if we had either an old-style or a new-style store area
|
||||
if(storeAreaMatch || haveHadNewStoreArea) {
|
||||
return results;
|
||||
}
|
||||
// Otherwise, check whether we've got an encrypted file
|
||||
var encryptedStoreArea = $tw.utils.extractEncryptedStoreArea(text);
|
||||
if(encryptedStoreArea) {
|
||||
// If so, attempt to decrypt it using the current password
|
||||
return $tw.utils.decryptStoreArea(encryptedStoreArea);
|
||||
} else {
|
||||
// It's not a TiddlyWiki so we'll return the entire HTML file as a tiddler
|
||||
return deserializeHtmlFile(text,fields);
|
||||
}
|
||||
};
|
||||
|
||||
function deserializeHtmlFile(text,fields) {
|
||||
var result = {};
|
||||
$tw.utils.each(fields,function(value,name) {
|
||||
result[name] = value;
|
||||
});
|
||||
result.text = text;
|
||||
result.type = "text/html";
|
||||
return [result];
|
||||
}
|
||||
|
||||
function deserializeNewStoreArea(text,storeAreaEnd,type,fields) {
|
||||
var endOfScriptRegExp = /<\/script>/gi;
|
||||
endOfScriptRegExp.lastIndex = storeAreaEnd;
|
||||
var match = endOfScriptRegExp.exec(text);
|
||||
if(match) {
|
||||
var scriptContent = text.substring(storeAreaEnd,match.index);
|
||||
return $tw.wiki.deserializeTiddlers(type,scriptContent);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function deserializeStoreArea(text,storeAreaEnd,isTiddlyWiki5,fields) {
|
||||
var results = [],
|
||||
endOfDivRegExp = /(<\/div>\s*)/gi,
|
||||
startPos = storeAreaEnd,
|
||||
defaultType = isTiddlyWiki5 ? undefined : "text/x-tiddlywiki";
|
||||
endOfDivRegExp.lastIndex = startPos;
|
||||
var match = endOfDivRegExp.exec(text);
|
||||
while(match) {
|
||||
var endPos = endOfDivRegExp.lastIndex,
|
||||
tiddlerFields = deserializeTiddlerDiv(text.substring(startPos,endPos),fields,{type: defaultType});
|
||||
if(!tiddlerFields) {
|
||||
break;
|
||||
}
|
||||
$tw.utils.each(tiddlerFields,function(value,name) {
|
||||
if(typeof value === "string") {
|
||||
tiddlerFields[name] = $tw.utils.htmlDecode(value);
|
||||
}
|
||||
});
|
||||
if(tiddlerFields.text !== null) {
|
||||
results.push(tiddlerFields);
|
||||
}
|
||||
startPos = endPos;
|
||||
match = endOfDivRegExp.exec(text);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/*
|
||||
Utility function to parse an old-style tiddler DIV in a *.tid file. It looks like this:
|
||||
|
||||
@@ -24,7 +142,7 @@ Note that the field attributes are HTML encoded, but that the body of the <PRE>
|
||||
|
||||
When these tiddler DIVs are encountered within a TiddlyWiki HTML file then the body is encoded in the usual way.
|
||||
*/
|
||||
var parseTiddlerDiv = function(text /* [,fields] */) {
|
||||
var deserializeTiddlerDiv = function(text /* [,fields] */) {
|
||||
// Slot together the default results
|
||||
var result = {};
|
||||
if(arguments.length > 1) {
|
||||
@@ -67,106 +185,4 @@ var parseTiddlerDiv = function(text /* [,fields] */) {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
exports["application/x-tiddler-html-div"] = function(text,fields) {
|
||||
return [parseTiddlerDiv(text,fields)];
|
||||
};
|
||||
|
||||
exports["application/json"] = function(text,fields) {
|
||||
var incoming,
|
||||
results = [];
|
||||
try {
|
||||
incoming = JSON.parse(text);
|
||||
} catch(e) {
|
||||
incoming = [{
|
||||
title: "JSON error: " + e,
|
||||
text: ""
|
||||
}]
|
||||
}
|
||||
if(!$tw.utils.isArray(incoming)) {
|
||||
incoming = [incoming];
|
||||
}
|
||||
for(var t=0; t<incoming.length; t++) {
|
||||
var incomingFields = incoming[t],
|
||||
fields = {};
|
||||
for(var f in incomingFields) {
|
||||
if(typeof incomingFields[f] === "string") {
|
||||
fields[f] = incomingFields[f];
|
||||
}
|
||||
}
|
||||
results.push(fields);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
/*
|
||||
Parse an HTML file into tiddlers. There are three possibilities:
|
||||
# A TiddlyWiki classic HTML file containing `text/x-tiddlywiki` tiddlers
|
||||
# A TiddlyWiki5 HTML file containing `text/vnd.tiddlywiki` tiddlers
|
||||
# An ordinary HTML file
|
||||
*/
|
||||
exports["text/html"] = function(text,fields) {
|
||||
// Check if we've got a store area
|
||||
var storeAreaMarkerRegExp = /<div id=["']?storeArea['"]?( style=["']?display:none;["']?)?>/gi,
|
||||
match = storeAreaMarkerRegExp.exec(text);
|
||||
if(match) {
|
||||
// If so, it's either a classic TiddlyWiki file or an unencrypted TW5 file
|
||||
// First read the normal tiddlers
|
||||
var results = deserializeTiddlyWikiFile(text,storeAreaMarkerRegExp.lastIndex,!!match[1],fields);
|
||||
// Then any system tiddlers
|
||||
var systemAreaMarkerRegExp = /<div id=["']?systemArea['"]?( style=["']?display:none;["']?)?>/gi,
|
||||
sysMatch = systemAreaMarkerRegExp.exec(text);
|
||||
if(sysMatch) {
|
||||
results.push.apply(results,deserializeTiddlyWikiFile(text,systemAreaMarkerRegExp.lastIndex,!!sysMatch[1],fields));
|
||||
}
|
||||
return results;
|
||||
} else {
|
||||
// Check whether we've got an encrypted file
|
||||
var encryptedStoreArea = $tw.utils.extractEncryptedStoreArea(text);
|
||||
if(encryptedStoreArea) {
|
||||
// If so, attempt to decrypt it using the current password
|
||||
return $tw.utils.decryptStoreArea(encryptedStoreArea);
|
||||
} else {
|
||||
// It's not a TiddlyWiki so we'll return the entire HTML file as a tiddler
|
||||
return deserializeHtmlFile(text,fields);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function deserializeHtmlFile(text,fields) {
|
||||
var result = {};
|
||||
$tw.utils.each(fields,function(value,name) {
|
||||
result[name] = value;
|
||||
});
|
||||
result.text = text;
|
||||
result.type = "text/html";
|
||||
return [result];
|
||||
}
|
||||
|
||||
function deserializeTiddlyWikiFile(text,storeAreaEnd,isTiddlyWiki5,fields) {
|
||||
var results = [],
|
||||
endOfDivRegExp = /(<\/div>\s*)/gi,
|
||||
startPos = storeAreaEnd,
|
||||
defaultType = isTiddlyWiki5 ? undefined : "text/x-tiddlywiki";
|
||||
endOfDivRegExp.lastIndex = startPos;
|
||||
var match = endOfDivRegExp.exec(text);
|
||||
while(match) {
|
||||
var endPos = endOfDivRegExp.lastIndex,
|
||||
tiddlerFields = parseTiddlerDiv(text.substring(startPos,endPos),fields,{type: defaultType});
|
||||
if(!tiddlerFields) {
|
||||
break;
|
||||
}
|
||||
$tw.utils.each(tiddlerFields,function(value,name) {
|
||||
if(typeof value === "string") {
|
||||
tiddlerFields[name] = $tw.utils.htmlDecode(value);
|
||||
}
|
||||
});
|
||||
if(tiddlerFields.text !== null) {
|
||||
results.push(tiddlerFields);
|
||||
}
|
||||
startPos = endPos;
|
||||
match = endOfDivRegExp.exec(text);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -42,7 +42,6 @@ function FramedEngine(options) {
|
||||
this.iframeNode.style.border = "none";
|
||||
this.iframeNode.style.padding = "0";
|
||||
this.iframeNode.style.resize = "none";
|
||||
this.iframeNode.style["background-color"] = this.widget.wiki.extractTiddlerDataItem(this.widget.wiki.getTiddlerText("$:/palette"),"tiddler-editor-background");
|
||||
this.iframeDoc.body.style.margin = "0";
|
||||
this.iframeDoc.body.style.padding = "0";
|
||||
this.widget.domNodes.push(this.iframeNode);
|
||||
@@ -74,6 +73,12 @@ function FramedEngine(options) {
|
||||
if(this.widget.editTabIndex) {
|
||||
this.iframeNode.setAttribute("tabindex",this.widget.editTabIndex);
|
||||
}
|
||||
if(this.widget.editAutoComplete) {
|
||||
this.domNode.setAttribute("autocomplete",this.widget.editAutoComplete);
|
||||
}
|
||||
if(this.widget.isDisabled === "yes") {
|
||||
this.domNode.setAttribute("disabled",true);
|
||||
}
|
||||
// Copy the styles from the dummy textarea
|
||||
this.copyStyles();
|
||||
// Add event listeners
|
||||
@@ -83,6 +88,18 @@ function FramedEngine(options) {
|
||||
{name: "keydown",handlerObject: this.widget,handlerMethod: "handleKeydownEvent"},
|
||||
{name: "focus",handlerObject: this,handlerMethod: "handleFocusEvent"}
|
||||
]);
|
||||
// Add drag and drop event listeners if fileDrop is enabled
|
||||
if(this.widget.isFileDropEnabled) {
|
||||
$tw.utils.addEventListeners(this.domNode,[
|
||||
{name: "dragenter",handlerObject: this.widget,handlerMethod: "handleDragEnterEvent"},
|
||||
{name: "dragover",handlerObject: this.widget,handlerMethod: "handleDragOverEvent"},
|
||||
{name: "dragleave",handlerObject: this.widget,handlerMethod: "handleDragLeaveEvent"},
|
||||
{name: "dragend",handlerObject: this.widget,handlerMethod: "handleDragEndEvent"},
|
||||
{name: "drop", handlerObject: this.widget,handlerMethod: "handleDropEvent"},
|
||||
{name: "paste", handlerObject: this.widget,handlerMethod: "handlePasteEvent"},
|
||||
{name: "click",handlerObject: this.widget,handlerMethod: "handleClickEvent"}
|
||||
]);
|
||||
}
|
||||
// Insert the element into the DOM
|
||||
this.iframeDoc.body.appendChild(this.domNode);
|
||||
}
|
||||
@@ -97,7 +114,6 @@ FramedEngine.prototype.copyStyles = function() {
|
||||
this.domNode.style.display = "block";
|
||||
this.domNode.style.width = "100%";
|
||||
this.domNode.style.margin = "0";
|
||||
this.domNode.style["background-color"] = this.widget.wiki.extractTiddlerDataItem(this.widget.wiki.getTiddlerText("$:/palette"),"tiddler-editor-background");
|
||||
// In Chrome setting -webkit-text-fill-color overrides the placeholder text colour
|
||||
this.domNode.style["-webkit-text-fill-color"] = "currentcolor";
|
||||
};
|
||||
@@ -166,7 +182,7 @@ Handle a focus event
|
||||
*/
|
||||
FramedEngine.prototype.handleFocusEvent = function(event) {
|
||||
if(this.widget.editCancelPopups) {
|
||||
$tw.popup.cancel(0);
|
||||
$tw.popup.cancel(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,12 @@ function SimpleEngine(options) {
|
||||
if(this.widget.editTabIndex) {
|
||||
this.domNode.setAttribute("tabindex",this.widget.editTabIndex);
|
||||
}
|
||||
if(this.widget.editAutoComplete) {
|
||||
this.domNode.setAttribute("autocomplete",this.widget.editAutoComplete);
|
||||
}
|
||||
if(this.widget.isDisabled === "yes") {
|
||||
this.domNode.setAttribute("disabled",true);
|
||||
}
|
||||
// Add an input event handler
|
||||
$tw.utils.addEventListeners(this.domNode,[
|
||||
{name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"},
|
||||
|
||||
@@ -103,7 +103,11 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
var tiddler = this.wiki.getTiddler(this.editTitle);
|
||||
if(tiddler) {
|
||||
// If we've got a tiddler, the value to display is the field string value
|
||||
value = tiddler.getFieldString(this.editField);
|
||||
if(tiddler.hasField(this.editField)) {
|
||||
value = tiddler.getFieldString(this.editField);
|
||||
} else {
|
||||
value = this.editDefault || "";
|
||||
}
|
||||
if(this.editField === "text") {
|
||||
type = tiddler.fields.type || "text/vnd.tiddlywiki";
|
||||
}
|
||||
@@ -180,6 +184,9 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
this.editCancelPopups = this.getAttribute("cancelPopups","") === "yes";
|
||||
this.editInputActions = this.getAttribute("inputActions");
|
||||
this.editRefreshTitle = this.getAttribute("refreshTitle");
|
||||
this.editAutoComplete = this.getAttribute("autocomplete");
|
||||
this.isDisabled = this.getAttribute("disabled","no");
|
||||
this.isFileDropEnabled = this.getAttribute("fileDrop","no") === "yes";
|
||||
// Get the default editor element tag and type
|
||||
var tag,type;
|
||||
if(this.editField === "text") {
|
||||
@@ -211,7 +218,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
EditTextWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
// 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 || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE]) {
|
||||
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] || changedAttributes.disabled || changedAttributes.fileDrop) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if (changedTiddlers[this.editRefreshTitle]) {
|
||||
@@ -291,21 +298,89 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||
Propogate keydown events to our container for the keyboard widgets benefit
|
||||
*/
|
||||
EditTextWidget.prototype.propogateKeydownEvent = function(event) {
|
||||
var newEvent = this.document.createEventObject ? this.document.createEventObject() : this.document.createEvent("Events");
|
||||
if(newEvent.initEvent) {
|
||||
newEvent.initEvent("keydown", true, true);
|
||||
}
|
||||
newEvent.keyCode = event.keyCode;
|
||||
newEvent.which = event.which;
|
||||
newEvent.metaKey = event.metaKey;
|
||||
newEvent.ctrlKey = event.ctrlKey;
|
||||
newEvent.altKey = event.altKey;
|
||||
newEvent.shiftKey = event.shiftKey;
|
||||
var newEvent = this.cloneEvent(event,["keyCode","which","metaKey","ctrlKey","altKey","shiftKey"]);
|
||||
return !this.parentDomNode.dispatchEvent(newEvent);
|
||||
};
|
||||
|
||||
return EditTextWidget;
|
||||
EditTextWidget.prototype.cloneEvent = function(event,propertiesToCopy) {
|
||||
var propertiesToCopy = propertiesToCopy || [],
|
||||
newEvent = this.document.createEventObject ? this.document.createEventObject() : this.document.createEvent("Events");
|
||||
if(newEvent.initEvent) {
|
||||
newEvent.initEvent(event.type, true, true);
|
||||
}
|
||||
$tw.utils.each(propertiesToCopy,function(prop){
|
||||
newEvent[prop] = event[prop];
|
||||
});
|
||||
return newEvent;
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.dispatchDOMEvent = function(newEvent) {
|
||||
var dispatchNode = this.engine.iframeNode || this.engine.parentNode;
|
||||
return dispatchNode.dispatchEvent(newEvent);
|
||||
};
|
||||
|
||||
/*
|
||||
Propogate drag and drop events with File data to our container for the dropzone widgets benefit.
|
||||
If there are no Files, let the browser handle it.
|
||||
*/
|
||||
EditTextWidget.prototype.handleDropEvent = function(event) {
|
||||
if(event.dataTransfer.files.length) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
||||
}
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.handlePasteEvent = function(event) {
|
||||
if(event.clipboardData.files.length) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.dispatchDOMEvent(this.cloneEvent(event,["clipboardData"]));
|
||||
}
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.handleDragEnterEvent = function(event) {
|
||||
if($tw.utils.dragEventContainsFiles(event)) {
|
||||
// Ignore excessive events fired by FF when entering and leaving text nodes in a text area.
|
||||
if( event.relatedTarget && (event.relatedTarget.nodeType === 3 || event.target === event.relatedTarget)) {
|
||||
return true;
|
||||
}
|
||||
event.preventDefault();
|
||||
return this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.handleDragOverEvent = function(event) {
|
||||
if($tw.utils.dragEventContainsFiles(event)) {
|
||||
// Call preventDefault() in browsers that default to not allowing drop events on textarea
|
||||
if($tw.browser.isFirefox || $tw.browser.isIE) {
|
||||
event.preventDefault();
|
||||
}
|
||||
event.dataTransfer.dropEffect = "copy";
|
||||
return this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.handleDragLeaveEvent = function(event) {
|
||||
// Ignore excessive events fired by FF when entering and leaving text nodes in a text area.
|
||||
if(event.relatedTarget && ((event.relatedTarget.nodeType === 3) || (event.target === event.relatedTarget))) {
|
||||
return true;
|
||||
}
|
||||
event.preventDefault();
|
||||
this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.handleDragEndEvent = function(event) {
|
||||
this.dispatchDOMEvent(this.cloneEvent(event));
|
||||
};
|
||||
|
||||
EditTextWidget.prototype.handleClickEvent = function(event) {
|
||||
return !this.dispatchDOMEvent(this.cloneEvent(event));
|
||||
};
|
||||
|
||||
return EditTextWidget;
|
||||
}
|
||||
|
||||
exports.editTextWidgetFactory = editTextWidgetFactory;
|
||||
|
||||
23
core/modules/editor/operations/text/insert-text.js
Normal file
23
core/modules/editor/operations/text/insert-text.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/*\
|
||||
title: $:/core/modules/editor/operations/text/insert-text.js
|
||||
type: application/javascript
|
||||
module-type: texteditoroperation
|
||||
|
||||
Text editor operation insert text at the caret position. If there is a selection it is replaced.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports["insert-text"] = function(event,operation) {
|
||||
operation.replacement = event.paramObject.text;
|
||||
operation.cutStart = operation.selStart;
|
||||
operation.cutEnd = operation.selEnd;
|
||||
operation.newSelStart = operation.selStart + operation.replacement.length;
|
||||
operation.newSelEnd = operation.newSelStart;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -18,7 +18,7 @@ Export our filter prefix function
|
||||
*/
|
||||
exports.all = function(operationSubFunction) {
|
||||
return function(results,source,widget) {
|
||||
Array.prototype.push.apply(results,operationSubFunction(source,widget));
|
||||
results.push.apply(results, operationSubFunction(source,widget));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@ Equivalent to + filter run prefix.
|
||||
/*
|
||||
Export our filter prefix function
|
||||
*/
|
||||
exports.and = function(operationSubFunction) {
|
||||
exports.and = function(operationSubFunction,options) {
|
||||
return function(results,source,widget) {
|
||||
// This replaces all the elements of the array, but keeps the actual array so that references to it are preserved
|
||||
source = $tw.wiki.makeTiddlerIterator(results);
|
||||
results.splice(0,results.length);
|
||||
$tw.utils.pushTop(results,operationSubFunction(source,widget));
|
||||
source = options.wiki.makeTiddlerIterator(results.toArray());
|
||||
results.clear();
|
||||
results.pushTop(operationSubFunction(source,widget));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ exports.else = function(operationSubFunction) {
|
||||
return function(results,source,widget) {
|
||||
if(results.length === 0) {
|
||||
// Main result so far is empty
|
||||
$tw.utils.pushTop(results,operationSubFunction(source,widget));
|
||||
results.pushTop(operationSubFunction(source,widget));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ Export our filter prefix function
|
||||
*/
|
||||
exports.except = function(operationSubFunction) {
|
||||
return function(results,source,widget) {
|
||||
$tw.utils.removeArrayEntries(results,operationSubFunction(source,widget));
|
||||
results.remove(operationSubFunction(source,widget));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -13,17 +13,28 @@ module-type: filterrunprefix
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.filter = function(operationSubFunction) {
|
||||
exports.filter = function(operationSubFunction,options) {
|
||||
return function(results,source,widget) {
|
||||
if(results.length > 0) {
|
||||
var resultsToRemove = [];
|
||||
$tw.utils.each(results,function(result) {
|
||||
var filtered = operationSubFunction($tw.wiki.makeTiddlerIterator([result]),widget);
|
||||
results.each(function(title) {
|
||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return widget.getVariable(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
if(filtered.length === 0) {
|
||||
resultsToRemove.push(result);
|
||||
resultsToRemove.push(title);
|
||||
}
|
||||
});
|
||||
$tw.utils.removeArrayEntries(results,resultsToRemove);
|
||||
results.remove(resultsToRemove);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,8 @@ exports.intersection = function(operationSubFunction) {
|
||||
return function(results,source,widget) {
|
||||
if(results.length !== 0) {
|
||||
var secondRunResults = operationSubFunction(source,widget);
|
||||
var firstRunResults = results.splice(0);
|
||||
var firstRunResults = results.toArray();
|
||||
results.clear();
|
||||
$tw.utils.each(firstRunResults,function(title) {
|
||||
if(secondRunResults.indexOf(title) !== -1) {
|
||||
results.push(title);
|
||||
@@ -27,4 +28,4 @@ exports.intersection = function(operationSubFunction) {
|
||||
};
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
39
core/modules/filterrunprefixes/map.js
Normal file
39
core/modules/filterrunprefixes/map.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/*\
|
||||
title: $:/core/modules/filterrunprefixes/map.js
|
||||
type: application/javascript
|
||||
module-type: filterrunprefix
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter prefix function
|
||||
*/
|
||||
exports.map = function(operationSubFunction,options) {
|
||||
return function(results,source,widget) {
|
||||
if(results.length > 0) {
|
||||
var inputTitles = results.toArray();
|
||||
results.clear();
|
||||
$tw.utils.each(inputTitles,function(title) {
|
||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return widget.getVariable(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
results.push(filtered[0] || "");
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -17,7 +17,7 @@ Export our filter prefix function
|
||||
*/
|
||||
exports.or = function(operationSubFunction) {
|
||||
return function(results,source,widget) {
|
||||
$tw.utils.pushTop(results,operationSubFunction(source,widget));
|
||||
results.pushTop(operationSubFunction(source,widget));
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
52
core/modules/filterrunprefixes/reduce.js
Normal file
52
core/modules/filterrunprefixes/reduce.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/*\
|
||||
title: $:/core/modules/filterrunprefixes/reduce.js
|
||||
type: application/javascript
|
||||
module-type: filterrunprefix
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter prefix function
|
||||
*/
|
||||
exports.reduce = function(operationSubFunction,options) {
|
||||
return function(results,source,widget) {
|
||||
if(results.length > 0) {
|
||||
var accumulator = "";
|
||||
var index = 0;
|
||||
results.each(function(title) {
|
||||
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return widget.getVariable("currentTiddler");
|
||||
case "accumulator":
|
||||
return "" + accumulator;
|
||||
case "index":
|
||||
return "" + index;
|
||||
case "revIndex":
|
||||
return "" + (results.length - 1 - index);
|
||||
case "length":
|
||||
return "" + results.length;
|
||||
default:
|
||||
return widget.getVariable(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
if(list.length > 0) {
|
||||
accumulator = "" + list[0];
|
||||
}
|
||||
++index;
|
||||
});
|
||||
results.clear();
|
||||
results.push(accumulator);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
60
core/modules/filterrunprefixes/sort.js
Normal file
60
core/modules/filterrunprefixes/sort.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/*\
|
||||
title: $:/core/modules/filterrunprefixes/sort.js
|
||||
type: application/javascript
|
||||
module-type: filterrunprefix
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter prefix function
|
||||
*/
|
||||
exports.sort = function(operationSubFunction,options) {
|
||||
return function(results,source,widget) {
|
||||
if(results.length > 0) {
|
||||
var suffixes = options.suffixes,
|
||||
sortType = (suffixes[0] && suffixes[0][0]) ? suffixes[0][0] : "string",
|
||||
invert = suffixes[1] ? (suffixes[1].indexOf("reverse") !== -1) : false,
|
||||
isCaseSensitive = suffixes[1] ? (suffixes[1].indexOf("casesensitive") !== -1) : false,
|
||||
inputTitles = results.toArray(),
|
||||
sortKeys = [],
|
||||
indexes = new Array(inputTitles.length),
|
||||
compareFn;
|
||||
results.each(function(title) {
|
||||
var key = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return widget.getVariable(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
sortKeys.push(key[0] || "");
|
||||
});
|
||||
results.clear();
|
||||
// Prepare an array of indexes to sort
|
||||
for(var t=0; t<inputTitles.length; t++) {
|
||||
indexes[t] = t;
|
||||
}
|
||||
// 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]);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -62,42 +62,60 @@ function parseFilterOperation(operators,filterString,p) {
|
||||
else if(operator.operator === "") {
|
||||
operator.operator = "title";
|
||||
}
|
||||
operator.operands = [];
|
||||
var parseOperand = function(bracketType) {
|
||||
var operand = {};
|
||||
switch (bracketType) {
|
||||
case "{": // Curly brackets
|
||||
operand.indirect = true;
|
||||
nextBracketPos = filterString.indexOf("}",p);
|
||||
break;
|
||||
case "[": // Square brackets
|
||||
nextBracketPos = filterString.indexOf("]",p);
|
||||
break;
|
||||
case "<": // Angle brackets
|
||||
operand.variable = true;
|
||||
nextBracketPos = filterString.indexOf(">",p);
|
||||
break;
|
||||
case "/": // regexp brackets
|
||||
var rex = /^((?:[^\\\/]|\\.)*)\/(?:\(([mygi]+)\))?/g,
|
||||
rexMatch = rex.exec(filterString.substring(p));
|
||||
if(rexMatch) {
|
||||
operator.regexp = new RegExp(rexMatch[1], rexMatch[2]);
|
||||
// DEPRECATION WARNING
|
||||
console.log("WARNING: Filter",operator.operator,"has a deprecated regexp operand",operator.regexp);
|
||||
nextBracketPos = p + rex.lastIndex - 1;
|
||||
}
|
||||
else {
|
||||
throw "Unterminated regular expression in filter expression";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(nextBracketPos === -1) {
|
||||
throw "Missing closing bracket in filter expression";
|
||||
}
|
||||
if(!operator.regexp) {
|
||||
operand.text = filterString.substring(p,nextBracketPos);
|
||||
operator.operands.push(operand);
|
||||
}
|
||||
p = nextBracketPos + 1;
|
||||
}
|
||||
|
||||
p = nextBracketPos + 1;
|
||||
switch (bracket) {
|
||||
case "{": // Curly brackets
|
||||
operator.indirect = true;
|
||||
nextBracketPos = filterString.indexOf("}",p);
|
||||
break;
|
||||
case "[": // Square brackets
|
||||
nextBracketPos = filterString.indexOf("]",p);
|
||||
break;
|
||||
case "<": // Angle brackets
|
||||
operator.variable = true;
|
||||
nextBracketPos = filterString.indexOf(">",p);
|
||||
break;
|
||||
case "/": // regexp brackets
|
||||
var rex = /^((?:[^\\\/]*|\\.)*)\/(?:\(([mygi]+)\))?/g,
|
||||
rexMatch = rex.exec(filterString.substring(p));
|
||||
if(rexMatch) {
|
||||
operator.regexp = new RegExp(rexMatch[1], rexMatch[2]);
|
||||
// DEPRECATION WARNING
|
||||
console.log("WARNING: Filter",operator.operator,"has a deprecated regexp operand",operator.regexp);
|
||||
nextBracketPos = p + rex.lastIndex - 1;
|
||||
}
|
||||
else {
|
||||
throw "Unterminated regular expression in filter expression";
|
||||
}
|
||||
break;
|
||||
}
|
||||
parseOperand(bracket);
|
||||
|
||||
if(nextBracketPos === -1) {
|
||||
throw "Missing closing bracket in filter expression";
|
||||
// Check for multiple operands
|
||||
while(filterString.charAt(p) === ",") {
|
||||
p++;
|
||||
if(/^[\[\{<\/]/.test(filterString.substring(p))) {
|
||||
nextBracketPos = p;
|
||||
p++;
|
||||
parseOperand(filterString.charAt(nextBracketPos));
|
||||
} else {
|
||||
throw "Missing [ in filter expression";
|
||||
}
|
||||
}
|
||||
if(!operator.regexp) {
|
||||
operator.operand = filterString.substring(p,nextBracketPos);
|
||||
}
|
||||
p = nextBracketPos + 1;
|
||||
|
||||
// Push this operator
|
||||
operators.push(operator);
|
||||
@@ -119,7 +137,7 @@ exports.parseFilter = function(filterString) {
|
||||
p = 0, // Current position in the filter string
|
||||
match;
|
||||
var whitespaceRegExp = /(\s+)/mg,
|
||||
operandRegExp = /((?:\+|\-|~|=|\:(\w+))?)(?:(\[)|(?:"([^"]*)")|(?:'([^']*)')|([^\s\[\]]+))/mg;
|
||||
operandRegExp = /((?:\+|\-|~|=|\:(\w+)(?:\:([\w\:, ]*))?)?)(?:(\[)|(?:"([^"]*)")|(?:'([^']*)')|([^\s\[\]]+))/mg;
|
||||
while(p < filterString.length) {
|
||||
// Skip any whitespace
|
||||
whitespaceRegExp.lastIndex = p;
|
||||
@@ -144,15 +162,27 @@ exports.parseFilter = function(filterString) {
|
||||
if(match[2]) {
|
||||
operation.namedPrefix = match[2];
|
||||
}
|
||||
if(match[3]) {
|
||||
operation.suffixes = [];
|
||||
$tw.utils.each(match[3].split(":"),function(subsuffix) {
|
||||
operation.suffixes.push([]);
|
||||
$tw.utils.each(subsuffix.split(","),function(entry) {
|
||||
entry = $tw.utils.trim(entry);
|
||||
if(entry) {
|
||||
operation.suffixes[operation.suffixes.length -1].push(entry);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if(match[3]) { // Opening square bracket
|
||||
if(match[4]) { // Opening square bracket
|
||||
p = parseFilterOperation(operation.operators,filterString,p);
|
||||
} else {
|
||||
p = match.index + match[0].length;
|
||||
}
|
||||
if(match[4] || match[5] || match[6]) { // Double quoted string, single quoted string or unquoted title
|
||||
if(match[5] || match[6] || match[7]) { // Double quoted string, single quoted string or unquoted title
|
||||
operation.operators.push(
|
||||
{operator: "title", operand: match[4] || match[5] || match[6]}
|
||||
{operator: "title", operands: [{text: match[5] || match[6] || match[7]}]}
|
||||
);
|
||||
}
|
||||
results.push(operation);
|
||||
@@ -170,7 +200,7 @@ exports.getFilterOperators = function() {
|
||||
};
|
||||
|
||||
exports.getFilterRunPrefixes = function() {
|
||||
if(!this.filterPrefixes) {
|
||||
if(!this.filterRunPrefixes) {
|
||||
$tw.Wiki.prototype.filterRunPrefixes = {};
|
||||
$tw.modules.applyMethods("filterrunprefix",this.filterRunPrefixes);
|
||||
}
|
||||
@@ -209,7 +239,7 @@ exports.compileFilter = function(filterString) {
|
||||
results = [],
|
||||
currTiddlerTitle = widget && widget.getVariable("currentTiddler");
|
||||
$tw.utils.each(operation.operators,function(operator) {
|
||||
var operand = operator.operand,
|
||||
var operands = [],
|
||||
operatorFunction;
|
||||
if(!operator.operator) {
|
||||
operatorFunction = filterOperators.title;
|
||||
@@ -218,16 +248,24 @@ exports.compileFilter = function(filterString) {
|
||||
} else {
|
||||
operatorFunction = filterOperators[operator.operator];
|
||||
}
|
||||
if(operator.indirect) {
|
||||
operand = self.getTextReference(operator.operand,"",currTiddlerTitle);
|
||||
}
|
||||
if(operator.variable) {
|
||||
operand = widget.getVariable(operator.operand,{defaultValue: ""});
|
||||
}
|
||||
|
||||
$tw.utils.each(operator.operands,function(operand) {
|
||||
if(operand.indirect) {
|
||||
operand.value = self.getTextReference(operand.text,"",currTiddlerTitle);
|
||||
} else if(operand.variable) {
|
||||
var varTree = $tw.utils.parseFilterVariable(operand.text);
|
||||
operand.value = widget.getVariable(varTree.name,{params:varTree.params,defaultValue: ""});
|
||||
} else {
|
||||
operand.value = operand.text;
|
||||
}
|
||||
operands.push(operand.value);
|
||||
});
|
||||
|
||||
// Invoke the appropriate filteroperator module
|
||||
results = operatorFunction(accumulator,{
|
||||
operator: operator.operator,
|
||||
operand: operand,
|
||||
operand: operands.length > 0 ? operands[0] : undefined,
|
||||
operands: operands,
|
||||
prefix: operator.prefix,
|
||||
suffix: operator.suffix,
|
||||
suffixes: operator.suffixes,
|
||||
@@ -255,23 +293,24 @@ exports.compileFilter = function(filterString) {
|
||||
var filterRunPrefixes = self.getFilterRunPrefixes();
|
||||
// Wrap the operator functions in a wrapper function that depends on the prefix
|
||||
operationFunctions.push((function() {
|
||||
var options = {wiki: self, suffixes: operation.suffixes || []};
|
||||
switch(operation.prefix || "") {
|
||||
case "": // No prefix means that the operation is unioned into the result
|
||||
return filterRunPrefixes["or"](operationSubFunction);
|
||||
return filterRunPrefixes["or"](operationSubFunction, options);
|
||||
case "=": // The results of the operation are pushed into the result without deduplication
|
||||
return filterRunPrefixes["all"](operationSubFunction);
|
||||
return filterRunPrefixes["all"](operationSubFunction, options);
|
||||
case "-": // The results of this operation are removed from the main result
|
||||
return filterRunPrefixes["except"](operationSubFunction);
|
||||
return filterRunPrefixes["except"](operationSubFunction, options);
|
||||
case "+": // This operation is applied to the main results so far
|
||||
return filterRunPrefixes["and"](operationSubFunction);
|
||||
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);
|
||||
return filterRunPrefixes["else"](operationSubFunction, options);
|
||||
default:
|
||||
if(operation.namedPrefix && filterRunPrefixes[operation.namedPrefix]) {
|
||||
return filterRunPrefixes[operation.namedPrefix](operationSubFunction);
|
||||
return filterRunPrefixes[operation.namedPrefix](operationSubFunction, options);
|
||||
} else {
|
||||
return function(results,source,widget) {
|
||||
results.splice(0,results.length);
|
||||
results.clear();
|
||||
results.push($tw.language.getString("Error/FilterRunPrefix"));
|
||||
};
|
||||
}
|
||||
@@ -285,11 +324,14 @@ exports.compileFilter = function(filterString) {
|
||||
} else if(typeof source === "object") { // Array or hashmap
|
||||
source = self.makeTiddlerIterator(source);
|
||||
}
|
||||
var results = [];
|
||||
if(!widget) {
|
||||
widget = $tw.rootWidget;
|
||||
}
|
||||
var results = new $tw.utils.LinkedList();
|
||||
$tw.utils.each(operationFunctions,function(operationFunction) {
|
||||
operationFunction(results,source,widget);
|
||||
});
|
||||
return results;
|
||||
return results.toArray();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ exports.all = function(source,operator,options) {
|
||||
// Get our suboperators
|
||||
var allFilterOperators = getAllFilterOperators();
|
||||
// Cycle through the suboperators accumulating their results
|
||||
var results = [],
|
||||
var results = new $tw.utils.LinkedList(),
|
||||
subops = operator.operand.split("+");
|
||||
// Check for common optimisations
|
||||
if(subops.length === 1 && subops[0] === "") {
|
||||
@@ -49,10 +49,10 @@ exports.all = function(source,operator,options) {
|
||||
for(var t=0; t<subops.length; t++) {
|
||||
var subop = allFilterOperators[subops[t]];
|
||||
if(subop) {
|
||||
$tw.utils.pushTop(results,subop(source,operator.prefix,options));
|
||||
results.pushTop(subop(source,operator.prefix,options));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
return results.toArray();
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -17,7 +17,7 @@ Export our filter function
|
||||
*/
|
||||
exports.contains = function(source,operator,options) {
|
||||
var results = [],
|
||||
fieldname = (operator.suffix || "list").toLowerCase();
|
||||
fieldname = operator.suffix || "list";
|
||||
if(operator.prefix === "!") {
|
||||
source(function(tiddler,title) {
|
||||
if(tiddler) {
|
||||
|
||||
27
core/modules/filters/deserializers.js
Normal file
27
core/modules/filters/deserializers.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/deserializers.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the names of the deserializers in this wiki
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.deserializers = function(source,operator,options) {
|
||||
var results = [];
|
||||
$tw.utils.each($tw.Wiki.tiddlerDeserializerModules,function(deserializer,type) {
|
||||
results.push(type);
|
||||
});
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -16,14 +16,16 @@ Filter operator for returning the descriptions of the specified edition names
|
||||
Export our filter function
|
||||
*/
|
||||
exports.editiondescription = function(source,operator,options) {
|
||||
var results = [],
|
||||
editionInfo = $tw.utils.getEditionInfo();
|
||||
if(editionInfo) {
|
||||
source(function(tiddler,title) {
|
||||
if($tw.utils.hop(editionInfo,title)) {
|
||||
results.push(editionInfo[title].description || "");
|
||||
}
|
||||
});
|
||||
var results = [];
|
||||
if($tw.node) {
|
||||
var editionInfo = $tw.utils.getEditionInfo();
|
||||
if(editionInfo) {
|
||||
source(function(tiddler,title) {
|
||||
if($tw.utils.hop(editionInfo,title)) {
|
||||
results.push(editionInfo[title].description || "");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -16,14 +16,16 @@ Filter operator for returning the names of the available editions in this wiki
|
||||
Export our filter function
|
||||
*/
|
||||
exports.editions = function(source,operator,options) {
|
||||
var results = [],
|
||||
editionInfo = $tw.utils.getEditionInfo();
|
||||
if(editionInfo) {
|
||||
$tw.utils.each(editionInfo,function(info,name) {
|
||||
results.push(name);
|
||||
});
|
||||
var results = [];
|
||||
if($tw.node) {
|
||||
var editionInfo = $tw.utils.getEditionInfo();
|
||||
if(editionInfo) {
|
||||
$tw.utils.each(editionInfo,function(info,name) {
|
||||
results.push(name);
|
||||
});
|
||||
}
|
||||
results.sort();
|
||||
}
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ exports.encodehtml = function(source,operator,options) {
|
||||
exports.stringify = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.stringify(title));
|
||||
results.push($tw.utils.stringify(title,(operator.suffix === "rawunicode")));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
@@ -85,7 +85,7 @@ exports.stringify = function(source,operator,options) {
|
||||
exports.jsonstringify = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.jsonStringify(title));
|
||||
results.push($tw.utils.jsonStringify(title,(operator.suffix === "rawunicode")));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
@@ -102,7 +102,7 @@ exports.escapecss = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
// escape any character with a special meaning in CSS using CSS.escape()
|
||||
results.push(CSS.escape(title));
|
||||
results.push($tw.utils.escapeCSS(title));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ Export our filter function
|
||||
*/
|
||||
exports.field = function(source,operator,options) {
|
||||
var results = [],indexedResults,
|
||||
fieldname = (operator.suffix || operator.operator || "title").toLowerCase();
|
||||
fieldname = operator.suffix || operator.operator || "title";
|
||||
if(operator.prefix === "!") {
|
||||
if(operator.regexp) {
|
||||
source(function(tiddler,title) {
|
||||
|
||||
@@ -20,7 +20,7 @@ exports.fields = function(source,operator,options) {
|
||||
fieldName,
|
||||
suffixes = (operator.suffixes || [])[0] || [],
|
||||
operand = $tw.utils.parseStringArray(operator.operand);
|
||||
|
||||
|
||||
source(function(tiddler,title) {
|
||||
if(tiddler) {
|
||||
if(suffixes.indexOf("include") !== -1) {
|
||||
|
||||
@@ -20,7 +20,18 @@ exports.filter = function(source,operator,options) {
|
||||
results = [],
|
||||
target = operator.prefix !== "!";
|
||||
source(function(tiddler,title) {
|
||||
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]));
|
||||
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),{
|
||||
getVariable: function(name) {
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return options.widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return options.widget.getVariable(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
if((list.length > 0) === target) {
|
||||
results.push(title);
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ module-type: formatfilteroperator
|
||||
Export our filter function
|
||||
*/
|
||||
exports.date = function(source,operand,options) {
|
||||
var results = [];
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
var value = $tw.utils.parseDate(title);
|
||||
if(value && $tw.utils.isDate(value) && value.toString() !== "Invalid Date") {
|
||||
results.push($tw.utils.formatDateString(value,operand || "YYYY MM DD 0hh:0mm"));
|
||||
}
|
||||
});
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ module-type: formatfilteroperator
|
||||
Export our filter function
|
||||
*/
|
||||
exports.relativedate = function(source,operand,options) {
|
||||
var results = [];
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
var value = $tw.utils.parseDate(title);
|
||||
if(value && $tw.utils.isDate(value) && value.toString() !== "Invalid Date") {
|
||||
results.push($tw.utils.getRelativeDate((new Date()) - (new Date(value))).description);
|
||||
}
|
||||
});
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
25
core/modules/filters/format/titlelist.js
Normal file
25
core/modules/filters/format/titlelist.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/format/titlelist.js
|
||||
type: application/javascript
|
||||
module-type: formatfilteroperator
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.titlelist = function(source,operand,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
if(title && title.length) {
|
||||
results.push($tw.utils.stringifyList([title]));
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -61,7 +61,7 @@ exports.has = function(source,operator,options) {
|
||||
if(tiddler && $tw.utils.hop(tiddler.fields,operator.operand) && (tiddler.fields[operator.operand].length !== 0)) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
||||
36
core/modules/filters/is/draft.js
Normal file
36
core/modules/filters/is/draft.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/is/draft.js
|
||||
type: application/javascript
|
||||
module-type: isfilteroperator
|
||||
|
||||
Filter function for [is[draft]] analagous to [has[draft.of]]
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.draft = function(source,prefix,options) {
|
||||
var results = [];
|
||||
if(prefix === "!") {
|
||||
source(function(tiddler,title) {
|
||||
if(!tiddler || !$tw.utils.hop(tiddler.fields,"draft.of")) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
source(function(tiddler,title) {
|
||||
if(tiddler && $tw.utils.hop(tiddler.fields,"draft.of") && (tiddler.fields["draft.of"].length !== 0)) {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -16,11 +16,11 @@ Filter operator for returning all the links from a tiddler
|
||||
Export our filter function
|
||||
*/
|
||||
exports.links = function(source,operator,options) {
|
||||
var results = [];
|
||||
var results = new $tw.utils.LinkedList();
|
||||
source(function(tiddler,title) {
|
||||
$tw.utils.pushTop(results,options.wiki.getTiddlerLinks(title));
|
||||
results.pushTop(options.wiki.getTiddlerLinks(title));
|
||||
});
|
||||
return results;
|
||||
return results.toArray();
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -22,7 +22,7 @@ Export our filter function
|
||||
exports.lookup = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push(options.wiki.getTiddlerText(operator.operand + title) || options.wiki.getTiddlerText(operator.operand + operator.suffix));
|
||||
results.push(options.wiki.getTiddlerText(operator.operand + title) || operator.suffix || '');
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -91,6 +91,20 @@ exports.exponential = makeNumericBinaryOperator(
|
||||
function(a,b) {return Number.prototype.toExponential.call(a,Math.min(Math.max(b,0),100));}
|
||||
);
|
||||
|
||||
exports.power = makeNumericBinaryOperator(
|
||||
function(a,b) {return Math.pow(a,b);}
|
||||
);
|
||||
|
||||
exports.log = makeNumericBinaryOperator(
|
||||
function(a,b) {
|
||||
if(b) {
|
||||
return Math.log(a)/Math.log(b);
|
||||
} else {
|
||||
return Math.log(a);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
exports.sum = makeNumericReducingOperator(
|
||||
function(accumulator,value) {return accumulator + value},
|
||||
0 // Initial value
|
||||
@@ -111,6 +125,54 @@ exports.minall = makeNumericReducingOperator(
|
||||
Infinity // Initial value
|
||||
);
|
||||
|
||||
exports.median = makeNumericArrayOperator(
|
||||
function(values) {
|
||||
var len = values.length, median;
|
||||
values.sort();
|
||||
if(len % 2) {
|
||||
// Odd, return the middle number
|
||||
median = values[(len - 1) / 2];
|
||||
} else {
|
||||
// Even, return average of two middle numbers
|
||||
median = (values[len / 2 - 1] + values[len / 2]) / 2;
|
||||
}
|
||||
return [median];
|
||||
}
|
||||
);
|
||||
|
||||
exports.average = makeNumericReducingOperator(
|
||||
function(accumulator,value) {return accumulator + value},
|
||||
0, // Initial value
|
||||
function(finalValue,numberOfValues) {
|
||||
return finalValue/numberOfValues;
|
||||
}
|
||||
);
|
||||
|
||||
exports.variance = makeNumericReducingOperator(
|
||||
function(accumulator,value) {return accumulator + value},
|
||||
0,
|
||||
function(finalValue,numberOfValues,originalValues) {
|
||||
return getVarianceFromArray(originalValues,finalValue/numberOfValues);
|
||||
}
|
||||
);
|
||||
|
||||
exports["standard-deviation"] = makeNumericReducingOperator(
|
||||
function(accumulator,value) {return accumulator + value},
|
||||
0,
|
||||
function(finalValue,numberOfValues,originalValues) {
|
||||
var variance = getVarianceFromArray(originalValues,finalValue/numberOfValues);
|
||||
return Math.sqrt(variance);
|
||||
}
|
||||
);
|
||||
|
||||
//Calculate the variance of a population of numbers in an array given its mean
|
||||
function getVarianceFromArray(values,mean) {
|
||||
var deviationTotal = values.reduce(function(accumulator,value) {
|
||||
return accumulator + Math.pow(value - mean, 2);
|
||||
},0);
|
||||
return deviationTotal/values.length;
|
||||
};
|
||||
|
||||
function makeNumericBinaryOperator(fnCalc) {
|
||||
return function(source,operator,options) {
|
||||
var result = [],
|
||||
@@ -120,19 +182,37 @@ function makeNumericBinaryOperator(fnCalc) {
|
||||
});
|
||||
return result;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function makeNumericReducingOperator(fnCalc,initialValue) {
|
||||
function makeNumericReducingOperator(fnCalc,initialValue,fnFinal) {
|
||||
initialValue = initialValue || 0;
|
||||
return function(source,operator,options) {
|
||||
var result = [];
|
||||
source(function(tiddler,title) {
|
||||
result.push(title);
|
||||
result.push($tw.utils.parseNumber(title));
|
||||
});
|
||||
return [$tw.utils.stringifyNumber(result.reduce(function(accumulator,currentValue) {
|
||||
return fnCalc(accumulator,$tw.utils.parseNumber(currentValue));
|
||||
},initialValue))];
|
||||
var value = result.reduce(function(accumulator,currentValue) {
|
||||
return fnCalc(accumulator,currentValue);
|
||||
},initialValue);
|
||||
if(fnFinal) {
|
||||
value = fnFinal(value,result.length,result);
|
||||
}
|
||||
return [$tw.utils.stringifyNumber(value)];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function makeNumericArrayOperator(fnCalc) {
|
||||
return function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.parseNumber(title));
|
||||
});
|
||||
results = fnCalc(results);
|
||||
$tw.utils.each(results,function(value,index) {
|
||||
results[index] = $tw.utils.stringifyNumber(value);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
30
core/modules/filters/moduleproperty.js
Normal file
30
core/modules/filters/moduleproperty.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/moduleproperty.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter [[module-name]moduleproperty[name]] retrieve a module property
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.moduleproperty = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
var value = require(title)[operator.operand || ""];
|
||||
if(value !== undefined) {
|
||||
results.push(value);
|
||||
}
|
||||
});
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -17,11 +17,23 @@ Export our filter function
|
||||
*/
|
||||
exports.modules = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
||||
results.push(moduleName);
|
||||
if(operator.operands.length === 1) {
|
||||
// Return all the module names without filtering
|
||||
source(function(tiddler,title) {
|
||||
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
||||
results.push(moduleName);
|
||||
});
|
||||
});
|
||||
});
|
||||
} else if(operator.operands.length >= 2) {
|
||||
// Return the modules that have the module property specified in the first operand with the value in the second operand
|
||||
source(function(tiddler,title) {
|
||||
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
||||
if(require(moduleName)[operator.operands[0]] === operator.operands[1]) {
|
||||
results.push(moduleName);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
30
core/modules/filters/modulestring.js
Normal file
30
core/modules/filters/modulestring.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/modulestring.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter [[module-name]modulestring[en-gb]] retrieve a module strings in a particular language
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.modulestring = function(source,operator,options) {
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
var s = $tw.modules.getModuleString(title,operator.operands[0] || "",operator.operands[1] || "");
|
||||
if(s !== null) {
|
||||
results.push(s);
|
||||
}
|
||||
});
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -23,7 +23,7 @@ exports.reduce = function(source,operator,options) {
|
||||
});
|
||||
// Run the filter over each item
|
||||
var filterFn = options.wiki.compileFilter(operator.operand),
|
||||
accumulator = operator.suffix || "";
|
||||
accumulator = operator.operands[1] || "";
|
||||
for(var index=0; index<results.length; index++) {
|
||||
var title = results[index],
|
||||
list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),{
|
||||
@@ -31,6 +31,8 @@ exports.reduce = function(source,operator,options) {
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return options.widget.getVariable("currentTiddler");
|
||||
case "accumulator":
|
||||
return "" + accumulator;
|
||||
case "index":
|
||||
@@ -48,7 +50,11 @@ exports.reduce = function(source,operator,options) {
|
||||
accumulator = "" + list[0];
|
||||
}
|
||||
}
|
||||
return [accumulator];
|
||||
if(results.length > 0) {
|
||||
return [accumulator];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -17,7 +17,7 @@ Export our filter function
|
||||
*/
|
||||
exports.regexp = function(source,operator,options) {
|
||||
var results = [],
|
||||
fieldname = (operator.suffix || "title").toLowerCase(),
|
||||
fieldname = operator.suffix || "title",
|
||||
regexpString, regexp, flags = "", match,
|
||||
getFieldString = function(tiddler,title) {
|
||||
if(tiddler) {
|
||||
|
||||
@@ -27,10 +27,13 @@ exports.sortsub = function(source,operator,options) {
|
||||
iterator(options.wiki.getTiddler(title),title);
|
||||
},{
|
||||
getVariable: function(name) {
|
||||
if(name === "currentTiddler") {
|
||||
return title;
|
||||
} else {
|
||||
return options.widget.getVariable(name);
|
||||
switch(name) {
|
||||
case "currentTiddler":
|
||||
return "" + title;
|
||||
case "..currentTiddler":
|
||||
return options.widget.getVariable("currentTiddler");
|
||||
default:
|
||||
return options.widget.getVariable(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ exports.split = makeStringBinaryOperator(
|
||||
);
|
||||
|
||||
exports["enlist-input"] = makeStringBinaryOperator(
|
||||
function(a) {return $tw.utils.parseStringArray("" + a);}
|
||||
function(a,o,s) {return $tw.utils.parseStringArray("" + a,(s === "raw"));}
|
||||
);
|
||||
|
||||
exports.join = makeStringReducingOperator(
|
||||
@@ -78,7 +78,7 @@ function makeStringBinaryOperator(fnCalc) {
|
||||
return function(source,operator,options) {
|
||||
var result = [];
|
||||
source(function(tiddler,title) {
|
||||
Array.prototype.push.apply(result,fnCalc(title,operator.operand || ""));
|
||||
Array.prototype.push.apply(result,fnCalc(title,operator.operand || "",operator.suffix || ""));
|
||||
});
|
||||
return result;
|
||||
};
|
||||
@@ -105,14 +105,81 @@ exports.splitregexp = function(source,operator,options) {
|
||||
flags = (suffix.indexOf("m") !== -1 ? "m" : "") + (suffix.indexOf("i") !== -1 ? "i" : ""),
|
||||
regExp;
|
||||
try {
|
||||
regExp = new RegExp(operator.operand || "",flags);
|
||||
regExp = new RegExp(operator.operand || "",flags);
|
||||
} catch(ex) {
|
||||
return ["RegExp error: " + ex];
|
||||
}
|
||||
source(function(tiddler,title) {
|
||||
Array.prototype.push.apply(result,title.split(regExp));
|
||||
});
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
exports["search-replace"] = function(source,operator,options) {
|
||||
var results = [],
|
||||
suffixes = operator.suffixes || [],
|
||||
flagSuffix = (suffixes[0] ? (suffixes[0][0] || "") : ""),
|
||||
flags = (flagSuffix.indexOf("g") !== -1 ? "g" : "") + (flagSuffix.indexOf("i") !== -1 ? "i" : ""),
|
||||
isRegExp = (suffixes[1] && suffixes[1][0] === "regexp") ? true : false,
|
||||
searchTerm,
|
||||
regExp;
|
||||
|
||||
source(function(tiddler,title) {
|
||||
if(title && (operator.operands.length > 1)) {
|
||||
//Escape regexp characters if the operand is not a regular expression
|
||||
searchTerm = isRegExp ? operator.operand : $tw.utils.escapeRegExp(operator.operand);
|
||||
try {
|
||||
regExp = new RegExp(searchTerm,flags);
|
||||
} catch(ex) {
|
||||
return ["RegExp error: " + ex];
|
||||
}
|
||||
results.push(
|
||||
title.replace(regExp,operator.operands[1])
|
||||
);
|
||||
} else {
|
||||
results.push(title);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
exports.pad = function(source,operator,options) {
|
||||
var results = [],
|
||||
targetLength = operator.operand ? parseInt(operator.operand) : 0,
|
||||
fill = operator.operands[1] || "0";
|
||||
|
||||
source(function(tiddler,title) {
|
||||
if(title && title.length) {
|
||||
if(title.length >= targetLength) {
|
||||
results.push(title);
|
||||
} else {
|
||||
var padString = "",
|
||||
padStringLength = targetLength - title.length;
|
||||
while (padStringLength > padString.length) {
|
||||
padString += fill;
|
||||
}
|
||||
//make sure we do not exceed the specified length
|
||||
padString = padString.slice(0,padStringLength);
|
||||
if(operator.suffix && (operator.suffix === "suffix")) {
|
||||
title = title + padString;
|
||||
} else {
|
||||
title = padString + title;
|
||||
}
|
||||
results.push(title);
|
||||
}
|
||||
}
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
exports.charcode = function(source,operator,options) {
|
||||
var chars = [];
|
||||
$tw.utils.each(operator.operands,function(operand) {
|
||||
if(operand !== "") {
|
||||
chars.push(String.fromCharCode($tw.utils.parseInt(operand)));
|
||||
}
|
||||
});
|
||||
return [chars.join("")];
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -50,7 +50,7 @@ exports.tag = function(source,operator,options) {
|
||||
});
|
||||
results = options.wiki.sortByList(results,operator.operand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -8,183 +8,228 @@ Extended filter operators to manipulate the current list.
|
||||
\*/
|
||||
(function () {
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Fetch titles from the current list
|
||||
*/
|
||||
var prepare_results = function (source) {
|
||||
var results = [];
|
||||
source(function (tiddler, title) {
|
||||
results.push(title);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
/*
|
||||
Fetch titles from the current list
|
||||
*/
|
||||
var prepare_results = function (source) {
|
||||
var results = [];
|
||||
source(function (tiddler, title) {
|
||||
results.push(title);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
/*
|
||||
Moves a number of items from the tail of the current list before the item named in the operand
|
||||
*/
|
||||
exports.putbefore = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return (index === -1) ?
|
||||
results.slice(0, -1) :
|
||||
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 before the item named in the operand
|
||||
*/
|
||||
exports.putbefore = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return (index === -1) ?
|
||||
results.slice(0, -1) :
|
||||
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
|
||||
*/
|
||||
exports.putafter = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return (index === -1) ?
|
||||
results.slice(0, -1) :
|
||||
results.slice(0, index + 1).concat(results.slice(-count)).concat(results.slice(index + 1, -count));
|
||||
};
|
||||
/*
|
||||
Moves a number of items from the tail of the current list after the item named in the operand
|
||||
*/
|
||||
exports.putafter = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return (index === -1) ?
|
||||
results.slice(0, -1) :
|
||||
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
|
||||
*/
|
||||
exports.replace = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return (index === -1) ?
|
||||
results.slice(0, -count) :
|
||||
results.slice(0, index).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
|
||||
*/
|
||||
exports.replace = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return (index === -1) ?
|
||||
results.slice(0, -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
|
||||
*/
|
||||
exports.putfirst = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return results.slice(-count).concat(results.slice(0, -count));
|
||||
};
|
||||
/*
|
||||
Moves a number of items from the tail of the current list to the head of the list
|
||||
*/
|
||||
exports.putfirst = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return results.slice(-count).concat(results.slice(0, -count));
|
||||
};
|
||||
|
||||
/*
|
||||
Moves a number of items from the head of the current list to the tail of the list
|
||||
*/
|
||||
exports.putlast = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return results.slice(count).concat(results.slice(0, count));
|
||||
};
|
||||
/*
|
||||
Moves a number of items from the head of the current list to the tail of the list
|
||||
*/
|
||||
exports.putlast = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
count = $tw.utils.getInt(operator.suffix,1);
|
||||
return results.slice(count).concat(results.slice(0, count));
|
||||
};
|
||||
|
||||
/*
|
||||
Moves the item named in the operand a number of places forward or backward in the list
|
||||
*/
|
||||
exports.move = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1),
|
||||
marker = results.splice(index, 1),
|
||||
offset = (index + count) > 0 ? index + count : 0;
|
||||
return results.slice(0, offset).concat(marker).concat(results.slice(offset));
|
||||
};
|
||||
/*
|
||||
Moves the item named in the operand a number of places forward or backward in the list
|
||||
*/
|
||||
exports.move = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand),
|
||||
count = $tw.utils.getInt(operator.suffix,1),
|
||||
marker = results.splice(index, 1),
|
||||
offset = (index + count) > 0 ? index + count : 0;
|
||||
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
|
||||
*/
|
||||
exports.allafter = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand);
|
||||
return (index === -1) ? [] :
|
||||
(operator.suffix) ? results.slice(index) :
|
||||
results.slice(index + 1);
|
||||
};
|
||||
/*
|
||||
Returns the items from the current list that are after the item named in the operand
|
||||
*/
|
||||
exports.allafter = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand);
|
||||
return (index === -1) ? [] :
|
||||
(operator.suffix) ? results.slice(index) :
|
||||
results.slice(index + 1);
|
||||
};
|
||||
|
||||
/*
|
||||
Returns the items from the current list that are before the item named in the operand
|
||||
*/
|
||||
exports.allbefore = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand);
|
||||
return (index === -1) ? [] :
|
||||
(operator.suffix) ? results.slice(0, index + 1) :
|
||||
results.slice(0, index);
|
||||
};
|
||||
/*
|
||||
Returns the items from the current list that are before the item named in the operand
|
||||
*/
|
||||
exports.allbefore = function (source, operator) {
|
||||
var results = prepare_results(source),
|
||||
index = results.indexOf(operator.operand);
|
||||
return (index === -1) ? [] :
|
||||
(operator.suffix) ? results.slice(0, index + 1) :
|
||||
results.slice(0, index);
|
||||
};
|
||||
|
||||
/*
|
||||
Appends the items listed in the operand array to the tail of the current list
|
||||
*/
|
||||
exports.append = function (source, operator) {
|
||||
var append = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||
results = prepare_results(source),
|
||||
count = parseInt(operator.suffix) || append.length;
|
||||
return (append.length === 0) ? results :
|
||||
(operator.prefix) ? results.concat(append.slice(-count)) :
|
||||
results.concat(append.slice(0, count));
|
||||
};
|
||||
/*
|
||||
Appends the items listed in the operand array to the tail of the current list
|
||||
*/
|
||||
exports.append = function (source, operator) {
|
||||
var append = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||
results = prepare_results(source),
|
||||
count = parseInt(operator.suffix) || append.length;
|
||||
return (append.length === 0) ? results :
|
||||
(operator.prefix) ? results.concat(append.slice(-count)) :
|
||||
results.concat(append.slice(0, count));
|
||||
};
|
||||
|
||||
/*
|
||||
Prepends the items listed in the operand array to the head of the current list
|
||||
*/
|
||||
exports.prepend = function (source, operator) {
|
||||
var prepend = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||
results = prepare_results(source),
|
||||
count = $tw.utils.getInt(operator.suffix,prepend.length);
|
||||
return (prepend.length === 0) ? results :
|
||||
(operator.prefix) ? prepend.slice(-count).concat(results) :
|
||||
prepend.slice(0, count).concat(results);
|
||||
};
|
||||
/*
|
||||
Prepends the items listed in the operand array to the head of the current list
|
||||
*/
|
||||
exports.prepend = function (source, operator) {
|
||||
var prepend = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||
results = prepare_results(source),
|
||||
count = $tw.utils.getInt(operator.suffix,prepend.length);
|
||||
return (prepend.length === 0) ? results :
|
||||
(operator.prefix) ? prepend.slice(-count).concat(results) :
|
||||
prepend.slice(0, count).concat(results);
|
||||
};
|
||||
|
||||
/*
|
||||
Returns all items from the current list except the items listed in the operand array
|
||||
*/
|
||||
exports.remove = function (source, operator) {
|
||||
var array = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||
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;
|
||||
};
|
||||
/*
|
||||
Returns all items from the current list except the items listed in the operand array
|
||||
*/
|
||||
exports.remove = function (source, operator) {
|
||||
var array = $tw.utils.parseStringArray(operator.operand, "true"),
|
||||
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;
|
||||
};
|
||||
|
||||
/*
|
||||
Returns all items from the current list sorted in the order of the items in the operand array
|
||||
*/
|
||||
exports.sortby = function (source, operator) {
|
||||
var results = prepare_results(source);
|
||||
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;
|
||||
};
|
||||
/*
|
||||
Returns all items from the current list sorted in the order of the items in the operand array
|
||||
*/
|
||||
exports.sortby = function (source, operator) {
|
||||
var results = prepare_results(source);
|
||||
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;
|
||||
};
|
||||
|
||||
/*
|
||||
Removes all duplicate items from the current list
|
||||
*/
|
||||
exports.unique = function (source, operator) {
|
||||
var results = 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) {
|
||||
var resultsIndex,
|
||||
step = stepSize || 1,
|
||||
i = 0,
|
||||
opLength = operands.length,
|
||||
nextOperandIndex;
|
||||
for(i; i < opLength; i++) {
|
||||
resultsIndex = results.indexOf(operands[i]);
|
||||
if(resultsIndex !== -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(resultsIndex !== -1) {
|
||||
i = i + step;
|
||||
nextOperandIndex = (i < opLength ? i : i - opLength);
|
||||
if(operands.length > 1) {
|
||||
results.splice(resultsIndex,1,operands[nextOperandIndex]);
|
||||
} else {
|
||||
results.splice(resultsIndex,1);
|
||||
}
|
||||
} else {
|
||||
results.push(operands[0]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/*
|
||||
Toggles an item in the current list.
|
||||
*/
|
||||
exports.toggle = function(source,operator) {
|
||||
return cycleValueInArray(prepare_results(source),operator.operands);
|
||||
}
|
||||
|
||||
exports.cycle = function(source,operator) {
|
||||
var results = prepare_results(source),
|
||||
operands = (operator.operand.length ? $tw.utils.parseStringArray(operator.operand, "true") : [""]),
|
||||
step = $tw.utils.getInt(operator.operands[1]||"",1);
|
||||
if(step < 0) {
|
||||
operands.reverse();
|
||||
step = Math.abs(step);
|
||||
}
|
||||
return cycleValueInArray(results,operands,step);
|
||||
}
|
||||
|
||||
/*
|
||||
Removes all duplicate items from the current list
|
||||
*/
|
||||
exports.unique = function (source, operator) {
|
||||
var results = prepare_results(source);
|
||||
var set = results.reduce(function (a, b) {
|
||||
if (a.indexOf(b) < 0) {
|
||||
a.push(b);
|
||||
}
|
||||
return a;
|
||||
}, []);
|
||||
return set;
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -121,7 +121,7 @@ FieldIndexer.prototype.update = function(updateDescriptor) {
|
||||
indexEntry[value].push(updateDescriptor["new"].tiddler.fields.title);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ TagSubIndexer.prototype.rebuild = function() {
|
||||
} else {
|
||||
self.index[tag].titles.push(title);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -83,7 +83,7 @@ TagSubIndexer.prototype.lookup = function(tag) {
|
||||
if(!indexRecord.isSorted) {
|
||||
if(this.indexer.wiki.sortByList) {
|
||||
indexRecord.titles = this.indexer.wiki.sortByList(indexRecord.titles,tag);
|
||||
}
|
||||
}
|
||||
indexRecord.isSorted = true;
|
||||
}
|
||||
return indexRecord.titles;
|
||||
|
||||
@@ -12,7 +12,7 @@ Initialise basic platform $:/info/ tiddlers
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.getInfoTiddlerFields = function() {
|
||||
exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) {
|
||||
var mapBoolean = function(value) {return value ? "yes" : "no";},
|
||||
infoTiddlerFields = [];
|
||||
// Basics
|
||||
@@ -22,7 +22,7 @@ exports.getInfoTiddlerFields = function() {
|
||||
if($tw.browser) {
|
||||
// Document location
|
||||
var setLocationProperty = function(name,value) {
|
||||
infoTiddlerFields.push({title: "$:/info/url/" + name, text: value});
|
||||
infoTiddlerFields.push({title: "$:/info/url/" + name, text: value});
|
||||
},
|
||||
location = document.location;
|
||||
setLocationProperty("full", (location.toString()).split("#")[0]);
|
||||
@@ -36,6 +36,13 @@ exports.getInfoTiddlerFields = function() {
|
||||
// Screen size
|
||||
infoTiddlerFields.push({title: "$:/info/browser/screen/width", text: window.screen.width.toString()});
|
||||
infoTiddlerFields.push({title: "$:/info/browser/screen/height", text: window.screen.height.toString()});
|
||||
// Dark mode through event listener on MediaQueryList
|
||||
var mqList = window.matchMedia("(prefers-color-scheme: dark)"),
|
||||
getDarkModeTiddler = function() {return {title: "$:/info/darkmode", text: mqList.matches ? "yes" : "no"};};
|
||||
infoTiddlerFields.push(getDarkModeTiddler());
|
||||
mqList.addListener(function(event) {
|
||||
updateInfoTiddlersCallback([getDarkModeTiddler()]);
|
||||
});
|
||||
// Language
|
||||
infoTiddlerFields.push({title: "$:/info/browser/language", text: navigator.language || ""});
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ Key descriptors have the following format:
|
||||
ctrl+enter
|
||||
ctrl+shift+alt+A
|
||||
*/
|
||||
KeyboardManager.prototype.parseKeyDescriptor = function(keyDescriptor) {
|
||||
KeyboardManager.prototype.parseKeyDescriptor = function(keyDescriptor,options) {
|
||||
var components = keyDescriptor.split(/\+|\-/),
|
||||
info = {
|
||||
keyCode: 0,
|
||||
@@ -206,6 +206,9 @@ KeyboardManager.prototype.parseKeyDescriptor = function(keyDescriptor) {
|
||||
info.keyCode = this.namedKeys[s];
|
||||
}
|
||||
}
|
||||
if(options.keyDescriptor) {
|
||||
info.keyDescriptor = options.keyDescriptor;
|
||||
}
|
||||
if(info.keyCode) {
|
||||
return info;
|
||||
} else {
|
||||
@@ -237,6 +240,7 @@ KeyboardManager.prototype.parseKeyDescriptors = function(keyDescriptors,options)
|
||||
lookupName = function(configName) {
|
||||
var keyDescriptors = wiki.getTiddlerText("$:/config/" + configName + "/" + name);
|
||||
if(keyDescriptors) {
|
||||
options.keyDescriptor = keyDescriptor;
|
||||
result.push.apply(result,self.parseKeyDescriptors(keyDescriptors,options));
|
||||
}
|
||||
};
|
||||
@@ -245,7 +249,7 @@ KeyboardManager.prototype.parseKeyDescriptors = function(keyDescriptors,options)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
result.push(self.parseKeyDescriptor(keyDescriptor));
|
||||
result.push(self.parseKeyDescriptor(keyDescriptor,options));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@@ -276,22 +280,30 @@ KeyboardManager.prototype.checkKeyDescriptor = function(event,keyInfo) {
|
||||
};
|
||||
|
||||
KeyboardManager.prototype.checkKeyDescriptors = function(event,keyInfoArray) {
|
||||
return (this.getMatchingKeyDescriptor(event,keyInfoArray) !== null);
|
||||
};
|
||||
|
||||
KeyboardManager.prototype.getMatchingKeyDescriptor = function(event,keyInfoArray) {
|
||||
for(var t=0; t<keyInfoArray.length; t++) {
|
||||
if(this.checkKeyDescriptor(event,keyInfoArray[t])) {
|
||||
return true;
|
||||
return keyInfoArray[t];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
};
|
||||
|
||||
KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) {
|
||||
return event.ctrlKey && !event.shiftKey && !event.altKey ? "ctrl" :
|
||||
event.shiftKey && !event.ctrlKey && !event.altKey? "shift" :
|
||||
event.ctrlKey && event.shiftKey && !event.altKey ? "ctrl-shift" :
|
||||
event.altKey && !event.shiftKey && !event.ctrlKey ? "alt" :
|
||||
event.altKey && event.shiftKey && !event.ctrlKey ? "alt-shift" :
|
||||
event.altKey && event.ctrlKey && !event.shiftKey ? "ctrl-alt" :
|
||||
event.altKey && event.shiftKey && event.ctrlKey ? "ctrl-alt-shift" : "normal";
|
||||
return event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey ? "ctrl" :
|
||||
event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ? "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-shift" :
|
||||
event.altKey && event.ctrlKey && !event.shiftKey && !event.metaKey ? "ctrl-alt" :
|
||||
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-ctrl" :
|
||||
event.metaKey && event.ctrlKey && event.shiftKey && !event.altKey ? "meta-ctrl-shift" :
|
||||
event.metaKey && event.ctrlKey && event.shiftKey && event.altKey ? "meta-ctrl-alt-shift" : "normal";
|
||||
};
|
||||
|
||||
KeyboardManager.prototype.getShortcutTiddlerList = function() {
|
||||
@@ -320,7 +332,7 @@ KeyboardManager.prototype.handleKeydownEvent = function(event) {
|
||||
if(key !== undefined) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$tw.rootWidget.invokeActionString(action,$tw.rootWidget);
|
||||
$tw.rootWidget.invokeActionString(action,$tw.rootWidget,event);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
title: $:/core/modules/macros/unusedtitle.js
|
||||
type: application/javascript
|
||||
module-type: macro
|
||||
|
||||
Macro to return a new title that is unused in the wiki. It can be given a name as a base.
|
||||
\*/
|
||||
(function(){
|
||||
@@ -10,25 +11,25 @@ Macro to return a new title that is unused in the wiki. It can be given a name a
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Information about this macro
|
||||
*/
|
||||
|
||||
exports.name = "unusedtitle";
|
||||
|
||||
exports.params = [
|
||||
{name: "baseName"},
|
||||
{name: "options"}
|
||||
{name: "separator"},
|
||||
{name: "template"}
|
||||
];
|
||||
|
||||
/*
|
||||
Run the macro
|
||||
*/
|
||||
exports.run = function(baseName, options) {
|
||||
exports.run = function(baseName,separator,template) {
|
||||
separator = separator || " ";
|
||||
if(!baseName) {
|
||||
baseName = $tw.language.getString("DefaultNewTiddlerTitle");
|
||||
}
|
||||
return this.wiki.generateNewTitle(baseName, options);
|
||||
// $tw.wiki.generateNewTitle = function(baseTitle,options)
|
||||
// options.prefix must be a string!
|
||||
return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template});
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -23,10 +23,12 @@ var HtmlParser = function(type,text,options) {
|
||||
type: "element",
|
||||
tag: "iframe",
|
||||
attributes: {
|
||||
src: {type: "string", value: src},
|
||||
sandbox: {type: "string", value: ""}
|
||||
src: {type: "string", value: src}
|
||||
}
|
||||
}];
|
||||
if($tw.wiki.getTiddlerText("$:/config/HtmlParser/DisableSandbox","no") !== "yes") {
|
||||
this.tree[0].attributes.sandbox = {type: "string", value: $tw.wiki.getTiddlerText("$:/config/HtmlParser/SandboxTokens","")};
|
||||
}
|
||||
};
|
||||
|
||||
exports["text/html"] = HtmlParser;
|
||||
|
||||
@@ -39,6 +39,7 @@ exports["image/webp"] = ImageParser;
|
||||
exports["image/heic"] = ImageParser;
|
||||
exports["image/heif"] = ImageParser;
|
||||
exports["image/x-icon"] = ImageParser;
|
||||
exports["image/vnd.microsoft.icon"] = ImageParser;
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -123,6 +123,19 @@ exports.parseStringLiteral = function(source,pos) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.parseMacroParameters = function(node,source,pos) {
|
||||
// Process parameters
|
||||
var parameter = $tw.utils.parseMacroParameter(source,pos);
|
||||
while(parameter) {
|
||||
node.params.push(parameter);
|
||||
pos = parameter.end;
|
||||
// Get the next parameter
|
||||
parameter = $tw.utils.parseMacroParameter(source,pos);
|
||||
}
|
||||
node.end = pos;
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
Look for a macro invocation parameter. Returns null if not found, or {type: "macro-parameter", name:, value:, start:, end:}
|
||||
*/
|
||||
@@ -132,7 +145,7 @@ exports.parseMacroParameter = function(source,pos) {
|
||||
start: pos
|
||||
};
|
||||
// Define our regexp
|
||||
var reMacroParameter = /(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^\s>"'=]+)))/g;
|
||||
var reMacroParameter = /(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|((?:(?:>(?!>))|[^\s>"'])+)))/g;
|
||||
// Skip whitespace
|
||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||
// Look for the parameter
|
||||
@@ -187,14 +200,8 @@ exports.parseMacroInvocation = function(source,pos) {
|
||||
}
|
||||
node.name = name.match[1];
|
||||
pos = name.end;
|
||||
// Process parameters
|
||||
var parameter = $tw.utils.parseMacroParameter(source,pos);
|
||||
while(parameter) {
|
||||
node.params.push(parameter);
|
||||
pos = parameter.end;
|
||||
// Get the next parameter
|
||||
parameter = $tw.utils.parseMacroParameter(source,pos);
|
||||
}
|
||||
node = $tw.utils.parseMacroParameters(node,source,pos);
|
||||
pos = node.end;
|
||||
// Skip whitespace
|
||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||
// Look for a double greater than sign
|
||||
@@ -208,6 +215,29 @@ exports.parseMacroInvocation = function(source,pos) {
|
||||
return node;
|
||||
};
|
||||
|
||||
exports.parseFilterVariable = function(source) {
|
||||
var node = {
|
||||
name: "",
|
||||
params: [],
|
||||
},
|
||||
pos = 0,
|
||||
reName = /([^\s"']+)/g;
|
||||
// If there is no whitespace or it is an empty string then there are no macro parameters
|
||||
if(/^\S*$/.test(source)) {
|
||||
node.name = source;
|
||||
return node;
|
||||
}
|
||||
// Get the variable name
|
||||
var nameMatch = $tw.utils.parseTokenRegExp(source,pos,reName);
|
||||
if(nameMatch) {
|
||||
node.name = nameMatch.match[1];
|
||||
pos = nameMatch.end;
|
||||
node = $tw.utils.parseMacroParameters(node,source,pos);
|
||||
delete node.end;
|
||||
}
|
||||
return node;
|
||||
};
|
||||
|
||||
/*
|
||||
Look for an HTML attribute definition. Returns null if not found, otherwise returns {type: "attribute", name:, valueType: "string|indirect|macro", value:, start:, end:,}
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,12 @@ Wiki text block rule for HTML comments. For example:
|
||||
|
||||
```
|
||||
<!-- This is a comment -->
|
||||
\define macroX()
|
||||
<!-- This is a comment -->
|
||||
xxxx
|
||||
\end
|
||||
<!-- This is a comment -->
|
||||
|
||||
```
|
||||
|
||||
Note that the syntax for comments is simplified to an opening "<!--" sequence and a closing "-->" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html)
|
||||
@@ -19,7 +25,7 @@ Note that the syntax for comments is simplified to an opening "<!--" sequence an
|
||||
"use strict";
|
||||
|
||||
exports.name = "commentblock";
|
||||
exports.types = {block: true};
|
||||
exports.types = {block:true, pragma:true};
|
||||
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
@@ -31,7 +37,7 @@ exports.findNextMatch = function(startPos) {
|
||||
this.matchRegExp.lastIndex = startPos;
|
||||
this.match = this.matchRegExp.exec(this.parser.source);
|
||||
if(this.match) {
|
||||
this.endMatchRegExp.lastIndex = startPos + this.match[0].length;
|
||||
this.endMatchRegExp.lastIndex = this.match.index + this.match[0].length;
|
||||
this.endMatch = this.endMatchRegExp.exec(this.parser.source);
|
||||
if(this.endMatch) {
|
||||
return this.match.index;
|
||||
|
||||
@@ -31,7 +31,7 @@ exports.findNextMatch = function(startPos) {
|
||||
this.matchRegExp.lastIndex = startPos;
|
||||
this.match = this.matchRegExp.exec(this.parser.source);
|
||||
if(this.match) {
|
||||
this.endMatchRegExp.lastIndex = startPos + this.match[0].length;
|
||||
this.endMatchRegExp.lastIndex = this.match.index + this.match[0].length;
|
||||
this.endMatch = this.endMatchRegExp.exec(this.parser.source);
|
||||
if(this.endMatch) {
|
||||
return this.match.index;
|
||||
|
||||
@@ -53,17 +53,12 @@ exports.parse = function() {
|
||||
tag.isBlock = this.is.block || hasLineBreak;
|
||||
// Parse the body if we need to
|
||||
if(!tag.isSelfClosing && $tw.config.htmlVoidElements.indexOf(tag.tag) === -1) {
|
||||
var reEndString = "</" + $tw.utils.escapeRegExp(tag.tag) + ">",
|
||||
reEnd = new RegExp("(" + reEndString + ")","mg");
|
||||
var reEndString = "</" + $tw.utils.escapeRegExp(tag.tag) + ">";
|
||||
if(hasLineBreak) {
|
||||
tag.children = this.parser.parseBlocks(reEndString);
|
||||
} else {
|
||||
tag.children = this.parser.parseInlineRun(reEnd);
|
||||
}
|
||||
reEnd.lastIndex = this.parser.pos;
|
||||
var endMatch = reEnd.exec(this.parser.source);
|
||||
if(endMatch && endMatch.index === this.parser.pos) {
|
||||
this.parser.pos = endMatch.index + endMatch[0].length;
|
||||
var reEnd = new RegExp("(" + reEndString + ")","mg");
|
||||
tag.children = this.parser.parseInlineRun(reEnd,{eatTerminator: true});
|
||||
}
|
||||
}
|
||||
// Return the tag
|
||||
|
||||
@@ -36,7 +36,7 @@ exports.parse = function() {
|
||||
// Move past the pragma invocation
|
||||
this.parser.pos = this.matchRegExp.lastIndex;
|
||||
// Parse the filter terminated by a line break
|
||||
var reMatch = /(.*)(\r?\n)|$/mg;
|
||||
var reMatch = /(.*)(?:$|\r?\n)/mg;
|
||||
reMatch.lastIndex = this.parser.pos;
|
||||
var match = reMatch.exec(this.parser.source);
|
||||
this.parser.pos = reMatch.lastIndex;
|
||||
|
||||
@@ -21,40 +21,36 @@ exports.types = {block: true};
|
||||
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
// Regexp to match
|
||||
this.matchRegExp = /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*?)>>(?:\r?\n|$)/mg;
|
||||
};
|
||||
|
||||
exports.findNextMatch = function(startPos) {
|
||||
var nextStart = startPos;
|
||||
// Try parsing at all possible macrocall openers until we match
|
||||
while((nextStart = this.parser.source.indexOf("<<",nextStart)) >= 0) {
|
||||
var nextCall = $tw.utils.parseMacroInvocation(this.parser.source,nextStart);
|
||||
if(nextCall) {
|
||||
var c = this.parser.source.charAt(nextCall.end);
|
||||
// Ensure EOL after parsed macro
|
||||
// If we didn't need to support IE, we'd just use /(?:\r?\n|$)/ym
|
||||
if ((c === "") || (c === "\n") || ((c === "\r") && this.parser.source.charAt(nextCall.end+1) === "\n")) {
|
||||
this.nextCall = nextCall;
|
||||
return nextStart;
|
||||
}
|
||||
}
|
||||
nextStart += 2;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/*
|
||||
Parse the most recent match
|
||||
*/
|
||||
exports.parse = function() {
|
||||
// Get all the details of the match
|
||||
var macroName = this.match[1],
|
||||
paramString = this.match[2];
|
||||
// Move past the macro call
|
||||
this.parser.pos = this.matchRegExp.lastIndex;
|
||||
var params = [],
|
||||
reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg,
|
||||
paramMatch = reParam.exec(paramString);
|
||||
while(paramMatch) {
|
||||
// Process this parameter
|
||||
var paramInfo = {
|
||||
value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] || paramMatch[6]
|
||||
};
|
||||
if(paramMatch[1]) {
|
||||
paramInfo.name = paramMatch[1];
|
||||
}
|
||||
params.push(paramInfo);
|
||||
// Find the next match
|
||||
paramMatch = reParam.exec(paramString);
|
||||
}
|
||||
return [{
|
||||
type: "macrocall",
|
||||
name: macroName,
|
||||
params: params,
|
||||
isBlock: true
|
||||
}];
|
||||
var call = this.nextCall;
|
||||
call.isBlock = true;
|
||||
this.nextCall = null;
|
||||
this.parser.pos = call.end;
|
||||
return [call];
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -21,39 +21,29 @@ exports.types = {inline: true};
|
||||
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
// Regexp to match
|
||||
this.matchRegExp = /<<([^\s>]+)\s*([\s\S]*?)>>/mg;
|
||||
};
|
||||
|
||||
exports.findNextMatch = function(startPos) {
|
||||
var nextStart = startPos;
|
||||
// Try parsing at all possible macrocall openers until we match
|
||||
while((nextStart = this.parser.source.indexOf("<<",nextStart)) >= 0) {
|
||||
this.nextCall = $tw.utils.parseMacroInvocation(this.parser.source,nextStart);
|
||||
if(this.nextCall) {
|
||||
return nextStart;
|
||||
}
|
||||
nextStart += 2;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/*
|
||||
Parse the most recent match
|
||||
*/
|
||||
exports.parse = function() {
|
||||
// Get all the details of the match
|
||||
var macroName = this.match[1],
|
||||
paramString = this.match[2];
|
||||
// Move past the macro call
|
||||
this.parser.pos = this.matchRegExp.lastIndex;
|
||||
var params = [],
|
||||
reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg,
|
||||
paramMatch = reParam.exec(paramString);
|
||||
while(paramMatch) {
|
||||
// Process this parameter
|
||||
var paramInfo = {
|
||||
value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5]|| paramMatch[6]
|
||||
};
|
||||
if(paramMatch[1]) {
|
||||
paramInfo.name = paramMatch[1];
|
||||
}
|
||||
params.push(paramInfo);
|
||||
// Find the next match
|
||||
paramMatch = reParam.exec(paramString);
|
||||
}
|
||||
return [{
|
||||
type: "macrocall",
|
||||
name: macroName,
|
||||
params: params
|
||||
}];
|
||||
var call = this.nextCall;
|
||||
this.nextCall = null;
|
||||
this.parser.pos = call.end;
|
||||
return [call];
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -161,7 +161,7 @@ exports.parse = function() {
|
||||
// Move the caption to the first row if it isn't already
|
||||
if(table.children.length !== 1) {
|
||||
table.children.pop(); // Take rowContainer out of the children array
|
||||
table.children.splice(0,0,rowContainer); // Insert it at the bottom
|
||||
table.children.splice(0,0,rowContainer); // Insert it at the bottom
|
||||
}
|
||||
// Set the alignment - TODO: figure out why TW did this
|
||||
// rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
|
||||
|
||||
@@ -25,6 +25,14 @@ Attributes are stored as hashmaps of the following objects:
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
type: content type of text
|
||||
text: text to be parsed
|
||||
options: see below:
|
||||
parseAsInline: true to parse text as inline instead of block
|
||||
wiki: reference to wiki to use
|
||||
_canonical_uri: optional URI of content if text is missing or empty
|
||||
*/
|
||||
var WikiParser = function(type,text,options) {
|
||||
this.wiki = options.wiki;
|
||||
var self = this;
|
||||
@@ -33,19 +41,6 @@ var WikiParser = function(type,text,options) {
|
||||
this.loadRemoteTiddler(options._canonical_uri);
|
||||
text = $tw.language.getRawString("LazyLoadingWarning");
|
||||
}
|
||||
// Initialise the classes if we don't have them already
|
||||
if(!this.pragmaRuleClasses) {
|
||||
WikiParser.prototype.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikirule","pragma",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.pragmaRuleClasses,"$:/config/WikiParserRules/Pragmas/");
|
||||
}
|
||||
if(!this.blockRuleClasses) {
|
||||
WikiParser.prototype.blockRuleClasses = $tw.modules.createClassesFromModules("wikirule","block",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.blockRuleClasses,"$:/config/WikiParserRules/Block/");
|
||||
}
|
||||
if(!this.inlineRuleClasses) {
|
||||
WikiParser.prototype.inlineRuleClasses = $tw.modules.createClassesFromModules("wikirule","inline",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.inlineRuleClasses,"$:/config/WikiParserRules/Inline/");
|
||||
}
|
||||
// Save the parse text
|
||||
this.type = type || "text/vnd.tiddlywiki";
|
||||
this.source = text || "";
|
||||
@@ -54,13 +49,38 @@ var WikiParser = function(type,text,options) {
|
||||
this.configTrimWhiteSpace = false;
|
||||
// Set current parse position
|
||||
this.pos = 0;
|
||||
// Instantiate the pragma parse rules
|
||||
this.pragmaRules = this.instantiateRules(this.pragmaRuleClasses,"pragma",0);
|
||||
// Instantiate the parser block and inline rules
|
||||
this.blockRules = this.instantiateRules(this.blockRuleClasses,"block",0);
|
||||
this.inlineRules = this.instantiateRules(this.inlineRuleClasses,"inline",0);
|
||||
// Parse any pragmas
|
||||
// Start with empty output
|
||||
this.tree = [];
|
||||
// Assemble the rule classes we're going to use
|
||||
var pragmaRuleClasses, blockRuleClasses, inlineRuleClasses;
|
||||
if(options.rules) {
|
||||
pragmaRuleClasses = options.rules.pragma;
|
||||
blockRuleClasses = options.rules.block;
|
||||
inlineRuleClasses = options.rules.inline;
|
||||
} else {
|
||||
// Setup the rule classes if we don't have them already
|
||||
if(!this.pragmaRuleClasses) {
|
||||
WikiParser.prototype.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikirule","pragma",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.pragmaRuleClasses,"$:/config/WikiParserRules/Pragmas/");
|
||||
}
|
||||
pragmaRuleClasses = this.pragmaRuleClasses;
|
||||
if(!this.blockRuleClasses) {
|
||||
WikiParser.prototype.blockRuleClasses = $tw.modules.createClassesFromModules("wikirule","block",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.blockRuleClasses,"$:/config/WikiParserRules/Block/");
|
||||
}
|
||||
blockRuleClasses = this.blockRuleClasses;
|
||||
if(!this.inlineRuleClasses) {
|
||||
WikiParser.prototype.inlineRuleClasses = $tw.modules.createClassesFromModules("wikirule","inline",$tw.WikiRuleBase);
|
||||
this.setupRules(WikiParser.prototype.inlineRuleClasses,"$:/config/WikiParserRules/Inline/");
|
||||
}
|
||||
inlineRuleClasses = this.inlineRuleClasses;
|
||||
}
|
||||
// Instantiate the pragma parse rules
|
||||
this.pragmaRules = this.instantiateRules(pragmaRuleClasses,"pragma",0);
|
||||
// Instantiate the parser block and inline rules
|
||||
this.blockRules = this.instantiateRules(blockRuleClasses,"block",0);
|
||||
this.inlineRules = this.instantiateRules(inlineRuleClasses,"inline",0);
|
||||
// Parse any pragmas
|
||||
var topBranch = this.parsePragmas();
|
||||
// Parse the text into inline runs or blocks
|
||||
if(options.parseAsInline) {
|
||||
@@ -358,7 +378,7 @@ WikiParser.prototype.pushTextWidget = function(array,text) {
|
||||
text = $tw.utils.trim(text);
|
||||
}
|
||||
if(text) {
|
||||
array.push({type: "text", text: text});
|
||||
array.push({type: "text", text: text});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -386,22 +406,18 @@ Amend the rules used by this instance of the parser
|
||||
WikiParser.prototype.amendRules = function(type,names) {
|
||||
names = names || [];
|
||||
// Define the filter function
|
||||
var keepFilter;
|
||||
var target;
|
||||
if(type === "only") {
|
||||
keepFilter = function(name) {
|
||||
return names.indexOf(name) !== -1;
|
||||
};
|
||||
target = true;
|
||||
} else if(type === "except") {
|
||||
keepFilter = function(name) {
|
||||
return names.indexOf(name) === -1;
|
||||
};
|
||||
target = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
// Define a function to process each of our rule arrays
|
||||
var processRuleArray = function(ruleArray) {
|
||||
for(var t=ruleArray.length-1; t>=0; t--) {
|
||||
if(!keepFilter(ruleArray[t].rule.name)) {
|
||||
if((names.indexOf(ruleArray[t].rule.name) === -1) === target) {
|
||||
ruleArray.splice(t,1);
|
||||
}
|
||||
}
|
||||
|
||||
181
core/modules/publisher-handler.js
Normal file
181
core/modules/publisher-handler.js
Normal file
@@ -0,0 +1,181 @@
|
||||
/*\
|
||||
title: $:/core/modules/publisherhandler.js
|
||||
type: application/javascript
|
||||
module-type: global
|
||||
|
||||
The publisher manages publishing extracts of wikis as external files
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var PUBLISHING_MODAL_TITLE = "$:/language/Publishing/Modal";
|
||||
|
||||
/*
|
||||
Instantiate the publisher manager with the following options
|
||||
wiki: wiki object to be used
|
||||
commander: commander object to be used for output
|
||||
*/
|
||||
function PublisherHandler(options) {
|
||||
this.wiki = options.wiki;
|
||||
this.commander = options.commander;
|
||||
}
|
||||
|
||||
/*
|
||||
Publish a job
|
||||
|
||||
jobTitle: title of tiddler containing details of the job
|
||||
callback: completion callback invoked callback(err)
|
||||
options: Include:
|
||||
|
||||
commander: commander object associated with publishing under Node.js
|
||||
variables: hashmap of variables to be passed to renderings
|
||||
*/
|
||||
PublisherHandler.prototype.publish = function(jobTitle,callback,options) {
|
||||
if(jobTitle) {
|
||||
var job = new PublishingJob(jobTitle,this,options);
|
||||
job.publish(callback);
|
||||
}
|
||||
};
|
||||
|
||||
function PublishingJob(jobTitle,publisherHandler,options) {
|
||||
options = options || {};
|
||||
// Save params
|
||||
this.jobTitle = jobTitle;
|
||||
this.publisherHandler = publisherHandler;
|
||||
this.commander = options.commander;
|
||||
this.publishVariables = options.variables || Object.create(null);
|
||||
}
|
||||
|
||||
/*
|
||||
Start publishing
|
||||
*/
|
||||
PublishingJob.prototype.publish = function(callback) {
|
||||
var self = this;
|
||||
// Get the job tiddler and check it is enabled
|
||||
this.jobTiddler = this.publisherHandler.wiki.getTiddler(this.jobTitle);
|
||||
if(this.jobTiddler && this.jobTiddler.fields.enabled === "yes") {
|
||||
// Get the list of tiddlers to be exported, defaulting to all non-system tiddlers
|
||||
this.exportList = this.publisherHandler.wiki.filterTiddlers(this.jobTiddler.fields["export-filter"] || "[!is[system]]");
|
||||
// Get publisher
|
||||
this.publisher = this.getPublisher(this.jobTiddler.fields.publisher);
|
||||
if(this.publisher) {
|
||||
// Get the sitemap
|
||||
this.sitemap = new $tw.Sitemap(this.jobTiddler.fields.sitemap,{
|
||||
wiki: this.publisherHandler.wiki,
|
||||
variables: this.publishVariables
|
||||
});
|
||||
this.sitemap.load();
|
||||
// Get the output operations
|
||||
this.operations = this.sitemap.getAllFileDetails(this.exportList);
|
||||
// Display the progress modal
|
||||
if($tw.modal) {
|
||||
this.progressModal = $tw.modal.display(PUBLISHING_MODAL_TITLE,{
|
||||
progress: true,
|
||||
variables: {
|
||||
currentTiddler: this.jobTitle,
|
||||
totalFiles: this.operations.length + ""
|
||||
},
|
||||
onclose: function(event) {
|
||||
if(event !== self) {
|
||||
// The modal was closed other than by us programmatically
|
||||
self.isCancelled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Send the operations to the publisher
|
||||
this.executeOperations(function(err) {
|
||||
if(self.progressModal) {
|
||||
self.progressModal.closeHandler(self);
|
||||
}
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
return callback("Unrecognised publisher");
|
||||
}
|
||||
} else {
|
||||
return callback("Missing or disabled job tiddler");
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Instantiate the required publisher object
|
||||
*/
|
||||
PublishingJob.prototype.getPublisher = function(publisherName) {
|
||||
var publisher;
|
||||
$tw.modules.forEachModuleOfType("publisher",function(title,module) {
|
||||
if(module.name === publisherName) {
|
||||
publisher = module;
|
||||
}
|
||||
});
|
||||
return publisher && publisher.create(this.jobTiddler.fields,this.publisherHandler,this);
|
||||
};
|
||||
|
||||
/*
|
||||
Execute the operations for this job
|
||||
*/
|
||||
PublishingJob.prototype.executeOperations = function(callback) {
|
||||
var self = this,
|
||||
report = {overwrites: []},
|
||||
nextOperation = 0,
|
||||
performNextOperation = function() {
|
||||
// Check for having been cancelled
|
||||
if(self.isCancelled) {
|
||||
if(self.publisher.publishCancel) {
|
||||
self.publisher.publishCancel();
|
||||
}
|
||||
return callback("CANCELLED");
|
||||
}
|
||||
// Update progress
|
||||
if(self.progressModal) {
|
||||
self.progressModal.setProgress(nextOperation,self.operations.length);
|
||||
}
|
||||
// Check for having finished
|
||||
if(nextOperation >= self.operations.length) {
|
||||
$tw.utils.nextTick(function() {
|
||||
self.publisher.publishEnd(callback);
|
||||
});
|
||||
} else {
|
||||
// Execute this operation
|
||||
var fileDetails = self.operations[nextOperation]();
|
||||
nextOperation += 1;
|
||||
self.publisher.publishFile(fileDetails,function() {
|
||||
$tw.utils.nextTick(performNextOperation);
|
||||
});
|
||||
}
|
||||
};
|
||||
// Tell the publisher to start, and get back an array of the existing paths
|
||||
self.publisher.publishStart(function(existingPaths) {
|
||||
var paths = {};
|
||||
$tw.utils.each(self.operations,function(operation) {
|
||||
if(operation.path in paths) {
|
||||
report.overwrites.push(operation.path);
|
||||
}
|
||||
paths[operation.path] = true;
|
||||
});
|
||||
// Run the operations
|
||||
performNextOperation();
|
||||
});
|
||||
};
|
||||
|
||||
PublishingJob.prototype.saveReport = function(report) {
|
||||
// Create the report tiddler
|
||||
var reportTitle = this.wiki.generateNewTitle("$:/temp/publish-report");
|
||||
$tw.wiki.addTiddler({
|
||||
title: reportTitle,
|
||||
text: "* " + report.overwrites.join("\n* ")
|
||||
});
|
||||
// Add the report tiddler title to the list field of the publisher parameters tiddler
|
||||
var paramsTiddler = $tw.wiki.getTiddler(this.publisherParamsTitle),
|
||||
list = (paramsTiddler.fields.list || []).slice(0);
|
||||
list.unshift(reportTitle);
|
||||
$tw.wiki.addTiddler(new $tw.Tiddler(paramsTiddler,{list: list}));
|
||||
};
|
||||
|
||||
exports.PublisherHandler = PublisherHandler;
|
||||
|
||||
})();
|
||||
52
core/modules/publishers/filesystem.js
Normal file
52
core/modules/publishers/filesystem.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/*\
|
||||
title: $:/core/modules/publishers/filesystem.js
|
||||
type: application/javascript
|
||||
module-type: publisher
|
||||
|
||||
Handles publishing to the Node.js filesystem
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.name = "filesystem";
|
||||
|
||||
exports.create = function(params,publisherHandler,publishingJob) {
|
||||
return new FileSystemPublisher(params,publisherHandler,publishingJob);
|
||||
};
|
||||
|
||||
function FileSystemPublisher(params,publisherHandler,publishingJob) {
|
||||
this.params = params;
|
||||
this.publisherHandler = publisherHandler;
|
||||
this.publishingJob = publishingJob;
|
||||
};
|
||||
|
||||
FileSystemPublisher.prototype.publishStart = function(callback) {
|
||||
console.log("publishStart");
|
||||
// Returns a list of the previously published files
|
||||
callback([]);
|
||||
};
|
||||
|
||||
FileSystemPublisher.prototype.publishFile = function(item,callback) {
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
filepath = path.resolve(this.publishingJob.commander.outputPath,item.path);
|
||||
$tw.utils.createFileDirectories(filepath);
|
||||
fs.writeFile(filepath,item.text,item.isBase64 ? "base64" : "utf8",function(err) {
|
||||
if(err) {
|
||||
console.log("File writing error",err)
|
||||
}
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
FileSystemPublisher.prototype.publishEnd = function(callback) {
|
||||
console.log("publishEnd");
|
||||
callback(null);
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -157,7 +157,8 @@ SaverHandler.prototype.saveWiki = function(options) {
|
||||
return false;
|
||||
}
|
||||
var variables = options.variables || {},
|
||||
template = options.template || "$:/core/save/all",
|
||||
template = (options.template ||
|
||||
this.wiki.getTiddlerText("$:/config/SaveWikiButton/Template","$:/core/save/all")).trim(),
|
||||
downloadType = options.downloadType || "text/plain",
|
||||
text = this.wiki.renderTiddler(downloadType,template,options),
|
||||
callback = function(err) {
|
||||
@@ -197,8 +198,12 @@ SaverHandler.prototype.isDirty = function() {
|
||||
Update the document body with the class "tc-dirty" if the wiki has unsaved/unsynced changes
|
||||
*/
|
||||
SaverHandler.prototype.updateDirtyStatus = function() {
|
||||
var self = this;
|
||||
if($tw.browser) {
|
||||
$tw.utils.toggleClass(document.body,"tc-dirty",this.isDirty());
|
||||
$tw.utils.each($tw.windows,function(win) {
|
||||
$tw.utils.toggleClass(win.document.body,"tc-dirty",self.isDirty());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@ GitHubSaver.prototype.save = function(text,method,callback) {
|
||||
repo = this.wiki.getTiddlerText("$:/GitHub/Repo"),
|
||||
path = this.wiki.getTiddlerText("$:/GitHub/Path",""),
|
||||
filename = this.wiki.getTiddlerText("$:/GitHub/Filename"),
|
||||
branch = this.wiki.getTiddlerText("$:/GitHub/Branch") || "master",
|
||||
branch = this.wiki.getTiddlerText("$:/GitHub/Branch") || "main",
|
||||
endpoint = this.wiki.getTiddlerText("$:/GitHub/ServerURL") || "https://api.github.com",
|
||||
headers = {
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
"Content-Type": "application/json;charset=UTF-8",
|
||||
"Authorization": "Basic " + window.btoa(username + ":" + password)
|
||||
"Authorization": "Basic " + window.btoa(username + ":" + password),
|
||||
"If-None-Match": ""
|
||||
};
|
||||
// Bail if we don't have everything we need
|
||||
if(!username || !password || !repo || !filename) {
|
||||
|
||||
@@ -89,9 +89,12 @@ PutSaver.prototype.save = function(text,method,callback) {
|
||||
if(err) {
|
||||
// response is textual: "XMLHttpRequest error code: 412"
|
||||
var status = Number(err.substring(err.indexOf(':') + 2, err.length))
|
||||
if(status === 412) { // edit conflict
|
||||
var message = $tw.language.getString("Error/EditConflict");
|
||||
callback(message);
|
||||
if(status === 412) { // file changed on server
|
||||
callback($tw.language.getString("Error/PutEditConflict"));
|
||||
} else if(status === 401) { // authentication required
|
||||
callback($tw.language.getString("Error/PutUnauthorized"));
|
||||
} else if(status === 403) { // permission denied
|
||||
callback($tw.language.getString("Error/PutForbidden"));
|
||||
} else {
|
||||
callback(err); // fail
|
||||
}
|
||||
|
||||
@@ -28,17 +28,29 @@ UploadSaver.prototype.save = function(text,method,callback) {
|
||||
password = $tw.utils.getPassword("upload"),
|
||||
uploadDir = this.wiki.getTextReference("$:/UploadDir") || ".",
|
||||
uploadFilename = this.wiki.getTextReference("$:/UploadFilename") || "index.html",
|
||||
uploadWithUrlOnly = this.wiki.getTextReference("$:/UploadWithUrlOnly") || "no",
|
||||
url = this.wiki.getTextReference("$:/UploadURL");
|
||||
// Bail out if we don't have the bits we need
|
||||
if(!username || username.toString().trim() === "" || !password || password.toString().trim() === "") {
|
||||
return false;
|
||||
if (uploadWithUrlOnly === "yes") {
|
||||
// The url is good enough. No need for a username and password.
|
||||
// Assume the server uses some other kind of auth mechanism.
|
||||
if(!url || url.toString().trim() === "") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Require username and password to be present.
|
||||
// Assume the server uses the standard UploadPlugin username/password.
|
||||
if(!username || username.toString().trim() === "" || !password || password.toString().trim() === "") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Construct the url if not provided
|
||||
if(!url) {
|
||||
url = "http://" + username + ".tiddlyspot.com/store.cgi";
|
||||
}
|
||||
// Assemble the header
|
||||
var boundary = "---------------------------" + "AaB03x";
|
||||
var boundary = "---------------------------" + "AaB03x";
|
||||
var uploadFormName = "UploadPlugin";
|
||||
var head = [];
|
||||
head.push("--" + boundary + "\r\nContent-disposition: form-data; name=\"UploadPlugin\"\r\n");
|
||||
|
||||
@@ -17,9 +17,8 @@ exports.method = "GET";
|
||||
exports.path = /^\/favicon.ico$/;
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
response.writeHead(200, {"Content-Type": "image/x-icon"});
|
||||
var buffer = state.wiki.getTiddlerText("$:/favicon.ico","");
|
||||
response.end(buffer,"base64");
|
||||
state.sendResponse(200,{"Content-Type": "image/x-icon"},buffer,"base64");
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
@@ -34,10 +34,7 @@ exports.handler = function(request,response,state) {
|
||||
content = content;
|
||||
type = ($tw.config.fileExtensionInfo[extension] ? $tw.config.fileExtensionInfo[extension].type : "application/octet-stream");
|
||||
}
|
||||
response.writeHead(status,{
|
||||
"Content-Type": type
|
||||
});
|
||||
response.end(content);
|
||||
state.sendResponse(status,{"Content-Type": type},content);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -12,38 +12,16 @@ GET /
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var zlib = require("zlib");
|
||||
|
||||
exports.method = "GET";
|
||||
|
||||
exports.path = /^\/$/;
|
||||
exports.path = /^\/index.html$/;
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
var acceptEncoding = request.headers["accept-encoding"];
|
||||
if(!acceptEncoding) {
|
||||
acceptEncoding = "";
|
||||
}
|
||||
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler")),
|
||||
responseHeaders = {
|
||||
"Content-Type": state.server.get("root-serve-type")
|
||||
};
|
||||
/*
|
||||
If the gzip=yes flag for `listen` is set, check if the user agent permits
|
||||
compression. If so, compress our response. Note that we use the synchronous
|
||||
functions from zlib to stay in the imperative style. The current `Server`
|
||||
doesn't depend on this, and we may just as well use the async versions.
|
||||
*/
|
||||
if(state.server.enableGzip) {
|
||||
if (/\bdeflate\b/.test(acceptEncoding)) {
|
||||
responseHeaders["Content-Encoding"] = "deflate";
|
||||
text = zlib.deflateSync(text);
|
||||
} else if (/\bgzip\b/.test(acceptEncoding)) {
|
||||
responseHeaders["Content-Encoding"] = "gzip";
|
||||
text = zlib.gzipSync(text);
|
||||
}
|
||||
}
|
||||
response.writeHead(200,responseHeaders);
|
||||
response.end(text);
|
||||
state.sendResponse(200,responseHeaders,text);
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
@@ -22,11 +22,12 @@ exports.handler = function(request,response,state) {
|
||||
response.writeHead(401,{
|
||||
"WWW-Authenticate": 'Basic realm="Please provide your username and password to login to ' + state.server.servername + '"'
|
||||
});
|
||||
response.end();
|
||||
response.end();
|
||||
} else {
|
||||
// Redirect to the root wiki if login worked
|
||||
var location = ($tw.syncadaptor && $tw.syncadaptor.host)? $tw.syncadaptor.host: "/";
|
||||
response.writeHead(302,{
|
||||
Location: "/"
|
||||
Location: location
|
||||
});
|
||||
response.end();
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ exports.method = "GET";
|
||||
exports.path = /^\/status$/;
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
response.writeHead(200, {"Content-Type": "application/json"});
|
||||
var text = JSON.stringify({
|
||||
username: state.authenticatedUsername || state.server.get("anon-username") || "",
|
||||
anonymous: !state.authenticatedUsername,
|
||||
read_only: !state.server.isAuthorized("writers",state.authenticatedUsername),
|
||||
sse_enabled: state.server.get("sse-enabled") === "yes",
|
||||
space: {
|
||||
recipe: "default"
|
||||
},
|
||||
tiddlywiki_version: $tw.version
|
||||
});
|
||||
response.end(text,"utf8");
|
||||
state.sendResponse(200,{"Content-Type": "application/json"},text,"utf8");
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
@@ -32,9 +32,9 @@ exports.handler = function(request,response,state) {
|
||||
renderTemplate = renderTemplate || state.server.get("tiddler-render-template");
|
||||
}
|
||||
var text = state.wiki.renderTiddler(renderType,renderTemplate,{parseAsInline: true, variables: {currentTiddler: title}});
|
||||
|
||||
// Naughty not to set a content-type, but it's the easiest way to ensure the browser will see HTML pages as HTML, and accept plain text tiddlers as CSS or JS
|
||||
response.writeHead(200);
|
||||
response.end(text,"utf8");
|
||||
state.sendResponse(200,{},text,"utf8");
|
||||
} else {
|
||||
response.writeHead(404);
|
||||
response.end();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user