mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-02-12 13:09:50 +00:00
Compare commits
423 Commits
publishing
...
dynannotat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a79644bff3 | ||
|
|
9e8e93cbb7 | ||
|
|
495c42c7cf | ||
|
|
ffea61b345 | ||
|
|
a4dcd92f1b | ||
|
|
fe581a83b3 | ||
|
|
25b2e708c9 | ||
|
|
5db5d711d3 | ||
|
|
075b2ab149 | ||
|
|
8301fb8699 | ||
|
|
bc81195b5a | ||
|
|
02f8713012 | ||
|
|
9df88bfda9 | ||
|
|
97901d756e | ||
|
|
ecde2606ad | ||
|
|
938419ba2c | ||
|
|
1cb1e77785 | ||
|
|
a8331f8909 | ||
|
|
7cc100b82d | ||
|
|
681f22b66d | ||
|
|
b0c4886d23 | ||
|
|
c1f123499c | ||
|
|
977ea24e96 | ||
|
|
b529e69289 | ||
|
|
b5edaae1f4 | ||
|
|
22fd1ca630 | ||
|
|
c741978e95 | ||
|
|
28a91aafa7 | ||
|
|
1d8c538e45 | ||
|
|
3f0fb71635 | ||
|
|
347355128b | ||
|
|
2a38b15a29 | ||
|
|
84ad758829 | ||
|
|
5f4dc2a5fe | ||
|
|
f694f5ead7 | ||
|
|
29aef731a3 | ||
|
|
115b20ff7b | ||
|
|
a38b25eff5 | ||
|
|
71df5162ba | ||
|
|
864b5ec05d | ||
|
|
aaf1aa3821 | ||
|
|
8114d5475b | ||
|
|
29599baa3b | ||
|
|
b196cf77e8 | ||
|
|
4d3ebf4bf0 | ||
|
|
b3268546ef | ||
|
|
615d8da64f | ||
|
|
45a1478bc9 | ||
|
|
a071881562 | ||
|
|
2c38c8351b | ||
|
|
a51191d334 | ||
|
|
4054566493 | ||
|
|
5f994f7d46 | ||
|
|
7a7472833f | ||
|
|
9777aa9d13 | ||
|
|
d0b5b2124a | ||
|
|
95bd694a65 | ||
|
|
49de500b5e | ||
|
|
4cf3df0f86 | ||
|
|
1ae1ff3da2 | ||
|
|
4f42df8bef | ||
|
|
36b162a377 | ||
|
|
82c8fe7fa8 | ||
|
|
5378b45c40 | ||
|
|
ab3109d84b | ||
|
|
a4ab42da8a | ||
|
|
af87727ffc | ||
|
|
6b4e5c74ad | ||
|
|
94ab1e998d | ||
|
|
8af99878cc | ||
|
|
d6d2bc455c | ||
|
|
d5ff723d4c | ||
|
|
1d0af90ba2 | ||
|
|
b12d6c0758 | ||
|
|
a89677ea40 | ||
|
|
59572cd75d | ||
|
|
1d16206188 | ||
|
|
37a6ff8521 | ||
|
|
d3ea98fcef | ||
|
|
5022516c61 | ||
|
|
965d8ee014 | ||
|
|
8e50ad1243 | ||
|
|
33f40c47c6 | ||
|
|
1b3c2557b8 | ||
|
|
6b31d7cae3 | ||
|
|
1a4766c5a1 | ||
|
|
3e62e8406b | ||
|
|
e49dda3b48 | ||
|
|
bd447f0716 | ||
|
|
13faeaa0bd | ||
|
|
7f0fb2b610 | ||
|
|
7d2994388b | ||
|
|
edb5dc3fdc | ||
|
|
df1b1316c8 | ||
|
|
1a0c831216 | ||
|
|
f4365e4bb4 | ||
|
|
75d10a2dc3 | ||
|
|
da7cf7a4f3 | ||
|
|
6452eb56a9 | ||
|
|
9fce8153df | ||
|
|
4cdfa4e3f9 | ||
|
|
d6384df6fc | ||
|
|
f0bd06b38d | ||
|
|
d823856082 | ||
|
|
b02a82ba0f | ||
|
|
c43b013539 | ||
|
|
5548186c93 | ||
|
|
def9b553a8 | ||
|
|
35f7a8ea06 | ||
|
|
54bfb28063 | ||
|
|
80c63b96cf | ||
|
|
2ef9ecbc44 | ||
|
|
88812092fd | ||
|
|
4e01fc1838 | ||
|
|
5cab75f4a7 | ||
|
|
1345384d39 | ||
|
|
927013a57a | ||
|
|
0d11fccba2 | ||
|
|
d78ad756db | ||
|
|
5613bcc884 | ||
|
|
0729d730f8 | ||
|
|
f2422efeb8 | ||
|
|
cbb002ec4b | ||
|
|
c7e8c87f85 | ||
|
|
66ae1d6930 | ||
|
|
8e3885277f | ||
|
|
9293dfa477 | ||
|
|
8a80d89582 | ||
|
|
10ebd93df3 | ||
|
|
d414eef773 | ||
|
|
7d1f0ea8f4 | ||
|
|
f477e90192 | ||
|
|
b4dec78a72 | ||
|
|
60187dc59e | ||
|
|
4453aefad8 | ||
|
|
54cfda76ee | ||
|
|
1e8c2821d6 | ||
|
|
cbc030fbe2 | ||
|
|
b454116163 | ||
|
|
0186c6490f | ||
|
|
853a899c77 | ||
|
|
95a3d7fde2 | ||
|
|
d33e0a05e2 | ||
|
|
cb833b3f65 | ||
|
|
b73c50adeb | ||
|
|
fdfa45329a | ||
|
|
7b1880404c | ||
|
|
2739b1bafe | ||
|
|
cc782ff518 | ||
|
|
492bfbebe9 | ||
|
|
c9fbff265a | ||
|
|
b0f72d0690 | ||
|
|
6070a2c921 | ||
|
|
cb43b91ab6 | ||
|
|
804bc9e9c0 | ||
|
|
4514a67a1f | ||
|
|
edcba4ee16 | ||
|
|
9e28356047 | ||
|
|
44ad8c770f | ||
|
|
2dd4fa41a5 | ||
|
|
f5389b3859 | ||
|
|
65c8d74218 | ||
|
|
f88e3939e1 | ||
|
|
769778b05b | ||
|
|
f84ff0d778 | ||
|
|
ca1aabe21f | ||
|
|
dd801d1571 | ||
|
|
485730483b | ||
|
|
8b6733d792 | ||
|
|
75aabcce64 | ||
|
|
5dfa6b2bb4 | ||
|
|
3798a3c7d0 | ||
|
|
1c4b2243a6 | ||
|
|
c11493ec37 | ||
|
|
b6c8cdae64 | ||
|
|
b80d079d71 | ||
|
|
6512b038c5 | ||
|
|
6d1d497a63 | ||
|
|
6ea7140e8f | ||
|
|
7b311b0e4a | ||
|
|
be3018fe3b | ||
|
|
68095eb392 | ||
|
|
4bb34e4801 | ||
|
|
1348607c8f | ||
|
|
2f86779a27 | ||
|
|
2af632a46d | ||
|
|
05606f72ad | ||
|
|
6d0701e0fa | ||
|
|
76cdc17f3b | ||
|
|
7b076eadfa | ||
|
|
c5ce2a0a94 | ||
|
|
7fcc84156e | ||
|
|
75bf12db7a | ||
|
|
07de96459e | ||
|
|
be036aa9c8 | ||
|
|
0664895670 | ||
|
|
dde1e4bc0f | ||
|
|
122de63b71 | ||
|
|
e3ba880e18 | ||
|
|
e3be15531f | ||
|
|
5a3ff4e3dc | ||
|
|
f7f32f00a3 | ||
|
|
d7d694b14f | ||
|
|
a6feb6dd66 | ||
|
|
ecf10e41c3 | ||
|
|
481edc1cfe | ||
|
|
ff5817ab50 | ||
|
|
80235bf049 | ||
|
|
ecddd5a7be | ||
|
|
f22fc788e5 | ||
|
|
f828a582c3 | ||
|
|
a94f94f352 | ||
|
|
9f34a01577 | ||
|
|
9cd49ed485 | ||
|
|
4ea1a05af6 | ||
|
|
b6eb6d477b | ||
|
|
cce18d8e2e | ||
|
|
45d469ca5c | ||
|
|
fbee714ffe | ||
|
|
2429dcc2e2 | ||
|
|
4d84422f22 | ||
|
|
d98bfbde58 | ||
|
|
983787a8f2 | ||
|
|
7b83c22e78 | ||
|
|
c8c43b2811 | ||
|
|
7e32e2efcf | ||
|
|
6f8e842105 | ||
|
|
ce99c0aa0f | ||
|
|
3ff165402c | ||
|
|
a350a76a00 | ||
|
|
05b9dd1822 | ||
|
|
5207b1c127 | ||
|
|
267c351735 | ||
|
|
f545418e55 | ||
|
|
97dd832d2e | ||
|
|
d7e7d87581 | ||
|
|
bd2efeaaa3 | ||
|
|
a206bf56b9 | ||
|
|
a33e94c4ee | ||
|
|
e9313b1c9d | ||
|
|
8096935d87 | ||
|
|
dcb083abb0 | ||
|
|
6cc76fe6ab | ||
|
|
4f8de1881c | ||
|
|
9caba544eb | ||
|
|
746a8ca17f | ||
|
|
2475e1b501 | ||
|
|
193628d63f | ||
|
|
b6ce353a7d | ||
|
|
7a50603d9d | ||
|
|
d21fabca4b | ||
|
|
daa9a8ae45 | ||
|
|
d9eb5499a3 | ||
|
|
870c7897ad | ||
|
|
95da1c2907 | ||
|
|
2bfe522b72 | ||
|
|
c099bf9893 | ||
|
|
ab0dda1177 | ||
|
|
4f65953da9 | ||
|
|
d77de61a06 | ||
|
|
3287cf56bb | ||
|
|
b5c81d2721 | ||
|
|
d3522854b6 | ||
|
|
2f3f9de7be | ||
|
|
6890952357 | ||
|
|
d695fca301 | ||
|
|
a0d2392f01 | ||
|
|
23b4e03cd5 | ||
|
|
d5f72cb282 | ||
|
|
5f57bf81cd | ||
|
|
e32c9e4658 | ||
|
|
2a73505508 | ||
|
|
4d87ef4231 | ||
|
|
71be167592 | ||
|
|
c543036a0f | ||
|
|
989947b99a | ||
|
|
3d86d62a6e | ||
|
|
0cfe6597d4 | ||
|
|
8ae4428332 | ||
|
|
81b4e99ccc | ||
|
|
2f133a08aa | ||
|
|
6b17e688da | ||
|
|
8654066f03 | ||
|
|
56dae90425 | ||
|
|
1f6ef07860 | ||
|
|
f30a455ee3 | ||
|
|
03bd99cd11 | ||
|
|
cc389ec82b | ||
|
|
f85678b6dc | ||
|
|
8d7c869072 | ||
|
|
8f592d3f0a | ||
|
|
1f2e0ed189 | ||
|
|
4d6c428ba9 | ||
|
|
d095aa0182 | ||
|
|
15bf850280 | ||
|
|
62b273266e | ||
|
|
1d058177be | ||
|
|
14676b345a | ||
|
|
a50e6eed38 | ||
|
|
073a064ae8 | ||
|
|
e00a3d3cb4 | ||
|
|
68d9200a6b | ||
|
|
2551bb3e3f | ||
|
|
80b18e6315 | ||
|
|
e0561397f1 | ||
|
|
b9c3c38edc | ||
|
|
077ced0d1a | ||
|
|
e5ff84035c | ||
|
|
e18a983209 | ||
|
|
6f61fa07fb | ||
|
|
d5d73e02e9 | ||
|
|
4ba7454d8d | ||
|
|
5192a39830 | ||
|
|
aa5413b942 | ||
|
|
ef284e9bde | ||
|
|
9c41fe1d18 | ||
|
|
e577cf7302 | ||
|
|
ebf563ac70 | ||
|
|
909340c6fe | ||
|
|
df6d38df65 | ||
|
|
59a53e695b | ||
|
|
6d17505f7b | ||
|
|
36dd8ea1d2 | ||
|
|
b965ae926b | ||
|
|
f6eadbd1c9 | ||
|
|
bdbb884be0 | ||
|
|
0be39cfbc2 | ||
|
|
ef2aeac7de | ||
|
|
157afda2fc | ||
|
|
fb4d77ef46 | ||
|
|
575c233597 | ||
|
|
2e59d770f7 | ||
|
|
baf0ee9cde | ||
|
|
af89bb591d | ||
|
|
d0dec741ad | ||
|
|
33a82e395e | ||
|
|
f223896c26 | ||
|
|
de33b365ae | ||
|
|
e9d8547a81 | ||
|
|
dcff318a98 | ||
|
|
f725123690 | ||
|
|
e9e5d37ff0 | ||
|
|
f70cee6907 | ||
|
|
1491339f50 | ||
|
|
8a5ed59ff4 | ||
|
|
a2ca5e4d1e | ||
|
|
fba993502d | ||
|
|
9fae3a932b | ||
|
|
62610f0666 | ||
|
|
7282ec5286 | ||
|
|
9830e0104f | ||
|
|
e6fd0caf6b | ||
|
|
137df37bc7 | ||
|
|
d895706199 | ||
|
|
6ed7d418b5 | ||
|
|
62b8a83741 | ||
|
|
e795b501ac | ||
|
|
03228d8d20 | ||
|
|
c9c5d4cf79 | ||
|
|
f5cc5bc6a1 | ||
|
|
447494ad4d | ||
|
|
c9f178ec87 | ||
|
|
33be326ef6 | ||
|
|
c13f04d838 | ||
|
|
737685149c | ||
|
|
33eef0202d | ||
|
|
a67b1b8bb5 | ||
|
|
124b49456a | ||
|
|
24956087cc | ||
|
|
199ca57f1c | ||
|
|
64d53ac533 | ||
|
|
b3accbf9e0 | ||
|
|
99249a3160 | ||
|
|
f7cd8bad3a | ||
|
|
e9613d7f12 | ||
|
|
97dff042f7 | ||
|
|
32b36fb2af | ||
|
|
41535150dd | ||
|
|
8e69284e8c | ||
|
|
61cfac4eeb | ||
|
|
2720072b23 | ||
|
|
0413c3a38e | ||
|
|
f2b30c1fe0 | ||
|
|
3c86cf7d2e | ||
|
|
451074f7ed | ||
|
|
1e5601ca31 | ||
|
|
75c99cd235 | ||
|
|
bb2c2be9b6 | ||
|
|
53c247b9a1 | ||
|
|
82667d9d16 | ||
|
|
97ed2757f0 | ||
|
|
19fd5ca5f2 | ||
|
|
6ae78a770f | ||
|
|
04962b4cd6 | ||
|
|
f97850dd05 | ||
|
|
2cb3ed3ab9 | ||
|
|
a4421f50c6 | ||
|
|
cb726f40fa | ||
|
|
be026aa308 | ||
|
|
b95f6ca084 | ||
|
|
4a7f078abd | ||
|
|
54d8b8a373 | ||
|
|
dd6bd58140 | ||
|
|
4c56bd771a | ||
|
|
a70b26cd55 | ||
|
|
c4a7ae3164 | ||
|
|
8b8f654c9c | ||
|
|
9b247f6d63 | ||
|
|
f342fdc41d | ||
|
|
ca96f7f62b | ||
|
|
2f31eab8f4 | ||
|
|
c8528fd1f7 | ||
|
|
07ac85d9fa | ||
|
|
e84f214280 | ||
|
|
9cd65efad9 | ||
|
|
41200ab6d7 | ||
|
|
62fdaa633a | ||
|
|
79f5e6b498 | ||
|
|
23bd7e7817 | ||
|
|
792171c8fc | ||
|
|
051a468c63 | ||
|
|
1b226c7556 | ||
|
|
2bd9cc45fa |
@@ -1,15 +1,8 @@
|
|||||||
# Known minified files
|
# Ignore "third party" code whose style we will not change.
|
||||||
/boot/sjcl.js
|
/boot/sjcl.js
|
||||||
|
/core/modules/utils/base64-utf8/base64-utf8.module.js
|
||||||
/core/modules/utils/base64-utf8/base64-utf8.module.min.js
|
/core/modules/utils/base64-utf8/base64-utf8.module.min.js
|
||||||
/core/modules/utils/diff-match-patch/diff_match_patch.js
|
/core/modules/utils/diff-match-patch/diff_match_patch.js
|
||||||
/plugins/tiddlywiki/async/files/async.min.v1.5.0.js
|
/core/modules/utils/diff-match-patch/diff_match_patch_uncompressed.js
|
||||||
/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js
|
/core/modules/utils/dom/csscolorparser.js
|
||||||
/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js
|
/plugins/tiddlywiki/*/files/
|
||||||
/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js
|
|
||||||
/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js
|
|
||||||
/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js
|
|
||||||
/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js
|
|
||||||
/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/closebrackets.js
|
|
||||||
/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js
|
|
||||||
/plugins/tiddlywiki/codemirror-closetag/files/addon/edit/closetag.js
|
|
||||||
/plugins/tiddlywiki/codemirror-closetag/files/addon/fold/xml-fold.js
|
|
||||||
|
|||||||
@@ -64,7 +64,23 @@ rules:
|
|||||||
init-declarations: 'off'
|
init-declarations: 'off'
|
||||||
jsx-quotes: error
|
jsx-quotes: error
|
||||||
key-spacing: 'off'
|
key-spacing: 'off'
|
||||||
keyword-spacing: 'off'
|
keyword-spacing:
|
||||||
|
- error
|
||||||
|
- before: true
|
||||||
|
after: false
|
||||||
|
overrides:
|
||||||
|
'case':
|
||||||
|
after: true
|
||||||
|
'do':
|
||||||
|
'after': true
|
||||||
|
'else':
|
||||||
|
after: true
|
||||||
|
'return':
|
||||||
|
after: true
|
||||||
|
'throw':
|
||||||
|
after: true
|
||||||
|
'try':
|
||||||
|
after: true
|
||||||
line-comment-position: 'off'
|
line-comment-position: 'off'
|
||||||
linebreak-style: 'off'
|
linebreak-style: 'off'
|
||||||
lines-around-comment: 'off'
|
lines-around-comment: 'off'
|
||||||
|
|||||||
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -72,3 +72,6 @@ jobs:
|
|||||||
- run: "./bin/ci-push.sh"
|
- run: "./bin/ci-push.sh"
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }}
|
||||||
|
- run: "./bin/build-tw-org.sh"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# Default to the current version number for building the plugin library
|
# Default to the current version number for building the plugin library
|
||||||
|
|
||||||
if [ -z "$TW5_BUILD_VERSION" ]; then
|
if [ -z "$TW5_BUILD_VERSION" ]; then
|
||||||
TW5_BUILD_VERSION=v5.2.0
|
TW5_BUILD_VERSION=v5.2.2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
|
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
|
||||||
|
|||||||
97
bin/build-tw-org.sh
Executable file
97
bin/build-tw-org.sh
Executable file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Build tiddlywiki.org assets.
|
||||||
|
|
||||||
|
# Default to the version of TiddlyWiki installed in this repo
|
||||||
|
|
||||||
|
if [ -z "$TWORG_BUILD_TIDDLYWIKI" ]; then
|
||||||
|
TWORG_BUILD_TIDDLYWIKI=./tiddlywiki.js
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using TWORG_BUILD_TIDDLYWIKI as [$TWORG_BUILD_TIDDLYWIKI]"
|
||||||
|
|
||||||
|
# Set up the build details
|
||||||
|
|
||||||
|
if [ -z "$TWORG_BUILD_DETAILS" ]; then
|
||||||
|
TWORG_BUILD_DETAILS="$(git symbolic-ref --short HEAD)-$(git rev-parse HEAD) from $(git remote get-url origin)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using TWORG_BUILD_DETAILS as [$TWORG_BUILD_DETAILS]"
|
||||||
|
|
||||||
|
if [ -z "$TWORG_BUILD_COMMIT" ]; then
|
||||||
|
TWORG_BUILD_COMMIT="$(git rev-parse HEAD)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using TWORG_BUILD_COMMIT as [$TWORG_BUILD_COMMIT]"
|
||||||
|
|
||||||
|
# Set up the build output directory
|
||||||
|
|
||||||
|
if [ -z "$TWORG_BUILD_OUTPUT" ]; then
|
||||||
|
TWORG_BUILD_OUTPUT=$(mktemp -d)
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $TWORG_BUILD_OUTPUT
|
||||||
|
|
||||||
|
if [ ! -d "$TWORG_BUILD_OUTPUT" ]; then
|
||||||
|
echo 'A valid TWORG_BUILD_OUTPUT environment variable must be set'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using TWORG_BUILD_OUTPUT as [$TWORG_BUILD_OUTPUT]"
|
||||||
|
|
||||||
|
# Pull existing GitHub pages content
|
||||||
|
|
||||||
|
git clone --depth=1 --branch=main "https://github.com/TiddlyWiki/tiddlywiki.org-gh-pages.git" $TWORG_BUILD_OUTPUT
|
||||||
|
|
||||||
|
# Make the CNAME file that GitHub Pages requires
|
||||||
|
|
||||||
|
echo "tiddlywiki.org" > $TWORG_BUILD_OUTPUT/CNAME
|
||||||
|
|
||||||
|
# Delete any existing static content
|
||||||
|
|
||||||
|
mkdir -p $TWORG_BUILD_OUTPUT/static
|
||||||
|
rm $TWORG_BUILD_OUTPUT/static/*
|
||||||
|
|
||||||
|
# Put the build details into a .tid file so that it can be included in each build (deleted at the end of this script)
|
||||||
|
|
||||||
|
echo -e -n "title: $:/build\ncommit: $TWORG_BUILD_COMMIT\n\n$TWORG_BUILD_DETAILS\n" > $TWORG_BUILD_OUTPUT/build.tid
|
||||||
|
|
||||||
|
######################################################
|
||||||
|
#
|
||||||
|
# tiddlywiki.org distribution
|
||||||
|
#
|
||||||
|
######################################################
|
||||||
|
|
||||||
|
# /index.html Main site
|
||||||
|
# /favicon.ico Favicon for main site
|
||||||
|
# /static.html Static rendering of default tiddlers
|
||||||
|
# /alltiddlers.html Static rendering of all tiddlers
|
||||||
|
# /static/* Static single tiddlers
|
||||||
|
# /static/static.css Static stylesheet
|
||||||
|
# /static/favicon.ico Favicon for static pages
|
||||||
|
node $TWORG_BUILD_TIDDLYWIKI \
|
||||||
|
editions/tw.org \
|
||||||
|
--verbose \
|
||||||
|
--version \
|
||||||
|
--load $TWORG_BUILD_OUTPUT/build.tid \
|
||||||
|
--output $TWORG_BUILD_OUTPUT \
|
||||||
|
--build favicon static index \
|
||||||
|
|| exit 1
|
||||||
|
|
||||||
|
# Delete the temporary build tiddler
|
||||||
|
|
||||||
|
rm $TWORG_BUILD_OUTPUT/build.tid || exit 1
|
||||||
|
|
||||||
|
# Push output back to GitHub
|
||||||
|
|
||||||
|
# Exit script immediately if any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
pushd $TWORG_BUILD_OUTPUT
|
||||||
|
git config --global user.email "actions@github.com"
|
||||||
|
git config --global user.name "GitHub Actions"
|
||||||
|
git add -A .
|
||||||
|
git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))"
|
||||||
|
git remote add deploy "https://$GH_TOKEN@github.com/TiddlyWiki/tiddlywiki.org-gh-pages.git" &>/dev/null
|
||||||
|
git push deploy main &>/dev/null
|
||||||
|
popd
|
||||||
138
boot/boot.js
138
boot/boot.js
@@ -68,6 +68,26 @@ $tw.utils.isArrayEqual = function(array1,array2) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Add an entry to a sorted array if it doesn't already exist, while maintaining the sort order
|
||||||
|
*/
|
||||||
|
$tw.utils.insertSortedArray = function(array,value) {
|
||||||
|
var low = 0, high = array.length - 1, mid, cmp;
|
||||||
|
while(low <= high) {
|
||||||
|
mid = (low + high) >> 1;
|
||||||
|
cmp = value.localeCompare(array[mid]);
|
||||||
|
if(cmp > 0) {
|
||||||
|
low = mid + 1;
|
||||||
|
} else if(cmp < 0) {
|
||||||
|
high = mid - 1;
|
||||||
|
} else {
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array.splice(low,0,value);
|
||||||
|
return array;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Push entries onto an array, removing them first if they already exist in the array
|
Push entries onto an array, removing them first if they already exist in the array
|
||||||
array: array to modify (assumed to be free of duplicates)
|
array: array to modify (assumed to be free of duplicates)
|
||||||
@@ -256,6 +276,28 @@ $tw.utils.deepDefaults = function(object /*, sourceObjectList */) {
|
|||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Convert a URIComponent encoded string to a string safely
|
||||||
|
*/
|
||||||
|
$tw.utils.decodeURIComponentSafe = function(s) {
|
||||||
|
var v = s;
|
||||||
|
try {
|
||||||
|
v = decodeURIComponent(s);
|
||||||
|
} catch(e) {}
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Convert a URI encoded string to a string safely
|
||||||
|
*/
|
||||||
|
$tw.utils.decodeURISafe = function(s) {
|
||||||
|
var v = s;
|
||||||
|
try {
|
||||||
|
v = decodeURI(s);
|
||||||
|
} catch(e) {}
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Convert "&" to &, " " to nbsp, "<" to <, ">" to > and """ to "
|
Convert "&" to &, " " to nbsp, "<" to <, ">" to > and """ to "
|
||||||
*/
|
*/
|
||||||
@@ -387,6 +429,19 @@ $tw.utils.parseFields = function(text,fields) {
|
|||||||
return fields;
|
return fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Safely parse a string as JSON
|
||||||
|
$tw.utils.parseJSONSafe = function(text,defaultJSON) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(text);
|
||||||
|
} catch(e) {
|
||||||
|
if(typeof defaultJSON === "function") {
|
||||||
|
return defaultJSON(e);
|
||||||
|
} else {
|
||||||
|
return defaultJSON || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Resolves a source filepath delimited with `/` relative to a specified absolute root filepath.
|
Resolves a source filepath delimited with `/` relative to a specified absolute root filepath.
|
||||||
In relative paths, the special folder name `..` refers to immediate parent directory, and the
|
In relative paths, the special folder name `..` refers to immediate parent directory, and the
|
||||||
@@ -757,12 +812,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
|
|||||||
tiddler = $tw.wiki.getTiddler(name),
|
tiddler = $tw.wiki.getTiddler(name),
|
||||||
_exports = {},
|
_exports = {},
|
||||||
sandbox = {
|
sandbox = {
|
||||||
module: {
|
module: {exports: _exports},
|
||||||
exports: _exports,
|
|
||||||
setStringHandler: function(handler) {
|
|
||||||
moduleInfo.stringHandler = handler;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//moduleInfo: moduleInfo,
|
//moduleInfo: moduleInfo,
|
||||||
exports: _exports,
|
exports: _exports,
|
||||||
console: console,
|
console: console,
|
||||||
@@ -826,7 +876,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
|
|||||||
moduleInfo.definition(moduleInfo,moduleInfo.exports,sandbox.require);
|
moduleInfo.definition(moduleInfo,moduleInfo.exports,sandbox.require);
|
||||||
} else if(typeof moduleInfo.definition === "string") { // String
|
} else if(typeof moduleInfo.definition === "string") { // String
|
||||||
moduleInfo.exports = _exports;
|
moduleInfo.exports = _exports;
|
||||||
$tw.utils.evalSandboxed(moduleInfo.definition,sandbox,name);
|
$tw.utils.evalSandboxed(moduleInfo.definition,sandbox,tiddler.fields.title);
|
||||||
if(sandbox.module.exports) {
|
if(sandbox.module.exports) {
|
||||||
moduleInfo.exports = sandbox.module.exports; //more codemirror workaround
|
moduleInfo.exports = sandbox.module.exports; //more codemirror workaround
|
||||||
}
|
}
|
||||||
@@ -923,20 +973,6 @@ $tw.modules.createClassesFromModules = function(moduleType,subType,baseClass) {
|
|||||||
return classes;
|
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
|
/////////////////////////// Barebones tiddler object
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1078,7 +1114,7 @@ $tw.Wiki = function(options) {
|
|||||||
tiddlerTitles = null, // Array of tiddler titles
|
tiddlerTitles = null, // Array of tiddler titles
|
||||||
getTiddlerTitles = function() {
|
getTiddlerTitles = function() {
|
||||||
if(!tiddlerTitles) {
|
if(!tiddlerTitles) {
|
||||||
tiddlerTitles = Object.keys(tiddlers);
|
tiddlerTitles = Object.keys(tiddlers).sort(function(a,b) {return a.localeCompare(b);});
|
||||||
}
|
}
|
||||||
return tiddlerTitles;
|
return tiddlerTitles;
|
||||||
},
|
},
|
||||||
@@ -1131,10 +1167,8 @@ $tw.Wiki = function(options) {
|
|||||||
}
|
}
|
||||||
// Save the new tiddler
|
// Save the new tiddler
|
||||||
tiddlers[title] = tiddler;
|
tiddlers[title] = tiddler;
|
||||||
// Check we've got it's title
|
// Check we've got the title
|
||||||
if(tiddlerTitles && tiddlerTitles.indexOf(title) === -1) {
|
tiddlerTitles = $tw.utils.insertSortedArray(tiddlerTitles || [],title);
|
||||||
tiddlerTitles.push(title);
|
|
||||||
}
|
|
||||||
// Record the new tiddler state
|
// Record the new tiddler state
|
||||||
updateDescriptor["new"] = {
|
updateDescriptor["new"] = {
|
||||||
tiddler: tiddler,
|
tiddler: tiddler,
|
||||||
@@ -1231,8 +1265,12 @@ $tw.Wiki = function(options) {
|
|||||||
index,titlesLength,title;
|
index,titlesLength,title;
|
||||||
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
|
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
|
||||||
title = titles[index];
|
title = titles[index];
|
||||||
var shadowInfo = shadowTiddlers[title];
|
if(tiddlers[title]) {
|
||||||
callback(shadowInfo.tiddler,title);
|
callback(tiddlers[title],title);
|
||||||
|
} else {
|
||||||
|
var shadowInfo = shadowTiddlers[title];
|
||||||
|
callback(shadowInfo.tiddler,title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1315,7 +1353,7 @@ $tw.Wiki = function(options) {
|
|||||||
var tiddler = tiddlers[title];
|
var tiddler = tiddlers[title];
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
if(tiddler.fields.type === "application/json" && tiddler.hasField("plugin-type") && tiddler.fields.text) {
|
if(tiddler.fields.type === "application/json" && tiddler.hasField("plugin-type") && tiddler.fields.text) {
|
||||||
pluginInfo[tiddler.fields.title] = JSON.parse(tiddler.fields.text);
|
pluginInfo[tiddler.fields.title] = $tw.utils.parseJSONSafe(tiddler.fields.text);
|
||||||
results.modifiedPlugins.push(tiddler.fields.title);
|
results.modifiedPlugins.push(tiddler.fields.title);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1448,7 +1486,7 @@ $tw.Wiki.prototype.defineTiddlerModules = function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "application/json":
|
case "application/json":
|
||||||
$tw.modules.define(tiddler.fields.title,tiddler.fields["module-type"],JSON.parse(tiddler.fields.text));
|
$tw.modules.define(tiddler.fields.title,tiddler.fields["module-type"],$tw.utils.parseJSONSafe(tiddler.fields.text));
|
||||||
break;
|
break;
|
||||||
case "application/x-tiddler-dictionary":
|
case "application/x-tiddler-dictionary":
|
||||||
$tw.modules.define(tiddler.fields.title,tiddler.fields["module-type"],$tw.utils.parseFields(tiddler.fields.text));
|
$tw.modules.define(tiddler.fields.title,tiddler.fields["module-type"],$tw.utils.parseFields(tiddler.fields.text));
|
||||||
@@ -1621,8 +1659,8 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/json","tiddlerdeserializer",{
|
|||||||
}
|
}
|
||||||
for(var f in data) {
|
for(var f in data) {
|
||||||
if($tw.utils.hop(data,f)) {
|
if($tw.utils.hop(data,f)) {
|
||||||
// Check field name doesn't contain whitespace or control characters
|
// Check field name doesn't contain control characters
|
||||||
if(typeof(data[f]) !== "string" || /[\x00-\x1F\s]/.test(f)) {
|
if(typeof(data[f]) !== "string" || /[\x00-\x1F]/.test(f)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1637,7 +1675,7 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/json","tiddlerdeserializer",{
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
data = JSON.parse(text);
|
data = $tw.utils.parseJSONSafe(text);
|
||||||
if($tw.utils.isArray(data) && isTiddlerArrayValid(data)) {
|
if($tw.utils.isArray(data) && isTiddlerArrayValid(data)) {
|
||||||
return data;
|
return data;
|
||||||
} else if(isTiddlerValid(data)) {
|
} else if(isTiddlerValid(data)) {
|
||||||
@@ -1677,7 +1715,7 @@ $tw.boot.decryptEncryptedTiddlers = function(callback) {
|
|||||||
$tw.crypto.setPassword(data.password);
|
$tw.crypto.setPassword(data.password);
|
||||||
var decryptedText = $tw.crypto.decrypt(encryptedText);
|
var decryptedText = $tw.crypto.decrypt(encryptedText);
|
||||||
if(decryptedText) {
|
if(decryptedText) {
|
||||||
var json = JSON.parse(decryptedText);
|
var json = $tw.utils.parseJSONSafe(decryptedText);
|
||||||
for(var title in json) {
|
for(var title in json) {
|
||||||
$tw.preloadTiddler(json[title]);
|
$tw.preloadTiddler(json[title]);
|
||||||
}
|
}
|
||||||
@@ -1877,7 +1915,7 @@ filepath: pathname of the directory containing the specification file
|
|||||||
$tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
$tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
||||||
var tiddlers = [];
|
var tiddlers = [];
|
||||||
// Read the specification
|
// Read the specification
|
||||||
var filesInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8"));
|
var filesInfo = $tw.utils.parseJSONSafe(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8"));
|
||||||
// Helper to process a file
|
// Helper to process a file
|
||||||
var processFile = function(filename,isTiddlerFile,fields,isEditableFile) {
|
var processFile = function(filename,isTiddlerFile,fields,isEditableFile) {
|
||||||
var extInfo = $tw.config.fileExtensionInfo[path.extname(filename)],
|
var extInfo = $tw.config.fileExtensionInfo[path.extname(filename)],
|
||||||
@@ -1904,13 +1942,13 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
|||||||
value = path.basename(filename);
|
value = path.basename(filename);
|
||||||
break;
|
break;
|
||||||
case "filename-uri-decoded":
|
case "filename-uri-decoded":
|
||||||
value = decodeURIComponent(path.basename(filename));
|
value = $tw.utils.decodeURIComponentSafe(path.basename(filename));
|
||||||
break;
|
break;
|
||||||
case "basename":
|
case "basename":
|
||||||
value = path.basename(filename,path.extname(filename));
|
value = path.basename(filename,path.extname(filename));
|
||||||
break;
|
break;
|
||||||
case "basename-uri-decoded":
|
case "basename-uri-decoded":
|
||||||
value = decodeURIComponent(path.basename(filename,path.extname(filename)));
|
value = $tw.utils.decodeURIComponentSafe(path.basename(filename,path.extname(filename)));
|
||||||
break;
|
break;
|
||||||
case "extname":
|
case "extname":
|
||||||
value = path.extname(filename);
|
value = path.extname(filename);
|
||||||
@@ -1938,6 +1976,20 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
|||||||
tiddlers.push({tiddlers: fileTiddlers});
|
tiddlers.push({tiddlers: fileTiddlers});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// Helper to recursively search subdirectories
|
||||||
|
var getAllFiles = function(dirPath, recurse, arrayOfFiles) {
|
||||||
|
recurse = recurse || false;
|
||||||
|
arrayOfFiles = arrayOfFiles || [];
|
||||||
|
var files = fs.readdirSync(dirPath);
|
||||||
|
files.forEach(function(file) {
|
||||||
|
if (recurse && fs.statSync(dirPath + path.sep + file).isDirectory()) {
|
||||||
|
arrayOfFiles = getAllFiles(dirPath + path.sep + file, recurse, arrayOfFiles);
|
||||||
|
} else if(fs.statSync(dirPath + path.sep + file).isFile()){
|
||||||
|
arrayOfFiles.push(path.join(dirPath, path.sep, file));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return arrayOfFiles;
|
||||||
|
}
|
||||||
// Process the listed tiddlers
|
// Process the listed tiddlers
|
||||||
$tw.utils.each(filesInfo.tiddlers,function(tidInfo) {
|
$tw.utils.each(filesInfo.tiddlers,function(tidInfo) {
|
||||||
if(tidInfo.prefix && tidInfo.suffix) {
|
if(tidInfo.prefix && tidInfo.suffix) {
|
||||||
@@ -1961,13 +2013,14 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
|||||||
// Process directory specifier
|
// Process directory specifier
|
||||||
var dirPath = path.resolve(filepath,dirSpec.path);
|
var dirPath = path.resolve(filepath,dirSpec.path);
|
||||||
if(fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()) {
|
if(fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()) {
|
||||||
var files = fs.readdirSync(dirPath),
|
var files = getAllFiles(dirPath, dirSpec.searchSubdirectories),
|
||||||
fileRegExp = new RegExp(dirSpec.filesRegExp || "^.*$"),
|
fileRegExp = new RegExp(dirSpec.filesRegExp || "^.*$"),
|
||||||
metaRegExp = /^.*\.meta$/;
|
metaRegExp = /^.*\.meta$/;
|
||||||
for(var t=0; t<files.length; t++) {
|
for(var t=0; t<files.length; t++) {
|
||||||
var filename = files[t];
|
var thisPath = path.relative(filepath, files[t]),
|
||||||
|
filename = path.basename(thisPath);
|
||||||
if(filename !== "tiddlywiki.files" && !metaRegExp.test(filename) && fileRegExp.test(filename)) {
|
if(filename !== "tiddlywiki.files" && !metaRegExp.test(filename) && fileRegExp.test(filename)) {
|
||||||
processFile(dirPath + path.sep + filename,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile);
|
processFile(thisPath,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1992,7 +2045,7 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
|
|||||||
console.log("Warning: missing plugin.info file in " + filepath);
|
console.log("Warning: missing plugin.info file in " + filepath);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var pluginInfo = JSON.parse(fs.readFileSync(infoPath,"utf8"));
|
var pluginInfo = $tw.utils.parseJSONSafe(fs.readFileSync(infoPath,"utf8"));
|
||||||
// Read the plugin files
|
// Read the plugin files
|
||||||
var pluginFiles = $tw.loadTiddlersFromPath(filepath,excludeRegExp);
|
var pluginFiles = $tw.loadTiddlersFromPath(filepath,excludeRegExp);
|
||||||
// Save the plugin tiddlers into the plugin info
|
// Save the plugin tiddlers into the plugin info
|
||||||
@@ -2109,7 +2162,7 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
|
|||||||
pluginFields;
|
pluginFields;
|
||||||
// Bail if we don't have a wiki info file
|
// Bail if we don't have a wiki info file
|
||||||
if(fs.existsSync(wikiInfoPath)) {
|
if(fs.existsSync(wikiInfoPath)) {
|
||||||
wikiInfo = JSON.parse(fs.readFileSync(wikiInfoPath,"utf8"));
|
wikiInfo = $tw.utils.parseJSONSafe(fs.readFileSync(wikiInfoPath,"utf8"));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -2622,3 +2675,4 @@ if(typeof(exports) !== "undefined") {
|
|||||||
} else {
|
} else {
|
||||||
_boot(window.$tw);
|
_boot(window.$tw);
|
||||||
}
|
}
|
||||||
|
//# sourceURL=$:/boot/boot.js
|
||||||
|
|||||||
@@ -117,3 +117,4 @@ if(typeof(exports) === "undefined") {
|
|||||||
// Export functionality as a module
|
// Export functionality as a module
|
||||||
exports.bootprefix = _bootprefix;
|
exports.bootprefix = _bootprefix;
|
||||||
}
|
}
|
||||||
|
//# sourceURL=$:/boot/bootprefix.js
|
||||||
|
|||||||
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)
|
TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)
|
||||||
|
|
||||||
Copyright (c) 2004-2007, Jeremy Ruston
|
Copyright (c) 2004-2007, Jeremy Ruston
|
||||||
Copyright (c) 2007-2021, UnaMesa Association
|
Copyright (c) 2007-2022, UnaMesa Association
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
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,8 +32,6 @@ ExportTiddler/Caption: export tiddler
|
|||||||
ExportTiddler/Hint: Export tiddler
|
ExportTiddler/Hint: Export tiddler
|
||||||
ExportTiddlers/Caption: export tiddlers
|
ExportTiddlers/Caption: export tiddlers
|
||||||
ExportTiddlers/Hint: 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
|
SidebarSearch/Hint: Select the sidebar search field
|
||||||
Fold/Caption: fold tiddler
|
Fold/Caption: fold tiddler
|
||||||
Fold/Hint: Fold the body of this tiddler
|
Fold/Hint: Fold the body of this tiddler
|
||||||
@@ -85,8 +83,6 @@ Permaview/Caption: permaview
|
|||||||
Permaview/Hint: Set browser address bar to a direct link to all the tiddlers in this story
|
Permaview/Hint: Set browser address bar to a direct link to all the tiddlers in this story
|
||||||
Print/Caption: print page
|
Print/Caption: print page
|
||||||
Print/Hint: Print the current page
|
Print/Hint: Print the current page
|
||||||
Publish/Caption: publish
|
|
||||||
Publish/Hint: Publish from the wiki
|
|
||||||
Refresh/Caption: refresh
|
Refresh/Caption: refresh
|
||||||
Refresh/Hint: Perform a full refresh of the wiki
|
Refresh/Hint: Perform a full refresh of the wiki
|
||||||
Save/Caption: ok
|
Save/Caption: ok
|
||||||
|
|||||||
@@ -27,10 +27,17 @@ Basics/Tiddlers/Prompt: Number of tiddlers
|
|||||||
Basics/Title/Prompt: Title of this ~TiddlyWiki
|
Basics/Title/Prompt: Title of this ~TiddlyWiki
|
||||||
Basics/Username/Prompt: Username for signing edits
|
Basics/Username/Prompt: Username for signing edits
|
||||||
Basics/Version/Prompt: ~TiddlyWiki version
|
Basics/Version/Prompt: ~TiddlyWiki version
|
||||||
|
Cascades/Caption: Cascades
|
||||||
|
Cascades/Hint: These global rules are used to dynamically choose certain templates. The result of the cascade is the result of the first filter in the sequence that returns a result
|
||||||
|
Cascades/TagPrompt: Filters tagged <$macrocall $name="tag" tag=<<currentTiddler>>/>
|
||||||
EditorTypes/Caption: Editor Types
|
EditorTypes/Caption: Editor Types
|
||||||
EditorTypes/Editor/Caption: Editor
|
EditorTypes/Editor/Caption: Editor
|
||||||
EditorTypes/Hint: These tiddlers determine which editor is used to edit specific tiddler types.
|
EditorTypes/Hint: These tiddlers determine which editor is used to edit specific tiddler types.
|
||||||
EditorTypes/Type/Caption: Type
|
EditorTypes/Type/Caption: Type
|
||||||
|
EditTemplateBody/Caption: Edit Template Body
|
||||||
|
EditTemplateBody/Hint: This rule cascade is used by the default edit template to dynamically choose the template for editing the body of a tiddler.
|
||||||
|
FieldEditor/Caption: Field Editor
|
||||||
|
FieldEditor/Hint: This rules cascade is used to dynamically choose the template for rendering a tiddler field based on its name. It is used within the Edit Template.
|
||||||
Info/Caption: Info
|
Info/Caption: Info
|
||||||
Info/Hint: Information about this TiddlyWiki
|
Info/Hint: Information about this TiddlyWiki
|
||||||
KeyboardShortcuts/Add/Prompt: Type shortcut here
|
KeyboardShortcuts/Add/Prompt: Type shortcut here
|
||||||
@@ -96,8 +103,6 @@ Plugins/Updates/Caption: Updates
|
|||||||
Plugins/Updates/Hint: Available updates to installed plugins
|
Plugins/Updates/Hint: Available updates to installed plugins
|
||||||
Plugins/Updates/UpdateAll/Caption: Update <<update-count>> plugins
|
Plugins/Updates/UpdateAll/Caption: Update <<update-count>> plugins
|
||||||
Plugins/SubPluginPrompt: With <<count>> sub-plugins available
|
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/Caption: Saving
|
||||||
Saving/DownloadSaver/AutoSave/Description: Permit automatic saving for the download saver
|
Saving/DownloadSaver/AutoSave/Description: Permit automatic saving for the download saver
|
||||||
Saving/DownloadSaver/AutoSave/Hint: Enable Autosave for Download Saver
|
Saving/DownloadSaver/AutoSave/Hint: Enable Autosave for Download Saver
|
||||||
@@ -193,6 +198,8 @@ Settings/TitleLinks/Yes/Description: Display tiddler titles as links
|
|||||||
Settings/MissingLinks/Caption: Wiki Links
|
Settings/MissingLinks/Caption: Wiki Links
|
||||||
Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist yet
|
Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist yet
|
||||||
Settings/MissingLinks/Description: Enable links to missing tiddlers
|
Settings/MissingLinks/Description: Enable links to missing tiddlers
|
||||||
|
StoryTiddler/Caption: Story Tiddler
|
||||||
|
StoryTiddler/Hint: This rule cascade is used to dynamically choose the template for displaying a tiddler in the story river.
|
||||||
StoryView/Caption: Story View
|
StoryView/Caption: Story View
|
||||||
StoryView/Prompt: Current view:
|
StoryView/Prompt: Current view:
|
||||||
Stylesheets/Caption: Stylesheets
|
Stylesheets/Caption: Stylesheets
|
||||||
@@ -203,6 +210,10 @@ Theme/Caption: Theme
|
|||||||
Theme/Prompt: Current theme:
|
Theme/Prompt: Current theme:
|
||||||
TiddlerFields/Caption: Tiddler Fields
|
TiddlerFields/Caption: Tiddler Fields
|
||||||
TiddlerFields/Hint: This is the full set of TiddlerFields in use in this wiki (including system tiddlers but excluding shadow tiddlers).
|
TiddlerFields/Hint: This is the full set of TiddlerFields in use in this wiki (including system tiddlers but excluding shadow tiddlers).
|
||||||
|
TiddlerColour/Caption: Tiddler Colour
|
||||||
|
TiddlerColour/Hint: This rules cascade is used to dynamically choose the colour for a tiddler (used for the icon and the associated tag pill).
|
||||||
|
TiddlerIcon/Caption: Tiddler Icon
|
||||||
|
TiddlerIcon/Hint: This rules cascade is used to dynamically choose the icon for a tiddler.
|
||||||
Toolbars/Caption: Toolbars
|
Toolbars/Caption: Toolbars
|
||||||
Toolbars/EditToolbar/Caption: Edit Toolbar
|
Toolbars/EditToolbar/Caption: Edit Toolbar
|
||||||
Toolbars/EditToolbar/Hint: Choose which buttons are displayed for tiddlers in edit mode. Drag and drop to change the ordering
|
Toolbars/EditToolbar/Hint: Choose which buttons are displayed for tiddlers in edit mode. Drag and drop to change the ordering
|
||||||
@@ -214,3 +225,7 @@ Toolbars/EditorToolbar/Hint: Choose which buttons are displayed in the editor to
|
|||||||
Toolbars/ViewToolbar/Caption: View Toolbar
|
Toolbars/ViewToolbar/Caption: View Toolbar
|
||||||
Toolbars/ViewToolbar/Hint: Choose which buttons are displayed for tiddlers in view mode. Drag and drop to change the ordering
|
Toolbars/ViewToolbar/Hint: Choose which buttons are displayed for tiddlers in view mode. Drag and drop to change the ordering
|
||||||
Tools/Download/Full/Caption: Download full wiki
|
Tools/Download/Full/Caption: Download full wiki
|
||||||
|
ViewTemplateBody/Caption: View Template Body
|
||||||
|
ViewTemplateBody/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the body of a tiddler.
|
||||||
|
ViewTemplateTitle/Caption: View Template Title
|
||||||
|
ViewTemplateTitle/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the title of a tiddler.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ title: $:/language/Docs/Fields/
|
|||||||
_canonical_uri: The full URI of an external image tiddler
|
_canonical_uri: The full URI of an external image tiddler
|
||||||
bag: The name of the bag from which a tiddler came
|
bag: The name of the bag from which a tiddler came
|
||||||
caption: The text to be displayed on a tab or button
|
caption: The text to be displayed on a tab or button
|
||||||
|
code-body: The view template will display the tiddler as code if set to ''yes''
|
||||||
color: The CSS color value associated with a tiddler
|
color: The CSS color value associated with a tiddler
|
||||||
component: The name of the component responsible for an [[alert tiddler|AlertMechanism]]
|
component: The name of the component responsible for an [[alert tiddler|AlertMechanism]]
|
||||||
current-tiddler: Used to cache the top tiddler in a [[history list|HistoryMechanism]]
|
current-tiddler: Used to cache the top tiddler in a [[history list|HistoryMechanism]]
|
||||||
@@ -13,9 +14,9 @@ description: The descriptive text for a plugin, or a modal dialogue
|
|||||||
draft.of: For draft tiddlers, contains the title of the tiddler of which this is a draft
|
draft.of: For draft tiddlers, contains the title of the tiddler of which this is a draft
|
||||||
draft.title: For draft tiddlers, contains the proposed new title of the tiddler
|
draft.title: For draft tiddlers, contains the proposed new title of the tiddler
|
||||||
footer: The footer text for a wizard
|
footer: The footer text for a wizard
|
||||||
hide-body: The view template will hide bodies of tiddlers if set to: ''yes''
|
hide-body: The view template will hide bodies of tiddlers if set to ''yes''
|
||||||
icon: The title of the tiddler containing the icon associated with a tiddler
|
icon: The title of the tiddler containing the icon associated with a tiddler
|
||||||
library: Indicates that a tiddler should be saved as a JavaScript library if set to: ''yes''
|
library: Indicates that a tiddler should be saved as a JavaScript library if set to ''yes''
|
||||||
list: An ordered list of tiddler titles associated with a tiddler
|
list: An ordered list of tiddler titles associated with a tiddler
|
||||||
list-before: If set, the title of a tiddler before which this tiddler should be added to the ordered list of tiddler titles, or at the start of the list if this field is present but empty
|
list-before: If set, the title of a tiddler before which this tiddler should be added to the ordered list of tiddler titles, or at the start of the list if this field is present but empty
|
||||||
list-after: If set, the title of the tiddler after which this tiddler should be added to the ordered list of tiddler titles, or at the end of the list if this field is present but empty
|
list-after: If set, the title of the tiddler after which this tiddler should be added to the ordered list of tiddler titles, or at the end of the list if this field is present but empty
|
||||||
@@ -32,7 +33,7 @@ tags: A list of tags associated with a tiddler
|
|||||||
text: The body text of a tiddler
|
text: The body text of a tiddler
|
||||||
throttle.refresh: If present, throttles refreshes of this tiddler
|
throttle.refresh: If present, throttles refreshes of this tiddler
|
||||||
title: The unique name of a tiddler
|
title: The unique name of a tiddler
|
||||||
toc-link: Suppresses the tiddler's link in a Table of Contents tree if set to: ''no''
|
toc-link: Suppresses the tiddler's link in a Table of Contents tree if set to ''no''
|
||||||
type: The content type of a tiddler
|
type: The content type of a tiddler
|
||||||
version: Version information for a plugin
|
version: Version information for a plugin
|
||||||
_is_skinny: If present, indicates that the tiddler text field must be loaded from the server
|
_is_skinny: If present, indicates that the tiddler text field must be loaded from the server
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ All parameters are optional with safe defaults, and can be specified in any orde
|
|||||||
* ''readers'' - comma-separated list of principals allowed to read from 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
|
* ''writers'' - comma-separated list of principals allowed to write to this wiki
|
||||||
* ''csrf-disable'' - set to "yes" to disable CSRF checks (defaults to "no")
|
* ''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-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-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")
|
* ''root-serve-type'' - the content type with which the root tiddler should be served (defaults to "text/html")
|
||||||
|
|||||||
@@ -30,5 +30,5 @@ 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/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/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
|
||||||
Upgrader/Tiddler/Disabled: Disabled tiddler.
|
Upgrader/Tiddler/Disabled: Disabled tiddler.
|
||||||
Upgrader/Tiddler/Selected: User selected.
|
Upgrader/Tiddler/Selected: Selected tiddler.
|
||||||
Upgrader/Tiddler/Unselected: Unselected tiddler.
|
Upgrader/Tiddler/Unselected: Unselected tiddler.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ ConfirmAction: Do you wish to proceed?
|
|||||||
Count: count
|
Count: count
|
||||||
DefaultNewTiddlerTitle: New Tiddler
|
DefaultNewTiddlerTitle: New Tiddler
|
||||||
Diffs/CountMessage: <<diff-count>> differences
|
Diffs/CountMessage: <<diff-count>> differences
|
||||||
DropMessage: Drop here (or use the 'Escape' key to cancel)
|
DropMessage: Drop now (or use the 'Escape' key to cancel)
|
||||||
Encryption/Cancel: Cancel
|
Encryption/Cancel: Cancel
|
||||||
Encryption/ConfirmClearPassword: Do you wish to clear the password? This will remove the encryption applied when saving this wiki
|
Encryption/ConfirmClearPassword: Do you wish to clear the password? This will remove the encryption applied when saving this wiki
|
||||||
Encryption/PromptSetPassword: Set a new password for this TiddlyWiki
|
Encryption/PromptSetPassword: Set a new password for this TiddlyWiki
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
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.
|
|
||||||
@@ -48,7 +48,7 @@ Command.prototype.execute = function() {
|
|||||||
}
|
}
|
||||||
// Tweak the tiddlywiki.info to remove any included wikis
|
// Tweak the tiddlywiki.info to remove any included wikis
|
||||||
var packagePath = $tw.boot.wikiPath + "/tiddlywiki.info",
|
var packagePath = $tw.boot.wikiPath + "/tiddlywiki.info",
|
||||||
packageJson = JSON.parse(fs.readFileSync(packagePath));
|
packageJson = $tw.utils.parseJSONSafe(fs.readFileSync(packagePath));
|
||||||
delete packageJson.includeWikis;
|
delete packageJson.includeWikis;
|
||||||
fs.writeFileSync(packagePath,JSON.stringify(packageJson,null,$tw.config.preferences.jsonSpaces));
|
fs.writeFileSync(packagePath,JSON.stringify(packageJson,null,$tw.config.preferences.jsonSpaces));
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
/*\
|
|
||||||
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;
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -8,58 +8,59 @@ Render individual tiddlers and save the results to the specified files
|
|||||||
\*/
|
\*/
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
/*jslint node: true, browser: true */
|
||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js");
|
var widget = require("$:/core/modules/widgets/widget.js");
|
||||||
|
|
||||||
exports.info = {
|
exports.info = {
|
||||||
name: "render",
|
name: "render",
|
||||||
synchronous: true
|
synchronous: true
|
||||||
};
|
};
|
||||||
|
|
||||||
var Command = function(params,commander,callback) {
|
var Command = function(params,commander,callback) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.commander = commander;
|
this.commander = commander;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
Command.prototype.execute = function() {
|
Command.prototype.execute = function() {
|
||||||
if(this.params.length < 1) {
|
if(this.params.length < 1) {
|
||||||
return "Missing tiddler filter";
|
return "Missing tiddler filter";
|
||||||
}
|
|
||||||
var self = this,
|
|
||||||
fs = require("fs"),
|
|
||||||
path = require("path"),
|
|
||||||
wiki = this.commander.wiki,
|
|
||||||
tiddlerFilter = this.params[0],
|
|
||||||
filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]",
|
|
||||||
type = this.params[2] || "text/html",
|
|
||||||
template = this.params[3],
|
|
||||||
variableList = this.params.slice(4),
|
|
||||||
tiddlers = wiki.filterTiddlers(tiddlerFilter),
|
|
||||||
variables = Object.create(null);
|
|
||||||
while(variableList.length >= 2) {
|
|
||||||
variables[variableList[0]] = variableList[1];
|
|
||||||
variableList = variableList.slice(2);
|
|
||||||
}
|
|
||||||
$tw.utils.each(tiddlers,function(title) {
|
|
||||||
var 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,
|
|
||||||
filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
|
|
||||||
if(self.commander.verbose) {
|
|
||||||
console.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
|
|
||||||
}
|
}
|
||||||
$tw.utils.createFileDirectories(filepath);
|
var self = this,
|
||||||
fs.writeFileSync(filepath,text,"utf8");
|
fs = require("fs"),
|
||||||
});
|
path = require("path"),
|
||||||
return null;
|
wiki = this.commander.wiki,
|
||||||
};
|
tiddlerFilter = this.params[0],
|
||||||
|
filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]",
|
||||||
exports.Command = Command;
|
type = this.params[2] || "text/html",
|
||||||
|
template = this.params[3],
|
||||||
})();
|
variableList = this.params.slice(4),
|
||||||
|
tiddlers = wiki.filterTiddlers(tiddlerFilter),
|
||||||
|
variables = Object.create(null);
|
||||||
|
while(variableList.length >= 2) {
|
||||||
|
variables[variableList[0]] = variableList[1];
|
||||||
|
variableList = variableList.slice(2);
|
||||||
|
}
|
||||||
|
$tw.utils.each(tiddlers,function(title) {
|
||||||
|
var filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]);
|
||||||
|
if(self.commander.verbose) {
|
||||||
|
console.log("Rendering \"" + title + "\" to \"" + filepath + "\"");
|
||||||
|
}
|
||||||
|
var parser = wiki.parseTiddler(template || title),
|
||||||
|
widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title})}),
|
||||||
|
container = $tw.fakeDocument.createElement("div");
|
||||||
|
widgetNode.render(container,null);
|
||||||
|
var text = type === "text/html" ? container.innerHTML : container.textContent;
|
||||||
|
$tw.utils.createFileDirectories(filepath);
|
||||||
|
fs.writeFileSync(filepath,text,"utf8");
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Command = Command;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ Command.prototype.execute = function() {
|
|||||||
$tw.utils.createFileDirectories(pathname);
|
$tw.utils.createFileDirectories(pathname);
|
||||||
fs.writeFileSync(pathname,JSON.stringify(tiddler),"utf8");
|
fs.writeFileSync(pathname,JSON.stringify(tiddler),"utf8");
|
||||||
// Collect the skinny list data
|
// Collect the skinny list data
|
||||||
var pluginTiddlers = JSON.parse(tiddler.text),
|
var pluginTiddlers = $tw.utils.parseJSONSafe(tiddler.text),
|
||||||
readmeContent = (pluginTiddlers.tiddlers[title + "/readme"] || {}).text,
|
readmeContent = (pluginTiddlers.tiddlers[title + "/readme"] || {}).text,
|
||||||
doesRequireReload = !!self.commander.wiki.doesPluginInfoRequireReload(pluginTiddlers),
|
doesRequireReload = !!self.commander.wiki.doesPluginInfoRequireReload(pluginTiddlers),
|
||||||
iconTiddler = pluginTiddlers.tiddlers[title + "/icon"] || {},
|
iconTiddler = pluginTiddlers.tiddlers[title + "/icon"] || {},
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ WikiFolderMaker.prototype.saveCustomPlugin = function(pluginTiddler) {
|
|||||||
pluginInfo = pluginTiddler.getFieldStrings({exclude: ["text","type"]});
|
pluginInfo = pluginTiddler.getFieldStrings({exclude: ["text","type"]});
|
||||||
this.saveJSONFile(directory + path.sep + "plugin.info",pluginInfo);
|
this.saveJSONFile(directory + path.sep + "plugin.info",pluginInfo);
|
||||||
self.log("Writing " + directory + path.sep + "plugin.info: " + JSON.stringify(pluginInfo,null,$tw.config.preferences.jsonSpaces));
|
self.log("Writing " + directory + path.sep + "plugin.info: " + JSON.stringify(pluginInfo,null,$tw.config.preferences.jsonSpaces));
|
||||||
var pluginTiddlers = JSON.parse(pluginTiddler.fields.text).tiddlers; // A hashmap of tiddlers in the plugin
|
var pluginTiddlers = $tw.utils.parseJSONSafe(pluginTiddler.fields.text).tiddlers; // A hashmap of tiddlers in the plugin
|
||||||
$tw.utils.each(pluginTiddlers,function(tiddler) {
|
$tw.utils.each(pluginTiddlers,function(tiddler) {
|
||||||
self.saveTiddler(directory,new $tw.Tiddler(tiddler));
|
self.saveTiddler(directory,new $tw.Tiddler(tiddler));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,16 +17,13 @@ exports["application/x-tiddler-html-div"] = function(text,fields) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports["application/json"] = function(text,fields) {
|
exports["application/json"] = function(text,fields) {
|
||||||
var incoming,
|
var results = [],
|
||||||
results = [];
|
incoming = $tw.utils.parseJSONSafe(text,function(err) {
|
||||||
try {
|
return [{
|
||||||
incoming = JSON.parse(text);
|
title: "JSON error: " + err,
|
||||||
} catch(e) {
|
text: ""
|
||||||
incoming = [{
|
}];
|
||||||
title: "JSON error: " + e,
|
});
|
||||||
text: ""
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
if(!$tw.utils.isArray(incoming)) {
|
if(!$tw.utils.isArray(incoming)) {
|
||||||
incoming = [incoming];
|
incoming = [incoming];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,11 @@ FramedEngine.prototype.setText = function(text,type) {
|
|||||||
Update the DomNode with the new text
|
Update the DomNode with the new text
|
||||||
*/
|
*/
|
||||||
FramedEngine.prototype.updateDomNodeText = function(text) {
|
FramedEngine.prototype.updateDomNodeText = function(text) {
|
||||||
this.domNode.value = text;
|
try {
|
||||||
|
this.domNode.value = text;
|
||||||
|
} catch(e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -201,7 +205,7 @@ FramedEngine.prototype.handleInputEvent = function(event) {
|
|||||||
this.widget.saveChanges(this.getText());
|
this.widget.saveChanges(this.getText());
|
||||||
this.fixHeight();
|
this.fixHeight();
|
||||||
if(this.widget.editInputActions) {
|
if(this.widget.editInputActions) {
|
||||||
this.widget.invokeActionString(this.widget.editInputActions);
|
this.widget.invokeActionString(this.widget.editInputActions,this,event,{actionValue: this.getText()});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,7 +85,11 @@ SimpleEngine.prototype.setText = function(text,type) {
|
|||||||
Update the DomNode with the new text
|
Update the DomNode with the new text
|
||||||
*/
|
*/
|
||||||
SimpleEngine.prototype.updateDomNodeText = function(text) {
|
SimpleEngine.prototype.updateDomNodeText = function(text) {
|
||||||
this.domNode.value = text;
|
try {
|
||||||
|
this.domNode.value = text;
|
||||||
|
} catch(e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -129,7 +133,7 @@ SimpleEngine.prototype.handleInputEvent = function(event) {
|
|||||||
this.widget.saveChanges(this.getText());
|
this.widget.saveChanges(this.getText());
|
||||||
this.fixHeight();
|
this.fixHeight();
|
||||||
if(this.widget.editInputActions) {
|
if(this.widget.editInputActions) {
|
||||||
this.widget.invokeActionString(this.widget.editInputActions);
|
this.widget.invokeActionString(this.widget.editInputActions,this,event,{actionValue: this.getText()});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
If there are no Files, let the browser handle it.
|
If there are no Files, let the browser handle it.
|
||||||
*/
|
*/
|
||||||
EditTextWidget.prototype.handleDropEvent = function(event) {
|
EditTextWidget.prototype.handleDropEvent = function(event) {
|
||||||
if(event.dataTransfer.files.length) {
|
if($tw.utils.dragEventContainsFiles(event)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
||||||
@@ -332,7 +332,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EditTextWidget.prototype.handlePasteEvent = function(event) {
|
EditTextWidget.prototype.handlePasteEvent = function(event) {
|
||||||
if(event.clipboardData.files.length) {
|
if(event.clipboardData && event.clipboardData.files && event.clipboardData.files.length) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.dispatchDOMEvent(this.cloneEvent(event,["clipboardData"]));
|
this.dispatchDOMEvent(this.cloneEvent(event,["clipboardData"]));
|
||||||
|
|||||||
17
core/modules/editor/operations/text/focus-editor.js
Normal file
17
core/modules/editor/operations/text/focus-editor.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/editor/operations/text/focus-editor.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: texteditoroperation
|
||||||
|
Simply focus the Text editor
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports["focus-editor"] = function(event,operation) {
|
||||||
|
operation = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -13,15 +13,17 @@ Text editor operation to wrap the selected lines with a prefix and suffix
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports["wrap-lines"] = function(event,operation) {
|
exports["wrap-lines"] = function(event,operation) {
|
||||||
|
var prefix = event.paramObject.prefix || "",
|
||||||
|
suffix = event.paramObject.suffix || "";
|
||||||
// Cut just past the preceding line break, or the start of the text
|
// Cut just past the preceding line break, or the start of the text
|
||||||
operation.cutStart = $tw.utils.findPrecedingLineBreak(operation.text,operation.selStart);
|
operation.cutStart = $tw.utils.findPrecedingLineBreak(operation.text,operation.selStart);
|
||||||
// Cut to just past the following line break, or to the end of the text
|
// Cut to just past the following line break, or to the end of the text
|
||||||
operation.cutEnd = $tw.utils.findFollowingLineBreak(operation.text,operation.selEnd);
|
operation.cutEnd = $tw.utils.findFollowingLineBreak(operation.text,operation.selEnd);
|
||||||
// Add the prefix and suffix
|
// Add the prefix and suffix
|
||||||
operation.replacement = event.paramObject.prefix + "\n" +
|
operation.replacement = prefix + "\n" +
|
||||||
operation.text.substring(operation.cutStart,operation.cutEnd) + "\n" +
|
operation.text.substring(operation.cutStart,operation.cutEnd) + "\n" +
|
||||||
event.paramObject.suffix + "\n";
|
suffix + "\n";
|
||||||
operation.newSelStart = operation.cutStart + event.paramObject.prefix.length + 1;
|
operation.newSelStart = operation.cutStart + prefix.length + 1;
|
||||||
operation.newSelEnd = operation.newSelStart + (operation.cutEnd - operation.cutStart);
|
operation.newSelEnd = operation.newSelStart + (operation.cutEnd - operation.cutStart);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
53
core/modules/filterrunprefixes/cascade.js
Normal file
53
core/modules/filterrunprefixes/cascade.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filterrunprefixes/cascade.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filterrunprefix
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter prefix function
|
||||||
|
*/
|
||||||
|
exports.cascade = function(operationSubFunction,options) {
|
||||||
|
return function(results,source,widget) {
|
||||||
|
if(results.length !== 0) {
|
||||||
|
var filterList = operationSubFunction(source,widget),
|
||||||
|
filterFnList = [];
|
||||||
|
var inputResults = results.toArray();
|
||||||
|
results.clear();
|
||||||
|
$tw.utils.each(inputResults,function(title) {
|
||||||
|
var result = ""; // If no filter matches, we return an empty string
|
||||||
|
$tw.utils.each(filterList,function(filter,index) {
|
||||||
|
if(!filterFnList[index]) {
|
||||||
|
filterFnList[index] = options.wiki.compileFilter(filter);
|
||||||
|
}
|
||||||
|
var output = filterFnList[index](options.wiki.makeTiddlerIterator([title]),{
|
||||||
|
getVariable: function(name,opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
opts.variables = {
|
||||||
|
"currentTiddler": "" + title,
|
||||||
|
"..currentTiddler": widget.getVariable("currentTiddler")
|
||||||
|
};
|
||||||
|
if(name in opts.variables) {
|
||||||
|
return opts.variables[name];
|
||||||
|
} else {
|
||||||
|
return widget.getVariable(name,opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(output.length !== 0) {
|
||||||
|
result = output[0];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
results.push(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -16,23 +16,30 @@ Export our filter function
|
|||||||
exports.filter = function(operationSubFunction,options) {
|
exports.filter = function(operationSubFunction,options) {
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
if(results.length > 0) {
|
if(results.length > 0) {
|
||||||
var resultsToRemove = [];
|
var resultsToRemove = [],
|
||||||
|
index = 0;
|
||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
getVariable: function(name) {
|
getVariable: function(name,opts) {
|
||||||
switch(name) {
|
opts = opts || {};
|
||||||
case "currentTiddler":
|
opts.variables = {
|
||||||
return "" + title;
|
"currentTiddler": "" + title,
|
||||||
case "..currentTiddler":
|
"..currentTiddler": widget.getVariable("currentTiddler"),
|
||||||
return widget.getVariable("currentTiddler");
|
"index": "" + index,
|
||||||
default:
|
"revIndex": "" + (results.length - 1 - index),
|
||||||
return widget.getVariable(name);
|
"length": "" + results.length
|
||||||
|
};
|
||||||
|
if(name in opts.variables) {
|
||||||
|
return opts.variables[name];
|
||||||
|
} else {
|
||||||
|
return widget.getVariable(name,opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(filtered.length === 0) {
|
if(filtered.length === 0) {
|
||||||
resultsToRemove.push(title);
|
resultsToRemove.push(title);
|
||||||
}
|
}
|
||||||
|
++index;
|
||||||
});
|
});
|
||||||
results.remove(resultsToRemove);
|
results.remove(resultsToRemove);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,22 +15,29 @@ Export our filter prefix function
|
|||||||
exports.map = function(operationSubFunction,options) {
|
exports.map = function(operationSubFunction,options) {
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
if(results.length > 0) {
|
if(results.length > 0) {
|
||||||
var inputTitles = results.toArray();
|
var inputTitles = results.toArray(),
|
||||||
|
index = 0;
|
||||||
results.clear();
|
results.clear();
|
||||||
$tw.utils.each(inputTitles,function(title) {
|
$tw.utils.each(inputTitles,function(title) {
|
||||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
getVariable: function(name) {
|
getVariable: function(name,opts) {
|
||||||
switch(name) {
|
opts = opts || {};
|
||||||
case "currentTiddler":
|
opts.variables = {
|
||||||
return "" + title;
|
"currentTiddler": "" + title,
|
||||||
case "..currentTiddler":
|
"..currentTiddler": widget.getVariable("currentTiddler"),
|
||||||
return widget.getVariable("currentTiddler");
|
"index": "" + index,
|
||||||
default:
|
"revIndex": "" + (inputTitles.length - 1 - index),
|
||||||
return widget.getVariable(name);
|
"length": "" + inputTitles.length
|
||||||
|
};
|
||||||
|
if(name in opts.variables) {
|
||||||
|
return opts.variables[name];
|
||||||
|
} else {
|
||||||
|
return widget.getVariable(name,opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
results.push(filtered[0] || "");
|
results.push(filtered[0] || "");
|
||||||
|
++index;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,26 +15,24 @@ Export our filter prefix function
|
|||||||
exports.reduce = function(operationSubFunction,options) {
|
exports.reduce = function(operationSubFunction,options) {
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
if(results.length > 0) {
|
if(results.length > 0) {
|
||||||
var accumulator = "";
|
var accumulator = "",
|
||||||
var index = 0;
|
index = 0;
|
||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
getVariable: function(name) {
|
getVariable: function(name,opts) {
|
||||||
switch(name) {
|
opts = opts || {};
|
||||||
case "currentTiddler":
|
opts.variables = {
|
||||||
return "" + title;
|
"currentTiddler": "" + title,
|
||||||
case "..currentTiddler":
|
"..currentTiddler": widget.getVariable("currentTiddler"),
|
||||||
return widget.getVariable("currentTiddler");
|
"index": "" + index,
|
||||||
case "accumulator":
|
"revIndex": "" + (results.length - 1 - index),
|
||||||
return "" + accumulator;
|
"length": "" + results.length,
|
||||||
case "index":
|
"accumulator": "" + accumulator
|
||||||
return "" + index;
|
};
|
||||||
case "revIndex":
|
if(name in opts.variables) {
|
||||||
return "" + (results.length - 1 - index);
|
return opts.variables[name];
|
||||||
case "length":
|
} else {
|
||||||
return "" + results.length;
|
return widget.getVariable(name,opts);
|
||||||
default:
|
|
||||||
return widget.getVariable(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ exports.sort = function(operationSubFunction,options) {
|
|||||||
compareFn;
|
compareFn;
|
||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var key = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
var key = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
getVariable: function(name) {
|
getVariable: function(name,opts) {
|
||||||
switch(name) {
|
opts = opts || {};
|
||||||
case "currentTiddler":
|
opts.variables = {
|
||||||
return "" + title;
|
"currentTiddler": "" + title,
|
||||||
case "..currentTiddler":
|
"..currentTiddler": widget.getVariable("currentTiddler")
|
||||||
return widget.getVariable("currentTiddler");
|
};
|
||||||
default:
|
if(name in opts.variables) {
|
||||||
return widget.getVariable(name);
|
return opts.variables[name];
|
||||||
|
} else {
|
||||||
|
return widget.getVariable(name,opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,10 +95,12 @@ function parseFilterOperation(operators,filterString,p) {
|
|||||||
if(nextBracketPos === -1) {
|
if(nextBracketPos === -1) {
|
||||||
throw "Missing closing bracket in filter expression";
|
throw "Missing closing bracket in filter expression";
|
||||||
}
|
}
|
||||||
if(!operator.regexp) {
|
if(operator.regexp) {
|
||||||
|
operand.text = "";
|
||||||
|
} else {
|
||||||
operand.text = filterString.substring(p,nextBracketPos);
|
operand.text = filterString.substring(p,nextBracketPos);
|
||||||
operator.operands.push(operand);
|
|
||||||
}
|
}
|
||||||
|
operator.operands.push(operand);
|
||||||
p = nextBracketPos + 1;
|
p = nextBracketPos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ exports.all = function(source,operator,options) {
|
|||||||
results.pushTop(subop(source,operator.prefix,options));
|
results.pushTop(subop(source,operator.prefix,options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results.toArray();
|
return results.makeTiddlerIterator(options.wiki);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ Filter operator for returning all the backlinks from a tiddler
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.backlinks = function(source,operator,options) {
|
exports.backlinks = function(source,operator,options) {
|
||||||
var results = [];
|
var results = new $tw.utils.LinkedList();
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
$tw.utils.pushTop(results,options.wiki.getTiddlerBacklinks(title));
|
results.pushTop(options.wiki.getTiddlerBacklinks(title));
|
||||||
});
|
});
|
||||||
return results;
|
return results.makeTiddlerIterator(options.wiki);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
27
core/modules/filters/crypto.js
Normal file
27
core/modules/filters/crypto.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/crypto.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operators for cryptography, using the Stanford JavaScript library
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.sha256 = function(source,operator,options) {
|
||||||
|
var results = [],
|
||||||
|
length = parseInt(operator.operand,10) || 20,
|
||||||
|
sha256 = function(text) {
|
||||||
|
return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(text)).substr(0,length);
|
||||||
|
};
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
results.push(sha256(title));
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -19,12 +19,7 @@ Export our filter functions
|
|||||||
exports.decodeuricomponent = function(source,operator,options) {
|
exports.decodeuricomponent = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var value = title;
|
results.push($tw.utils.decodeURIComponentSafe(title));
|
||||||
try {
|
|
||||||
value = decodeURIComponent(title);
|
|
||||||
} catch(e) {
|
|
||||||
}
|
|
||||||
results.push(value);
|
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
@@ -40,12 +35,7 @@ exports.encodeuricomponent = function(source,operator,options) {
|
|||||||
exports.decodeuri = function(source,operator,options) {
|
exports.decodeuri = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var value = title;
|
results.push($tw.utils.decodeURISafe(title));
|
||||||
try {
|
|
||||||
value = decodeURI(title);
|
|
||||||
} catch(e) {
|
|
||||||
}
|
|
||||||
results.push(value);
|
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ exports.insertbefore = function(source,operator,options) {
|
|||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
});
|
});
|
||||||
var target = options.widget && options.widget.getVariable(operator.suffix || "currentTiddler");
|
var target = operator.operands[1] || (options.widget && options.widget.getVariable(operator.suffix || "currentTiddler"));
|
||||||
if(target !== operator.operand) {
|
if(target !== operator.operand) {
|
||||||
// Remove the entry from the list if it is present
|
// Remove the entry from the list if it is present
|
||||||
var pos = results.indexOf(operator.operand);
|
var pos = results.indexOf(operator.operand);
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ exports.draft = function(source,prefix,options) {
|
|||||||
var results = [];
|
var results = [];
|
||||||
if(prefix === "!") {
|
if(prefix === "!") {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(!tiddler || !$tw.utils.hop(tiddler.fields,"draft.of")) {
|
if(!tiddler || !tiddler.isDraft()) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler && $tw.utils.hop(tiddler.fields,"draft.of") && (tiddler.fields["draft.of"].length !== 0)) {
|
if(tiddler && tiddler.isDraft()) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
167
core/modules/filters/json-ops.js
Normal file
167
core/modules/filters/json-ops.js
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/json-ops.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operators for JSON operations
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports["getjson"] = function(source,operator,options) {
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
var data = options.wiki.getTiddlerDataCached(title);
|
||||||
|
if(data) {
|
||||||
|
var item = getDataItemValueAsStrings(data,operator.operands);
|
||||||
|
if(item !== undefined) {
|
||||||
|
results.push.apply(results,item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports["indexesjson"] = function(source,operator,options) {
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
var data = options.wiki.getTiddlerDataCached(title);
|
||||||
|
if(data) {
|
||||||
|
var item = getDataItemKeysAsStrings(data,operator.operands);
|
||||||
|
if(item !== undefined) {
|
||||||
|
results.push.apply(results,item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports["typejson"] = function(source,operator,options) {
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
var data = options.wiki.getTiddlerDataCached(title);
|
||||||
|
if(data) {
|
||||||
|
var item = getDataItemType(data,operator.operands);
|
||||||
|
if(item !== undefined) {
|
||||||
|
results.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Given a JSON data structure and an array of index strings, return an array of the string representation of the values at the end of the index chain, or "undefined" if any of the index strings are invalid
|
||||||
|
*/
|
||||||
|
function getDataItemValueAsStrings(data,indexes) {
|
||||||
|
// Get the item
|
||||||
|
var item = getDataItem(data,indexes);
|
||||||
|
// Return the item as a string
|
||||||
|
return convertDataItemValueToStrings(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Given a JSON data structure and an array of index strings, return an array of the string representation of the keys of the item at the end of the index chain, or "undefined" if any of the index strings are invalid
|
||||||
|
*/
|
||||||
|
function getDataItemKeysAsStrings(data,indexes) {
|
||||||
|
// Get the item
|
||||||
|
var item = getDataItem(data,indexes);
|
||||||
|
// Return the item keys as a string
|
||||||
|
return convertDataItemKeysToStrings(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Return an array of the string representation of the values of a data item, or "undefined" if the item is undefined
|
||||||
|
*/
|
||||||
|
function convertDataItemValueToStrings(item) {
|
||||||
|
// Return the item as a string
|
||||||
|
if(item === undefined) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
if(typeof item === "object") {
|
||||||
|
if(item === null) {
|
||||||
|
return ["null"];
|
||||||
|
}
|
||||||
|
var results = [];
|
||||||
|
if($tw.utils.isArray(item)) {
|
||||||
|
$tw.utils.each(item,function(value) {
|
||||||
|
results.push.apply(results,convertDataItemValueToStrings(value));
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
} else {
|
||||||
|
$tw.utils.each(Object.keys(item).sort(),function(key) {
|
||||||
|
results.push.apply(results,convertDataItemValueToStrings(item[key]));
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [item.toString()];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Return an array of the string representation of the keys of a data item, or "undefined" if the item is undefined
|
||||||
|
*/
|
||||||
|
function convertDataItemKeysToStrings(item) {
|
||||||
|
// Return the item as a string
|
||||||
|
if(item === undefined) {
|
||||||
|
return item;
|
||||||
|
} else if(typeof item === "object") {
|
||||||
|
if(item === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
var results = [];
|
||||||
|
if($tw.utils.isArray(item)) {
|
||||||
|
for(var i=0; i<item.length; i++) {
|
||||||
|
results.push(i.toString());
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
} else {
|
||||||
|
$tw.utils.each(Object.keys(item).sort(),function(key) {
|
||||||
|
results.push(key);
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDataItemType(data,indexes) {
|
||||||
|
// Get the item
|
||||||
|
var item = getDataItem(data,indexes);
|
||||||
|
// Return the item type
|
||||||
|
if(item === undefined) {
|
||||||
|
return item;
|
||||||
|
} else if(item === null) {
|
||||||
|
return "null";
|
||||||
|
} else if($tw.utils.isArray(item)) {
|
||||||
|
return "array";
|
||||||
|
} else if(typeof item === "object") {
|
||||||
|
return "object";
|
||||||
|
} else {
|
||||||
|
return typeof item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Given a JSON data structure and an array of index strings, return the value at the end of the index chain, or "undefined" if any of the index strings are invalid
|
||||||
|
*/
|
||||||
|
function getDataItem(data,indexes) {
|
||||||
|
if(indexes.length === 0 || (indexes.length === 1 && indexes[0] === "")) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
// Get the item
|
||||||
|
var item = data;
|
||||||
|
for(var i=0; i<indexes.length; i++) {
|
||||||
|
if(item !== undefined) {
|
||||||
|
item = item[indexes[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ exports.links = function(source,operator,options) {
|
|||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
results.pushTop(options.wiki.getTiddlerLinks(title));
|
results.pushTop(options.wiki.getTiddlerLinks(title));
|
||||||
});
|
});
|
||||||
return results.toArray();
|
return results.makeTiddlerIterator(options.wiki);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ exports.butlast = function(source,operator,options) {
|
|||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
});
|
});
|
||||||
return results.slice(0,-count);
|
var index = count === 0 ? results.length : -count;
|
||||||
|
return results.slice(0,index);
|
||||||
};
|
};
|
||||||
exports.bl = exports.butlast;
|
exports.bl = exports.butlast;
|
||||||
|
|
||||||
@@ -103,4 +104,16 @@ exports.nth = function(source,operator,options) {
|
|||||||
return results.slice(count - 1,count);
|
return results.slice(count - 1,count);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
The zero based nth member of the list
|
||||||
|
*/
|
||||||
|
exports.zth = function(source,operator,options) {
|
||||||
|
var count = $tw.utils.getInt(operator.operand,0),
|
||||||
|
results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
results.push(title);
|
||||||
|
});
|
||||||
|
return results.slice(count,count + 1);
|
||||||
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ module-type: filteroperator
|
|||||||
|
|
||||||
Filter operator that looks up values via a title prefix
|
Filter operator that looks up values via a title prefix
|
||||||
|
|
||||||
[lookup:<field>[<prefix>]]
|
[lookup:<defaultvalue>:<field OR index>[<prefix>],[<field-name OR index-name>]]
|
||||||
|
|
||||||
Prepends the prefix to the selected items and returns the specified field value
|
Prepends the prefix to the selected items and returns the specified
|
||||||
|
field or index value. If the 2nd suffix does not exist, it defaults to field.
|
||||||
|
If the second operand is missing it defaults to "text" for fields, and "0" for indexes
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
(function(){
|
(function(){
|
||||||
@@ -20,10 +22,31 @@ Prepends the prefix to the selected items and returns the specified field value
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.lookup = function(source,operator,options) {
|
exports.lookup = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [],
|
||||||
source(function(tiddler,title) {
|
suffixes = operator.suffixes || [],
|
||||||
results.push(options.wiki.getTiddlerText(operator.operand + title) || operator.suffix || '');
|
defaultSuffix = suffixes[0] ? (suffixes[0][0] || "") : "",
|
||||||
});
|
indexSuffix = (suffixes[1] && suffixes[1][0] === "index") ? true : false,
|
||||||
|
target;
|
||||||
|
if(operator.operands.length == 2) {
|
||||||
|
target = operator.operands[1]
|
||||||
|
} else {
|
||||||
|
target = indexSuffix ? "0": "text";
|
||||||
|
}
|
||||||
|
if(indexSuffix) {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
var data = options.wiki.extractTiddlerDataItem(operator.operands[0]+title,target,defaultSuffix);
|
||||||
|
results.push(data);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
var value = defaultSuffix;
|
||||||
|
var targetTiddler = options.wiki.getTiddler(operator.operands[0]+title);
|
||||||
|
if(targetTiddler && targetTiddler.getFieldString(target)) {
|
||||||
|
value = targetTiddler.getFieldString(target);
|
||||||
|
}
|
||||||
|
results.push(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,35 @@ exports["standard-deviation"] = makeNumericReducingOperator(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//trigonometry
|
||||||
|
exports.cos = makeNumericBinaryOperator(
|
||||||
|
function(a) {return Math.cos(a)}
|
||||||
|
);
|
||||||
|
|
||||||
|
exports.sin = makeNumericBinaryOperator(
|
||||||
|
function(a) {return Math.sin(a)}
|
||||||
|
);
|
||||||
|
|
||||||
|
exports.tan = makeNumericBinaryOperator(
|
||||||
|
function(a) {return Math.tan(a)}
|
||||||
|
);
|
||||||
|
|
||||||
|
exports.acos = makeNumericBinaryOperator(
|
||||||
|
function(a) {return Math.acos(a)}
|
||||||
|
);
|
||||||
|
|
||||||
|
exports.asin = makeNumericBinaryOperator(
|
||||||
|
function(a) {return Math.asin(a)}
|
||||||
|
);
|
||||||
|
|
||||||
|
exports.atan = makeNumericBinaryOperator(
|
||||||
|
function(a) {return Math.atan(a)}
|
||||||
|
);
|
||||||
|
|
||||||
|
exports.atan2 = makeNumericBinaryOperator(
|
||||||
|
function(a,b) {return Math.atan2(a,b)}
|
||||||
|
);
|
||||||
|
|
||||||
//Calculate the variance of a population of numbers in an array given its mean
|
//Calculate the variance of a population of numbers in an array given its mean
|
||||||
function getVarianceFromArray(values,mean) {
|
function getVarianceFromArray(values,mean) {
|
||||||
var deviationTotal = values.reduce(function(accumulator,value) {
|
var deviationTotal = values.reduce(function(accumulator,value) {
|
||||||
|
|||||||
@@ -17,14 +17,7 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.modules = function(source,operator,options) {
|
exports.modules = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
if(operator.operands.length === 1) {
|
if(operator.operands.length >= 2) {
|
||||||
// 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
|
// Return the modules that have the module property specified in the first operand with the value in the second operand
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
||||||
@@ -33,6 +26,13 @@ exports.modules = function(source,operator,options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// Return all the module names without filtering
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
$tw.utils.each($tw.modules.types[title],function(moduleInfo,moduleName) {
|
||||||
|
results.push(moduleName);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
results.sort();
|
results.sort();
|
||||||
return results;
|
return results;
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
/*\
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
@@ -16,19 +16,37 @@ Filter operator for checking if a title starts with a prefix
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.prefix = function(source,operator,options) {
|
exports.prefix = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [],
|
||||||
if(operator.prefix === "!") {
|
suffixes = (operator.suffixes || [])[0] || [];
|
||||||
source(function(tiddler,title) {
|
if(suffixes.indexOf("caseinsensitive") !== -1) {
|
||||||
if(title.substr(0,operator.operand.length) !== operator.operand) {
|
var operand = operator.operand.toLowerCase();
|
||||||
results.push(title);
|
if(operator.prefix === "!") {
|
||||||
}
|
source(function(tiddler,title) {
|
||||||
});
|
if(title.toLowerCase().substr(0,operand.length) !== operand) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.toLowerCase().substr(0,operand.length) === operand) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
source(function(tiddler,title) {
|
if(operator.prefix === "!") {
|
||||||
if(title.substr(0,operator.operand.length) === operator.operand) {
|
source(function(tiddler,title) {
|
||||||
results.push(title);
|
if(title.substr(0,operator.operand.length) !== operator.operand) {
|
||||||
}
|
results.push(title);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.substr(0,operator.operand.length) === operator.operand) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,9 +17,13 @@ Export our filter function
|
|||||||
*/
|
*/
|
||||||
exports.range = function(source,operator,options) {
|
exports.range = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
// Split the operand into numbers delimited by these symbols
|
// For backwards compatibility, if there is only one operand, try to split it using one of the delimiters
|
||||||
var parts = operator.operand.split(/[,:;]/g),
|
var parts = operator.operands || [];
|
||||||
beg, end, inc, i, fixed = 0;
|
if(parts.length === 1) {
|
||||||
|
parts = operator.operand.split(/[,:;]/g);
|
||||||
|
}
|
||||||
|
// Process the parts
|
||||||
|
var beg, end, inc, i, fixed = 0;
|
||||||
for (i=0; i<parts.length; i++) {
|
for (i=0; i<parts.length; i++) {
|
||||||
// Validate real number
|
// Validate real number
|
||||||
if(!/^\s*[+-]?((\d+(\.\d*)?)|(\.\d+))\s*$/.test(parts[i])) {
|
if(!/^\s*[+-]?((\d+(\.\d*)?)|(\.\d+))\s*$/.test(parts[i])) {
|
||||||
|
|||||||
@@ -16,12 +16,22 @@ Filter operator for removing a prefix from each title in the list. Titles that d
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.removeprefix = function(source,operator,options) {
|
exports.removeprefix = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [],
|
||||||
source(function(tiddler,title) {
|
suffixes = (operator.suffixes || [])[0] || [];
|
||||||
if(title.substr(0,operator.operand.length) === operator.operand) {
|
if(suffixes.indexOf("caseinsensitive") !== -1) {
|
||||||
results.push(title.substr(operator.operand.length));
|
var operand = operator.operand.toLowerCase();
|
||||||
}
|
source(function(tiddler,title) {
|
||||||
});
|
if(title.toLowerCase().substr(0,operand.length) === operand) {
|
||||||
|
results.push(title.substr(operand.length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.substr(0,operator.operand.length) === operator.operand) {
|
||||||
|
results.push(title.substr(operator.operand.length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,26 @@ Filter operator for removing a suffix from each title in the list. Titles that d
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.removesuffix = function(source,operator,options) {
|
exports.removesuffix = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [],
|
||||||
source(function(tiddler,title) {
|
suffixes = (operator.suffixes || [])[0] || [];
|
||||||
if(title && title.substr(-operator.operand.length) === operator.operand) {
|
if (!operator.operand) {
|
||||||
results.push(title.substr(0,title.length - operator.operand.length));
|
source(function(tiddler,title) {
|
||||||
}
|
results.push(title);
|
||||||
});
|
});
|
||||||
|
} else if(suffixes.indexOf("caseinsensitive") !== -1) {
|
||||||
|
var operand = operator.operand.toLowerCase();
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title && title.toLowerCase().substr(-operand.length) === operand) {
|
||||||
|
results.push(title.substr(0,title.length - operand.length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title && title.substr(-operator.operand.length) === operator.operand) {
|
||||||
|
results.push(title.substr(0,title.length - operator.operand.length));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ exports.search = function(source,operator,options) {
|
|||||||
invert: invert,
|
invert: invert,
|
||||||
field: fields,
|
field: fields,
|
||||||
excludeField: excludeFields,
|
excludeField: excludeFields,
|
||||||
|
some: hasFlag("some"),
|
||||||
caseSensitive: hasFlag("casesensitive"),
|
caseSensitive: hasFlag("casesensitive"),
|
||||||
literal: hasFlag("literal"),
|
literal: hasFlag("literal"),
|
||||||
whitespace: hasFlag("whitespace"),
|
whitespace: hasFlag("whitespace"),
|
||||||
|
|||||||
@@ -119,23 +119,25 @@ exports["search-replace"] = function(source,operator,options) {
|
|||||||
var results = [],
|
var results = [],
|
||||||
suffixes = operator.suffixes || [],
|
suffixes = operator.suffixes || [],
|
||||||
flagSuffix = (suffixes[0] ? (suffixes[0][0] || "") : ""),
|
flagSuffix = (suffixes[0] ? (suffixes[0][0] || "") : ""),
|
||||||
flags = (flagSuffix.indexOf("g") !== -1 ? "g" : "") + (flagSuffix.indexOf("i") !== -1 ? "i" : ""),
|
flags = (flagSuffix.indexOf("g") !== -1 ? "g" : "") + (flagSuffix.indexOf("i") !== -1 ? "i" : "") + (flagSuffix.indexOf("m") !== -1 ? "m" : ""),
|
||||||
isRegExp = (suffixes[1] && suffixes[1][0] === "regexp") ? true : false,
|
isRegExp = (suffixes[1] && suffixes[1][0] === "regexp") ? true : false,
|
||||||
searchTerm,
|
//Escape regexp characters if the operand is not a regular expression
|
||||||
|
searchTerm = isRegExp ? operator.operand : $tw.utils.escapeRegExp(operator.operand),
|
||||||
|
//Escape $ character in replacement string if not in regular expression mode
|
||||||
|
replacement = isRegExp ? operator.operands[1] : (operator.operands[1]||"").replace(/\$/g,"$$$$"),
|
||||||
regExp;
|
regExp;
|
||||||
|
try {
|
||||||
|
regExp = new RegExp(searchTerm,flags);
|
||||||
|
} catch(ex) {
|
||||||
|
return ["RegExp error: " + ex];
|
||||||
|
}
|
||||||
|
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(title && (operator.operands.length > 1)) {
|
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(
|
results.push(
|
||||||
title.replace(regExp,operator.operands[1])
|
title.replace(regExp,replacement)
|
||||||
);
|
);
|
||||||
|
regExp.lastIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,41 @@ Filter operator for checking if a title ends with a suffix
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.suffix = function(source,operator,options) {
|
exports.suffix = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [],
|
||||||
if(operator.prefix === "!") {
|
suffixes = (operator.suffixes || [])[0] || [];
|
||||||
|
if (!operator.operand) {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(title.substr(-operator.operand.length) !== operator.operand) {
|
results.push(title);
|
||||||
results.push(title);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
} else if(suffixes.indexOf("caseinsensitive") !== -1) {
|
||||||
|
var operand = operator.operand.toLowerCase();
|
||||||
|
if(operator.prefix === "!") {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.toLowerCase().substr(-operand.length) !== operand) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.toLowerCase().substr(-operand.length) === operand) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
source(function(tiddler,title) {
|
if(operator.prefix === "!") {
|
||||||
if(title.substr(-operator.operand.length) === operator.operand) {
|
source(function(tiddler,title) {
|
||||||
results.push(title);
|
if(title.substr(-operator.operand.length) !== operator.operand) {
|
||||||
}
|
results.push(title);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title.substr(-operator.operand.length) === operator.operand) {
|
||||||
|
results.push(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,20 +16,13 @@ Filter operator returning all the selected tiddlers that are untagged
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.untagged = function(source,operator,options) {
|
exports.untagged = function(source,operator,options) {
|
||||||
var results = [];
|
var results = [],
|
||||||
if(operator.prefix === "!") {
|
expected = (operator.prefix === "!");
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler && $tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length > 0) {
|
if(((tiddler && $tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length > 0) === expected) || (!tiddler && !expected)) {
|
||||||
$tw.utils.pushTop(results,title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
source(function(tiddler,title) {
|
|
||||||
if(!tiddler || !tiddler.hasField("tags") || ($tw.utils.isArray(tiddler.fields.tags) && tiddler.fields.tags.length === 0)) {
|
|
||||||
$tw.utils.pushTop(results,title);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ exports.parseFilterVariable = function(source) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Look for an HTML attribute definition. Returns null if not found, otherwise returns {type: "attribute", name:, valueType: "string|indirect|macro", value:, start:, end:,}
|
Look for an HTML attribute definition. Returns null if not found, otherwise returns {type: "attribute", name:, type: "filtered|string|indirect|macro", value|filter|textReference:, start:, end:,}
|
||||||
*/
|
*/
|
||||||
exports.parseAttribute = function(source,pos) {
|
exports.parseAttribute = function(source,pos) {
|
||||||
var node = {
|
var node = {
|
||||||
@@ -248,7 +248,7 @@ exports.parseAttribute = function(source,pos) {
|
|||||||
// Define our regexps
|
// Define our regexps
|
||||||
var reAttributeName = /([^\/\s>"'=]+)/g,
|
var reAttributeName = /([^\/\s>"'=]+)/g,
|
||||||
reUnquotedAttribute = /([^\/\s<>"'=]+)/g,
|
reUnquotedAttribute = /([^\/\s<>"'=]+)/g,
|
||||||
reFilteredValue = /\{\{\{(.+?)\}\}\}/g,
|
reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/g,
|
||||||
reIndirectValue = /\{\{([^\}]+)\}\}/g;
|
reIndirectValue = /\{\{([^\}]+)\}\}/g;
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
pos = $tw.utils.skipWhiteSpace(source,pos);
|
pos = $tw.utils.skipWhiteSpace(source,pos);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ exports.parse = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Look for an HTML tag. Returns null if not found, otherwise returns {type: "element", name:, attributes: [], isSelfClosing:, start:, end:,}
|
Look for an HTML tag. Returns null if not found, otherwise returns {type: "element", name:, attributes: {}, orderedAttributes: [], isSelfClosing:, start:, end:,}
|
||||||
*/
|
*/
|
||||||
exports.parseTag = function(source,pos,options) {
|
exports.parseTag = function(source,pos,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@@ -74,7 +74,8 @@ exports.parseTag = function(source,pos,options) {
|
|||||||
node = {
|
node = {
|
||||||
type: "element",
|
type: "element",
|
||||||
start: pos,
|
start: pos,
|
||||||
attributes: {}
|
attributes: {},
|
||||||
|
orderedAttributes: []
|
||||||
};
|
};
|
||||||
// Define our regexps
|
// Define our regexps
|
||||||
var reTagName = /([a-zA-Z0-9\-\$]+)/g;
|
var reTagName = /([a-zA-Z0-9\-\$]+)/g;
|
||||||
@@ -106,6 +107,7 @@ exports.parseTag = function(source,pos,options) {
|
|||||||
// Process attributes
|
// Process attributes
|
||||||
var attribute = $tw.utils.parseAttribute(source,pos);
|
var attribute = $tw.utils.parseAttribute(source,pos);
|
||||||
while(attribute) {
|
while(attribute) {
|
||||||
|
node.orderedAttributes.push(attribute);
|
||||||
node.attributes[attribute.name] = attribute;
|
node.attributes[attribute.name] = attribute;
|
||||||
pos = attribute.end;
|
pos = attribute.end;
|
||||||
// Get the next attribute
|
// Get the next attribute
|
||||||
|
|||||||
@@ -231,7 +231,10 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
|
|||||||
return nextMatch.rule.parse();
|
return nextMatch.rule.parse();
|
||||||
}
|
}
|
||||||
// Treat it as a paragraph if we didn't find a block rule
|
// Treat it as a paragraph if we didn't find a block rule
|
||||||
return [{type: "element", tag: "p", children: this.parseInlineRun(terminatorRegExp)}];
|
var start = this.pos;
|
||||||
|
var children = this.parseInlineRun(terminatorRegExp);
|
||||||
|
var end = this.pos;
|
||||||
|
return [{type: "element", tag: "p", children: children, start: start, end: end }];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -307,7 +310,7 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
|
|||||||
while(this.pos < this.sourceLength && nextMatch) {
|
while(this.pos < this.sourceLength && nextMatch) {
|
||||||
// Process the text preceding the run rule
|
// Process the text preceding the run rule
|
||||||
if(nextMatch.matchIndex > this.pos) {
|
if(nextMatch.matchIndex > this.pos) {
|
||||||
this.pushTextWidget(tree,this.source.substring(this.pos,nextMatch.matchIndex));
|
this.pushTextWidget(tree,this.source.substring(this.pos,nextMatch.matchIndex),this.pos,nextMatch.matchIndex);
|
||||||
this.pos = nextMatch.matchIndex;
|
this.pos = nextMatch.matchIndex;
|
||||||
}
|
}
|
||||||
// Process the run rule
|
// Process the run rule
|
||||||
@@ -317,7 +320,7 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
|
|||||||
}
|
}
|
||||||
// Process the remaining text
|
// Process the remaining text
|
||||||
if(this.pos < this.sourceLength) {
|
if(this.pos < this.sourceLength) {
|
||||||
this.pushTextWidget(tree,this.source.substr(this.pos));
|
this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength);
|
||||||
}
|
}
|
||||||
this.pos = this.sourceLength;
|
this.pos = this.sourceLength;
|
||||||
return tree;
|
return tree;
|
||||||
@@ -337,7 +340,7 @@ WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,option
|
|||||||
if(terminatorMatch) {
|
if(terminatorMatch) {
|
||||||
if(!inlineRuleMatch || inlineRuleMatch.matchIndex >= terminatorMatch.index) {
|
if(!inlineRuleMatch || inlineRuleMatch.matchIndex >= terminatorMatch.index) {
|
||||||
if(terminatorMatch.index > this.pos) {
|
if(terminatorMatch.index > this.pos) {
|
||||||
this.pushTextWidget(tree,this.source.substring(this.pos,terminatorMatch.index));
|
this.pushTextWidget(tree,this.source.substring(this.pos,terminatorMatch.index),this.pos,terminatorMatch.index);
|
||||||
}
|
}
|
||||||
this.pos = terminatorMatch.index;
|
this.pos = terminatorMatch.index;
|
||||||
if(options.eatTerminator) {
|
if(options.eatTerminator) {
|
||||||
@@ -350,7 +353,7 @@ WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,option
|
|||||||
if(inlineRuleMatch) {
|
if(inlineRuleMatch) {
|
||||||
// Preceding text
|
// Preceding text
|
||||||
if(inlineRuleMatch.matchIndex > this.pos) {
|
if(inlineRuleMatch.matchIndex > this.pos) {
|
||||||
this.pushTextWidget(tree,this.source.substring(this.pos,inlineRuleMatch.matchIndex));
|
this.pushTextWidget(tree,this.source.substring(this.pos,inlineRuleMatch.matchIndex),this.pos,inlineRuleMatch.matchIndex);
|
||||||
this.pos = inlineRuleMatch.matchIndex;
|
this.pos = inlineRuleMatch.matchIndex;
|
||||||
}
|
}
|
||||||
// Process the inline rule
|
// Process the inline rule
|
||||||
@@ -364,7 +367,7 @@ WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,option
|
|||||||
}
|
}
|
||||||
// Process the remaining text
|
// Process the remaining text
|
||||||
if(this.pos < this.sourceLength) {
|
if(this.pos < this.sourceLength) {
|
||||||
this.pushTextWidget(tree,this.source.substr(this.pos));
|
this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength);
|
||||||
}
|
}
|
||||||
this.pos = this.sourceLength;
|
this.pos = this.sourceLength;
|
||||||
return tree;
|
return tree;
|
||||||
@@ -373,12 +376,12 @@ WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,option
|
|||||||
/*
|
/*
|
||||||
Push a text widget onto an array, respecting the configTrimWhiteSpace setting
|
Push a text widget onto an array, respecting the configTrimWhiteSpace setting
|
||||||
*/
|
*/
|
||||||
WikiParser.prototype.pushTextWidget = function(array,text) {
|
WikiParser.prototype.pushTextWidget = function(array,text,start,end) {
|
||||||
if(this.configTrimWhiteSpace) {
|
if(this.configTrimWhiteSpace) {
|
||||||
text = $tw.utils.trim(text);
|
text = $tw.utils.trim(text);
|
||||||
}
|
}
|
||||||
if(text) {
|
if(text) {
|
||||||
array.push({type: "text", text: text});
|
array.push({type: "text", text: text, start: start, end: end});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ PluginSwitcher.prototype.switchPlugins = function() {
|
|||||||
var tiddler = self.wiki.getTiddler(title);
|
var tiddler = self.wiki.getTiddler(title);
|
||||||
if(tiddler && tiddler.isPlugin() && plugins.indexOf(title) === -1) {
|
if(tiddler && tiddler.isPlugin() && plugins.indexOf(title) === -1) {
|
||||||
plugins.push(title);
|
plugins.push(title);
|
||||||
var pluginInfo = JSON.parse(self.wiki.getTiddlerText(title)),
|
var pluginInfo = $tw.utils.parseJSONSafe(self.wiki.getTiddlerText(title)),
|
||||||
dependents = $tw.utils.parseStringArray(tiddler.fields.dependents || "");
|
dependents = $tw.utils.parseStringArray(tiddler.fields.dependents || "");
|
||||||
$tw.utils.each(dependents,function(title) {
|
$tw.utils.each(dependents,function(title) {
|
||||||
accumulatePlugin(title);
|
accumulatePlugin(title);
|
||||||
|
|||||||
@@ -1,181 +0,0 @@
|
|||||||
/*\
|
|
||||||
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;
|
|
||||||
|
|
||||||
})();
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*\
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ AndTidWiki.prototype.save = function(text,method,callback,options) {
|
|||||||
window.twi.saveWiki(text);
|
window.twi.saveWiki(text);
|
||||||
} else {
|
} else {
|
||||||
// Get the pathname of this document
|
// Get the pathname of this document
|
||||||
var pathname = decodeURIComponent(document.location.toString().split("#")[0]);
|
var pathname = $tw.utils.decodeURIComponentSafe(document.location.toString().split("#")[0]);
|
||||||
// Strip the file://
|
// Strip the file://
|
||||||
if(pathname.indexOf("file://") === 0) {
|
if(pathname.indexOf("file://") === 0) {
|
||||||
pathname = pathname.substr(7);
|
pathname = pathname.substr(7);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ DownloadSaver.prototype.save = function(text,method,callback,options) {
|
|||||||
var p = document.location.pathname.lastIndexOf("/");
|
var p = document.location.pathname.lastIndexOf("/");
|
||||||
if(p !== -1) {
|
if(p !== -1) {
|
||||||
// We decode the pathname because document.location is URL encoded by the browser
|
// We decode the pathname because document.location is URL encoded by the browser
|
||||||
filename = decodeURIComponent(document.location.pathname.substr(p+1));
|
filename = $tw.utils.decodeURIComponentSafe(document.location.pathname.substr(p+1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!filename) {
|
if(!filename) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ GiteaSaver.prototype.save = function(text,method,callback) {
|
|||||||
}
|
}
|
||||||
var use_put = true;
|
var use_put = true;
|
||||||
if(xhr.status !== 404) {
|
if(xhr.status !== 404) {
|
||||||
getResponseData = JSON.parse(getResponseDataJson);
|
getResponseData = $tw.utils.parseJSONSafe(getResponseDataJson);
|
||||||
$tw.utils.each(getResponseData,function(details) {
|
$tw.utils.each(getResponseData,function(details) {
|
||||||
if(details.name === filename) {
|
if(details.name === filename) {
|
||||||
sha = details.sha;
|
sha = details.sha;
|
||||||
@@ -72,7 +72,7 @@ GiteaSaver.prototype.save = function(text,method,callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
message: $tw.language.getRawString("ControlPanel/Saving/GitService/CommitMessage"),
|
message: $tw.language.getString("ControlPanel/Saving/GitService/CommitMessage"),
|
||||||
content: $tw.utils.base64Encode(text),
|
content: $tw.utils.base64Encode(text),
|
||||||
sha: sha
|
sha: sha
|
||||||
};
|
};
|
||||||
@@ -104,7 +104,7 @@ GiteaSaver.prototype.upload = function(uri,method,headers,data,callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var putResponseData = JSON.parse(putResponseDataJson);
|
var putResponseData = $tw.utils.parseJSONSafe(putResponseDataJson);
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
if(xhr.status !== 404) {
|
if(xhr.status !== 404) {
|
||||||
getResponseData = JSON.parse(getResponseDataJson);
|
getResponseData = $tw.utils.parseJSONSafe(getResponseDataJson);
|
||||||
$tw.utils.each(getResponseData,function(details) {
|
$tw.utils.each(getResponseData,function(details) {
|
||||||
if(details.name === filename) {
|
if(details.name === filename) {
|
||||||
sha = details.sha;
|
sha = details.sha;
|
||||||
@@ -69,7 +69,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
message: $tw.language.getRawString("ControlPanel/Saving/GitService/CommitMessage"),
|
message: $tw.language.getString("ControlPanel/Saving/GitService/CommitMessage"),
|
||||||
content: $tw.utils.base64Encode(text),
|
content: $tw.utils.base64Encode(text),
|
||||||
branch: branch,
|
branch: branch,
|
||||||
sha: sha
|
sha: sha
|
||||||
@@ -84,7 +84,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var putResponseData = JSON.parse(putResponseDataJson);
|
var putResponseData = $tw.utils.parseJSONSafe(putResponseDataJson);
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ GitLabSaver.prototype.save = function(text,method,callback) {
|
|||||||
}
|
}
|
||||||
var requestType = "POST";
|
var requestType = "POST";
|
||||||
if(xhr.status !== 404) {
|
if(xhr.status !== 404) {
|
||||||
getResponseData = JSON.parse(getResponseDataJson);
|
getResponseData = $tw.utils.parseJSONSafe(getResponseDataJson);
|
||||||
$tw.utils.each(getResponseData,function(details) {
|
$tw.utils.each(getResponseData,function(details) {
|
||||||
if(details.name === filename) {
|
if(details.name === filename) {
|
||||||
requestType = "PUT";
|
requestType = "PUT";
|
||||||
@@ -67,7 +67,7 @@ GitLabSaver.prototype.save = function(text,method,callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
commit_message: $tw.language.getRawString("ControlPanel/Saving/GitService/CommitMessage"),
|
commit_message: $tw.language.getString("ControlPanel/Saving/GitService/CommitMessage"),
|
||||||
content: text,
|
content: text,
|
||||||
branch: branch,
|
branch: branch,
|
||||||
sha: sha
|
sha: sha
|
||||||
@@ -82,7 +82,7 @@ GitLabSaver.prototype.save = function(text,method,callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
var putResponseData = JSON.parse(putResponseDataJson);
|
var putResponseData = $tw.utils.parseJSONSafe(putResponseDataJson);
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ TiddlyFoxSaver.prototype.save = function(text,method,callback) {
|
|||||||
}
|
}
|
||||||
// Create the message element and put it in the message box
|
// Create the message element and put it in the message box
|
||||||
var message = document.createElement("div");
|
var message = document.createElement("div");
|
||||||
message.setAttribute("data-tiddlyfox-path",decodeURIComponent(pathname));
|
message.setAttribute("data-tiddlyfox-path",$tw.utils.decodeURIComponentSafe(pathname));
|
||||||
message.setAttribute("data-tiddlyfox-content",text);
|
message.setAttribute("data-tiddlyfox-content",text);
|
||||||
messageBox.appendChild(message);
|
messageBox.appendChild(message);
|
||||||
// Add an event handler for when the file has been saved
|
// Add an event handler for when the file has been saved
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ TWEditSaver.prototype.save = function(text,method,callback) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Get the pathname of this document
|
// Get the pathname of this document
|
||||||
var pathname = decodeURIComponent(document.location.pathname);
|
var pathname = $tw.utils.decodeURIComponentSafe(document.location.pathname);
|
||||||
// Strip any query or location part
|
// Strip any query or location part
|
||||||
var p = pathname.indexOf("?");
|
var p = pathname.indexOf("?");
|
||||||
if(p !== -1) {
|
if(p !== -1) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ exports.method = "DELETE";
|
|||||||
exports.path = /^\/bags\/default\/tiddlers\/(.+)$/;
|
exports.path = /^\/bags\/default\/tiddlers\/(.+)$/;
|
||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var title = decodeURIComponent(state.params[0]);
|
var title = $tw.utils.decodeURIComponentSafe(state.params[0]);
|
||||||
state.wiki.deleteTiddler(title);
|
state.wiki.deleteTiddler(title);
|
||||||
response.writeHead(204, "OK", {
|
response.writeHead(204, "OK", {
|
||||||
"Content-Type": "text/plain"
|
"Content-Type": "text/plain"
|
||||||
|
|||||||
@@ -20,22 +20,29 @@ exports.handler = function(request,response,state) {
|
|||||||
var path = require("path"),
|
var path = require("path"),
|
||||||
fs = require("fs"),
|
fs = require("fs"),
|
||||||
util = require("util"),
|
util = require("util"),
|
||||||
suppliedFilename = decodeURIComponent(state.params[0]),
|
suppliedFilename = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||||
filename = path.resolve(state.boot.wikiPath,"files",suppliedFilename),
|
baseFilename = path.resolve(state.boot.wikiPath,"files"),
|
||||||
|
filename = path.resolve(baseFilename,suppliedFilename),
|
||||||
extension = path.extname(filename);
|
extension = path.extname(filename);
|
||||||
fs.readFile(filename,function(err,content) {
|
// Check that the filename is inside the wiki files folder
|
||||||
var status,content,type = "text/plain";
|
if(path.relative(baseFilename,filename).indexOf("..") !== 0) {
|
||||||
if(err) {
|
// Send the file
|
||||||
console.log("Error accessing file " + filename + ": " + err.toString());
|
fs.readFile(filename,function(err,content) {
|
||||||
status = 404;
|
var status,content,type = "text/plain";
|
||||||
content = "File '" + suppliedFilename + "' not found";
|
if(err) {
|
||||||
} else {
|
console.log("Error accessing file " + filename + ": " + err.toString());
|
||||||
status = 200;
|
status = 404;
|
||||||
content = content;
|
content = "File '" + suppliedFilename + "' not found";
|
||||||
type = ($tw.config.fileExtensionInfo[extension] ? $tw.config.fileExtensionInfo[extension].type : "application/octet-stream");
|
} else {
|
||||||
}
|
status = 200;
|
||||||
state.sendResponse(status,{"Content-Type": type},content);
|
content = content;
|
||||||
});
|
type = ($tw.config.fileExtensionInfo[extension] ? $tw.config.fileExtensionInfo[extension].type : "application/octet-stream");
|
||||||
|
}
|
||||||
|
state.sendResponse(status,{"Content-Type": type},content);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
state.sendResponse(404,{"Content-Type": "text/plain"},"File '" + suppliedFilename + "' not found");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ GET /
|
|||||||
|
|
||||||
exports.method = "GET";
|
exports.method = "GET";
|
||||||
|
|
||||||
exports.path = /^\/index.html$/;
|
exports.path = /^\/$/;
|
||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler")),
|
var text = state.wiki.renderTiddler(state.server.get("root-render-type"),state.server.get("root-tiddler")),
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ exports.handler = function(request,response,state) {
|
|||||||
username: state.authenticatedUsername || state.server.get("anon-username") || "",
|
username: state.authenticatedUsername || state.server.get("anon-username") || "",
|
||||||
anonymous: !state.authenticatedUsername,
|
anonymous: !state.authenticatedUsername,
|
||||||
read_only: !state.server.isAuthorized("writers",state.authenticatedUsername),
|
read_only: !state.server.isAuthorized("writers",state.authenticatedUsername),
|
||||||
sse_enabled: state.server.get("sse-enabled") === "yes",
|
|
||||||
space: {
|
space: {
|
||||||
recipe: "default"
|
recipe: "default"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ exports.method = "GET";
|
|||||||
exports.path = /^\/([^\/]+)$/;
|
exports.path = /^\/([^\/]+)$/;
|
||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var title = decodeURIComponent(state.params[0]),
|
var title = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||||
tiddler = state.wiki.getTiddler(title);
|
tiddler = state.wiki.getTiddler(title);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
var renderType = tiddler.getFieldString("_render_type"),
|
var renderType = tiddler.getFieldString("_render_type"),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ exports.method = "GET";
|
|||||||
exports.path = /^\/recipes\/default\/tiddlers\/(.+)$/;
|
exports.path = /^\/recipes\/default\/tiddlers\/(.+)$/;
|
||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var title = decodeURIComponent(state.params[0]),
|
var title = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||||
tiddler = state.wiki.getTiddler(title),
|
tiddler = state.wiki.getTiddler(title),
|
||||||
tiddlerFields = {},
|
tiddlerFields = {},
|
||||||
knownFields = [
|
knownFields = [
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ exports.method = "PUT";
|
|||||||
exports.path = /^\/recipes\/default\/tiddlers\/(.+)$/;
|
exports.path = /^\/recipes\/default\/tiddlers\/(.+)$/;
|
||||||
|
|
||||||
exports.handler = function(request,response,state) {
|
exports.handler = function(request,response,state) {
|
||||||
var title = decodeURIComponent(state.params[0]),
|
var title = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||||
fields = JSON.parse(state.data);
|
fields = $tw.utils.parseJSONSafe(state.data);
|
||||||
// Pull up any subfields in the `fields` object
|
// Pull up any subfields in the `fields` object
|
||||||
if(fields.fields) {
|
if(fields.fields) {
|
||||||
$tw.utils.each(fields.fields,function(field,name) {
|
$tw.utils.each(fields.fields,function(field,name) {
|
||||||
@@ -30,7 +30,7 @@ exports.handler = function(request,response,state) {
|
|||||||
if(fields.revision) {
|
if(fields.revision) {
|
||||||
delete fields.revision;
|
delete fields.revision;
|
||||||
}
|
}
|
||||||
state.wiki.addTiddler(new $tw.Tiddler(state.wiki.getCreationFields(),fields,{title: title},state.wiki.getModificationFields()));
|
state.wiki.addTiddler(new $tw.Tiddler(fields,{title: title}));
|
||||||
var changeCount = state.wiki.getChangeCount(title).toString();
|
var changeCount = state.wiki.getChangeCount(title).toString();
|
||||||
response.writeHead(204, "OK",{
|
response.writeHead(204, "OK",{
|
||||||
Etag: "\"default/" + encodeURIComponent(title) + "/" + changeCount + ":\"",
|
Etag: "\"default/" + encodeURIComponent(title) + "/" + changeCount + ":\"",
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: $:/core/modules/server/server-sent-events.js
|
|
||||||
type: application/javascript
|
|
||||||
module-type: library
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/*
|
|
||||||
parameters:
|
|
||||||
prefix - usually the plugin path, such as `plugins/tiddlywiki/tiddlyweb`. The
|
|
||||||
route will match `/events/${prefix}` exactly.
|
|
||||||
|
|
||||||
handler - a function that will be called each time a request comes in with the
|
|
||||||
request and state from the route and an emit function to call.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var ServerSentEvents = function ServerSentEvents(prefix, handler) {
|
|
||||||
this.handler = handler;
|
|
||||||
this.prefix = prefix;
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerSentEvents.prototype.getExports = function() {
|
|
||||||
return {
|
|
||||||
bodyFormat: "stream",
|
|
||||||
method: "GET",
|
|
||||||
path: new RegExp("^/events/" + this.prefix + "$"),
|
|
||||||
handler: this.handleEventRequest.bind(this)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerSentEvents.prototype.handleEventRequest = function(request,response,state) {
|
|
||||||
if(ServerSentEvents.prototype.isEventStreamRequest(request)) {
|
|
||||||
response.writeHead(200, {
|
|
||||||
"Content-Type": "text/event-stream",
|
|
||||||
"Cache-Control": "no-cache",
|
|
||||||
"Connection": "keep-alive"
|
|
||||||
});
|
|
||||||
this.handler(request,state,this.emit.bind(this,response),this.end.bind(this,response));
|
|
||||||
} else {
|
|
||||||
response.writeHead(406,"Not Acceptable",{});
|
|
||||||
response.end();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerSentEvents.prototype.isEventStreamRequest = function(request) {
|
|
||||||
return request.headers.accept &&
|
|
||||||
request.headers.accept.match(/^text\/event-stream/);
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerSentEvents.prototype.emit = function(response,event,data) {
|
|
||||||
if(typeof event !== "string" || event.indexOf("\n") !== -1) {
|
|
||||||
throw new Error("Type must be a single-line string");
|
|
||||||
}
|
|
||||||
if(typeof data !== "string" || data.indexOf("\n") !== -1) {
|
|
||||||
throw new Error("Data must be a single-line string");
|
|
||||||
}
|
|
||||||
response.write("event: " + event + "\ndata: " + data + "\n\n", "utf8");
|
|
||||||
};
|
|
||||||
|
|
||||||
ServerSentEvents.prototype.end = function(response) {
|
|
||||||
response.end();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.ServerSentEvents = ServerSentEvents;
|
|
||||||
|
|
||||||
})();
|
|
||||||
@@ -34,7 +34,6 @@ function Server(options) {
|
|||||||
this.authenticators = options.authenticators || [];
|
this.authenticators = options.authenticators || [];
|
||||||
this.wiki = options.wiki;
|
this.wiki = options.wiki;
|
||||||
this.boot = options.boot || $tw.boot;
|
this.boot = options.boot || $tw.boot;
|
||||||
this.servername = $tw.utils.transliterateToSafeASCII(this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5");
|
|
||||||
// Initialise the variables
|
// Initialise the variables
|
||||||
this.variables = $tw.utils.extend({},this.defaultVariables);
|
this.variables = $tw.utils.extend({},this.defaultVariables);
|
||||||
if(options.variables) {
|
if(options.variables) {
|
||||||
@@ -44,7 +43,8 @@ function Server(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$tw.utils.extend({},this.defaultVariables,options.variables);
|
// Setup the default required plugins
|
||||||
|
this.requiredPlugins = this.get("required-plugins").split(',');
|
||||||
// Initialise CSRF
|
// Initialise CSRF
|
||||||
this.csrfDisable = this.get("csrf-disable") === "yes";
|
this.csrfDisable = this.get("csrf-disable") === "yes";
|
||||||
// Initialize Gzip compression
|
// Initialize Gzip compression
|
||||||
@@ -52,31 +52,50 @@ function Server(options) {
|
|||||||
// Initialize browser-caching
|
// Initialize browser-caching
|
||||||
this.enableBrowserCache = this.get("use-browser-cache") === "yes";
|
this.enableBrowserCache = this.get("use-browser-cache") === "yes";
|
||||||
// Initialise authorization
|
// Initialise authorization
|
||||||
var authorizedUserName = (this.get("username") && this.get("password")) ? this.get("username") : "(anon)";
|
var authorizedUserName;
|
||||||
|
if(this.get("username") && this.get("password")) {
|
||||||
|
authorizedUserName = this.get("username");
|
||||||
|
} else if(this.get("credentials")) {
|
||||||
|
authorizedUserName = "(authenticated)";
|
||||||
|
} else {
|
||||||
|
authorizedUserName = "(anon)";
|
||||||
|
}
|
||||||
this.authorizationPrincipals = {
|
this.authorizationPrincipals = {
|
||||||
readers: (this.get("readers") || authorizedUserName).split(",").map($tw.utils.trim),
|
readers: (this.get("readers") || authorizedUserName).split(",").map($tw.utils.trim),
|
||||||
writers: (this.get("writers") || authorizedUserName).split(",").map($tw.utils.trim)
|
writers: (this.get("writers") || authorizedUserName).split(",").map($tw.utils.trim)
|
||||||
}
|
}
|
||||||
|
if(this.get("admin") || authorizedUserName !== "(anon)") {
|
||||||
|
this.authorizationPrincipals["admin"] = (this.get("admin") || authorizedUserName).split(',').map($tw.utils.trim)
|
||||||
|
}
|
||||||
// Load and initialise authenticators
|
// Load and initialise authenticators
|
||||||
$tw.modules.forEachModuleOfType("authenticator", function(title,authenticatorDefinition) {
|
$tw.modules.forEachModuleOfType("authenticator", function(title,authenticatorDefinition) {
|
||||||
// console.log("Loading server route " + title);
|
// console.log("Loading authenticator " + title);
|
||||||
self.addAuthenticator(authenticatorDefinition.AuthenticatorClass);
|
self.addAuthenticator(authenticatorDefinition.AuthenticatorClass);
|
||||||
});
|
});
|
||||||
// Load route handlers
|
// Load route handlers
|
||||||
this.addRouteHandlers();
|
$tw.modules.forEachModuleOfType("route", function(title,routeDefinition) {
|
||||||
|
// console.log("Loading server route " + title);
|
||||||
|
self.addRoute(routeDefinition);
|
||||||
|
});
|
||||||
// Initialise the http vs https
|
// Initialise the http vs https
|
||||||
this.listenOptions = null;
|
this.listenOptions = null;
|
||||||
this.protocol = "http";
|
this.protocol = "http";
|
||||||
var tlsKeyFilepath = this.get("tls-key"),
|
var tlsKeyFilepath = this.get("tls-key"),
|
||||||
tlsCertFilepath = this.get("tls-cert");
|
tlsCertFilepath = this.get("tls-cert"),
|
||||||
|
tlsPassphrase = this.get("tls-passphrase");
|
||||||
if(tlsCertFilepath && tlsKeyFilepath) {
|
if(tlsCertFilepath && tlsKeyFilepath) {
|
||||||
this.listenOptions = {
|
this.listenOptions = {
|
||||||
key: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsKeyFilepath),"utf8"),
|
key: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsKeyFilepath),"utf8"),
|
||||||
cert: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsCertFilepath),"utf8")
|
cert: fs.readFileSync(path.resolve(this.boot.wikiPath,tlsCertFilepath),"utf8"),
|
||||||
|
passphrase: tlsPassphrase || ''
|
||||||
};
|
};
|
||||||
this.protocol = "https";
|
this.protocol = "https";
|
||||||
}
|
}
|
||||||
this.transport = require(this.protocol);
|
this.transport = require(this.protocol);
|
||||||
|
// Name the server and init the boot state
|
||||||
|
this.servername = $tw.utils.transliterateToSafeASCII(this.get("server-name") || this.wiki.getTiddlerText("$:/SiteTitle") || "TiddlyWiki5");
|
||||||
|
this.boot.origin = this.get("origin")? this.get("origin"): this.protocol+"://"+this.get("host")+":"+this.get("port");
|
||||||
|
this.boot.pathPrefix = this.get("path-prefix") || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -147,6 +166,7 @@ function sendResponse(request,response,statusCode,headers,data,encoding) {
|
|||||||
Server.prototype.defaultVariables = {
|
Server.prototype.defaultVariables = {
|
||||||
port: "8080",
|
port: "8080",
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
|
"required-plugins": "$:/plugins/tiddlywiki/filesystem,$:/plugins/tiddlywiki/tiddlyweb",
|
||||||
"root-tiddler": "$:/core/save/all",
|
"root-tiddler": "$:/core/save/all",
|
||||||
"root-render-type": "text/plain",
|
"root-render-type": "text/plain",
|
||||||
"root-serve-type": "text/html",
|
"root-serve-type": "text/html",
|
||||||
@@ -179,43 +199,11 @@ Server.prototype.addAuthenticator = function(AuthenticatorClass) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype.addRouteHandlers = function() {
|
Server.prototype.findMatchingRoute = function(request,state) {
|
||||||
var self = this;
|
|
||||||
// Load route handlers from sitemap if present, or just load all route modules
|
|
||||||
if(this.variables.sitemap) {
|
|
||||||
this.sitemap = new $tw.Sitemap(this.variables.sitemap,{
|
|
||||||
wiki: this.wiki,
|
|
||||||
variables: {}
|
|
||||||
});
|
|
||||||
this.sitemap.load();
|
|
||||||
$tw.utils.each(this.sitemap.getServerRoutes(),function(routeInfo) {
|
|
||||||
self.addRoute({
|
|
||||||
method: "GET",
|
|
||||||
path: routeInfo.regexp,
|
|
||||||
handler: function(request,response,state) {
|
|
||||||
var fileDetails = routeInfo.handler(state.params);
|
|
||||||
if(fileDetails) {
|
|
||||||
response.writeHead(200, {"Content-Type": fileDetails.type});
|
|
||||||
response.end(fileDetails.text,fileDetails.isBase64 ? "base64" : "utf8");
|
|
||||||
} else {
|
|
||||||
response.writeHead(404);
|
|
||||||
response.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$tw.modules.forEachModuleOfType("route",function(title,routeDefinition) {
|
|
||||||
self.addRoute(routeDefinition);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Server.prototype.findMatchingRoute = function(request,state,options) {
|
|
||||||
options = options || {};
|
|
||||||
for(var t=0; t<this.routes.length; t++) {
|
for(var t=0; t<this.routes.length; t++) {
|
||||||
var potentialRoute = this.routes[t],
|
var potentialRoute = this.routes[t],
|
||||||
pathname = options.pathname || state.urlInfo.pathname,
|
pathRegExp = potentialRoute.path,
|
||||||
|
pathname = state.urlInfo.pathname,
|
||||||
match;
|
match;
|
||||||
if(state.pathPrefix) {
|
if(state.pathPrefix) {
|
||||||
if(pathname.substr(0,state.pathPrefix.length) === state.pathPrefix) {
|
if(pathname.substr(0,state.pathPrefix.length) === state.pathPrefix) {
|
||||||
@@ -268,15 +256,15 @@ Server.prototype.requestHandler = function(request,response,options) {
|
|||||||
state.pathPrefix = options.pathPrefix || this.get("path-prefix") || "";
|
state.pathPrefix = options.pathPrefix || this.get("path-prefix") || "";
|
||||||
state.sendResponse = sendResponse.bind(self,request,response);
|
state.sendResponse = sendResponse.bind(self,request,response);
|
||||||
// Get the principals authorized to access this resource
|
// Get the principals authorized to access this resource
|
||||||
var authorizationType = this.methodMappings[request.method] || "readers";
|
state.authorizationType = options.authorizationType || this.methodMappings[request.method] || "readers";
|
||||||
// Check for the CSRF header if this is a write
|
// Check for the CSRF header if this is a write
|
||||||
if(!this.csrfDisable && authorizationType === "writers" && request.headers["x-requested-with"] !== "TiddlyWiki") {
|
if(!this.csrfDisable && state.authorizationType === "writers" && request.headers["x-requested-with"] !== "TiddlyWiki") {
|
||||||
response.writeHead(403,"'X-Requested-With' header required to login to '" + this.servername + "'");
|
response.writeHead(403,"'X-Requested-With' header required to login to '" + this.servername + "'");
|
||||||
response.end();
|
response.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check whether anonymous access is granted
|
// Check whether anonymous access is granted
|
||||||
state.allowAnon = this.isAuthorized(authorizationType,null);
|
state.allowAnon = this.isAuthorized(state.authorizationType,null);
|
||||||
// Authenticate with the first active authenticator
|
// Authenticate with the first active authenticator
|
||||||
if(this.authenticators.length > 0) {
|
if(this.authenticators.length > 0) {
|
||||||
if(!this.authenticators[0].authenticateRequest(request,response,state)) {
|
if(!this.authenticators[0].authenticateRequest(request,response,state)) {
|
||||||
@@ -285,22 +273,13 @@ Server.prototype.requestHandler = function(request,response,options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Authorize with the authenticated username
|
// Authorize with the authenticated username
|
||||||
if(!this.isAuthorized(authorizationType,state.authenticatedUsername)) {
|
if(!this.isAuthorized(state.authorizationType,state.authenticatedUsername)) {
|
||||||
response.writeHead(401,"'" + state.authenticatedUsername + "' is not authorized to access '" + this.servername + "'");
|
response.writeHead(401,"'" + state.authenticatedUsername + "' is not authorized to access '" + this.servername + "'");
|
||||||
response.end();
|
response.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Find the route that matches this path
|
// Find the route that matches this path
|
||||||
var route = self.findMatchingRoute(request,state);
|
var route = self.findMatchingRoute(request,state);
|
||||||
if(!route) {
|
|
||||||
// Try with the default document
|
|
||||||
var defaultDocumentPathname = state.urlInfo.pathname;
|
|
||||||
if(defaultDocumentPathname.substr(-1) !== "/") {
|
|
||||||
defaultDocumentPathname = defaultDocumentPathname + "/";
|
|
||||||
}
|
|
||||||
defaultDocumentPathname = defaultDocumentPathname + "index.html";
|
|
||||||
route = self.findMatchingRoute(request,state,{pathname: defaultDocumentPathname});
|
|
||||||
}
|
|
||||||
// Optionally output debug info
|
// Optionally output debug info
|
||||||
if(self.get("debug-level") !== "none") {
|
if(self.get("debug-level") !== "none") {
|
||||||
console.log("Request path:",JSON.stringify(state.urlInfo));
|
console.log("Request path:",JSON.stringify(state.urlInfo));
|
||||||
@@ -360,8 +339,16 @@ Server.prototype.listen = function(port,host,prefix) {
|
|||||||
port = process.env[port] || 8080;
|
port = process.env[port] || 8080;
|
||||||
}
|
}
|
||||||
// Warn if required plugins are missing
|
// Warn if required plugins are missing
|
||||||
if(!this.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !this.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) {
|
var missing = [];
|
||||||
$tw.utils.warning("Warning: Plugins required for client-server operation (\"tiddlywiki/filesystem\" and \"tiddlywiki/tiddlyweb\") are missing from tiddlywiki.info file");
|
for (var index=0; index<this.requiredPlugins.length; index++) {
|
||||||
|
if (!this.wiki.getTiddler(this.requiredPlugins[index])) {
|
||||||
|
missing.push(this.requiredPlugins[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(missing.length > 0) {
|
||||||
|
var error = "Warning: Plugin(s) required for client-server operation are missing.\n"+
|
||||||
|
"\""+ missing.join("\", \"")+"\"";
|
||||||
|
$tw.utils.warning(error);
|
||||||
}
|
}
|
||||||
// Create the server
|
// Create the server
|
||||||
var server;
|
var server;
|
||||||
|
|||||||
@@ -1,236 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: $:/core/modules/sitemap.js
|
|
||||||
type: application/javascript
|
|
||||||
module-type: global
|
|
||||||
|
|
||||||
Sitemaps are used for static publishing and web serving
|
|
||||||
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Sitemap(sitemapTitle,options) {
|
|
||||||
options = options || {};
|
|
||||||
this.sitemapTitle = sitemapTitle;
|
|
||||||
this.wiki = options.wiki;
|
|
||||||
this.routes = [];
|
|
||||||
this.variables = $tw.utils.extend({},options.variables);
|
|
||||||
}
|
|
||||||
|
|
||||||
Sitemap.prototype.load = function(sitemapTitle) {
|
|
||||||
var self = this;
|
|
||||||
// Get the sitemap
|
|
||||||
var sitemapTiddler = this.wiki.getTiddler(this.sitemapTitle);
|
|
||||||
if(sitemapTiddler) {
|
|
||||||
// Collect each route
|
|
||||||
$tw.utils.each(sitemapTiddler.fields.list,function(routeTitle) {
|
|
||||||
var routeTiddler = self.wiki.getTiddler(routeTitle);
|
|
||||||
if(routeTiddler) {
|
|
||||||
// Convert the path into a regexp and an array of {field:,function:} for each capture group
|
|
||||||
var regexpurgatedParameterisedPath = self.regexpurgateParameterisedPath(routeTiddler.fields["route-path"]);
|
|
||||||
self.routes.push({
|
|
||||||
title: routeTitle,
|
|
||||||
params: routeTiddler.getFieldStrings({prefix: "route-"}),
|
|
||||||
variables: routeTiddler.getFieldStrings({prefix: "var-"}),
|
|
||||||
regexp: regexpurgatedParameterisedPath.regexp,
|
|
||||||
captureGroups: regexpurgatedParameterisedPath.captureGroups
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Sitemap.prototype.renderRoute = function(title,route) {
|
|
||||||
var tiddler = this.wiki.getTiddler(title);
|
|
||||||
switch(route.params.type) {
|
|
||||||
case "raw":
|
|
||||||
return {
|
|
||||||
path: this.resolveParameterisedPath(route.params.path,title),
|
|
||||||
text: tiddler.fields.text || "",
|
|
||||||
type: tiddler.fields.type || "",
|
|
||||||
isBase64: ($tw.config.contentTypeInfo[tiddler.fields.type] || {}).encoding === "base64"
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case "render":
|
|
||||||
var parser = {
|
|
||||||
tree: [
|
|
||||||
{
|
|
||||||
"type": "importvariables",
|
|
||||||
"attributes": {
|
|
||||||
"tiddler": {
|
|
||||||
"name": "tiddler",
|
|
||||||
"type": "string",
|
|
||||||
"value": this.sitemapTitle,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tag": "$importvariables",
|
|
||||||
"isBlock": false,
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "importvariables",
|
|
||||||
"attributes": {
|
|
||||||
"tiddler": {
|
|
||||||
"name": "tiddler",
|
|
||||||
"type": "string",
|
|
||||||
"value": route.title,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tag": "$importvariables",
|
|
||||||
"isBlock": false,
|
|
||||||
"children": this.wiki.parseTiddler(route.params.template,{parseAsInline: true}).tree
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
widgetNode = this.wiki.makeWidget(parser,{
|
|
||||||
variables: $tw.utils.extend({},this.variables,{currentTiddler: title})
|
|
||||||
}),
|
|
||||||
container = $tw.fakeDocument.createElement("div");
|
|
||||||
widgetNode.render(container,null);
|
|
||||||
return {
|
|
||||||
path: this.resolveParameterisedPath(route.params.path,title),
|
|
||||||
text: container.textContent,
|
|
||||||
type: route.params["output-type"] || "text/html"
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Returns an array of functions that return {path:,text:,type:,isBase64:} for each path
|
|
||||||
*/
|
|
||||||
Sitemap.prototype.getAllFileDetails = function(exportTiddlers) {
|
|
||||||
var self = this,
|
|
||||||
output = [];
|
|
||||||
$tw.utils.each(this.routes,function(route) {
|
|
||||||
var routeFilter = route.params["tiddler-filter"] || "DUMMY_RESULT", // If no filter is provided, use a dummy filter that returns a single result
|
|
||||||
routeTiddlers = self.wiki.filterTiddlers(routeFilter,null,self.wiki.makeTiddlerIterator(exportTiddlers));
|
|
||||||
$tw.utils.each(routeTiddlers,function(title) {
|
|
||||||
output.push(self.renderRoute.bind(self,title,route));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Returns an array of server routes {regexp:, handler:}
|
|
||||||
*/
|
|
||||||
Sitemap.prototype.getServerRoutes = function() {
|
|
||||||
var self = this,
|
|
||||||
output = [];
|
|
||||||
$tw.utils.each(this.routes,function(route) {
|
|
||||||
output.push({
|
|
||||||
regexp: route.regexp,
|
|
||||||
handler: function(params) {
|
|
||||||
// Locate the tiddler identified by the capture groups, if any
|
|
||||||
var title = null,
|
|
||||||
nextParam = 0;
|
|
||||||
$tw.utils.each(route.captureGroups,function(captureGroup) {
|
|
||||||
var param = params[nextParam++];
|
|
||||||
if(captureGroup.field === "title") {
|
|
||||||
switch(captureGroup.function) {
|
|
||||||
case "slugify":
|
|
||||||
var titles = self.wiki.unslugify(param);
|
|
||||||
if(titles && titles.length > 0) {
|
|
||||||
title = titles[0];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// Check that the tiddler passes the route filter
|
|
||||||
if(route.params["tiddler-filter"]) {
|
|
||||||
if(!title) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var routeTiddlers = self.wiki.filterTiddlers(route.params["tiddler-filter"],null,self.wiki.makeTiddlerIterator([title]));
|
|
||||||
if(routeTiddlers.indexOf(title) === -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Return the rendering or raw tiddler
|
|
||||||
return self.renderRoute(title,route);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Apply a tiddler to a parameterised path to create a usable path
|
|
||||||
*/
|
|
||||||
Sitemap.prototype.resolveParameterisedPath = function(parameterisedPath,title) {
|
|
||||||
var self = this;
|
|
||||||
// Split the path on $*_*$ markers
|
|
||||||
var tiddler = this.wiki.getTiddler(title),
|
|
||||||
output = [];
|
|
||||||
$tw.utils.each(parameterisedPath.split(/(\$[a-z_]+\$)/),function(part) {
|
|
||||||
var match = part.match(/\$([a-z]+)_([a-z]+)\$/);
|
|
||||||
if(match) {
|
|
||||||
var value;
|
|
||||||
// Get the base value
|
|
||||||
switch(match[1]) {
|
|
||||||
case "uri":
|
|
||||||
case "title":
|
|
||||||
value = title;
|
|
||||||
break;
|
|
||||||
case "type":
|
|
||||||
value = tiddler.fields.type || "text/vnd.tiddlywiki";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Apply the encoding function
|
|
||||||
switch(match[2]) {
|
|
||||||
case "encoded":
|
|
||||||
value = encodeURIComponent(value);
|
|
||||||
break;
|
|
||||||
case "doubleencoded":
|
|
||||||
value = encodeURIComponent(encodeURIComponent(value));
|
|
||||||
break;
|
|
||||||
case "slugify":
|
|
||||||
value = self.wiki.slugify(value);
|
|
||||||
break;
|
|
||||||
case "extension":
|
|
||||||
value = ($tw.config.contentTypeInfo[value] || {extension: "."}).extension.slice(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
output.push(value);
|
|
||||||
} else {
|
|
||||||
output.push(part);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return output.join("");
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Convert the path into a regexp and an array of {field:,function:} for each capture group
|
|
||||||
*/
|
|
||||||
Sitemap.prototype.regexpurgateParameterisedPath = function(parameterisedPath) {
|
|
||||||
var regexpParts = ["\\/"],
|
|
||||||
captureGroups = [];
|
|
||||||
$tw.utils.each(parameterisedPath.split(/(\$[a-z_]+\$)/),function(part) {
|
|
||||||
var match = part.match(/\$([a-z]+)_([a-z]+)\$/);
|
|
||||||
if(match) {
|
|
||||||
regexpParts.push("(.+)");
|
|
||||||
captureGroups.push({
|
|
||||||
field: match[1],
|
|
||||||
function: match[2]
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
regexpParts.push($tw.utils.escapeRegExp(part));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
regexp: new RegExp("^" + regexpParts.join("") + "$"),
|
|
||||||
captureGroups: captureGroups
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Sitemap = Sitemap;
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ exports.startup = function() {
|
|||||||
if(event.data.status.charAt(0) === "2") {
|
if(event.data.status.charAt(0) === "2") {
|
||||||
if(event.data.cookies) {
|
if(event.data.cookies) {
|
||||||
if(event.data.cookies.type === "save-info") {
|
if(event.data.cookies.type === "save-info") {
|
||||||
var tiddlers = JSON.parse(event.data.body);
|
var tiddlers = $tw.utils.parseJSONSafe(event.data.body);
|
||||||
$tw.utils.each(tiddlers,function(tiddler) {
|
$tw.utils.each(tiddlers,function(tiddler) {
|
||||||
$tw.wiki.addTiddler(new $tw.Tiddler($tw.wiki.getCreationFields(),tiddler,{
|
$tw.wiki.addTiddler(new $tw.Tiddler($tw.wiki.getCreationFields(),tiddler,{
|
||||||
title: event.data.cookies.infoTitlePrefix + event.data.cookies.url + "/" + tiddler.title,
|
title: event.data.cookies.infoTitlePrefix + event.data.cookies.url + "/" + tiddler.title,
|
||||||
@@ -170,7 +170,7 @@ exports.startup = function() {
|
|||||||
},$tw.wiki.getModificationFields()));
|
},$tw.wiki.getModificationFields()));
|
||||||
});
|
});
|
||||||
} else if(event.data.cookies.type === "save-tiddler") {
|
} else if(event.data.cookies.type === "save-tiddler") {
|
||||||
var tiddler = JSON.parse(event.data.body);
|
var tiddler = $tw.utils.parseJSONSafe(event.data.body);
|
||||||
$tw.wiki.addTiddler(new $tw.Tiddler(tiddler));
|
$tw.wiki.addTiddler(new $tw.Tiddler(tiddler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,17 @@ exports.startup = function() {
|
|||||||
$tw.styleWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_STYLESHEET_TITLE,{document: $tw.fakeDocument});
|
$tw.styleWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_STYLESHEET_TITLE,{document: $tw.fakeDocument});
|
||||||
$tw.styleContainer = $tw.fakeDocument.createElement("style");
|
$tw.styleContainer = $tw.fakeDocument.createElement("style");
|
||||||
$tw.styleWidgetNode.render($tw.styleContainer,null);
|
$tw.styleWidgetNode.render($tw.styleContainer,null);
|
||||||
|
$tw.styleWidgetNode.assignedStyles = $tw.styleContainer.textContent;
|
||||||
$tw.styleElement = document.createElement("style");
|
$tw.styleElement = document.createElement("style");
|
||||||
$tw.styleElement.innerHTML = $tw.styleContainer.textContent;
|
$tw.styleElement.innerHTML = $tw.styleWidgetNode.assignedStyles;
|
||||||
document.head.insertBefore($tw.styleElement,document.head.firstChild);
|
document.head.insertBefore($tw.styleElement,document.head.firstChild);
|
||||||
$tw.wiki.addEventListener("change",$tw.perf.report("styleRefresh",function(changes) {
|
$tw.wiki.addEventListener("change",$tw.perf.report("styleRefresh",function(changes) {
|
||||||
if($tw.styleWidgetNode.refresh(changes,$tw.styleContainer,null)) {
|
if($tw.styleWidgetNode.refresh(changes,$tw.styleContainer,null)) {
|
||||||
$tw.styleElement.innerHTML = $tw.styleContainer.textContent;
|
var newStyles = $tw.styleContainer.textContent;
|
||||||
|
if(newStyles !== $tw.styleWidgetNode.assignedStyles) {
|
||||||
|
$tw.styleWidgetNode.assignedStyles = newStyles;
|
||||||
|
$tw.styleElement.innerHTML = $tw.styleWidgetNode.assignedStyles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
// Display the $:/core/ui/PageTemplate tiddler to kick off the display
|
// Display the $:/core/ui/PageTemplate tiddler to kick off the display
|
||||||
|
|||||||
@@ -51,6 +51,20 @@ exports.startup = function() {
|
|||||||
element.focus(event.paramObject);
|
element.focus(event.paramObject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Install the tm-rename-tiddler and tm-relink-tiddler messages
|
||||||
|
var makeRenameHandler = function(method) {
|
||||||
|
return function(event) {
|
||||||
|
var options = {},
|
||||||
|
paramObject = event.paramObject || {},
|
||||||
|
from = paramObject.from || event.tiddlerTitle,
|
||||||
|
to = paramObject.to;
|
||||||
|
options.dontRenameInTags = (paramObject.renameInTags === "false" || paramObject.renameInTags === "no") ? true : false;
|
||||||
|
options.dontRenameInLists = (paramObject.renameInLists === "false" || paramObject.renameInLists === "no") ? true : false;
|
||||||
|
$tw.wiki[method](from,to,options);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$tw.rootWidget.addEventListener("tm-rename-tiddler",makeRenameHandler("renameTiddler"));
|
||||||
|
$tw.rootWidget.addEventListener("tm-relink-tiddler",makeRenameHandler("relinkTiddler"));
|
||||||
// Install the scroller
|
// Install the scroller
|
||||||
$tw.pageScroller = new $tw.utils.PageScroller();
|
$tw.pageScroller = new $tw.utils.PageScroller();
|
||||||
$tw.rootWidget.addEventListener("tm-scroll",function(event) {
|
$tw.rootWidget.addEventListener("tm-scroll",function(event) {
|
||||||
@@ -73,12 +87,6 @@ exports.startup = function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Hook up events for the publisher handler
|
|
||||||
$tw.rootWidget.addEventListener("tm-publish",function(event) {
|
|
||||||
$tw.publisherHandler.publish(event.paramObject.job,function(err) {
|
|
||||||
console.log("Finished publishing with result:",err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// If we're being viewed on a data: URI then give instructions for how to save
|
// If we're being viewed on a data: URI then give instructions for how to save
|
||||||
if(document.location.protocol === "data:") {
|
if(document.location.protocol === "data:") {
|
||||||
$tw.rootWidget.dispatchEvent({
|
$tw.rootWidget.dispatchEvent({
|
||||||
|
|||||||
@@ -129,10 +129,6 @@ exports.startup = function() {
|
|||||||
dirtyTracking: !$tw.syncadaptor,
|
dirtyTracking: !$tw.syncadaptor,
|
||||||
preloadDirty: $tw.boot.preloadDirty || []
|
preloadDirty: $tw.boot.preloadDirty || []
|
||||||
});
|
});
|
||||||
// Install the publisher handler
|
|
||||||
$tw.publisherHandler = new $tw.PublisherHandler({
|
|
||||||
wiki: $tw.wiki
|
|
||||||
});
|
|
||||||
// Host-specific startup
|
// Host-specific startup
|
||||||
if($tw.browser) {
|
if($tw.browser) {
|
||||||
// Install the popup manager
|
// Install the popup manager
|
||||||
|
|||||||
@@ -120,10 +120,10 @@ function openStartupTiddlers(options) {
|
|||||||
var hash = $tw.locationHash.substr(1),
|
var hash = $tw.locationHash.substr(1),
|
||||||
split = hash.indexOf(":");
|
split = hash.indexOf(":");
|
||||||
if(split === -1) {
|
if(split === -1) {
|
||||||
target = decodeURIComponent(hash.trim());
|
target = $tw.utils.decodeURIComponentSafe(hash.trim());
|
||||||
} else {
|
} else {
|
||||||
target = decodeURIComponent(hash.substr(0,split).trim());
|
target = $tw.utils.decodeURIComponentSafe(hash.substr(0,split).trim());
|
||||||
storyFilter = decodeURIComponent(hash.substr(split + 1).trim());
|
storyFilter = $tw.utils.decodeURIComponentSafe(hash.substr(split + 1).trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the story wasn't specified use the current tiddlers or a blank story
|
// If the story wasn't specified use the current tiddlers or a blank story
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ exports.synchronous = true;
|
|||||||
|
|
||||||
// Global to keep track of open windows (hashmap by title)
|
// Global to keep track of open windows (hashmap by title)
|
||||||
$tw.windows = {};
|
$tw.windows = {};
|
||||||
|
// Default template to use for new windows
|
||||||
|
var DEFAULT_WINDOW_TEMPLATE = "$:/core/templates/single.tiddler.window";
|
||||||
|
|
||||||
exports.startup = function() {
|
exports.startup = function() {
|
||||||
// Handle open window message
|
// Handle open window message
|
||||||
@@ -29,22 +31,25 @@ exports.startup = function() {
|
|||||||
title = event.param || event.tiddlerTitle,
|
title = event.param || event.tiddlerTitle,
|
||||||
paramObject = event.paramObject || {},
|
paramObject = event.paramObject || {},
|
||||||
windowTitle = paramObject.windowTitle || title,
|
windowTitle = paramObject.windowTitle || title,
|
||||||
template = paramObject.template || "$:/core/templates/single.tiddler.window",
|
windowID = paramObject.windowID || title,
|
||||||
|
template = paramObject.template || DEFAULT_WINDOW_TEMPLATE,
|
||||||
width = paramObject.width || "700",
|
width = paramObject.width || "700",
|
||||||
height = paramObject.height || "600",
|
height = paramObject.height || "600",
|
||||||
variables = $tw.utils.extend({},paramObject,{currentTiddler: title});
|
top = paramObject.top,
|
||||||
|
left = paramObject.left,
|
||||||
|
variables = $tw.utils.extend({},paramObject,{currentTiddler: title, "tv-window-id": windowID});
|
||||||
// Open the window
|
// Open the window
|
||||||
var srcWindow,
|
var srcWindow,
|
||||||
srcDocument;
|
srcDocument;
|
||||||
// In case that popup blockers deny opening a new window
|
// In case that popup blockers deny opening a new window
|
||||||
try {
|
try {
|
||||||
srcWindow = window.open("","external-" + title,"scrollbars,width=" + width + ",height=" + height),
|
srcWindow = window.open("","external-" + windowID,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )),
|
||||||
srcDocument = srcWindow.document;
|
srcDocument = srcWindow.document;
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$tw.windows[title] = srcWindow;
|
$tw.windows[windowID] = srcWindow;
|
||||||
// Check for reopening the same window
|
// Check for reopening the same window
|
||||||
if(srcWindow.haveInitialisedWindow) {
|
if(srcWindow.haveInitialisedWindow) {
|
||||||
return;
|
return;
|
||||||
@@ -54,7 +59,7 @@ exports.startup = function() {
|
|||||||
srcDocument.close();
|
srcDocument.close();
|
||||||
srcDocument.title = windowTitle;
|
srcDocument.title = windowTitle;
|
||||||
srcWindow.addEventListener("beforeunload",function(event) {
|
srcWindow.addEventListener("beforeunload",function(event) {
|
||||||
delete $tw.windows[title];
|
delete $tw.windows[windowID];
|
||||||
$tw.wiki.removeEventListener("change",refreshHandler);
|
$tw.wiki.removeEventListener("change",refreshHandler);
|
||||||
},false);
|
},false);
|
||||||
// Set up the styles
|
// Set up the styles
|
||||||
@@ -88,13 +93,21 @@ exports.startup = function() {
|
|||||||
srcWindow.document.documentElement.addEventListener("click",$tw.popup,true);
|
srcWindow.document.documentElement.addEventListener("click",$tw.popup,true);
|
||||||
srcWindow.haveInitialisedWindow = true;
|
srcWindow.haveInitialisedWindow = true;
|
||||||
});
|
});
|
||||||
// Close open windows when unloading main window
|
$tw.rootWidget.addEventListener("tm-close-window",function(event) {
|
||||||
$tw.addUnloadTask(function() {
|
var windowID = event.param,
|
||||||
|
win = $tw.windows[windowID];
|
||||||
|
if(win) {
|
||||||
|
win.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var closeAllWindows = function() {
|
||||||
$tw.utils.each($tw.windows,function(win) {
|
$tw.utils.each($tw.windows,function(win) {
|
||||||
win.close();
|
win.close();
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
$tw.rootWidget.addEventListener("tm-close-all-windows",closeAllWindows);
|
||||||
|
// Close open windows when unloading main window
|
||||||
|
$tw.addUnloadTask(closeAllWindows);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ Syncer.prototype.titleIsAnonymous = "$:/status/IsAnonymous";
|
|||||||
Syncer.prototype.titleIsReadOnly = "$:/status/IsReadOnly";
|
Syncer.prototype.titleIsReadOnly = "$:/status/IsReadOnly";
|
||||||
Syncer.prototype.titleUserName = "$:/status/UserName";
|
Syncer.prototype.titleUserName = "$:/status/UserName";
|
||||||
Syncer.prototype.titleSyncFilter = "$:/config/SyncFilter";
|
Syncer.prototype.titleSyncFilter = "$:/config/SyncFilter";
|
||||||
Syncer.prototype.titleSyncDisablePolling = "$:/config/SyncDisablePolling";
|
|
||||||
Syncer.prototype.titleSyncPollingInterval = "$:/config/SyncPollingInterval";
|
Syncer.prototype.titleSyncPollingInterval = "$:/config/SyncPollingInterval";
|
||||||
Syncer.prototype.titleSyncDisableLazyLoading = "$:/config/SyncDisableLazyLoading";
|
Syncer.prototype.titleSyncDisableLazyLoading = "$:/config/SyncDisableLazyLoading";
|
||||||
Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
|
Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
|
||||||
@@ -90,7 +89,7 @@ function Syncer(options) {
|
|||||||
if(filteredChanges.length > 0) {
|
if(filteredChanges.length > 0) {
|
||||||
self.processTaskQueue();
|
self.processTaskQueue();
|
||||||
} else {
|
} else {
|
||||||
// Look for deletions of tiddlers we're already syncing
|
// Look for deletions of tiddlers we're already syncing
|
||||||
var outstandingDeletion = false
|
var outstandingDeletion = false
|
||||||
$tw.utils.each(changes,function(change,title,object) {
|
$tw.utils.each(changes,function(change,title,object) {
|
||||||
if(change.deleted && $tw.utils.hop(self.tiddlerInfo,title)) {
|
if(change.deleted && $tw.utils.hop(self.tiddlerInfo,title)) {
|
||||||
@@ -122,7 +121,7 @@ function Syncer(options) {
|
|||||||
self.login(username,password,function() {});
|
self.login(username,password,function() {});
|
||||||
} else {
|
} else {
|
||||||
// No username and password, so we display a prompt
|
// No username and password, so we display a prompt
|
||||||
self.handleLoginEvent();
|
self.handleLoginEvent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$tw.rootWidget.addEventListener("tm-logout",function() {
|
$tw.rootWidget.addEventListener("tm-logout",function() {
|
||||||
@@ -139,7 +138,7 @@ function Syncer(options) {
|
|||||||
if(!this.disableUI && this.wiki.getTiddlerText(this.titleSyncDisableLazyLoading) !== "yes") {
|
if(!this.disableUI && this.wiki.getTiddlerText(this.titleSyncDisableLazyLoading) !== "yes") {
|
||||||
this.wiki.addEventListener("lazyLoad",function(title) {
|
this.wiki.addEventListener("lazyLoad",function(title) {
|
||||||
self.handleLazyLoadEvent(title);
|
self.handleLazyLoadEvent(title);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Get the login status
|
// Get the login status
|
||||||
this.getStatus(function(err,isLoggedIn) {
|
this.getStatus(function(err,isLoggedIn) {
|
||||||
@@ -174,8 +173,8 @@ Syncer.prototype.getTiddlerRevision = function(title) {
|
|||||||
if(this.syncadaptor && this.syncadaptor.getTiddlerRevision) {
|
if(this.syncadaptor && this.syncadaptor.getTiddlerRevision) {
|
||||||
return this.syncadaptor.getTiddlerRevision(title);
|
return this.syncadaptor.getTiddlerRevision(title);
|
||||||
} else {
|
} else {
|
||||||
return this.wiki.getTiddler(title).fields.revision;
|
return this.wiki.getTiddler(title).fields.revision;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -268,9 +267,9 @@ Syncer.prototype.getStatus = function(callback) {
|
|||||||
// Mark us as not logged in
|
// Mark us as not logged in
|
||||||
this.wiki.addTiddler({title: this.titleIsLoggedIn,text: "no"});
|
this.wiki.addTiddler({title: this.titleIsLoggedIn,text: "no"});
|
||||||
// Get login status
|
// Get login status
|
||||||
this.syncadaptor.getStatus(function(err,isLoggedIn,username,isReadOnly,isAnonymous,isPollingDisabled) {
|
this.syncadaptor.getStatus(function(err,isLoggedIn,username,isReadOnly,isAnonymous) {
|
||||||
if(err) {
|
if(err) {
|
||||||
self.logger.alert(err);
|
self.displayError("Get Status Error",err);
|
||||||
} else {
|
} else {
|
||||||
// Set the various status tiddlers
|
// Set the various status tiddlers
|
||||||
self.wiki.addTiddler({title: self.titleIsReadOnly,text: isReadOnly ? "yes" : "no"});
|
self.wiki.addTiddler({title: self.titleIsReadOnly,text: isReadOnly ? "yes" : "no"});
|
||||||
@@ -279,9 +278,6 @@ Syncer.prototype.getStatus = function(callback) {
|
|||||||
if(isLoggedIn) {
|
if(isLoggedIn) {
|
||||||
self.wiki.addTiddler({title: self.titleUserName,text: username || ""});
|
self.wiki.addTiddler({title: self.titleUserName,text: username || ""});
|
||||||
}
|
}
|
||||||
if(isPollingDisabled) {
|
|
||||||
self.wiki.addTiddler({title: self.titleSyncDisablePolling, text: "yes"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Invoke the callback
|
// Invoke the callback
|
||||||
if(callback) {
|
if(callback) {
|
||||||
@@ -305,15 +301,12 @@ Syncer.prototype.syncFromServer = function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
triggerNextSync = function() {
|
triggerNextSync = function() {
|
||||||
if(pollingEnabled) {
|
self.pollTimerId = setTimeout(function() {
|
||||||
self.pollTimerId = setTimeout(function() {
|
self.pollTimerId = null;
|
||||||
self.pollTimerId = null;
|
self.syncFromServer.call(self);
|
||||||
self.syncFromServer.call(self);
|
},self.pollTimerInterval);
|
||||||
},self.pollTimerInterval);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes"),
|
syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
|
||||||
pollingEnabled = (self.wiki.getTiddlerText(self.titleSyncDisablePolling) !== "yes");
|
|
||||||
if(this.syncadaptor && this.syncadaptor.getUpdatedTiddlers) {
|
if(this.syncadaptor && this.syncadaptor.getUpdatedTiddlers) {
|
||||||
this.logger.log("Retrieving updated tiddler list");
|
this.logger.log("Retrieving updated tiddler list");
|
||||||
cancelNextSync();
|
cancelNextSync();
|
||||||
@@ -336,7 +329,7 @@ Syncer.prototype.syncFromServer = function() {
|
|||||||
});
|
});
|
||||||
if(updates.modifications.length > 0 || updates.deletions.length > 0) {
|
if(updates.modifications.length > 0 || updates.deletions.length > 0) {
|
||||||
self.processTaskQueue();
|
self.processTaskQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if(this.syncadaptor && this.syncadaptor.getSkinnyTiddlers) {
|
} else if(this.syncadaptor && this.syncadaptor.getSkinnyTiddlers) {
|
||||||
@@ -479,7 +472,7 @@ Syncer.prototype.handleLogoutEvent = function() {
|
|||||||
if(this.syncadaptor.logout) {
|
if(this.syncadaptor.logout) {
|
||||||
this.syncadaptor.logout(function(err) {
|
this.syncadaptor.logout(function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
self.logger.alert(err);
|
self.displayError("Logout Error",err);
|
||||||
} else {
|
} else {
|
||||||
self.getStatus();
|
self.getStatus();
|
||||||
}
|
}
|
||||||
@@ -516,7 +509,7 @@ Syncer.prototype.processTaskQueue = function() {
|
|||||||
} else {
|
} else {
|
||||||
self.updateDirtyStatus();
|
self.updateDirtyStatus();
|
||||||
// Process the next task
|
// Process the next task
|
||||||
self.processTaskQueue.call(self);
|
self.processTaskQueue.call(self);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -524,11 +517,11 @@ Syncer.prototype.processTaskQueue = function() {
|
|||||||
this.updateDirtyStatus();
|
this.updateDirtyStatus();
|
||||||
// And trigger a timeout if there is a pending task
|
// And trigger a timeout if there is a pending task
|
||||||
if(task === true) {
|
if(task === true) {
|
||||||
this.triggerTimeout();
|
this.triggerTimeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.updateDirtyStatus();
|
this.updateDirtyStatus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -562,7 +555,7 @@ Syncer.prototype.chooseNextTask = function() {
|
|||||||
isReadyToSave = !tiddlerInfo || !tiddlerInfo.timestampLastSaved || tiddlerInfo.timestampLastSaved < thresholdLastSaved;
|
isReadyToSave = !tiddlerInfo || !tiddlerInfo.timestampLastSaved || tiddlerInfo.timestampLastSaved < thresholdLastSaved;
|
||||||
if(hasChanged) {
|
if(hasChanged) {
|
||||||
if(isReadyToSave) {
|
if(isReadyToSave) {
|
||||||
return new SaveTiddlerTask(this,title);
|
return new SaveTiddlerTask(this,title);
|
||||||
} else {
|
} else {
|
||||||
havePending = true;
|
havePending = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ exports.isDraft = function() {
|
|||||||
return this.hasField("draft.of");
|
return this.hasField("draft.of");
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getFieldString = function(field) {
|
exports.getFieldString = function(field,defaultValue) {
|
||||||
var value = this.fields[field];
|
var value = this.fields[field];
|
||||||
// Check for a missing field
|
// Check for a missing field
|
||||||
if(value === undefined || value === null) {
|
if(value === undefined || value === null) {
|
||||||
return "";
|
return defaultValue || "";
|
||||||
}
|
}
|
||||||
// Parse the field with the associated module (if any)
|
// Stringify the field with the associated tiddler field module (if any)
|
||||||
var fieldModule = $tw.Tiddler.fieldModules[field];
|
var fieldModule = $tw.Tiddler.fieldModules[field];
|
||||||
if(fieldModule && fieldModule.stringify) {
|
if(fieldModule && fieldModule.stringify) {
|
||||||
return fieldModule.stringify.call(this,value);
|
return fieldModule.stringify.call(this,value);
|
||||||
@@ -54,27 +54,15 @@ exports.getFieldList = function(field) {
|
|||||||
/*
|
/*
|
||||||
Get all the fields as a hashmap of strings. Options:
|
Get all the fields as a hashmap of strings. Options:
|
||||||
exclude: an array of field names to exclude
|
exclude: an array of field names to exclude
|
||||||
prefix: an optional field name prefix. Only fields with the prefix are included, and the prefix is stripped from the name
|
|
||||||
*/
|
*/
|
||||||
exports.getFieldStrings = function(options) {
|
exports.getFieldStrings = function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var exclude = options.exclude || [],
|
var exclude = options.exclude || [];
|
||||||
fields = {},
|
var fields = {};
|
||||||
field;
|
for(var field in this.fields) {
|
||||||
if(options.prefix) {
|
if($tw.utils.hop(this.fields,field)) {
|
||||||
for(field in this.fields) {
|
if(exclude.indexOf(field) === -1) {
|
||||||
if($tw.utils.hop(this.fields,field)) {
|
fields[field] = this.getFieldString(field);
|
||||||
if(exclude.indexOf(field) === -1 && field.substring(0,options.prefix.length) === options.prefix) {
|
|
||||||
fields[field.substring(options.prefix.length)] = this.getFieldString(field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(field in this.fields) {
|
|
||||||
if($tw.utils.hop(this.fields,field)) {
|
|
||||||
if(exclude.indexOf(field) === -1) {
|
|
||||||
fields[field] = this.getFieldString(field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
|||||||
// Check if we're dealing with a plugin
|
// Check if we're dealing with a plugin
|
||||||
if(incomingTiddler && incomingTiddler["plugin-type"]) {
|
if(incomingTiddler && incomingTiddler["plugin-type"]) {
|
||||||
// Check whether the plugin contains JS modules
|
// Check whether the plugin contains JS modules
|
||||||
var requiresReload = wiki.doesPluginInfoRequireReload(JSON.parse(incomingTiddler.text)) ? (wiki.getTiddlerText("$:/language/ControlPanel/Plugins/PluginWillRequireReload") + " ") : "";
|
var requiresReload = wiki.doesPluginInfoRequireReload($tw.utils.parseJSONSafe(incomingTiddler.text)) ? (wiki.getTiddlerText("$:/language/ControlPanel/Plugins/PluginWillRequireReload") + " ") : "";
|
||||||
messages[title] = requiresReload;
|
messages[title] = requiresReload;
|
||||||
if(incomingTiddler.version) {
|
if(incomingTiddler.version) {
|
||||||
// Upgrade the incoming plugin if it is in the upgrade library
|
// Upgrade the incoming plugin if it is in the upgrade library
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ exports.extractEncryptedStoreArea = function(text) {
|
|||||||
if(encryptedStoreAreaStart !== -1) {
|
if(encryptedStoreAreaStart !== -1) {
|
||||||
var encryptedStoreAreaEnd = text.indexOf("</pre>",encryptedStoreAreaStart);
|
var encryptedStoreAreaEnd = text.indexOf("</pre>",encryptedStoreAreaStart);
|
||||||
if(encryptedStoreAreaEnd !== -1) {
|
if(encryptedStoreAreaEnd !== -1) {
|
||||||
return $tw.utils.htmlDecode(text.substring(encryptedStoreAreaStart + encryptedStoreAreaStartMarker.length,encryptedStoreAreaEnd-1));
|
return $tw.utils.htmlDecode(text.substring(encryptedStoreAreaStart + encryptedStoreAreaStartMarker.length,encryptedStoreAreaEnd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -33,7 +33,7 @@ Attempt to extract the tiddlers from an encrypted store area using the current p
|
|||||||
exports.decryptStoreArea = function(encryptedStoreArea,password) {
|
exports.decryptStoreArea = function(encryptedStoreArea,password) {
|
||||||
var decryptedText = $tw.crypto.decrypt(encryptedStoreArea,password);
|
var decryptedText = $tw.crypto.decrypt(encryptedStoreArea,password);
|
||||||
if(decryptedText) {
|
if(decryptedText) {
|
||||||
var json = JSON.parse(decryptedText),
|
var json = $tw.utils.parseJSONSafe(decryptedText),
|
||||||
tiddlers = [];
|
tiddlers = [];
|
||||||
for(var title in json) {
|
for(var title in json) {
|
||||||
if(title !== "$:/isEncrypted") {
|
if(title !== "$:/isEncrypted") {
|
||||||
|
|||||||
@@ -16,21 +16,23 @@ Browser data transfer utilities, used with the clipboard and drag and drop
|
|||||||
Options:
|
Options:
|
||||||
|
|
||||||
domNode: dom node to make draggable
|
domNode: dom node to make draggable
|
||||||
dragImageType: "pill" or "dom"
|
selector: CSS selector to identify element within domNode to be used as drag handle (optional)
|
||||||
|
dragImageType: "pill", "blank" or "dom" (the default)
|
||||||
dragTiddlerFn: optional function to retrieve the title of tiddler to drag
|
dragTiddlerFn: optional function to retrieve the title of tiddler to drag
|
||||||
dragFilterFn: optional function to retreive the filter defining a list of tiddlers to drag
|
dragFilterFn: optional function to retreive the filter defining a list of tiddlers to drag
|
||||||
widget: widget to use as the contect for the filter
|
widget: widget to use as the context for the filter
|
||||||
*/
|
*/
|
||||||
exports.makeDraggable = function(options) {
|
exports.makeDraggable = function(options) {
|
||||||
var dragImageType = options.dragImageType || "dom",
|
var dragImageType = options.dragImageType || "dom",
|
||||||
dragImage,
|
dragImage,
|
||||||
domNode = options.domNode;
|
domNode = options.domNode,
|
||||||
|
dragHandle = options.selector && domNode.querySelector(options.selector) || domNode;
|
||||||
// Make the dom node draggable (not necessary for anchor tags)
|
// Make the dom node draggable (not necessary for anchor tags)
|
||||||
if((domNode.tagName || "").toLowerCase() !== "a") {
|
if((domNode.tagName || "").toLowerCase() !== "a") {
|
||||||
domNode.setAttribute("draggable","true");
|
dragHandle.setAttribute("draggable","true");
|
||||||
}
|
}
|
||||||
// Add event handlers
|
// Add event handlers
|
||||||
$tw.utils.addEventListeners(domNode,[
|
$tw.utils.addEventListeners(dragHandle,[
|
||||||
{name: "dragstart", handlerFunction: function(event) {
|
{name: "dragstart", handlerFunction: function(event) {
|
||||||
if(event.dataTransfer === undefined) {
|
if(event.dataTransfer === undefined) {
|
||||||
return false;
|
return false;
|
||||||
@@ -45,7 +47,7 @@ exports.makeDraggable = function(options) {
|
|||||||
}
|
}
|
||||||
var titleString = $tw.utils.stringifyList(titles);
|
var titleString = $tw.utils.stringifyList(titles);
|
||||||
// Check that we've something to drag
|
// Check that we've something to drag
|
||||||
if(titles.length > 0 && event.target === domNode) {
|
if(titles.length > 0 && event.target === dragHandle) {
|
||||||
// Mark the drag in progress
|
// Mark the drag in progress
|
||||||
$tw.dragInProgress = domNode;
|
$tw.dragInProgress = domNode;
|
||||||
// Set the dragging class on the element being dragged
|
// Set the dragging class on the element being dragged
|
||||||
@@ -73,6 +75,9 @@ exports.makeDraggable = function(options) {
|
|||||||
if(dataTransfer.setDragImage) {
|
if(dataTransfer.setDragImage) {
|
||||||
if(dragImageType === "pill") {
|
if(dragImageType === "pill") {
|
||||||
dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
|
dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
|
||||||
|
} else if (dragImageType === "blank") {
|
||||||
|
dragImage.removeChild(dragImage.firstChild);
|
||||||
|
dataTransfer.setDragImage(dragImage,0,0);
|
||||||
} else {
|
} else {
|
||||||
var r = domNode.getBoundingClientRect();
|
var r = domNode.getBoundingClientRect();
|
||||||
dataTransfer.setDragImage(domNode,event.clientX-r.left,event.clientY-r.top);
|
dataTransfer.setDragImage(domNode,event.clientX-r.left,event.clientY-r.top);
|
||||||
@@ -164,7 +169,7 @@ var importDataTypes = [
|
|||||||
}},
|
}},
|
||||||
{type: "URL", IECompatible: true, toTiddlerFieldsArray: function(data,fallbackTitle) {
|
{type: "URL", IECompatible: true, toTiddlerFieldsArray: function(data,fallbackTitle) {
|
||||||
// Check for tiddler data URI
|
// Check for tiddler data URI
|
||||||
var match = decodeURIComponent(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
var match = $tw.utils.decodeURIComponentSafe(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||||
if(match) {
|
if(match) {
|
||||||
return parseJSONTiddlers(match[1],fallbackTitle);
|
return parseJSONTiddlers(match[1],fallbackTitle);
|
||||||
} else {
|
} else {
|
||||||
@@ -173,7 +178,7 @@ var importDataTypes = [
|
|||||||
}},
|
}},
|
||||||
{type: "text/x-moz-url", IECompatible: false, toTiddlerFieldsArray: function(data,fallbackTitle) {
|
{type: "text/x-moz-url", IECompatible: false, toTiddlerFieldsArray: function(data,fallbackTitle) {
|
||||||
// Check for tiddler data URI
|
// Check for tiddler data URI
|
||||||
var match = decodeURIComponent(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
var match = $tw.utils.decodeURIComponentSafe(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||||
if(match) {
|
if(match) {
|
||||||
return parseJSONTiddlers(match[1],fallbackTitle);
|
return parseJSONTiddlers(match[1],fallbackTitle);
|
||||||
} else {
|
} else {
|
||||||
@@ -195,7 +200,7 @@ var importDataTypes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function parseJSONTiddlers(json,fallbackTitle) {
|
function parseJSONTiddlers(json,fallbackTitle) {
|
||||||
var data = JSON.parse(json);
|
var data = $tw.utils.parseJSONSafe(json);
|
||||||
if(!$tw.utils.isArray(data)) {
|
if(!$tw.utils.isArray(data)) {
|
||||||
data = [data];
|
data = [data];
|
||||||
}
|
}
|
||||||
@@ -205,10 +210,10 @@ function parseJSONTiddlers(json,fallbackTitle) {
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.dragEventContainsFiles = function(event) {
|
function dragEventContainsType(event,targetType) {
|
||||||
if(event.dataTransfer.types) {
|
if(event.dataTransfer.types) {
|
||||||
for(var i=0; i<event.dataTransfer.types.length; i++) {
|
for(var i=0; i<event.dataTransfer.types.length; i++) {
|
||||||
if(event.dataTransfer.types[i] === "Files") {
|
if(event.dataTransfer.types[i] === targetType) {
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -217,4 +222,10 @@ exports.dragEventContainsFiles = function(event) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.dragEventContainsFiles = function(event) {
|
||||||
|
return (dragEventContainsType(event,"Files") && !dragEventContainsType(event,"text/plain"));
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.dragEventContainsType = dragEventContainsType;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -34,6 +34,23 @@ exports.httpRequest = function(options) {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
getHeader = function(targetHeader) {
|
||||||
|
return headers[targetHeader] || headers[targetHeader.toLowerCase()];
|
||||||
|
},
|
||||||
|
isSimpleRequest = function(type,headers) {
|
||||||
|
if(["GET","HEAD","POST"].indexOf(type) === -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for(var header in headers) {
|
||||||
|
if(["accept","accept-language","content-language","content-type"].indexOf(header.toLowerCase()) === -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(hasHeader("Content-Type") && ["application/x-www-form-urlencoded","multipart/form-data","text/plain"].indexOf(getHeader["Content-Type"]) === -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
returnProp = options.returnProp || "responseText",
|
returnProp = options.returnProp || "responseText",
|
||||||
request = new XMLHttpRequest(),
|
request = new XMLHttpRequest(),
|
||||||
data = "",
|
data = "",
|
||||||
@@ -76,7 +93,7 @@ exports.httpRequest = function(options) {
|
|||||||
if(data && !hasHeader("Content-Type")) {
|
if(data && !hasHeader("Content-Type")) {
|
||||||
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
|
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
}
|
}
|
||||||
if(!hasHeader("X-Requested-With")) {
|
if(!hasHeader("X-Requested-With") && !isSimpleRequest(type,headers)) {
|
||||||
request.setRequestHeader("X-Requested-With","TiddlyWiki");
|
request.setRequestHeader("X-Requested-With","TiddlyWiki");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ Modal message mechanism
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var widget = require("$:/core/modules/widgets/widget.js"),
|
var widget = require("$:/core/modules/widgets/widget.js");
|
||||||
navigator = require("$:/core/modules/widgets/navigator.js"),
|
var navigator = require("$:/core/modules/widgets/navigator.js");
|
||||||
dm = $tw.utils.domMaker;
|
|
||||||
|
|
||||||
var Modal = function(wiki) {
|
var Modal = function(wiki) {
|
||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
@@ -27,10 +26,6 @@ Display a modal dialogue
|
|||||||
options: see below
|
options: see below
|
||||||
Options include:
|
Options include:
|
||||||
downloadLink: Text of a big download link to include
|
downloadLink: Text of a big download link to include
|
||||||
variables: variables to be passed to the modal
|
|
||||||
event: optional DOM event that initiated the modal
|
|
||||||
progress: set to true to add a progress bar
|
|
||||||
onclose: callback for when the modal is closed
|
|
||||||
*/
|
*/
|
||||||
Modal.prototype.display = function(title,options) {
|
Modal.prototype.display = function(title,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@@ -52,6 +47,7 @@ Modal.prototype.display = function(title,options) {
|
|||||||
"tv-story-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-story-list") : ""),
|
"tv-story-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-story-list") : ""),
|
||||||
"tv-history-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-history-list") : "")
|
"tv-history-list": (options.event && options.event.widget ? options.event.widget.getVariable("tv-history-list") : "")
|
||||||
},options.variables);
|
},options.variables);
|
||||||
|
|
||||||
// Create the wrapper divs
|
// Create the wrapper divs
|
||||||
var wrapper = this.srcDocument.createElement("div"),
|
var wrapper = this.srcDocument.createElement("div"),
|
||||||
modalBackdrop = this.srcDocument.createElement("div"),
|
modalBackdrop = this.srcDocument.createElement("div"),
|
||||||
@@ -59,7 +55,6 @@ Modal.prototype.display = function(title,options) {
|
|||||||
modalHeader = this.srcDocument.createElement("div"),
|
modalHeader = this.srcDocument.createElement("div"),
|
||||||
headerTitle = this.srcDocument.createElement("h3"),
|
headerTitle = this.srcDocument.createElement("h3"),
|
||||||
modalBody = this.srcDocument.createElement("div"),
|
modalBody = this.srcDocument.createElement("div"),
|
||||||
modalProgress = this.srcDocument.createElement("div"),
|
|
||||||
modalLink = this.srcDocument.createElement("a"),
|
modalLink = this.srcDocument.createElement("a"),
|
||||||
modalFooter = this.srcDocument.createElement("div"),
|
modalFooter = this.srcDocument.createElement("div"),
|
||||||
modalFooterHelp = this.srcDocument.createElement("span"),
|
modalFooterHelp = this.srcDocument.createElement("span"),
|
||||||
@@ -76,7 +71,6 @@ Modal.prototype.display = function(title,options) {
|
|||||||
$tw.utils.addClass(modalWrapper,"tc-modal");
|
$tw.utils.addClass(modalWrapper,"tc-modal");
|
||||||
$tw.utils.addClass(modalHeader,"tc-modal-header");
|
$tw.utils.addClass(modalHeader,"tc-modal-header");
|
||||||
$tw.utils.addClass(modalBody,"tc-modal-body");
|
$tw.utils.addClass(modalBody,"tc-modal-body");
|
||||||
$tw.utils.addClass(modalProgress,"tc-modal-progress");
|
|
||||||
$tw.utils.addClass(modalFooter,"tc-modal-footer");
|
$tw.utils.addClass(modalFooter,"tc-modal-footer");
|
||||||
// Join them together
|
// Join them together
|
||||||
wrapper.appendChild(modalBackdrop);
|
wrapper.appendChild(modalBackdrop);
|
||||||
@@ -84,15 +78,6 @@ Modal.prototype.display = function(title,options) {
|
|||||||
modalHeader.appendChild(headerTitle);
|
modalHeader.appendChild(headerTitle);
|
||||||
modalWrapper.appendChild(modalHeader);
|
modalWrapper.appendChild(modalHeader);
|
||||||
modalWrapper.appendChild(modalBody);
|
modalWrapper.appendChild(modalBody);
|
||||||
if(options.progress) {
|
|
||||||
var modalProgressBar = this.srcDocument.createElement("div");
|
|
||||||
modalProgressBar.className = "tc-modal-progress-bar";
|
|
||||||
modalProgress.appendChild(modalProgressBar);
|
|
||||||
var modalProgressPercent = this.srcDocument.createElement("div");
|
|
||||||
modalProgressPercent.className = "tc-modal-progress-percent";
|
|
||||||
modalProgress.appendChild(modalProgressPercent);
|
|
||||||
modalWrapper.appendChild(modalProgress);
|
|
||||||
}
|
|
||||||
modalFooter.appendChild(modalFooterHelp);
|
modalFooter.appendChild(modalFooterHelp);
|
||||||
modalFooter.appendChild(modalFooterButtons);
|
modalFooter.appendChild(modalFooterButtons);
|
||||||
modalWrapper.appendChild(modalFooter);
|
modalWrapper.appendChild(modalFooter);
|
||||||
@@ -120,6 +105,7 @@ Modal.prototype.display = function(title,options) {
|
|||||||
parentWidget: $tw.rootWidget
|
parentWidget: $tw.rootWidget
|
||||||
});
|
});
|
||||||
navigatorWidgetNode.render(modalBody,null);
|
navigatorWidgetNode.render(modalBody,null);
|
||||||
|
|
||||||
// Render the title of the message
|
// Render the title of the message
|
||||||
var headerWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
var headerWidgetNode = this.wiki.makeTranscludeWidget(title,{
|
||||||
field: "subtitle",
|
field: "subtitle",
|
||||||
@@ -196,10 +182,6 @@ Modal.prototype.display = function(title,options) {
|
|||||||
this.wiki.addEventListener("change",refreshHandler);
|
this.wiki.addEventListener("change",refreshHandler);
|
||||||
// Add the close event handler
|
// Add the close event handler
|
||||||
var closeHandler = function(event) {
|
var closeHandler = function(event) {
|
||||||
// Call the onclose handler
|
|
||||||
if(options.onclose) {
|
|
||||||
options.onclose(event);
|
|
||||||
}
|
|
||||||
// Remove our refresh handler
|
// Remove our refresh handler
|
||||||
self.wiki.removeEventListener("change",refreshHandler);
|
self.wiki.removeEventListener("change",refreshHandler);
|
||||||
// Decrease the modal count and adjust the body class
|
// Decrease the modal count and adjust the body class
|
||||||
@@ -254,22 +236,6 @@ Modal.prototype.display = function(title,options) {
|
|||||||
$tw.utils.setStyle(modalWrapper,[
|
$tw.utils.setStyle(modalWrapper,[
|
||||||
{transform: "translateY(0px)"}
|
{transform: "translateY(0px)"}
|
||||||
]);
|
]);
|
||||||
// Return the wrapper node
|
|
||||||
return {
|
|
||||||
domNode: wrapper,
|
|
||||||
closeHandler: closeHandler,
|
|
||||||
setProgress: function(numerator,denominator) {
|
|
||||||
// Remove old progress
|
|
||||||
while(modalProgressPercent.hasChildNodes()) {
|
|
||||||
modalProgressPercent.removeChild(modalProgressPercent.firstChild);
|
|
||||||
}
|
|
||||||
// Set new text
|
|
||||||
var percent = (numerator * 100 /denominator).toFixed(2) + "%";
|
|
||||||
modalProgressPercent.appendChild(self.srcDocument.createTextNode(percent));
|
|
||||||
// Set bar width
|
|
||||||
modalProgressBar.style.width = percent;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Modal.prototype.adjustPageClass = function() {
|
Modal.prototype.adjustPageClass = function() {
|
||||||
|
|||||||
@@ -49,10 +49,14 @@ Handle an event
|
|||||||
*/
|
*/
|
||||||
PageScroller.prototype.handleEvent = function(event) {
|
PageScroller.prototype.handleEvent = function(event) {
|
||||||
if(event.type === "tm-scroll") {
|
if(event.type === "tm-scroll") {
|
||||||
|
var options = {};
|
||||||
|
if($tw.utils.hop(event.paramObject,"animationDuration")) {
|
||||||
|
options.animationDuration = event.paramObject.animationDuration;
|
||||||
|
}
|
||||||
if(event.paramObject && event.paramObject.selector) {
|
if(event.paramObject && event.paramObject.selector) {
|
||||||
this.scrollSelectorIntoView(null,event.paramObject.selector);
|
this.scrollSelectorIntoView(null,event.paramObject.selector,null,options);
|
||||||
} else {
|
} else {
|
||||||
this.scrollIntoView(event.target);
|
this.scrollIntoView(event.target,null,options);
|
||||||
}
|
}
|
||||||
return false; // Event was handled
|
return false; // Event was handled
|
||||||
}
|
}
|
||||||
@@ -62,10 +66,10 @@ PageScroller.prototype.handleEvent = function(event) {
|
|||||||
/*
|
/*
|
||||||
Handle a scroll event hitting the page document
|
Handle a scroll event hitting the page document
|
||||||
*/
|
*/
|
||||||
PageScroller.prototype.scrollIntoView = function(element,callback) {
|
PageScroller.prototype.scrollIntoView = function(element,callback,options) {
|
||||||
var self = this,
|
var self = this,
|
||||||
duration = $tw.utils.getAnimationDuration(),
|
duration = $tw.utils.hop(options,"animationDuration") ? parseInt(options.animationDuration) : $tw.utils.getAnimationDuration(),
|
||||||
srcWindow = element ? element.ownerDocument.defaultView : window;
|
srcWindow = element ? element.ownerDocument.defaultView : window;
|
||||||
// Now get ready to scroll the body
|
// Now get ready to scroll the body
|
||||||
this.cancelScroll(srcWindow);
|
this.cancelScroll(srcWindow);
|
||||||
this.startTime = Date.now();
|
this.startTime = Date.now();
|
||||||
@@ -122,11 +126,11 @@ PageScroller.prototype.scrollIntoView = function(element,callback) {
|
|||||||
drawFrame();
|
drawFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
PageScroller.prototype.scrollSelectorIntoView = function(baseElement,selector,callback) {
|
PageScroller.prototype.scrollSelectorIntoView = function(baseElement,selector,callback,options) {
|
||||||
baseElement = baseElement || document.body;
|
baseElement = baseElement || document.body;
|
||||||
var element = baseElement.querySelector(selector);
|
var element = baseElement.querySelector(selector);
|
||||||
if(element) {
|
if(element) {
|
||||||
this.scrollIntoView(element,callback);
|
this.scrollIntoView(element,callback,options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,7 @@ exports.getEditionInfo = function() {
|
|||||||
var entry = entries[entryIndex];
|
var entry = entries[entryIndex];
|
||||||
// Check if directories have a valid tiddlywiki.info
|
// Check if directories have a valid tiddlywiki.info
|
||||||
if(!editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
|
if(!editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
|
||||||
var info;
|
var info = $tw.utils.parseJSONSafe(fs.readFileSync(path.resolve(editionPath,entry,"tiddlywiki.info"),"utf8"),null);
|
||||||
try {
|
|
||||||
info = JSON.parse(fs.readFileSync(path.resolve(editionPath,entry,"tiddlywiki.info"),"utf8"));
|
|
||||||
} catch(ex) {
|
|
||||||
}
|
|
||||||
if(info) {
|
if(info) {
|
||||||
editionInfo[entry] = info;
|
editionInfo[entry] = info;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ Object.defineProperty(TW_Element.prototype, "innerHTML", {
|
|||||||
if(node instanceof TW_Element) {
|
if(node instanceof TW_Element) {
|
||||||
b.push(node.outerHTML);
|
b.push(node.outerHTML);
|
||||||
} else if(node instanceof TW_TextNode) {
|
} else if(node instanceof TW_TextNode) {
|
||||||
b.push($tw.utils.htmlEncode(node.textContent));
|
b.push($tw.utils.htmlTextEncode(node.textContent));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return b.join("");
|
return b.join("");
|
||||||
|
|||||||
@@ -95,6 +95,15 @@ LinkedList.prototype.toArray = function() {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LinkedList.prototype.makeTiddlerIterator = function(wiki) {
|
||||||
|
var self = this;
|
||||||
|
return function(callback) {
|
||||||
|
self.each(function(title) {
|
||||||
|
callback(wiki.getTiddler(title),title);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
function _removeOne(list,value) {
|
function _removeOne(list,value) {
|
||||||
var prevEntry = list.prev[value],
|
var prevEntry = list.prev[value],
|
||||||
nextEntry = list.next[value],
|
nextEntry = list.next[value],
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ exports.repackPlugin = function(title,additionalTiddlers,excludeTiddlers) {
|
|||||||
throw "No such tiddler as " + title;
|
throw "No such tiddler as " + title;
|
||||||
}
|
}
|
||||||
// Extract the JSON
|
// Extract the JSON
|
||||||
var jsonPluginTiddler;
|
var jsonPluginTiddler = $tw.utils.parseJSONSafe(pluginTiddler.fields.text,null);
|
||||||
try {
|
if(!jsonPluginTiddler) {
|
||||||
jsonPluginTiddler = JSON.parse(pluginTiddler.fields.text);
|
|
||||||
} catch(e) {
|
|
||||||
throw "Cannot parse plugin tiddler " + title + "\n" + $tw.language.getString("Error/Caption") + ": " + e;
|
throw "Cannot parse plugin tiddler " + title + "\n" + $tw.language.getString("Error/Caption") + ": " + e;
|
||||||
}
|
}
|
||||||
// Get the list of tiddlers
|
// Get the list of tiddlers
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ exports.transliterationPairs = {
|
|||||||
"Nj":"N",
|
"Nj":"N",
|
||||||
"Ñ":"N",
|
"Ñ":"N",
|
||||||
"NJ":"NJ",
|
"NJ":"NJ",
|
||||||
|
"ð":"d",
|
||||||
|
"Ð":"D",
|
||||||
"Ó":"O",
|
"Ó":"O",
|
||||||
"Ŏ":"O",
|
"Ŏ":"O",
|
||||||
"Ǒ":"O",
|
"Ǒ":"O",
|
||||||
@@ -265,6 +267,8 @@ exports.transliterationPairs = {
|
|||||||
"Ɽ":"R",
|
"Ɽ":"R",
|
||||||
"Ꜿ":"C",
|
"Ꜿ":"C",
|
||||||
"Ǝ":"E",
|
"Ǝ":"E",
|
||||||
|
"ß":"ss",
|
||||||
|
"ẞ":"SS",
|
||||||
"Ś":"S",
|
"Ś":"S",
|
||||||
"Ṥ":"S",
|
"Ṥ":"S",
|
||||||
"Š":"S",
|
"Š":"S",
|
||||||
@@ -275,6 +279,8 @@ exports.transliterationPairs = {
|
|||||||
"Ṡ":"S",
|
"Ṡ":"S",
|
||||||
"Ṣ":"S",
|
"Ṣ":"S",
|
||||||
"Ṩ":"S",
|
"Ṩ":"S",
|
||||||
|
"þ": "th",
|
||||||
|
"Þ": "TH",
|
||||||
"Ť":"T",
|
"Ť":"T",
|
||||||
"Ţ":"T",
|
"Ţ":"T",
|
||||||
"Ṱ":"T",
|
"Ṱ":"T",
|
||||||
@@ -907,7 +913,8 @@ exports.transliterationPairs = {
|
|||||||
"т":"t",
|
"т":"t",
|
||||||
"ь":"'",
|
"ь":"'",
|
||||||
"б":"b",
|
"б":"b",
|
||||||
"ю":"yu"
|
"ю":"yu",
|
||||||
|
"…":"..."
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.transliterate = function(str) {
|
exports.transliterate = function(str) {
|
||||||
|
|||||||
@@ -383,6 +383,15 @@ exports.formatDateString = function(date,template) {
|
|||||||
[/^0WW/, function() {
|
[/^0WW/, function() {
|
||||||
return $tw.utils.pad($tw.utils.getWeek(date));
|
return $tw.utils.pad($tw.utils.getWeek(date));
|
||||||
}],
|
}],
|
||||||
|
[/^0ddddd/, function() {
|
||||||
|
return $tw.utils.pad(Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24),3);
|
||||||
|
}],
|
||||||
|
[/^ddddd/, function() {
|
||||||
|
return Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);
|
||||||
|
}],
|
||||||
|
[/^dddd/, function() {
|
||||||
|
return [7,1,2,3,4,5,6][date.getDay()];
|
||||||
|
}],
|
||||||
[/^ddd/, function() {
|
[/^ddd/, function() {
|
||||||
return $tw.language.getString("Date/Short/Day/" + date.getDay());
|
return $tw.language.getString("Date/Short/Day/" + date.getDay());
|
||||||
}],
|
}],
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Invoke the action associated with this widget
|
|||||||
ConfirmWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
ConfirmWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||||
var invokeActions = true,
|
var invokeActions = true,
|
||||||
handled = true,
|
handled = true,
|
||||||
win = event.event && event.event.view ? event.event.view : window;
|
win = event && event.event && event.event.view ? event.event.view : window;
|
||||||
if(this.prompt) {
|
if(this.prompt) {
|
||||||
invokeActions = win.confirm(this.message);
|
invokeActions = win.confirm(this.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ ActionListopsWidget.prototype.invokeAction = function(triggeringWidget,
|
|||||||
}
|
}
|
||||||
if(this.subfilter) {
|
if(this.subfilter) {
|
||||||
var inputList = this.wiki.getTiddlerList(this.target,field,index),
|
var inputList = this.wiki.getTiddlerList(this.target,field,index),
|
||||||
subfilter = $tw.utils.stringifyList(inputList) + " " + this.subfilter;
|
subfilter = "[all[]] " + this.subfilter;
|
||||||
this.wiki.setText(this.target, field, index, $tw.utils.stringifyList(this.wiki.filterTiddlers(subfilter,this)));
|
this.wiki.setText(this.target, field, index, $tw.utils.stringifyList(this.wiki.filterTiddlers(subfilter,this,this.wiki.makeTiddlerIterator(inputList))));
|
||||||
}
|
}
|
||||||
if(this.filtertags) {
|
if(this.filtertags) {
|
||||||
var tiddler = this.wiki.getTiddler(this.target),
|
var tiddler = this.wiki.getTiddler(this.target),
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user