mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-27 09:33:08 +00:00
Compare commits
1976 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ede3d7cf3 | ||
|
|
e56b2a7ce5 | ||
|
|
ad8e004fa9 | ||
|
|
e05d2e805c | ||
|
|
a083999943 | ||
|
|
247bc719b8 | ||
|
|
cd01014d79 | ||
|
|
7ab1efb0c9 | ||
|
|
eb05ac00a6 | ||
|
|
2bc39a468f | ||
|
|
c735ab7c35 | ||
|
|
d5e367649e | ||
|
|
f10444f14a | ||
|
|
29d4003bd2 | ||
|
|
1225e5cb6a | ||
|
|
aab24c732e | ||
|
|
d7d690a9d1 | ||
|
|
4f39222724 | ||
|
|
a1e585ccaa | ||
|
|
373a627c14 | ||
|
|
a7cb73b02e | ||
|
|
cd3e517b03 | ||
|
|
ef201409d9 | ||
|
|
e3ef93f03a | ||
|
|
1990064be4 | ||
|
|
44099c813c | ||
|
|
56185e2a1c | ||
|
|
590318ff1d | ||
|
|
48a5a70d2e | ||
|
|
1c1901c90a | ||
|
|
ebae351033 | ||
|
|
e54d81ceef | ||
|
|
849da23829 | ||
|
|
1e36e63ed6 | ||
|
|
abb2d57879 | ||
|
|
52779eec35 | ||
|
|
9e694e5e46 | ||
|
|
321b8a0696 | ||
|
|
f2563e436f | ||
|
|
3c6f49aa0a | ||
|
|
9bc5701006 | ||
|
|
a3a5f749ab | ||
|
|
36b026d89e | ||
|
|
dbd4a5c490 | ||
|
|
0d95c48988 | ||
|
|
0d40f4eb16 | ||
|
|
6234943ffd | ||
|
|
702f55bdbd | ||
|
|
859117cdf8 | ||
|
|
7474605b93 | ||
|
|
00a83ec16e | ||
|
|
afa1e7974a | ||
|
|
1517c00132 | ||
|
|
6d24908465 | ||
|
|
fd2d1f1ce2 | ||
|
|
226ad49663 | ||
|
|
e830c51a16 | ||
|
|
b6e904c9c8 | ||
|
|
3fc2e5202e | ||
|
|
f0b447866c | ||
|
|
c528c8639a | ||
|
|
47d8bb20d2 | ||
|
|
bb08aed1a8 | ||
|
|
9a2f18fc0d | ||
|
|
df21f978df | ||
|
|
fb8c4c5c44 | ||
|
|
19102db23a | ||
|
|
8d2a9ed9cb | ||
|
|
a0010c9c84 | ||
|
|
f7c3e81b7b | ||
|
|
c7f695e86a | ||
|
|
e6e220fbec | ||
|
|
8658a6a97a | ||
|
|
cd94857b13 | ||
|
|
3825bcbbfb | ||
|
|
981e7986ce | ||
|
|
89583528c2 | ||
|
|
e588e68313 | ||
|
|
e4c2ffe973 | ||
|
|
c41116e6c8 | ||
|
|
b66ac43b35 | ||
|
|
c30404804d | ||
|
|
6b10e1aacb | ||
|
|
e6185879c8 | ||
|
|
e776e5e054 | ||
|
|
04bbb3d615 | ||
|
|
5d1f589b07 | ||
|
|
ce5f093945 | ||
|
|
371e464eb2 | ||
|
|
804d714473 | ||
|
|
8d00389aa2 | ||
|
|
d64787168b | ||
|
|
49a1a74263 | ||
|
|
2636635397 | ||
|
|
c49c620ce1 | ||
|
|
0b00162590 | ||
|
|
5e19bdaee7 | ||
|
|
bda8be6ec1 | ||
|
|
132a7d1f53 | ||
|
|
2dbb92a37e | ||
|
|
a124bd8657 | ||
|
|
5323e6ca7a | ||
|
|
8423c48fd1 | ||
|
|
e8aceac133 | ||
|
|
5a692a74c5 | ||
|
|
6436e62ec0 | ||
|
|
c9947d7f91 | ||
|
|
3b3127248b | ||
|
|
1d2355e802 | ||
|
|
b85bb7bdd4 | ||
|
|
a016bfd133 | ||
|
|
63fa747fd7 | ||
|
|
a7ddeafd06 | ||
|
|
81e6cae99d | ||
|
|
be0db1770d | ||
|
|
f905a62b6c | ||
|
|
35ca31cf43 | ||
|
|
0ce3ac9be2 | ||
|
|
7cdf1c93cf | ||
|
|
a7c4b78ec8 | ||
|
|
aa321fe2c3 | ||
|
|
7bc0af9a8c | ||
|
|
69475833e6 | ||
|
|
7dce3b3de5 | ||
|
|
183687d676 | ||
|
|
786acc7a1c | ||
|
|
3d3ad3f284 | ||
|
|
a6a1d70abc | ||
|
|
73461d6372 | ||
|
|
e56c6a5085 | ||
|
|
f8f0280f8c | ||
|
|
4e393779ac | ||
|
|
5671728c97 | ||
|
|
e06611a90f | ||
|
|
7b767368df | ||
|
|
d59c6be359 | ||
|
|
0d564dd0bf | ||
|
|
ef6e1e1782 | ||
|
|
b2f5e39256 | ||
|
|
762de62aa6 | ||
|
|
d4d27aab6a | ||
|
|
1803c89a23 | ||
|
|
4b0b56dd35 | ||
|
|
bf6eae7b3c | ||
|
|
3377d6645d | ||
|
|
5069eadd0a | ||
|
|
7a5b0b32c4 | ||
|
|
35a0a12f16 | ||
|
|
504bb78a8d | ||
|
|
94ae33d328 | ||
|
|
690c683943 | ||
|
|
3acf90dfdb | ||
|
|
6bb5d04f07 | ||
|
|
b0b1f7fd0b | ||
|
|
c25bf95a66 | ||
|
|
370c480670 | ||
|
|
a351013359 | ||
|
|
1f86b4c3d0 | ||
|
|
627a6a732b | ||
|
|
77421c2950 | ||
|
|
f3ed174b0e | ||
|
|
977d0ea73a | ||
|
|
04effa2150 | ||
|
|
7f694e6ca7 | ||
|
|
769a03916b | ||
|
|
e3c90a8295 | ||
|
|
561ff6283a | ||
|
|
5e69718f4f | ||
|
|
ca5a7a1dbb | ||
|
|
505ac0c1d5 | ||
|
|
987d1c881b | ||
|
|
f34107ee1d | ||
|
|
2246944dd2 | ||
|
|
717ced28d6 | ||
|
|
fb836df8d5 | ||
|
|
fba08262d3 | ||
|
|
56582b6b24 | ||
|
|
43e4e43c7c | ||
|
|
3f3f113305 | ||
|
|
96e23ee2ea | ||
|
|
c57c9e236b | ||
|
|
32c6224f40 | ||
|
|
8dadc57934 | ||
|
|
0dc9e9ecdb | ||
|
|
977b871967 | ||
|
|
4fa8351f7f | ||
|
|
fa669f32fc | ||
|
|
fc294807fd | ||
|
|
a9fe516675 | ||
|
|
6502847b95 | ||
|
|
90dd4326e7 | ||
|
|
eeedc5f7d4 | ||
|
|
fff357d08b | ||
|
|
e0b69dce14 | ||
|
|
e6c5e6451c | ||
|
|
26866c337f | ||
|
|
4c71987866 | ||
|
|
8965bb60aa | ||
|
|
64fb032622 | ||
|
|
073076e011 | ||
|
|
71b505d55b | ||
|
|
dc7d877e6f | ||
|
|
40ab2c2283 | ||
|
|
d8f0618691 | ||
|
|
955b34b637 | ||
|
|
8dea2ca9fb | ||
|
|
696bcd4367 | ||
|
|
d70c5a6fe3 | ||
|
|
645c9a122c | ||
|
|
b774c89bdb | ||
|
|
c75ebb36cb | ||
|
|
1c03138968 | ||
|
|
1313772adc | ||
|
|
fb06ae0d03 | ||
|
|
e952e05b79 | ||
|
|
c020297d78 | ||
|
|
8ea7d3dc8f | ||
|
|
051eed0e83 | ||
|
|
cdc2ffeff4 | ||
|
|
dedf9e0be9 | ||
|
|
0cc001fe94 | ||
|
|
0f969ce383 | ||
|
|
83244485ab | ||
|
|
defbc716c0 | ||
|
|
1803dfdeb1 | ||
|
|
787d50f17c | ||
|
|
925d934892 | ||
|
|
e45bcf76ce | ||
|
|
54d5dbf992 | ||
|
|
bb18ed7eda | ||
|
|
f8895721fc | ||
|
|
ba340f033a | ||
|
|
4c30a8f6a3 | ||
|
|
cbcb712587 | ||
|
|
187b6a9e8a | ||
|
|
2816a39ff9 | ||
|
|
9203cc2a6a | ||
|
|
9e19ba2d4e | ||
|
|
a706c9ff9b | ||
|
|
4957a0d2ef | ||
|
|
727f2bd80e | ||
|
|
11790fa438 | ||
|
|
c4049ec5fa | ||
|
|
02fca27f85 | ||
|
|
7f717b92fd | ||
|
|
e2272b078b | ||
|
|
01161752c6 | ||
|
|
3237a4f2eb | ||
|
|
d87e07e9ba | ||
|
|
82529e0b06 | ||
|
|
641303d1ad | ||
|
|
845c2eca76 | ||
|
|
e957f40775 | ||
|
|
3985afade9 | ||
|
|
f5ee55d0ca | ||
|
|
2cf73698e8 | ||
|
|
28a06348ab | ||
|
|
9510b4d097 | ||
|
|
37c8ea4fd7 | ||
|
|
9adc3e2e1a | ||
|
|
fd00a9f81d | ||
|
|
720e43e9d9 | ||
|
|
176977dd2a | ||
|
|
a42b867bcb | ||
|
|
1196a1577f | ||
|
|
54b11b1a4c | ||
|
|
7fa9b3cdd2 | ||
|
|
2f42c3f857 | ||
|
|
67e868b5ee | ||
|
|
3a81521e6f | ||
|
|
a30608a8ae | ||
|
|
6a129aebdb | ||
|
|
184f182b3a | ||
|
|
05dd5e4c04 | ||
|
|
499c640a11 | ||
|
|
5a11b7918e | ||
|
|
36ab6923ed | ||
|
|
7cc967ad49 | ||
|
|
d108088295 | ||
|
|
8be3154865 | ||
|
|
9aa7c67c5b | ||
|
|
5a84c0aaa7 | ||
|
|
4a6418a475 | ||
|
|
efb4c67e2a | ||
|
|
b325779466 | ||
|
|
0d475ab035 | ||
|
|
c791c0f60b | ||
|
|
f204b0ebc0 | ||
|
|
adab8449e0 | ||
|
|
fc96f6bf95 | ||
|
|
9924c6049e | ||
|
|
21e9251043 | ||
|
|
19e6d94419 | ||
|
|
232f28b5b4 | ||
|
|
6af5abd37d | ||
|
|
e0e49c606f | ||
|
|
e9e49e39fb | ||
|
|
ee4eb19f1e | ||
|
|
cc9edcc67c | ||
|
|
032fcf12e0 | ||
|
|
174024b472 | ||
|
|
8a8cd3fb18 | ||
|
|
dff0a7ae77 | ||
|
|
014482b3d5 | ||
|
|
ce7a98f974 | ||
|
|
5ee4ada112 | ||
|
|
f0765b5aaa | ||
|
|
9dde4aa94e | ||
|
|
1452920fbd | ||
|
|
81a098b6cf | ||
|
|
c6f87eded0 | ||
|
|
aa2fe3ef97 | ||
|
|
31fcf28e3f | ||
|
|
aa945c4177 | ||
|
|
52faa366ca | ||
|
|
fc6930c868 | ||
|
|
1ed7e43db1 | ||
|
|
6ec51bf725 | ||
|
|
ae336f1429 | ||
|
|
5847b246ef | ||
|
|
38168131e7 | ||
|
|
00e113ff67 | ||
|
|
62b96f4e79 | ||
|
|
136e877ee6 | ||
|
|
8faae1e645 | ||
|
|
e4852b7077 | ||
|
|
2ba42def09 | ||
|
|
337d3567fc | ||
|
|
3dc8eec1e6 | ||
|
|
fac2293b77 | ||
|
|
7d699e455e | ||
|
|
cbc6dcdc35 | ||
|
|
5894dc5a7a | ||
|
|
284bfe565b | ||
|
|
e03b540788 | ||
|
|
2dc4ebb39f | ||
|
|
59672b79d8 | ||
|
|
59717fe630 | ||
|
|
3f9c7a1794 | ||
|
|
ca1f2dd1c3 | ||
|
|
a8e6f5cf26 | ||
|
|
f3a774d55c | ||
|
|
834980890a | ||
|
|
969eb354ce | ||
|
|
075c8805e0 | ||
|
|
5c4187cd06 | ||
|
|
1719cc68fa | ||
|
|
3ba67fb3d0 | ||
|
|
f58d52c4b6 | ||
|
|
9288ead130 | ||
|
|
a8a4930225 | ||
|
|
e1ad6f8114 | ||
|
|
22257a95e0 | ||
|
|
713c978f08 | ||
|
|
3eb0c7acfe | ||
|
|
c3e6c01ec1 | ||
|
|
190bce519f | ||
|
|
5bb5cdec05 | ||
|
|
f8e68c1485 | ||
|
|
60ccd08bce | ||
|
|
f241024167 | ||
|
|
f1fd75574d | ||
|
|
31352e417f | ||
|
|
643af98ca3 | ||
|
|
3b61cd355f | ||
|
|
8df19e3b8f | ||
|
|
91d6548822 | ||
|
|
ef797b2a69 | ||
|
|
33a62a0ac7 | ||
|
|
5a9025f555 | ||
|
|
0a494633bb | ||
|
|
aeaea5b5e0 | ||
|
|
e03ec34104 | ||
|
|
c65ee59998 | ||
|
|
4d59a14f74 | ||
|
|
3c8aaa7465 | ||
|
|
ac70403203 | ||
|
|
a5e7ad882d | ||
|
|
061925e89a | ||
|
|
5fc8b508d1 | ||
|
|
cb444bef9d | ||
|
|
481f2e7d39 | ||
|
|
7559652a32 | ||
|
|
8e15466063 | ||
|
|
8ef319d2cd | ||
|
|
1513a983f7 | ||
|
|
1b71bbaefb | ||
|
|
fcd5279381 | ||
|
|
4276d38152 | ||
|
|
6f4604c8a9 | ||
|
|
13fa06ec1f | ||
|
|
d6bf2dec7e | ||
|
|
423a4a521a | ||
|
|
05d4d5b1ff | ||
|
|
ad1e8d50d7 | ||
|
|
c926f0de79 | ||
|
|
4337c67f69 | ||
|
|
bb06a3e4d4 | ||
|
|
6af9c9e432 | ||
|
|
84d0d15c5a | ||
|
|
b185fe8e35 | ||
|
|
adbb9e54c1 | ||
|
|
1d3c2d7cd6 | ||
|
|
2dc397e9f1 | ||
|
|
6465564b6f | ||
|
|
e1fe640e92 | ||
|
|
6f99fe7455 | ||
|
|
4b3b44ecc8 | ||
|
|
129e18da0f | ||
|
|
2bc7cda8c9 | ||
|
|
342963dae6 | ||
|
|
957b1ed9e7 | ||
|
|
31b3bd1ace | ||
|
|
f1ab332ce0 | ||
|
|
d50f23354a | ||
|
|
662a2d776a | ||
|
|
80f07bf0b0 | ||
|
|
6cf2dd8186 | ||
|
|
5de20cb451 | ||
|
|
423ed28fbd | ||
|
|
a4f17259e1 | ||
|
|
c2678e5f2c | ||
|
|
d797333b97 | ||
|
|
40777a3794 | ||
|
|
ac1005c2b0 | ||
|
|
c77395149b | ||
|
|
fb0580fff1 | ||
|
|
0e953d08b2 | ||
|
|
7fce362a52 | ||
|
|
3e7844ba6d | ||
|
|
7619f8f420 | ||
|
|
bac52f8376 | ||
|
|
5c72cd9d47 | ||
|
|
89b59a52bc | ||
|
|
a6f2a1a4c8 | ||
|
|
e9e9fbe21c | ||
|
|
e7108947d6 | ||
|
|
8b68f24135 | ||
|
|
e32ae9a792 | ||
|
|
758a951bf5 | ||
|
|
21ac50cd27 | ||
|
|
fc67a40167 | ||
|
|
7949df1865 | ||
|
|
8ed013cbb2 | ||
|
|
0138c27863 | ||
|
|
7930c209ff | ||
|
|
26fdc1ba91 | ||
|
|
8681994747 | ||
|
|
0e684b14a7 | ||
|
|
974f84d49f | ||
|
|
5a6abef4fb | ||
|
|
15200e0c6e | ||
|
|
79c22f383f | ||
|
|
915f9aafa8 | ||
|
|
aa0d0bed48 | ||
|
|
11f8809c5e | ||
|
|
27a4831ea0 | ||
|
|
1abced20d6 | ||
|
|
251d03b7be | ||
|
|
c92f30cfe0 | ||
|
|
2a8e4b2a63 | ||
|
|
51c7549b45 | ||
|
|
ea5170e6a6 | ||
|
|
29bbf3fef9 | ||
|
|
a7f8b52966 | ||
|
|
6629bc64d8 | ||
|
|
bfd46fb6fd | ||
|
|
2d335ef7fc | ||
|
|
fac0d151b6 | ||
|
|
4f950b6024 | ||
|
|
1c1d331df9 | ||
|
|
8609925da8 | ||
|
|
607244d6e1 | ||
|
|
9cc81d2ff9 | ||
|
|
32fa50d608 | ||
|
|
8221579b6a | ||
|
|
88eaebfd49 | ||
|
|
ee9f2c8c83 | ||
|
|
2870caaae6 | ||
|
|
e0425ec6c0 | ||
|
|
8aa88a2e45 | ||
|
|
cef90f5ff9 | ||
|
|
5a9b77190a | ||
|
|
59a5f641af | ||
|
|
edec9369ec | ||
|
|
f2d933410e | ||
|
|
0bda666127 | ||
|
|
5b96ef4406 | ||
|
|
af5bbdc677 | ||
|
|
b64a0c5200 | ||
|
|
113f9b3fe3 | ||
|
|
2c4f4ff5fc | ||
|
|
c1dc712542 | ||
|
|
3e2c2de269 | ||
|
|
cc08579583 | ||
|
|
d2afa7adea | ||
|
|
e562ebef48 | ||
|
|
e206b501a6 | ||
|
|
016a9fa1e8 | ||
|
|
01ee184044 | ||
|
|
8e7baca47d | ||
|
|
ddc5693778 | ||
|
|
82f73fb21d | ||
|
|
27c52fc244 | ||
|
|
ac82e3ecb2 | ||
|
|
22b6aa14f0 | ||
|
|
24ab3d3392 | ||
|
|
0b01f27d11 | ||
|
|
d640ad6bb7 | ||
|
|
fd91bf0fff | ||
|
|
270aa9e0f9 | ||
|
|
6ae249a527 | ||
|
|
c0123b96eb | ||
|
|
45f7080afd | ||
|
|
2af2ad629d | ||
|
|
2fc7aa454f | ||
|
|
ddf2006285 | ||
|
|
fde797c044 | ||
|
|
6693fb1c13 | ||
|
|
17f8de48a8 | ||
|
|
0a5ff213de | ||
|
|
aebfcc7885 | ||
|
|
2c4f3473e5 | ||
|
|
9a4cc5f63e | ||
|
|
c82b62f953 | ||
|
|
f364f054f8 | ||
|
|
460358ce1f | ||
|
|
0448f15322 | ||
|
|
d741878f78 | ||
|
|
f830104531 | ||
|
|
d22cd88446 | ||
|
|
1444581c86 | ||
|
|
dfbd85a8ce | ||
|
|
af5434c9b7 | ||
|
|
484b0a6dff | ||
|
|
4951b9bf1a | ||
|
|
62c619de24 | ||
|
|
44c96aad04 | ||
|
|
f392216ff4 | ||
|
|
591cae0e8f | ||
|
|
e222811d03 | ||
|
|
c9b885f868 | ||
|
|
fed65f5430 | ||
|
|
47f912750b | ||
|
|
f29a5e346e | ||
|
|
ee381c91fe | ||
|
|
5f8d46f1b6 | ||
|
|
ade819c70c | ||
|
|
c209a86f90 | ||
|
|
4fe38e3929 | ||
|
|
b6d69173cd | ||
|
|
8b085e1806 | ||
|
|
cb9d24d5b4 | ||
|
|
23fd70e3c3 | ||
|
|
2fa3c0f311 | ||
|
|
5c0a072115 | ||
|
|
29c2274a19 | ||
|
|
a6f787ea8f | ||
|
|
24c86dd199 | ||
|
|
7eb96ee6be | ||
|
|
27aebf0e3b | ||
|
|
88578a3d16 | ||
|
|
28446d3ae2 | ||
|
|
a247e50c9f | ||
|
|
656edb07ea | ||
|
|
0cf79ceeb1 | ||
|
|
7b9bd70554 | ||
|
|
4b05bcac69 | ||
|
|
1555535f2e | ||
|
|
a413dc8d4f | ||
|
|
74ee09397e | ||
|
|
a06aa2a103 | ||
|
|
ea6595d4d6 | ||
|
|
5b02132e57 | ||
|
|
f8841c068f | ||
|
|
da1d08f8a9 | ||
|
|
0a199e750f | ||
|
|
5433cda52f | ||
|
|
9c4de58161 | ||
|
|
1b96dae27f | ||
|
|
16ca52756d | ||
|
|
645da7ae5f | ||
|
|
8570335d79 | ||
|
|
1564bc7448 | ||
|
|
8e20d3ba10 | ||
|
|
450baee66a | ||
|
|
4b588786c4 | ||
|
|
e07a04ebfa | ||
|
|
f707752c26 | ||
|
|
80e039b194 | ||
|
|
c888df28aa | ||
|
|
94cc1c642c | ||
|
|
9a02a351fa | ||
|
|
e8e7237a8e | ||
|
|
086c4f74f6 | ||
|
|
e987da498b | ||
|
|
d12f644f5b | ||
|
|
e4bde91f6a | ||
|
|
3eb071fbdc | ||
|
|
81e17b420c | ||
|
|
e8ccd094e8 | ||
|
|
7c60fbe655 | ||
|
|
2d570924d1 | ||
|
|
8ee70b0928 | ||
|
|
2cdd65b083 | ||
|
|
758a06e58a | ||
|
|
a87e420437 | ||
|
|
46085c8d44 | ||
|
|
179e21755c | ||
|
|
e9ca68e7d3 | ||
|
|
9886200fa9 | ||
|
|
9a1070bb06 | ||
|
|
853f048812 | ||
|
|
4564066c63 | ||
|
|
eb99acc95b | ||
|
|
ba76c51da7 | ||
|
|
435fb6ecfe | ||
|
|
8a10fac81e | ||
|
|
7f1949a7f4 | ||
|
|
060f28a0a6 | ||
|
|
a3f146cd53 | ||
|
|
47b56398b1 | ||
|
|
2ea2f41bd0 | ||
|
|
3b8dbe8a04 | ||
|
|
7a349ae26d | ||
|
|
0945a5e47e | ||
|
|
5232c16eb2 | ||
|
|
bdfd194672 | ||
|
|
cb0cb32860 | ||
|
|
1e080b30fd | ||
|
|
cba57d1033 | ||
|
|
1bece09339 | ||
|
|
90431efbc9 | ||
|
|
99b0c2b54e | ||
|
|
042e217872 | ||
|
|
65d6eb11dd | ||
|
|
a591763d10 | ||
|
|
62bf982a73 | ||
|
|
6294b12ad5 | ||
|
|
68f95f6130 | ||
|
|
35ae5e09ee | ||
|
|
552a23585b | ||
|
|
e635877b66 | ||
|
|
954bcbdaf6 | ||
|
|
559de2527b | ||
|
|
4c14774f1a | ||
|
|
ea380ae6a9 | ||
|
|
e2a946674f | ||
|
|
75926e34a2 | ||
|
|
37bc37bd94 | ||
|
|
528359dd9f | ||
|
|
f745fdefb3 | ||
|
|
2d9b80a81e | ||
|
|
299acfb92c | ||
|
|
8fc97493c5 | ||
|
|
7c7c6341f9 | ||
|
|
227ab192c4 | ||
|
|
ad48c0cd76 | ||
|
|
958b168906 | ||
|
|
51d4b5042c | ||
|
|
371ac9680c | ||
|
|
f68af555de | ||
|
|
66fdf808a6 | ||
|
|
65770782c2 | ||
|
|
fdf6acd80a | ||
|
|
08b61a6bb4 | ||
|
|
33c2bee873 | ||
|
|
8bbf2e1ce4 | ||
|
|
476002ae4d | ||
|
|
54ec1b8827 | ||
|
|
7bb92bc790 | ||
|
|
a87d62c9c2 | ||
|
|
8c315980e9 | ||
|
|
359a64968c | ||
|
|
866548deec | ||
|
|
ed39852a8f | ||
|
|
38fc647495 | ||
|
|
fa7b3ea2a0 | ||
|
|
9e041d26bd | ||
|
|
978c0c4c7b | ||
|
|
4f4cef0f6c | ||
|
|
556ded9b08 | ||
|
|
b7f88d53d0 | ||
|
|
cb8d98266c | ||
|
|
c918a79957 | ||
|
|
0efcd5d258 | ||
|
|
31b6e0c4f6 | ||
|
|
423413e41b | ||
|
|
ec514cdb51 | ||
|
|
7272544724 | ||
|
|
99ff7fdf14 | ||
|
|
491b38c330 | ||
|
|
4033d3ad99 | ||
|
|
9285d355b2 | ||
|
|
24e67e2270 | ||
|
|
5f6d5f53cc | ||
|
|
865c5678bc | ||
|
|
05ba7b41d1 | ||
|
|
e7735e242a | ||
|
|
1111d8275c | ||
|
|
f3b01bc75c | ||
|
|
8685c5cae4 | ||
|
|
e0a457bf40 | ||
|
|
a48d9d295e | ||
|
|
a5f453f1e5 | ||
|
|
c2170dd558 | ||
|
|
0c9958f461 | ||
|
|
e2a3959feb | ||
|
|
202ea1d905 | ||
|
|
e3c1e4b6f0 | ||
|
|
d20c9c502c | ||
|
|
8c5e68e571 | ||
|
|
fbe65a4e93 | ||
|
|
3875dabfd2 | ||
|
|
6464f35ce9 | ||
|
|
5442f232d5 | ||
|
|
930709223a | ||
|
|
a6ce36689c | ||
|
|
2424d34682 | ||
|
|
3fad8227a7 | ||
|
|
2d051fcdc0 | ||
|
|
95d7ce2876 | ||
|
|
1a52acd4a9 | ||
|
|
de8194d7e0 | ||
|
|
c60ddb701c | ||
|
|
0e00460012 | ||
|
|
ed92628012 | ||
|
|
12de8c5221 | ||
|
|
afa0571382 | ||
|
|
75c592b437 | ||
|
|
000c3db8cd | ||
|
|
f23c0bccbc | ||
|
|
69db1e2cb7 | ||
|
|
933dc372d2 | ||
|
|
176766dfe7 | ||
|
|
6fb185a964 | ||
|
|
1442414299 | ||
|
|
f6161abf52 | ||
|
|
8fc224e9a1 | ||
|
|
98fc007efd | ||
|
|
7fb23c7362 | ||
|
|
a2f0546a6d | ||
|
|
8a55658bd7 | ||
|
|
01d60c4520 | ||
|
|
b4349a0476 | ||
|
|
695b9916dd | ||
|
|
4543881808 | ||
|
|
ac3168e365 | ||
|
|
e396211f92 | ||
|
|
4ce68b86ed | ||
|
|
24769d69d4 | ||
|
|
609f5a3330 | ||
|
|
058d70ed82 | ||
|
|
cbdf06f39d | ||
|
|
6f6c142aa2 | ||
|
|
72cb8e7db9 | ||
|
|
fc22e6cd53 | ||
|
|
62ed026757 | ||
|
|
7cef4316d7 | ||
|
|
0df53daa4c | ||
|
|
b496ef3597 | ||
|
|
3ae5d4c1e3 | ||
|
|
a227a792c0 | ||
|
|
133295c225 | ||
|
|
54efc18ad4 | ||
|
|
43f77dc525 | ||
|
|
d9d4d74b71 | ||
|
|
af82d71e4f | ||
|
|
f897cbfdf4 | ||
|
|
1773e77cb9 | ||
|
|
34d37b24f1 | ||
|
|
1e6427ca56 | ||
|
|
b9152867b8 | ||
|
|
879a1f5a57 | ||
|
|
0f9ba1a5ae | ||
|
|
d96d3c501e | ||
|
|
215888baf4 | ||
|
|
d56ea62b5e | ||
|
|
888cf55b3d | ||
|
|
4d7b1864d9 | ||
|
|
319746f6cd | ||
|
|
dcd34ccdaf | ||
|
|
2453b623db | ||
|
|
8fd165a79b | ||
|
|
783e88b5e6 | ||
|
|
77c0af42d0 | ||
|
|
c21b4eb2d6 | ||
|
|
6043af81e4 | ||
|
|
7c3321b62f | ||
|
|
d1955951e4 | ||
|
|
e62e185214 | ||
|
|
0c38415372 | ||
|
|
73f879aa63 | ||
|
|
f12de7d953 | ||
|
|
933ac41774 | ||
|
|
54b4d490f1 | ||
|
|
193af61725 | ||
|
|
ecfdada810 | ||
|
|
68c3e1ba84 | ||
|
|
efda06ebe5 | ||
|
|
e9b85e1a9a | ||
|
|
f9d19c75b2 | ||
|
|
bc9ab284d8 | ||
|
|
eb809ca375 | ||
|
|
54d2709d6a | ||
|
|
916bd5f4d6 | ||
|
|
511c9ffada | ||
|
|
ea03538552 | ||
|
|
8fb9f3f823 | ||
|
|
7af919afd3 | ||
|
|
5bbe4016d6 | ||
|
|
0f3312a5d7 | ||
|
|
0bf432dd76 | ||
|
|
27b3da0144 | ||
|
|
21244fba58 | ||
|
|
55dd4efe41 | ||
|
|
40c8b04a98 | ||
|
|
c0cc27a750 | ||
|
|
6e08fcca80 | ||
|
|
b8b1b9660f | ||
|
|
3d0a9ea805 | ||
|
|
a711f8eb89 | ||
|
|
9b0db15083 | ||
|
|
c6f62142e1 | ||
|
|
f40d851d49 | ||
|
|
b64c835706 | ||
|
|
b7717171b3 | ||
|
|
92e27cda6c | ||
|
|
aef6605225 | ||
|
|
7c9cc25923 | ||
|
|
78ce8aa6e3 | ||
|
|
8ae22bdc27 | ||
|
|
46c14ef23b | ||
|
|
d3080c03a4 | ||
|
|
12eead3379 | ||
|
|
a2e065c5d8 | ||
|
|
0d1a3d55cf | ||
|
|
b748a597d2 | ||
|
|
5fb0e123e3 | ||
|
|
9a4a14fa97 | ||
|
|
0c76a546e4 | ||
|
|
fb299f898e | ||
|
|
97ef56f905 | ||
|
|
124af97cc8 | ||
|
|
021ac68400 | ||
|
|
4b10686336 | ||
|
|
153812c6e5 | ||
|
|
9aa3ebe872 | ||
|
|
e23166e1d5 | ||
|
|
69f01b282a | ||
|
|
66e39d9c65 | ||
|
|
8c5f4e0605 | ||
|
|
a89b575b26 | ||
|
|
ed210da4af | ||
|
|
afb5ccec81 | ||
|
|
c0beae6e46 | ||
|
|
9c6ece3e7f | ||
|
|
5494c02f00 | ||
|
|
b4ee62a1bd | ||
|
|
b6c2f96b82 | ||
|
|
632efe8b9f | ||
|
|
bf38f95d25 | ||
|
|
f6daeb4acd | ||
|
|
10a7f34abb | ||
|
|
3a054f1ae0 | ||
|
|
25b4b3d906 | ||
|
|
5eeac603db | ||
|
|
f21d636846 | ||
|
|
8365841b89 | ||
|
|
e6bf8b59a1 | ||
|
|
b4a4934c5c | ||
|
|
a6b2dab9cc | ||
|
|
d692e88b96 | ||
|
|
62c9e081e6 | ||
|
|
6f7a657b59 | ||
|
|
65495b4e7c | ||
|
|
5a52e76ff0 | ||
|
|
cca0f3b4dc | ||
|
|
3b1f4a0d13 | ||
|
|
22f4dade4f | ||
|
|
e30a0c3dce | ||
|
|
9966e6322d | ||
|
|
02450982c1 | ||
|
|
cdad9af453 | ||
|
|
07ca134d98 | ||
|
|
dde8e28d07 | ||
|
|
5fd92ee72d | ||
|
|
5bcd3a1b01 | ||
|
|
d49d9fd755 | ||
|
|
41d817823b | ||
|
|
cfffb4961b | ||
|
|
6bd2f4d98d | ||
|
|
872ee339da | ||
|
|
295fea7581 | ||
|
|
f9f2e604c0 | ||
|
|
f936b8b12b | ||
|
|
9f04c34b06 | ||
|
|
c9d416fec0 | ||
|
|
40ac8b1909 | ||
|
|
f1a2037bca | ||
|
|
ded78c6639 | ||
|
|
51fcb59f09 | ||
|
|
e75c556443 | ||
|
|
3dde6a098c | ||
|
|
ef25139ffe | ||
|
|
9d6076f642 | ||
|
|
dd82a1bebd | ||
|
|
752b2caaf4 | ||
|
|
d3f1fde9d9 | ||
|
|
d83e7bce0a | ||
|
|
8cd4a58304 | ||
|
|
0ef683222d | ||
|
|
ebbf162318 | ||
|
|
268d202562 | ||
|
|
4e0ec75e58 | ||
|
|
1af989c4a3 | ||
|
|
53480fdd5f | ||
|
|
ffa90c397c | ||
|
|
df3d1078f1 | ||
|
|
22bdb85dff | ||
|
|
2f5081156d | ||
|
|
c3f153a5fa | ||
|
|
5e0dda1bde | ||
|
|
b0379b0821 | ||
|
|
c506c9cee5 | ||
|
|
9184593bc0 | ||
|
|
1da70d54e8 | ||
|
|
55cdd016da | ||
|
|
10997898b9 | ||
|
|
76b66977e9 | ||
|
|
d695648d9b | ||
|
|
72160f5daf | ||
|
|
0751da42b6 | ||
|
|
babe1f30a2 | ||
|
|
cd35e91ea2 | ||
|
|
8d8a965241 | ||
|
|
2309887c92 | ||
|
|
d36e6e5834 | ||
|
|
dd205a14bc | ||
|
|
d854fe1202 | ||
|
|
58f487ac58 | ||
|
|
1761c506be | ||
|
|
9f19514b03 | ||
|
|
ade1056a02 | ||
|
|
e5fecaf9b6 | ||
|
|
5b8b0aa641 | ||
|
|
b7bc5cbad7 | ||
|
|
f2fc47a719 | ||
|
|
a5f9ab7897 | ||
|
|
39368c1a38 | ||
|
|
d879cf3cbb | ||
|
|
ae59c56ddd | ||
|
|
35431384bd | ||
|
|
dd31c0138b | ||
|
|
11f1e3fee8 | ||
|
|
aaaa8ed693 | ||
|
|
fec6bf290b | ||
|
|
2418e42655 | ||
|
|
dce86580ce | ||
|
|
f6997871be | ||
|
|
660a586a7c | ||
|
|
193cde0925 | ||
|
|
1a33e6e631 | ||
|
|
bb8ade435d | ||
|
|
94905f8151 | ||
|
|
05a30f00e3 | ||
|
|
3c1f8804af | ||
|
|
716e3d7143 | ||
|
|
a0e6487a7b | ||
|
|
076599f05c | ||
|
|
9fb0f37718 | ||
|
|
b86502aec7 | ||
|
|
88ccb955ce | ||
|
|
822f8a2cd0 | ||
|
|
d2965e1122 | ||
|
|
37e211937c | ||
|
|
e7a03dc7d6 | ||
|
|
a469b88fd2 | ||
|
|
45244c8e5d | ||
|
|
fad5817353 | ||
|
|
c0a8b79acc | ||
|
|
34a41fd610 | ||
|
|
eb0440d36d | ||
|
|
cd82db16d5 | ||
|
|
bdad601ebc | ||
|
|
97a74902ef | ||
|
|
ab30b6a799 | ||
|
|
da6bc497fc | ||
|
|
06c3168868 | ||
|
|
86be90adb2 | ||
|
|
a296678d20 | ||
|
|
f768990fb1 | ||
|
|
313543d0d1 | ||
|
|
2ebe8d80e9 | ||
|
|
8c20422fef | ||
|
|
2197a9b782 | ||
|
|
928a8b351e | ||
|
|
980ed8e265 | ||
|
|
2a148cb138 | ||
|
|
9426c6acd9 | ||
|
|
90ce48b170 | ||
|
|
448af683a0 | ||
|
|
ec5f8254f1 | ||
|
|
7ca38b88ad | ||
|
|
9f31a2c8a2 | ||
|
|
09cf5a9b04 | ||
|
|
4c6953a4e0 | ||
|
|
b4b4fbe375 | ||
|
|
4bc07ceb4e | ||
|
|
fde1706a0c | ||
|
|
1891d7c90a | ||
|
|
98d032913b | ||
|
|
80bcf92fa3 | ||
|
|
41d536b7ff | ||
|
|
1e5e3d5f41 | ||
|
|
19961c7ec5 | ||
|
|
08e273bfd6 | ||
|
|
9f45456066 | ||
|
|
6e69696b4a | ||
|
|
8b6be1cab8 | ||
|
|
93a490e881 | ||
|
|
f23959bb05 | ||
|
|
228041913e | ||
|
|
fc53989946 | ||
|
|
83103a893a | ||
|
|
8cbc7a68e5 | ||
|
|
1292d9ad9b | ||
|
|
1177fd721c | ||
|
|
2c8908850b | ||
|
|
9f72dc08c6 | ||
|
|
1018ba554f | ||
|
|
709c9ece74 | ||
|
|
4622a74786 | ||
|
|
19e51102d2 | ||
|
|
68a68bde82 | ||
|
|
e1186b4a1e | ||
|
|
72cfca1158 | ||
|
|
67d824cac9 | ||
|
|
4f010d77e8 | ||
|
|
3b1f9b10e7 | ||
|
|
5e33d8b6c4 | ||
|
|
f7a2509405 | ||
|
|
52904eea09 | ||
|
|
ff84ded547 | ||
|
|
6220e4f63f | ||
|
|
b0c2521101 | ||
|
|
30d2a03fd0 | ||
|
|
61a4b558a8 | ||
|
|
3771d4bfd8 | ||
|
|
b087e849b5 | ||
|
|
9e71945a76 | ||
|
|
9f6fc3d1ac | ||
|
|
e22830eb4a | ||
|
|
f02a3d815a | ||
|
|
7097897df8 | ||
|
|
9247967f93 | ||
|
|
1b3d82fc04 | ||
|
|
810934f2c1 | ||
|
|
3b507a1fb9 | ||
|
|
4f1056a320 | ||
|
|
963aa8f003 | ||
|
|
431dfd7780 | ||
|
|
4f0cbd82d4 | ||
|
|
53e437c6bc | ||
|
|
0e5c91733d | ||
|
|
f5c729c328 | ||
|
|
4f9e93fac7 | ||
|
|
7cc83eaf95 | ||
|
|
22b01b131f | ||
|
|
2045bf8060 | ||
|
|
df73b37180 | ||
|
|
99f9b10348 | ||
|
|
ed85f77c48 | ||
|
|
777438fd94 | ||
|
|
08406de5cc | ||
|
|
e1599909bc | ||
|
|
e7eda1f5ec | ||
|
|
9f2aaf01c7 | ||
|
|
882c78fbb5 | ||
|
|
a79b2fb755 | ||
|
|
97fba241a1 | ||
|
|
d0fbca7af5 | ||
|
|
36726c747c | ||
|
|
74580e63d6 | ||
|
|
1d8eb35c64 | ||
|
|
659472578b | ||
|
|
9ec549b496 | ||
|
|
e37c190600 | ||
|
|
d51d7efdcf | ||
|
|
b0a16c8daf | ||
|
|
beb86c1820 | ||
|
|
48f8026c35 | ||
|
|
1be0a2dac3 | ||
|
|
d31e495d07 | ||
|
|
3b2a48eabf | ||
|
|
4bc76a0766 | ||
|
|
3faa23c6eb | ||
|
|
e324de8f4f | ||
|
|
7954ae8692 | ||
|
|
85a00b508b | ||
|
|
3c84143511 | ||
|
|
1e91d7256c | ||
|
|
8a15172db1 | ||
|
|
aae574e4e5 | ||
|
|
45106b47d4 | ||
|
|
59b3038b9b | ||
|
|
963ec282d3 | ||
|
|
31cf8b7d28 | ||
|
|
9f6bc10369 | ||
|
|
f7c7d40195 | ||
|
|
380e3fead3 | ||
|
|
ffa01c7f1d | ||
|
|
15367f9444 | ||
|
|
90a710907e | ||
|
|
da6d06728c | ||
|
|
451ff3ffec | ||
|
|
61038f876d | ||
|
|
20e1c71eff | ||
|
|
d2d7f5b71e | ||
|
|
0ad4cb7cfd | ||
|
|
161efbb3c8 | ||
|
|
b35739c5c1 | ||
|
|
7690fb9287 | ||
|
|
57f0aefbc8 | ||
|
|
2e54520b32 | ||
|
|
cdf5b29ac2 | ||
|
|
733b929940 | ||
|
|
211fe48e29 | ||
|
|
9d3f7fe556 | ||
|
|
5d87508d0e | ||
|
|
40d0e7e90e | ||
|
|
7ca10ff5a4 | ||
|
|
831c635149 | ||
|
|
d961e7695d | ||
|
|
4b842ef37f | ||
|
|
0396bedcd0 | ||
|
|
1705e66be2 | ||
|
|
1e4f804542 | ||
|
|
6a03be9d64 | ||
|
|
591278862a | ||
|
|
9848e4b600 | ||
|
|
772b478682 | ||
|
|
dab8dd278d | ||
|
|
72d26c6c7e | ||
|
|
a7f07ab9f5 | ||
|
|
75080135af | ||
|
|
7a9483c0d0 | ||
|
|
484c6bb8a7 | ||
|
|
125adfb198 | ||
|
|
a0c6e92016 | ||
|
|
7de58740a2 | ||
|
|
bae56b8b9d | ||
|
|
e02d925a49 | ||
|
|
03f868d084 | ||
|
|
920c4cd7cb | ||
|
|
bf2c638cad | ||
|
|
eddb513e72 | ||
|
|
fea68ac71a | ||
|
|
97b10c685c | ||
|
|
40fc422ab5 | ||
|
|
f0a8020189 | ||
|
|
647afba2b0 | ||
|
|
bd324a7e74 | ||
|
|
ac080c8323 | ||
|
|
30ebf90371 | ||
|
|
f9a7adbd72 | ||
|
|
b74fb22182 | ||
|
|
b6ea89356b | ||
|
|
37488ded4d | ||
|
|
c47dd828ed | ||
|
|
a34ed8ccb4 | ||
|
|
d4d0546d61 | ||
|
|
e94c1d33d2 | ||
|
|
dd6388bf9f | ||
|
|
8b8071a903 | ||
|
|
19746a78f4 | ||
|
|
13d679c4bf | ||
|
|
a851378a2f | ||
|
|
e3b2d33a5e | ||
|
|
e4b7d0be64 | ||
|
|
7e48696fb5 | ||
|
|
b727c56e56 | ||
|
|
7f168f35b8 | ||
|
|
21c0916693 | ||
|
|
8f0fb6e458 | ||
|
|
4606ad4c6e | ||
|
|
bf267436b0 | ||
|
|
2af44665e1 | ||
|
|
e412a379e3 | ||
|
|
f37da19649 | ||
|
|
d7756230fb | ||
|
|
f2f32c35ea | ||
|
|
d4770f16e3 | ||
|
|
d6aa0138f0 | ||
|
|
f3b17f4615 | ||
|
|
04e6f2ea58 | ||
|
|
ed6718eef1 | ||
|
|
e36a638ae5 | ||
|
|
d1c2e74ed6 | ||
|
|
5a410029f6 | ||
|
|
005fb705fa | ||
|
|
b4fec32320 | ||
|
|
d0000cee11 | ||
|
|
846b3b9d02 | ||
|
|
54d881642d | ||
|
|
f6c0b0d6fc | ||
|
|
08a3d7367b | ||
|
|
cd537f98c7 | ||
|
|
8ab91c3eb2 | ||
|
|
8c773ced9c | ||
|
|
e487f9a951 | ||
|
|
eb4ecf853b | ||
|
|
54e2deaddc | ||
|
|
1ac510af3d | ||
|
|
a666c8def3 | ||
|
|
33933ef212 | ||
|
|
d9dade7181 | ||
|
|
87502f4249 | ||
|
|
4cc2acc9e6 | ||
|
|
f903e97562 | ||
|
|
b57e42be6f | ||
|
|
9f95947d16 | ||
|
|
d129fc14c1 | ||
|
|
58422569c9 | ||
|
|
9adafbd473 | ||
|
|
47ea2f6ed7 | ||
|
|
e2ba0ec059 | ||
|
|
870cbc103d | ||
|
|
dfca664f6e | ||
|
|
00cfd427b1 | ||
|
|
e639a32822 | ||
|
|
8765bc800d | ||
|
|
1dc73a951e | ||
|
|
317b80bf4d | ||
|
|
2aaae95e89 | ||
|
|
0580e45af9 | ||
|
|
0dbf6453ac | ||
|
|
695324832c | ||
|
|
ac4c84e7a4 | ||
|
|
f172d02920 | ||
|
|
dbe60e3ff1 | ||
|
|
18aa453bb0 | ||
|
|
beaf67c975 | ||
|
|
8e6f0a7dbb | ||
|
|
b2b276c3a3 | ||
|
|
7483b4afc6 | ||
|
|
c7a2e84927 | ||
|
|
3482330629 | ||
|
|
17f78169f2 | ||
|
|
a74b556188 | ||
|
|
1721b9087a | ||
|
|
c871548877 | ||
|
|
190ecddc2a | ||
|
|
0a24ac9f25 | ||
|
|
d8d580c277 | ||
|
|
be08887e50 | ||
|
|
5043313aca | ||
|
|
83d2a604e1 | ||
|
|
02509ebc3a | ||
|
|
e494899f8b | ||
|
|
9f483bba6f | ||
|
|
f93af38fa6 | ||
|
|
6f6a06c8c3 | ||
|
|
6eecd9cee4 | ||
|
|
79a4291153 | ||
|
|
a54fb98d4e | ||
|
|
7e847cc139 | ||
|
|
99daaf5537 | ||
|
|
24421ca4e7 | ||
|
|
a3549ae694 | ||
|
|
25945fc0df | ||
|
|
b50353c8c4 | ||
|
|
4f4b43f49d | ||
|
|
cfdc3e6870 | ||
|
|
f71c3da568 | ||
|
|
e472465ce7 | ||
|
|
776b6da79f | ||
|
|
1e4a00ce56 | ||
|
|
ed6bca04f5 | ||
|
|
dbfc1e7d28 | ||
|
|
cc9ead20b3 | ||
|
|
79c89bb621 | ||
|
|
cf1617f2a3 | ||
|
|
7ecca16fd0 | ||
|
|
1e1505c63f | ||
|
|
1bddb38fcc | ||
|
|
3314471d73 | ||
|
|
42c441f534 | ||
|
|
a957ea37f6 | ||
|
|
a4d426bc00 | ||
|
|
15f95ddd44 | ||
|
|
4dd8ad77bb | ||
|
|
9f5a4fb44c | ||
|
|
7f16da110f | ||
|
|
3734c9e71d | ||
|
|
a924f53320 | ||
|
|
6b93b1c1e7 | ||
|
|
3d7780958a | ||
|
|
59e87697ff | ||
|
|
20c088b6de | ||
|
|
50f069e688 | ||
|
|
148c243d9f | ||
|
|
16e4f66b99 | ||
|
|
774b555a61 | ||
|
|
4f90f92b38 | ||
|
|
753b3befad | ||
|
|
544bc9bd01 | ||
|
|
1a467565c1 | ||
|
|
562daf9b04 | ||
|
|
5b35d1169d | ||
|
|
0d1d3a180d | ||
|
|
df3db14e8b | ||
|
|
8f15887c03 | ||
|
|
7384cdc241 | ||
|
|
56851f2c2d | ||
|
|
50c9d95ce0 | ||
|
|
0310eee685 | ||
|
|
c4499fcc26 | ||
|
|
1d317788fe | ||
|
|
b5301ff978 | ||
|
|
a027e16636 | ||
|
|
673a22a571 | ||
|
|
1c7d2740f3 | ||
|
|
4f4659b0e2 | ||
|
|
7b3a1eb4ff | ||
|
|
3778b4c719 | ||
|
|
3e258332c1 | ||
|
|
713865fb40 | ||
|
|
bc29cddcec | ||
|
|
f9d8344dba | ||
|
|
9d38c937b4 | ||
|
|
622579bb7d | ||
|
|
26263c0bf8 | ||
|
|
05f88dfd00 | ||
|
|
d1d28acebb | ||
|
|
84d5b26530 | ||
|
|
16c37d8d76 | ||
|
|
802da2920b | ||
|
|
a608df9cd9 | ||
|
|
254b0852ca | ||
|
|
8e41755d2a | ||
|
|
36eb250d7a | ||
|
|
a2b97abb2e | ||
|
|
0331f5cf5b | ||
|
|
54159513e4 | ||
|
|
99a766d990 | ||
|
|
1ec0cb14ef | ||
|
|
387f03db25 | ||
|
|
0c20a65999 | ||
|
|
da8836ba99 | ||
|
|
2456432844 | ||
|
|
bf874c55af | ||
|
|
3e66647f9f | ||
|
|
6d6571be0b | ||
|
|
dad4cd90ca | ||
|
|
43a76933ab | ||
|
|
ce9013fed2 | ||
|
|
e4632ea340 | ||
|
|
f21eaab997 | ||
|
|
f48b9c46fe | ||
|
|
7d08731094 | ||
|
|
bd97d78195 | ||
|
|
b1a3fcf33c | ||
|
|
453656fbeb | ||
|
|
7d755fe2a3 | ||
|
|
f9307986cd | ||
|
|
ba1430c377 | ||
|
|
f60090e5fa | ||
|
|
7698abe70f | ||
|
|
fd58503a77 | ||
|
|
8aa7a26183 | ||
|
|
ad5ad05b7b | ||
|
|
c0827d6db0 | ||
|
|
43209186ee | ||
|
|
46a0a66fb6 | ||
|
|
9e6f7a496e | ||
|
|
94d9e1b08e | ||
|
|
087ce4bb90 | ||
|
|
2c02d4174f | ||
|
|
4feeaee7e7 | ||
|
|
5f5185c619 | ||
|
|
3e76307303 | ||
|
|
fe3a5f4def | ||
|
|
5d752f3355 | ||
|
|
8f400236a7 | ||
|
|
8779ee3325 | ||
|
|
e268858945 | ||
|
|
0e48f325f2 | ||
|
|
7e38271ac6 | ||
|
|
ff75afa91f | ||
|
|
094ad3bd59 | ||
|
|
ae2bb3a028 | ||
|
|
c319d6bcfa | ||
|
|
4866eacd5d | ||
|
|
1386020bbb | ||
|
|
6b7af58e6c | ||
|
|
0f1d07d90f | ||
|
|
d5230757b1 | ||
|
|
06825468b4 | ||
|
|
faab60f271 | ||
|
|
4bed2349a9 | ||
|
|
53f1e53fcb | ||
|
|
df447d3d4d | ||
|
|
e3bf913a80 | ||
|
|
7bb1f16946 | ||
|
|
6870fd6d76 | ||
|
|
e2ef9b8122 | ||
|
|
9ad1d1f196 | ||
|
|
969cff61bf | ||
|
|
736f729457 | ||
|
|
0050e1e294 | ||
|
|
f2d1b61a7a | ||
|
|
1d1fa99b4b | ||
|
|
8e48df5de1 | ||
|
|
a3b1d7fb7c | ||
|
|
f42cab6e40 | ||
|
|
01e3cd0296 | ||
|
|
fd6109099a | ||
|
|
8c07b12bb0 | ||
|
|
eb404b8e5b | ||
|
|
0fdb5e83cf | ||
|
|
2a780bc482 | ||
|
|
f61b664687 | ||
|
|
04844a4422 | ||
|
|
3afc9f83d9 | ||
|
|
e08435568c | ||
|
|
1a80a74d4f | ||
|
|
9c53541cbd | ||
|
|
62db393969 | ||
|
|
d7c9ab43bc | ||
|
|
fcb4c722c6 | ||
|
|
7626f63beb | ||
|
|
a6e45c7fd1 | ||
|
|
2658831e83 | ||
|
|
ffdbe46a23 | ||
|
|
6a11cd0e28 | ||
|
|
153ab63393 | ||
|
|
ea1855485c | ||
|
|
3427fa1e94 | ||
|
|
46262c56db | ||
|
|
3482d92ab6 | ||
|
|
bc21abd509 | ||
|
|
41d43e84a5 | ||
|
|
72744718cc | ||
|
|
e85a62a05c | ||
|
|
5a68acc0f5 | ||
|
|
f51fca74e6 | ||
|
|
fe5a76c0df | ||
|
|
74ac8f9ffa | ||
|
|
7e289950fa | ||
|
|
9fc8af6553 | ||
|
|
3bda834ad3 | ||
|
|
29f0a8e635 | ||
|
|
7ffc02c3e5 | ||
|
|
2f323cde8a | ||
|
|
534131d994 | ||
|
|
d233e2b4a5 | ||
|
|
05a7defcb8 | ||
|
|
eeec24ae78 | ||
|
|
1d778e3249 | ||
|
|
3bb44d8a17 | ||
|
|
c035404555 | ||
|
|
74ddc71962 | ||
|
|
1491a1b4ff | ||
|
|
6890bab668 | ||
|
|
209c237b73 | ||
|
|
71c52b4587 | ||
|
|
086468d65b | ||
|
|
323d84974c | ||
|
|
fe449abb47 | ||
|
|
6365fb9b56 | ||
|
|
19bb9705b6 | ||
|
|
705d170b6e | ||
|
|
ab54188ba4 | ||
|
|
e0b6b95295 | ||
|
|
c7cfade86f | ||
|
|
e4fa59aae8 | ||
|
|
35227268cf | ||
|
|
67b11d62ea | ||
|
|
2b81c26cff | ||
|
|
32b5bebbc4 | ||
|
|
c27f5d9efa | ||
|
|
26a41e6262 | ||
|
|
87c9e587a1 | ||
|
|
bfd3eff6f2 | ||
|
|
f3148ed53c | ||
|
|
ea320e0cc4 | ||
|
|
7f8b87bb85 | ||
|
|
5e97121e5a | ||
|
|
c9fc976c72 | ||
|
|
9e8570c19b | ||
|
|
ed2d539995 | ||
|
|
13fbcd0eb1 | ||
|
|
43b9f3d901 | ||
|
|
3ee9fe1c3f | ||
|
|
65cc8567a1 | ||
|
|
dd82f54549 | ||
|
|
a014056440 | ||
|
|
c176c38f30 | ||
|
|
4c87aed628 | ||
|
|
09f2f96dff | ||
|
|
703e207970 | ||
|
|
f075b19a68 | ||
|
|
283c2b5ae1 | ||
|
|
f1c3507a9f | ||
|
|
29dc1e0747 | ||
|
|
265e9976b9 | ||
|
|
70657c16d1 | ||
|
|
7177548c0e | ||
|
|
e1ad05eb3a | ||
|
|
75c41f4466 | ||
|
|
85caf0a892 | ||
|
|
692205b0e6 | ||
|
|
e4324f316d | ||
|
|
46140e92fd | ||
|
|
3bc2df0ac5 | ||
|
|
46d1f89b77 | ||
|
|
bf1f2054de | ||
|
|
399caaaeff | ||
|
|
27b4176e23 | ||
|
|
a8bc6b4e1d | ||
|
|
3ca8f72762 | ||
|
|
8aec5dbba6 | ||
|
|
cccebd8494 | ||
|
|
5fbbd92ea7 | ||
|
|
81f26e0892 | ||
|
|
9366284e1d | ||
|
|
9aa5eea8c9 | ||
|
|
20f61bff07 | ||
|
|
625819da91 | ||
|
|
2c691d84f2 | ||
|
|
4630d2640b | ||
|
|
77abab8395 | ||
|
|
043f24d5ca | ||
|
|
87e18c0521 | ||
|
|
7e30f860b2 | ||
|
|
0ac0ffe53d | ||
|
|
ae4e1b55e6 | ||
|
|
756ced088c | ||
|
|
8ce6b22be7 | ||
|
|
37c72d5125 | ||
|
|
602a476b59 | ||
|
|
965397733d | ||
|
|
f10868db0b | ||
|
|
d7a95d3cff | ||
|
|
6eeed49022 | ||
|
|
be96c3a56f | ||
|
|
57a31f3b71 | ||
|
|
7c5955c96f | ||
|
|
8ab273363c | ||
|
|
538650bf92 | ||
|
|
54921a998a | ||
|
|
6184d64f89 | ||
|
|
da11089fff | ||
|
|
0243d138ff | ||
|
|
4c8a5baee5 | ||
|
|
e5acbfed3a | ||
|
|
0163e22567 | ||
|
|
b503b8fc9b | ||
|
|
3243e4d56c | ||
|
|
fbc164a9b8 | ||
|
|
02e6a3df99 | ||
|
|
78cf95fbb1 | ||
|
|
d2306b70a9 | ||
|
|
43180c314f | ||
|
|
f47c2dcb56 | ||
|
|
a4ea1612c1 | ||
|
|
c00c2626b4 | ||
|
|
8b6517eb8d | ||
|
|
b8ee696b69 | ||
|
|
067a7cd507 | ||
|
|
89fddd0210 | ||
|
|
0c167d803c | ||
|
|
c50042c1e7 | ||
|
|
0dc1b46466 | ||
|
|
4ed9fc7d0e | ||
|
|
162929bdca | ||
|
|
54a2f6940c | ||
|
|
0243b5f491 | ||
|
|
0dff59d793 | ||
|
|
31c7fd12b9 | ||
|
|
7951c4a03a | ||
|
|
7b8aaa408d | ||
|
|
1c65ee150b | ||
|
|
66fd56fccb | ||
|
|
b0cfeaa782 | ||
|
|
da699e999f | ||
|
|
84de560083 | ||
|
|
c6a5f50c76 | ||
|
|
74c7395ab9 | ||
|
|
26c4b1afa6 | ||
|
|
622827efda | ||
|
|
854c21639a | ||
|
|
2b1b0acefc | ||
|
|
8fc6047127 | ||
|
|
7782e200af | ||
|
|
62e679571e | ||
|
|
f32c52a460 | ||
|
|
edbe8cdace | ||
|
|
9e4344de83 | ||
|
|
760269a6e1 | ||
|
|
e53e00713d | ||
|
|
faba9f1616 | ||
|
|
6beee49ebc | ||
|
|
eaf3c7978d | ||
|
|
d36e052478 | ||
|
|
099ea08bd4 | ||
|
|
b0ea34cc3f | ||
|
|
a241813b8d | ||
|
|
de27437148 | ||
|
|
79e8dfec18 | ||
|
|
0c010a0a87 | ||
|
|
0c6c9fce4d | ||
|
|
ac9fc720f7 | ||
|
|
8b31966c2b | ||
|
|
76d966f17d | ||
|
|
d0d8b268d4 | ||
|
|
8bd8f0fc37 | ||
|
|
a2acf3be0e | ||
|
|
844a3c19ec | ||
|
|
877c2e365f | ||
|
|
81c7950ad1 | ||
|
|
7b8e3da90a | ||
|
|
eef3d7738e | ||
|
|
b8ca837c02 | ||
|
|
1fc3573087 | ||
|
|
5ab89b2583 | ||
|
|
539cd1d2b9 | ||
|
|
c930ae87f4 | ||
|
|
4424a331d5 | ||
|
|
c747c5577e | ||
|
|
ce8cbba441 | ||
|
|
c0cabbb563 | ||
|
|
e56ff93db1 | ||
|
|
033776168e | ||
|
|
d0ccc4a15a | ||
|
|
2f383d59b6 | ||
|
|
c9c5176f1b | ||
|
|
fe0cfcb2b6 | ||
|
|
0470d13ae0 | ||
|
|
c4defb7b3f | ||
|
|
c1e17bb6aa | ||
|
|
d09dc11f5f | ||
|
|
4c2211c428 | ||
|
|
d076d6c719 | ||
|
|
d648bacd26 | ||
|
|
1ca5ba1086 | ||
|
|
7c28f60e0a | ||
|
|
20b76bdead | ||
|
|
2fd2ccfe14 | ||
|
|
69308cfd8b | ||
|
|
ccc1895304 | ||
|
|
05a0d80c1b | ||
|
|
2ea65de0c0 | ||
|
|
742798ad79 | ||
|
|
f088fc49f3 | ||
|
|
b837ac5d6b | ||
|
|
64af24f0f4 | ||
|
|
5abb1db512 | ||
|
|
f1133b9c33 | ||
|
|
c73d02c550 | ||
|
|
f1d26cc0c0 | ||
|
|
077d699f0b | ||
|
|
2ed8614642 | ||
|
|
9834fcb97f | ||
|
|
347393520d | ||
|
|
e65e12ff6e | ||
|
|
4dfe1a0914 | ||
|
|
1a1acec2f3 | ||
|
|
e6276a0c7b | ||
|
|
84a0c43745 | ||
|
|
baed640a3d | ||
|
|
9621a69b7d | ||
|
|
7d6851572f | ||
|
|
3e2ec7cd36 | ||
|
|
0ac88bd84a | ||
|
|
db3f9a45ad | ||
|
|
8fc2737670 | ||
|
|
0c2e4ce20b | ||
|
|
62948b2838 | ||
|
|
3dfb3a9738 | ||
|
|
42c1bece65 | ||
|
|
448c12cc91 | ||
|
|
56c82f8793 | ||
|
|
84b0407f74 | ||
|
|
90977521df | ||
|
|
09a52bc7cb | ||
|
|
6ef80eed7f | ||
|
|
ad1795258b | ||
|
|
993ae295af | ||
|
|
78c26ab1a3 | ||
|
|
eb669e6eca | ||
|
|
17355012fb | ||
|
|
eae593ce90 | ||
|
|
7a8a6480de | ||
|
|
d0dd61a25c | ||
|
|
dbf0559f95 | ||
|
|
8e88b881fc | ||
|
|
c722e0af39 | ||
|
|
6dcdc1b685 | ||
|
|
76d17baf7e | ||
|
|
c97e2be9d5 | ||
|
|
229acbfcd1 | ||
|
|
2cb216ed7b | ||
|
|
8674bc9da2 | ||
|
|
199e049871 | ||
|
|
31f18ef3d5 | ||
|
|
9db55c4dff | ||
|
|
e2ac6c9b6b | ||
|
|
407c35d9f7 | ||
|
|
8575d72f6e | ||
|
|
7b8e398891 | ||
|
|
dfd5b228c2 | ||
|
|
89c5c3f255 | ||
|
|
4dd58aaad3 | ||
|
|
96d973528c | ||
|
|
3a4de13551 | ||
|
|
a65c24bebf | ||
|
|
7dfc857217 | ||
|
|
d5980cba89 | ||
|
|
9ed32527a6 | ||
|
|
62982f86a1 | ||
|
|
985a9843f2 | ||
|
|
3bbcb1b6fb | ||
|
|
9da203d204 | ||
|
|
212b3f7e05 | ||
|
|
7a06fe386d | ||
|
|
4580217410 | ||
|
|
e82ba8cb7a | ||
|
|
636f10cb41 | ||
|
|
d6eaa812b1 | ||
|
|
507f170720 | ||
|
|
faaf4207b4 | ||
|
|
688377ce0b | ||
|
|
8cf57dbc72 | ||
|
|
12012a2a5b | ||
|
|
9b59f47536 | ||
|
|
90b4e47861 | ||
|
|
ef00231c5b | ||
|
|
c39653bc69 | ||
|
|
83faa86063 | ||
|
|
af20d0b1c2 | ||
|
|
1861c7db69 | ||
|
|
a88b256b6c | ||
|
|
40542e9bec | ||
|
|
04187cf769 | ||
|
|
67a4391dcb | ||
|
|
3784e0f583 | ||
|
|
df33713f82 | ||
|
|
c4ba6381f2 | ||
|
|
547daf6499 | ||
|
|
649e225359 | ||
|
|
35bf26feae | ||
|
|
481bab9463 | ||
|
|
a0e2997a40 | ||
|
|
74c4f4fe52 | ||
|
|
7c9513f377 | ||
|
|
c10be139c9 | ||
|
|
ee4921f02c | ||
|
|
f5f6137a4d | ||
|
|
0775f9ee1b | ||
|
|
75ed555de1 | ||
|
|
e7d0741139 | ||
|
|
c69de1036f | ||
|
|
7d115c970a | ||
|
|
852aa8d289 | ||
|
|
ae974b270d | ||
|
|
0a1c04d003 | ||
|
|
ef10b71e56 | ||
|
|
5bfd0dd537 | ||
|
|
05e56221f4 | ||
|
|
5c5230e64e | ||
|
|
769f636db2 | ||
|
|
eeba037244 | ||
|
|
688eca05e1 | ||
|
|
4c48992331 | ||
|
|
fcb9a8cdc5 | ||
|
|
78d4d6fb7c | ||
|
|
407efd0f8b | ||
|
|
d39ae139d7 | ||
|
|
467b728c47 | ||
|
|
b02036fb7a | ||
|
|
d8524c3a84 | ||
|
|
75809a5f42 | ||
|
|
e99aad15c1 | ||
|
|
c57b011215 | ||
|
|
5942bfece1 | ||
|
|
2dc874daba | ||
|
|
38fa428fde | ||
|
|
6bf51cd94a | ||
|
|
ddef21cd7e | ||
|
|
bf30cadb68 | ||
|
|
2f13b89510 | ||
|
|
abe3a7e7c7 | ||
|
|
4ec5f73aed | ||
|
|
a5313deb78 | ||
|
|
5dd486866f | ||
|
|
ada642e56e | ||
|
|
881fcc9cba | ||
|
|
a809e920fc | ||
|
|
36f3eb4da1 | ||
|
|
57772065e0 | ||
|
|
f10be94190 | ||
|
|
055ee38cb7 | ||
|
|
202b275966 | ||
|
|
34be05ac51 | ||
|
|
39e33da2d1 | ||
|
|
d262f586fc | ||
|
|
71f1aed227 | ||
|
|
159d5a35b2 | ||
|
|
efecfac68a | ||
|
|
2c997458b2 | ||
|
|
7e98f79416 | ||
|
|
cfecc001aa | ||
|
|
ab8716d071 | ||
|
|
9e12ab71f8 | ||
|
|
995d1c63d8 | ||
|
|
875e1023fc | ||
|
|
6c4dad675f | ||
|
|
632882d370 | ||
|
|
041c7ed48f | ||
|
|
6dcc6d36b7 | ||
|
|
0762b82c40 | ||
|
|
c6821819c7 | ||
|
|
5a79795e4f | ||
|
|
3073b3e35d | ||
|
|
0491516662 | ||
|
|
b55616170b | ||
|
|
e080c46509 | ||
|
|
171d1c7c46 | ||
|
|
d1503c8d6f | ||
|
|
be72b029bf | ||
|
|
93a7b11017 | ||
|
|
045fbbe158 | ||
|
|
ede731e3a5 | ||
|
|
d6e63604ac | ||
|
|
0624f8a0b9 | ||
|
|
960c03bfa6 | ||
|
|
cda98e02e0 | ||
|
|
9ac070512d | ||
|
|
a1e9c82c06 | ||
|
|
b116e0a622 | ||
|
|
ef2bbfea5e | ||
|
|
c858c705d2 | ||
|
|
fb91761c31 | ||
|
|
93d38eb184 | ||
|
|
d31dae728f | ||
|
|
c068aca9ff | ||
|
|
fcdaef2445 | ||
|
|
c78dcbfe05 | ||
|
|
8d94e5fbe0 | ||
|
|
c6d8bbae16 | ||
|
|
0a54c7b04e | ||
|
|
2fd54ee87e | ||
|
|
1f5f160964 | ||
|
|
8d04f09aab | ||
|
|
be1f905b48 | ||
|
|
dbbd8cb26d | ||
|
|
827fdd3cff | ||
|
|
7b85995b4a | ||
|
|
37593573ce | ||
|
|
a6ecec4172 | ||
|
|
b561f69dd0 | ||
|
|
0bdadaf946 | ||
|
|
7b1a815e78 | ||
|
|
7b9a23670d | ||
|
|
a762626c53 | ||
|
|
1c5c21d89b | ||
|
|
da2c647fa6 | ||
|
|
cb61badfc5 | ||
|
|
d2f909384e | ||
|
|
cebc7be81d | ||
|
|
83c604cb74 | ||
|
|
ad455f652c | ||
|
|
3f19b2975c | ||
|
|
cacfc788fb | ||
|
|
8f99712a28 | ||
|
|
367c2bd111 | ||
|
|
1c45cb1b7f | ||
|
|
19fbd832f1 | ||
|
|
7ce0ac577a | ||
|
|
3ce4d6d1f8 | ||
|
|
18aca07e84 | ||
|
|
4bda071742 | ||
|
|
35bde09aa7 | ||
|
|
d43ea46e40 | ||
|
|
f1ca6eeee2 | ||
|
|
d390d518a3 | ||
|
|
d1152dcbb5 | ||
|
|
837306c9a7 | ||
|
|
e6428a3b18 | ||
|
|
c58c8777f1 | ||
|
|
caadb7b4ce | ||
|
|
ce1ba8289c | ||
|
|
ce946bda98 | ||
|
|
07b1254309 | ||
|
|
4c7715286e | ||
|
|
980c544bba | ||
|
|
7c0b9ea3f6 | ||
|
|
e6d8784633 | ||
|
|
4720aced6c | ||
|
|
cf5e61cf09 | ||
|
|
9d43588f44 | ||
|
|
ce005da20f | ||
|
|
17531151ad | ||
|
|
863f624772 | ||
|
|
6a5f4efd26 | ||
|
|
6200b416ab | ||
|
|
dc1931a5e3 | ||
|
|
26bddc1a79 | ||
|
|
74ebd44d7c | ||
|
|
989af1bbd0 | ||
|
|
3359e489f5 | ||
|
|
f431ac2e40 | ||
|
|
511c38dd1e | ||
|
|
85b0976082 | ||
|
|
7052337669 | ||
|
|
e07d1d1ddb | ||
|
|
c5ebd0352d | ||
|
|
a8fbcf0ad1 | ||
|
|
92f33136ce | ||
|
|
9260283914 | ||
|
|
a08263dd7c | ||
|
|
7eae170f6c | ||
|
|
b5cb8ce834 | ||
|
|
d497c0094b | ||
|
|
71141aa6f6 | ||
|
|
36e607eb3b | ||
|
|
d67f206900 | ||
|
|
6bf9ddd585 | ||
|
|
1607a1ac10 | ||
|
|
392a3db3c2 | ||
|
|
0845234f2f | ||
|
|
f58a7d65b5 | ||
|
|
3ac0ac7568 | ||
|
|
1c71ff0945 | ||
|
|
3ccfef0763 | ||
|
|
a6ec8370be | ||
|
|
7b059f029d | ||
|
|
2de7ec3585 | ||
|
|
efbfbf3568 | ||
|
|
12ca82e6e6 | ||
|
|
0a309ad0e1 | ||
|
|
52b0ae0400 | ||
|
|
a420f202d8 | ||
|
|
3628ca837a | ||
|
|
cc3a42402a | ||
|
|
1e9b71080b | ||
|
|
90917bb84c | ||
|
|
7f6e90fee3 | ||
|
|
b8d8c1bebb | ||
|
|
7ee0e914e6 | ||
|
|
08dbd5638d | ||
|
|
b7d7f4f2a0 | ||
|
|
3cf6691e67 | ||
|
|
8077a91ff7 | ||
|
|
09670b8535 | ||
|
|
36f8f39486 | ||
|
|
1556cf361a | ||
|
|
b557144f63 | ||
|
|
738fc62b8f | ||
|
|
216de73c93 | ||
|
|
a306030635 | ||
|
|
7870c763df | ||
|
|
7f1758364b | ||
|
|
46a6ed4fcc | ||
|
|
7efd23039e | ||
|
|
3d5f99adae | ||
|
|
a889fa657e | ||
|
|
4347debf45 | ||
|
|
dc3243ae59 | ||
|
|
38c20430a9 | ||
|
|
3d71799469 | ||
|
|
fe402bc211 | ||
|
|
dc7e4cd192 | ||
|
|
7fd7230e15 |
@@ -64,6 +64,15 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: Test - Mustache Spans
|
name: Test - Mustache Spans
|
||||||
command: npm run test:mustache-syntax
|
command: npm run test:mustache-syntax
|
||||||
|
- run:
|
||||||
|
name: Test - Definition Lists
|
||||||
|
command: npm run test:definition-lists
|
||||||
|
- run:
|
||||||
|
name: Test - Hard Breaks
|
||||||
|
command: npm run test:hard-breaks
|
||||||
|
- run:
|
||||||
|
name: Test - Variables
|
||||||
|
command: npm run test:variables
|
||||||
- run:
|
- run:
|
||||||
name: Test - Routes
|
name: Test - Routes
|
||||||
command: npm run test:route
|
command: npm run test:route
|
||||||
|
|||||||
79
.eslintrc.js
79
.eslintrc.js
@@ -1,79 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
root : true,
|
|
||||||
parserOptions : {
|
|
||||||
ecmaVersion : 2021,
|
|
||||||
sourceType : 'module',
|
|
||||||
ecmaFeatures : {
|
|
||||||
jsx : true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
env : {
|
|
||||||
browser : true,
|
|
||||||
node : true
|
|
||||||
},
|
|
||||||
plugins : ['react', 'jest'],
|
|
||||||
rules : {
|
|
||||||
/** Errors **/
|
|
||||||
'camelcase' : ['error', { properties: 'never' }],
|
|
||||||
//'func-style' : ['error', 'expression', { allowArrowFunctions: true }],
|
|
||||||
'no-array-constructor' : 'error',
|
|
||||||
'no-iterator' : 'error',
|
|
||||||
'no-nested-ternary' : 'error',
|
|
||||||
'no-new-object' : 'error',
|
|
||||||
'no-proto' : 'error',
|
|
||||||
'react/jsx-no-bind' : ['error', { allowArrowFunctions: true }],
|
|
||||||
'react/jsx-uses-react' : 'error',
|
|
||||||
'react/prefer-es6-class' : ['error', 'never'],
|
|
||||||
'jest/valid-expect' : ['error', { maxArgs: 3 }],
|
|
||||||
|
|
||||||
/** Warnings **/
|
|
||||||
'max-lines' : ['warn', {
|
|
||||||
max : 200,
|
|
||||||
skipComments : true,
|
|
||||||
skipBlankLines : true,
|
|
||||||
}],
|
|
||||||
'max-depth' : ['warn', { max: 4 }],
|
|
||||||
'max-params' : ['warn', { max: 5 }],
|
|
||||||
'no-restricted-syntax' : ['warn', 'ClassDeclaration', 'SwitchStatement'],
|
|
||||||
'no-unused-vars' : ['warn', {
|
|
||||||
vars : 'all',
|
|
||||||
args : 'none',
|
|
||||||
varsIgnorePattern : 'config|_|cx|createClass'
|
|
||||||
}],
|
|
||||||
'react/jsx-uses-vars' : 'warn',
|
|
||||||
|
|
||||||
/** Fixable **/
|
|
||||||
'arrow-parens' : ['warn', 'always'],
|
|
||||||
'brace-style' : ['warn', '1tbs', { allowSingleLine: true }],
|
|
||||||
'jsx-quotes' : ['warn', 'prefer-single'],
|
|
||||||
'no-var' : 'warn',
|
|
||||||
'prefer-const' : 'warn',
|
|
||||||
'prefer-template' : 'warn',
|
|
||||||
'quotes' : ['warn', 'single', { 'allowTemplateLiterals': true }],
|
|
||||||
'semi' : ['warn', 'always'],
|
|
||||||
|
|
||||||
/** Whitespace **/
|
|
||||||
'array-bracket-spacing' : ['warn', 'never'],
|
|
||||||
'arrow-spacing' : ['warn', { before: false, after: false }],
|
|
||||||
'comma-spacing' : ['warn', { before: false, after: true }],
|
|
||||||
'indent' : ['warn', 'tab', { 'MemberExpression': 'off' }],
|
|
||||||
'keyword-spacing' : ['warn', {
|
|
||||||
before : true,
|
|
||||||
after : true,
|
|
||||||
overrides : {
|
|
||||||
if : { 'before': false, 'after': false }
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
'key-spacing' : ['warn', {
|
|
||||||
multiLine : { beforeColon: true, afterColon: true, align: 'colon' },
|
|
||||||
singleLine : { beforeColon: false, afterColon: true }
|
|
||||||
}],
|
|
||||||
'linebreak-style' : 'off',
|
|
||||||
'no-trailing-spaces' : 'warn',
|
|
||||||
'no-whitespace-before-property' : 'warn',
|
|
||||||
'object-curly-spacing' : ['warn', 'always'],
|
|
||||||
'react/jsx-indent-props' : ['warn', 'tab'],
|
|
||||||
'space-in-parens' : ['warn', 'never'],
|
|
||||||
'template-curly-spacing' : ['warn', 'never'],
|
|
||||||
}
|
|
||||||
};
|
|
||||||
103
.github/actions/limit-pull-requests/action.yml
vendored
Normal file
103
.github/actions/limit-pull-requests/action.yml
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
name: Limit pull requests
|
||||||
|
description: >
|
||||||
|
Limit the number of open pull requests to the repository created by a user
|
||||||
|
author: ZhongRuoyu (from Homebrew repository)
|
||||||
|
branding:
|
||||||
|
icon: alert-triangle
|
||||||
|
color: yellow
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
token:
|
||||||
|
description: GitHub token
|
||||||
|
required: false
|
||||||
|
default: ${{ github.token }}
|
||||||
|
except-users:
|
||||||
|
description: The users exempted from the limit, one per line
|
||||||
|
required: false
|
||||||
|
# https://docs.github.com/en/graphql/reference/enums#commentauthorassociation
|
||||||
|
except-author-associations:
|
||||||
|
description: The author associations exempted from the limit, one per line
|
||||||
|
required: false
|
||||||
|
comment-limit:
|
||||||
|
description: >
|
||||||
|
Post the comment when the user's number of open pull requests exceeds this
|
||||||
|
number and `comment` is not empty
|
||||||
|
required: true
|
||||||
|
default: "10"
|
||||||
|
comment:
|
||||||
|
description: The comment to post when the limit is reached
|
||||||
|
required: false
|
||||||
|
close-limit:
|
||||||
|
description: >
|
||||||
|
Close the pull request when the user's number of open pull requests
|
||||||
|
exceeds this number and `close` is set to `true`
|
||||||
|
required: true
|
||||||
|
default: "50"
|
||||||
|
close:
|
||||||
|
description: Whether to close the pull request when the limit is reached
|
||||||
|
required: true
|
||||||
|
default: "false"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Check the number of pull requests
|
||||||
|
id: count-pull-requests
|
||||||
|
run: |
|
||||||
|
# If the user is exempted, assume they have no pull requests.
|
||||||
|
if grep -Fiqx '${{ github.actor }}' <<<"$EXCEPT_USERS"; then
|
||||||
|
echo "::notice::@${{ github.actor }} is exempted from the limit."
|
||||||
|
echo "count=0" >>"$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if grep -Fiqx '${{ github.event.pull_request.author_association }}' <<<"$EXCEPT_AUTHOR_ASSOCIATIONS"; then
|
||||||
|
echo "::notice::@{{ github.actor }} is a ${{ github.event.pull_request.author_association }} exempted from the limit."
|
||||||
|
echo "count=0" >>"$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
count="$(
|
||||||
|
gh api \
|
||||||
|
--method GET \
|
||||||
|
--header 'Accept: application/vnd.github+json' \
|
||||||
|
--header 'X-GitHub-Api-Version: 2022-11-28' \
|
||||||
|
--field state=open \
|
||||||
|
--paginate \
|
||||||
|
'/repos/{owner}/{repo}/pulls' |
|
||||||
|
jq \
|
||||||
|
--raw-output \
|
||||||
|
--arg USER '${{ github.actor }}' \
|
||||||
|
'map(select(.user.login == $USER)) | length'
|
||||||
|
)"
|
||||||
|
echo "::notice::@${{ github.actor }} has $count open pull request(s)."
|
||||||
|
echo "count=$count" >>"$GITHUB_OUTPUT"
|
||||||
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_TOKEN: ${{ inputs.token }}
|
||||||
|
EXCEPT_USERS: ${{ inputs.except-users }}
|
||||||
|
EXCEPT_AUTHOR_ASSOCIATIONS: ${{ inputs.except-author-associations }}
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Comment on pull request
|
||||||
|
if: >
|
||||||
|
fromJSON(steps.count-pull-requests.outputs.count) > fromJSON(inputs.comment-limit) &&
|
||||||
|
inputs.comment != ''
|
||||||
|
run: |
|
||||||
|
gh pr comment '${{ github.event.pull_request.number }}' \
|
||||||
|
--body="${COMMENT_BODY}"
|
||||||
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_TOKEN: ${{ inputs.token }}
|
||||||
|
COMMENT_BODY: ${{ inputs.comment }}
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Close pull request
|
||||||
|
if: >
|
||||||
|
fromJSON(steps.count-pull-requests.outputs.count) > fromJSON(inputs.close-limit) &&
|
||||||
|
inputs.close == 'true'
|
||||||
|
run: |
|
||||||
|
gh pr close '${{ github.event.pull_request.number }}'
|
||||||
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_TOKEN: ${{ inputs.token }}
|
||||||
|
shell: bash
|
||||||
29
.github/workflows/pr-check.yml
vendored
Normal file
29
.github/workflows/pr-check.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: PR Check
|
||||||
|
on: pull_request_target
|
||||||
|
env:
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
GH_NO_UPDATE_NOTIFIER: 1
|
||||||
|
GH_PROMPT_DISABLED: 1
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
statuses: write
|
||||||
|
jobs:
|
||||||
|
limit-pull-requests:
|
||||||
|
if: always() && github.repository_owner == 'naturalcrit'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name : Run limit-pull-requests action
|
||||||
|
uses: ./.github/actions/limit-pull-requests
|
||||||
|
with:
|
||||||
|
except-users: |
|
||||||
|
dependabot
|
||||||
|
comment-limit: 3
|
||||||
|
comment: |
|
||||||
|
Hi, thanks for your contribution to the Homebrewery! You already have >=3 open pull requests. Consider completing some of your existing PRs before opening new ones. Thanks!
|
||||||
|
close-limit: 5
|
||||||
|
close: false
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"stylelint-config-recess-order",
|
"stylelint-config-recess-order",
|
||||||
"stylelint-config-recommended"],
|
"stylelint-config-recommended"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"stylelint-stylistic",
|
"@stylistic/stylelint-plugin",
|
||||||
"./stylelint_plugins/declaration-colon-align.js",
|
"./stylelint_plugins/declaration-colon-align.js",
|
||||||
"./stylelint_plugins/declaration-colon-min-space-before",
|
"./stylelint_plugins/declaration-colon-min-space-before",
|
||||||
"./stylelint_plugins/declaration-block-multi-line-min-declarations"
|
"./stylelint_plugins/declaration-block-multi-line-min-declarations"
|
||||||
@@ -16,32 +16,32 @@
|
|||||||
"font-family-no-missing-generic-family-keyword" : null,
|
"font-family-no-missing-generic-family-keyword" : null,
|
||||||
"font-weight-notation" : "named-where-possible",
|
"font-weight-notation" : "named-where-possible",
|
||||||
"font-family-name-quotes" : "always-unless-keyword",
|
"font-family-name-quotes" : "always-unless-keyword",
|
||||||
"stylistic/indentation" : "tab",
|
"@stylistic/indentation" : "tab",
|
||||||
"no-duplicate-selectors" : true,
|
"no-duplicate-selectors" : true,
|
||||||
"stylistic/color-hex-case" : "upper",
|
"@stylistic/color-hex-case" : "upper",
|
||||||
"color-hex-length" : "long",
|
"color-hex-length" : "long",
|
||||||
"stylistic/selector-combinator-space-after" : "always",
|
"@stylistic/selector-combinator-space-after" : "always",
|
||||||
"stylistic/selector-combinator-space-before" : "always",
|
"@stylistic/selector-combinator-space-before" : "always",
|
||||||
"stylistic/selector-attribute-operator-space-before" : "never",
|
"@stylistic/selector-attribute-operator-space-before" : "never",
|
||||||
"stylistic/selector-attribute-operator-space-after" : "never",
|
"@stylistic/selector-attribute-operator-space-after" : "never",
|
||||||
"stylistic/selector-attribute-brackets-space-inside" : "never",
|
"@stylistic/selector-attribute-brackets-space-inside" : "never",
|
||||||
"selector-attribute-quotes" : "always",
|
"selector-attribute-quotes" : "always",
|
||||||
"selector-pseudo-element-colon-notation" : "double",
|
"selector-pseudo-element-colon-notation" : "double",
|
||||||
"stylistic/selector-pseudo-class-parentheses-space-inside" : "never",
|
"@stylistic/selector-pseudo-class-parentheses-space-inside" : "never",
|
||||||
"stylistic/block-opening-brace-space-before" : "always",
|
"@stylistic/block-opening-brace-space-before" : "always",
|
||||||
"naturalcrit/declaration-colon-min-space-before" : 1,
|
"naturalcrit/declaration-colon-min-space-before" : 1,
|
||||||
"stylistic/declaration-block-trailing-semicolon" : "always",
|
"@stylistic/declaration-block-trailing-semicolon" : "always",
|
||||||
"stylistic/declaration-colon-space-after" : "always",
|
"@stylistic/declaration-colon-space-after" : "always",
|
||||||
"stylistic/number-leading-zero" : "always",
|
"@stylistic/number-leading-zero" : "always",
|
||||||
"function-url-quotes" : ["always", { "except": ["empty"] }],
|
"function-url-quotes" : ["always", { "except": ["empty"] }],
|
||||||
"function-url-scheme-disallowed-list" : ["data","http"],
|
"function-url-scheme-disallowed-list" : ["data","http"],
|
||||||
"comment-whitespace-inside" : "always",
|
"comment-whitespace-inside" : "always",
|
||||||
"stylistic/string-quotes" : "single",
|
"@stylistic/string-quotes" : "single",
|
||||||
"stylistic/media-feature-range-operator-space-before" : "always",
|
"@stylistic/media-feature-range-operator-space-before" : "always",
|
||||||
"stylistic/media-feature-range-operator-space-after" : "always",
|
"@stylistic/media-feature-range-operator-space-after" : "always",
|
||||||
"stylistic/media-feature-parentheses-space-inside" : "never",
|
"@stylistic/media-feature-parentheses-space-inside" : "never",
|
||||||
"stylistic/media-feature-colon-space-before" : "always",
|
"@stylistic/media-feature-colon-space-before" : "always",
|
||||||
"stylistic/media-feature-colon-space-after" : "always",
|
"@stylistic/media-feature-colon-space-after" : "always",
|
||||||
"naturalcrit/declaration-colon-align" : true,
|
"naturalcrit/declaration-colon-align" : true,
|
||||||
"naturalcrit/declaration-block-multi-line-min-declarations": 1
|
"naturalcrit/declaration-block-multi-line-min-declarations": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM node:18-alpine
|
FROM node:20-alpine
|
||||||
RUN apk --no-cache add git
|
RUN apk --no-cache add git
|
||||||
|
|
||||||
ENV NODE_ENV=docker
|
ENV NODE_ENV=docker
|
||||||
|
|||||||
491
changelog.md
491
changelog.md
@@ -75,11 +75,480 @@ pre {
|
|||||||
.page {
|
.page {
|
||||||
padding-bottom: 1.5cm;
|
padding-bottom: 1.5cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.varSyntaxTable th:first-of-type {
|
||||||
|
width:6cm;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## changelog
|
## changelog
|
||||||
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).
|
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).
|
||||||
|
|
||||||
|
### Wednesday 9/04/2024 - v3.15.0
|
||||||
|
|
||||||
|
{{taskList
|
||||||
|
##### 5e-Cleric, abquintic, calculuschild, Gazook89, G-Ambatte, Ericsheid, Kaiburr
|
||||||
|
|
||||||
|
* [x] New {{openSans **VAULT** {{fas,fa-dungeon}}}} page 🎉🎉🎉
|
||||||
|
:
|
||||||
|
All **PUBLISHED** brews ({{openSans :fas_circle_info: **Properties**}} menu) will be searchable, by title or author, and filtered by renderer. More features and adjustments will be coming.
|
||||||
|
:
|
||||||
|
Note: If any of your own brews are not showing up in search (particularly if stored on Google Drive), please edit and re-save to ensure our database has the data needed from document to be searchable.
|
||||||
|
|
||||||
|
Fixes issue [#697](https://github.com/naturalcrit/homebrewery/issues/697)
|
||||||
|
|
||||||
|
##### Gazook89
|
||||||
|
|
||||||
|
* [x] Auto-focus on text editor when switching editor tabs
|
||||||
|
}}
|
||||||
|
|
||||||
|
### Wednesday 8/28/2024 - v3.14.3
|
||||||
|
|
||||||
|
{{taskList
|
||||||
|
##### calculuschild, G-Ambatte
|
||||||
|
|
||||||
|
* [x] New {{openSans **IMAGES → {{fac,image-wrap-left}} IMAGE WRAP LEFT/RIGHT**}} snippets
|
||||||
|
|
||||||
|
Fixes issue [#380](https://github.com/naturalcrit/homebrewery/issues/380)
|
||||||
|
|
||||||
|
* [x] Fix v3.14.2 bug with `꞉꞉꞉꞉` failing after tables
|
||||||
|
|
||||||
|
##### 5e-Cleric
|
||||||
|
|
||||||
|
* [x] Fix Account page crash when not logged in
|
||||||
|
|
||||||
|
Fixes issue [#3605](https://github.com/naturalcrit/homebrewery/issues/3605)
|
||||||
|
|
||||||
|
##### abquintic
|
||||||
|
|
||||||
|
* [x] Fix jump hotkeys conflicting with `CTRL + SHIFT`. Preview and Source movement shortcuts now use `CTRL + SHIFT + META + LEFT\RIGHTARROW`
|
||||||
|
|
||||||
|
##### G-Ambatte
|
||||||
|
|
||||||
|
* [x] Fix display issue with image wrap icons
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
### Tuesday 8/27/2024 - v3.14.2
|
||||||
|
|
||||||
|
{{taskList
|
||||||
|
##### calculuschild
|
||||||
|
|
||||||
|
* [x] Reroute invalid urls to homepage
|
||||||
|
|
||||||
|
Fixes issues [#3269](https://github.com/naturalcrit/homebrewery/issues/3629)
|
||||||
|
|
||||||
|
* [x] Background dependency updates
|
||||||
|
|
||||||
|
##### G-Ambatte
|
||||||
|
|
||||||
|
* [x] Add route to get brew styling via `/css/shareId`
|
||||||
|
|
||||||
|
Fixes issues [#1097](https://github.com/naturalcrit/homebrewery/issues/1097)
|
||||||
|
|
||||||
|
* [x] Fix `:emojis:` preventing code folding
|
||||||
|
|
||||||
|
Fixes issues [#3604](https://github.com/naturalcrit/homebrewery/issues/3604)
|
||||||
|
|
||||||
|
* [x] Fix mask image warping when rotated and stretched
|
||||||
|
|
||||||
|
Fixes issues [#3636](https://github.com/naturalcrit/homebrewery/issues/3636)
|
||||||
|
|
||||||
|
* [x] Fix Table of Contents uppercasing
|
||||||
|
|
||||||
|
Fixes issues [#3572](https://github.com/naturalcrit/homebrewery/issues/3572)
|
||||||
|
|
||||||
|
##### abquintic
|
||||||
|
|
||||||
|
* [x] Create globally unique Header IDs across pages
|
||||||
|
|
||||||
|
Fixes issues [#1430](https://github.com/naturalcrit/homebrewery/issues/1430)
|
||||||
|
|
||||||
|
* [x] Fix colon `꞉꞉꞉꞉` being parsed in codeblocks
|
||||||
|
|
||||||
|
* [x] Prevent crashes when loading undefined renderer or theme bundle
|
||||||
|
|
||||||
|
* [x] Add Jump-To hotkeys
|
||||||
|
|
||||||
|
* Use `CTRL/META + SHIFT + LEFTARROW` to brewJump
|
||||||
|
* Use `CTRL/META + SHIFT + RIGHTARROW` to sourceJump
|
||||||
|
|
||||||
|
* [x] Prevent reload from clobbering modified fresh clones
|
||||||
|
|
||||||
|
##### 5e-Cleric, Gazook89
|
||||||
|
|
||||||
|
* [x] Viewer tools for zoom/page navigation
|
||||||
|
}}
|
||||||
|
|
||||||
|
### Tuesday 8/13/2024 - v3.14.1
|
||||||
|
|
||||||
|
{{taskList
|
||||||
|
##### abquintic
|
||||||
|
|
||||||
|
* [x] Allow Table of Contents to flow across columns
|
||||||
|
|
||||||
|
Fixes issues [#2563](https://github.com/naturalcrit/homebrewery/issues/2563)
|
||||||
|
|
||||||
|
* [x] Fix unusual margin spacing for adjacent `.descriptive` and `.wide` blocks
|
||||||
|
|
||||||
|
Fixes issues [#2688](https://github.com/naturalcrit/homebrewery/issues/2688)
|
||||||
|
|
||||||
|
* [x] Add code folding to :fas_paintbrush: {{openSans **STYLE**}} tab
|
||||||
|
|
||||||
|
##### G-Ambatte
|
||||||
|
|
||||||
|
* [x] Fix edge case where Table of Contents generator changed capitalization of headings
|
||||||
|
|
||||||
|
Fixes issues [#3572](https://github.com/naturalcrit/homebrewery/issues/3572)
|
||||||
|
|
||||||
|
* [x] Fix **Ink Friendly** snippet causing unselectable PDF text
|
||||||
|
|
||||||
|
Fixes issues [#3563](https://github.com/naturalcrit/homebrewery/issues/3563)
|
||||||
|
|
||||||
|
* [x] Prevent brews selecting themselves as a theme
|
||||||
|
|
||||||
|
Fixes issues [#3614](https://github.com/naturalcrit/homebrewery/issues/3614)
|
||||||
|
|
||||||
|
* [x] Fix info pages (`/faq`, `/migrate`, etc.) showing blank authorship info
|
||||||
|
|
||||||
|
Fixes issues [#3568](https://github.com/naturalcrit/homebrewery/issues/3568)
|
||||||
|
|
||||||
|
* [x] Add `abs()`, `sign()` and `signed()` functions to variable syntax math handler
|
||||||
|
|
||||||
|
Fixes issues [#3537](https://github.com/naturalcrit/homebrewery/issues/3537)
|
||||||
|
|
||||||
|
* [x] Fix variable math handler not processing commas (i.e., in `$[max(varA,varB)]`
|
||||||
|
|
||||||
|
Fixes issues [#3613](https://github.com/naturalcrit/homebrewery/issues/3613)
|
||||||
|
|
||||||
|
* [x] Fix variable math handler scrambling variables with names that are subsets of other variables
|
||||||
|
|
||||||
|
Fixes issues [#3622](https://github.com/naturalcrit/homebrewery/issues/3622)
|
||||||
|
|
||||||
|
##### calculuschild
|
||||||
|
|
||||||
|
* [x] Fix `/migrate` page using an editor context instead of share context
|
||||||
|
|
||||||
|
##### 5e-Cleric
|
||||||
|
|
||||||
|
* [x] Fix Monster Stat Blocks losing color in Safari
|
||||||
|
}}
|
||||||
|
|
||||||
|
\page
|
||||||
|
|
||||||
|
### Monday 7/29/2024 - v3.14.0
|
||||||
|
{{taskList
|
||||||
|
|
||||||
|
##### abquintic, calculuschild
|
||||||
|
|
||||||
|
* [x] Alternative Brew Themes, including importing other brews as a base theme.
|
||||||
|
|
||||||
|
- In the :fas_circle_info: **Properties** menu, find the new {{openSans **THEME**}} dropdown. It lists Brew Themes, including a new **Blank** theme as a simpler basis for custom styling.
|
||||||
|
- Brews tagged with `meta:theme` will appear in the Brew Themes list. Selecting one loads its :fas_paintbrush: **Style** tab contents as the CSS basis for the current brew, allowing one brew to style multiple documents.
|
||||||
|
- Brews with `meta:theme` can also select their own Theme, i.e. layering Themes on top of each other.
|
||||||
|
- The next goal is to make **Published** Themes shareable between users.
|
||||||
|
|
||||||
|
|
||||||
|
Fixes issues [#1899](https://github.com/naturalcrit/homebrewery/issues/1899), [#3085](https://github.com/naturalcrit/homebrewery/issues/3085)
|
||||||
|
|
||||||
|
##### G-Ambatte
|
||||||
|
|
||||||
|
* [x] Fix Drop-cap font becoming corrupted when Bold
|
||||||
|
|
||||||
|
Fixes issues [#3551](https://github.com/naturalcrit/homebrewery/issues/3551)
|
||||||
|
|
||||||
|
* [x] Fixes to UI styling
|
||||||
|
|
||||||
|
Fixes issues [#3568](https://github.com/naturalcrit/homebrewery/issues/3568)
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
### Saturday 6/7/2024 - v3.13.1
|
||||||
|
{{taskList
|
||||||
|
|
||||||
|
##### calculuschild, G-Ambatte
|
||||||
|
|
||||||
|
* [x] Hotfixes for issues with v3.13.0
|
||||||
|
|
||||||
|
Fixes issues [#3559](https://github.com/naturalcrit/homebrewery/issues/3559), [#3552](https://github.com/naturalcrit/homebrewery/issues/3552), [#3554](https://github.com/naturalcrit/homebrewery/issues/3554)
|
||||||
|
}}
|
||||||
|
|
||||||
|
### Friday 28/6/2024 - v3.13.0
|
||||||
|
{{taskList
|
||||||
|
|
||||||
|
##### calculuschild
|
||||||
|
|
||||||
|
* [x] Add `:emoji:` Markdown syntax, with autosuggest; start typing after the first `:` for matching emojis from
|
||||||
|
:fab_font_awesome: FontAwesome, :df_d20: DiceFont, :ei_action: ElderberryInn, and a subset of :gi_broadsword: GameIcons
|
||||||
|
|
||||||
|
* [x] Fix `{curly injection}` to append to, rather than erase and replace target CSS
|
||||||
|
* [x] {{openSans **GET PDF**}} {{fa,fa-file-pdf}} now opens the print dialog directly, rather than redirecting to a separate page
|
||||||
|
|
||||||
|
##### Gazook
|
||||||
|
|
||||||
|
* [x] Several small style tweaks to the UI
|
||||||
|
* [x] Cleaning and refactoring several large pieces of code
|
||||||
|
|
||||||
|
##### 5e-Cleric
|
||||||
|
|
||||||
|
* [x] For error pages, add links to user account and `/share` page if available
|
||||||
|
|
||||||
|
Fixes issue [#3298](https://github.com/naturalcrit/homebrewery/issues/3298)
|
||||||
|
|
||||||
|
* [x] Change FrontCover title to use stroke outline instead of faking it with dozens of shadows
|
||||||
|
* [x] Cleaning and refactoring several large pieces of CSS
|
||||||
|
|
||||||
|
##### abquintic
|
||||||
|
|
||||||
|
* [x] Added additional {{openSans **TABLE OF CONTENTS**}} snippet options. Explicitly include or exclude items from the ToC generation via CSS properties
|
||||||
|
`--TOC:exclude` or `--TOC:include`, or change the included header depth from 3 to 6 (default 3) with `tocDepthH6`
|
||||||
|
|
||||||
|
##### MurdoMaclachlan *(new contributor!)*
|
||||||
|
|
||||||
|
* [x] Added "proficiency bonus" to Monster Stat Block snippet.
|
||||||
|
|
||||||
|
Fixes issue [#3397](https://github.com/naturalcrit/homebrewery/issues/3397)
|
||||||
|
}}
|
||||||
|
|
||||||
|
### Monday 18/3/2024 - v3.12.0
|
||||||
|
{{taskList
|
||||||
|
|
||||||
|
##### 5e-Cleric
|
||||||
|
|
||||||
|
* [x] Fix language-specific hyphenation on print page
|
||||||
|
|
||||||
|
Fixes issue [#3294](https://github.com/naturalcrit/homebrewery/issues/3294)
|
||||||
|
|
||||||
|
* [x] Upgrade Font-Awesome to v6.51
|
||||||
|
|
||||||
|
* [x] Allow downloaded files to be uploaded via {{openSans **NEW {{fa,fa-plus-square}} → FROM UPLOAD {{fa,fa-upload}}**}}
|
||||||
|
|
||||||
|
##### G-Ambatte
|
||||||
|
|
||||||
|
* [x] Fix an edge case crash with empty documents
|
||||||
|
|
||||||
|
Fixes issue [#3315](https://github.com/naturalcrit/homebrewery/issues/3315)
|
||||||
|
|
||||||
|
* [x] Brews on the user page can be searched by tag; clicking a tag adds it to the filter
|
||||||
|
|
||||||
|
Fixes issue [#3164](https://github.com/naturalcrit/homebrewery/issues/3164)
|
||||||
|
|
||||||
|
* [x] Add *DiceFont* icons {{df,d20-20}} `{{df,icon-name}}`
|
||||||
|
|
||||||
|
##### abquintic
|
||||||
|
|
||||||
|
* [x] Fix ^super^ and ^^sub^^ highlighting in the text editor
|
||||||
|
|
||||||
|
* [x] Add new syntax for multiline Definition Lists:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
Term
|
||||||
|
::Definition 1
|
||||||
|
::Definition 2
|
||||||
|
with more text
|
||||||
|
```
|
||||||
|
|
||||||
|
produces:
|
||||||
|
|
||||||
|
Term
|
||||||
|
::Definition 1
|
||||||
|
::Definition 2
|
||||||
|
with more text
|
||||||
|
|
||||||
|
Fixes issue [#2340](https://github.com/naturalcrit/homebrewery/issues/2340)
|
||||||
|
|
||||||
|
##### RKuerten :
|
||||||
|
* [x] Fix monster stat block backgrounds on print page
|
||||||
|
|
||||||
|
Fixes issue [#3275](https://github.com/naturalcrit/homebrewery/issues/3275)
|
||||||
|
|
||||||
|
* [x] Added new text editor theme: "Darkvision".
|
||||||
|
|
||||||
|
##### calculuschild, G-Ambatte, 5e-Cleric
|
||||||
|
|
||||||
|
* [x] Codebase and UI cleanup
|
||||||
|
}}
|
||||||
|
|
||||||
|
\page
|
||||||
|
|
||||||
|
|
||||||
|
### Friday 21/2/2024 - v3.11.0
|
||||||
|
{{taskList
|
||||||
|
|
||||||
|
##### Gazook89
|
||||||
|
|
||||||
|
* [x] Brew view count no longer increases when viewed by owner
|
||||||
|
|
||||||
|
Fixes issue [#3037](https://github.com/naturalcrit/homebrewery/issues/3037)
|
||||||
|
|
||||||
|
* [x] Small tweak to PHB H3 sizing
|
||||||
|
|
||||||
|
Fixes issue [#2989](https://github.com/naturalcrit/homebrewery/issues/2989)
|
||||||
|
|
||||||
|
* [x] Add **Fold/Unfold All** {{fas,fa-compress-alt}} / {{fas,fa-expand-alt}} buttons to editor bar
|
||||||
|
|
||||||
|
Fixes issue [#2965](https://github.com/naturalcrit/homebrewery/issues/2965)
|
||||||
|
|
||||||
|
|
||||||
|
##### G-Ambatte
|
||||||
|
|
||||||
|
* [x] Share link added to Editor Access error page
|
||||||
|
|
||||||
|
Fixes issue [#3086](https://github.com/naturalcrit/homebrewery/issues/3086)
|
||||||
|
|
||||||
|
* [x] Add Darkbrewery theme to Editor theme selector {{fas,fa-palette}}
|
||||||
|
|
||||||
|
Fixes issue [#3034](https://github.com/naturalcrit/homebrewery/issues/3034)
|
||||||
|
|
||||||
|
* [x] Fix Firefox prints with alternating blank pages
|
||||||
|
|
||||||
|
Fixes issue [#3115](https://github.com/naturalcrit/homebrewery/issues/3115)
|
||||||
|
|
||||||
|
* [x] Admin page working again
|
||||||
|
|
||||||
|
Fixes issue [#2657](https://github.com/naturalcrit/homebrewery/issues/2657)
|
||||||
|
|
||||||
|
|
||||||
|
##### 5e-Cleric
|
||||||
|
|
||||||
|
* [x] Fix indenting issue with Monster Blocks and italics in Class Feature
|
||||||
|
|
||||||
|
Fixes issues [#527](https://github.com/naturalcrit/homebrewery/issues/527),
|
||||||
|
[#3247](https://github.com/naturalcrit/homebrewery/issues/3247)
|
||||||
|
|
||||||
|
* [x] Allow CSS vars in curly syntax to be formatted as strings using single quotes
|
||||||
|
|
||||||
|
`{{--customVar:"'a string'"}}`
|
||||||
|
|
||||||
|
Fixes issue [#3066](https://github.com/naturalcrit/homebrewery/issues/3066)
|
||||||
|
|
||||||
|
* [x] Add *Elderberry Inn* icons {{ei,action}} `{{ei,icon-name}}`
|
||||||
|
|
||||||
|
Fixes issue [#3171](https://github.com/naturalcrit/homebrewery/issues/3171)
|
||||||
|
|
||||||
|
* [x] New {{openSans **{{fas,fa-keyboard}} FONTS** }} snippets!
|
||||||
|
|
||||||
|
Fixes issue [#3171](https://github.com/naturalcrit/homebrewery/issues/3171)
|
||||||
|
|
||||||
|
* [x] New page now opens in a new tab
|
||||||
|
|
||||||
|
|
||||||
|
##### abquintic (new contributor!)
|
||||||
|
|
||||||
|
* [x] Add ^super^ `^abc^` and ^^sub^^ `^^abc^^` syntax.
|
||||||
|
|
||||||
|
Fixes issue [#2171](https://github.com/naturalcrit/homebrewery/issues/2171)
|
||||||
|
|
||||||
|
* [x] Add HTML tag assignment to curly syntax `{{tag=value}}`
|
||||||
|
|
||||||
|
Fixes issue [1488](https://github.com/naturalcrit/homebrewery/issues/1488)
|
||||||
|
|
||||||
|
* [x] {{openSans **Brew → Clone to New**}} now clones tags
|
||||||
|
|
||||||
|
Fixes issue [1488](https://github.com/naturalcrit/homebrewery/issues/1488)
|
||||||
|
|
||||||
|
##### calculuschild
|
||||||
|
|
||||||
|
* [x] Better error messages for "Out of Google Drive Storage" and "Not logged in to edit"
|
||||||
|
|
||||||
|
Fixes issues [2510](https://github.com/naturalcrit/homebrewery/issues/2510),
|
||||||
|
[2975](https://github.com/naturalcrit/homebrewery/issues/2975)
|
||||||
|
|
||||||
|
* [x] Brew Variables
|
||||||
|
}}
|
||||||
|
|
||||||
|
\
|
||||||
|
|
||||||
|
{{wide
|
||||||
|
|
||||||
|
### Brew Variable Syntax
|
||||||
|
|
||||||
|
You may already be familiar with `[link](url)` and `` synax. We have expanded this to include a third `$[variable](text)` syntax. All three of these syntaxes now share a common set of features:
|
||||||
|
|
||||||
|
{{varSyntaxTable
|
||||||
|
| syntax | description |
|
||||||
|
|:-------|-------------|
|
||||||
|
| `[var]:content` | Assigns a variable (must start on a line by itself, and ends at the next blank line) |
|
||||||
|
| `[var](content)` | Assigns a variable and outputs it (can be inline) |
|
||||||
|
| `[var]` | Outputs the variable contents as a link, if formatted as a valid link |
|
||||||
|
| `![var]` | Outputs as an image, if formatted as a valid image |
|
||||||
|
| `$[var]` | Outputs as Markdown |
|
||||||
|
| `$[var1 + var2 - 2 * var3]` | Performs math operations and outputs result if all variables are valid numbers |
|
||||||
|
}}
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{wide,margin-top:0,margin-bottom:0
|
||||||
|
### Examples
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{wide,columns:2,margin-top:0,margin-bottom:0
|
||||||
|
|
||||||
|
```
|
||||||
|
[first]: Bob
|
||||||
|
|
||||||
|
[last]: Jones
|
||||||
|
|
||||||
|
My name is $[first] $[last].
|
||||||
|
```
|
||||||
|
|
||||||
|
\column
|
||||||
|
|
||||||
|
[first]: Bob
|
||||||
|
|
||||||
|
[last]: Jones
|
||||||
|
|
||||||
|
My name is $[first] $[last].
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{wide,columns:2,margin-top:0,margin-bottom:0
|
||||||
|
|
||||||
|
```
|
||||||
|
[myTable]:
|
||||||
|
| h1 | h2 |
|
||||||
|
|----|----|
|
||||||
|
| c1 | c2 |
|
||||||
|
|
||||||
|
Here is my table:
|
||||||
|
$[myTable]
|
||||||
|
```
|
||||||
|
|
||||||
|
\column
|
||||||
|
|
||||||
|
[myTable]:
|
||||||
|
| h1 | h2 |
|
||||||
|
|----|----|
|
||||||
|
| c1 | c2 |
|
||||||
|
|
||||||
|
Here is my table:
|
||||||
|
$[myTable]
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{wide,columns:2,margin-top:0,margin-bottom:0
|
||||||
|
|
||||||
|
```
|
||||||
|
There are $[TableNum] tables total.
|
||||||
|
|
||||||
|
#### Table $[TableNum](1): Horses
|
||||||
|
|
||||||
|
#### Table $[TableNum]($[TableNum + 1]): Cows
|
||||||
|
```
|
||||||
|
|
||||||
|
\column
|
||||||
|
|
||||||
|
There are $[TableNum] tables in this document. *(note: final value of `$[TableNum]` gets hoisted up if available)*
|
||||||
|
|
||||||
|
|
||||||
|
#### Table $[TableNum](1): Horses
|
||||||
|
|
||||||
|
#### Table $[TableNum]($[TableNum + 1]): Cows
|
||||||
|
}}
|
||||||
|
|
||||||
|
\page
|
||||||
|
|
||||||
### Friday 13/10/2023 - v3.10.0
|
### Friday 13/10/2023 - v3.10.0
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
@@ -133,7 +602,7 @@ Fixes issue [#2729](https://github.com/naturalcrit/homebrewery/issues/2729),
|
|||||||
### Thursday 17/08/2023 - v3.9.2
|
### Thursday 17/08/2023 - v3.9.2
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Fix links to certain old Google Drive files
|
* [x] Fix links to certain old Google Drive files
|
||||||
|
|
||||||
@@ -191,7 +660,7 @@ Fixes issue [#1924](https://github.com/naturalcrit/homebrewery/issues/1924)
|
|||||||
### Friday 02/06/2023 - v3.9.0
|
### Friday 02/06/2023 - v3.9.0
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Fix some files not showing up on userpage when user has a large number of brews in Google Drive
|
* [x] Fix some files not showing up on userpage when user has a large number of brews in Google Drive
|
||||||
|
|
||||||
@@ -288,7 +757,7 @@ Fixes issues [#2731](https://github.com/naturalcrit/homebrewery/issues/2731)
|
|||||||
### Monday 13/03/2023 - v3.7.2
|
### Monday 13/03/2023 - v3.7.2
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Fix wide Monster Stat Blocks not spanning columns on Legacy
|
* [x] Fix wide Monster Stat Blocks not spanning columns on Legacy
|
||||||
}}
|
}}
|
||||||
@@ -311,7 +780,7 @@ Fixes issues [#1569](https://github.com/naturalcrit/homebrewery/issues/1569)
|
|||||||
* [x] Updated the Google Drive icon
|
* [x] Updated the Google Drive icon
|
||||||
* [x] Backend fix to unit tests failing intermittently
|
* [x] Backend fix to unit tests failing intermittently
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Fix PDF pixelation on CoverPage text outlines
|
* [x] Fix PDF pixelation on CoverPage text outlines
|
||||||
}}
|
}}
|
||||||
@@ -323,7 +792,7 @@ Fixes issues [#1569](https://github.com/naturalcrit/homebrewery/issues/1569)
|
|||||||
**NOTE:** Some new snippets will now show a {{beta BETA}} tag. Feel free to use them, but be aware we may change how they work depending on your feedback.
|
**NOTE:** Some new snippets will now show a {{beta BETA}} tag. Feel free to use them, but be aware we may change how they work depending on your feedback.
|
||||||
}}
|
}}
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] New {{openSans **IMAGES → WATERCOLOR EDGE** {{fac,mask-edge}} }} and {{openSans **WATERCOLOR CORNER** {{fac,mask-corner}} }} snippets for V3, which adds a stylish watercolor texture to the edge of your images! (Thanks to /u/flamableconcrete on Reddit for providing these image masks!)
|
* [x] New {{openSans **IMAGES → WATERCOLOR EDGE** {{fac,mask-edge}} }} and {{openSans **WATERCOLOR CORNER** {{fac,mask-corner}} }} snippets for V3, which adds a stylish watercolor texture to the edge of your images! (Thanks to /u/flamableconcrete on Reddit for providing these image masks!)
|
||||||
|
|
||||||
@@ -467,7 +936,7 @@ Fixes issues [#1670](https://github.com/naturalcrit/homebrewery/issues/1670)
|
|||||||
### Thursday 28/10/2022 - v3.3.1
|
### Thursday 28/10/2022 - v3.3.1
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Fixes to several broken CSS styles from v3.3.0
|
* [x] Fixes to several broken CSS styles from v3.3.0
|
||||||
|
|
||||||
@@ -482,7 +951,7 @@ Fixes issues [#2468](https://github.com/naturalcrit/homebrewery/issues/2468)
|
|||||||
### Friday 19/10/2022 - v3.3.0
|
### Friday 19/10/2022 - v3.3.0
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Fix for tables broken by Chrome v106
|
* [x] Fix for tables broken by Chrome v106
|
||||||
|
|
||||||
@@ -565,7 +1034,7 @@ Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [
|
|||||||
### Wednesday 31/08/2022 - v3.2.1
|
### Wednesday 31/08/2022 - v3.2.1
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] Reference Links should now work inside tables
|
* [x] Reference Links should now work inside tables
|
||||||
|
|
||||||
@@ -591,7 +1060,7 @@ Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [
|
|||||||
### Saturday 27/08/2022 - v3.2.0
|
### Saturday 27/08/2022 - v3.2.0
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild
|
##### calculuschild
|
||||||
|
|
||||||
* [x] The V3 renderer is now the default for new brews.
|
* [x] The V3 renderer is now the default for new brews.
|
||||||
|
|
||||||
@@ -618,7 +1087,7 @@ Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [
|
|||||||
### Thursday 09/06/2022 - v3.1.1
|
### Thursday 09/06/2022 - v3.1.1
|
||||||
{{taskList
|
{{taskList
|
||||||
|
|
||||||
##### Calculuschild:
|
##### calculuschild:
|
||||||
|
|
||||||
* [x] Fixed class table decorations appearing on top of the table in PDF output.
|
* [x] Fixed class table decorations appearing on top of the table in PDF output.
|
||||||
|
|
||||||
@@ -1335,7 +1804,7 @@ myStyle {color: black}
|
|||||||
### Sunday, 29/05/2016 - v2.1.0
|
### Sunday, 29/05/2016 - v2.1.0
|
||||||
- Finally added a syntax for doing spell lists. A bit in-depth about why this took so long. Essentially I'm running out of syntax to use in stardard Markdown. There are too many unique elements in the PHB-style to be mapped. I solved this earlier by stacking certain elements together (eg. an `<hr>` before a `blockquote` turns it into moster state block), but those are getting unweildly. I would like to simply wrap these in `div`s with classes, but unfortunately Markdown stops processing when within HTML blocks. To get around this I wrote my own override to the Markdown parser and lexer to process Markdown within a simple div class wrapper. This should open the door for more unique syntaxes in the future. Big step!
|
- Finally added a syntax for doing spell lists. A bit in-depth about why this took so long. Essentially I'm running out of syntax to use in stardard Markdown. There are too many unique elements in the PHB-style to be mapped. I solved this earlier by stacking certain elements together (eg. an `<hr>` before a `blockquote` turns it into moster state block), but those are getting unweildly. I would like to simply wrap these in `div`s with classes, but unfortunately Markdown stops processing when within HTML blocks. To get around this I wrote my own override to the Markdown parser and lexer to process Markdown within a simple div class wrapper. This should open the door for more unique syntaxes in the future. Big step!
|
||||||
- Override Ctrl+P (and cmd+P) to launch to the print page. Many people try to just print either the editing or share page to get a PDF. While this dones;t make much sense, I do get a ton of issues about it. So now if you try to do this, it'll just bring you imediately to the print page. Everybody wins!
|
- Override Ctrl+P (and cmd+P) to launch to the print page. Many people try to just print either the editing or share page to get a PDF. While this dones;t make much sense, I do get a ton of issues about it. So now if you try to do this, it'll just bring you imediately to the print page. Everybody wins!
|
||||||
- The onboarding flow has also been confusing a few users (Homepage -> new -> save -> edit page). If you edit the Homepage text now, a Call to Action to save your work will pop-up.
|
- The onboarding flow has also been confusing a few users (Homepage → new → save → edit page). If you edit the Homepage text now, a Call to Action to save your work will pop-up.
|
||||||
- Added a 'Recently Edited' and 'Recently Viewed' nav item to the edit and share page respectively. Each will remember the last 8 items you edited or viewed and when you viewed it. Makes use of the new title attribute of brews to easy navigatation.
|
- Added a 'Recently Edited' and 'Recently Viewed' nav item to the edit and share page respectively. Each will remember the last 8 items you edited or viewed and when you viewed it. Makes use of the new title attribute of brews to easy navigatation.
|
||||||
- Paragraphs now indent properly after lists (thanks u/slitjen!)
|
- Paragraphs now indent properly after lists (thanks u/slitjen!)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
require('./brewCleanup.less');
|
require('./brewCleanup.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
require('./brewCompress.less');
|
require('./brewCompress.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
require('./combobox.less');
|
require('./combobox.less');
|
||||||
|
|
||||||
const Combobox = createClass({
|
const Combobox = createClass({
|
||||||
|
|||||||
29
client/components/dialog.jsx
Normal file
29
client/components/dialog.jsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Dialog box, for popups and modal blocking messages
|
||||||
|
const React = require('react');
|
||||||
|
const { useRef, useEffect } = React;
|
||||||
|
|
||||||
|
function Dialog({ dismissKey, closeText = 'Close', blocking = false, ...rest }) {
|
||||||
|
const dialogRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
if(!dismissKey || !localStorage.getItem(dismissKey)) {
|
||||||
|
blocking ? dialogRef.current?.showModal() : dialogRef.current?.show();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const dismiss = ()=>{
|
||||||
|
dismissKey && localStorage.setItem(dismissKey, true);
|
||||||
|
dialogRef.current?.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<dialog ref={dialogRef} onCancel={dismiss} {...rest}>
|
||||||
|
{rest.children}
|
||||||
|
<button className='dismiss' onClick={dismiss}>
|
||||||
|
{closeText}
|
||||||
|
</button>
|
||||||
|
</dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Dialog;
|
||||||
@@ -1,256 +1,238 @@
|
|||||||
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
||||||
require('./brewRenderer.less');
|
require('./brewRenderer.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const { useState, useRef, useEffect } = React;
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
|
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
|
||||||
const Markdown = require('naturalcrit/markdown.js');
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
const ErrorBar = require('./errorBar/errorBar.jsx');
|
const ErrorBar = require('./errorBar/errorBar.jsx');
|
||||||
|
const ToolBar = require('./toolBar/toolBar.jsx');
|
||||||
|
|
||||||
//TODO: move to the brew renderer
|
//TODO: move to the brew renderer
|
||||||
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
|
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
|
||||||
const NotificationPopup = require('./notificationPopup/notificationPopup.jsx');
|
const NotificationPopup = require('./notificationPopup/notificationPopup.jsx');
|
||||||
const Frame = require('react-frame-component').default;
|
const Frame = require('react-frame-component').default;
|
||||||
|
const dedent = require('dedent-tabs').default;
|
||||||
|
const { printCurrentBrew } = require('../../../shared/helpers.js');
|
||||||
|
|
||||||
const Themes = require('themes/themes.json');
|
const DOMPurify = require('dompurify');
|
||||||
|
const purifyConfig = { FORCE_BODY: true, SANITIZE_DOM: false };
|
||||||
|
|
||||||
const PAGE_HEIGHT = 1056;
|
const PAGE_HEIGHT = 1056;
|
||||||
const PPR_THRESHOLD = 50;
|
|
||||||
|
|
||||||
const BrewRenderer = createClass({
|
const INITIAL_CONTENT = dedent`
|
||||||
displayName : 'BrewRenderer',
|
<!DOCTYPE html><html><head>
|
||||||
getDefaultProps : function() {
|
<link href="//use.fontawesome.com/releases/v6.5.1/css/all.css" rel="stylesheet" type="text/css" />
|
||||||
return {
|
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
||||||
|
<link href='/homebrew/bundle.css' type="text/css" rel='stylesheet' />
|
||||||
|
<base target=_blank>
|
||||||
|
</head><body style='overflow: hidden'><div></div></body></html>`;
|
||||||
|
|
||||||
|
//v=====----------------------< Brew Page Component >---------------------=====v//
|
||||||
|
const BrewPage = (props)=>{
|
||||||
|
props = {
|
||||||
|
contents : '',
|
||||||
|
index : 0,
|
||||||
|
...props
|
||||||
|
};
|
||||||
|
const cleanText = props.contents; //DOMPurify.sanitize(props.contents, purifyConfig);
|
||||||
|
return <div className={props.className} id={`p${props.index + 1}`} >
|
||||||
|
<div className='columnWrapper' dangerouslySetInnerHTML={{ __html: cleanText }} />
|
||||||
|
</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//v=====--------------------< Brew Renderer Component >-------------------=====v//
|
||||||
|
const renderedPages = [];
|
||||||
|
let rawPages = [];
|
||||||
|
|
||||||
|
const BrewRenderer = (props)=>{
|
||||||
|
props = {
|
||||||
text : '',
|
text : '',
|
||||||
style : '',
|
style : '',
|
||||||
renderer : 'legacy',
|
renderer : 'legacy',
|
||||||
theme : '5ePHB',
|
theme : '5ePHB',
|
||||||
lang : '',
|
lang : '',
|
||||||
errors : []
|
errors : [],
|
||||||
|
currentEditorPage : 0,
|
||||||
|
themeBundle : {},
|
||||||
|
...props
|
||||||
};
|
};
|
||||||
},
|
|
||||||
getInitialState : function() {
|
|
||||||
let pages;
|
|
||||||
if(this.props.renderer == 'legacy') {
|
|
||||||
pages = this.props.text.split('\\page');
|
|
||||||
} else {
|
|
||||||
pages = this.props.text.split(/^\\page$/gm);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
const [state, setState] = useState({
|
||||||
viewablePageNumber : 0,
|
height : PAGE_HEIGHT,
|
||||||
height : 0,
|
|
||||||
isMounted : false,
|
isMounted : false,
|
||||||
|
|
||||||
pages : pages,
|
|
||||||
usePPR : pages.length >= PPR_THRESHOLD,
|
|
||||||
visibility : 'hidden',
|
visibility : 'hidden',
|
||||||
initialContent : `<!DOCTYPE html><html><head>
|
zoom : 100,
|
||||||
<link href="//use.fontawesome.com/releases/v5.15.1/css/all.css" rel="stylesheet" />
|
currentPageNumber : 1,
|
||||||
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
});
|
||||||
<link href='/homebrew/bundle.css' rel='stylesheet' />
|
|
||||||
<base target=_blank>
|
|
||||||
</head><body style='overflow: hidden'><div></div></body></html>`
|
|
||||||
};
|
|
||||||
},
|
|
||||||
height : 0,
|
|
||||||
lastRender : <div></div>,
|
|
||||||
|
|
||||||
componentWillUnmount : function() {
|
const mainRef = useRef(null);
|
||||||
window.removeEventListener('resize', this.updateSize);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidUpdate : function(prevProps) {
|
if(props.renderer == 'legacy') {
|
||||||
if(prevProps.text !== this.props.text) {
|
rawPages = props.text.split('\\page');
|
||||||
let pages;
|
|
||||||
if(this.props.renderer == 'legacy') {
|
|
||||||
pages = this.props.text.split('\\page');
|
|
||||||
} else {
|
} else {
|
||||||
pages = this.props.text.split(/^\\page$/gm);
|
rawPages = props.text.split(/^\\page$/gm);
|
||||||
}
|
}
|
||||||
this.setState({
|
|
||||||
pages : pages,
|
|
||||||
usePPR : pages.length >= PPR_THRESHOLD
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
updateSize : function() {
|
useEffect(()=>{ // Unmounting steps
|
||||||
this.setState({
|
return ()=>{window.removeEventListener('resize', updateSize);};
|
||||||
height : this.refs.main.parentNode.clientHeight,
|
}, []);
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleScroll : function(e){
|
const updateSize = ()=>{
|
||||||
const target = e.target;
|
setState((prevState)=>({
|
||||||
this.setState((prevState)=>({
|
...prevState,
|
||||||
viewablePageNumber : Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length)
|
height : mainRef.current.parentNode.clientHeight,
|
||||||
}));
|
}));
|
||||||
},
|
};
|
||||||
|
|
||||||
shouldRender : function(pageText, index){
|
const getCurrentPage = (e)=>{
|
||||||
if(!this.state.isMounted) return false;
|
const { scrollTop, clientHeight, scrollHeight } = e.target;
|
||||||
|
const totalScrollableHeight = scrollHeight - clientHeight;
|
||||||
|
const currentPageNumber = Math.ceil((scrollTop / totalScrollableHeight) * rawPages.length);
|
||||||
|
|
||||||
const viewIndex = this.state.viewablePageNumber;
|
setState((prevState)=>({
|
||||||
if(index == viewIndex - 3) return true;
|
...prevState,
|
||||||
if(index == viewIndex - 2) return true;
|
currentPageNumber : currentPageNumber || 1
|
||||||
if(index == viewIndex - 1) return true;
|
}));
|
||||||
if(index == viewIndex) return true;
|
};
|
||||||
if(index == viewIndex + 1) return true;
|
|
||||||
if(index == viewIndex + 2) return true;
|
|
||||||
if(index == viewIndex + 3) return true;
|
|
||||||
|
|
||||||
//Check for style tages
|
const isInView = (index)=>{
|
||||||
if(pageText.indexOf('<style>') !== -1) return true;
|
if(!state.isMounted)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(index == props.currentEditorPage) //Already rendered before this step
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(Math.abs(index - state.currentPageNumber) <= 3)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
};
|
||||||
|
|
||||||
sanitizeScriptTags : function(content) {
|
const renderDummyPage = (index)=>{
|
||||||
return content
|
|
||||||
.replace(/<script/ig, '<script')
|
|
||||||
.replace(/<\/script>/ig, '</script>');
|
|
||||||
},
|
|
||||||
|
|
||||||
renderPageInfo : function(){
|
|
||||||
return <div className='pageInfo' ref='main'>
|
|
||||||
<div>
|
|
||||||
{this.props.renderer}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{this.state.viewablePageNumber + 1} / {this.state.pages.length}
|
|
||||||
</div>
|
|
||||||
</div>;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderPPRmsg : function(){
|
|
||||||
if(!this.state.usePPR) return;
|
|
||||||
|
|
||||||
return <div className='ppr_msg'>
|
|
||||||
Partial Page Renderer is enabled, because your brew is so large. May affect rendering.
|
|
||||||
</div>;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderDummyPage : function(index){
|
|
||||||
return <div className='phb page' id={`p${index + 1}`} key={index}>
|
return <div className='phb page' id={`p${index + 1}`} key={index}>
|
||||||
<i className='fas fa-spinner fa-spin' />
|
<i className='fas fa-spinner fa-spin' />
|
||||||
</div>;
|
</div>;
|
||||||
},
|
};
|
||||||
|
|
||||||
renderStyle : function() {
|
const renderStyle = ()=>{
|
||||||
if(!this.props.style) return;
|
const cleanStyle = props.style; //DOMPurify.sanitize(props.style, purifyConfig);
|
||||||
const cleanStyle = this.sanitizeScriptTags(this.props.style);
|
const themeStyles = props.themeBundle?.joinedStyles ?? '<style>@import url("/themes/V3/Blank/style.css");</style>';
|
||||||
//return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style>@layer styleTab {\n${this.sanitizeScriptTags(this.props.style)}\n} </style>` }} />;
|
return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `${themeStyles} \n\n <style> ${cleanStyle} </style>` }} />;
|
||||||
return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style> ${cleanStyle} </style>` }} />;
|
};
|
||||||
},
|
|
||||||
|
|
||||||
renderPage : function(pageText, index){
|
const renderPage = (pageText, index)=>{
|
||||||
let cleanPageText = this.sanitizeScriptTags(pageText);
|
if(props.renderer == 'legacy') {
|
||||||
if(this.props.renderer == 'legacy')
|
const html = MarkdownLegacy.render(pageText);
|
||||||
return <div className='phb page' id={`p${index + 1}`} dangerouslySetInnerHTML={{ __html: MarkdownLegacy.render(cleanPageText) }} key={index} />;
|
return <BrewPage className='page phb' index={index} key={index} contents={html} />;
|
||||||
else {
|
|
||||||
cleanPageText += `\n\n \n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear)
|
|
||||||
return (
|
|
||||||
<div className='page' id={`p${index + 1}`} key={index} >
|
|
||||||
<div className='columnWrapper' dangerouslySetInnerHTML={{ __html: Markdown.render(cleanPageText) }} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
renderPages : function(){
|
|
||||||
if(this.state.usePPR){
|
|
||||||
return _.map(this.state.pages, (page, index)=>{
|
|
||||||
if(this.shouldRender(page, index) && typeof window !== 'undefined'){
|
|
||||||
return this.renderPage(page, index);
|
|
||||||
} else {
|
} else {
|
||||||
return this.renderDummyPage(index);
|
pageText += `\n\n \n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear)
|
||||||
|
const html = Markdown.render(pageText, index);
|
||||||
|
return <BrewPage className='page' index={index} key={index} contents={html} />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderPages = ()=>{
|
||||||
|
if(props.errors && props.errors.length)
|
||||||
|
return renderedPages;
|
||||||
|
|
||||||
|
if(rawPages.length != renderedPages.length) // Re-render all pages when page count changes
|
||||||
|
renderedPages.length = 0;
|
||||||
|
|
||||||
|
// Render currently-edited page first so cross-page effects (variables, links) can propagate out first
|
||||||
|
renderedPages[props.currentEditorPage] = renderPage(rawPages[props.currentEditorPage], props.currentEditorPage);
|
||||||
|
|
||||||
|
_.forEach(rawPages, (page, index)=>{
|
||||||
|
if((isInView(index) || !renderedPages[index]) && typeof window !== 'undefined'){
|
||||||
|
renderedPages[index] = renderPage(page, index); // Render any page not yet rendered, but only re-render those in PPR range
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
return renderedPages;
|
||||||
if(this.props.errors && this.props.errors.length) return this.lastRender;
|
};
|
||||||
this.lastRender = _.map(this.state.pages, (page, index)=>{
|
|
||||||
if(typeof window !== 'undefined') {
|
|
||||||
return this.renderPage(page, index);
|
|
||||||
} else {
|
|
||||||
return this.renderDummyPage(index);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return this.lastRender;
|
|
||||||
},
|
|
||||||
|
|
||||||
frameDidMount : function(){ //This triggers when iFrame finishes internal "componentDidMount"
|
const handleControlKeys = (e)=>{
|
||||||
|
if(!(e.ctrlKey || e.metaKey)) return;
|
||||||
|
const P_KEY = 80;
|
||||||
|
if(e.keyCode == P_KEY && props.allowPrint) printCurrentBrew();
|
||||||
|
if(e.keyCode == P_KEY) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
|
||||||
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
|
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
|
||||||
this.updateSize();
|
updateSize();
|
||||||
window.addEventListener('resize', this.updateSize);
|
window.addEventListener('resize', updateSize);
|
||||||
this.renderPages(); //Make sure page is renderable before showing
|
renderPages(); //Make sure page is renderable before showing
|
||||||
this.setState({
|
setState((prevState)=>({
|
||||||
|
...prevState,
|
||||||
isMounted : true,
|
isMounted : true,
|
||||||
visibility : 'visible'
|
visibility : 'visible'
|
||||||
});
|
}));
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
};
|
||||||
|
|
||||||
emitClick : function(){
|
const emitClick = ()=>{ // Allow clicks inside iFrame to interact with dropdowns, etc. from outside
|
||||||
// console.log('iFrame clicked');
|
|
||||||
if(!window || !document) return;
|
if(!window || !document) return;
|
||||||
document.dispatchEvent(new MouseEvent('click'));
|
document.dispatchEvent(new MouseEvent('click'));
|
||||||
},
|
};
|
||||||
|
|
||||||
|
//Toolbar settings:
|
||||||
|
const handleZoom = (newZoom)=>{
|
||||||
|
setState((prevState)=>({
|
||||||
|
...prevState,
|
||||||
|
zoom : newZoom
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
render : function(){
|
|
||||||
//render in iFrame so broken code doesn't crash the site.
|
|
||||||
//Also render dummy page while iframe is mounting.
|
|
||||||
const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy';
|
|
||||||
const themePath = this.props.theme ?? '5ePHB';
|
|
||||||
const baseThemePath = Themes[rendererPath][themePath].baseTheme;
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<>
|
||||||
{!this.state.isMounted
|
{/*render dummy page while iFrame is mounting.*/}
|
||||||
? <div className='brewRenderer' onScroll={this.handleScroll}>
|
{!state.isMounted
|
||||||
<div className='pages' ref='pages'>
|
? <div className='brewRenderer' onScroll={getCurrentPage}>
|
||||||
{this.renderDummyPage(1)}
|
<div className='pages'>
|
||||||
|
{renderDummyPage(1)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
<Frame id='BrewRenderer' initialContent={this.state.initialContent}
|
<ErrorBar errors={props.errors} />
|
||||||
style={{ width: '100%', height: '100%', visibility: this.state.visibility }}
|
<div className='popups' ref={mainRef}>
|
||||||
contentDidMount={this.frameDidMount}
|
|
||||||
onClick={()=>{this.emitClick();}}
|
|
||||||
>
|
|
||||||
<div className={'brewRenderer'}
|
|
||||||
onScroll={this.handleScroll}
|
|
||||||
style={{ height: this.state.height }}>
|
|
||||||
|
|
||||||
<ErrorBar errors={this.props.errors} />
|
|
||||||
<div className='popups'>
|
|
||||||
<RenderWarnings />
|
<RenderWarnings />
|
||||||
<NotificationPopup />
|
<NotificationPopup />
|
||||||
</div>
|
</div>
|
||||||
<link href={`/themes/${rendererPath}/Blank/style.css`} rel='stylesheet'/>
|
|
||||||
{baseThemePath &&
|
<ToolBar onZoomChange={handleZoom} currentPage={state.currentPageNumber} totalPages={rawPages.length}/>
|
||||||
<link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} rel='stylesheet'/>
|
|
||||||
}
|
{/*render in iFrame so broken code doesn't crash the site.*/}
|
||||||
<link href={`/themes/${rendererPath}/${themePath}/style.css`} rel='stylesheet'/>
|
<Frame id='BrewRenderer' initialContent={INITIAL_CONTENT}
|
||||||
|
style={{ width: '100%', height: '100%', visibility: state.visibility }}
|
||||||
|
contentDidMount={frameDidMount}
|
||||||
|
onClick={()=>{emitClick();}}
|
||||||
|
>
|
||||||
|
<div className={'brewRenderer'}
|
||||||
|
onScroll={getCurrentPage}
|
||||||
|
onKeyDown={handleControlKeys}
|
||||||
|
tabIndex={-1}
|
||||||
|
style={{ height: state.height }}>
|
||||||
|
|
||||||
{/* Apply CSS from Style tab and render pages from Markdown tab */}
|
{/* Apply CSS from Style tab and render pages from Markdown tab */}
|
||||||
{this.state.isMounted
|
{state.isMounted
|
||||||
&&
|
&&
|
||||||
<>
|
<>
|
||||||
{this.renderStyle()}
|
{renderStyle()}
|
||||||
<div className='pages' ref='pages' lang={`${this.props.lang || 'en'}`}>
|
<div className='pages' lang={`${props.lang || 'en'}`} style={{ zoom: `${state.zoom}%` }}>
|
||||||
{this.renderPages()}
|
{renderPages()}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</Frame>
|
</Frame>
|
||||||
{this.renderPageInfo()}
|
</>
|
||||||
{this.renderPPRmsg()}
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = BrewRenderer;
|
module.exports = BrewRenderer;
|
||||||
|
|||||||
@@ -1,46 +1,45 @@
|
|||||||
@import (multiple, less) 'shared/naturalcrit/styles/reset.less';
|
@import (multiple, less) 'shared/naturalcrit/styles/reset.less';
|
||||||
|
|
||||||
.brewRenderer {
|
.brewRenderer {
|
||||||
will-change : transform;
|
|
||||||
overflow-y : scroll;
|
overflow-y : scroll;
|
||||||
.pages{
|
will-change : transform;
|
||||||
|
padding-top : 30px;
|
||||||
|
:where(.pages) {
|
||||||
margin : 30px 0px;
|
margin : 30px 0px;
|
||||||
&>.page{
|
& > :where(.page) {
|
||||||
|
width : 215.9mm;
|
||||||
|
height : 279.4mm;
|
||||||
margin-right : auto;
|
margin-right : auto;
|
||||||
margin-bottom : 30px;
|
margin-bottom : 30px;
|
||||||
margin-left : auto;
|
margin-left : auto;
|
||||||
box-shadow : 1px 4px 14px #000;
|
box-shadow : 1px 4px 14px #000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width : 20px;
|
||||||
|
&:horizontal {
|
||||||
|
width : auto;
|
||||||
|
height : 20px;
|
||||||
|
}
|
||||||
|
&-thumb {
|
||||||
|
background : linear-gradient(90deg, #D3C1AF 15px, #00000000 15px);
|
||||||
|
&:horizontal { background : linear-gradient(0deg, #D3C1AF 15px, #00000000 15px); }
|
||||||
|
}
|
||||||
|
&-corner { visibility : hidden; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pane { position : relative; }
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
.toolBar { display : none; }
|
||||||
|
.brewRenderer {
|
||||||
|
height : 100%;
|
||||||
|
padding-top : unset;
|
||||||
|
overflow-y : unset;
|
||||||
|
.pages {
|
||||||
|
margin : 0px;
|
||||||
|
& > .page { box-shadow : unset; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pane{
|
|
||||||
position : relative;
|
|
||||||
}
|
|
||||||
.pageInfo{
|
|
||||||
position : absolute;
|
|
||||||
right : 17px;
|
|
||||||
bottom : 0;
|
|
||||||
z-index : 1000;
|
|
||||||
background-color : #333;
|
|
||||||
font-size : 10px;
|
|
||||||
font-weight : 800;
|
|
||||||
color : white;
|
|
||||||
div {
|
|
||||||
display: inline-block;
|
|
||||||
padding : 8px 10px;
|
|
||||||
&:not(:last-child){
|
|
||||||
border-right: 1px solid #666;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.ppr_msg{
|
|
||||||
position : absolute;
|
|
||||||
left : 0px;
|
|
||||||
bottom : 0;
|
|
||||||
z-index : 1000;
|
|
||||||
padding : 8px 10px;
|
|
||||||
background-color : #333;
|
|
||||||
font-size : 10px;
|
|
||||||
font-weight : 800;
|
|
||||||
color : white;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ require('./errorBar.less');
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const ErrorBar = createClass({
|
const ErrorBar = createClass({
|
||||||
displayName : 'ErrorBar',
|
displayName : 'ErrorBar',
|
||||||
|
|||||||
@@ -1,37 +1,26 @@
|
|||||||
require('./notificationPopup.less');
|
require('./notificationPopup.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames'); //Unused variable
|
|
||||||
|
|
||||||
const DISMISS_KEY = 'dismiss_notification12-04-23';
|
import Dialog from '../../../components/dialog.jsx';
|
||||||
|
|
||||||
const NotificationPopup = createClass({
|
const DISMISS_KEY = 'dismiss_notification04-09-24';
|
||||||
displayName : 'NotificationPopup',
|
const DISMISS_BUTTON = <i className='fas fa-times dismiss' />;
|
||||||
getInitialState : function() {
|
|
||||||
return {
|
const NotificationPopup = ()=>{
|
||||||
notifications : {}
|
return <Dialog className='notificationPopup' dismissKey={DISMISS_KEY} closeText={DISMISS_BUTTON} >
|
||||||
};
|
<div className='header'>
|
||||||
},
|
<i className='fas fa-info-circle info'></i>
|
||||||
componentDidMount : function() {
|
<h3>Notice</h3>
|
||||||
this.checkNotifications();
|
<small>This website is always improving and we are still adding new features and squashing bugs. Keep the following in mind:</small>
|
||||||
window.addEventListener('resize', this.checkNotifications);
|
</div>
|
||||||
},
|
<ul>
|
||||||
componentWillUnmount : function() {
|
<li key='Vault'>
|
||||||
window.removeEventListener('resize', this.checkNotifications);
|
<em>Search brews with our new page!</em><br />
|
||||||
},
|
We have been working very hard in making this possible, now you can share your work and look at it in the new <a href="/vault">Vault</a> page!
|
||||||
notifications : {
|
All PUBLISHED brews will be available to anyone searching there, by title or author, and filtering by renderer.
|
||||||
psa : function(){
|
|
||||||
return (
|
More features will be coming.
|
||||||
<>
|
|
||||||
<li key='psa'>
|
|
||||||
<em>Broken default logo on <b>CoverPage</b> </em> <br />
|
|
||||||
If you have used the Cover Page snippet and notice the Naturalcrit
|
|
||||||
logo is showing as a broken image, this is due to some small tweaks
|
|
||||||
of this BETA feature. To fix the logo in your cover page, rename
|
|
||||||
the image link <b>"/assets/naturalCritLogoRed.svg"</b>. Remember
|
|
||||||
that any snippet marked "BETA" may have a similar change in the
|
|
||||||
future as we encounter any bugs or reworks.
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li key='googleDriveFolder'>
|
<li key='googleDriveFolder'>
|
||||||
@@ -50,35 +39,8 @@ const NotificationPopup = createClass({
|
|||||||
See the FAQ
|
See the FAQ
|
||||||
</a> to learn how to avoid losing your work!
|
</a> to learn how to avoid losing your work!
|
||||||
</li>
|
</li>
|
||||||
</>
|
</ul>
|
||||||
);
|
</Dialog>;
|
||||||
}
|
};
|
||||||
},
|
|
||||||
checkNotifications : function(){
|
|
||||||
const hideDismiss = localStorage.getItem(DISMISS_KEY);
|
|
||||||
if(hideDismiss) return this.setState({ notifications: {} });
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
notifications : _.mapValues(this.notifications, (fn)=>{ return fn(); }) //Convert notification functions into their return text value
|
|
||||||
});
|
|
||||||
},
|
|
||||||
dismiss : function(){
|
|
||||||
localStorage.setItem(DISMISS_KEY, true);
|
|
||||||
this.checkNotifications();
|
|
||||||
},
|
|
||||||
render : function(){
|
|
||||||
if(_.isEmpty(this.state.notifications)) return null;
|
|
||||||
|
|
||||||
return <div className='notificationPopup'>
|
|
||||||
<i className='fas fa-times dismiss' onClick={this.dismiss}/>
|
|
||||||
<i className='fas fa-info-circle info' />
|
|
||||||
<div className='header'>
|
|
||||||
<h3>Notice</h3>
|
|
||||||
<small>This website is always improving and we are still adding new features and squashing bugs. Keep the following in mind:</small>
|
|
||||||
</div>
|
|
||||||
<ul>{_.values(this.state.notifications)}</ul>
|
|
||||||
</div>;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = NotificationPopup;
|
module.exports = NotificationPopup;
|
||||||
|
|||||||
@@ -1,47 +1,46 @@
|
|||||||
.popups {
|
.popups {
|
||||||
position : fixed;
|
position : fixed;
|
||||||
top : @navbarHeight;
|
top : calc(@navbarHeight + @viewerToolsHeight);
|
||||||
right : 15px;
|
right : 24px;
|
||||||
z-index : 10001;
|
z-index : 10001;
|
||||||
width : 450px;
|
width : 450px;
|
||||||
|
margin-top : 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notificationPopup {
|
.notificationPopup {
|
||||||
position : relative;
|
position : relative;
|
||||||
display : inline-block;
|
|
||||||
width : 100%;
|
width : 100%;
|
||||||
padding : 15px;
|
padding : 15px;
|
||||||
padding-bottom : 10px;
|
padding-bottom : 10px;
|
||||||
padding-left : 25px;
|
padding-left : 25px;
|
||||||
background-color : @blue;
|
|
||||||
color : white;
|
color : white;
|
||||||
|
background-color : @blue;
|
||||||
|
border : none;
|
||||||
|
&[open] { display : inline-block; }
|
||||||
a {
|
a {
|
||||||
color : #e0e5c1;
|
|
||||||
font-weight : 800;
|
font-weight : 800;
|
||||||
|
color : #E0E5C1;
|
||||||
}
|
}
|
||||||
i.info {
|
i.info {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 12px;
|
top : 12px;
|
||||||
left : 12px;
|
left : 12px;
|
||||||
opacity : 0.8;
|
|
||||||
font-size : 2.5em;
|
font-size : 2.5em;
|
||||||
|
opacity : 0.8;
|
||||||
}
|
}
|
||||||
i.dismiss{
|
button.dismiss {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 10px;
|
top : 10px;
|
||||||
right : 10px;
|
right : 10px;
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
|
background-color : transparent;
|
||||||
opacity : 0.6;
|
opacity : 0.6;
|
||||||
&:hover{
|
&:hover { opacity : 1; }
|
||||||
opacity : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
padding-left : 50px;
|
|
||||||
}
|
}
|
||||||
|
.header { padding-left : 50px; }
|
||||||
small {
|
small {
|
||||||
opacity : 0.7;
|
|
||||||
font-size : 0.6em;
|
font-size : 0.6em;
|
||||||
|
opacity : 0.7;
|
||||||
}
|
}
|
||||||
h3 {
|
h3 {
|
||||||
font-size : 1.1em;
|
font-size : 1.1em;
|
||||||
@@ -53,12 +52,10 @@
|
|||||||
list-style-position : outside;
|
list-style-position : outside;
|
||||||
list-style-type : disc;
|
list-style-type : disc;
|
||||||
li {
|
li {
|
||||||
|
margin-top : 1.4em;
|
||||||
font-size : 0.8em;
|
font-size : 0.8em;
|
||||||
line-height : 1.4em;
|
line-height : 1.4em;
|
||||||
margin-top : 1.4em;
|
em { font-weight : 800; }
|
||||||
em{
|
|
||||||
font-weight : 800;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
162
client/homebrew/brewRenderer/toolBar/toolBar.jsx
Normal file
162
client/homebrew/brewRenderer/toolBar/toolBar.jsx
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
require('./toolBar.less');
|
||||||
|
const React = require('react');
|
||||||
|
const { useState, useEffect } = React;
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
|
||||||
|
const MAX_ZOOM = 300;
|
||||||
|
const MIN_ZOOM = 10;
|
||||||
|
|
||||||
|
const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
|
||||||
|
|
||||||
|
const [zoomLevel, setZoomLevel] = useState(100);
|
||||||
|
const [pageNum, setPageNum] = useState(currentPage);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
onZoomChange(zoomLevel);
|
||||||
|
}, [zoomLevel]);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
setPageNum(currentPage);
|
||||||
|
}, [currentPage]);
|
||||||
|
|
||||||
|
const handleZoomButton = (zoom)=>{
|
||||||
|
setZoomLevel(_.round(_.clamp(zoom, MIN_ZOOM, MAX_ZOOM)));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePageInput = (pageInput)=>{
|
||||||
|
if(/[0-9]/.test(pageInput))
|
||||||
|
setPageNum(parseInt(pageInput)); // input type is 'text', so `page` comes in as a string, not number.
|
||||||
|
};
|
||||||
|
|
||||||
|
const scrollToPage = (pageNumber)=>{
|
||||||
|
pageNumber = _.clamp(pageNumber, 1, totalPages);
|
||||||
|
const iframe = document.getElementById('BrewRenderer');
|
||||||
|
const brewRenderer = iframe?.contentWindow?.document.querySelector('.brewRenderer');
|
||||||
|
const page = brewRenderer?.querySelector(`#p${pageNumber}`);
|
||||||
|
page?.scrollIntoView({ block: 'start' });
|
||||||
|
setPageNum(pageNumber);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const calculateChange = (mode)=>{
|
||||||
|
const iframe = document.getElementById('BrewRenderer');
|
||||||
|
const iframeWidth = iframe.getBoundingClientRect().width;
|
||||||
|
const iframeHeight = iframe.getBoundingClientRect().height;
|
||||||
|
const pages = iframe.contentWindow.document.getElementsByClassName('page');
|
||||||
|
|
||||||
|
let desiredZoom = 0;
|
||||||
|
|
||||||
|
if(mode == 'fill'){
|
||||||
|
// find widest page, in case pages are different widths, so that the zoom is adapted to not cut the widest page off screen.
|
||||||
|
const widestPage = _.maxBy([...pages], 'offsetWidth').offsetWidth;
|
||||||
|
|
||||||
|
desiredZoom = (iframeWidth / widestPage) * 100;
|
||||||
|
|
||||||
|
} else if(mode == 'fit'){
|
||||||
|
// find the page with the largest single dim (height or width) so that zoom can be adapted to fit it.
|
||||||
|
const minDimRatio = [...pages].reduce((minRatio, page) => Math.min(minRatio, iframeWidth / page.offsetWidth, iframeHeight / page.offsetHeight), Infinity);
|
||||||
|
|
||||||
|
desiredZoom = minDimRatio * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
const margin = 5; // extra space so page isn't edge to edge (not truly "to fill")
|
||||||
|
|
||||||
|
const deltaZoom = (desiredZoom - zoomLevel) - margin;
|
||||||
|
return deltaZoom;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='toolBar'>
|
||||||
|
{/*v=====----------------------< Zoom Controls >---------------------=====v*/}
|
||||||
|
<div className='group'>
|
||||||
|
<button
|
||||||
|
id='fill-width'
|
||||||
|
className='tool'
|
||||||
|
onClick={()=>handleZoomButton(zoomLevel + calculateChange('fill'))}
|
||||||
|
>
|
||||||
|
<i className='fac fit-width' />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
id='zoom-to-fit'
|
||||||
|
className='tool'
|
||||||
|
onClick={()=>handleZoomButton(zoomLevel + calculateChange('fit'))}
|
||||||
|
>
|
||||||
|
<i className='fac zoom-to-fit' />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
id='zoom-out'
|
||||||
|
className='tool'
|
||||||
|
onClick={()=>handleZoomButton(zoomLevel - 20)}
|
||||||
|
disabled={zoomLevel <= MIN_ZOOM}
|
||||||
|
>
|
||||||
|
<i className='fas fa-magnifying-glass-minus' />
|
||||||
|
</button>
|
||||||
|
<input
|
||||||
|
id='zoom-slider'
|
||||||
|
className='range-input tool'
|
||||||
|
type='range'
|
||||||
|
name='zoom'
|
||||||
|
list='zoomLevels'
|
||||||
|
min={MIN_ZOOM}
|
||||||
|
max={MAX_ZOOM}
|
||||||
|
step='1'
|
||||||
|
value={zoomLevel}
|
||||||
|
onChange={(e)=>handleZoomButton(parseInt(e.target.value))}
|
||||||
|
/>
|
||||||
|
<datalist id='zoomLevels'>
|
||||||
|
<option value='100' />
|
||||||
|
</datalist>
|
||||||
|
|
||||||
|
<button
|
||||||
|
id='zoom-in'
|
||||||
|
className='tool'
|
||||||
|
onClick={()=>handleZoomButton(zoomLevel + 20)}
|
||||||
|
disabled={zoomLevel >= MAX_ZOOM}
|
||||||
|
>
|
||||||
|
<i className='fas fa-magnifying-glass-plus' />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/*v=====----------------------< Page Controls >---------------------=====v*/}
|
||||||
|
<div className='group'>
|
||||||
|
<button
|
||||||
|
id='previous-page'
|
||||||
|
className='previousPage tool'
|
||||||
|
onClick={()=>scrollToPage(pageNum - 1)}
|
||||||
|
disabled={pageNum <= 1}
|
||||||
|
>
|
||||||
|
<i className='fas fa-arrow-left'></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div className='tool'>
|
||||||
|
<input
|
||||||
|
id='page-input'
|
||||||
|
className='text-input'
|
||||||
|
type='text'
|
||||||
|
name='page'
|
||||||
|
inputMode='numeric'
|
||||||
|
pattern='[0-9]'
|
||||||
|
value={pageNum}
|
||||||
|
onClick={(e)=>e.target.select()}
|
||||||
|
onChange={(e)=>handlePageInput(e.target.value)}
|
||||||
|
onBlur={()=>scrollToPage(pageNum)}
|
||||||
|
onKeyDown={(e)=>e.key == 'Enter' && scrollToPage(pageNum)}
|
||||||
|
/>
|
||||||
|
<span id='page-count'>/ {totalPages}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
id='next-page'
|
||||||
|
className='tool'
|
||||||
|
onClick={()=>scrollToPage(pageNum + 1)}
|
||||||
|
disabled={pageNum >= totalPages}
|
||||||
|
>
|
||||||
|
<i className='fas fa-arrow-right'></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ToolBar;
|
||||||
103
client/homebrew/brewRenderer/toolBar/toolBar.less
Normal file
103
client/homebrew/brewRenderer/toolBar/toolBar.less
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
@import (less) './client/icons/customIcons.less';
|
||||||
|
|
||||||
|
.toolBar {
|
||||||
|
position : absolute;
|
||||||
|
z-index : 1;
|
||||||
|
box-sizing : border-box;
|
||||||
|
display : flex;
|
||||||
|
flex-wrap : wrap;
|
||||||
|
gap : 8px 30px;
|
||||||
|
align-items : center;
|
||||||
|
justify-content : center;
|
||||||
|
width : 100%;
|
||||||
|
height : auto;
|
||||||
|
padding : 2px 0;
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
color : #CCCCCC;
|
||||||
|
background-color : #555555;
|
||||||
|
|
||||||
|
.group {
|
||||||
|
box-sizing : border-box;
|
||||||
|
display : flex;
|
||||||
|
gap : 0 3px;
|
||||||
|
align-items : center;
|
||||||
|
justify-content : center;
|
||||||
|
height : 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool {
|
||||||
|
display : flex;
|
||||||
|
align-items : center;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
position : relative;
|
||||||
|
height : 1.5em;
|
||||||
|
padding : 2px 5px;
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
color : #000000;
|
||||||
|
background : #EEEEEE;
|
||||||
|
border : 1px solid gray;
|
||||||
|
&:focus { outline : 1px solid #D3D3D3; }
|
||||||
|
|
||||||
|
// `.range-input` if generic to all range inputs, or `#zoom-slider` if only for zoom slider
|
||||||
|
&.range-input {
|
||||||
|
padding : 2px 0;
|
||||||
|
color : #D3D3D3;
|
||||||
|
accent-color : #D3D3D3;
|
||||||
|
|
||||||
|
&::-webkit-slider-thumb, &::-moz-slider-thumb {
|
||||||
|
width : 5px;
|
||||||
|
height : 5px;
|
||||||
|
cursor : pointer;
|
||||||
|
outline : none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover::after {
|
||||||
|
position : absolute;
|
||||||
|
bottom : -30px;
|
||||||
|
left : 50%;
|
||||||
|
z-index : 1;
|
||||||
|
display : grid;
|
||||||
|
place-items : center;
|
||||||
|
width : 4ch;
|
||||||
|
height : 1.2lh;
|
||||||
|
pointer-events : none;
|
||||||
|
content : attr(value);
|
||||||
|
background-color : #555555;
|
||||||
|
border : 1px solid #A1A1A1;
|
||||||
|
transform : translate(-50%, 50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// `.text-input` if generic to all range inputs, or `#page-input` if only for current page input
|
||||||
|
&#page-input {
|
||||||
|
width : 4ch;
|
||||||
|
margin-right : 1ch;
|
||||||
|
text-align : center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
box-sizing : content-box;
|
||||||
|
display : flex;
|
||||||
|
align-items : center;
|
||||||
|
justify-content : center;
|
||||||
|
width : auto;
|
||||||
|
min-width : 46px;
|
||||||
|
height : 100%;
|
||||||
|
padding : 0 0px;
|
||||||
|
font-weight : unset;
|
||||||
|
color : inherit;
|
||||||
|
background-color : unset;
|
||||||
|
&:hover { background-color : #444444; }
|
||||||
|
&:focus { outline : 1px solid #D3D3D3; }
|
||||||
|
&:disabled {
|
||||||
|
color : #777777;
|
||||||
|
background-color : unset !important;
|
||||||
|
}
|
||||||
|
i {
|
||||||
|
font-size:1.2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ const createClass = require('create-react-class');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
const dedent = require('dedent-tabs').default;
|
const dedent = require('dedent-tabs').default;
|
||||||
|
const Markdown = require('../../../shared/naturalcrit/markdown.js');
|
||||||
|
|
||||||
const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx');
|
const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx');
|
||||||
const SnippetBar = require('./snippetbar/snippetbar.jsx');
|
const SnippetBar = require('./snippetbar/snippetbar.jsx');
|
||||||
@@ -47,6 +48,9 @@ const Editor = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editor : React.createRef(null),
|
||||||
|
codeEditor : React.createRef(null),
|
||||||
|
|
||||||
isText : function() {return this.state.view == 'text';},
|
isText : function() {return this.state.view == 'text';},
|
||||||
isStyle : function() {return this.state.view == 'style';},
|
isStyle : function() {return this.state.view == 'style';},
|
||||||
isMeta : function() {return this.state.view == 'meta';},
|
isMeta : function() {return this.state.view == 'meta';},
|
||||||
@@ -55,6 +59,8 @@ const Editor = createClass({
|
|||||||
this.updateEditorSize();
|
this.updateEditorSize();
|
||||||
this.highlightCustomMarkdown();
|
this.highlightCustomMarkdown();
|
||||||
window.addEventListener('resize', this.updateEditorSize);
|
window.addEventListener('resize', this.updateEditorSize);
|
||||||
|
document.getElementById('BrewRenderer').addEventListener('keydown', this.handleControlKeys);
|
||||||
|
document.addEventListener('keydown', this.handleControlKeys);
|
||||||
|
|
||||||
const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY);
|
const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY);
|
||||||
if(editorTheme) {
|
if(editorTheme) {
|
||||||
@@ -78,27 +84,43 @@ const Editor = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleControlKeys : function(e){
|
||||||
|
if(!(e.ctrlKey && e.metaKey)) return;
|
||||||
|
const LEFTARROW_KEY = 37;
|
||||||
|
const RIGHTARROW_KEY = 39;
|
||||||
|
if (e.shiftKey && (e.keyCode == RIGHTARROW_KEY)) this.brewJump();
|
||||||
|
if (e.shiftKey && (e.keyCode == LEFTARROW_KEY)) this.sourceJump();
|
||||||
|
if ((e.keyCode == LEFTARROW_KEY) || (e.keyCode == RIGHTARROW_KEY)) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
updateEditorSize : function() {
|
updateEditorSize : function() {
|
||||||
if(this.refs.codeEditor) {
|
if(this.codeEditor.current) {
|
||||||
let paneHeight = this.refs.main.parentNode.clientHeight;
|
let paneHeight = this.editor.current.parentNode.clientHeight;
|
||||||
paneHeight -= SNIPPETBAR_HEIGHT + 1;
|
paneHeight -= SNIPPETBAR_HEIGHT;
|
||||||
this.refs.codeEditor.codeMirror.setSize(null, paneHeight);
|
this.codeEditor.current.codeMirror.setSize(null, paneHeight);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleInject : function(injectText){
|
handleInject : function(injectText){
|
||||||
this.refs.codeEditor?.injectText(injectText, false);
|
this.codeEditor.current?.injectText(injectText, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleViewChange : function(newView){
|
handleViewChange : function(newView){
|
||||||
this.props.setMoveArrows(newView === 'text');
|
this.props.setMoveArrows(newView === 'text');
|
||||||
this.setState({
|
this.setState({
|
||||||
view : newView
|
view : newView
|
||||||
}, this.updateEditorSize); //TODO: not sure if updateeditorsize needed
|
}, ()=>{
|
||||||
|
this.codeEditor.current?.codeMirror.focus();
|
||||||
|
this.updateEditorSize();
|
||||||
|
}); //TODO: not sure if updateeditorsize needed
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentPage : function(){
|
getCurrentPage : function(){
|
||||||
const lines = this.props.brew.text.split('\n').slice(0, this.refs.codeEditor.getCursorPosition().line + 1);
|
const lines = this.props.brew.text.split('\n').slice(0, this.codeEditor.current.getCursorPosition().line + 1);
|
||||||
return _.reduce(lines, (r, line)=>{
|
return _.reduce(lines, (r, line)=>{
|
||||||
if(
|
if(
|
||||||
(this.props.renderer == 'legacy' && line.indexOf('\\page') !== -1)
|
(this.props.renderer == 'legacy' && line.indexOf('\\page') !== -1)
|
||||||
@@ -110,13 +132,24 @@ const Editor = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
highlightCustomMarkdown : function(){
|
highlightCustomMarkdown : function(){
|
||||||
if(!this.refs.codeEditor) return;
|
if(!this.codeEditor.current) return;
|
||||||
if(this.state.view === 'text') {
|
if(this.state.view === 'text') {
|
||||||
const codeMirror = this.refs.codeEditor.codeMirror;
|
const codeMirror = this.codeEditor.current.codeMirror;
|
||||||
|
|
||||||
codeMirror.operation(()=>{ // Batch CodeMirror styling
|
codeMirror.operation(()=>{ // Batch CodeMirror styling
|
||||||
|
|
||||||
|
const foldLines = [];
|
||||||
|
|
||||||
//reset custom text styles
|
//reset custom text styles
|
||||||
const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding
|
const customHighlights = codeMirror.getAllMarks().filter((mark)=>{
|
||||||
|
// Record details of folded sections
|
||||||
|
if(mark.__isFold) {
|
||||||
|
const fold = mark.find();
|
||||||
|
foldLines.push({from: fold.from?.line, to: fold.to?.line});
|
||||||
|
}
|
||||||
|
return !mark.__isFold;
|
||||||
|
}); //Don't undo code folding
|
||||||
|
|
||||||
for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear();
|
for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear();
|
||||||
|
|
||||||
let editorPageCount = 2; // start page count from page 2
|
let editorPageCount = 2; // start page count from page 2
|
||||||
@@ -128,6 +161,11 @@ const Editor = createClass({
|
|||||||
codeMirror.removeLineClass(lineNumber, 'text');
|
codeMirror.removeLineClass(lineNumber, 'text');
|
||||||
codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash');
|
codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash');
|
||||||
|
|
||||||
|
// Don't process lines inside folded text
|
||||||
|
// If the current lineNumber is inside any folded marks, skip line styling
|
||||||
|
if (foldLines.some(fold => lineNumber >= fold.from && lineNumber <= fold.to))
|
||||||
|
return;
|
||||||
|
|
||||||
// Styling for \page breaks
|
// Styling for \page breaks
|
||||||
if((this.props.renderer == 'legacy' && line.includes('\\page')) ||
|
if((this.props.renderer == 'legacy' && line.includes('\\page')) ||
|
||||||
(this.props.renderer == 'V3' && line.match(/^\\page$/))) {
|
(this.props.renderer == 'V3' && line.match(/^\\page$/))) {
|
||||||
@@ -151,18 +189,43 @@ const Editor = createClass({
|
|||||||
|
|
||||||
// definition lists
|
// definition lists
|
||||||
if(line.includes('::')){
|
if(line.includes('::')){
|
||||||
const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym;
|
if(/^:*$/.test(line) == true){ return };
|
||||||
|
const regex = /^([^\n]*?:?\s?)(::[^\n]*)(?:\n|$)/ymd; // the `d` flag, for match indices, throws an ESLint error.
|
||||||
let match;
|
let match;
|
||||||
while ((match = regex.exec(line)) != null){
|
while ((match = regex.exec(line)) != null){
|
||||||
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[0]) }, { line: lineNumber, ch: line.indexOf(match[0]) + match[0].length }, { className: 'define' });
|
codeMirror.markText({ line: lineNumber, ch: match.indices[0][0] }, { line: lineNumber, ch: match.indices[0][1] }, { className: 'dl-highlight' });
|
||||||
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'term' });
|
codeMirror.markText({ line: lineNumber, ch: match.indices[1][0] }, { line: lineNumber, ch: match.indices[1][1] }, { className: 'dt-highlight' });
|
||||||
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[2]) }, { line: lineNumber, ch: line.indexOf(match[2]) + match[2].length }, { className: 'definition' });
|
codeMirror.markText({ line: lineNumber, ch: match.indices[2][0] }, { line: lineNumber, ch: match.indices[2][1] }, { className: 'dd-highlight' });
|
||||||
|
const ddIndex = match.indices[2][0];
|
||||||
|
let colons = /::/g;
|
||||||
|
let colonMatches = colons.exec(match[2]);
|
||||||
|
if(colonMatches !== null){
|
||||||
|
codeMirror.markText({ line: lineNumber, ch: colonMatches.index + ddIndex }, { line: lineNumber, ch: colonMatches.index + colonMatches[0].length + ddIndex }, { className: 'dl-colon-highlight'} )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscript & Superscript
|
||||||
|
if(line.includes('^')) {
|
||||||
|
let startIndex = line.indexOf('^');
|
||||||
|
const superRegex = /\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/gy;
|
||||||
|
const subRegex = /\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/gy;
|
||||||
|
|
||||||
|
while (startIndex >= 0) {
|
||||||
|
superRegex.lastIndex = subRegex.lastIndex = startIndex;
|
||||||
|
let isSuper = false;
|
||||||
|
let match = subRegex.exec(line) || superRegex.exec(line);
|
||||||
|
if (match) {
|
||||||
|
isSuper = !subRegex.lastIndex;
|
||||||
|
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: isSuper ? 'superscript' : 'subscript' });
|
||||||
|
}
|
||||||
|
startIndex = line.indexOf('^', Math.max(startIndex + 1, subRegex.lastIndex, superRegex.lastIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight injectors {style}
|
// Highlight injectors {style}
|
||||||
if(line.includes('{') && line.includes('}')){
|
if(line.includes('{') && line.includes('}')){
|
||||||
const regex = /(?:^|[^{\n])({(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\2})/gm;
|
const regex = /(?:^|[^{\n])({(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\2})/gm;
|
||||||
let match;
|
let match;
|
||||||
while ((match = regex.exec(line)) != null) {
|
while ((match = regex.exec(line)) != null) {
|
||||||
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'injection' });
|
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'injection' });
|
||||||
@@ -170,7 +233,7 @@ const Editor = createClass({
|
|||||||
}
|
}
|
||||||
// Highlight inline spans {{content}}
|
// Highlight inline spans {{content}}
|
||||||
if(line.includes('{{') && line.includes('}}')){
|
if(line.includes('{{') && line.includes('}}')){
|
||||||
const regex = /{{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1 *|}}/g;
|
const regex = /{{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1 *|}}/g;
|
||||||
let match;
|
let match;
|
||||||
let blockCount = 0;
|
let blockCount = 0;
|
||||||
while ((match = regex.exec(line)) != null) {
|
while ((match = regex.exec(line)) != null) {
|
||||||
@@ -189,11 +252,39 @@ const Editor = createClass({
|
|||||||
// Highlight block divs {{\n Content \n}}
|
// Highlight block divs {{\n Content \n}}
|
||||||
let endCh = line.length+1;
|
let endCh = line.length+1;
|
||||||
|
|
||||||
const match = line.match(/^ *{{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1 *$|^ *}}$/);
|
const match = line.match(/^ *{{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1 *$|^ *}}$/);
|
||||||
if(match)
|
if(match)
|
||||||
endCh = match.index+match[0].length;
|
endCh = match.index+match[0].length;
|
||||||
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
|
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emojis
|
||||||
|
if(line.match(/:[^\s:]+:/g)) {
|
||||||
|
let startIndex = line.indexOf(':');
|
||||||
|
const emojiRegex = /:[^\s:]+:/gy;
|
||||||
|
|
||||||
|
while (startIndex >= 0) {
|
||||||
|
emojiRegex.lastIndex = startIndex;
|
||||||
|
let match = emojiRegex.exec(line);
|
||||||
|
if (match) {
|
||||||
|
let tokens = Markdown.marked.lexer(match[0]);
|
||||||
|
tokens = tokens[0].tokens.filter(t => t.type == 'emoji')
|
||||||
|
if (!tokens.length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let startPos = { line: lineNumber, ch: match.index };
|
||||||
|
let endPos = { line: lineNumber, ch: match.index + match[0].length };
|
||||||
|
|
||||||
|
// Iterate over conflicting marks and clear them
|
||||||
|
var marks = codeMirror.findMarks(startPos, endPos);
|
||||||
|
marks.forEach(function(marker) {
|
||||||
|
if(!marker.__isFold) marker.clear();
|
||||||
|
});
|
||||||
|
codeMirror.markText(startPos, endPos, { className: 'emoji' });
|
||||||
|
}
|
||||||
|
startIndex = line.indexOf(':', Math.max(startIndex + 1, emojiRegex.lastIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -248,23 +339,23 @@ const Editor = createClass({
|
|||||||
|
|
||||||
targetLine = lineCount - 1; //Scroll to `\page`, which is one line back.
|
targetLine = lineCount - 1; //Scroll to `\page`, which is one line back.
|
||||||
|
|
||||||
let currentY = this.refs.codeEditor.codeMirror.getScrollInfo().top;
|
let currentY = this.codeEditor.current.codeMirror.getScrollInfo().top;
|
||||||
let targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true);
|
let targetY = this.codeEditor.current.codeMirror.heightAtLine(targetLine, 'local', true);
|
||||||
|
|
||||||
//Scroll 1/10 of the way every 10ms until 1px off.
|
//Scroll 1/10 of the way every 10ms until 1px off.
|
||||||
const incrementalScroll = setInterval(()=>{
|
const incrementalScroll = setInterval(()=>{
|
||||||
currentY += (targetY - currentY) / 10;
|
currentY += (targetY - currentY) / 10;
|
||||||
this.refs.codeEditor.codeMirror.scrollTo(null, currentY);
|
this.codeEditor.current.codeMirror.scrollTo(null, currentY);
|
||||||
|
|
||||||
// Update target: target height is not accurate until within +-10 lines of the visible window
|
// Update target: target height is not accurate until within +-10 lines of the visible window
|
||||||
if(Math.abs(targetY - currentY > 100))
|
if(Math.abs(targetY - currentY > 100))
|
||||||
targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true);
|
targetY = this.codeEditor.current.codeMirror.heightAtLine(targetLine, 'local', true);
|
||||||
|
|
||||||
// End when close enough
|
// End when close enough
|
||||||
if(Math.abs(targetY - currentY) < 1) {
|
if(Math.abs(targetY - currentY) < 1) {
|
||||||
this.refs.codeEditor.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference
|
this.codeEditor.current.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference
|
||||||
this.refs.codeEditor.setCursorPosition({ line: targetLine + 1, ch: 0 });
|
this.codeEditor.current.setCursorPosition({ line: targetLine + 1, ch: 0 });
|
||||||
this.refs.codeEditor.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
|
this.codeEditor.current.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
|
||||||
clearInterval(incrementalScroll);
|
clearInterval(incrementalScroll);
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
@@ -274,7 +365,7 @@ const Editor = createClass({
|
|||||||
|
|
||||||
//Called when there are changes to the editor's dimensions
|
//Called when there are changes to the editor's dimensions
|
||||||
update : function(){
|
update : function(){
|
||||||
this.refs.codeEditor?.updateSize();
|
this.codeEditor.current?.updateSize();
|
||||||
},
|
},
|
||||||
|
|
||||||
updateEditorTheme : function(newTheme){
|
updateEditorTheme : function(newTheme){
|
||||||
@@ -293,7 +384,7 @@ const Editor = createClass({
|
|||||||
if(this.isText()){
|
if(this.isText()){
|
||||||
return <>
|
return <>
|
||||||
<CodeEditor key='codeEditor'
|
<CodeEditor key='codeEditor'
|
||||||
ref='codeEditor'
|
ref={this.codeEditor}
|
||||||
language='gfm'
|
language='gfm'
|
||||||
view={this.state.view}
|
view={this.state.view}
|
||||||
value={this.props.brew.text}
|
value={this.props.brew.text}
|
||||||
@@ -305,12 +396,12 @@ const Editor = createClass({
|
|||||||
if(this.isStyle()){
|
if(this.isStyle()){
|
||||||
return <>
|
return <>
|
||||||
<CodeEditor key='codeEditor'
|
<CodeEditor key='codeEditor'
|
||||||
ref='codeEditor'
|
ref={this.codeEditor}
|
||||||
language='css'
|
language='css'
|
||||||
view={this.state.view}
|
view={this.state.view}
|
||||||
value={this.props.brew.style ?? DEFAULT_STYLE_TEXT}
|
value={this.props.brew.style ?? DEFAULT_STYLE_TEXT}
|
||||||
onChange={this.props.onStyleChange}
|
onChange={this.props.onStyleChange}
|
||||||
enableFolding={false}
|
enableFolding={true}
|
||||||
editorTheme={this.state.editorTheme}
|
editorTheme={this.state.editorTheme}
|
||||||
rerenderParent={this.rerenderParent} />
|
rerenderParent={this.rerenderParent} />
|
||||||
</>;
|
</>;
|
||||||
@@ -324,26 +415,35 @@ const Editor = createClass({
|
|||||||
<MetadataEditor
|
<MetadataEditor
|
||||||
metadata={this.props.brew}
|
metadata={this.props.brew}
|
||||||
onChange={this.props.onMetaChange}
|
onChange={this.props.onMetaChange}
|
||||||
reportError={this.props.reportError}/>
|
reportError={this.props.reportError}
|
||||||
|
userThemes={this.props.userThemes}/>
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
redo : function(){
|
redo : function(){
|
||||||
return this.refs.codeEditor?.redo();
|
return this.codeEditor.current?.redo();
|
||||||
},
|
},
|
||||||
|
|
||||||
historySize : function(){
|
historySize : function(){
|
||||||
return this.refs.codeEditor?.historySize();
|
return this.codeEditor.current?.historySize();
|
||||||
},
|
},
|
||||||
|
|
||||||
undo : function(){
|
undo : function(){
|
||||||
return this.refs.codeEditor?.undo();
|
return this.codeEditor.current?.undo();
|
||||||
|
},
|
||||||
|
|
||||||
|
foldCode : function(){
|
||||||
|
return this.codeEditor.current?.foldAllCode();
|
||||||
|
},
|
||||||
|
|
||||||
|
unfoldCode : function(){
|
||||||
|
return this.codeEditor.current?.unfoldAllCode();
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return (
|
return (
|
||||||
<div className='editor' ref='main'>
|
<div className='editor' ref={this.editor}>
|
||||||
<SnippetBar
|
<SnippetBar
|
||||||
brew={this.props.brew}
|
brew={this.props.brew}
|
||||||
view={this.state.view}
|
view={this.state.view}
|
||||||
@@ -354,10 +454,13 @@ const Editor = createClass({
|
|||||||
theme={this.props.brew.theme}
|
theme={this.props.brew.theme}
|
||||||
undo={this.undo}
|
undo={this.undo}
|
||||||
redo={this.redo}
|
redo={this.redo}
|
||||||
|
foldCode={this.foldCode}
|
||||||
|
unfoldCode={this.unfoldCode}
|
||||||
historySize={this.historySize()}
|
historySize={this.historySize()}
|
||||||
currentEditorTheme={this.state.editorTheme}
|
currentEditorTheme={this.state.editorTheme}
|
||||||
updateEditorTheme={this.updateEditorTheme}
|
updateEditorTheme={this.updateEditorTheme}
|
||||||
cursorPos={this.refs.codeEditor?.getCursorPosition() || {}} />
|
snippetBundle={this.props.snippetBundle}
|
||||||
|
cursorPos={this.codeEditor.current?.getCursorPosition() || {}} />
|
||||||
|
|
||||||
{this.renderEditor()}
|
{this.renderEditor()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -43,6 +43,38 @@
|
|||||||
font-weight : bold;
|
font-weight : bold;
|
||||||
color : green;
|
color : green;
|
||||||
}
|
}
|
||||||
|
.emoji:not(.cm-comment) {
|
||||||
|
margin-left : 2px;
|
||||||
|
color : #360034;
|
||||||
|
background : #ffc8ff;
|
||||||
|
border-radius : 6px;
|
||||||
|
font-weight : bold;
|
||||||
|
padding-bottom : 1px;
|
||||||
|
outline-offset : -2px;
|
||||||
|
outline : solid 2px #ff96fc;
|
||||||
|
}
|
||||||
|
.superscript:not(.cm-comment) {
|
||||||
|
font-weight : bold;
|
||||||
|
color : goldenrod;
|
||||||
|
vertical-align : super;
|
||||||
|
font-size : 0.9em;
|
||||||
|
}
|
||||||
|
.subscript:not(.cm-comment) {
|
||||||
|
font-weight : bold;
|
||||||
|
color : rgb(123, 123, 15);
|
||||||
|
vertical-align : sub;
|
||||||
|
font-size : 0.9em;
|
||||||
|
}
|
||||||
|
.dl-highlight {
|
||||||
|
&.dl-colon-highlight {
|
||||||
|
font-weight : bold;
|
||||||
|
color : #949494;
|
||||||
|
background : #E5E5E5;
|
||||||
|
border-radius : 3px;
|
||||||
|
}
|
||||||
|
&.dt-highlight { color : rgb(96, 117, 143); }
|
||||||
|
&.dd-highlight { color : rgb(97, 57, 178); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.brewJump {
|
.brewJump {
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ require('./metadataEditor.less');
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
const request = require('../../utils/request-middleware.js');
|
const request = require('../../utils/request-middleware.js');
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const Combobox = require('client/components/combobox.jsx');
|
const Combobox = require('client/components/combobox.jsx');
|
||||||
const StringArrayEditor = require('../stringArrayEditor/stringArrayEditor.jsx');
|
const StringArrayEditor = require('../stringArrayEditor/stringArrayEditor.jsx');
|
||||||
|
|
||||||
|
|
||||||
const Themes = require('themes/themes.json');
|
const Themes = require('themes/themes.json');
|
||||||
const validations = require('./validations.js');
|
const validations = require('./validations.js');
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@ const MetadataEditor = createClass({
|
|||||||
return {
|
return {
|
||||||
metadata : {
|
metadata : {
|
||||||
editId : null,
|
editId : null,
|
||||||
|
shareId : null,
|
||||||
title : '',
|
title : '',
|
||||||
description : '',
|
description : '',
|
||||||
thumbnail : '',
|
thumbnail : '',
|
||||||
@@ -99,7 +100,7 @@ const MetadataEditor = createClass({
|
|||||||
if(renderer == 'legacy')
|
if(renderer == 'legacy')
|
||||||
this.props.metadata.theme = '5ePHB';
|
this.props.metadata.theme = '5ePHB';
|
||||||
}
|
}
|
||||||
this.props.onChange(this.props.metadata);
|
this.props.onChange(this.props.metadata, 'renderer');
|
||||||
},
|
},
|
||||||
handlePublish : function(val){
|
handlePublish : function(val){
|
||||||
this.props.onChange({
|
this.props.onChange({
|
||||||
@@ -111,7 +112,7 @@ const MetadataEditor = createClass({
|
|||||||
handleTheme : function(theme){
|
handleTheme : function(theme){
|
||||||
this.props.metadata.renderer = theme.renderer;
|
this.props.metadata.renderer = theme.renderer;
|
||||||
this.props.metadata.theme = theme.path;
|
this.props.metadata.theme = theme.path;
|
||||||
this.props.onChange(this.props.metadata);
|
this.props.onChange(this.props.metadata, 'theme');
|
||||||
},
|
},
|
||||||
|
|
||||||
handleLanguage : function(languageCode){
|
handleLanguage : function(languageCode){
|
||||||
@@ -192,37 +193,42 @@ const MetadataEditor = createClass({
|
|||||||
renderThemeDropdown : function(){
|
renderThemeDropdown : function(){
|
||||||
if(!global.enable_themes) return;
|
if(!global.enable_themes) return;
|
||||||
|
|
||||||
|
const mergedThemes = _.merge(Themes, this.props.userThemes);
|
||||||
|
|
||||||
const listThemes = (renderer)=>{
|
const listThemes = (renderer)=>{
|
||||||
return _.map(_.values(Themes[renderer]), (theme)=>{
|
return _.map(_.values(mergedThemes[renderer]), (theme)=>{
|
||||||
return <div className='item' key={''} onClick={()=>this.handleTheme(theme)} title={''}>
|
if(theme.path == this.props.metadata.shareId) return;
|
||||||
{`${theme.renderer} : ${theme.name}`}
|
const preview = theme.thumbnail || `/themes/${theme.renderer}/${theme.path}/dropdownPreview.png`;
|
||||||
<img src={`/themes/${theme.renderer}/${theme.path}/dropdownTexture.png`}/>
|
const texture = theme.thumbnail || `/themes/${theme.renderer}/${theme.path}/dropdownTexture.png`;
|
||||||
|
return <div className='item' key={`${renderer}_${theme.name}`} onClick={()=>this.handleTheme(theme)} title={''}>
|
||||||
|
{theme.author ?? renderer} : {theme.name}
|
||||||
|
<div className='texture-container'>
|
||||||
|
<img src={texture}/>
|
||||||
|
</div>
|
||||||
<div className='preview'>
|
<div className='preview'>
|
||||||
<h6>{`${theme.name}`} preview</h6>
|
<h6>{theme.name} preview</h6>
|
||||||
<img src={`/themes/${theme.renderer}/${theme.path}/dropdownPreview.png`}/>
|
<img src={preview}/>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentTheme = Themes[`${_.upperFirst(this.props.metadata.renderer)}`][this.props.metadata.theme];
|
const currentRenderer = this.props.metadata.renderer;
|
||||||
|
const currentTheme = mergedThemes[`${_.upperFirst(this.props.metadata.renderer)}`][this.props.metadata.theme]
|
||||||
|
?? { name: `!!! THEME MISSING !!! ID=${this.props.metadata.theme}` };
|
||||||
let dropdown;
|
let dropdown;
|
||||||
|
|
||||||
if(this.props.metadata.renderer == 'legacy') {
|
if(currentRenderer == 'legacy') {
|
||||||
dropdown =
|
dropdown =
|
||||||
<Nav.dropdown className='disabled value' trigger='disabled'>
|
<Nav.dropdown className='disabled value' trigger='disabled'>
|
||||||
<div>
|
<div> {`Themes are not supported in the Legacy Renderer`} <i className='fas fa-caret-down'></i> </div>
|
||||||
{`Themes are not supported in the Legacy Renderer`} <i className='fas fa-caret-down'></i>
|
|
||||||
</div>
|
|
||||||
</Nav.dropdown>;
|
</Nav.dropdown>;
|
||||||
} else {
|
} else {
|
||||||
dropdown =
|
dropdown =
|
||||||
<Nav.dropdown className='value' trigger='click'>
|
<Nav.dropdown className='value' trigger='click'>
|
||||||
<div>
|
<div> {currentTheme.author ?? _.upperFirst(currentRenderer)} : {currentTheme.name} <i className='fas fa-caret-down'></i> </div>
|
||||||
{`${_.upperFirst(currentTheme.renderer)} : ${currentTheme.name}`} <i className='fas fa-caret-down'></i>
|
|
||||||
</div>
|
{listThemes(currentRenderer)}
|
||||||
{/*listThemes('Legacy')*/}
|
|
||||||
{listThemes('V3')}
|
|
||||||
</Nav.dropdown>;
|
</Nav.dropdown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,49 +2,45 @@
|
|||||||
|
|
||||||
.metadataEditor {
|
.metadataEditor {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
z-index : 10000;
|
z-index : 5;
|
||||||
box-sizing : border-box;
|
box-sizing : border-box;
|
||||||
width : 100%;
|
width : 100%;
|
||||||
padding : 25px;
|
|
||||||
background-color : #999;
|
|
||||||
height : calc(100vh - 54px); // 54px is the height of the navbar + snippet bar. probably a better way to dynamic get this.
|
height : calc(100vh - 54px); // 54px is the height of the navbar + snippet bar. probably a better way to dynamic get this.
|
||||||
|
padding : 25px;
|
||||||
overflow-y : auto;
|
overflow-y : auto;
|
||||||
|
background-color : #999999;
|
||||||
|
|
||||||
.sectionHead {
|
.sectionHead {
|
||||||
font-weight: 1000;
|
|
||||||
margin : 20px 0;
|
margin : 20px 0;
|
||||||
|
font-weight : 1000;
|
||||||
|
|
||||||
&:first-of-type {
|
&:first-of-type { margin-top : 0; }
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
& > div {
|
& > div { margin-bottom : 10px; }
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-group {
|
.field-group {
|
||||||
display : flex;
|
display : flex;
|
||||||
width: 100%;
|
|
||||||
flex-wrap : wrap;
|
flex-wrap : wrap;
|
||||||
gap : 10px;
|
gap : 10px;
|
||||||
|
width : 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field-column {
|
.field-column {
|
||||||
display : flex;
|
display : flex;
|
||||||
flex-direction: column;
|
|
||||||
flex : 5 0 200px;
|
flex : 5 0 200px;
|
||||||
|
flex-direction : column;
|
||||||
gap : 10px;
|
gap : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
|
position : relative;
|
||||||
display : flex;
|
display : flex;
|
||||||
flex-wrap : wrap;
|
flex-wrap : wrap;
|
||||||
width : 100%;
|
width : 100%;
|
||||||
min-width : 200px;
|
min-width : 200px;
|
||||||
position : relative;
|
|
||||||
& > label {
|
& > label {
|
||||||
width : 80px;
|
width : 80px;
|
||||||
font-size : 11px;
|
font-size : 11px;
|
||||||
@@ -55,100 +51,90 @@
|
|||||||
& > .value {
|
& > .value {
|
||||||
flex : 1 1 auto;
|
flex : 1 1 auto;
|
||||||
width : 50px;
|
width : 50px;
|
||||||
&:invalid {
|
&:invalid { background : #FFB9B9; }
|
||||||
background : #ffb9b9;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
input[type='text'], textarea {
|
input[type='text'], textarea {
|
||||||
border : 1px solid gray;
|
border : 1px solid gray;
|
||||||
&:focus {
|
&:focus { outline : 1px solid #444444; }
|
||||||
outline: 1px solid #444;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
&.thumbnail {
|
&.thumbnail {
|
||||||
height : 1.4em;
|
height : 1.4em;
|
||||||
label{
|
label { line-height : 2.0em; }
|
||||||
line-height: 2.0em;
|
|
||||||
}
|
|
||||||
.value {
|
.value {
|
||||||
overflow : hidden;
|
overflow : hidden;
|
||||||
text-overflow : ellipsis;
|
text-overflow : ellipsis;
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
border: 1px solid #999;
|
|
||||||
color: white;
|
|
||||||
padding : 0px 5px;
|
padding : 0px 5px;
|
||||||
|
color : white;
|
||||||
background-color : black;
|
background-color : black;
|
||||||
&:hover{
|
border : 1px solid #999999;
|
||||||
background-color: #777;
|
&:hover { background-color : #777777; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.description {
|
&.description {
|
||||||
flex : 1;
|
flex : 1;
|
||||||
textarea.value {
|
textarea.value {
|
||||||
resize : none;
|
|
||||||
height : auto;
|
height : auto;
|
||||||
font-family : 'Open Sans', sans-serif;
|
font-family : 'Open Sans', sans-serif;
|
||||||
font-size : 0.8em;
|
font-size : 0.8em;
|
||||||
|
resize : none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.language .language-dropdown {
|
&.language .language-dropdown {
|
||||||
max-width : 150px;
|
|
||||||
z-index : 200;
|
z-index : 200;
|
||||||
|
max-width : 150px;
|
||||||
}
|
}
|
||||||
small {
|
small {
|
||||||
|
display : inline-block;
|
||||||
font-size : 0.6em;
|
font-size : 0.6em;
|
||||||
font-style : italic;
|
font-style : italic;
|
||||||
line-height : 1.4em;
|
line-height : 1.4em;
|
||||||
display : inline-block;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.thumbnail-preview {
|
.thumbnail-preview {
|
||||||
position : relative;
|
position : relative;
|
||||||
|
flex : 1 1;
|
||||||
justify-self : center;
|
justify-self : center;
|
||||||
width : 80px;
|
width : 80px;
|
||||||
height : min-content;
|
height : min-content;
|
||||||
flex: 1 1;
|
|
||||||
max-height : 115px;
|
max-height : 115px;
|
||||||
aspect-ratio : 1 / 1;
|
aspect-ratio : 1 / 1;
|
||||||
object-fit : contain;
|
object-fit : contain;
|
||||||
background-color: #AAA;
|
background-color : #AAAAAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
.systems.field .value {
|
.systems.field .value {
|
||||||
label {
|
label {
|
||||||
vertical-align : middle;
|
|
||||||
margin-right : 15px;
|
|
||||||
cursor : pointer;
|
|
||||||
font-size : 0.7em;
|
|
||||||
font-weight : 800;
|
|
||||||
user-select : none;
|
|
||||||
white-space : nowrap;
|
|
||||||
display : inline-flex;
|
display : inline-flex;
|
||||||
align-items : center;
|
align-items : center;
|
||||||
}
|
margin-right : 15px;
|
||||||
a {
|
|
||||||
font-size : 0.7em;
|
font-size : 0.7em;
|
||||||
font-weight : 800;
|
font-weight : 800;
|
||||||
display : inline-flex;
|
white-space : nowrap;
|
||||||
}
|
|
||||||
input{
|
|
||||||
vertical-align : middle;
|
vertical-align : middle;
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
|
user-select : none;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
display : inline-flex;
|
||||||
|
font-size : 0.7em;
|
||||||
|
font-weight : 800;
|
||||||
|
}
|
||||||
|
input {
|
||||||
margin : 3px;
|
margin : 3px;
|
||||||
|
vertical-align : middle;
|
||||||
|
cursor : pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.publish.field .value {
|
.publish.field .value {
|
||||||
position : relative;
|
position : relative;
|
||||||
margin-bottom : 15px;
|
margin-bottom : 15px;
|
||||||
button{
|
button { width : 100%; }
|
||||||
width:100%;
|
|
||||||
}
|
|
||||||
button.publish {
|
button.publish {
|
||||||
.button(@blueLight);
|
.button(@blueLight);
|
||||||
}
|
}
|
||||||
@@ -170,74 +156,85 @@
|
|||||||
.themes.field {
|
.themes.field {
|
||||||
font-size : 13.33px;
|
font-size : 13.33px;
|
||||||
.navDropdownContainer {
|
.navDropdownContainer {
|
||||||
background-color : white;
|
|
||||||
position : relative;
|
position : relative;
|
||||||
z-index : 100;
|
z-index : 100;
|
||||||
|
background-color : white;
|
||||||
&.disabled {
|
&.disabled {
|
||||||
font-style : italic;
|
font-style : italic;
|
||||||
font-style : italic;
|
|
||||||
background-color : darkgray;
|
|
||||||
color : dimgray;
|
color : dimgray;
|
||||||
|
background-color : darkgray;
|
||||||
}
|
}
|
||||||
& > div:first-child {
|
& > div:first-child {
|
||||||
border : 2px solid rgb(118,118,118);
|
|
||||||
padding : 6px 3px;
|
padding : 6px 3px;
|
||||||
background-color : inherit;
|
background-color : inherit;
|
||||||
i {
|
border : 2px solid rgb(118,118,118);
|
||||||
float : right;
|
i { float : right; }
|
||||||
}
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color : @blue;
|
|
||||||
color : white;
|
color : white;
|
||||||
|
background-color : @blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.navDropdown .item > p {
|
||||||
|
width : 45%;
|
||||||
|
height : 1.1em;
|
||||||
|
overflow : hidden;
|
||||||
|
text-overflow : ellipsis;
|
||||||
|
white-space : nowrap;
|
||||||
|
}
|
||||||
.navDropdown {
|
.navDropdown {
|
||||||
box-shadow : 0px 5px 10px rgba(0, 0, 0, 0.3);
|
|
||||||
position : absolute;
|
position : absolute;
|
||||||
width : 100%;
|
width : 100%;
|
||||||
|
box-shadow : 0px 5px 10px rgba(0, 0, 0, 0.3);
|
||||||
.item {
|
.item {
|
||||||
padding : 3px 3px;
|
|
||||||
border-top : 1px solid rgb(118, 118, 118);
|
|
||||||
position : relative;
|
position : relative;
|
||||||
|
padding : 3px 3px;
|
||||||
overflow : visible;
|
overflow : visible;
|
||||||
background-color : white;
|
background-color : white;
|
||||||
|
border-top : 1px solid rgb(118, 118, 118);
|
||||||
.preview {
|
.preview {
|
||||||
display : flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background : #ccc;
|
|
||||||
border-radius : 5px;
|
|
||||||
box-shadow : 0 0 5px black;
|
|
||||||
width : 200px;
|
|
||||||
color :black;
|
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 0;
|
top : 0;
|
||||||
right : 0;
|
right : 0;
|
||||||
|
z-index : 1;
|
||||||
|
display : flex;
|
||||||
|
flex-direction : column;
|
||||||
|
width : 200px;
|
||||||
|
overflow : hidden;
|
||||||
|
color : black;
|
||||||
|
background : #CCCCCC;
|
||||||
|
border-radius : 5px;
|
||||||
|
box-shadow : 0 0 5px black;
|
||||||
opacity : 0;
|
opacity : 0;
|
||||||
transition : opacity 250ms ease;
|
transition : opacity 250ms ease;
|
||||||
z-index : 1;
|
|
||||||
overflow :hidden;
|
|
||||||
h6 {
|
h6 {
|
||||||
font-weight : 900;
|
padding-block : 0.5em;
|
||||||
padding-inline : 1em;
|
padding-inline : 1em;
|
||||||
padding-block :.5em;
|
font-weight : 900;
|
||||||
border-bottom : 2px solid hsl(0,0%,40%);
|
border-bottom : 2px solid hsl(0,0%,40%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color : @blue;
|
|
||||||
color : white;
|
color : white;
|
||||||
|
background-color : @blue;
|
||||||
}
|
}
|
||||||
&:hover > .preview {
|
&:hover > .preview { opacity : 1; }
|
||||||
opacity: 1;
|
.texture-container {
|
||||||
}
|
|
||||||
>img {
|
|
||||||
mask-image : linear-gradient(90deg, transparent, black 20%);
|
|
||||||
-webkit-mask-image : linear-gradient(90deg, transparent, black 20%);
|
|
||||||
position : absolute;
|
position : absolute;
|
||||||
right : 0;
|
top : 0;
|
||||||
top : 0px;
|
left : 0;
|
||||||
width : 50%;
|
width : 100%;
|
||||||
height : 100%;
|
height : 100%;
|
||||||
|
min-height : 100%;
|
||||||
|
overflow : hidden;
|
||||||
|
> img {
|
||||||
|
position : absolute;
|
||||||
|
top : 0px;
|
||||||
|
right : 0;
|
||||||
|
width : 50%;
|
||||||
|
min-height : 100%;
|
||||||
|
-webkit-mask-image : linear-gradient(90deg, transparent, black 20%);
|
||||||
|
mask-image : linear-gradient(90deg, transparent, black 20%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,21 +245,19 @@
|
|||||||
flex : 1 0;
|
flex : 1 0;
|
||||||
flex-wrap : wrap;
|
flex-wrap : wrap;
|
||||||
|
|
||||||
> * {
|
> * { flex : 0 0 auto; }
|
||||||
flex: 0 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#groupedIcon {
|
#groupedIcon {
|
||||||
#backgroundColors;
|
#backgroundColors;
|
||||||
display: inline-block;
|
|
||||||
height: ~"calc(100% + 0.6em)";
|
|
||||||
position : relative;
|
position : relative;
|
||||||
top : -0.3em;
|
top : -0.3em;
|
||||||
right : -0.3em;
|
right : -0.3em;
|
||||||
cursor: pointer;
|
display : inline-block;
|
||||||
min-width : 20px;
|
min-width : 20px;
|
||||||
text-align: center;
|
height : ~'calc(100% + 0.6em)';
|
||||||
color : white;
|
color : white;
|
||||||
|
text-align : center;
|
||||||
|
cursor : pointer;
|
||||||
|
|
||||||
i {
|
i {
|
||||||
position : relative;
|
position : relative;
|
||||||
@@ -270,37 +265,28 @@
|
|||||||
transform : translateY(-50%);
|
transform : translateY(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(:last-child) {
|
&:not(:last-child) { border-right : 1px solid black; }
|
||||||
border-right: 1px solid black;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:last-child {
|
&:last-child { border-radius : 0 0.5em 0.5em 0; }
|
||||||
border-radius: 0 0.5em 0.5em 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
background-color: #dddddd;
|
padding : 0.3em;
|
||||||
border-radius: .5em;
|
|
||||||
font-size: .9em;
|
|
||||||
margin : 2px;
|
margin : 2px;
|
||||||
padding: .3em;
|
font-size : 0.9em;
|
||||||
|
background-color : #DDDDDD;
|
||||||
|
border-radius : 0.5em;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
#groupedIcon
|
#groupedIcon; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-group {
|
.input-group {
|
||||||
height: ~"calc(.9em + 4px + .6em)";
|
height : ~'calc(.9em + 4px + .6em)';
|
||||||
|
|
||||||
input {
|
input { border-radius : 0.5em 0 0 0.5em; }
|
||||||
border-radius: .5em 0 0 .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
input:last-child {
|
input:last-child { border-radius : 0.5em; }
|
||||||
border-radius: .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
width : 7.5vw;
|
width : 7.5vw;
|
||||||
@@ -308,20 +294,16 @@
|
|||||||
height : 100%;
|
height : 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.invalid:focus {
|
.invalid:focus { background-color : pink; }
|
||||||
background-color: pink;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
#groupedIcon;
|
#groupedIcon;
|
||||||
height: 97%;
|
top : -0.54em;
|
||||||
font-size: .8em;
|
|
||||||
right : 1px;
|
right : 1px;
|
||||||
top: -.54em;
|
height : 97%;
|
||||||
|
font-size : 0.8em;
|
||||||
|
|
||||||
i {
|
i { font-size : 1.125em; }
|
||||||
font-size: 1.125em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ const _ = require('lodash');
|
|||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|
||||||
//Import all themes
|
//Import all themes
|
||||||
|
|
||||||
const Themes = require('themes/themes.json');
|
|
||||||
|
|
||||||
const ThemeSnippets = {};
|
const ThemeSnippets = {};
|
||||||
ThemeSnippets['Legacy_5ePHB'] = require('themes/Legacy/5ePHB/snippets.js');
|
ThemeSnippets['Legacy_5ePHB'] = require('themes/Legacy/5ePHB/snippets.js');
|
||||||
ThemeSnippets['V3_5ePHB'] = require('themes/V3/5ePHB/snippets.js');
|
ThemeSnippets['V3_5ePHB'] = require('themes/V3/5ePHB/snippets.js');
|
||||||
@@ -37,8 +34,11 @@ const Snippetbar = createClass({
|
|||||||
undo : ()=>{},
|
undo : ()=>{},
|
||||||
redo : ()=>{},
|
redo : ()=>{},
|
||||||
historySize : ()=>{},
|
historySize : ()=>{},
|
||||||
|
foldCode : ()=>{},
|
||||||
|
unfoldCode : ()=>{},
|
||||||
updateEditorTheme : ()=>{},
|
updateEditorTheme : ()=>{},
|
||||||
cursorPos : {}
|
cursorPos : {},
|
||||||
|
snippetBundle : []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -51,47 +51,42 @@ const Snippetbar = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount : async function() {
|
componentDidMount : async function() {
|
||||||
const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy';
|
const snippets = this.compileSnippets();
|
||||||
const themePath = this.props.theme ?? '5ePHB';
|
|
||||||
let snippets = _.cloneDeep(ThemeSnippets[`${rendererPath}_${themePath}`]);
|
|
||||||
snippets = this.compileSnippets(rendererPath, themePath, snippets);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
snippets : snippets
|
snippets : snippets
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate : async function(prevProps) {
|
componentDidUpdate : async function(prevProps) {
|
||||||
if(prevProps.renderer != this.props.renderer || prevProps.theme != this.props.theme) {
|
if(prevProps.renderer != this.props.renderer || prevProps.theme != this.props.theme || prevProps.snippetBundle != this.props.snippetBundle) {
|
||||||
const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy';
|
const snippets = this.compileSnippets();
|
||||||
const themePath = this.props.theme ?? '5ePHB';
|
|
||||||
let snippets = _.cloneDeep(ThemeSnippets[`${rendererPath}_${themePath}`]);
|
|
||||||
snippets = this.compileSnippets(rendererPath, themePath, snippets);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
snippets : snippets
|
snippets : snippets
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mergeCustomizer : function(valueA, valueB, key) {
|
|
||||||
|
mergeCustomizer : function(oldValue, newValue, key) {
|
||||||
if(key == 'snippets') {
|
if(key == 'snippets') {
|
||||||
const result = _.reverse(_.unionBy(_.reverse(valueB), _.reverse(valueA), 'name')); // Join snippets together, with preference for the current theme over the base theme
|
const result = _.reverse(_.unionBy(_.reverse(newValue), _.reverse(oldValue), 'name')); // Join snippets together, with preference for the child theme over the parent theme
|
||||||
return _.filter(result, 'gen'); //Only keep snippets with a 'gen' property.
|
return _.filter(result, 'gen'); //Only keep snippets with a 'gen' property.
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
compileSnippets : function(rendererPath, themePath, snippets) {
|
compileSnippets : function() {
|
||||||
let compiledSnippets = snippets;
|
let compiledSnippets = [];
|
||||||
const baseSnippetsPath = Themes[rendererPath][themePath].baseSnippets;
|
|
||||||
|
|
||||||
const objB = _.keyBy(compiledSnippets, 'groupName');
|
let oldSnippets = _.keyBy(compiledSnippets, 'groupName');
|
||||||
|
|
||||||
if(baseSnippetsPath) {
|
for (let snippets of this.props.snippetBundle) {
|
||||||
const objA = _.keyBy(_.cloneDeep(ThemeSnippets[`${rendererPath}_${baseSnippetsPath}`]), 'groupName');
|
if(typeof(snippets) == 'string') // load staticThemes as needed; they were sent as just a file name
|
||||||
compiledSnippets = _.values(_.mergeWith(objA, objB, this.mergeCustomizer));
|
snippets = ThemeSnippets[snippets];
|
||||||
compiledSnippets = this.compileSnippets(rendererPath, baseSnippetsPath, _.cloneDeep(compiledSnippets));
|
|
||||||
} else {
|
const newSnippets = _.keyBy(_.cloneDeep(snippets), 'groupName');
|
||||||
const objA = _.keyBy(_.cloneDeep(ThemeSnippets[`${rendererPath}_Blank`]), 'groupName');
|
compiledSnippets = _.values(_.mergeWith(oldSnippets, newSnippets, this.mergeCustomizer));
|
||||||
compiledSnippets = _.values(_.mergeWith(objA, objB, this.mergeCustomizer));
|
|
||||||
|
oldSnippets = _.keyBy(compiledSnippets, 'groupName');
|
||||||
}
|
}
|
||||||
return compiledSnippets;
|
return compiledSnippets;
|
||||||
},
|
},
|
||||||
@@ -100,10 +95,12 @@ const Snippetbar = createClass({
|
|||||||
this.props.onInject(injectedText);
|
this.props.onInject(injectedText);
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleThemeSelector : function(){
|
toggleThemeSelector : function(e){
|
||||||
|
if(e.target.tagName != 'SELECT'){
|
||||||
this.setState({
|
this.setState({
|
||||||
themeSelector : !this.state.themeSelector
|
themeSelector : !this.state.themeSelector
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeTheme : function(e){
|
changeTheme : function(e){
|
||||||
@@ -117,7 +114,7 @@ const Snippetbar = createClass({
|
|||||||
|
|
||||||
renderThemeSelector : function(){
|
renderThemeSelector : function(){
|
||||||
return <div className='themeSelector'>
|
return <div className='themeSelector'>
|
||||||
<select value={this.props.currentEditorTheme} onChange={this.changeTheme} onMouseDown={(this.changeTheme)}>
|
<select value={this.props.currentEditorTheme} onChange={this.changeTheme} >
|
||||||
{EditorThemes.map((theme, key)=>{
|
{EditorThemes.map((theme, key)=>{
|
||||||
return <option key={key} value={theme}>{theme}</option>;
|
return <option key={key} value={theme}>{theme}</option>;
|
||||||
})}
|
})}
|
||||||
@@ -144,6 +141,22 @@ const Snippetbar = createClass({
|
|||||||
renderEditorButtons : function(){
|
renderEditorButtons : function(){
|
||||||
if(!this.props.showEditButtons) return;
|
if(!this.props.showEditButtons) return;
|
||||||
|
|
||||||
|
let foldButtons;
|
||||||
|
if(this.props.view == 'text'){
|
||||||
|
foldButtons =
|
||||||
|
<>
|
||||||
|
<div className={`editorTool foldAll ${this.props.foldCode ? 'active' : ''}`}
|
||||||
|
onClick={this.props.foldCode} >
|
||||||
|
<i className='fas fa-compress-alt' />
|
||||||
|
</div>
|
||||||
|
<div className={`editorTool unfoldAll ${this.props.unfoldCode ? 'active' : ''}`}
|
||||||
|
onClick={this.props.unfoldCode} >
|
||||||
|
<i className='fas fa-expand-alt' />
|
||||||
|
</div>
|
||||||
|
</>;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return <div className='editors'>
|
return <div className='editors'>
|
||||||
<div className={`editorTool undo ${this.props.historySize.undo ? 'active' : ''}`}
|
<div className={`editorTool undo ${this.props.historySize.undo ? 'active' : ''}`}
|
||||||
onClick={this.props.undo} >
|
onClick={this.props.undo} >
|
||||||
@@ -154,11 +167,13 @@ const Snippetbar = createClass({
|
|||||||
<i className='fas fa-redo' />
|
<i className='fas fa-redo' />
|
||||||
</div>
|
</div>
|
||||||
<div className='divider'></div>
|
<div className='divider'></div>
|
||||||
|
{foldButtons}
|
||||||
<div className={`editorTool editorTheme ${this.state.themeSelector ? 'active' : ''}`}
|
<div className={`editorTool editorTheme ${this.state.themeSelector ? 'active' : ''}`}
|
||||||
onClick={this.toggleThemeSelector} >
|
onClick={this.toggleThemeSelector} >
|
||||||
<i className='fas fa-palette' />
|
<i className='fas fa-palette' />
|
||||||
</div>
|
|
||||||
{this.state.themeSelector && this.renderThemeSelector()}
|
{this.state.themeSelector && this.renderThemeSelector()}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className='divider'></div>
|
<div className='divider'></div>
|
||||||
<div className={cx('text', { selected: this.props.view === 'text' })}
|
<div className={cx('text', { selected: this.props.view === 'text' })}
|
||||||
onClick={()=>this.props.onViewChange('text')}>
|
onClick={()=>this.props.onViewChange('text')}>
|
||||||
@@ -209,7 +224,7 @@ const SnippetGroup = createClass({
|
|||||||
return _.map(snippets, (snippet)=>{
|
return _.map(snippets, (snippet)=>{
|
||||||
return <div className='snippet' key={snippet.name} onClick={(e)=>this.handleSnippetClick(e, snippet)}>
|
return <div className='snippet' key={snippet.name} onClick={(e)=>this.handleSnippetClick(e, snippet)}>
|
||||||
<i className={snippet.icon} />
|
<i className={snippet.icon} />
|
||||||
<span className='name'>{snippet.name}</span>
|
<span className='name'title={snippet.name}>{snippet.name}</span>
|
||||||
{snippet.experimental && <span className='beta'>beta</span>}
|
{snippet.experimental && <span className='beta'>beta</span>}
|
||||||
{snippet.subsnippets && <>
|
{snippet.subsnippets && <>
|
||||||
<i className='fas fa-caret-right'></i>
|
<i className='fas fa-caret-right'></i>
|
||||||
|
|||||||
@@ -1,26 +1,27 @@
|
|||||||
@import (less) './client/icons/customIcons.less';
|
@import (less) './client/icons/customIcons.less';
|
||||||
|
@import (less) '././././themes/fonts/5e/fonts.less';
|
||||||
|
|
||||||
.snippetBar {
|
.snippetBar {
|
||||||
@menuHeight : 25px;
|
@menuHeight : 25px;
|
||||||
position : relative;
|
position : relative;
|
||||||
height : @menuHeight;
|
height : @menuHeight;
|
||||||
background-color : #ddd;
|
color : black;
|
||||||
|
background-color : #DDDDDD;
|
||||||
|
|
||||||
.editors {
|
.editors {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
display : flex;
|
|
||||||
top : 0px;
|
top : 0px;
|
||||||
right : 0px;
|
right : 0px;
|
||||||
height : @menuHeight;
|
display : flex;
|
||||||
width : 125px;
|
|
||||||
justify-content : space-between;
|
justify-content : space-between;
|
||||||
&>div{
|
|
||||||
height : @menuHeight;
|
height : @menuHeight;
|
||||||
|
& > div {
|
||||||
width : @menuHeight;
|
width : @menuHeight;
|
||||||
cursor : pointer;
|
height : @menuHeight;
|
||||||
line-height : @menuHeight;
|
line-height : @menuHeight;
|
||||||
text-align : center;
|
text-align : center;
|
||||||
&:hover,&.selected{
|
cursor : pointer;
|
||||||
background-color : #999;
|
&:hover,&.selected { background-color : #999999; }
|
||||||
}
|
|
||||||
&.text {
|
&.text {
|
||||||
.tooltipLeft('Brew Editor');
|
.tooltipLeft('Brew Editor');
|
||||||
}
|
}
|
||||||
@@ -34,61 +35,66 @@
|
|||||||
.tooltipLeft('Undo');
|
.tooltipLeft('Undo');
|
||||||
font-size : 0.75em;
|
font-size : 0.75em;
|
||||||
color : grey;
|
color : grey;
|
||||||
&.active{
|
&.active { color : inherit; }
|
||||||
color : black;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
&.redo {
|
&.redo {
|
||||||
.tooltipLeft('Redo');
|
.tooltipLeft('Redo');
|
||||||
font-size : 0.75em;
|
font-size : 0.75em;
|
||||||
color : grey;
|
color : grey;
|
||||||
&.active{
|
&.active { color : inherit; }
|
||||||
color : black;
|
|
||||||
}
|
}
|
||||||
|
&.foldAll {
|
||||||
|
.tooltipLeft('Fold All');
|
||||||
|
font-size : 0.75em;
|
||||||
|
color : inherit;
|
||||||
|
}
|
||||||
|
&.unfoldAll {
|
||||||
|
.tooltipLeft('Unfold All');
|
||||||
|
font-size : 0.75em;
|
||||||
|
color : inherit;
|
||||||
}
|
}
|
||||||
&.editorTheme {
|
&.editorTheme {
|
||||||
.tooltipLeft('Editor Themes');
|
.tooltipLeft('Editor Themes');
|
||||||
font-size : 0.75em;
|
font-size : 0.75em;
|
||||||
color : black;
|
color : black;
|
||||||
&.active {
|
&.active {
|
||||||
color : white;
|
position : relative;
|
||||||
background-color: black;
|
background-color : #999999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.divider {
|
&.divider {
|
||||||
background: linear-gradient(#000, #000) no-repeat center/1px 100%;
|
|
||||||
width : 5px;
|
width : 5px;
|
||||||
&:hover{
|
background : linear-gradient(currentColor, currentColor) no-repeat center/1px 100%;
|
||||||
background-color: inherit;
|
&:hover { background-color : inherit; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.themeSelector {
|
.themeSelector {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
left: -65px;
|
top : 25px;
|
||||||
top: 30px;
|
right : 0;
|
||||||
z-index: 999;
|
z-index : 10;
|
||||||
|
display : flex;
|
||||||
|
align-items : center;
|
||||||
|
justify-content : center;
|
||||||
width : 170px;
|
width : 170px;
|
||||||
background-color: black;
|
height : inherit;
|
||||||
border-radius: 5px;
|
background-color : inherit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.snippetBarButton {
|
.snippetBarButton {
|
||||||
height : @menuHeight;
|
|
||||||
line-height : @menuHeight;
|
|
||||||
display : inline-block;
|
display : inline-block;
|
||||||
|
height : @menuHeight;
|
||||||
padding : 0px 5px;
|
padding : 0px 5px;
|
||||||
font-weight : 800;
|
|
||||||
font-size : 0.625em;
|
font-size : 0.625em;
|
||||||
|
font-weight : 800;
|
||||||
|
line-height : @menuHeight;
|
||||||
text-transform : uppercase;
|
text-transform : uppercase;
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
&:hover, &.selected{
|
&:hover, &.selected { background-color : #999999; }
|
||||||
background-color : #999;
|
|
||||||
}
|
|
||||||
i {
|
i {
|
||||||
vertical-align : middle;
|
|
||||||
margin-right : 3px;
|
margin-right : 3px;
|
||||||
font-size : 1.4em;
|
font-size : 1.4em;
|
||||||
|
vertical-align : middle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toggleMeta {
|
.toggleMeta {
|
||||||
@@ -96,63 +102,87 @@
|
|||||||
top : 0px;
|
top : 0px;
|
||||||
right : 0px;
|
right : 0px;
|
||||||
border-left : 1px solid black;
|
border-left : 1px solid black;
|
||||||
.tooltipLeft("Edit Brew Properties");
|
.tooltipLeft('Edit Brew Properties');
|
||||||
}
|
}
|
||||||
.snippetGroup {
|
.snippetGroup {
|
||||||
border-right : 1px solid black;
|
border-right : 1px solid currentColor;
|
||||||
&:hover {
|
&:hover {
|
||||||
&>.dropdown{
|
& > .dropdown { visibility : visible; }
|
||||||
visibility : visible;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.dropdown {
|
.dropdown {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 100%;
|
top : 100%;
|
||||||
visibility : hidden;
|
|
||||||
z-index : 1000;
|
z-index : 1000;
|
||||||
margin-left : -5px;
|
|
||||||
padding : 0px;
|
padding : 0px;
|
||||||
background-color : #ddd;
|
margin-left : -5px;
|
||||||
|
visibility : hidden;
|
||||||
|
background-color : #DDDDDD;
|
||||||
.snippet {
|
.snippet {
|
||||||
position : relative;
|
position : relative;
|
||||||
.animate(background-color);
|
|
||||||
display : flex;
|
display : flex;
|
||||||
align-items : center;
|
align-items : center;
|
||||||
min-width : max-content;
|
min-width : max-content;
|
||||||
padding : 5px;
|
padding : 5px;
|
||||||
cursor : pointer;
|
|
||||||
font-size : 10px;
|
font-size : 10px;
|
||||||
|
cursor : pointer;
|
||||||
|
.animate(background-color);
|
||||||
i {
|
i {
|
||||||
|
height : 1.2em;
|
||||||
margin-right : 8px;
|
margin-right : 8px;
|
||||||
font-size : 1.2em;
|
font-size : 1.2em;
|
||||||
height : 1.2em;
|
min-width: 25px;
|
||||||
|
text-align: center;
|
||||||
& ~ i {
|
& ~ i {
|
||||||
margin-right : 0;
|
margin-right : 0;
|
||||||
margin-left : 5px;
|
margin-left : 5px;
|
||||||
}
|
}
|
||||||
|
/* Fonts */
|
||||||
|
&.font {
|
||||||
|
height : auto;
|
||||||
|
&::before {
|
||||||
|
font-size : 1em;
|
||||||
|
content : 'ABC';
|
||||||
}
|
}
|
||||||
.name {
|
|
||||||
margin-right : auto;
|
&.OpenSans {font-family : 'OpenSans';}
|
||||||
|
&.CodeBold {font-family : 'CodeBold';}
|
||||||
|
&.CodeLight {font-family : 'CodeLight';}
|
||||||
|
&.ScalySansRemake {font-family : 'ScalySansRemake';}
|
||||||
|
&.BookInsanityRemake {font-family : 'BookInsanityRemake';}
|
||||||
|
&.MrEavesRemake {font-family : 'MrEavesRemake';}
|
||||||
|
&.SolberaImitationRemake {font-family : 'SolberaImitationRemake';}
|
||||||
|
&.ScalySansSmallCapsRemake {font-family : 'ScalySansSmallCapsRemake';}
|
||||||
|
&.WalterTurncoat {font-family : 'WalterTurncoat';}
|
||||||
|
&.Lato {font-family : 'Lato';}
|
||||||
|
&.Courier {font-family : 'Courier';}
|
||||||
|
&.NodestoCapsCondensed {font-family : 'NodestoCapsCondensed';}
|
||||||
|
&.Overpass {font-family : 'Overpass';}
|
||||||
|
&.Davek {font-family : 'Davek';}
|
||||||
|
&.Iokharic {font-family : 'Iokharic';}
|
||||||
|
&.Rellanic {font-family : 'Rellanic';}
|
||||||
|
&.TimesNewRoman {font-family : 'Times New Roman';}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.name { margin-right : auto; }
|
||||||
.beta {
|
.beta {
|
||||||
color : white;
|
|
||||||
padding : 4px 6px;
|
|
||||||
line-height : 1em;
|
|
||||||
margin-left : 5px;
|
|
||||||
align-self : center;
|
align-self : center;
|
||||||
|
padding : 4px 6px;
|
||||||
|
margin-left : 5px;
|
||||||
|
font-family : monospace;
|
||||||
|
line-height : 1em;
|
||||||
|
color : white;
|
||||||
background : grey;
|
background : grey;
|
||||||
border-radius : 12px;
|
border-radius : 12px;
|
||||||
font-family : monospace;
|
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color : #999;
|
background-color : #999999;
|
||||||
& > .dropdown {
|
& > .dropdown {
|
||||||
visibility : visible;
|
visibility : visible;
|
||||||
&.side {
|
&.side {
|
||||||
left: 100%;
|
|
||||||
top : 0%;
|
top : 0%;
|
||||||
|
left : 100%;
|
||||||
margin-left : 0;
|
margin-left : 0;
|
||||||
box-shadow: -1px 1px 2px 0px #999;
|
box-shadow : -1px 1px 2px 0px #999999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const UserPage = require('./pages/userPage/userPage.jsx');
|
|||||||
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
||||||
const NewPage = require('./pages/newPage/newPage.jsx');
|
const NewPage = require('./pages/newPage/newPage.jsx');
|
||||||
const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
||||||
const PrintPage = require('./pages/printPage/printPage.jsx');
|
const VaultPage = require('./pages/vaultPage/vaultPage.jsx');
|
||||||
const AccountPage = require('./pages/accountPage/accountPage.jsx');
|
const AccountPage = require('./pages/accountPage/accountPage.jsx');
|
||||||
|
|
||||||
const WithRoute = (props)=>{
|
const WithRoute = (props)=>{
|
||||||
@@ -67,16 +67,16 @@ const Homebrew = createClass({
|
|||||||
<Router location={this.props.url}>
|
<Router location={this.props.url}>
|
||||||
<div className='homebrew'>
|
<div className='homebrew'>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path='/edit/:id' element={<WithRoute el={EditPage} brew={this.props.brew} />} />
|
<Route path='/edit/:id' element={<WithRoute el={EditPage} brew={this.props.brew} userThemes={this.props.userThemes}/>} />
|
||||||
<Route path='/share/:id' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
<Route path='/share/:id' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
||||||
<Route path='/new/:id' element={<WithRoute el={NewPage} brew={this.props.brew} />} />
|
<Route path='/new/:id' element={<WithRoute el={NewPage} brew={this.props.brew} userThemes={this.props.userThemes}/>} />
|
||||||
<Route path='/new' element={<WithRoute el={NewPage}/>} />
|
<Route path='/new' element={<WithRoute el={NewPage} userThemes={this.props.userThemes}/> } />
|
||||||
<Route path='/user/:username' element={<WithRoute el={UserPage} brews={this.props.brews} />} />
|
<Route path='/user/:username' element={<WithRoute el={UserPage} brews={this.props.brews} />} />
|
||||||
<Route path='/print/:id' element={<WithRoute el={PrintPage} brew={this.props.brew} />} />
|
<Route path='/vault' element={<WithRoute el={VaultPage}/>}/>
|
||||||
<Route path='/print' element={<WithRoute el={PrintPage} />} />
|
<Route path='/changelog' element={<WithRoute el={SharePage} brew={this.props.brew} disableMeta={true} />} />
|
||||||
<Route path='/changelog' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
<Route path='/faq' element={<WithRoute el={SharePage} brew={this.props.brew} disableMeta={true} />} />
|
||||||
<Route path='/faq' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
<Route path='/migrate' element={<WithRoute el={SharePage} brew={this.props.brew} disableMeta={true} />} />
|
||||||
<Route path='/account' element={<WithRoute el={AccountPage} brew={this.props.brew} uiItems={this.props.brew.uiItems} />} />
|
<Route path='/account' element={<WithRoute el={AccountPage} brew={this.props.brew} accountDetails={this.props.brew.accountDetails} />} />
|
||||||
<Route path='/legacy' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
<Route path='/legacy' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||||
<Route path='/error' element={<WithRoute el={ErrorPage} brew={this.props.brew} />} />
|
<Route path='/error' element={<WithRoute el={ErrorPage} brew={this.props.brew} />} />
|
||||||
<Route path='/' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
<Route path='/' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||||
@@ -89,14 +89,3 @@ const Homebrew = createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Homebrew;
|
module.exports = Homebrew;
|
||||||
|
|
||||||
//TODO: Nicer Error page instead of just "cant get that"
|
|
||||||
// '/share/:id' : (args)=>{
|
|
||||||
// if(!this.props.brew.shareId){
|
|
||||||
// return <ErrorPage errorId={args.id}/>;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return <SharePage
|
|
||||||
// id={args.id}
|
|
||||||
// brew={this.props.brew} />;
|
|
||||||
// },
|
|
||||||
|
|||||||
@@ -15,6 +15,23 @@
|
|||||||
}
|
}
|
||||||
&.listPage .content {
|
&.listPage .content {
|
||||||
overflow-y : scroll;
|
overflow-y : scroll;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 20px;
|
||||||
|
&:horizontal{
|
||||||
|
height: 20px;
|
||||||
|
width:auto;
|
||||||
|
}
|
||||||
|
&-thumb {
|
||||||
|
background: linear-gradient(90deg, #d3c1af 15px, #00000000 15px);
|
||||||
|
&:horizontal{
|
||||||
|
background: linear-gradient(0deg, #d3c1af 15px, #00000000 15px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-corner {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ const ErrorNavItem = createClass({
|
|||||||
const error = this.props.error;
|
const error = this.props.error;
|
||||||
const response = error.response;
|
const response = error.response;
|
||||||
const status = response.status;
|
const status = response.status;
|
||||||
|
const HBErrorCode = response.body?.HBErrorCode;
|
||||||
const message = response.body?.message;
|
const message = response.body?.message;
|
||||||
let errMsg = '';
|
let errMsg = '';
|
||||||
try {
|
try {
|
||||||
@@ -40,7 +41,9 @@ const ErrorNavItem = createClass({
|
|||||||
{message ?? 'Conflict: please refresh to get latest changes'}
|
{message ?? 'Conflict: please refresh to get latest changes'}
|
||||||
</div>
|
</div>
|
||||||
</Nav.item>;
|
</Nav.item>;
|
||||||
} else if(status === 412) {
|
}
|
||||||
|
|
||||||
|
if(status === 412) {
|
||||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
Oops!
|
Oops!
|
||||||
<div className='errorContainer' onClick={clearError}>
|
<div className='errorContainer' onClick={clearError}>
|
||||||
@@ -49,6 +52,36 @@ const ErrorNavItem = createClass({
|
|||||||
</Nav.item>;
|
</Nav.item>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(HBErrorCode === '04') {
|
||||||
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
|
Oops!
|
||||||
|
<div className='errorContainer' onClick={clearError}>
|
||||||
|
You are no longer signed in as an author of
|
||||||
|
this brew! Were you signed out from a different
|
||||||
|
window? Visit our log in page, then try again!
|
||||||
|
<br></br>
|
||||||
|
<a target='_blank' rel='noopener noreferrer'
|
||||||
|
href={`https://www.naturalcrit.com/login?redirect=${window.location.href}`}>
|
||||||
|
<div className='confirm'>
|
||||||
|
Sign In
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div className='deny'>
|
||||||
|
Not Now
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Nav.item>;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(response.body?.errors?.[0].reason == 'storageQuotaExceeded') {
|
||||||
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
|
Oops!
|
||||||
|
<div className='errorContainer' onClick={clearError}>
|
||||||
|
Can't save because your Google Drive seems to be full!
|
||||||
|
</div>
|
||||||
|
</Nav.item>;
|
||||||
|
}
|
||||||
|
|
||||||
if(response.req.url.match(/^\/api.*Google.*$/m)){
|
if(response.req.url.match(/^\/api.*Google.*$/m)){
|
||||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
Oops!
|
Oops!
|
||||||
@@ -57,6 +90,7 @@ const ErrorNavItem = createClass({
|
|||||||
expired! Visit our log in page to sign out
|
expired! Visit our log in page to sign out
|
||||||
and sign back in with Google,
|
and sign back in with Google,
|
||||||
then try saving again!
|
then try saving again!
|
||||||
|
<br></br>
|
||||||
<a target='_blank' rel='noopener noreferrer'
|
<a target='_blank' rel='noopener noreferrer'
|
||||||
href={`https://www.naturalcrit.com/login?redirect=${window.location.href}`}>
|
href={`https://www.naturalcrit.com/login?redirect=${window.location.href}`}>
|
||||||
<div className='confirm'>
|
<div className='confirm'>
|
||||||
@@ -70,6 +104,18 @@ const ErrorNavItem = createClass({
|
|||||||
</Nav.item>;
|
</Nav.item>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(HBErrorCode === '09') {
|
||||||
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
|
Oops!
|
||||||
|
<div className='errorContainer' onClick={clearError}>
|
||||||
|
Looks like there was a problem retreiving
|
||||||
|
the theme, or a theme that it inherits,
|
||||||
|
for this brew. Verify that brew <a className='lowercase' target='_blank' rel='noopener noreferrer' href={`/share/${response.body.brewId}`}>
|
||||||
|
{response.body.brewId}</a> still exists!
|
||||||
|
</div>
|
||||||
|
</Nav.item>;
|
||||||
|
}
|
||||||
|
|
||||||
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
|
||||||
Oops!
|
Oops!
|
||||||
<div className='errorContainer'>
|
<div className='errorContainer'>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
font-size : 10px;
|
font-size : 10px;
|
||||||
font-weight : 800;
|
font-weight : 800;
|
||||||
text-transform : uppercase;
|
text-transform : uppercase;
|
||||||
|
.lowercase {
|
||||||
|
text-transform : none;
|
||||||
|
}
|
||||||
a{
|
a{
|
||||||
color : @teal;
|
color : @teal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const dedent = require('dedent-tabs').default;
|
const dedent = require('dedent-tabs').default;
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
|
||||||
const Moment = require('moment');
|
const Moment = require('moment');
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
|||||||
@@ -1,106 +1,287 @@
|
|||||||
@import "naturalcrit/styles/colors.less";
|
@import 'naturalcrit/styles/colors.less';
|
||||||
|
|
||||||
@navbarHeight : 28px;
|
@navbarHeight : 28px;
|
||||||
|
@viewerToolsHeight : 32px;
|
||||||
|
|
||||||
@keyframes pinkColoring {
|
@keyframes pinkColoring {
|
||||||
0% { color : pink; }
|
0% { color : pink; }
|
||||||
50% { color : pink; }
|
50% { color : pink; }
|
||||||
75% { color : red; }
|
75% { color : red; }
|
||||||
100% { color : pink; }
|
100% { color : pink; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes glideDropDown {
|
||||||
|
0% {
|
||||||
|
background-color : #333333;
|
||||||
|
opacity : 0;
|
||||||
|
transform : translate(0px, -100%);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
background-color : #333333;
|
||||||
|
opacity : 1;
|
||||||
|
transform : translate(0px, 0px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.homebrew nav {
|
.homebrew nav {
|
||||||
.homebrewLogo {
|
background-color : #333333;
|
||||||
|
.navContent {
|
||||||
|
position : relative;
|
||||||
|
z-index : 2;
|
||||||
|
display : flex;
|
||||||
|
justify-content : space-between;
|
||||||
|
}
|
||||||
|
.navSection {
|
||||||
|
display : flex;
|
||||||
|
align-items : center;
|
||||||
|
&:last-child .navItem { border-left : 1px solid #666666; }
|
||||||
|
}
|
||||||
|
// "NaturalCrit" logo
|
||||||
|
.navLogo {
|
||||||
|
display : block;
|
||||||
|
margin-top : 0px;
|
||||||
|
margin-right : 8px;
|
||||||
|
margin-left : 8px;
|
||||||
|
color : white;
|
||||||
|
text-decoration : none;
|
||||||
|
&:hover {
|
||||||
|
.name { color : @orange; }
|
||||||
|
svg { fill : @orange; }
|
||||||
|
}
|
||||||
|
svg {
|
||||||
|
height : 13px;
|
||||||
|
margin-right : 0.2em;
|
||||||
|
cursor : pointer;
|
||||||
|
fill : white;
|
||||||
|
}
|
||||||
|
span.name {
|
||||||
|
font-family : 'CodeLight';
|
||||||
|
font-size : 15px;
|
||||||
|
span.crit { font-family : 'CodeBold'; }
|
||||||
|
small {
|
||||||
|
font-family : 'Open Sans';
|
||||||
|
font-size : 0.3em;
|
||||||
|
font-weight : 800;
|
||||||
|
text-transform : uppercase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.navItem {
|
||||||
|
#backgroundColorsHover;
|
||||||
|
.animate(background-color);
|
||||||
|
padding : 8px 12px;
|
||||||
|
font-size : 10px;
|
||||||
|
font-weight : 800;
|
||||||
|
line-height : 13px;
|
||||||
|
color : white;
|
||||||
|
text-decoration : none;
|
||||||
|
text-transform : uppercase;
|
||||||
|
cursor : pointer;
|
||||||
|
background-color : #333333;
|
||||||
|
i {
|
||||||
|
float : right;
|
||||||
|
margin-left : 5px;
|
||||||
|
font-size : 13px;
|
||||||
|
}
|
||||||
|
&.patreon {
|
||||||
|
border-right : 1px solid #666666;
|
||||||
|
border-left : 1px solid #666666;
|
||||||
|
&:hover i { color : red; }
|
||||||
|
i {
|
||||||
|
color : pink;
|
||||||
.animate(color);
|
.animate(color);
|
||||||
font-family : CodeBold;
|
animation-name : pinkColoring;
|
||||||
|
animation-duration : 2s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.editTitle { // this is not needed at all currently - you used to be able to edit the title via the navbar.
|
||||||
|
padding : 2px 12px;
|
||||||
|
input {
|
||||||
|
width : 250px;
|
||||||
|
padding : 2px;
|
||||||
|
margin : 0;
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
font-size : 12px;
|
||||||
|
font-weight : 800;
|
||||||
|
color : white;
|
||||||
|
text-align : center;
|
||||||
|
background-color : transparent;
|
||||||
|
border : 1px solid @blue;
|
||||||
|
outline : none;
|
||||||
|
}
|
||||||
|
.charCount {
|
||||||
|
display : inline-block;
|
||||||
|
margin-left : 8px;
|
||||||
|
color : #666666;
|
||||||
|
text-align : right;
|
||||||
|
vertical-align : bottom;
|
||||||
|
&.max { color : @red; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.brewTitle {
|
||||||
|
flex-grow : 1;
|
||||||
|
font-size : 12px;
|
||||||
|
font-weight : 800;
|
||||||
|
color : white;
|
||||||
|
text-align : center;
|
||||||
|
text-transform : initial;
|
||||||
|
background-color : transparent;
|
||||||
|
}
|
||||||
|
// "The Homebrewery" logo
|
||||||
|
&.homebrewLogo {
|
||||||
|
.animate(color);
|
||||||
|
font-family : 'CodeBold';
|
||||||
font-size : 12px;
|
font-size : 12px;
|
||||||
color : white;
|
color : white;
|
||||||
div {
|
div {
|
||||||
margin-top : 2px;
|
margin-top : 2px;
|
||||||
margin-bottom : -2px;
|
margin-bottom : -2px;
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover { color : @blue; }
|
||||||
color : @blue;
|
|
||||||
}
|
}
|
||||||
}
|
&.metadata {
|
||||||
.editTitle.navItem {
|
position : relative;
|
||||||
padding : 2px 12px;
|
display : flex;
|
||||||
input {
|
|
||||||
font-family : "Open Sans", sans-serif;
|
|
||||||
font-size : 12px;
|
|
||||||
font-weight : 800;
|
|
||||||
width : 250px;
|
|
||||||
margin : 0;
|
|
||||||
padding : 2px;
|
|
||||||
text-align : center;
|
|
||||||
color : white;
|
|
||||||
border : 1px solid @blue;
|
|
||||||
outline : none;
|
|
||||||
background-color : transparent;
|
|
||||||
}
|
|
||||||
.charCount {
|
|
||||||
display : inline-block;
|
|
||||||
margin-left : 8px;
|
|
||||||
text-align : right;
|
|
||||||
vertical-align : bottom;
|
|
||||||
color : #666;
|
|
||||||
&.max {
|
|
||||||
color : @red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.brewTitle.navItem {
|
|
||||||
font-size : 12px;
|
|
||||||
font-weight : 800;
|
|
||||||
height : 100%;
|
|
||||||
text-align : center;
|
|
||||||
text-transform : initial;
|
|
||||||
color : white;
|
|
||||||
background-color : transparent;
|
|
||||||
flex-grow : 1;
|
flex-grow : 1;
|
||||||
}
|
align-items : center;
|
||||||
.save-menu {
|
height : 100%;
|
||||||
.dropdown {
|
padding : 0;
|
||||||
z-index : 1000;
|
i { margin-right : 10px;}
|
||||||
}
|
.window {
|
||||||
.navItem i.fa-power-off {
|
position : absolute;
|
||||||
color : red;
|
bottom : 0;
|
||||||
|
left : 50%;
|
||||||
|
z-index : -1;
|
||||||
|
display : flex;
|
||||||
|
flex-flow : row wrap;
|
||||||
|
align-content : baseline;
|
||||||
|
justify-content : flex-start;
|
||||||
|
width : 440px;
|
||||||
|
max-height : ~'calc(100vh - 28px)';
|
||||||
|
padding : 0 10px 5px;
|
||||||
|
margin : 0 auto;
|
||||||
|
background-color : #333333;
|
||||||
|
border : 3px solid #444444;
|
||||||
|
border-top : unset;
|
||||||
|
border-radius : 0 0 5px 5px;
|
||||||
|
box-shadow : inset 0 7px 9px -7px #111111;
|
||||||
|
transition : transform 0.4s, opacity 0.4s;
|
||||||
&.active {
|
&.active {
|
||||||
color : rgb(0, 182, 52);
|
opacity : 1;
|
||||||
filter : drop-shadow(0 0 2px rgba(0, 182, 52, 0.765));
|
transform : translateX(-50%) translateY(100%);
|
||||||
|
}
|
||||||
|
&.inactive {
|
||||||
|
opacity : 0;
|
||||||
|
transform : translateX(-50%) translateY(0%);
|
||||||
|
}
|
||||||
|
.row {
|
||||||
|
display : flex;
|
||||||
|
flex-flow : row wrap;
|
||||||
|
width : 100%;
|
||||||
|
h4 {
|
||||||
|
box-sizing : border-box;
|
||||||
|
display : block;
|
||||||
|
flex-basis : 20%;
|
||||||
|
flex-grow : 1;
|
||||||
|
min-width : 76px;
|
||||||
|
padding : 5px 0;
|
||||||
|
color : #BBBBBB;
|
||||||
|
text-align : center;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
flex-basis : 80%;
|
||||||
|
flex-grow : 1;
|
||||||
|
padding : 5px 0;
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
font-size : 10px;
|
||||||
|
font-weight : normal;
|
||||||
|
text-transform : initial;
|
||||||
|
.tag {
|
||||||
|
display : inline-block;
|
||||||
|
padding : 2px;
|
||||||
|
margin : 2px 2px;
|
||||||
|
background-color : #444444;
|
||||||
|
border : 2px solid grey;
|
||||||
|
border-radius : 5px;
|
||||||
|
}
|
||||||
|
a.userPageLink {
|
||||||
|
color : white;
|
||||||
|
text-decoration : none;
|
||||||
|
&:hover { text-decoration : underline; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&:nth-of-type(even) { background-color : #555555; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.patreon.navItem {
|
&.warning {
|
||||||
border-right : 1px solid #666;
|
position : relative;
|
||||||
border-left : 1px solid #666;
|
color : white;
|
||||||
&:hover i {
|
background-color : @orange;
|
||||||
color : red;
|
&:hover > .dropdown { visibility : visible; }
|
||||||
}
|
.dropdown {
|
||||||
i {
|
position : absolute;
|
||||||
.animate(color);
|
top : 28px;
|
||||||
animation-name : pinkColoring;
|
left : 0;
|
||||||
animation-duration : 2s;
|
z-index : 10000;
|
||||||
color : pink;
|
box-sizing : border-box;
|
||||||
|
display : block;
|
||||||
|
width : 100%;
|
||||||
|
padding : 13px 5px;
|
||||||
|
text-align : center;
|
||||||
|
visibility : hidden;
|
||||||
|
background-color : #333333;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.recent.navDropdownContainer {
|
&.account {
|
||||||
|
min-width : 100px;
|
||||||
|
&.username { text-transform : none;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.navDropdownContainer {
|
||||||
|
position : relative;
|
||||||
|
.navDropdown {
|
||||||
|
position: absolute;
|
||||||
|
top: 28px;
|
||||||
|
right: 0px;
|
||||||
|
z-index: 10000;
|
||||||
|
width: max-content;
|
||||||
|
min-width:100%;
|
||||||
|
max-height: calc(100vh - 28px);
|
||||||
|
overflow: hidden auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
.navItem {
|
||||||
|
position : relative;
|
||||||
|
display : flex;
|
||||||
|
justify-content : space-between;
|
||||||
|
align-items : center;
|
||||||
|
width : 100%;
|
||||||
|
border : 1px solid #888888;
|
||||||
|
border-bottom : 0;
|
||||||
|
animation-name : glideDropDown;
|
||||||
|
animation-duration : 0.4s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.recent {
|
||||||
position : relative;
|
position : relative;
|
||||||
.navDropdown .navItem {
|
.navDropdown .navItem {
|
||||||
overflow : hidden auto;
|
|
||||||
max-height : ~"calc(100vh - 28px)";
|
|
||||||
scrollbar-color : #666 #333;
|
|
||||||
scrollbar-width : thin;
|
|
||||||
|
|
||||||
|
|
||||||
#backgroundColorsHover;
|
#backgroundColorsHover;
|
||||||
.animate(background-color);
|
.animate(background-color);
|
||||||
position : relative;
|
position : relative;
|
||||||
display : block;
|
|
||||||
overflow : clip;
|
|
||||||
box-sizing : border-box;
|
box-sizing : border-box;
|
||||||
|
display : block;
|
||||||
|
max-width : 15em;
|
||||||
|
max-height : ~'calc(100vh - 28px)';
|
||||||
padding : 8px 5px 13px;
|
padding : 8px 5px 13px;
|
||||||
text-decoration : none;
|
overflow : hidden auto;
|
||||||
color : white;
|
color : white;
|
||||||
border-top : 1px solid #888;
|
text-decoration : none;
|
||||||
background-color : #333;
|
background-color : #333333;
|
||||||
|
border-top : 1px solid #888888;
|
||||||
|
scrollbar-color : #666666 #333333;
|
||||||
|
scrollbar-width : thin;
|
||||||
.clear {
|
.clear {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 50%;
|
top : 50%;
|
||||||
@@ -108,18 +289,16 @@
|
|||||||
display : none;
|
display : none;
|
||||||
width : 20px;
|
width : 20px;
|
||||||
height : 100%;
|
height : 100%;
|
||||||
transform : translateY(-50%);
|
background-color : #333333;
|
||||||
opacity : 70%;
|
|
||||||
border-radius : 3px;
|
border-radius : 3px;
|
||||||
background-color : #333;
|
opacity : 70%;
|
||||||
&:hover {
|
transform : translateY(-50%);
|
||||||
opacity : 100%;
|
&:hover { opacity : 100%; }
|
||||||
}
|
|
||||||
i {
|
i {
|
||||||
font-size : 10px;
|
|
||||||
width : 100%;
|
width : 100%;
|
||||||
height : 100%;
|
height : 100%;
|
||||||
margin : 0;
|
margin : 0;
|
||||||
|
font-size : 10px;
|
||||||
text-align : center;
|
text-align : center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,141 +311,42 @@
|
|||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
display : inline-block;
|
display : inline-block;
|
||||||
overflow : hidden;
|
|
||||||
width : 100%;
|
width : 100%;
|
||||||
white-space : nowrap;
|
overflow : hidden auto;
|
||||||
text-overflow : ellipsis;
|
text-overflow : ellipsis;
|
||||||
|
white-space : nowrap;
|
||||||
}
|
}
|
||||||
.time {
|
.time {
|
||||||
font-size : 0.7em;
|
|
||||||
position : absolute;
|
position : absolute;
|
||||||
right : 2px;
|
right : 2px;
|
||||||
bottom : 2px;
|
bottom : 2px;
|
||||||
color : #888;
|
font-size : 0.7em;
|
||||||
|
color : #888888;
|
||||||
}
|
}
|
||||||
&.header {
|
&.header {
|
||||||
display : block;
|
|
||||||
box-sizing : border-box;
|
box-sizing : border-box;
|
||||||
|
display : block;
|
||||||
padding : 5px 0;
|
padding : 5px 0;
|
||||||
|
color : #BBBBBB;
|
||||||
text-align : center;
|
text-align : center;
|
||||||
color : #BBB;
|
background-color : #333333;
|
||||||
border-top : 1px solid #888;
|
border-top : 1px solid #888888;
|
||||||
background-color : #333;
|
&:nth-of-type(1) { background-color : darken(@teal, 20%); }
|
||||||
&:nth-of-type(1) {
|
&:nth-of-type(2) { background-color : darken(@purple, 30%); }
|
||||||
background-color : darken(@teal, 20%);
|
|
||||||
}
|
|
||||||
&:nth-of-type(2) {
|
|
||||||
background-color : darken(@purple, 30%);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.metadata.navItem {
|
|
||||||
position : relative;
|
|
||||||
display : flex;
|
|
||||||
align-items : center;
|
|
||||||
height : 100%;
|
|
||||||
padding : 0;
|
|
||||||
flex-grow : 1;
|
|
||||||
i {
|
|
||||||
margin-right : 10px;
|
|
||||||
}
|
}
|
||||||
.window {
|
|
||||||
position : absolute;
|
// this should likely be refactored into .navDropdownContainer
|
||||||
z-index : -1;
|
.save-menu {
|
||||||
bottom : 0;
|
.dropdown { z-index : 1000; }
|
||||||
left : 50%;
|
.navItem i.fa-power-off {
|
||||||
display : flex;
|
color : red;
|
||||||
justify-content : flex-start;
|
|
||||||
width : 440px;
|
|
||||||
max-height : ~"calc(100vh - 28px)";
|
|
||||||
margin : 0 auto;
|
|
||||||
padding : 0 10px 5px;
|
|
||||||
transition : transform 0.4s, opacity 0.4s;
|
|
||||||
border : 3px solid #444;
|
|
||||||
border-top : unset;
|
|
||||||
border-radius : 0 0 5px 5px;
|
|
||||||
background-color : #333;
|
|
||||||
box-shadow : inset 0 7px 9px -7px #111;
|
|
||||||
flex-flow : row wrap;
|
|
||||||
align-content : baseline;
|
|
||||||
&.active {
|
&.active {
|
||||||
transform : translateX(-50%) translateY(100%);
|
color : rgb(0, 182, 52);
|
||||||
opacity : 1;
|
filter : drop-shadow(0 0 2px rgba(0, 182, 52, 0.765));
|
||||||
}
|
|
||||||
&.inactive {
|
|
||||||
transform : translateX(-50%) translateY(0%);
|
|
||||||
opacity : 0;
|
|
||||||
}
|
|
||||||
.row {
|
|
||||||
display : flex;
|
|
||||||
width : 100%;
|
|
||||||
flex-flow : row wrap;
|
|
||||||
h4 {
|
|
||||||
display : block;
|
|
||||||
box-sizing : border-box;
|
|
||||||
min-width : 76px;
|
|
||||||
padding : 5px 0;
|
|
||||||
text-align : center;
|
|
||||||
color : #BBB;
|
|
||||||
flex-basis : 20%;
|
|
||||||
flex-grow : 1;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
font-family : "Open Sans", sans-serif;
|
|
||||||
font-size : 10px;
|
|
||||||
font-weight : normal;
|
|
||||||
padding : 5px 0;
|
|
||||||
text-transform : initial;
|
|
||||||
flex-basis : 80%;
|
|
||||||
flex-grow : 1;
|
|
||||||
.tag {
|
|
||||||
display : inline-block;
|
|
||||||
margin : 2px 2px;
|
|
||||||
padding : 2px;
|
|
||||||
border : 2px solid grey;
|
|
||||||
border-radius : 5px;
|
|
||||||
background-color : #444;
|
|
||||||
}
|
|
||||||
a.userPageLink {
|
|
||||||
text-decoration : none;
|
|
||||||
color : white;
|
|
||||||
&:hover {
|
|
||||||
text-decoration : underline;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:nth-of-type(even) {
|
|
||||||
background-color : #555;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.warning.navItem {
|
|
||||||
position : relative;
|
|
||||||
color : white;
|
|
||||||
background-color : @orange;
|
|
||||||
&:hover > .dropdown {
|
|
||||||
visibility : visible;
|
|
||||||
}
|
|
||||||
.dropdown {
|
|
||||||
position : absolute;
|
|
||||||
z-index : 10000;
|
|
||||||
top : 28px;
|
|
||||||
left : 0;
|
|
||||||
display : block;
|
|
||||||
visibility : hidden;
|
|
||||||
box-sizing : border-box;
|
|
||||||
width : 100%;
|
|
||||||
padding : 13px 5px;
|
|
||||||
text-align : center;
|
|
||||||
background-color : #333;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.account.navItem {
|
|
||||||
min-width : 100px;
|
|
||||||
}
|
|
||||||
.account.username.navItem {
|
|
||||||
text-transform : none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +1,64 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
|
const _ = require('lodash');
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
const { splitTextStyleAndMetadata } = require('../../../shared/helpers.js'); // Importing the function from helpers.js
|
||||||
|
|
||||||
module.exports = function(props){
|
const BREWKEY = 'homebrewery-new';
|
||||||
return <Nav.item
|
const STYLEKEY = 'homebrewery-new-style';
|
||||||
href='/new'
|
const METAKEY = 'homebrewery-new-meta';
|
||||||
color='purple'
|
|
||||||
icon='fas fa-plus-square'>
|
const NewBrew = ()=>{
|
||||||
new
|
const handleFileChange = (e)=>{
|
||||||
</Nav.item>;
|
const file = e.target.files[0];
|
||||||
|
if(file) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = (e)=>{
|
||||||
|
const fileContent = e.target.result;
|
||||||
|
const newBrew = {
|
||||||
|
text : fileContent,
|
||||||
|
style : ''
|
||||||
};
|
};
|
||||||
|
if(fileContent.startsWith('```metadata')) {
|
||||||
|
splitTextStyleAndMetadata(newBrew); // Modify newBrew directly
|
||||||
|
localStorage.setItem(BREWKEY, newBrew.text);
|
||||||
|
localStorage.setItem(STYLEKEY, newBrew.style);
|
||||||
|
localStorage.setItem(METAKEY, JSON.stringify(_.pick(newBrew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang'])));
|
||||||
|
window.location.href = '/new';
|
||||||
|
} else {
|
||||||
|
alert('This file is invalid, please, enter a valid file');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Nav.dropdown>
|
||||||
|
<Nav.item
|
||||||
|
className='new'
|
||||||
|
color='purple'
|
||||||
|
icon='fa-solid fa-plus-square'>
|
||||||
|
new
|
||||||
|
</Nav.item>
|
||||||
|
<Nav.item
|
||||||
|
className='fromBlank'
|
||||||
|
href='/new'
|
||||||
|
newTab={true}
|
||||||
|
color='purple'
|
||||||
|
icon='fa-solid fa-file'>
|
||||||
|
from blank
|
||||||
|
</Nav.item>
|
||||||
|
|
||||||
|
<Nav.item
|
||||||
|
className='fromFile'
|
||||||
|
color='purple'
|
||||||
|
icon='fa-solid fa-upload'
|
||||||
|
onClick={()=>{ document.getElementById('uploadTxt').click(); }}>
|
||||||
|
<input id='uploadTxt' className='newFromLocal' type='file' onChange={handleFileChange} style={{ display: 'none' }} />
|
||||||
|
from file
|
||||||
|
</Nav.item>
|
||||||
|
</Nav.dropdown>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = NewBrew;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
const { printCurrentBrew } = require('../../../shared/helpers.js');
|
||||||
|
|
||||||
module.exports = function(props){
|
module.exports = function(){
|
||||||
return <Nav.item newTab={true} href={`/print/${props.shareId}?dialog=true`} color='purple' icon='far fa-file-pdf'>
|
return <Nav.item onClick={printCurrentBrew} color='purple' icon='far fa-file-pdf'>
|
||||||
get PDF
|
get PDF
|
||||||
</Nav.item>;
|
</Nav.item>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const cx = require('classnames');
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
|
||||||
const MAX_URL_SIZE = 2083;
|
|
||||||
const MAIN_URL = 'https://www.reddit.com/r/UnearthedArcana/submit?selftext=true';
|
const MAIN_URL = 'https://www.reddit.com/r/UnearthedArcana/submit?selftext=true';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
client/homebrew/navbar/vault.navitem.jsx
Normal file
17
client/homebrew/navbar/vault.navitem.jsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const React = require('react');
|
||||||
|
|
||||||
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
|
||||||
|
module.exports = function (props) {
|
||||||
|
return (
|
||||||
|
<Nav.item
|
||||||
|
color='purple'
|
||||||
|
icon='fas fa-dungeon'
|
||||||
|
href='/vault'
|
||||||
|
newTab={false}
|
||||||
|
rel='noopener noreferrer'
|
||||||
|
>
|
||||||
|
Vault
|
||||||
|
</Nav.item>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,102 +1,82 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const cx = require('classnames');
|
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
const UIPage = require('../basePages/uiPage/uiPage.jsx');
|
const UIPage = require('../basePages/uiPage/uiPage.jsx');
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
|
||||||
|
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
|
||||||
const Account = require('../../navbar/account.navitem.jsx');
|
|
||||||
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
|
||||||
|
|
||||||
const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx');
|
const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx');
|
||||||
|
|
||||||
let SAVEKEY = '';
|
let SAVEKEY = '';
|
||||||
|
|
||||||
const AccountPage = createClass({
|
const AccountPage = (props)=>{
|
||||||
displayName : 'AccountPage',
|
// destructure props and set state for save location
|
||||||
getDefaultProps : function() {
|
const { accountDetails, brew } = props;
|
||||||
return {
|
const [saveLocation, setSaveLocation] = React.useState('');
|
||||||
brew : {},
|
|
||||||
uiItems : {}
|
// initialize save location from local storage based on user id
|
||||||
};
|
React.useEffect(()=>{
|
||||||
},
|
if(!saveLocation && accountDetails.username) {
|
||||||
getInitialState : function() {
|
SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${accountDetails.username}`;
|
||||||
return {
|
// if no SAVEKEY in local storage, default save location to Google Drive if user has Google account.
|
||||||
uiItems : this.props.uiItems
|
|
||||||
};
|
|
||||||
},
|
|
||||||
componentDidMount : function(){
|
|
||||||
if(!this.state.saveLocation && this.props.uiItems.username) {
|
|
||||||
SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${this.props.uiItems.username}`;
|
|
||||||
let saveLocation = window.localStorage.getItem(SAVEKEY);
|
let saveLocation = window.localStorage.getItem(SAVEKEY);
|
||||||
saveLocation = saveLocation ?? (this.state.uiItems.googleId ? 'GOOGLE-DRIVE' : 'HOMEBREWERY');
|
saveLocation = saveLocation ?? (accountDetails.googleId ? 'GOOGLE-DRIVE' : 'HOMEBREWERY');
|
||||||
this.makeActive(saveLocation);
|
setActiveSaveLocation(saveLocation);
|
||||||
}
|
}
|
||||||
},
|
}, []);
|
||||||
|
|
||||||
makeActive : function(newSelection){
|
const setActiveSaveLocation = (newSelection)=>{
|
||||||
if(this.state.saveLocation == newSelection) return;
|
if(saveLocation === newSelection) return;
|
||||||
window.localStorage.setItem(SAVEKEY, newSelection);
|
window.localStorage.setItem(SAVEKEY, newSelection);
|
||||||
this.setState({
|
setSaveLocation(newSelection);
|
||||||
saveLocation : newSelection
|
};
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
renderButton : function(name, key, shouldRender=true){
|
// todo: should this be a set of radio buttons (well styled) since it's either/or choice?
|
||||||
if(!shouldRender) return;
|
const renderSaveLocationButton = (name, key, shouldRender = true)=>{
|
||||||
return <button className={this.state.saveLocation==key ? 'active' : ''} onClick={()=>{this.makeActive(key);}}>{name}</button>;
|
if(!shouldRender) return null;
|
||||||
},
|
return (
|
||||||
|
<button className={saveLocation === key ? 'active' : ''} onClick={()=>{setActiveSaveLocation(key);}}>
|
||||||
|
{name}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
renderNavItems : function() {
|
// render the entirety of the account page content
|
||||||
return <Navbar>
|
const renderAccountPage = ()=>{
|
||||||
<Nav.section>
|
return (
|
||||||
<NewBrew />
|
<>
|
||||||
<HelpNavItem />
|
|
||||||
<RecentNavItem />
|
|
||||||
<Account />
|
|
||||||
</Nav.section>
|
|
||||||
</Navbar>;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderUiItems : function() {
|
|
||||||
return <>
|
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h1>Account Information <i className='fas fa-user'></i></h1>
|
<h1>Account Information <i className='fas fa-user'></i></h1>
|
||||||
<p><strong>Username: </strong> {this.props.uiItems.username || 'No user currently logged in'}</p>
|
<p><strong>Username: </strong>{accountDetails.username || 'No user currently logged in'}</p>
|
||||||
<p><strong>Last Login: </strong> {moment(this.props.uiItems.issued).format('dddd, MMMM Do YYYY, h:mm:ss a ZZ') || '-'}</p>
|
<p><strong>Last Login: </strong>{moment(accountDetails.issued).format('dddd, MMMM Do YYYY, h:mm:ss a ZZ') || '-'}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h3>Homebrewery Information <NaturalCritIcon /></h3>
|
<h3>Homebrewery Information <NaturalCritIcon /></h3>
|
||||||
<p><strong>Brews on Homebrewery: </strong> {this.props.uiItems.mongoCount}</p>
|
<p><strong>Brews on Homebrewery: </strong>{accountDetails.mongoCount}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h3>Google Information <i className='fab fa-google-drive'></i></h3>
|
<h3>Google Information <i className='fab fa-google-drive'></i></h3>
|
||||||
<p><strong>Linked to Google: </strong> {this.props.uiItems.googleId ? 'YES' : 'NO'}</p>
|
<p><strong>Linked to Google: </strong>{accountDetails.googleId ? 'YES' : 'NO'}</p>
|
||||||
{this.props.uiItems.googleId &&
|
{accountDetails.googleId && (
|
||||||
<p>
|
<p>
|
||||||
<strong>Brews on Google Drive: </strong> {this.props.uiItems.googleCount ?? <>Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a></>}
|
<strong>Brews on Google Drive: </strong>{accountDetails.googleCount ?? (
|
||||||
|
<>
|
||||||
|
Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h4>Default Save Location</h4>
|
<h4>Default Save Location</h4>
|
||||||
{this.renderButton('Homebrewery', 'HOMEBREWERY')}
|
{renderSaveLocationButton('Homebrewery', 'HOMEBREWERY')}
|
||||||
{this.renderButton('Google Drive', 'GOOGLE-DRIVE', this.state.uiItems.googleId)}
|
{renderSaveLocationButton('Google Drive', 'GOOGLE-DRIVE', accountDetails.googleId)}
|
||||||
</div>
|
</div>
|
||||||
</>;
|
</>
|
||||||
},
|
);
|
||||||
|
};
|
||||||
|
|
||||||
render : function(){
|
// return the account page inside the base layout wrapper (with navbar etc).
|
||||||
return <UIPage brew={this.props.brew}>
|
return (
|
||||||
{this.renderUiItems()}
|
<UIPage brew={brew}>
|
||||||
</UIPage>;
|
{renderAccountPage()}
|
||||||
}
|
</UIPage>);
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports = AccountPage;
|
module.exports = AccountPage;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
require('./brewItem.less');
|
require('./brewItem.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
|
||||||
const cx = require('classnames');
|
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const request = require('../../../../utils/request-middleware.js');
|
const request = require('../../../../utils/request-middleware.js');
|
||||||
|
|
||||||
@@ -20,7 +18,9 @@ const BrewItem = createClass({
|
|||||||
authors : [],
|
authors : [],
|
||||||
stubbed : true
|
stubbed : true
|
||||||
},
|
},
|
||||||
reportError : ()=>{}
|
updateListFilter : ()=>{},
|
||||||
|
reportError : ()=>{},
|
||||||
|
renderStorage : true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -44,6 +44,10 @@ const BrewItem = createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateFilter : function(type, term){
|
||||||
|
this.props.updateListFilter(type, term);
|
||||||
|
},
|
||||||
|
|
||||||
renderDeleteBrewLink : function(){
|
renderDeleteBrewLink : function(){
|
||||||
if(!this.props.brew.editId) return;
|
if(!this.props.brew.editId) return;
|
||||||
|
|
||||||
@@ -92,6 +96,7 @@ const BrewItem = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderStorageIcon : function(){
|
renderStorageIcon : function(){
|
||||||
|
if(!this.props.renderStorage) return;
|
||||||
if(this.props.brew.googleId) {
|
if(this.props.brew.googleId) {
|
||||||
return <span title={this.props.brew.webViewLink ? 'Your Google Drive Storage': 'Another User\'s Google Drive Storage'}>
|
return <span title={this.props.brew.webViewLink ? 'Your Google Drive Storage': 'Another User\'s Google Drive Storage'}>
|
||||||
<a href={this.props.brew.webViewLink} target='_blank'>
|
<a href={this.props.brew.webViewLink} target='_blank'>
|
||||||
@@ -109,6 +114,9 @@ const BrewItem = createClass({
|
|||||||
const brew = this.props.brew;
|
const brew = this.props.brew;
|
||||||
if(Array.isArray(brew.tags)) { // temporary fix until dud tags are cleaned
|
if(Array.isArray(brew.tags)) { // temporary fix until dud tags are cleaned
|
||||||
brew.tags = brew.tags?.filter((tag)=>tag); //remove tags that are empty strings
|
brew.tags = brew.tags?.filter((tag)=>tag); //remove tags that are empty strings
|
||||||
|
brew.tags.sort((a, b)=>{
|
||||||
|
return a.indexOf(':') - b.indexOf(':') != 0 ? a.indexOf(':') - b.indexOf(':') : a.toLowerCase().localeCompare(b.toLowerCase());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const dateFormatString = 'YYYY-MM-DD HH:mm:ss';
|
const dateFormatString = 'YYYY-MM-DD HH:mm:ss';
|
||||||
|
|
||||||
@@ -125,17 +133,25 @@ const BrewItem = createClass({
|
|||||||
<div className='info'>
|
<div className='info'>
|
||||||
|
|
||||||
{brew.tags?.length ? <>
|
{brew.tags?.length ? <>
|
||||||
<div className='brewTags' title={`Tags:\n${brew.tags.join('\n')}`}>
|
<div className='brewTags' title={`${brew.tags.length} tags:\n${brew.tags.join('\n')}`}>
|
||||||
<i className='fas fa-tags'/>
|
<i className='fas fa-tags'/>
|
||||||
{brew.tags.map((tag, idx)=>{
|
{brew.tags.map((tag, idx)=>{
|
||||||
const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/);
|
const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/);
|
||||||
return <span key={idx} className={matches[1]}>{matches[2]}</span>;
|
return <span key={idx} className={matches[1]} onClick={()=>{this.updateFilter(tag);}}>{matches[2]}</span>;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</> : <></>
|
</> : <></>
|
||||||
}
|
}
|
||||||
<span title={`Authors:\n${brew.authors?.join('\n')}`}>
|
<span title={`Authors:\n${brew.authors?.join('\n')}`}>
|
||||||
<i className='fas fa-user'/> {brew.authors?.join(', ')}
|
<i className='fas fa-user'/> {brew.authors?.map((author, index)=>(
|
||||||
|
<React.Fragment key={index}>
|
||||||
|
{author === 'hidden'
|
||||||
|
? <span title="Username contained an email address; hidden to protect user's privacy">{author}</span>
|
||||||
|
: <a href={`/user/${author}`}>{author}</a>
|
||||||
|
}
|
||||||
|
{index < brew.authors.length - 1 && ', '}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
<span title={`Last viewed: ${moment(brew.lastViewed).local().format(dateFormatString)}`}>
|
<span title={`Last viewed: ${moment(brew.lastViewed).local().format(dateFormatString)}`}>
|
||||||
|
|||||||
@@ -48,6 +48,10 @@
|
|||||||
&>span{
|
&>span{
|
||||||
margin-right : 12px;
|
margin-right : 12px;
|
||||||
line-height : 1.5em;
|
line-height : 1.5em;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color:inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.brewTags span {
|
.brewTags span {
|
||||||
@@ -59,6 +63,41 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
border-color: currentColor;
|
||||||
|
cursor : pointer;
|
||||||
|
&:before {
|
||||||
|
font-family: 'Font Awesome 5 Free';
|
||||||
|
font-size: 12px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
&.type {
|
||||||
|
background-color: #0080003b;
|
||||||
|
color: #008000;
|
||||||
|
&:before{
|
||||||
|
content: '\f0ad';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.group {
|
||||||
|
background-color: #5050503b;
|
||||||
|
color: #000000;
|
||||||
|
&:before{
|
||||||
|
content: '\f500';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.meta {
|
||||||
|
background-color: #0000803b;
|
||||||
|
color: #000080;
|
||||||
|
&:before{
|
||||||
|
content: '\f05a';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.system {
|
||||||
|
background-color: #8000003b;
|
||||||
|
color: #800000;
|
||||||
|
&:before{
|
||||||
|
content: '\f518';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&:hover{
|
&:hover{
|
||||||
.links{
|
.links{
|
||||||
@@ -85,6 +124,7 @@
|
|||||||
opacity : 0.6;
|
opacity : 0.6;
|
||||||
font-size : 1.3em;
|
font-size : 1.3em;
|
||||||
color : white;
|
color : white;
|
||||||
|
text-decoration : unset;
|
||||||
&:hover{
|
&:hover{
|
||||||
opacity : 1;
|
opacity : 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const ListPage = createClass({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
filterString : this.props.query?.filter || '',
|
filterString : this.props.query?.filter || '',
|
||||||
|
filterTags : [],
|
||||||
sortType : this.props.query?.sort || null,
|
sortType : this.props.query?.sort || null,
|
||||||
sortDir : this.props.query?.dir || null,
|
sortDir : this.props.query?.dir || null,
|
||||||
query : this.props.query,
|
query : this.props.query,
|
||||||
@@ -82,7 +83,7 @@ const ListPage = createClass({
|
|||||||
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
||||||
|
|
||||||
return _.map(brews, (brew, idx)=>{
|
return _.map(brews, (brew, idx)=>{
|
||||||
return <BrewItem brew={brew} key={idx} reportError={this.props.reportError}/>;
|
return <BrewItem brew={brew} key={idx} reportError={this.props.reportError} updateListFilter={ (tag)=>{ this.updateUrl(this.state.filterString, this.state.sortType, this.state.sortDir, tag); }}/>;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -136,13 +137,33 @@ const ListPage = createClass({
|
|||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateUrl : function(filterTerm, sortType, sortDir){
|
updateUrl : function(filterTerm, sortType, sortDir, filterTag=''){
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
const urlParams = new URLSearchParams(url.search);
|
const urlParams = new URLSearchParams(url.search);
|
||||||
|
|
||||||
urlParams.set('sort', sortType);
|
urlParams.set('sort', sortType);
|
||||||
urlParams.set('dir', sortDir);
|
urlParams.set('dir', sortDir);
|
||||||
|
|
||||||
|
let filterTags = urlParams.getAll('tag');
|
||||||
|
if(filterTag != '') {
|
||||||
|
if(filterTags.findIndex((tag)=>{return tag.toLowerCase()==filterTag.toLowerCase();}) == -1){
|
||||||
|
filterTags.push(filterTag);
|
||||||
|
} else {
|
||||||
|
filterTags = filterTags.filter((tag)=>{ return tag.toLowerCase() != filterTag.toLowerCase(); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlParams.delete('tag');
|
||||||
|
// Add tags to URL in the order they were clicked
|
||||||
|
filterTags.forEach((tag)=>{ urlParams.append('tag', tag); });
|
||||||
|
// Sort tags before updating state
|
||||||
|
filterTags.sort((a, b)=>{
|
||||||
|
return a.indexOf(':') - b.indexOf(':') != 0 ? a.indexOf(':') - b.indexOf(':') : a.toLowerCase().localeCompare(b.toLowerCase());
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
filterTags
|
||||||
|
});
|
||||||
|
|
||||||
if(!filterTerm)
|
if(!filterTerm)
|
||||||
urlParams.delete('filter');
|
urlParams.delete('filter');
|
||||||
else
|
else
|
||||||
@@ -166,6 +187,16 @@ const ListPage = createClass({
|
|||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderTagsOptions : function(){
|
||||||
|
if(this.state.filterTags?.length == 0) return;
|
||||||
|
return <div className='tags-container'>
|
||||||
|
{_.map(this.state.filterTags, (tag, idx)=>{
|
||||||
|
const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/);
|
||||||
|
return <span key={idx} className={matches[1]} onClick={()=>{ this.updateUrl(this.state.filterString, this.state.sortType, this.state.sortDir, tag); }}>{matches[2]}</span>;
|
||||||
|
})}
|
||||||
|
</div>;
|
||||||
|
},
|
||||||
|
|
||||||
renderSortOptions : function(){
|
renderSortOptions : function(){
|
||||||
return <div className='sort-container'>
|
return <div className='sort-container'>
|
||||||
<h6>Sort by :</h6>
|
<h6>Sort by :</h6>
|
||||||
@@ -176,9 +207,6 @@ const ListPage = createClass({
|
|||||||
{/* {this.renderSortOption('Latest', 'latest')} */}
|
{/* {this.renderSortOption('Latest', 'latest')} */}
|
||||||
|
|
||||||
{this.renderFilterOption()}
|
{this.renderFilterOption()}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -186,14 +214,28 @@ const ListPage = createClass({
|
|||||||
const testString = _.deburr(this.state.filterString).toLowerCase();
|
const testString = _.deburr(this.state.filterString).toLowerCase();
|
||||||
|
|
||||||
brews = _.filter(brews, (brew)=>{
|
brews = _.filter(brews, (brew)=>{
|
||||||
|
// Filter by user entered text
|
||||||
const brewStrings = _.deburr([
|
const brewStrings = _.deburr([
|
||||||
brew.title,
|
brew.title,
|
||||||
brew.description,
|
brew.description,
|
||||||
brew.tags].join('\n')
|
brew.tags].join('\n')
|
||||||
.toLowerCase());
|
.toLowerCase());
|
||||||
|
|
||||||
return brewStrings.includes(testString);
|
const filterTextTest = brewStrings.includes(testString);
|
||||||
|
|
||||||
|
// Filter by user selected tags
|
||||||
|
let filterTagTest = true;
|
||||||
|
if(this.state.filterTags.length > 0){
|
||||||
|
filterTagTest = Array.isArray(brew.tags) && this.state.filterTags?.every((tag)=>{
|
||||||
|
return brew.tags.findIndex((brewTag)=>{
|
||||||
|
return brewTag.toLowerCase() == tag.toLowerCase();
|
||||||
|
}) >= 0;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return filterTextTest && filterTagTest;
|
||||||
|
});
|
||||||
|
|
||||||
return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
|
return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -220,9 +262,11 @@ const ListPage = createClass({
|
|||||||
render : function(){
|
render : function(){
|
||||||
return <div className='listPage sitePage'>
|
return <div className='listPage sitePage'>
|
||||||
{/*<style>@layer V3_5ePHB, bundle;</style>*/}
|
{/*<style>@layer V3_5ePHB, bundle;</style>*/}
|
||||||
<link href='/themes/V3/5ePHB/style.css' rel='stylesheet'/>
|
<link href='/themes/V3/Blank/style.css' type='text/css' rel='stylesheet'/>
|
||||||
|
<link href='/themes/V3/5ePHB/style.css' type='text/css' rel='stylesheet'/>
|
||||||
{this.props.navItems}
|
{this.props.navItems}
|
||||||
{this.renderSortOptions()}
|
{this.renderSortOptions()}
|
||||||
|
{this.renderTagsOptions()}
|
||||||
|
|
||||||
<div className='content V3'>
|
<div className='content V3'>
|
||||||
<div className='page'>
|
<div className='page'>
|
||||||
|
|||||||
@@ -2,17 +2,18 @@
|
|||||||
.noColumns(){
|
.noColumns(){
|
||||||
column-count : auto;
|
column-count : auto;
|
||||||
column-fill : auto;
|
column-fill : auto;
|
||||||
column-gap : auto;
|
column-gap : normal;
|
||||||
column-width : auto;
|
column-width : auto;
|
||||||
-webkit-column-count : auto;
|
-webkit-column-count : auto;
|
||||||
-moz-column-count : auto;
|
-moz-column-count : auto;
|
||||||
-webkit-column-width : auto;
|
-webkit-column-width : auto;
|
||||||
-moz-column-width : auto;
|
-moz-column-width : auto;
|
||||||
-webkit-column-gap : auto;
|
-webkit-column-gap : normal;
|
||||||
-moz-column-gap : auto;
|
-moz-column-gap : normal;
|
||||||
height : auto;
|
height : auto;
|
||||||
min-height : 279.4mm;
|
min-height : 279.4mm;
|
||||||
margin : 20px auto;
|
margin : 20px auto;
|
||||||
|
contain : unset;
|
||||||
}
|
}
|
||||||
.listPage{
|
.listPage{
|
||||||
.content{
|
.content{
|
||||||
@@ -124,4 +125,66 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.tags-container {
|
||||||
|
height : 30px;
|
||||||
|
background-color : #555;
|
||||||
|
border-top : 1px solid #666;
|
||||||
|
border-bottom : 1px solid #666;
|
||||||
|
color : white;
|
||||||
|
display : flex;
|
||||||
|
justify-content : center;
|
||||||
|
align-items : center;
|
||||||
|
column-gap : 15px;
|
||||||
|
row-gap : 5px;
|
||||||
|
flex-wrap : wrap;
|
||||||
|
span {
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
font-size : 11px;
|
||||||
|
font-weight : bold;
|
||||||
|
border : 1px solid;
|
||||||
|
border-radius : 3px;
|
||||||
|
padding : 3px;
|
||||||
|
cursor : pointer;
|
||||||
|
color: #dfdfdf;
|
||||||
|
&:before {
|
||||||
|
font-family: 'Font Awesome 5 Free';
|
||||||
|
font-size: 12px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
&:after {
|
||||||
|
content: '\f00d';
|
||||||
|
font-family: 'Font Awesome 5 Free';
|
||||||
|
font-size: 12px;
|
||||||
|
margin-left: 3px;
|
||||||
|
}
|
||||||
|
&.type {
|
||||||
|
background-color: #008000;
|
||||||
|
border-color: #00a000;
|
||||||
|
&:before{
|
||||||
|
content: '\f0ad';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.group {
|
||||||
|
background-color: #505050;
|
||||||
|
border-color: #000000;
|
||||||
|
&:before{
|
||||||
|
content: '\f500';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.meta {
|
||||||
|
background-color: #000080;
|
||||||
|
border-color: #0000a0;
|
||||||
|
&:before{
|
||||||
|
content: '\f05a';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.system {
|
||||||
|
background-color: #800000;
|
||||||
|
border-color: #a00000;
|
||||||
|
&:before{
|
||||||
|
content: '\f518';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const Navbar = require('../../navbar/navbar.jsx');
|
|||||||
|
|
||||||
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
||||||
const PrintLink = require('../../navbar/print.navitem.jsx');
|
const PrintNavItem = require('../../navbar/print.navitem.jsx');
|
||||||
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
||||||
const Account = require('../../navbar/account.navitem.jsx');
|
const Account = require('../../navbar/account.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
@@ -20,9 +20,12 @@ const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
|||||||
const Editor = require('../../editor/editor.jsx');
|
const Editor = require('../../editor/editor.jsx');
|
||||||
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||||
|
|
||||||
|
const LockNotification = require('./lockNotification/lockNotification.jsx');
|
||||||
|
|
||||||
const Markdown = require('naturalcrit/markdown.js');
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
|
||||||
const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
|
const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
|
||||||
|
const { printCurrentBrew, fetchThemeBundle } = require('../../../../shared/helpers.js');
|
||||||
|
|
||||||
const googleDriveIcon = require('../../googleDrive.svg');
|
const googleDriveIcon = require('../../googleDrive.svg');
|
||||||
|
|
||||||
@@ -50,9 +53,14 @@ const EditPage = createClass({
|
|||||||
url : '',
|
url : '',
|
||||||
autoSave : true,
|
autoSave : true,
|
||||||
autoSaveWarning : false,
|
autoSaveWarning : false,
|
||||||
unsavedTime : new Date()
|
unsavedTime : new Date(),
|
||||||
|
currentEditorPage : 0,
|
||||||
|
displayLockMessage : this.props.brew.lock || false,
|
||||||
|
themeBundle : {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editor : React.createRef(null),
|
||||||
savedBrew : null,
|
savedBrew : null,
|
||||||
|
|
||||||
componentDidMount : function(){
|
componentDidMount : function(){
|
||||||
@@ -80,6 +88,8 @@ const EditPage = createClass({
|
|||||||
htmlErrors : Markdown.validate(prevState.brew.text)
|
htmlErrors : Markdown.validate(prevState.brew.text)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fetchThemeBundle(this, this.props.brew.renderer, this.props.brew.theme);
|
||||||
|
|
||||||
document.addEventListener('keydown', this.handleControlKeys);
|
document.addEventListener('keydown', this.handleControlKeys);
|
||||||
},
|
},
|
||||||
componentWillUnmount : function() {
|
componentWillUnmount : function() {
|
||||||
@@ -92,7 +102,7 @@ const EditPage = createClass({
|
|||||||
const S_KEY = 83;
|
const S_KEY = 83;
|
||||||
const P_KEY = 80;
|
const P_KEY = 80;
|
||||||
if(e.keyCode == S_KEY) this.trySave(true);
|
if(e.keyCode == S_KEY) this.trySave(true);
|
||||||
if(e.keyCode == P_KEY) window.open(`/print/${this.processShareId()}?dialog=true`, '_blank').focus();
|
if(e.keyCode == P_KEY) printCurrentBrew();
|
||||||
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
|
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -100,7 +110,7 @@ const EditPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleSplitMove : function(){
|
handleSplitMove : function(){
|
||||||
this.refs.editor.update();
|
this.editor.current.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleTextChange : function(text){
|
handleTextChange : function(text){
|
||||||
@@ -111,7 +121,8 @@ const EditPage = createClass({
|
|||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
brew : { ...prevState.brew, text: text },
|
brew : { ...prevState.brew, text: text },
|
||||||
isPending : true,
|
isPending : true,
|
||||||
htmlErrors : htmlErrors
|
htmlErrors : htmlErrors,
|
||||||
|
currentEditorPage : this.editor.current.getCurrentPage() - 1 //Offset index since Marked starts pages at 0
|
||||||
}), ()=>{if(this.state.autoSave) this.trySave();});
|
}), ()=>{if(this.state.autoSave) this.trySave();});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -122,7 +133,10 @@ const EditPage = createClass({
|
|||||||
}), ()=>{if(this.state.autoSave) this.trySave();});
|
}), ()=>{if(this.state.autoSave) this.trySave();});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMetaChange : function(metadata){
|
handleMetaChange : function(metadata, field=undefined){
|
||||||
|
if(field == 'theme' || field == 'renderer') // Fetch theme bundle only if theme or renderer was changed
|
||||||
|
fetchThemeBundle(this, metadata.renderer, metadata.theme);
|
||||||
|
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
brew : {
|
brew : {
|
||||||
...prevState.brew,
|
...prevState.brew,
|
||||||
@@ -130,7 +144,6 @@ const EditPage = createClass({
|
|||||||
},
|
},
|
||||||
isPending : true,
|
isPending : true,
|
||||||
}), ()=>{if(this.state.autoSave) this.trySave();});
|
}), ()=>{if(this.state.autoSave) this.trySave();});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hasChanges : function(){
|
hasChanges : function(){
|
||||||
@@ -374,7 +387,7 @@ const EditPage = createClass({
|
|||||||
post to reddit
|
post to reddit
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
</Nav.dropdown>
|
</Nav.dropdown>
|
||||||
<PrintLink shareId={this.processShareId()} />
|
<PrintNavItem />
|
||||||
<RecentNavItem brew={this.state.brew} storageKey='edit' />
|
<RecentNavItem brew={this.state.brew} storageKey='edit' />
|
||||||
<Account />
|
<Account />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
@@ -388,23 +401,29 @@ const EditPage = createClass({
|
|||||||
{this.renderNavbar()}
|
{this.renderNavbar()}
|
||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
|
{this.props.brew.lock && <LockNotification shareId={this.props.brew.shareId} message={this.props.brew.lock.editMessage} />}
|
||||||
|
<SplitPane onDragFinish={this.handleSplitMove}>
|
||||||
<Editor
|
<Editor
|
||||||
ref='editor'
|
ref={this.editor}
|
||||||
brew={this.state.brew}
|
brew={this.state.brew}
|
||||||
onTextChange={this.handleTextChange}
|
onTextChange={this.handleTextChange}
|
||||||
onStyleChange={this.handleStyleChange}
|
onStyleChange={this.handleStyleChange}
|
||||||
onMetaChange={this.handleMetaChange}
|
onMetaChange={this.handleMetaChange}
|
||||||
reportError={this.errorReported}
|
reportError={this.errorReported}
|
||||||
renderer={this.state.brew.renderer}
|
renderer={this.state.brew.renderer}
|
||||||
|
userThemes={this.props.userThemes}
|
||||||
|
snippetBundle={this.state.themeBundle.snippets}
|
||||||
/>
|
/>
|
||||||
<BrewRenderer
|
<BrewRenderer
|
||||||
text={this.state.brew.text}
|
text={this.state.brew.text}
|
||||||
style={this.state.brew.style}
|
style={this.state.brew.style}
|
||||||
renderer={this.state.brew.renderer}
|
renderer={this.state.brew.renderer}
|
||||||
theme={this.state.brew.theme}
|
theme={this.state.brew.theme}
|
||||||
|
themeBundle={this.state.themeBundle}
|
||||||
errors={this.state.htmlErrors}
|
errors={this.state.htmlErrors}
|
||||||
lang={this.state.brew.lang}
|
lang={this.state.brew.lang}
|
||||||
|
currentEditorPage={this.state.currentEditorPage}
|
||||||
|
allowPrint={true}
|
||||||
/>
|
/>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
require('./lockNotification.less');
|
||||||
|
const React = require('react');
|
||||||
|
import Dialog from '../../../../components/dialog.jsx';
|
||||||
|
|
||||||
|
function LockNotification(props) {
|
||||||
|
props = {
|
||||||
|
shareId : 0,
|
||||||
|
disableLock : ()=>{},
|
||||||
|
message : '',
|
||||||
|
...props
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeLock = ()=>{
|
||||||
|
alert(`Not yet implemented - ID ${props.shareId}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Dialog className='lockNotification' blocking closeText='CONTINUE TO EDITOR' >
|
||||||
|
<h1>BREW LOCKED</h1>
|
||||||
|
<p>This brew been locked by the Administrators. It will not be accessible by any method other than the Editor until the lock is removed.</p>
|
||||||
|
<hr />
|
||||||
|
<h3>LOCK REASON</h3>
|
||||||
|
<p>{props.message || 'Unable to retrieve Lock Message'}</p>
|
||||||
|
<hr />
|
||||||
|
<p>Once you have resolved this issue, click REQUEST LOCK REMOVAL to notify the Administrators for review.</p>
|
||||||
|
<p>Click CONTINUE TO EDITOR to temporarily hide this notification; it will reappear the next time the page is reloaded.</p>
|
||||||
|
<button onClick={removeLock}>REQUEST LOCK REMOVAL</button>
|
||||||
|
</Dialog>;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = LockNotification;
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
.lockNotification {
|
||||||
|
z-index : 1;
|
||||||
|
width : 80%;
|
||||||
|
padding : 10px;
|
||||||
|
margin : 5% 10%;
|
||||||
|
line-height : 1.5em;
|
||||||
|
color : black;
|
||||||
|
text-align : center;
|
||||||
|
background-color : #CCCCCC;
|
||||||
|
|
||||||
|
&::backdrop { background-color : #000000AA; }
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin : 10px;
|
||||||
|
color : white;
|
||||||
|
background-color : #333333;
|
||||||
|
|
||||||
|
&:hover { background-color : #777777; }
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h3 {
|
||||||
|
font-family : 'Open Sans', sans-serif;
|
||||||
|
font-weight : 800;
|
||||||
|
}
|
||||||
|
h1 { font-size : 24px; }
|
||||||
|
h3 { font-size : 18px; }
|
||||||
|
}
|
||||||
@@ -1,41 +1,25 @@
|
|||||||
require('./errorPage.less');
|
require('./errorPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const UIPage = require('../basePages/uiPage/uiPage.jsx');
|
const UIPage = require('../basePages/uiPage/uiPage.jsx');
|
||||||
|
|
||||||
const Markdown = require('../../../../shared/naturalcrit/markdown.js');
|
const Markdown = require('../../../../shared/naturalcrit/markdown.js');
|
||||||
|
|
||||||
const ErrorIndex = require('./errors/errorIndex.js');
|
const ErrorIndex = require('./errors/errorIndex.js');
|
||||||
|
|
||||||
const ErrorPage = createClass({
|
const ErrorPage = ({ brew })=>{
|
||||||
displayName : 'ErrorPage',
|
// Retrieving the error text based on the brew's error code from ErrorIndex
|
||||||
|
const errorText = ErrorIndex({ brew })[brew.HBErrorCode.toString()] || '';
|
||||||
|
|
||||||
getDefaultProps : function() {
|
return (
|
||||||
return {
|
<UIPage brew={{ title: 'Crit Fail!' }}>
|
||||||
ver : '0.0.0',
|
|
||||||
errorId : '',
|
|
||||||
text : '# Oops \n We could not find a brew with that id. **Sorry!**',
|
|
||||||
error : {}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
render : function(){
|
|
||||||
const errorText = ErrorIndex(this.props)[this.props.brew.HBErrorCode.toString()] || '';
|
|
||||||
|
|
||||||
return <UIPage brew={{ title: 'Crit Fail!' }}>
|
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<div className='errorTitle'>
|
<div className='errorTitle'>
|
||||||
<h1>{`Error ${this.props.brew.status || '000'}`}</h1>
|
<h1>{`Error ${brew?.status || '000'}`}</h1>
|
||||||
<h4>{this.props.brew.text || 'No error text'}</h4>
|
<h4>{brew?.text || 'No error text'}</h4>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div dangerouslySetInnerHTML={{ __html: Markdown.render(errorText) }} />
|
<div dangerouslySetInnerHTML={{ __html: Markdown.render(errorText) }} />
|
||||||
</div>
|
</div>
|
||||||
</UIPage>;
|
</UIPage>
|
||||||
}
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports = ErrorPage;
|
module.exports = ErrorPage;
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ const dedent = require('dedent-tabs').default;
|
|||||||
|
|
||||||
const loginUrl = 'https://www.naturalcrit.com/login';
|
const loginUrl = 'https://www.naturalcrit.com/login';
|
||||||
|
|
||||||
|
//001-050 : Brew errors
|
||||||
|
//050-100 : Other pages errors
|
||||||
|
|
||||||
const errorIndex = (props)=>{
|
const errorIndex = (props)=>{
|
||||||
return {
|
return {
|
||||||
// Default catch all
|
// Default catch all
|
||||||
@@ -73,9 +76,13 @@ const errorIndex = (props)=>{
|
|||||||
**Properties** tab, and adding your username to the "invited authors" list. You can
|
**Properties** tab, and adding your username to the "invited authors" list. You can
|
||||||
then try to access this document again.
|
then try to access this document again.
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
**Brew Title:** ${props.brew.brewTitle || 'Unable to show title'}
|
**Brew Title:** ${props.brew.brewTitle || 'Unable to show title'}
|
||||||
|
|
||||||
**Current Authors:** ${props.brew.authors?.map((author)=>{return `${author}`;}).join(', ') || 'Unable to list authors'}`,
|
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}
|
||||||
|
|
||||||
|
[Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`,
|
||||||
|
|
||||||
// User is not signed in; must be a user on the Authors List
|
// User is not signed in; must be a user on the Authors List
|
||||||
'04' : dedent`
|
'04' : dedent`
|
||||||
@@ -84,9 +91,14 @@ const errorIndex = (props)=>{
|
|||||||
You must be logged in to one of the accounts listed as an author of this brew.
|
You must be logged in to one of the accounts listed as an author of this brew.
|
||||||
User is not logged in. Please log in [here](${loginUrl}).
|
User is not logged in. Please log in [here](${loginUrl}).
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
**Brew Title:** ${props.brew.brewTitle || 'Unable to show title'}
|
**Brew Title:** ${props.brew.brewTitle || 'Unable to show title'}
|
||||||
|
|
||||||
**Current Authors:** ${props.brew.authors?.map((author)=>{return `${author}`;}).join(', ') || 'Unable to list authors'}`,
|
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}
|
||||||
|
|
||||||
|
[Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`,
|
||||||
|
|
||||||
|
|
||||||
// Brew load error
|
// Brew load error
|
||||||
'05' : dedent`
|
'05' : dedent`
|
||||||
@@ -95,6 +107,8 @@ const errorIndex = (props)=>{
|
|||||||
The server could not locate the Homebrewery document. It was likely deleted by
|
The server could not locate the Homebrewery document. It was likely deleted by
|
||||||
its owner.
|
its owner.
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
**Requested access:** ${props.brew.accessType}
|
**Requested access:** ${props.brew.accessType}
|
||||||
|
|
||||||
**Brew ID:** ${props.brew.brewId}`,
|
**Brew ID:** ${props.brew.brewId}`,
|
||||||
@@ -111,6 +125,8 @@ const errorIndex = (props)=>{
|
|||||||
|
|
||||||
An error occurred while attempting to remove the Homebrewery document.
|
An error occurred while attempting to remove the Homebrewery document.
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
**Brew ID:** ${props.brew.brewId}`,
|
**Brew ID:** ${props.brew.brewId}`,
|
||||||
|
|
||||||
// Author delete error
|
// Author delete error
|
||||||
@@ -119,7 +135,47 @@ const errorIndex = (props)=>{
|
|||||||
|
|
||||||
An error occurred while attempting to remove the user from the Homebrewery document author list!
|
An error occurred while attempting to remove the user from the Homebrewery document author list!
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
**Brew ID:** ${props.brew.brewId}`,
|
**Brew ID:** ${props.brew.brewId}`,
|
||||||
|
|
||||||
|
// Theme load error
|
||||||
|
'09' : dedent`
|
||||||
|
## No Homebrewery theme document could be found.
|
||||||
|
|
||||||
|
The server could not locate the Homebrewery document. It was likely deleted by
|
||||||
|
its owner.
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
|
**Requested access:** ${props.brew.accessType}
|
||||||
|
|
||||||
|
**Brew ID:** ${props.brew.brewId}`,
|
||||||
|
|
||||||
|
//account page when account is not defined
|
||||||
|
'50' : dedent`
|
||||||
|
## You are not signed in
|
||||||
|
|
||||||
|
You are trying to access the account page, but are not signed in to an account.
|
||||||
|
|
||||||
|
Please login or signup at our [login page](https://www.naturalcrit.com/login?redirect=https://homebrewery.naturalcrit.com/account).`,
|
||||||
|
|
||||||
|
// Brew locked by Administrators error
|
||||||
|
'51' : dedent`
|
||||||
|
## This brew has been locked.
|
||||||
|
|
||||||
|
Only an author may request that this lock is removed.
|
||||||
|
|
||||||
|
:
|
||||||
|
|
||||||
|
**Brew ID:** ${props.brew.brewId}
|
||||||
|
|
||||||
|
**Brew Title:** ${props.brew.brewTitle}`,
|
||||||
|
|
||||||
|
'90' : dedent` An unexpected error occurred while looking for these brews.
|
||||||
|
Try again in a few minutes.`,
|
||||||
|
|
||||||
|
'91' : dedent` An unexpected error occurred while trying to get the total of brews.`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
//TODO: Depricate
|
|
||||||
|
|
||||||
module.exports = function(shareId){
|
|
||||||
return function(event){
|
|
||||||
event = event || window.event;
|
|
||||||
if((event.ctrlKey || event.metaKey) && event.keyCode == 80){
|
|
||||||
const win = window.open(`/homebrew/print/${shareId}?dialog=true`, '_blank');
|
|
||||||
win.focus();
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -10,10 +10,11 @@ const Nav = require('naturalcrit/nav/nav.jsx');
|
|||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
const NewBrewItem = require('../../navbar/newbrew.navitem.jsx');
|
const NewBrewItem = require('../../navbar/newbrew.navitem.jsx');
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
||||||
|
const VaultNavItem = require('../../navbar/vault.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
||||||
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
||||||
|
const { fetchThemeBundle } = require('../../../../shared/helpers.js');
|
||||||
|
|
||||||
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
const SplitPane = require('naturalcrit/splitPane/splitPane.jsx');
|
||||||
const Editor = require('../../editor/editor.jsx');
|
const Editor = require('../../editor/editor.jsx');
|
||||||
@@ -33,9 +34,18 @@ const HomePage = createClass({
|
|||||||
return {
|
return {
|
||||||
brew : this.props.brew,
|
brew : this.props.brew,
|
||||||
welcomeText : this.props.brew.text,
|
welcomeText : this.props.brew.text,
|
||||||
error : undefined
|
error : undefined,
|
||||||
|
currentEditorPage : 0,
|
||||||
|
themeBundle : {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editor : React.createRef(null),
|
||||||
|
|
||||||
|
componentDidMount : function() {
|
||||||
|
fetchThemeBundle(this, this.props.brew.renderer, this.props.brew.theme);
|
||||||
|
},
|
||||||
|
|
||||||
handleSave : function(){
|
handleSave : function(){
|
||||||
request.post('/api')
|
request.post('/api')
|
||||||
.send(this.state.brew)
|
.send(this.state.brew)
|
||||||
@@ -49,11 +59,12 @@ const HomePage = createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleSplitMove : function(){
|
handleSplitMove : function(){
|
||||||
this.refs.editor.update();
|
this.editor.current.update();
|
||||||
},
|
},
|
||||||
handleTextChange : function(text){
|
handleTextChange : function(text){
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
brew : { ...prevState.brew, text: text }
|
brew : { ...prevState.brew, text: text },
|
||||||
|
currentEditorPage : this.editor.current.getCurrentPage() - 1 //Offset index since Marked starts pages at 0
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
renderNavbar : function(){
|
renderNavbar : function(){
|
||||||
@@ -65,6 +76,7 @@ const HomePage = createClass({
|
|||||||
}
|
}
|
||||||
<NewBrewItem />
|
<NewBrewItem />
|
||||||
<HelpNavItem />
|
<HelpNavItem />
|
||||||
|
<VaultNavItem />
|
||||||
<RecentNavItem />
|
<RecentNavItem />
|
||||||
<AccountNavItem />
|
<AccountNavItem />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
@@ -77,15 +89,22 @@ const HomePage = createClass({
|
|||||||
{this.renderNavbar()}
|
{this.renderNavbar()}
|
||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
|
<SplitPane onDragFinish={this.handleSplitMove}>
|
||||||
<Editor
|
<Editor
|
||||||
ref='editor'
|
ref={this.editor}
|
||||||
brew={this.state.brew}
|
brew={this.state.brew}
|
||||||
onTextChange={this.handleTextChange}
|
onTextChange={this.handleTextChange}
|
||||||
renderer={this.state.brew.renderer}
|
renderer={this.state.brew.renderer}
|
||||||
showEditButtons={false}
|
showEditButtons={false}
|
||||||
|
snippetBundle={this.state.themeBundle.snippets}
|
||||||
|
/>
|
||||||
|
<BrewRenderer
|
||||||
|
text={this.state.brew.text}
|
||||||
|
style={this.state.brew.style}
|
||||||
|
renderer={this.state.brew.renderer}
|
||||||
|
currentEditorPage={this.state.currentEditorPage}
|
||||||
|
themeBundle={this.state.themeBundle}
|
||||||
/>
|
/>
|
||||||
<BrewRenderer text={this.state.brew.text} style={this.state.brew.style} renderer={this.state.brew.renderer}/>
|
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ Much nicer than `<br><br><br><br><br>`
|
|||||||
### Column Breaks
|
### Column Breaks
|
||||||
Column and page breaks with `\column` and `\page`.
|
Column and page breaks with `\column` and `\page`.
|
||||||
|
|
||||||
|
\column
|
||||||
### Tables
|
### Tables
|
||||||
Tables now allow column & row spanning between cells. This is included in some updated snippets, but a simplified example is given below.
|
Tables now allow column & row spanning between cells. This is included in some updated snippets, but a simplified example is given below.
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
require('./newPage.less');
|
require('./newPage.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
|
||||||
const request = require('../../utils/request-middleware.js');
|
const request = require('../../utils/request-middleware.js');
|
||||||
|
|
||||||
const Markdown = require('naturalcrit/markdown.js');
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
|
||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
const PrintNavItem = require('../../navbar/print.navitem.jsx');
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
||||||
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
||||||
@@ -19,6 +19,7 @@ const Editor = require('../../editor/editor.jsx');
|
|||||||
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||||
|
|
||||||
const { DEFAULT_BREW } = require('../../../../server/brewDefaults.js');
|
const { DEFAULT_BREW } = require('../../../../server/brewDefaults.js');
|
||||||
|
const { printCurrentBrew, fetchThemeBundle } = require('../../../../shared/helpers.js');
|
||||||
|
|
||||||
const BREWKEY = 'homebrewery-new';
|
const BREWKEY = 'homebrewery-new';
|
||||||
const STYLEKEY = 'homebrewery-new-style';
|
const STYLEKEY = 'homebrewery-new-style';
|
||||||
@@ -42,10 +43,14 @@ const NewPage = createClass({
|
|||||||
isSaving : false,
|
isSaving : false,
|
||||||
saveGoogle : (global.account && global.account.googleId ? true : false),
|
saveGoogle : (global.account && global.account.googleId ? true : false),
|
||||||
error : null,
|
error : null,
|
||||||
htmlErrors : Markdown.validate(brew.text)
|
htmlErrors : Markdown.validate(brew.text),
|
||||||
|
currentEditorPage : 0,
|
||||||
|
themeBundle : {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editor : React.createRef(null),
|
||||||
|
|
||||||
componentDidMount : function() {
|
componentDidMount : function() {
|
||||||
document.addEventListener('keydown', this.handleControlKeys);
|
document.addEventListener('keydown', this.handleControlKeys);
|
||||||
|
|
||||||
@@ -73,10 +78,15 @@ const NewPage = createClass({
|
|||||||
saveGoogle : (saveStorage == 'GOOGLE-DRIVE' && this.state.saveGoogle)
|
saveGoogle : (saveStorage == 'GOOGLE-DRIVE' && this.state.saveGoogle)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fetchThemeBundle(this, this.props.brew.renderer, this.props.brew.theme);
|
||||||
|
|
||||||
localStorage.setItem(BREWKEY, brew.text);
|
localStorage.setItem(BREWKEY, brew.text);
|
||||||
if(brew.style)
|
if(brew.style)
|
||||||
localStorage.setItem(STYLEKEY, brew.style);
|
localStorage.setItem(STYLEKEY, brew.style);
|
||||||
localStorage.setItem(METAKEY, JSON.stringify({ 'renderer': brew.renderer, 'theme': brew.theme, 'lang': brew.lang }));
|
localStorage.setItem(METAKEY, JSON.stringify({ 'renderer': brew.renderer, 'theme': brew.theme, 'lang': brew.lang }));
|
||||||
|
if(window.location.pathname != '/new') {
|
||||||
|
window.history.replaceState({}, window.location.title, '/new/');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
componentWillUnmount : function() {
|
componentWillUnmount : function() {
|
||||||
document.removeEventListener('keydown', this.handleControlKeys);
|
document.removeEventListener('keydown', this.handleControlKeys);
|
||||||
@@ -87,7 +97,7 @@ const NewPage = createClass({
|
|||||||
const S_KEY = 83;
|
const S_KEY = 83;
|
||||||
const P_KEY = 80;
|
const P_KEY = 80;
|
||||||
if(e.keyCode == S_KEY) this.save();
|
if(e.keyCode == S_KEY) this.save();
|
||||||
if(e.keyCode == P_KEY) this.print();
|
if(e.keyCode == P_KEY) printCurrentBrew();
|
||||||
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
|
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -95,7 +105,7 @@ const NewPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleSplitMove : function(){
|
handleSplitMove : function(){
|
||||||
this.refs.editor.update();
|
this.editor.current.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleTextChange : function(text){
|
handleTextChange : function(text){
|
||||||
@@ -105,7 +115,8 @@ const NewPage = createClass({
|
|||||||
|
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
brew : { ...prevState.brew, text: text },
|
brew : { ...prevState.brew, text: text },
|
||||||
htmlErrors : htmlErrors
|
htmlErrors : htmlErrors,
|
||||||
|
currentEditorPage : this.editor.current.getCurrentPage() - 1 //Offset index since Marked starts pages at 0
|
||||||
}));
|
}));
|
||||||
localStorage.setItem(BREWKEY, text);
|
localStorage.setItem(BREWKEY, text);
|
||||||
},
|
},
|
||||||
@@ -117,7 +128,10 @@ const NewPage = createClass({
|
|||||||
localStorage.setItem(STYLEKEY, style);
|
localStorage.setItem(STYLEKEY, style);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMetaChange : function(metadata){
|
handleMetaChange : function(metadata, field=undefined){
|
||||||
|
if(field == 'theme' || field == 'renderer') // Fetch theme bundle only if theme or renderer was changed
|
||||||
|
fetchThemeBundle(this, metadata.renderer, metadata.theme);
|
||||||
|
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
brew : { ...prevState.brew, ...metadata },
|
brew : { ...prevState.brew, ...metadata },
|
||||||
}), ()=>{
|
}), ()=>{
|
||||||
@@ -137,8 +151,6 @@ const NewPage = createClass({
|
|||||||
isSaving : true
|
isSaving : true
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('saving new brew');
|
|
||||||
|
|
||||||
let brew = this.state.brew;
|
let brew = this.state.brew;
|
||||||
// Split out CSS to Style if CSS codefence exists
|
// Split out CSS to Style if CSS codefence exists
|
||||||
if(brew.text.startsWith('```css') && brew.text.indexOf('```\n\n') > 0) {
|
if(brew.text.startsWith('```css') && brew.text.indexOf('```\n\n') > 0) {
|
||||||
@@ -148,12 +160,10 @@ const NewPage = createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
brew.pageCount=((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
brew.pageCount=((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;
|
||||||
|
|
||||||
const res = await request
|
const res = await request
|
||||||
.post(`/api${this.state.saveGoogle ? '?saveToGoogle=true' : ''}`)
|
.post(`/api${this.state.saveGoogle ? '?saveToGoogle=true' : ''}`)
|
||||||
.send(brew)
|
.send(brew)
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
|
||||||
this.setState({ isSaving: false, error: err });
|
this.setState({ isSaving: false, error: err });
|
||||||
});
|
});
|
||||||
if(!res) return;
|
if(!res) return;
|
||||||
@@ -177,16 +187,6 @@ const NewPage = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
print : function(){
|
|
||||||
window.open('/print?dialog=true&local=print', '_blank');
|
|
||||||
},
|
|
||||||
|
|
||||||
renderLocalPrintButton : function(){
|
|
||||||
return <Nav.item color='purple' icon='far fa-file-pdf' onClick={this.print}>
|
|
||||||
get PDF
|
|
||||||
</Nav.item>;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderNavbar : function(){
|
renderNavbar : function(){
|
||||||
return <Navbar>
|
return <Navbar>
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ const NewPage = createClass({
|
|||||||
<ErrorNavItem error={this.state.error} parent={this}></ErrorNavItem> :
|
<ErrorNavItem error={this.state.error} parent={this}></ErrorNavItem> :
|
||||||
this.renderSaveButton()
|
this.renderSaveButton()
|
||||||
}
|
}
|
||||||
{this.renderLocalPrintButton()}
|
<PrintNavItem />
|
||||||
<HelpNavItem />
|
<HelpNavItem />
|
||||||
<RecentNavItem />
|
<RecentNavItem />
|
||||||
<AccountNavItem />
|
<AccountNavItem />
|
||||||
@@ -211,16 +211,28 @@ const NewPage = createClass({
|
|||||||
return <div className='newPage sitePage'>
|
return <div className='newPage sitePage'>
|
||||||
{this.renderNavbar()}
|
{this.renderNavbar()}
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
|
<SplitPane onDragFinish={this.handleSplitMove}>
|
||||||
<Editor
|
<Editor
|
||||||
ref='editor'
|
ref={this.editor}
|
||||||
brew={this.state.brew}
|
brew={this.state.brew}
|
||||||
onTextChange={this.handleTextChange}
|
onTextChange={this.handleTextChange}
|
||||||
onStyleChange={this.handleStyleChange}
|
onStyleChange={this.handleStyleChange}
|
||||||
onMetaChange={this.handleMetaChange}
|
onMetaChange={this.handleMetaChange}
|
||||||
renderer={this.state.brew.renderer}
|
renderer={this.state.brew.renderer}
|
||||||
|
userThemes={this.props.userThemes}
|
||||||
|
snippetBundle={this.state.themeBundle.snippets}
|
||||||
|
/>
|
||||||
|
<BrewRenderer
|
||||||
|
text={this.state.brew.text}
|
||||||
|
style={this.state.brew.style}
|
||||||
|
renderer={this.state.brew.renderer}
|
||||||
|
theme={this.state.brew.theme}
|
||||||
|
themeBundle={this.state.themeBundle}
|
||||||
|
errors={this.state.htmlErrors}
|
||||||
|
lang={this.state.brew.lang}
|
||||||
|
currentEditorPage={this.state.currentEditorPage}
|
||||||
|
allowPrint={true}
|
||||||
/>
|
/>
|
||||||
<BrewRenderer text={this.state.brew.text} style={this.state.brew.style} renderer={this.state.brew.renderer} theme={this.state.brew.theme} lang={this.state.brew.lang} errors={this.state.htmlErrors}/>
|
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
require('./printPage.less');
|
|
||||||
const React = require('react');
|
|
||||||
const createClass = require('create-react-class');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const cx = require('classnames');
|
|
||||||
const { Meta } = require('vitreum/headtags');
|
|
||||||
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
|
|
||||||
const Markdown = require('naturalcrit/markdown.js');
|
|
||||||
|
|
||||||
const Themes = require('themes/themes.json');
|
|
||||||
|
|
||||||
const BREWKEY = 'homebrewery-new';
|
|
||||||
const STYLEKEY = 'homebrewery-new-style';
|
|
||||||
const METAKEY = 'homebrewery-new-meta';
|
|
||||||
|
|
||||||
const PrintPage = createClass({
|
|
||||||
displayName : 'PrintPage',
|
|
||||||
getDefaultProps : function() {
|
|
||||||
return {
|
|
||||||
query : {},
|
|
||||||
brew : {
|
|
||||||
text : '',
|
|
||||||
style : '',
|
|
||||||
renderer : 'legacy'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getInitialState : function() {
|
|
||||||
return {
|
|
||||||
brew : {
|
|
||||||
text : this.props.brew.text || '',
|
|
||||||
style : this.props.brew.style || undefined,
|
|
||||||
renderer : this.props.brew.renderer || 'legacy',
|
|
||||||
theme : this.props.brew.theme || '5ePHB'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount : function() {
|
|
||||||
if(this.props.query.local == 'print'){
|
|
||||||
const brewStorage = localStorage.getItem(BREWKEY);
|
|
||||||
const styleStorage = localStorage.getItem(STYLEKEY);
|
|
||||||
const metaStorage = JSON.parse(localStorage.getItem(METAKEY));
|
|
||||||
|
|
||||||
this.setState((prevState, prevProps)=>{
|
|
||||||
return {
|
|
||||||
brew : {
|
|
||||||
text : brewStorage,
|
|
||||||
style : styleStorage,
|
|
||||||
renderer : metaStorage?.renderer || 'legacy',
|
|
||||||
theme : metaStorage?.theme || '5ePHB'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.props.query.dialog) window.print();
|
|
||||||
},
|
|
||||||
|
|
||||||
renderStyle : function() {
|
|
||||||
if(!this.state.brew.style) return;
|
|
||||||
//return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style>@layer styleTab {\n${this.state.brew.style}\n} </style>` }} />;
|
|
||||||
return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style>\n${this.state.brew.style}\n</style>` }} />;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderPages : function(){
|
|
||||||
if(this.state.brew.renderer == 'legacy') {
|
|
||||||
return _.map(this.state.brew.text.split('\\page'), (pageText, index)=>{
|
|
||||||
return <div
|
|
||||||
className='phb page'
|
|
||||||
id={`p${index + 1}`}
|
|
||||||
dangerouslySetInnerHTML={{ __html: MarkdownLegacy.render(pageText) }}
|
|
||||||
key={index} />;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return _.map(this.state.brew.text.split(/^\\page$/gm), (pageText, index)=>{
|
|
||||||
pageText += `\n\n \n\\column\n `; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear)
|
|
||||||
return (
|
|
||||||
<div className='page' id={`p${index + 1}`} key={index} >
|
|
||||||
<div className='columnWrapper' dangerouslySetInnerHTML={{ __html: Markdown.render(pageText) }} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
render : function(){
|
|
||||||
const rendererPath = this.state.brew.renderer == 'V3' ? 'V3' : 'Legacy';
|
|
||||||
const themePath = this.state.brew.theme ?? '5ePHB';
|
|
||||||
const baseThemePath = Themes[rendererPath][themePath].baseTheme;
|
|
||||||
|
|
||||||
return <div>
|
|
||||||
<Meta name='robots' content='noindex, nofollow' />
|
|
||||||
<link href={`/themes/${rendererPath}/Blank/style.css`} rel='stylesheet'/>
|
|
||||||
{baseThemePath &&
|
|
||||||
<link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} rel='stylesheet'/>
|
|
||||||
}
|
|
||||||
<link href={`/themes/${rendererPath}/${themePath}/style.css`} rel='stylesheet'/>
|
|
||||||
{/* Apply CSS from Style tab */}
|
|
||||||
{this.renderStyle()}
|
|
||||||
<div className='pages' ref='pages'>
|
|
||||||
{this.renderPages()}
|
|
||||||
</div>
|
|
||||||
</div>;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = PrintPage;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
.printPage{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,25 +6,33 @@ const { Meta } = require('vitreum/headtags');
|
|||||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
const Navbar = require('../../navbar/navbar.jsx');
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
const MetadataNav = require('../../navbar/metadata.navitem.jsx');
|
const MetadataNav = require('../../navbar/metadata.navitem.jsx');
|
||||||
const PrintLink = require('../../navbar/print.navitem.jsx');
|
const PrintNavItem = require('../../navbar/print.navitem.jsx');
|
||||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
const Account = require('../../navbar/account.navitem.jsx');
|
const Account = require('../../navbar/account.navitem.jsx');
|
||||||
|
|
||||||
|
|
||||||
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||||
|
|
||||||
const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
|
const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
|
||||||
|
const { printCurrentBrew, fetchThemeBundle } = require('../../../../shared/helpers.js');
|
||||||
|
|
||||||
const SharePage = createClass({
|
const SharePage = createClass({
|
||||||
displayName : 'SharePage',
|
displayName : 'SharePage',
|
||||||
getDefaultProps : function() {
|
getDefaultProps : function() {
|
||||||
return {
|
return {
|
||||||
brew : DEFAULT_BREW_LOAD
|
brew : DEFAULT_BREW_LOAD,
|
||||||
|
disableMeta : false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState : function() {
|
||||||
|
return {
|
||||||
|
themeBundle : {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount : function() {
|
componentDidMount : function() {
|
||||||
document.addEventListener('keydown', this.handleControlKeys);
|
document.addEventListener('keydown', this.handleControlKeys);
|
||||||
|
|
||||||
|
fetchThemeBundle(this, this.props.brew.renderer, this.props.brew.theme);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount : function() {
|
componentWillUnmount : function() {
|
||||||
@@ -35,7 +43,7 @@ const SharePage = createClass({
|
|||||||
if(!(e.ctrlKey || e.metaKey)) return;
|
if(!(e.ctrlKey || e.metaKey)) return;
|
||||||
const P_KEY = 80;
|
const P_KEY = 80;
|
||||||
if(e.keyCode == P_KEY){
|
if(e.keyCode == P_KEY){
|
||||||
window.open(`/print/${this.processShareId()}?dialog=true`, '_blank').focus();
|
if(e.keyCode == P_KEY) printCurrentBrew();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -47,30 +55,52 @@ const SharePage = createClass({
|
|||||||
this.props.brew.shareId;
|
this.props.brew.shareId;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderEditLink : function(){
|
||||||
|
if(!this.props.brew.editId) return;
|
||||||
|
|
||||||
|
let editLink = this.props.brew.editId;
|
||||||
|
if(this.props.brew.googleId && !this.props.brew.stubbed) {
|
||||||
|
editLink = this.props.brew.googleId + editLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Nav.item color='orange' icon='fas fa-pencil-alt' href={`/edit/${editLink}`}>
|
||||||
|
edit
|
||||||
|
</Nav.item>;
|
||||||
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
|
const titleStyle = this.props.disableMeta ? { cursor: 'default' } : {};
|
||||||
|
const titleEl = <Nav.item className='brewTitle' style={titleStyle}>{this.props.brew.title}</Nav.item>;
|
||||||
|
|
||||||
return <div className='sharePage sitePage'>
|
return <div className='sharePage sitePage'>
|
||||||
<Meta name='robots' content='noindex, nofollow' />
|
<Meta name='robots' content='noindex, nofollow' />
|
||||||
<Navbar>
|
<Navbar>
|
||||||
<Nav.section className='titleSection'>
|
<Nav.section className='titleSection'>
|
||||||
|
{
|
||||||
|
this.props.disableMeta ?
|
||||||
|
titleEl
|
||||||
|
:
|
||||||
<MetadataNav brew={this.props.brew}>
|
<MetadataNav brew={this.props.brew}>
|
||||||
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
|
{titleEl}
|
||||||
</MetadataNav>
|
</MetadataNav>
|
||||||
|
}
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
|
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
{this.props.brew.shareId && <>
|
{this.props.brew.shareId && <>
|
||||||
<PrintLink shareId={this.processShareId()} />
|
<PrintNavItem/>
|
||||||
<Nav.dropdown>
|
<Nav.dropdown>
|
||||||
<Nav.item color='red' icon='fas fa-code'>
|
<Nav.item color='red' icon='fas fa-code'>
|
||||||
source
|
source
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
<Nav.item color='blue' href={`/source/${this.processShareId()}`}>
|
<Nav.item color='blue' icon='fas fa-eye' href={`/source/${this.processShareId()}`}>
|
||||||
view
|
view
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
<Nav.item color='blue' href={`/download/${this.processShareId()}`}>
|
{this.renderEditLink()}
|
||||||
|
<Nav.item color='blue' icon='fas fa-download' href={`/download/${this.processShareId()}`}>
|
||||||
download
|
download
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
<Nav.item color='blue' href={`/new/${this.processShareId()}`}>
|
<Nav.item color='blue' icon='fas fa-clone' href={`/new/${this.processShareId()}`}>
|
||||||
clone to new
|
clone to new
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
</Nav.dropdown>
|
</Nav.dropdown>
|
||||||
@@ -81,7 +111,14 @@ const SharePage = createClass({
|
|||||||
</Navbar>
|
</Navbar>
|
||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<BrewRenderer text={this.props.brew.text} style={this.props.brew.style} renderer={this.props.brew.renderer} theme={this.props.brew.theme} />
|
<BrewRenderer
|
||||||
|
text={this.props.brew.text}
|
||||||
|
style={this.props.brew.style}
|
||||||
|
renderer={this.props.brew.renderer}
|
||||||
|
theme={this.props.brew.theme}
|
||||||
|
themeBundle={this.state.themeBundle}
|
||||||
|
allowPrint={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const ListPage = require('../basePages/listPage/listPage.jsx');
|
const ListPage = require('../basePages/listPage/listPage.jsx');
|
||||||
|
|
||||||
@@ -13,6 +12,7 @@ const Account = require('../../navbar/account.navitem.jsx');
|
|||||||
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
||||||
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
||||||
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
|
||||||
|
const VaultNavitem = require('../../navbar/vault.navitem.jsx');
|
||||||
|
|
||||||
const UserPage = createClass({
|
const UserPage = createClass({
|
||||||
displayName : 'UserPage',
|
displayName : 'UserPage',
|
||||||
@@ -67,6 +67,7 @@ const UserPage = createClass({
|
|||||||
}
|
}
|
||||||
<NewBrew />
|
<NewBrew />
|
||||||
<HelpNavItem />
|
<HelpNavItem />
|
||||||
|
<VaultNavitem/>
|
||||||
<RecentNavItem />
|
<RecentNavItem />
|
||||||
<Account />
|
<Account />
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
|
|||||||
396
client/homebrew/pages/vaultPage/vaultPage.jsx
Normal file
396
client/homebrew/pages/vaultPage/vaultPage.jsx
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
require('./vaultPage.less');
|
||||||
|
|
||||||
|
const React = require('react');
|
||||||
|
const { useState, useEffect, useRef } = React;
|
||||||
|
|
||||||
|
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||||
|
const Navbar = require('../../navbar/navbar.jsx');
|
||||||
|
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
|
||||||
|
const Account = require('../../navbar/account.navitem.jsx');
|
||||||
|
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
|
||||||
|
const HelpNavItem = require('../../navbar/help.navitem.jsx');
|
||||||
|
const BrewItem = require('../basePages/listPage/brewItem/brewItem.jsx');
|
||||||
|
const SplitPane = require('../../../../shared/naturalcrit/splitPane/splitPane.jsx');
|
||||||
|
const ErrorIndex = require('../errorPage/errors/errorIndex.js');
|
||||||
|
|
||||||
|
const request = require('../../utils/request-middleware.js');
|
||||||
|
|
||||||
|
const VaultPage = (props)=>{
|
||||||
|
const [pageState, setPageState] = useState(parseInt(props.query.page) || 1);
|
||||||
|
|
||||||
|
//Response state
|
||||||
|
const [brewCollection, setBrewCollection] = useState(null);
|
||||||
|
const [totalBrews, setTotalBrews] = useState(null);
|
||||||
|
const [searching, setSearching] = useState(false);
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
|
||||||
|
const titleRef = useRef(null);
|
||||||
|
const authorRef = useRef(null);
|
||||||
|
const countRef = useRef(null);
|
||||||
|
const v3Ref = useRef(null);
|
||||||
|
const legacyRef = useRef(null);
|
||||||
|
const submitButtonRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
disableSubmitIfFormInvalid();
|
||||||
|
loadPage(pageState, true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const updateStateWithBrews = (brews, page)=>{
|
||||||
|
setBrewCollection(brews || null);
|
||||||
|
setPageState(parseInt(page) || 1);
|
||||||
|
setSearching(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateUrl = (titleValue, authorValue, countValue, v3Value, legacyValue, page)=>{
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
const urlParams = new URLSearchParams(url.search);
|
||||||
|
|
||||||
|
urlParams.set('title', titleValue);
|
||||||
|
urlParams.set('author', authorValue);
|
||||||
|
urlParams.set('count', countValue);
|
||||||
|
urlParams.set('v3', v3Value);
|
||||||
|
urlParams.set('legacy', legacyValue);
|
||||||
|
urlParams.set('page', page);
|
||||||
|
|
||||||
|
url.search = urlParams.toString();
|
||||||
|
window.history.replaceState(null, '', url.toString());
|
||||||
|
};
|
||||||
|
|
||||||
|
const performSearch = async (title, author, count, v3, legacy, page)=>{
|
||||||
|
updateUrl(title, author, count, v3, legacy, page);
|
||||||
|
|
||||||
|
const response = await request.get(
|
||||||
|
`/api/vault?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}&count=${count}&page=${page}`
|
||||||
|
).catch((error)=>{
|
||||||
|
console.log('error at loadPage: ', error);
|
||||||
|
setError(error);
|
||||||
|
updateStateWithBrews([], 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(response.ok)
|
||||||
|
updateStateWithBrews(response.body.brews, page);
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadTotal = async (title, author, v3, legacy)=>{
|
||||||
|
setTotalBrews(null);
|
||||||
|
|
||||||
|
const response = await request.get(
|
||||||
|
`/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`
|
||||||
|
).catch((error)=>{
|
||||||
|
console.log('error at loadTotal: ', error);
|
||||||
|
setError(error);
|
||||||
|
updateStateWithBrews([], 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(response.ok)
|
||||||
|
setTotalBrews(response.body.totalBrews);
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadPage = async (page, updateTotal)=>{
|
||||||
|
if(!validateForm())
|
||||||
|
return;
|
||||||
|
|
||||||
|
setSearching(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
const title = titleRef.current.value || '';
|
||||||
|
const author = authorRef.current.value || '';
|
||||||
|
const count = countRef.current.value || 10;
|
||||||
|
const v3 = v3Ref.current.checked != false;
|
||||||
|
const legacy = legacyRef.current.checked != false;
|
||||||
|
|
||||||
|
performSearch(title, author, count, v3, legacy, page);
|
||||||
|
|
||||||
|
if(updateTotal)
|
||||||
|
loadTotal(title, author, v3, legacy);
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderNavItems = ()=>(
|
||||||
|
<Navbar>
|
||||||
|
<Nav.section>
|
||||||
|
<Nav.item className='brewTitle'>
|
||||||
|
Vault: Search for brews
|
||||||
|
</Nav.item>
|
||||||
|
</Nav.section>
|
||||||
|
<Nav.section>
|
||||||
|
<NewBrew />
|
||||||
|
<HelpNavItem />
|
||||||
|
<RecentNavItem />
|
||||||
|
<Account />
|
||||||
|
</Nav.section>
|
||||||
|
</Navbar>
|
||||||
|
);
|
||||||
|
|
||||||
|
const validateForm = ()=>{
|
||||||
|
//form validity: title or author must be written, and at least one renderer set
|
||||||
|
const isTitleValid = titleRef.current.validity.valid && titleRef.current.value;
|
||||||
|
const isAuthorValid = authorRef.current.validity.valid && authorRef.current.value;
|
||||||
|
const isCheckboxChecked = legacyRef.current.checked || v3Ref.current.checked;
|
||||||
|
|
||||||
|
const isFormValid = (isTitleValid || isAuthorValid) && isCheckboxChecked;
|
||||||
|
|
||||||
|
return isFormValid;
|
||||||
|
};
|
||||||
|
|
||||||
|
const disableSubmitIfFormInvalid = ()=>{
|
||||||
|
submitButtonRef.current.disabled = !validateForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderForm = ()=>(
|
||||||
|
<div className='brewLookup'>
|
||||||
|
<h2 className='formTitle'>Brew Lookup</h2>
|
||||||
|
<div className='formContents'>
|
||||||
|
<label>
|
||||||
|
Title of the brew
|
||||||
|
<input
|
||||||
|
ref={titleRef}
|
||||||
|
type='text'
|
||||||
|
name='title'
|
||||||
|
defaultValue={props.query.title || ''}
|
||||||
|
onKeyUp={disableSubmitIfFormInvalid}
|
||||||
|
pattern='.{3,}'
|
||||||
|
title='At least 3 characters'
|
||||||
|
onKeyDown={(e)=>{
|
||||||
|
if(e.key === 'Enter' && !submitButtonRef.current.disabled)
|
||||||
|
loadPage(1, true);
|
||||||
|
}}
|
||||||
|
placeholder='v3 Reference Document'
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Author of the brew
|
||||||
|
<input
|
||||||
|
ref={authorRef}
|
||||||
|
type='text'
|
||||||
|
name='author'
|
||||||
|
pattern='.{1,}'
|
||||||
|
defaultValue={props.query.author || ''}
|
||||||
|
onKeyUp={disableSubmitIfFormInvalid}
|
||||||
|
onKeyDown={(e)=>{
|
||||||
|
if(e.key === 'Enter' && !submitButtonRef.current.disabled)
|
||||||
|
loadPage(1, true);
|
||||||
|
}}
|
||||||
|
placeholder='Username'
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
Results per page
|
||||||
|
<select ref={countRef} name='count' defaultValue={props.query.count || 20}>
|
||||||
|
<option value='10'>10</option>
|
||||||
|
<option value='20'>20</option>
|
||||||
|
<option value='40'>40</option>
|
||||||
|
<option value='60'>60</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
className='renderer'
|
||||||
|
ref={v3Ref}
|
||||||
|
type='checkbox'
|
||||||
|
defaultChecked={props.query.v3 !== 'false'}
|
||||||
|
onChange={disableSubmitIfFormInvalid}
|
||||||
|
/>
|
||||||
|
Search for v3 brews
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
className='renderer'
|
||||||
|
ref={legacyRef}
|
||||||
|
type='checkbox'
|
||||||
|
defaultChecked={props.query.legacy !== 'false'}
|
||||||
|
onChange={disableSubmitIfFormInvalid}
|
||||||
|
/>
|
||||||
|
Search for legacy brews
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<button
|
||||||
|
id='searchButton'
|
||||||
|
ref={submitButtonRef}
|
||||||
|
onClick={()=>{
|
||||||
|
loadPage(1, true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Search
|
||||||
|
<i
|
||||||
|
className={searching ? 'fas fa-spin fa-spinner': 'fas fa-search'}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<legend>
|
||||||
|
<h3>Tips and tricks</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Only <b>published</b> brews are searchable via this tool
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Usernames are case-sensitive
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Use <code>"word"</code> to match an exact string,
|
||||||
|
and <code>-</code> to exclude words (at least one word must not be negated)
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Some common words like "a", "after", "through", "itself", "here", etc.,
|
||||||
|
are ignored in searches. The full list can be found
|
||||||
|
<a href='https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt'>
|
||||||
|
here
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<small>New features will be coming, such as filters and search by tags.</small>
|
||||||
|
</legend>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const renderPaginationControls = ()=>{
|
||||||
|
if(!totalBrews) return null;
|
||||||
|
|
||||||
|
const countInt = parseInt(props.query.count || 20);
|
||||||
|
const totalPages = Math.ceil(totalBrews / countInt);
|
||||||
|
|
||||||
|
let startPage, endPage;
|
||||||
|
if(pageState <= 6) {
|
||||||
|
startPage = 1;
|
||||||
|
endPage = Math.min(totalPages, 10);
|
||||||
|
} else if(pageState + 4 >= totalPages) {
|
||||||
|
startPage = Math.max(1, totalPages - 9);
|
||||||
|
endPage = totalPages;
|
||||||
|
} else {
|
||||||
|
startPage = pageState - 5;
|
||||||
|
endPage = pageState + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pagesAroundCurrent = new Array(endPage - startPage + 1)
|
||||||
|
.fill()
|
||||||
|
.map((_, index)=>(
|
||||||
|
<a
|
||||||
|
key={startPage + index}
|
||||||
|
className={`pageNumber ${
|
||||||
|
pageState === startPage + index ? 'currentPage' : ''
|
||||||
|
}`}
|
||||||
|
onClick={()=>loadPage(startPage + index, false)}
|
||||||
|
>
|
||||||
|
{startPage + index}
|
||||||
|
</a>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='paginationControls'>
|
||||||
|
<button
|
||||||
|
className='previousPage'
|
||||||
|
onClick={()=>loadPage(pageState - 1, false)}
|
||||||
|
disabled={pageState === startPage}
|
||||||
|
>
|
||||||
|
<i className='fa-solid fa-chevron-left'></i>
|
||||||
|
</button>
|
||||||
|
<ol className='pages'>
|
||||||
|
{startPage > 1 && (
|
||||||
|
<a
|
||||||
|
className='pageNumber firstPage'
|
||||||
|
onClick={()=>loadPage(1, false)}
|
||||||
|
>
|
||||||
|
1 ...
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
{pagesAroundCurrent}
|
||||||
|
{endPage < totalPages && (
|
||||||
|
<a
|
||||||
|
className='pageNumber lastPage'
|
||||||
|
onClick={()=>loadPage(totalPages, false)}
|
||||||
|
>
|
||||||
|
... {totalPages}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</ol>
|
||||||
|
<button
|
||||||
|
className='nextPage'
|
||||||
|
onClick={()=>loadPage(pageState + 1, false)}
|
||||||
|
disabled={pageState === totalPages}
|
||||||
|
>
|
||||||
|
<i className='fa-solid fa-chevron-right'></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderFoundBrews = ()=>{
|
||||||
|
if(searching) {
|
||||||
|
return (
|
||||||
|
<div className='foundBrews searching'>
|
||||||
|
<h3 className='searchAnim'>Searching</h3>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
const errorText = ErrorIndex()[error.HBErrorCode.toString()] || '';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='foundBrews noBrews'>
|
||||||
|
<h3>Error: {errorText}</h3>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!brewCollection) {
|
||||||
|
return (
|
||||||
|
<div className='foundBrews noBrews'>
|
||||||
|
<h3>No search yet</h3>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(brewCollection.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className='foundBrews noBrews'>
|
||||||
|
<h3>No brews found</h3>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='foundBrews'>
|
||||||
|
<span className='totalBrews'>
|
||||||
|
{`Brews found: `}
|
||||||
|
<span>{totalBrews}</span>
|
||||||
|
</span>
|
||||||
|
{brewCollection.map((brew, index)=>{
|
||||||
|
return (
|
||||||
|
<BrewItem
|
||||||
|
brew={{ ...brew }}
|
||||||
|
key={index}
|
||||||
|
reportError={props.reportError}
|
||||||
|
renderStorage={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{renderPaginationControls()}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='vaultPage'>
|
||||||
|
<link href='/themes/V3/Blank/style.css' rel='stylesheet' />
|
||||||
|
<link href='/themes/V3/5ePHB/style.css' rel='stylesheet' />
|
||||||
|
{renderNavItems()}
|
||||||
|
<div className='content'>
|
||||||
|
<SplitPane showDividerButtons={false}>
|
||||||
|
<div className='form dataGroup'>{renderForm()}</div>
|
||||||
|
|
||||||
|
<div className='resultsContainer dataGroup'>
|
||||||
|
{renderFoundBrews()}
|
||||||
|
</div>
|
||||||
|
</SplitPane>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = VaultPage;
|
||||||
371
client/homebrew/pages/vaultPage/vaultPage.less
Normal file
371
client/homebrew/pages/vaultPage/vaultPage.less
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
body {
|
||||||
|
height : 100vh;
|
||||||
|
|
||||||
|
.content { height : 100%; }
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size : 10pt;
|
||||||
|
color : #555555;
|
||||||
|
|
||||||
|
a { color : #333333; }
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
padding-inline : 5px;
|
||||||
|
background : lightgrey;
|
||||||
|
border-radius : 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
*:not(input) { user-select : none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.vaultPage {
|
||||||
|
height : 100%;
|
||||||
|
overflow-y : hidden;
|
||||||
|
background-color : #2C3E50;
|
||||||
|
|
||||||
|
|
||||||
|
.content {
|
||||||
|
background : #2C3E50;
|
||||||
|
|
||||||
|
.dataGroup {
|
||||||
|
width : 100%;
|
||||||
|
height : 100%;
|
||||||
|
background : white;
|
||||||
|
|
||||||
|
&.form .brewLookup {
|
||||||
|
position : relative;
|
||||||
|
padding : 50px clamp(20px, 4vw, 50px);
|
||||||
|
|
||||||
|
h1, h2, h3, h4 {
|
||||||
|
font-family : 'CodeBold';
|
||||||
|
letter-spacing : 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
legend {
|
||||||
|
h3 {
|
||||||
|
margin-block : 30px 20px;
|
||||||
|
font-size : 20px;
|
||||||
|
text-align : center;
|
||||||
|
border-bottom : 2px solid;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
padding-inline : 30px 10px;
|
||||||
|
li {
|
||||||
|
margin-block : 5px;
|
||||||
|
line-height : calc(1em + 5px);
|
||||||
|
list-style : disc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
position : absolute;
|
||||||
|
top : 0;
|
||||||
|
right : 0;
|
||||||
|
left : 0;
|
||||||
|
display : block;
|
||||||
|
padding : 10px;
|
||||||
|
font-weight : 900;
|
||||||
|
color : white;
|
||||||
|
white-space : pre-wrap;
|
||||||
|
content : 'Error:\A At least one renderer should be enabled to make a search';
|
||||||
|
background : rgb(255, 60, 60);
|
||||||
|
opacity : 0;
|
||||||
|
transition : opacity 0.5s;
|
||||||
|
}
|
||||||
|
&:not(:has(input[type='checkbox']:checked))::after { opacity : 1; }
|
||||||
|
|
||||||
|
.formTitle {
|
||||||
|
margin : 20px 0;
|
||||||
|
font-size : 30px;
|
||||||
|
color : black;
|
||||||
|
text-align : center;
|
||||||
|
border-bottom : 2px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formContents {
|
||||||
|
position : relative;
|
||||||
|
display : flex;
|
||||||
|
flex-direction : column;
|
||||||
|
|
||||||
|
label {
|
||||||
|
display : flex;
|
||||||
|
align-items : center;
|
||||||
|
margin : 10px 0;
|
||||||
|
}
|
||||||
|
select { margin : 0 10px; }
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin : 0 10px;
|
||||||
|
|
||||||
|
&:invalid { background : rgb(255, 188, 181); }
|
||||||
|
|
||||||
|
&[type='checkbox'] {
|
||||||
|
position : relative;
|
||||||
|
display : inline-block;
|
||||||
|
width : 50px;
|
||||||
|
height : 30px;
|
||||||
|
font-family : 'WalterTurncoat';
|
||||||
|
font-size : 20px;
|
||||||
|
font-weight : 800;
|
||||||
|
color : white;
|
||||||
|
letter-spacing : 2px;
|
||||||
|
appearance : none;
|
||||||
|
background : red;
|
||||||
|
isolation : isolate;
|
||||||
|
border-radius : 5px;
|
||||||
|
|
||||||
|
&::before,&::after {
|
||||||
|
position : absolute;
|
||||||
|
inset : 0;
|
||||||
|
z-index : 5;
|
||||||
|
padding-top : 2px;
|
||||||
|
text-align : center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
display : block;
|
||||||
|
content : 'No';
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
display : none;
|
||||||
|
content : 'Yes';
|
||||||
|
}
|
||||||
|
|
||||||
|
&:checked {
|
||||||
|
background : green;
|
||||||
|
|
||||||
|
&::before { display : none; }
|
||||||
|
&::after { display : block; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#searchButton {
|
||||||
|
position : absolute;
|
||||||
|
right : 20px;
|
||||||
|
bottom : 0;
|
||||||
|
|
||||||
|
i {
|
||||||
|
margin-left : 10px;
|
||||||
|
animation-duration : 1000s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.resultsContainer {
|
||||||
|
display : flex;
|
||||||
|
flex-direction : column;
|
||||||
|
height : 100%;
|
||||||
|
overflow-y : auto;
|
||||||
|
font-family : 'BookInsanityRemake';
|
||||||
|
font-size : 0.34cm;
|
||||||
|
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-family : 'Open Sans';
|
||||||
|
font-weight : 900;
|
||||||
|
color : white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.foundBrews {
|
||||||
|
position : relative;
|
||||||
|
width : 100%;
|
||||||
|
height : 100%;
|
||||||
|
max-height : 100%;
|
||||||
|
padding : 50px 50px 70px 50px;
|
||||||
|
overflow-y : scroll;
|
||||||
|
background-color : #2C3E50;
|
||||||
|
|
||||||
|
h3 { font-size : 25px; }
|
||||||
|
|
||||||
|
&.noBrews {
|
||||||
|
display : grid;
|
||||||
|
place-items : center;
|
||||||
|
color : white;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.searching {
|
||||||
|
display : grid;
|
||||||
|
place-items : center;
|
||||||
|
color : white;
|
||||||
|
|
||||||
|
h3 { position : relative; }
|
||||||
|
|
||||||
|
h3.searchAnim::after {
|
||||||
|
position : absolute;
|
||||||
|
top : 50%;
|
||||||
|
right : 0;
|
||||||
|
width : max-content;
|
||||||
|
height : 1em;
|
||||||
|
content : '';
|
||||||
|
translate : calc(100% + 5px) -50%;
|
||||||
|
animation : trailingDots 2s ease infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.totalBrews {
|
||||||
|
position : fixed;
|
||||||
|
right : 0;
|
||||||
|
bottom : 0;
|
||||||
|
z-index : 1000;
|
||||||
|
padding : 8px 10px;
|
||||||
|
font-family : 'Open Sans';
|
||||||
|
font-size : 11px;
|
||||||
|
font-weight : 800;
|
||||||
|
color : white;
|
||||||
|
background-color : #333333;
|
||||||
|
|
||||||
|
.searchAnim {
|
||||||
|
position : relative;
|
||||||
|
display : inline-block;
|
||||||
|
width : 3ch;
|
||||||
|
height : 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchAnim::after {
|
||||||
|
position : absolute;
|
||||||
|
top : 50%;
|
||||||
|
right : 0;
|
||||||
|
width : max-content;
|
||||||
|
height : 1em;
|
||||||
|
content : '';
|
||||||
|
translate : -50% -50%;
|
||||||
|
animation : trailingDots 2s ease infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.brewItem {
|
||||||
|
width : 47%;
|
||||||
|
margin-right : 40px;
|
||||||
|
color : black;
|
||||||
|
isolation:isolate;
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
position:absolute;
|
||||||
|
inset:0;
|
||||||
|
display:block;
|
||||||
|
content:'';
|
||||||
|
background-image : url('/assets/parchmentBackground.jpg');
|
||||||
|
z-index:-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(even of .brewItem) { margin-right : 0; }
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-family : 'MrEavesRemake';
|
||||||
|
font-size : 0.75cm;
|
||||||
|
font-weight : 800;
|
||||||
|
line-height : 0.988em;
|
||||||
|
color : var(--HB_Color_HeaderText);
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
font-family : 'ScalySansRemake';
|
||||||
|
font-size : 1.2em;
|
||||||
|
position:relative;
|
||||||
|
z-index:2;
|
||||||
|
|
||||||
|
>span {
|
||||||
|
margin-right : 12px;
|
||||||
|
line-height : 1.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.links {
|
||||||
|
z-index:2;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
margin: 0px;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thumbnail {
|
||||||
|
z-index:1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.paginationControls {
|
||||||
|
position : absolute;
|
||||||
|
left : 50%;
|
||||||
|
display : grid;
|
||||||
|
grid-template-areas : 'previousPage currentPage nextPage';
|
||||||
|
grid-template-columns : 50px 1fr 50px;
|
||||||
|
place-items : center;
|
||||||
|
width : auto;
|
||||||
|
translate : -50%;
|
||||||
|
|
||||||
|
.pages {
|
||||||
|
display : flex;
|
||||||
|
grid-area : currentPage;
|
||||||
|
justify-content : space-evenly;
|
||||||
|
width : 100%;
|
||||||
|
height : 100%;
|
||||||
|
padding : 5px 8px;
|
||||||
|
text-align : center;
|
||||||
|
|
||||||
|
.pageNumber {
|
||||||
|
margin-inline : 1vw;
|
||||||
|
font-family : 'Open Sans';
|
||||||
|
font-weight : 900;
|
||||||
|
color : white;
|
||||||
|
text-underline-position : under;
|
||||||
|
text-wrap : nowrap;
|
||||||
|
cursor : pointer;
|
||||||
|
|
||||||
|
&.currentPage {
|
||||||
|
color : gold;
|
||||||
|
text-decoration : underline;
|
||||||
|
pointer-events : none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.firstPage { margin-right : -5px; }
|
||||||
|
|
||||||
|
&.lastPage { margin-left : -5px; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width : max-content;
|
||||||
|
|
||||||
|
&.previousPage { grid-area : previousPage; }
|
||||||
|
|
||||||
|
&.nextPage { grid-area : nextPage; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes trailingDots {
|
||||||
|
|
||||||
|
0%,
|
||||||
|
32% { content : ' .'; }
|
||||||
|
|
||||||
|
33%,
|
||||||
|
65% { content : ' ..'; }
|
||||||
|
|
||||||
|
66%,
|
||||||
|
100% { content : ' ...'; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// media query for when the page is smaller than 1079 px in width
|
||||||
|
@media screen and (max-width : 1079px) {
|
||||||
|
.vaultPage .content {
|
||||||
|
|
||||||
|
.dataGroup.form .brewLookup { padding : 1px 20px 20px 10px; }
|
||||||
|
|
||||||
|
.dataGroup.resultsContainer .foundBrews .brewItem {
|
||||||
|
width : 100%;
|
||||||
|
margin-inline : auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,57 +1,75 @@
|
|||||||
.fac {
|
.fac {
|
||||||
display : inline-block;
|
display : inline-block;
|
||||||
|
background-color : currentColor;
|
||||||
|
mask-size : contain;
|
||||||
|
mask-repeat : no-repeat;
|
||||||
|
mask-position : center;
|
||||||
|
width : 1em;
|
||||||
|
aspect-ratio : 1;
|
||||||
}
|
}
|
||||||
.position-top-left {
|
.position-top-left {
|
||||||
content: url('../icons/position-top-left.svg');
|
mask-image: url('../icons/position-top-left.svg');
|
||||||
}
|
}
|
||||||
.position-top-right {
|
.position-top-right {
|
||||||
content: url('../icons/position-top-right.svg');
|
mask-image: url('../icons/position-top-right.svg');
|
||||||
}
|
}
|
||||||
.position-bottom-left {
|
.position-bottom-left {
|
||||||
content: url('../icons/position-bottom-left.svg');
|
mask-image: url('../icons/position-bottom-left.svg');
|
||||||
}
|
}
|
||||||
.position-bottom-right {
|
.position-bottom-right {
|
||||||
content: url('../icons/position-bottom-right.svg');
|
mask-image: url('../icons/position-bottom-right.svg');
|
||||||
}
|
}
|
||||||
.position-top {
|
.position-top {
|
||||||
content: url('../icons/position-top.svg');
|
mask-image: url('../icons/position-top.svg');
|
||||||
}
|
}
|
||||||
.position-right {
|
.position-right {
|
||||||
content: url('../icons/position-right.svg');
|
mask-image: url('../icons/position-right.svg');
|
||||||
}
|
}
|
||||||
.position-bottom {
|
.position-bottom {
|
||||||
content: url('../icons/position-bottom.svg');
|
mask-image: url('../icons/position-bottom.svg');
|
||||||
}
|
}
|
||||||
.position-left {
|
.position-left {
|
||||||
content: url('../icons/position-left.svg');
|
mask-image: url('../icons/position-left.svg');
|
||||||
}
|
}
|
||||||
.mask-edge {
|
.mask-edge {
|
||||||
content: url('../icons/mask-edge.svg');
|
mask-image: url('../icons/mask-edge.svg');
|
||||||
}
|
}
|
||||||
.mask-corner {
|
.mask-corner {
|
||||||
content: url('../icons/mask-corner.svg');
|
mask-image: url('../icons/mask-corner.svg');
|
||||||
}
|
}
|
||||||
.mask-center {
|
.mask-center {
|
||||||
content: url('../icons/mask-center.svg');
|
mask-image: url('../icons/mask-center.svg');
|
||||||
}
|
}
|
||||||
.book-front-cover {
|
.book-front-cover {
|
||||||
content: url('../icons/book-front-cover.svg');
|
mask-image: url('../icons/book-front-cover.svg');
|
||||||
}
|
}
|
||||||
.book-back-cover {
|
.book-back-cover {
|
||||||
content: url('../icons/book-back-cover.svg');
|
mask-image: url('../icons/book-back-cover.svg');
|
||||||
}
|
}
|
||||||
.book-inside-cover {
|
.book-inside-cover {
|
||||||
content: url('../icons/book-inside-cover.svg');
|
mask-image: url('../icons/book-inside-cover.svg');
|
||||||
}
|
}
|
||||||
.book-part-cover {
|
.book-part-cover {
|
||||||
content: url('../icons/book-part-cover.svg');
|
mask-image: url('../icons/book-part-cover.svg');
|
||||||
|
}
|
||||||
|
.image-wrap-left {
|
||||||
|
mask-image: url('../icons/image-wrap-left.svg');
|
||||||
|
}
|
||||||
|
.image-wrap-right {
|
||||||
|
mask-image: url('../icons/image-wrap-right.svg');
|
||||||
}
|
}
|
||||||
.davek {
|
.davek {
|
||||||
content: url('../icons/Davek.svg');
|
mask-image: url('../icons/Davek.svg');
|
||||||
}
|
}
|
||||||
.rellanic {
|
.rellanic {
|
||||||
content: url('../icons/Rellanic.svg');
|
mask-image: url('../icons/Rellanic.svg');
|
||||||
}
|
}
|
||||||
.iokharic {
|
.iokharic {
|
||||||
content: url('../icons/Iokharic.svg');
|
mask-image: url('../icons/Iokharic.svg');
|
||||||
|
}
|
||||||
|
.zoom-to-fit {
|
||||||
|
mask-image: url('../icons/zoom-to-fit.svg');
|
||||||
|
}
|
||||||
|
.fit-width {
|
||||||
|
mask-image: url('../icons/fit-width.svg');
|
||||||
}
|
}
|
||||||
|
|||||||
15
client/icons/fit-width.svg
Normal file
15
client/icons/fit-width.svg
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
|
<g transform="matrix(1.07509,0,0,1.07509,-3.75511,-3.75468)">
|
||||||
|
<g transform="matrix(0.843549,0,0,0.950644,8.38004,4.39672)">
|
||||||
|
<path d="M28.455,52.413L28.455,58.581C28.455,59.719 27.684,60.745 26.501,61.181C25.318,61.616 23.956,61.375 23.051,60.571L11.114,49.96C9.878,48.862 9.878,47.08 11.114,45.981L23.051,35.371C23.956,34.566 25.318,34.326 26.501,34.761C27.684,35.197 28.455,36.223 28.455,37.361L28.455,43.528L70.223,43.528L70.223,37.361C70.223,36.223 70.995,35.197 72.177,34.761C73.36,34.326 74.722,34.566 75.627,35.371L87.564,45.981C88.8,47.08 88.8,48.862 87.564,49.96L75.627,60.571C74.722,61.375 73.36,61.616 72.177,61.181C70.995,60.745 70.223,59.719 70.223,58.581L70.223,52.413L28.455,52.413Z"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.46702,0,0,0.986488,-23.0335,3.50686)">
|
||||||
|
<path d="M23.967,5.877L23.967,88.383C23.967,90.556 22.781,92.321 21.319,92.321L21.157,92.321C19.695,92.321 18.509,90.556 18.509,88.383L18.509,5.877C18.509,3.703 19.695,1.939 21.157,1.939L21.319,1.939C22.781,1.939 23.967,3.703 23.967,5.877Z"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.46702,0,0,0.986488,60.7211,3.50686)">
|
||||||
|
<path d="M23.967,5.877L23.967,88.383C23.967,90.556 22.781,92.321 21.319,92.321L21.157,92.321C19.695,92.321 18.509,90.556 18.509,88.383L18.509,5.877C18.509,3.703 19.695,1.939 21.157,1.939L21.319,1.939C22.781,1.939 23.967,3.703 23.967,5.877Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
58
client/icons/image-wrap-left.svg
Normal file
58
client/icons/image-wrap-left.svg
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 512.00006 512"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg10"
|
||||||
|
sodipodi:docname="noun-wrap-image-left-212078.svg"
|
||||||
|
width="512.00006"
|
||||||
|
height="512"
|
||||||
|
inkscape:export-filename="image-wrap-right.svg"
|
||||||
|
inkscape:export-xdpi="300"
|
||||||
|
inkscape:export-ydpi="300"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||||
|
id="defs10" /><sodipodi:namedview
|
||||||
|
id="namedview10"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#111111"
|
||||||
|
borderopacity="1"
|
||||||
|
inkscape:showpageshadow="0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pagecheckerboard="1"
|
||||||
|
inkscape:deskcolor="#d1d1d1" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 185.80018,144 H 32"
|
||||||
|
id="path11"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
clip-path="none"
|
||||||
|
inkscape:export-filename="image-wrap-right.svg"
|
||||||
|
inkscape:export-xdpi="300"
|
||||||
|
inkscape:export-ydpi="300" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 185.80018,368 H 32"
|
||||||
|
id="path11-8"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
clip-path="none" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 480.00007,32 H 32"
|
||||||
|
id="path11-8-2-67"
|
||||||
|
clip-path="none"
|
||||||
|
sodipodi:nodetypes="cc" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 480.00008,480 H 32"
|
||||||
|
id="path11-8-2-67-2"
|
||||||
|
clip-path="none"
|
||||||
|
sodipodi:nodetypes="cc" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 160.0001,255.98832 32,256.01162"
|
||||||
|
id="path11-0"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
clip-path="none" /><path
|
||||||
|
id="path23"
|
||||||
|
style="opacity:0.922046;fill:#000000;fill-opacity:1;stroke-width:64;stroke-linecap:round;stroke-dasharray:none;paint-order:fill markers stroke"
|
||||||
|
d="m 416.00008,96 a 160,160 0 0 1 96,32.50977 v 254.98046 a 160,160 0 0 1 -96,32.50977 160,160 0 0 1 -160,-160 160,160 0 0 1 160,-160 z" /></svg>
|
||||||
|
After Width: | Height: | Size: 2.5 KiB |
58
client/icons/image-wrap-right.svg
Normal file
58
client/icons/image-wrap-right.svg
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 512.00006 512"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg10"
|
||||||
|
sodipodi:docname="noun-wrap-image-left-212078.svg"
|
||||||
|
width="512.00006"
|
||||||
|
height="512"
|
||||||
|
inkscape:export-filename="image-wrap-right.svg"
|
||||||
|
inkscape:export-xdpi="300"
|
||||||
|
inkscape:export-ydpi="300"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||||
|
id="defs10" /><sodipodi:namedview
|
||||||
|
id="namedview10"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#111111"
|
||||||
|
borderopacity="1"
|
||||||
|
inkscape:showpageshadow="0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pagecheckerboard="1"
|
||||||
|
inkscape:deskcolor="#d1d1d1" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 326.1999,144 H 480.00008"
|
||||||
|
id="path11"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
clip-path="none"
|
||||||
|
inkscape:export-filename="image-wrap-right.svg"
|
||||||
|
inkscape:export-xdpi="300"
|
||||||
|
inkscape:export-ydpi="300" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 326.1999,368 H 480.00008"
|
||||||
|
id="path11-8"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
clip-path="none" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 32.00001,32 H 480.00008"
|
||||||
|
id="path11-8-2-67"
|
||||||
|
clip-path="none"
|
||||||
|
sodipodi:nodetypes="cc" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 32,480 H 480.00008"
|
||||||
|
id="path11-8-2-67-2"
|
||||||
|
clip-path="none"
|
||||||
|
sodipodi:nodetypes="cc" /><path
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:64;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 351.99998,255.98832 128.0001,0.0233"
|
||||||
|
id="path11-0"
|
||||||
|
sodipodi:nodetypes="cc"
|
||||||
|
clip-path="none" /><path
|
||||||
|
id="path23"
|
||||||
|
style="opacity:0.922046;fill:#000000;fill-opacity:1;stroke-width:64;stroke-linecap:round;stroke-dasharray:none;paint-order:fill markers stroke"
|
||||||
|
d="M 96,96 A 160,160 0 0 0 0,128.50977 V 383.49023 A 160,160 0 0 0 96,416 160,160 0 0 0 256,256 160,160 0 0 0 96,96 Z" /></svg>
|
||||||
|
After Width: | Height: | Size: 2.5 KiB |
12
client/icons/zoom-to-fit.svg
Normal file
12
client/icons/zoom-to-fit.svg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
|
<g transform="matrix(1.0781,0,0,1.0781,-3.90545,-3.90502)">
|
||||||
|
<g transform="matrix(0.841196,0,0,0.947993,8.49652,4.52391)">
|
||||||
|
<path d="M44.333,52.413L28.455,52.413L28.455,58.581C28.455,59.719 27.684,60.745 26.501,61.181C25.318,61.616 23.956,61.375 23.051,60.571L11.114,49.96C9.878,48.862 9.878,47.08 11.114,45.981L23.051,35.371C23.956,34.566 25.318,34.326 26.501,34.761C27.684,35.197 28.455,36.223 28.455,37.361L28.455,43.528L44.333,43.528L44.333,29.439L37.382,29.439C36.099,29.439 34.943,28.755 34.452,27.705C33.961,26.656 34.233,25.448 35.14,24.644L47.097,14.052C48.335,12.956 50.343,12.956 51.581,14.052L63.539,24.644C64.446,25.448 64.717,26.656 64.226,27.705C63.735,28.755 62.579,29.439 61.296,29.439L54.346,29.439L54.346,43.528L70.223,43.528L70.223,37.361C70.223,36.223 70.995,35.197 72.177,34.761C73.36,34.326 74.722,34.566 75.627,35.371L87.564,45.981C88.8,47.08 88.8,48.862 87.564,49.96L75.627,60.571C74.722,61.375 73.36,61.616 72.177,61.181C70.995,60.745 70.223,59.719 70.223,58.581L70.223,52.413L54.346,52.413L54.346,66.502L61.296,66.502C62.579,66.502 63.735,67.187 64.226,68.236C64.717,69.286 64.446,70.494 63.539,71.297L51.581,81.889C50.343,82.986 48.335,82.986 47.097,81.889L35.14,71.297C34.233,70.494 33.961,69.286 34.452,68.236C34.943,67.187 36.099,66.502 37.382,66.502L44.333,66.503L44.333,52.413Z"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.0247,0,0,1.0247,-5.47698,-3.53855)">
|
||||||
|
<path d="M99.4,14.269L99.4,90.227C99.4,94.245 96.137,97.508 92.119,97.508L16.161,97.508C12.142,97.508 8.88,94.245 8.88,90.227L8.88,14.269C8.88,10.25 12.142,6.988 16.161,6.988L92.119,6.988C96.137,6.988 99.4,10.25 99.4,14.269ZM93.633,14.269C93.633,13.433 92.955,12.755 92.119,12.755L16.161,12.755C15.325,12.755 14.647,13.433 14.647,14.269L14.647,90.227C14.647,91.062 15.325,91.741 16.161,91.741L92.119,91.741C92.955,91.741 93.633,91.062 93.633,90.227L93.633,14.269Z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -12,9 +12,9 @@ const template = async function(name, title='', props = {}){
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, height=device-height, interactive-widget=resizes-visual" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, height=device-height, interactive-widget=resizes-visual" />
|
||||||
<link href="//use.fontawesome.com/releases/v5.15.1/css/all.css" rel="stylesheet" />
|
<link href="//use.fontawesome.com/releases/v6.5.1/css/all.css" rel="stylesheet" type="text/css" />
|
||||||
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
|
||||||
<link href=${`/${name}/bundle.css`} rel='stylesheet' />
|
<link href=${`/${name}/bundle.css`} type="text/css" rel='stylesheet' />
|
||||||
<link rel="icon" href="/assets/favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="/assets/favicon.ico" type="image/x-icon" />
|
||||||
${ogMetaTags}
|
${ogMetaTags}
|
||||||
<meta name="twitter:card" content="summary">
|
<meta name="twitter:card" content="summary">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"secret" : "secret",
|
"secret" : "secret",
|
||||||
"web_port" : 8000,
|
"web_port" : 8000,
|
||||||
"enable_v3" : true,
|
"enable_v3" : true,
|
||||||
|
"enable_themes" : true,
|
||||||
"local_environments" : ["docker", "local"],
|
"local_environments" : ["docker", "local"],
|
||||||
"publicUrl" : "https://homebrewery.naturalcrit.com"
|
"publicUrl" : "https://homebrewery.naturalcrit.com"
|
||||||
}
|
}
|
||||||
|
|||||||
71
eslint.config.mjs
Normal file
71
eslint.config.mjs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import react from "eslint-plugin-react";
|
||||||
|
import jest from "eslint-plugin-jest";
|
||||||
|
import globals from "globals";
|
||||||
|
|
||||||
|
export default [{
|
||||||
|
ignores: ["build/"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files : ['**/*.js', '**/*.jsx'],
|
||||||
|
plugins : { react, jest },
|
||||||
|
languageOptions : {
|
||||||
|
ecmaVersion : "latest",
|
||||||
|
sourceType : "module",
|
||||||
|
parserOptions : { ecmaFeatures: { jsx: true } },
|
||||||
|
globals : { ...globals.browser, ...globals.node }
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
/** Errors **/
|
||||||
|
"camelcase" : ["error", { properties: "never" }],
|
||||||
|
"no-array-constructor" : "error",
|
||||||
|
"no-iterator" : "error",
|
||||||
|
"no-nested-ternary" : "error",
|
||||||
|
"no-new-object" : "error",
|
||||||
|
"no-proto" : "error",
|
||||||
|
"react/jsx-no-bind" : ["error", { allowArrowFunctions: true }],
|
||||||
|
"react/jsx-uses-react" : "error",
|
||||||
|
"react/prefer-es6-class" : ["error", "never"],
|
||||||
|
"jest/valid-expect" : ["error", { maxArgs: 3 }],
|
||||||
|
|
||||||
|
/** Warnings **/
|
||||||
|
"max-lines" : ["warn", { max: 200, skipComments: true, skipBlankLines: true }],
|
||||||
|
"max-depth" : ["warn", { max: 4 }],
|
||||||
|
"max-params" : ["warn", { max: 5 }],
|
||||||
|
"no-restricted-syntax" : ["warn", "ClassDeclaration", "SwitchStatement"],
|
||||||
|
"no-unused-vars" : ["warn", { vars: "all", args: "none", varsIgnorePattern: "config|_|cx|createClass" }],
|
||||||
|
"react/jsx-uses-vars" : "warn",
|
||||||
|
|
||||||
|
/** Fixable **/
|
||||||
|
"arrow-parens" : ["warn", "always"],
|
||||||
|
"brace-style" : ["warn", "1tbs", { allowSingleLine: true }],
|
||||||
|
"jsx-quotes" : ["warn", "prefer-single"],
|
||||||
|
"no-var" : "warn",
|
||||||
|
"prefer-const" : "warn",
|
||||||
|
"prefer-template" : "warn",
|
||||||
|
"quotes" : ["warn", "single", { allowTemplateLiterals: true }],
|
||||||
|
"semi" : ["warn", "always"],
|
||||||
|
|
||||||
|
/** Whitespace **/
|
||||||
|
"array-bracket-spacing" : ["warn", "never"],
|
||||||
|
"arrow-spacing" : ["warn", { before: false, after: false }],
|
||||||
|
"comma-spacing" : ["warn", { before: false, after: true }],
|
||||||
|
"indent" : ["warn", "tab", { MemberExpression: "off" }],
|
||||||
|
"linebreak-style" : "off",
|
||||||
|
"no-trailing-spaces" : "warn",
|
||||||
|
"no-whitespace-before-property" : "warn",
|
||||||
|
"object-curly-spacing" : ["warn", "always"],
|
||||||
|
"react/jsx-indent-props" : ["warn", "tab"],
|
||||||
|
"space-in-parens" : ["warn", "never"],
|
||||||
|
"template-curly-spacing" : ["warn", "never"],
|
||||||
|
"keyword-spacing" : ["warn", {
|
||||||
|
before : true,
|
||||||
|
after : true,
|
||||||
|
overrides : { if: { before: false, after: false } }
|
||||||
|
}],
|
||||||
|
"key-spacing" : ["warn", {
|
||||||
|
multiLine : { beforeColon: true, afterColon: true, align: "colon" },
|
||||||
|
singleLine : { beforeColon: false, afterColon: true }
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
2
faq.md
2
faq.md
@@ -102,7 +102,7 @@ The best way to avoid this is to leave space at the end of a column equal to one
|
|||||||
|
|
||||||
### Why do I need to manually create a new page? Why doesn't text flow between pages?
|
### Why do I need to manually create a new page? Why doesn't text flow between pages?
|
||||||
|
|
||||||
A Homebrewery document is at it's core an HTML & CSS document, and currently limited by the specs of those technologies. It is currently not possible to flow content from inside one box ("page") to the inside of another box. It seems likely that someday CSS will add this capability, and if/when that happens, Homebrewery will adopt it as soon as possible.
|
A Homebrewery document is at its core an HTML & CSS document, and currently limited by the specs of those technologies. It is currently not possible to flow content from inside one box ("page") to the inside of another box. It seems likely that someday CSS will add this capability, and if/when that happens, Homebrewery will adopt it as soon as possible.
|
||||||
|
|
||||||
### Where do I get images?
|
### Where do I get images?
|
||||||
The Homebrewery does not provide images for use besides some page elements and example images for snippets. You will need to find your own images for use and be sure you are following the appropriate license requirements.
|
The Homebrewery does not provide images for use besides some page elements and example images for snippets. You will need to find your own images for use and be sure you are following the appropriate license requirements.
|
||||||
|
|||||||
7300
package-lock.json
generated
7300
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
94
package.json
94
package.json
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "homebrewery",
|
"name": "homebrewery",
|
||||||
"description": "Create authentic looking D&D homebrews using only markdown",
|
"description": "Create authentic looking D&D homebrews using only markdown",
|
||||||
"version": "3.10.0",
|
"version": "3.15.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"npm": "^10.2.x",
|
"npm": "^10.2.x",
|
||||||
"node": ">=20.8.x"
|
"node": "^20.8.x"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -15,21 +15,27 @@
|
|||||||
"quick": "node scripts/quick.js",
|
"quick": "node scripts/quick.js",
|
||||||
"build": "node scripts/buildHomebrew.js && node scripts/buildAdmin.js",
|
"build": "node scripts/buildHomebrew.js && node scripts/buildAdmin.js",
|
||||||
"builddev": "node scripts/buildHomebrew.js --dev",
|
"builddev": "node scripts/buildHomebrew.js --dev",
|
||||||
"lint": "eslint --fix **/*.{js,jsx}",
|
"lint": "eslint --fix",
|
||||||
"lint:dry": "eslint **/*.{js,jsx}",
|
"lint:dry": "eslint",
|
||||||
"stylelint": "stylelint --fix **/*.{less}",
|
"stylelint": "stylelint --fix **/*.{less}",
|
||||||
"stylelint:dry": "stylelint **/*.less",
|
"stylelint:dry": "stylelint **/*.less",
|
||||||
"circleci": "npm test && eslint **/*.{js,jsx} --max-warnings=0",
|
"circleci": "npm test && eslint **/*.{js,jsx} --max-warnings=0",
|
||||||
"verify": "npm run lint && npm test",
|
"verify": "npm run lint && npm test",
|
||||||
"test": "jest --runInBand",
|
"test": "jest --runInBand",
|
||||||
"test:api-unit": "jest server/*.spec.js --verbose",
|
"test:api-unit": "jest \"server/.*.spec.js\" --verbose",
|
||||||
|
"test:api-unit:themes": "jest \"server/.*.spec.js\" -t \"theme bundle\" --verbose",
|
||||||
|
"test:api-unit:css": "jest \"server/.*.spec.js\" -t \"Get CSS\" --verbose",
|
||||||
"test:coverage": "jest --coverage --silent --runInBand",
|
"test:coverage": "jest --coverage --silent --runInBand",
|
||||||
"test:dev": "jest --verbose --watch",
|
"test:dev": "jest --verbose --watch",
|
||||||
"test:basic": "jest tests/markdown/basic.test.js --verbose",
|
"test:basic": "jest tests/markdown/basic.test.js --verbose",
|
||||||
"test:mustache-syntax": "jest '.*(mustache-syntax).*' --verbose --noStackTrace",
|
"test:variables": "jest tests/markdown/variables.test.js --verbose",
|
||||||
"test:mustache-syntax:inline": "jest '.*(mustache-syntax).*' -t '^Inline:.*' --verbose --noStackTrace",
|
"test:mustache-syntax": "jest \".*(mustache-syntax).*\" --verbose --noStackTrace",
|
||||||
"test:mustache-syntax:block": "jest '.*(mustache-syntax).*' -t '^Block:.*' --verbose --noStackTrace",
|
"test:mustache-syntax:inline": "jest \".*(mustache-syntax).*\" -t '^Inline:.*' --verbose --noStackTrace",
|
||||||
"test:mustache-syntax:injection": "jest '.*(mustache-syntax).*' -t '^Injection:.*' --verbose --noStackTrace",
|
"test:mustache-syntax:block": "jest \".*(mustache-syntax).*\" -t '^Block:.*' --verbose --noStackTrace",
|
||||||
|
"test:mustache-syntax:injection": "jest \".*(mustache-syntax).*\" -t '^Injection:.*' --verbose --noStackTrace",
|
||||||
|
"test:definition-lists": "jest tests/markdown/definition-lists.test.js --verbose --noStackTrace",
|
||||||
|
"test:hard-breaks": "jest tests/markdown/hard-breaks.test.js --verbose --noStackTrace",
|
||||||
|
"test:emojis": "jest tests/markdown/emojis.test.js --verbose --noStackTrace",
|
||||||
"test:route": "jest tests/routes/static-pages.test.js --verbose",
|
"test:route": "jest tests/routes/static-pages.test.js --verbose",
|
||||||
"phb": "node scripts/phb.js",
|
"phb": "node scripts/phb.js",
|
||||||
"prod": "set NODE_ENV=production && npm run build",
|
"prod": "set NODE_ENV=production && npm run build",
|
||||||
@@ -53,15 +59,15 @@
|
|||||||
],
|
],
|
||||||
"coverageThreshold": {
|
"coverageThreshold": {
|
||||||
"global": {
|
"global": {
|
||||||
"statements": 25,
|
"statements": 50,
|
||||||
"branches": 10,
|
"branches": 40,
|
||||||
"functions": 22,
|
"functions": 40,
|
||||||
"lines": 25
|
"lines": 50
|
||||||
},
|
},
|
||||||
"server/homebrew.api.js": {
|
"server/homebrew.api.js": {
|
||||||
"statements": 65,
|
"statements": 70,
|
||||||
"branches": 50,
|
"branches": 50,
|
||||||
"functions": 60,
|
"functions": 65,
|
||||||
"lines": 70
|
"lines": 70
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -79,53 +85,57 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.23.2",
|
"@babel/core": "^7.25.2",
|
||||||
"@babel/plugin-transform-runtime": "^7.23.2",
|
"@babel/plugin-transform-runtime": "^7.25.4",
|
||||||
"@babel/preset-env": "^7.23.2",
|
"@babel/preset-env": "^7.25.4",
|
||||||
"@babel/preset-react": "^7.22.15",
|
"@babel/preset-react": "^7.24.7",
|
||||||
"@googleapis/drive": "^8.4.0",
|
"@googleapis/drive": "^8.14.0",
|
||||||
"body-parser": "^1.20.2",
|
"body-parser": "^1.20.2",
|
||||||
"classnames": "^2.3.2",
|
"classnames": "^2.5.1",
|
||||||
"codemirror": "^5.65.6",
|
"codemirror": "^5.65.6",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"create-react-class": "^15.7.0",
|
"create-react-class": "^15.7.0",
|
||||||
"dedent-tabs": "^0.10.3",
|
"dedent-tabs": "^0.10.3",
|
||||||
"express": "^4.18.2",
|
"dompurify": "^3.1.6",
|
||||||
|
"expr-eval": "^2.0.2",
|
||||||
|
"express": "^4.19.2",
|
||||||
"express-async-handler": "^1.2.0",
|
"express-async-handler": "^1.2.0",
|
||||||
"express-static-gzip": "2.1.7",
|
"express-static-gzip": "2.1.7",
|
||||||
"fs-extra": "11.1.1",
|
"fs-extra": "11.2.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
"less": "^3.13.1",
|
"less": "^3.13.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"marked": "5.1.1",
|
"marked": "11.2.0",
|
||||||
"marked-extended-tables": "^1.0.7",
|
"marked-emoji": "^1.4.2",
|
||||||
"marked-gfm-heading-id": "^3.1.0",
|
"marked-extended-tables": "^1.0.10",
|
||||||
"marked-smartypants-lite": "^1.0.1",
|
"marked-gfm-heading-id": "^3.2.0",
|
||||||
|
"marked-smartypants-lite": "^1.0.2",
|
||||||
"markedLegacy": "npm:marked@^0.3.19",
|
"markedLegacy": "npm:marked@^0.3.19",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.30.1",
|
||||||
"mongoose": "^7.6.1",
|
"mongoose": "^8.6.0",
|
||||||
"nanoid": "3.3.4",
|
"nanoid": "3.3.4",
|
||||||
"nconf": "^0.12.0",
|
"nconf": "^0.12.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.3.1",
|
||||||
"react-frame-component": "^4.1.3",
|
"react-frame-component": "^4.1.3",
|
||||||
"react-router-dom": "6.16.0",
|
"react-router-dom": "6.26.1",
|
||||||
"sanitize-filename": "1.6.3",
|
"sanitize-filename": "1.6.3",
|
||||||
"superagent": "^8.1.2",
|
"superagent": "^10.1.0",
|
||||||
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
|
"vitreum": "git+https://git@github.com/calculuschild/vitreum.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.51.0",
|
"@stylistic/stylelint-plugin": "^3.0.1",
|
||||||
"eslint-plugin-jest": "^27.4.2",
|
"eslint": "^9.9.1",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-jest": "^28.8.2",
|
||||||
|
"eslint-plugin-react": "^7.35.1",
|
||||||
|
"globals": "^15.9.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-expect-message": "^1.1.3",
|
"jest-expect-message": "^1.1.3",
|
||||||
"postcss-less": "^6.0.0",
|
"postcss-less": "^6.0.0",
|
||||||
"stylelint": "^15.10.3",
|
"stylelint": "^16.9.0",
|
||||||
"stylelint-config-recess-order": "^4.3.0",
|
"stylelint-config-recess-order": "^5.1.0",
|
||||||
"stylelint-config-recommended": "^13.0.0",
|
"stylelint-config-recommended": "^14.0.1",
|
||||||
"stylelint-stylistic": "^0.4.3",
|
"supertest": "^7.0.0"
|
||||||
"supertest": "^6.3.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,10 @@ fs.emptyDirSync('./build');
|
|||||||
|
|
||||||
//v==---------------------------MOVE CM EDITOR THEMES -----------------------------==v//
|
//v==---------------------------MOVE CM EDITOR THEMES -----------------------------==v//
|
||||||
|
|
||||||
editorThemeFiles = fs.readdirSync('./node_modules/codemirror/theme');
|
const editorThemesBuildDir = './build/homebrew/cm-themes';
|
||||||
|
await fs.copy('./node_modules/codemirror/theme', editorThemesBuildDir);
|
||||||
|
await fs.copy('./themes/codeMirror/customThemes', editorThemesBuildDir);
|
||||||
|
editorThemeFiles = fs.readdirSync(editorThemesBuildDir);
|
||||||
|
|
||||||
const editorThemeFile = './themes/codeMirror/editorThemes.json';
|
const editorThemeFile = './themes/codeMirror/editorThemes.json';
|
||||||
if(fs.existsSync(editorThemeFile)) fs.rmSync(editorThemeFile);
|
if(fs.existsSync(editorThemeFile)) fs.rmSync(editorThemeFile);
|
||||||
@@ -114,7 +117,7 @@ fs.emptyDirSync('./build');
|
|||||||
stream.write('\n]\n');
|
stream.write('\n]\n');
|
||||||
stream.end();
|
stream.end();
|
||||||
|
|
||||||
await fs.copy('./node_modules/codemirror/theme', './build/homebrew/cm-themes');
|
|
||||||
await fs.copy('./themes/codeMirror', './build/homebrew/codeMirror');
|
await fs.copy('./themes/codeMirror', './build/homebrew/codeMirror');
|
||||||
|
|
||||||
//v==----------------------------- BUNDLE PACKAGES --------------------------------==v//
|
//v==----------------------------- BUNDLE PACKAGES --------------------------------==v//
|
||||||
@@ -151,8 +154,6 @@ fs.emptyDirSync('./build');
|
|||||||
// build(bundles);
|
// build(bundles);
|
||||||
//
|
//
|
||||||
|
|
||||||
})().catch(console.error);
|
|
||||||
|
|
||||||
//In development, set up LiveReload (refreshes browser), and Nodemon (restarts server)
|
//In development, set up LiveReload (refreshes browser), and Nodemon (restarts server)
|
||||||
if(isDev){
|
if(isDev){
|
||||||
livereload('./build'); // Install the Chrome extension LiveReload to automatically refresh the browser
|
livereload('./build'); // Install the Chrome extension LiveReload to automatically refresh the browser
|
||||||
@@ -162,3 +163,5 @@ if(isDev){
|
|||||||
//watch : ['./server', './themes'], // Watch additional folders if needed
|
//watch : ['./server', './themes'], // Watch additional folders if needed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})().catch(console.error);
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
"codemirror/addon/edit/closetag.js",
|
"codemirror/addon/edit/closetag.js",
|
||||||
"codemirror/addon/edit/trailingspace.js",
|
"codemirror/addon/edit/trailingspace.js",
|
||||||
"codemirror/addon/selection/active-line.js",
|
"codemirror/addon/selection/active-line.js",
|
||||||
|
"codemirror/addon/hint/show-hint.js",
|
||||||
"moment",
|
"moment",
|
||||||
"superagent",
|
"superagent"
|
||||||
"marked"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
10
server.js
10
server.js
@@ -7,6 +7,14 @@ DB.connect(config).then(()=>{
|
|||||||
// before launching server
|
// before launching server
|
||||||
const PORT = process.env.PORT || config.get('web_port') || 8000;
|
const PORT = process.env.PORT || config.get('web_port') || 8000;
|
||||||
server.app.listen(PORT, ()=>{
|
server.app.listen(PORT, ()=>{
|
||||||
console.log(`server on port: ${PORT}`);
|
const reset = '\x1b[0m'; // Reset to default style
|
||||||
|
const bright = '\x1b[1m'; // Bright (bold) style
|
||||||
|
const cyan = '\x1b[36m'; // Cyan color
|
||||||
|
const underline = '\x1b[4m'; // Underlined style
|
||||||
|
|
||||||
|
console.log(`\n\tserver started at: ${new Date().toLocaleString()}`);
|
||||||
|
console.log(`\tserver on port: ${PORT}`);
|
||||||
|
console.log(`\t${bright + cyan}Open in browser: ${reset}${underline + bright + cyan}http://localhost:${PORT}${reset}\n\n`);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,77 +26,116 @@ const mw = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const junkBrewPipeline = [
|
||||||
/* Search for brews that are older than 3 days and that are shorter than a tweet */
|
{ $match : {
|
||||||
const junkBrewQuery = HomebrewModel.find({
|
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
|
||||||
'$where' : 'this.text.length < 140',
|
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
|
||||||
createdAt : {
|
} },
|
||||||
$lt : Moment().subtract(30, 'days').toDate()
|
{ $project: { textBinSize: { $binarySize: '$textBin' } } },
|
||||||
}
|
{ $match: { textBinSize: { $lt: 140 } } },
|
||||||
}).limit(100).maxTime(60000);
|
{ $limit: 100 }
|
||||||
|
];
|
||||||
|
|
||||||
/* Search for brews that aren't compressed (missing the compressed text field) */
|
/* Search for brews that aren't compressed (missing the compressed text field) */
|
||||||
const uncompressedBrewQuery = HomebrewModel.find({
|
const uncompressedBrewQuery = HomebrewModel.find({
|
||||||
'text' : { '$exists': true }
|
'text' : { '$exists': true }
|
||||||
}).lean().limit(10000).select('_id');
|
}).lean().limit(10000).select('_id');
|
||||||
|
|
||||||
|
// Search for up to 100 brews that have not been viewed or updated in 30 days and are shorter than 140 bytes
|
||||||
router.get('/admin/cleanup', mw.adminOnly, (req, res)=>{
|
router.get('/admin/cleanup', mw.adminOnly, (req, res)=>{
|
||||||
junkBrewQuery.exec((err, objs)=>{
|
HomebrewModel.aggregate(junkBrewPipeline).option({ maxTimeMS: 60000 })
|
||||||
if(err) return res.status(500).send(err);
|
.then((objs)=>res.json({ count: objs.length }))
|
||||||
return res.json({ count: objs.length });
|
.catch((error)=>{
|
||||||
|
console.error(error);
|
||||||
|
res.status(500).json({ error: 'Internal Server Error' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/* Removes all empty brews that are older than 3 days and that are shorter than a tweet */
|
|
||||||
|
// Delete up to 100 brews that have not been viewed or updated in 30 days and are shorter than 140 bytes
|
||||||
router.post('/admin/cleanup', mw.adminOnly, (req, res)=>{
|
router.post('/admin/cleanup', mw.adminOnly, (req, res)=>{
|
||||||
junkBrewQuery.remove().exec((err, objs)=>{
|
HomebrewModel.aggregate(junkBrewPipeline).option({ maxTimeMS: 60000 })
|
||||||
if(err) return res.status(500).send(err);
|
.then((docs)=>{
|
||||||
return res.json({ count: objs.length });
|
const ids = docs.map((doc)=>doc._id);
|
||||||
|
return HomebrewModel.deleteMany({ _id: { $in: ids } });
|
||||||
|
}).then((result)=>{
|
||||||
|
res.json({ count: result.deletedCount });
|
||||||
|
}).catch((error)=>{
|
||||||
|
console.error(error);
|
||||||
|
res.status(500).json({ error: 'Internal Server Error' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Searches for matching edit or share id, also attempts to partial match */
|
/* Searches for matching edit or share id, also attempts to partial match */
|
||||||
router.get('/admin/lookup/:id', mw.adminOnly, (req, res, next)=>{
|
router.get('/admin/lookup/:id', mw.adminOnly, async (req, res, next)=>{
|
||||||
HomebrewModel.findOne({ $or : [
|
HomebrewModel.findOne({
|
||||||
{ editId: { '$regex': req.params.id, '$options': 'i' } },
|
$or : [
|
||||||
{ shareId: { '$regex': req.params.id, '$options': 'i' } },
|
{ editId: { $regex: req.params.id, $options: 'i' } },
|
||||||
] }).exec((err, brew)=>{
|
{ shareId: { $regex: req.params.id, $options: 'i' } },
|
||||||
|
]
|
||||||
|
}).exec()
|
||||||
|
.then((brew)=>{
|
||||||
|
if(!brew) // No document found
|
||||||
|
return res.status(404).json({ error: 'Document not found' });
|
||||||
|
else
|
||||||
return res.json(brew);
|
return res.json(brew);
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.error(err);
|
||||||
|
return res.status(500).json({ error: 'Internal Server Error' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Find 50 brews that aren't compressed yet */
|
/* Find 50 brews that aren't compressed yet */
|
||||||
router.get('/admin/finduncompressed', mw.adminOnly, (req, res)=>{
|
router.get('/admin/finduncompressed', mw.adminOnly, (req, res)=>{
|
||||||
uncompressedBrewQuery.exec((err, objs)=>{
|
const query = uncompressedBrewQuery.clone();
|
||||||
if(err) return res.status(500).send(err);
|
|
||||||
objs = objs.map((obj)=>{return obj._id;});
|
query.exec()
|
||||||
return res.json({ count: objs.length, ids: objs });
|
.then((objs)=>{
|
||||||
|
const ids = objs.map((obj)=>obj._id);
|
||||||
|
res.json({ count: ids.length, ids });
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).send(err.message || 'Internal Server Error');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Compresses the "text" field of a brew to binary */
|
/* Compresses the "text" field of a brew to binary */
|
||||||
router.put('/admin/compress/:id', (req, res)=>{
|
router.put('/admin/compress/:id', (req, res)=>{
|
||||||
HomebrewModel.get({ _id: req.params.id })
|
HomebrewModel.findOne({ _id: req.params.id })
|
||||||
.then((brew)=>{
|
.then((brew)=>{
|
||||||
brew.textBin = zlib.deflateRawSync(brew.text); // Compress brew text to binary before saving
|
if(!brew)
|
||||||
brew.text = undefined; // Delete the non-binary text field since it's not needed anymore
|
return res.status(404).send('Brew not found');
|
||||||
|
|
||||||
brew.save((err, obj)=>{
|
if(brew.text) {
|
||||||
if(err) throw err;
|
brew.textBin = brew.textBin || zlib.deflateRawSync(brew.text); //Don't overwrite textBin if exists
|
||||||
return res.status(200).send(obj);
|
brew.text = undefined;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return brew.save();
|
||||||
})
|
})
|
||||||
|
.then((obj)=>res.status(200).send(obj))
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.log(err);
|
console.error(err);
|
||||||
return res.status(500).send('Error while saving');
|
res.status(500).send('Error while saving');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/admin/stats', mw.adminOnly, (req, res)=>{
|
|
||||||
HomebrewModel.count({}, (err, count)=>{
|
router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
|
||||||
|
try {
|
||||||
|
const totalBrewsCount = await HomebrewModel.countDocuments({});
|
||||||
|
const publishedBrewsCount = await HomebrewModel.countDocuments({ published: true });
|
||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
totalBrews : count
|
totalBrews : totalBrewsCount,
|
||||||
});
|
totalPublishedBrews : publishedBrewsCount
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/admin', mw.adminOnly, (req, res)=>{
|
router.get('/admin', mw.adminOnly, (req, res)=>{
|
||||||
|
|||||||
131
server/app.js
131
server/app.js
@@ -9,34 +9,22 @@ const yaml = require('js-yaml');
|
|||||||
const app = express();
|
const app = express();
|
||||||
const config = require('./config.js');
|
const config = require('./config.js');
|
||||||
|
|
||||||
const { homebrewApi, getBrew } = require('./homebrew.api.js');
|
const { homebrewApi, getBrew, getUsersBrewThemes, getCSS } = require('./homebrew.api.js');
|
||||||
const GoogleActions = require('./googleActions.js');
|
const GoogleActions = require('./googleActions.js');
|
||||||
const serveCompressedStaticAssets = require('./static-assets.mv.js');
|
const serveCompressedStaticAssets = require('./static-assets.mv.js');
|
||||||
const sanitizeFilename = require('sanitize-filename');
|
const sanitizeFilename = require('sanitize-filename');
|
||||||
const asyncHandler = require('express-async-handler');
|
const asyncHandler = require('express-async-handler');
|
||||||
|
const templateFn = require('./../client/template.js');
|
||||||
|
|
||||||
const { DEFAULT_BREW } = require('./brewDefaults.js');
|
const { DEFAULT_BREW } = require('./brewDefaults.js');
|
||||||
|
|
||||||
const splitTextStyleAndMetadata = (brew)=>{
|
const { splitTextStyleAndMetadata } = require('../shared/helpers.js');
|
||||||
brew.text = brew.text.replaceAll('\r\n', '\n');
|
|
||||||
if(brew.text.startsWith('```metadata')) {
|
|
||||||
const index = brew.text.indexOf('```\n\n');
|
|
||||||
const metadataSection = brew.text.slice(12, index - 1);
|
|
||||||
const metadata = yaml.load(metadataSection);
|
|
||||||
Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
|
|
||||||
brew.text = brew.text.slice(index + 5);
|
|
||||||
}
|
|
||||||
if(brew.text.startsWith('```css')) {
|
|
||||||
const index = brew.text.indexOf('```\n\n');
|
|
||||||
brew.style = brew.text.slice(7, index - 1);
|
|
||||||
brew.text = brew.text.slice(index + 5);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const sanitizeBrew = (brew, accessType)=>{
|
const sanitizeBrew = (brew, accessType)=>{
|
||||||
brew._id = undefined;
|
brew._id = undefined;
|
||||||
brew.__v = undefined;
|
brew.__v = undefined;
|
||||||
if(accessType !== 'edit'){
|
if(accessType !== 'edit' && accessType !== 'shareAuthor') {
|
||||||
brew.editId = undefined;
|
brew.editId = undefined;
|
||||||
}
|
}
|
||||||
return brew;
|
return brew;
|
||||||
@@ -67,6 +55,7 @@ app.use((req, res, next)=>{
|
|||||||
|
|
||||||
app.use(homebrewApi);
|
app.use(homebrewApi);
|
||||||
app.use(require('./admin.api.js'));
|
app.use(require('./admin.api.js'));
|
||||||
|
app.use(require('./vault.api.js'));
|
||||||
|
|
||||||
const HomebrewModel = require('./homebrew.model.js').model;
|
const HomebrewModel = require('./homebrew.model.js').model;
|
||||||
const welcomeText = require('fs').readFileSync('client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
|
const welcomeText = require('fs').readFileSync('client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
|
||||||
@@ -94,7 +83,8 @@ app.get('/robots.txt', (req, res)=>{
|
|||||||
app.get('/', (req, res, next)=>{
|
app.get('/', (req, res, next)=>{
|
||||||
req.brew = {
|
req.brew = {
|
||||||
text : welcomeText,
|
text : welcomeText,
|
||||||
renderer : 'V3'
|
renderer : 'V3',
|
||||||
|
theme : '5ePHB'
|
||||||
},
|
},
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
@@ -110,7 +100,8 @@ app.get('/', (req, res, next)=>{
|
|||||||
app.get('/legacy', (req, res, next)=>{
|
app.get('/legacy', (req, res, next)=>{
|
||||||
req.brew = {
|
req.brew = {
|
||||||
text : welcomeTextLegacy,
|
text : welcomeTextLegacy,
|
||||||
renderer : 'legacy'
|
renderer : 'legacy',
|
||||||
|
theme : '5ePHB'
|
||||||
},
|
},
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
@@ -126,7 +117,8 @@ app.get('/legacy', (req, res, next)=>{
|
|||||||
app.get('/migrate', (req, res, next)=>{
|
app.get('/migrate', (req, res, next)=>{
|
||||||
req.brew = {
|
req.brew = {
|
||||||
text : migrateText,
|
text : migrateText,
|
||||||
renderer : 'V3'
|
renderer : 'V3',
|
||||||
|
theme : '5ePHB'
|
||||||
},
|
},
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
@@ -143,7 +135,8 @@ app.get('/changelog', async (req, res, next)=>{
|
|||||||
req.brew = {
|
req.brew = {
|
||||||
title : 'Changelog',
|
title : 'Changelog',
|
||||||
text : changelogText,
|
text : changelogText,
|
||||||
renderer : 'V3'
|
renderer : 'V3',
|
||||||
|
theme : '5ePHB'
|
||||||
},
|
},
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
@@ -160,7 +153,8 @@ app.get('/faq', async (req, res, next)=>{
|
|||||||
req.brew = {
|
req.brew = {
|
||||||
title : 'FAQ',
|
title : 'FAQ',
|
||||||
text : faqText,
|
text : faqText,
|
||||||
renderer : 'V3'
|
renderer : 'V3',
|
||||||
|
theme : '5ePHB'
|
||||||
},
|
},
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
@@ -208,6 +202,9 @@ app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
|||||||
res.status(200).send(brew.text);
|
res.status(200).send(brew.text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Serve brew styling
|
||||||
|
app.get('/css/:id', asyncHandler(getBrew('share')), (req, res)=>{getCSS(req, res);});
|
||||||
|
|
||||||
//User Page
|
//User Page
|
||||||
app.get('/user/:username', async (req, res, next)=>{
|
app.get('/user/:username', async (req, res, next)=>{
|
||||||
const ownAccount = req.account && (req.account.username == req.params.username);
|
const ownAccount = req.account && (req.account.username == req.params.username);
|
||||||
@@ -278,9 +275,11 @@ app.get('/user/:username', async (req, res, next)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Edit Page
|
//Edit Page
|
||||||
app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{
|
app.get('/edit/:id', asyncHandler(getBrew('edit')), asyncHandler(async(req, res, next)=>{
|
||||||
req.brew = req.brew.toObject ? req.brew.toObject() : req.brew;
|
req.brew = req.brew.toObject ? req.brew.toObject() : req.brew;
|
||||||
|
|
||||||
|
req.userThemes = await(getUsersBrewThemes(req.account?.username));
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
title : req.brew.title || 'Untitled Brew',
|
title : req.brew.title || 'Untitled Brew',
|
||||||
description : req.brew.description || 'No description.',
|
description : req.brew.description || 'No description.',
|
||||||
@@ -292,10 +291,10 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{
|
|||||||
splitTextStyleAndMetadata(req.brew);
|
splitTextStyleAndMetadata(req.brew);
|
||||||
res.header('Cache-Control', 'no-cache, no-store'); //reload the latest saved brew when pressing back button, not the cached version before save.
|
res.header('Cache-Control', 'no-cache, no-store'); //reload the latest saved brew when pressing back button, not the cached version before save.
|
||||||
return next();
|
return next();
|
||||||
});
|
}));
|
||||||
|
|
||||||
//New Page
|
//New Page from ID
|
||||||
app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{
|
app.get('/new/:id', asyncHandler(getBrew('share')), asyncHandler(async(req, res, next)=>{
|
||||||
sanitizeBrew(req.brew, 'share');
|
sanitizeBrew(req.brew, 'share');
|
||||||
splitTextStyleAndMetadata(req.brew);
|
splitTextStyleAndMetadata(req.brew);
|
||||||
const brew = {
|
const brew = {
|
||||||
@@ -304,22 +303,36 @@ app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{
|
|||||||
text : req.brew.text,
|
text : req.brew.text,
|
||||||
style : req.brew.style,
|
style : req.brew.style,
|
||||||
renderer : req.brew.renderer,
|
renderer : req.brew.renderer,
|
||||||
theme : req.brew.theme
|
theme : req.brew.theme,
|
||||||
|
tags : req.brew.tags,
|
||||||
};
|
};
|
||||||
req.brew = _.defaults(brew, DEFAULT_BREW);
|
req.brew = _.defaults(brew, DEFAULT_BREW);
|
||||||
|
|
||||||
|
req.userThemes = await(getUsersBrewThemes(req.account?.username));
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
title : 'New',
|
title : 'New',
|
||||||
description : 'Start crafting your homebrew on the Homebrewery!'
|
description : 'Start crafting your homebrew on the Homebrewery!'
|
||||||
};
|
};
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
//New Page
|
||||||
|
app.get('/new', asyncHandler(async(req, res, next)=>{
|
||||||
|
req.userThemes = await(getUsersBrewThemes(req.account?.username));
|
||||||
|
|
||||||
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
|
title : 'New',
|
||||||
|
description : 'Start crafting your homebrew on the Homebrewery!'
|
||||||
|
};
|
||||||
|
|
||||||
|
return next();
|
||||||
|
}));
|
||||||
|
|
||||||
//Share Page
|
//Share Page
|
||||||
app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, res, next)=>{
|
app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, res, next)=>{
|
||||||
const { brew } = req;
|
const { brew } = req;
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
title : req.brew.title || 'Untitled Brew',
|
title : req.brew.title || 'Untitled Brew',
|
||||||
description : req.brew.description || 'No description.',
|
description : req.brew.description || 'No description.',
|
||||||
@@ -327,6 +340,8 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
|
|||||||
type : 'article'
|
type : 'article'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// increase visitor view count, do not include visits by author(s)
|
||||||
|
if(!brew.authors.includes(req.account?.username)){
|
||||||
if(req.params.id.length > 12 && !brew._id) {
|
if(req.params.id.length > 12 && !brew._id) {
|
||||||
const googleId = brew.googleId;
|
const googleId = brew.googleId;
|
||||||
const shareId = brew.shareId;
|
const shareId = brew.shareId;
|
||||||
@@ -335,23 +350,27 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
|
|||||||
} else {
|
} else {
|
||||||
await HomebrewModel.increaseView({ shareId: brew.shareId });
|
await HomebrewModel.increaseView({ shareId: brew.shareId });
|
||||||
}
|
}
|
||||||
sanitizeBrew(req.brew, 'share');
|
};
|
||||||
|
|
||||||
|
brew.authors.includes(req.account?.username) ? sanitizeBrew(req.brew, 'shareAuthor') : sanitizeBrew(req.brew, 'share');
|
||||||
splitTextStyleAndMetadata(req.brew);
|
splitTextStyleAndMetadata(req.brew);
|
||||||
return next();
|
return next();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//Print Page
|
|
||||||
app.get('/print/:id', asyncHandler(getBrew('share')), (req, res, next)=>{
|
|
||||||
sanitizeBrew(req.brew, 'share');
|
|
||||||
splitTextStyleAndMetadata(req.brew);
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
//Account Page
|
//Account Page
|
||||||
app.get('/account', asyncHandler(async (req, res, next)=>{
|
app.get('/account', asyncHandler(async (req, res, next)=>{
|
||||||
const data = {};
|
const data = {};
|
||||||
data.title = 'Account Information Page';
|
data.title = 'Account Information Page';
|
||||||
|
|
||||||
|
if(!req.account) {
|
||||||
|
res.set('WWW-Authenticate', 'Bearer realm="Authorization Required"');
|
||||||
|
const error = new Error('No valid account');
|
||||||
|
error.status = 401;
|
||||||
|
error.HBErrorCode = '50';
|
||||||
|
error.page = data.title;
|
||||||
|
return next(error);
|
||||||
|
};
|
||||||
|
|
||||||
let auth;
|
let auth;
|
||||||
let googleCount = [];
|
let googleCount = [];
|
||||||
if(req.account) {
|
if(req.account) {
|
||||||
@@ -381,7 +400,7 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
data.uiItems = {
|
data.accountDetails = {
|
||||||
username : req.account.username,
|
username : req.account.username,
|
||||||
issued : req.account.issued,
|
issued : req.account.issued,
|
||||||
googleId : Boolean(req.account.googleId),
|
googleId : Boolean(req.account.googleId),
|
||||||
@@ -415,8 +434,21 @@ if(isLocalEnvironment){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Vault Page
|
||||||
|
app.get('/vault', asyncHandler(async(req, res, next)=>{
|
||||||
|
return next();
|
||||||
|
}));
|
||||||
|
|
||||||
|
//Send rendered page
|
||||||
|
app.use(asyncHandler(async (req, res, next)=>{
|
||||||
|
if (!req.route) return res.redirect('/'); // Catch-all for invalid routes
|
||||||
|
|
||||||
|
const page = await renderPage(req, res);
|
||||||
|
if(!page) return;
|
||||||
|
res.send(page);
|
||||||
|
}));
|
||||||
|
|
||||||
//Render the page
|
//Render the page
|
||||||
const templateFn = require('./../client/template.js');
|
|
||||||
const renderPage = async (req, res)=>{
|
const renderPage = async (req, res)=>{
|
||||||
// Create configuration object
|
// Create configuration object
|
||||||
const configuration = {
|
const configuration = {
|
||||||
@@ -434,7 +466,8 @@ const renderPage = async (req, res)=>{
|
|||||||
enable_v3 : config.get('enable_v3'),
|
enable_v3 : config.get('enable_v3'),
|
||||||
enable_themes : config.get('enable_themes'),
|
enable_themes : config.get('enable_themes'),
|
||||||
config : configuration,
|
config : configuration,
|
||||||
ogMeta : req.ogMeta
|
ogMeta : req.ogMeta,
|
||||||
|
userThemes : req.userThemes
|
||||||
};
|
};
|
||||||
const title = req.brew ? req.brew.title : '';
|
const title = req.brew ? req.brew.title : '';
|
||||||
const page = await templateFn('homebrew', title, props)
|
const page = await templateFn('homebrew', title, props)
|
||||||
@@ -444,13 +477,6 @@ const renderPage = async (req, res)=>{
|
|||||||
return page;
|
return page;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Send rendered page
|
|
||||||
app.use(asyncHandler(async (req, res, next)=>{
|
|
||||||
const page = await renderPage(req, res);
|
|
||||||
if(!page) return;
|
|
||||||
res.send(page);
|
|
||||||
}));
|
|
||||||
|
|
||||||
//v=====----- Error-Handling Middleware -----=====v//
|
//v=====----- Error-Handling Middleware -----=====v//
|
||||||
//Format Errors as plain objects so all fields will appear in the string sent
|
//Format Errors as plain objects so all fields will appear in the string sent
|
||||||
const formatErrors = (key, value)=>{
|
const formatErrors = (key, value)=>{
|
||||||
@@ -469,9 +495,18 @@ const getPureError = (error)=>{
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.use(async (err, req, res, next)=>{
|
app.use(async (err, req, res, next)=>{
|
||||||
const status = err.status || err.code || 500;
|
err.originalUrl = req.originalUrl;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
||||||
|
if(err.originalUrl?.startsWith('/api/')) {
|
||||||
|
// console.log('API error');
|
||||||
|
res.status(err.status || err.response?.status || 500).send(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('non-API error');
|
||||||
|
const status = err.status || err.code || 500;
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
title : 'Error Page',
|
title : 'Error Page',
|
||||||
description : 'Something went wrong!'
|
description : 'Something went wrong!'
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable max-lines */
|
/* eslint-disable max-lines */
|
||||||
const _ = require('lodash');
|
|
||||||
const googleDrive = require('@googleapis/drive');
|
const googleDrive = require('@googleapis/drive');
|
||||||
const { nanoid } = require('nanoid');
|
const { nanoid } = require('nanoid');
|
||||||
const token = require('./token.js');
|
const token = require('./token.js');
|
||||||
@@ -7,7 +6,9 @@ const config = require('./config.js');
|
|||||||
|
|
||||||
let serviceAuth;
|
let serviceAuth;
|
||||||
if(!config.get('service_account')){
|
if(!config.get('service_account')){
|
||||||
console.log('No Google Service Account in config files - Google Drive integration will not be available.');
|
const reset = '\x1b[0m'; // Reset to default style
|
||||||
|
const yellow = '\x1b[33m'; // yellow color
|
||||||
|
console.warn(`\n${yellow}No Google Service Account in config files - Google Drive integration will not be available.${reset}`);
|
||||||
} else {
|
} else {
|
||||||
const keys = typeof(config.get('service_account')) == 'string' ?
|
const keys = typeof(config.get('service_account')) == 'string' ?
|
||||||
JSON.parse(config.get('service_account')) :
|
JSON.parse(config.get('service_account')) :
|
||||||
@@ -18,7 +19,7 @@ if(!config.get('service_account')){
|
|||||||
serviceAuth.scopes = ['https://www.googleapis.com/auth/drive'];
|
serviceAuth.scopes = ['https://www.googleapis.com/auth/drive'];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
console.log('Please make sure the Google Service Account is set up properly in your config files.');
|
console.warn('Please make sure the Google Service Account is set up properly in your config files.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,16 @@ const Markdown = require('../shared/naturalcrit/markdown.js');
|
|||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
const asyncHandler = require('express-async-handler');
|
const asyncHandler = require('express-async-handler');
|
||||||
const { nanoid } = require('nanoid');
|
const { nanoid } = require('nanoid');
|
||||||
|
const { splitTextStyleAndMetadata } = require('../shared/helpers.js');
|
||||||
|
|
||||||
const { DEFAULT_BREW, DEFAULT_BREW_LOAD } = require('./brewDefaults.js');
|
const { DEFAULT_BREW, DEFAULT_BREW_LOAD } = require('./brewDefaults.js');
|
||||||
|
|
||||||
|
const Themes = require('../themes/themes.json');
|
||||||
|
|
||||||
|
const isStaticTheme = (renderer, themeName)=>{
|
||||||
|
return Themes[renderer]?.[themeName] !== undefined;
|
||||||
|
};
|
||||||
|
|
||||||
// const getTopBrews = (cb) => {
|
// const getTopBrews = (cb) => {
|
||||||
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
|
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
|
||||||
// cb(brews);
|
// cb(brews);
|
||||||
@@ -37,6 +44,43 @@ const api = {
|
|||||||
}
|
}
|
||||||
return { id, googleId };
|
return { id, googleId };
|
||||||
},
|
},
|
||||||
|
//Get array of any of this user's brews tagged with `meta:theme`
|
||||||
|
getUsersBrewThemes : async (username)=>{
|
||||||
|
if(!username)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const fields = [
|
||||||
|
'title',
|
||||||
|
'tags',
|
||||||
|
'shareId',
|
||||||
|
'thumbnail',
|
||||||
|
'textBin',
|
||||||
|
'text',
|
||||||
|
'authors',
|
||||||
|
'renderer'
|
||||||
|
];
|
||||||
|
|
||||||
|
const userThemes = {};
|
||||||
|
|
||||||
|
const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['meta:theme', 'meta:Theme'] } });
|
||||||
|
|
||||||
|
if(brews) {
|
||||||
|
for (const brew of brews) {
|
||||||
|
userThemes[brew.renderer] ??= {};
|
||||||
|
userThemes[brew.renderer][brew.shareId] = {
|
||||||
|
name : brew.title,
|
||||||
|
renderer : brew.renderer,
|
||||||
|
baseTheme : brew.theme,
|
||||||
|
baseSnippets : false,
|
||||||
|
author : brew.authors[0],
|
||||||
|
path : brew.shareId,
|
||||||
|
thumbnail : brew.thumbnail || '/assets/naturalCritLogoWhite.svg'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return userThemes;
|
||||||
|
},
|
||||||
getBrew : (accessType, stubOnly = false)=>{
|
getBrew : (accessType, stubOnly = false)=>{
|
||||||
// Create middleware with the accessType passed in as part of the scope
|
// Create middleware with the accessType passed in as part of the scope
|
||||||
return async (req, res, next)=>{
|
return async (req, res, next)=>{
|
||||||
@@ -54,6 +98,10 @@ const api = {
|
|||||||
});
|
});
|
||||||
stub = stub?.toObject();
|
stub = stub?.toObject();
|
||||||
|
|
||||||
|
if(stub?.lock?.locked && accessType != 'edit') {
|
||||||
|
throw { HBErrorCode: '51', code: stub.lock.code, message: stub.lock.shareMessage, brewId: stub.shareId, brewTitle: stub.title };
|
||||||
|
}
|
||||||
|
|
||||||
// If there is a google id, try to find the google brew
|
// If there is a google id, try to find the google brew
|
||||||
if(!stubOnly && (googleId || stub?.googleId)) {
|
if(!stubOnly && (googleId || stub?.googleId)) {
|
||||||
let googleError;
|
let googleError;
|
||||||
@@ -79,9 +127,9 @@ const api = {
|
|||||||
if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) {
|
if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) {
|
||||||
const accessError = { name: 'Access Error', status: 401 };
|
const accessError = { name: 'Access Error', status: 401 };
|
||||||
if(req.account){
|
if(req.account){
|
||||||
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title };
|
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId };
|
||||||
}
|
}
|
||||||
throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title };
|
throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId };
|
||||||
}
|
}
|
||||||
|
|
||||||
// If after all of that we still don't have a brew, throw an exception
|
// If after all of that we still don't have a brew, throw an exception
|
||||||
@@ -100,6 +148,20 @@ const api = {
|
|||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getCSS : async (req, res)=>{
|
||||||
|
const { brew } = req;
|
||||||
|
if(!brew) return res.status(404).send('');
|
||||||
|
splitTextStyleAndMetadata(brew);
|
||||||
|
if(!brew.style) return res.status(404).send('');
|
||||||
|
|
||||||
|
res.set({
|
||||||
|
'Cache-Control' : 'no-cache',
|
||||||
|
'Content-Type' : 'text/css'
|
||||||
|
});
|
||||||
|
return res.status(200).send(brew.style);
|
||||||
|
},
|
||||||
|
|
||||||
mergeBrewText : (brew)=>{
|
mergeBrewText : (brew)=>{
|
||||||
let text = brew.text;
|
let text = brew.text;
|
||||||
if(brew.style !== undefined) {
|
if(brew.style !== undefined) {
|
||||||
@@ -138,7 +200,7 @@ const api = {
|
|||||||
return modified;
|
return modified;
|
||||||
},
|
},
|
||||||
excludeStubProps : (brew)=>{
|
excludeStubProps : (brew)=>{
|
||||||
const propsToExclude = ['text', 'textBin', 'renderer', 'pageCount'];
|
const propsToExclude = ['text', 'textBin'];
|
||||||
for (const prop of propsToExclude) {
|
for (const prop of propsToExclude) {
|
||||||
brew[prop] = undefined;
|
brew[prop] = undefined;
|
||||||
}
|
}
|
||||||
@@ -205,6 +267,58 @@ const api = {
|
|||||||
|
|
||||||
res.status(200).send(saved);
|
res.status(200).send(saved);
|
||||||
},
|
},
|
||||||
|
getThemeBundle : async(req, res)=>{
|
||||||
|
/* getThemeBundle: Collects the theme and all parent themes
|
||||||
|
returns an object containing an array of css, and an array of snippets, in render order
|
||||||
|
|
||||||
|
req.params.id : The shareId ( User theme ) or name ( static theme )
|
||||||
|
req.params.renderer : The Markdown renderer used for this theme */
|
||||||
|
|
||||||
|
req.params.renderer = _.upperFirst(req.params.renderer);
|
||||||
|
let currentTheme;
|
||||||
|
const completeStyles = [];
|
||||||
|
const completeSnippets = [];
|
||||||
|
|
||||||
|
while (req.params.id) {
|
||||||
|
//=== User Themes ===//
|
||||||
|
if(!isStaticTheme(req.params.renderer, req.params.id)) {
|
||||||
|
await api.getBrew('share')(req, res, ()=>{})
|
||||||
|
.catch((err)=>{
|
||||||
|
if(err.HBErrorCode == '05')
|
||||||
|
err = { ...err, name: 'ThemeLoad Error', message: 'Theme Not Found', HBErrorCode: '09' };
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
currentTheme = req.brew;
|
||||||
|
splitTextStyleAndMetadata(currentTheme);
|
||||||
|
|
||||||
|
// If there is anything in the snippets or style members, append them to the appropriate array
|
||||||
|
if(currentTheme?.snippets) completeSnippets.push(JSON.parse(currentTheme.snippets));
|
||||||
|
if(currentTheme?.style) completeStyles.push(`/* From Brew: ${req.protocol}://${req.get('host')}/share/${req.params.id} */\n\n${currentTheme.style}`);
|
||||||
|
|
||||||
|
req.params.id = currentTheme.theme;
|
||||||
|
req.params.renderer = currentTheme.renderer;
|
||||||
|
}
|
||||||
|
//=== Static Themes ===//
|
||||||
|
else {
|
||||||
|
const localSnippets = `${req.params.renderer}_${req.params.id}`; // Just log the name for loading on client
|
||||||
|
const localStyle = `@import url(\"/themes/${req.params.renderer}/${req.params.id}/style.css\");`;
|
||||||
|
completeSnippets.push(localSnippets);
|
||||||
|
completeStyles.push(`/* From Theme ${req.params.id} */\n\n${localStyle}`);
|
||||||
|
|
||||||
|
req.params.id = Themes[req.params.renderer][req.params.id].baseTheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const returnObj = {
|
||||||
|
// Reverse the order of the arrays so they are listed oldest parent to youngest child.
|
||||||
|
styles : completeStyles.reverse(),
|
||||||
|
snippets : completeSnippets.reverse()
|
||||||
|
};
|
||||||
|
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
return res.status(200).send(returnObj);
|
||||||
|
},
|
||||||
updateBrew : async (req, res)=>{
|
updateBrew : async (req, res)=>{
|
||||||
// Initialize brew from request and body, destructure query params, and set the initial value for the after-save method
|
// Initialize brew from request and body, destructure query params, and set the initial value for the after-save method
|
||||||
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
const brewFromClient = api.excludePropsFromUpdate(req.body);
|
||||||
@@ -365,5 +479,6 @@ router.put('/api/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api
|
|||||||
router.put('/api/update/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
|
router.put('/api/update/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
|
||||||
router.delete('/api/:id', asyncHandler(api.deleteBrew));
|
router.delete('/api/:id', asyncHandler(api.deleteBrew));
|
||||||
router.get('/api/remove/:id', asyncHandler(api.deleteBrew));
|
router.get('/api/remove/:id', asyncHandler(api.deleteBrew));
|
||||||
|
router.get('/api/theme/:renderer/:id', asyncHandler(api.getThemeBundle));
|
||||||
|
|
||||||
module.exports = api;
|
module.exports = api;
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ describe('Tests for api', ()=>{
|
|||||||
let saved;
|
let saved;
|
||||||
|
|
||||||
beforeEach(()=>{
|
beforeEach(()=>{
|
||||||
|
jest.resetModules();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
|
||||||
saved = undefined;
|
saved = undefined;
|
||||||
saveFunc = jest.fn(async function() {
|
saveFunc = jest.fn(async function() {
|
||||||
saved = { ...this, _id: '1' };
|
saved = { ...this, _id: '1' };
|
||||||
@@ -46,7 +49,9 @@ describe('Tests for api', ()=>{
|
|||||||
|
|
||||||
res = {
|
res = {
|
||||||
status : jest.fn(()=>res),
|
status : jest.fn(()=>res),
|
||||||
send : jest.fn(()=>{})
|
send : jest.fn(()=>{}),
|
||||||
|
set : jest.fn(()=>{}),
|
||||||
|
setHeader : jest.fn(()=>{})
|
||||||
};
|
};
|
||||||
|
|
||||||
api = require('./homebrew.api');
|
api = require('./homebrew.api');
|
||||||
@@ -81,10 +86,6 @@ describe('Tests for api', ()=>{
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(()=>{
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getId', ()=>{
|
describe('getId', ()=>{
|
||||||
it('should return only id if google id is not present', ()=>{
|
it('should return only id if google id is not present', ()=>{
|
||||||
const { id, googleId } = api.getId({
|
const { id, googleId } = api.getId({
|
||||||
@@ -298,6 +299,18 @@ describe('Tests for api', ()=>{
|
|||||||
expect(model.get).toHaveBeenCalledWith({ shareId: '1' });
|
expect(model.get).toHaveBeenCalledWith({ shareId: '1' });
|
||||||
expect(google.getGoogleBrew).toHaveBeenCalledWith('2', '1', 'share');
|
expect(google.getGoogleBrew).toHaveBeenCalledWith('2', '1', 'share');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('access is denied to a locked brew', async()=>{
|
||||||
|
const lockBrew = { title: 'test brew', shareId: '1', lock: { locked: true, code: 404, shareMessage: 'brew locked' } };
|
||||||
|
model.get = jest.fn(()=>toBrewPromise(lockBrew));
|
||||||
|
api.getId = jest.fn(()=>({ id: '1', googleId: undefined }));
|
||||||
|
|
||||||
|
const fn = api.getBrew('share', false);
|
||||||
|
const req = { brew: {} };
|
||||||
|
const next = jest.fn();
|
||||||
|
|
||||||
|
await expect(fn(req, null, next)).rejects.toEqual({ 'HBErrorCode': '51', 'brewId': '1', 'brewTitle': 'test brew', 'code': 404, 'message': 'brew locked' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('mergeBrewText', ()=>{
|
describe('mergeBrewText', ()=>{
|
||||||
@@ -396,8 +409,8 @@ brew`);
|
|||||||
expect(sent).not.toEqual(googleBrew);
|
expect(sent).not.toEqual(googleBrew);
|
||||||
expect(result.text).toBeUndefined();
|
expect(result.text).toBeUndefined();
|
||||||
expect(result.textBin).toBeUndefined();
|
expect(result.textBin).toBeUndefined();
|
||||||
expect(result.renderer).toBeUndefined();
|
expect(result.renderer).toBe('v3');
|
||||||
expect(result.pageCount).toBeUndefined();
|
expect(result.pageCount).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -528,9 +541,9 @@ brew`);
|
|||||||
description : '',
|
description : '',
|
||||||
editId : expect.any(String),
|
editId : expect.any(String),
|
||||||
gDrive : false,
|
gDrive : false,
|
||||||
pageCount : undefined,
|
pageCount : 1,
|
||||||
published : false,
|
published : false,
|
||||||
renderer : undefined,
|
renderer : 'V3',
|
||||||
lang : 'en',
|
lang : 'en',
|
||||||
shareId : expect.any(String),
|
shareId : expect.any(String),
|
||||||
googleId : expect.any(String),
|
googleId : expect.any(String),
|
||||||
@@ -569,6 +582,121 @@ brew`);
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Theme bundle', ()=>{
|
||||||
|
it('should return Theme Bundle for a User Theme', async ()=>{
|
||||||
|
const brews = {
|
||||||
|
userThemeAID : { title: 'User Theme A', renderer: 'V3', theme: null, shareId: 'userThemeAID', style: 'User Theme A Style' }
|
||||||
|
};
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
|
||||||
|
const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
|
||||||
|
|
||||||
|
await api.getThemeBundle(req, res);
|
||||||
|
|
||||||
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
|
expect(res.send).toHaveBeenCalledWith({
|
||||||
|
styles : ['/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style'],
|
||||||
|
snippets : []
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return Theme Bundle for nested User Themes', async ()=>{
|
||||||
|
const brews = {
|
||||||
|
userThemeAID : { title: 'User Theme A', renderer: 'V3', theme: 'userThemeBID', shareId: 'userThemeAID', style: 'User Theme A Style' },
|
||||||
|
userThemeBID : { title: 'User Theme B', renderer: 'V3', theme: 'userThemeCID', shareId: 'userThemeBID', style: 'User Theme B Style' },
|
||||||
|
userThemeCID : { title: 'User Theme C', renderer: 'V3', theme: null, shareId: 'userThemeCID', style: 'User Theme C Style' }
|
||||||
|
};
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
|
||||||
|
const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
|
||||||
|
|
||||||
|
await api.getThemeBundle(req, res);
|
||||||
|
|
||||||
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
|
expect(res.send).toHaveBeenCalledWith({
|
||||||
|
styles : [
|
||||||
|
'/* From Brew: https://localhost/share/userThemeCID */\n\nUser Theme C Style',
|
||||||
|
'/* From Brew: https://localhost/share/userThemeBID */\n\nUser Theme B Style',
|
||||||
|
'/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style'
|
||||||
|
],
|
||||||
|
snippets : []
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return Theme Bundle for a Static Theme', async ()=>{
|
||||||
|
const req = { params: { renderer: 'V3', id: '5ePHB' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
|
||||||
|
|
||||||
|
await api.getThemeBundle(req, res);
|
||||||
|
|
||||||
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
|
expect(res.send).toHaveBeenCalledWith({
|
||||||
|
styles : [
|
||||||
|
`/* From Theme Blank */\n\n@import url("/themes/V3/Blank/style.css");`,
|
||||||
|
`/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`
|
||||||
|
],
|
||||||
|
snippets : [
|
||||||
|
'V3_Blank',
|
||||||
|
'V3_5ePHB'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return Theme Bundle for nested User and Static Themes together', async ()=>{
|
||||||
|
const brews = {
|
||||||
|
userThemeAID : { title: 'User Theme A', renderer: 'V3', theme: 'userThemeBID', shareId: 'userThemeAID', style: 'User Theme A Style' },
|
||||||
|
userThemeBID : { title: 'User Theme B', renderer: 'V3', theme: 'userThemeCID', shareId: 'userThemeBID', style: 'User Theme B Style' },
|
||||||
|
userThemeCID : { title: 'User Theme C', renderer: 'V3', theme: '5eDMG', shareId: 'userThemeCID', style: 'User Theme C Style' }
|
||||||
|
};
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
|
||||||
|
const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
|
||||||
|
|
||||||
|
await api.getThemeBundle(req, res);
|
||||||
|
|
||||||
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
|
expect(res.send).toHaveBeenCalledWith({
|
||||||
|
styles : [
|
||||||
|
`/* From Theme Blank */\n\n@import url("/themes/V3/Blank/style.css");`,
|
||||||
|
`/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`,
|
||||||
|
`/* From Theme 5eDMG */\n\n@import url("/themes/V3/5eDMG/style.css");`,
|
||||||
|
'/* From Brew: https://localhost/share/userThemeCID */\n\nUser Theme C Style',
|
||||||
|
'/* From Brew: https://localhost/share/userThemeBID */\n\nUser Theme B Style',
|
||||||
|
'/* From Brew: https://localhost/share/userThemeAID */\n\nUser Theme A Style'
|
||||||
|
],
|
||||||
|
snippets : [
|
||||||
|
'V3_Blank',
|
||||||
|
'V3_5ePHB',
|
||||||
|
'V3_5eDMG'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail for an invalid Theme in the chain', async()=>{
|
||||||
|
const brews = {
|
||||||
|
userThemeAID : { title: 'User Theme A', renderer: 'V3', theme: 'missingTheme', shareId: 'userThemeAID', style: 'User Theme A Style' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
model.get = jest.fn((getParams)=>toBrewPromise(brews[getParams.shareId]));
|
||||||
|
const req = { params: { renderer: 'V3', id: 'userThemeAID' }, get: ()=>{ return 'localhost'; }, protocol: 'https' };
|
||||||
|
|
||||||
|
let err;
|
||||||
|
await api.getThemeBundle(req, res)
|
||||||
|
.catch((e)=>err = e);
|
||||||
|
|
||||||
|
expect(err).toEqual({
|
||||||
|
HBErrorCode : '09',
|
||||||
|
accessType : 'share',
|
||||||
|
brewId : 'missingTheme',
|
||||||
|
message : 'Theme Not Found',
|
||||||
|
name : 'ThemeLoad Error',
|
||||||
|
status : 404 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('deleteBrew', ()=>{
|
describe('deleteBrew', ()=>{
|
||||||
it('should handle case where fetching the brew returns an error', async ()=>{
|
it('should handle case where fetching the brew returns an error', async ()=>{
|
||||||
api.getBrew = jest.fn(()=>async ()=>{ throw { message: 'err', HBErrorCode: '02' }; });
|
api.getBrew = jest.fn(()=>async ()=>{ throw { message: 'err', HBErrorCode: '02' }; });
|
||||||
@@ -789,4 +917,66 @@ brew`);
|
|||||||
expect(saved.googleId).toEqual(brew.googleId);
|
expect(saved.googleId).toEqual(brew.googleId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('Get CSS', ()=>{
|
||||||
|
it('should return brew style content as CSS text', async ()=>{
|
||||||
|
const testBrew = { title: 'test brew', text: '```css\n\nI Have a style!\n````\n\n' };
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
api.getId = jest.fn(()=>({ id: '1', googleId: undefined }));
|
||||||
|
model.get = jest.fn(()=>toBrewPromise(testBrew));
|
||||||
|
|
||||||
|
const fn = api.getBrew('share', true);
|
||||||
|
const req = { brew: {} };
|
||||||
|
const next = jest.fn();
|
||||||
|
await fn(req, null, next);
|
||||||
|
await api.getCSS(req, res);
|
||||||
|
|
||||||
|
expect(req.brew).toEqual(testBrew);
|
||||||
|
expect(req.brew).toHaveProperty('style', '\nI Have a style!\n');
|
||||||
|
expect(res.status).toHaveBeenCalledWith(200);
|
||||||
|
expect(res.send).toHaveBeenCalledWith("\nI Have a style!\n");
|
||||||
|
expect(res.set).toHaveBeenCalledWith({
|
||||||
|
'Cache-Control' : 'no-cache',
|
||||||
|
'Content-Type' : 'text/css'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return 404 when brew has no style content', async ()=>{
|
||||||
|
const testBrew = { title: 'test brew', text: 'I don\'t have a style!' };
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
api.getId = jest.fn(()=>({ id: '1', googleId: undefined }));
|
||||||
|
model.get = jest.fn(()=>toBrewPromise(testBrew));
|
||||||
|
|
||||||
|
const fn = api.getBrew('share', true);
|
||||||
|
const req = { brew: {} };
|
||||||
|
const next = jest.fn();
|
||||||
|
await fn(req, null, next);
|
||||||
|
await api.getCSS(req, res);
|
||||||
|
|
||||||
|
expect(req.brew).toEqual(testBrew);
|
||||||
|
expect(req.brew).toHaveProperty('style');
|
||||||
|
expect(res.status).toHaveBeenCalledWith(404);
|
||||||
|
expect(res.send).toHaveBeenCalledWith('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return 404 when brew does not exist', async ()=>{
|
||||||
|
const testBrew = { };
|
||||||
|
|
||||||
|
const toBrewPromise = (brew)=>new Promise((res)=>res({ toObject: ()=>brew }));
|
||||||
|
api.getId = jest.fn(()=>({ id: '1', googleId: undefined }));
|
||||||
|
model.get = jest.fn(()=>toBrewPromise(testBrew));
|
||||||
|
|
||||||
|
const fn = api.getBrew('share', true);
|
||||||
|
const req = { brew: {} };
|
||||||
|
const next = jest.fn();
|
||||||
|
await fn(req, null, next);
|
||||||
|
await api.getCSS(req, res);
|
||||||
|
|
||||||
|
expect(req.brew).toEqual(testBrew);
|
||||||
|
expect(req.brew).toHaveProperty('style');
|
||||||
|
expect(res.status).toHaveBeenCalledWith(404);
|
||||||
|
expect(res.send).toHaveBeenCalledWith('');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ HomebrewSchema.statics.get = async function(query, fields=null){
|
|||||||
return brew;
|
return brew;
|
||||||
};
|
};
|
||||||
|
|
||||||
HomebrewSchema.statics.getByUser = async function(username, allowAccess=false, fields=null){
|
HomebrewSchema.statics.getByUser = async function(username, allowAccess=false, fields=null, filter=null){
|
||||||
const query = { authors: username, published: true };
|
const query = { authors: username, published: true, ...filter };
|
||||||
if(allowAccess){
|
if(allowAccess){
|
||||||
delete query.published;
|
delete query.published;
|
||||||
}
|
}
|
||||||
|
|||||||
102
server/vault.api.js
Normal file
102
server/vault.api.js
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const asyncHandler = require('express-async-handler');
|
||||||
|
const HomebrewModel = require('./homebrew.model.js').model;
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
const titleConditions = (title)=>{
|
||||||
|
if(!title) return {};
|
||||||
|
return {
|
||||||
|
$text : {
|
||||||
|
$search : title,
|
||||||
|
$caseSensitive : false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const authorConditions = (author)=>{
|
||||||
|
if(!author) return {};
|
||||||
|
return { authors: author };
|
||||||
|
};
|
||||||
|
|
||||||
|
const rendererConditions = (legacy, v3)=>{
|
||||||
|
if(legacy === 'true' && v3 !== 'true')
|
||||||
|
return { renderer: 'legacy' };
|
||||||
|
|
||||||
|
if(v3 === 'true' && legacy !== 'true')
|
||||||
|
return { renderer: 'V3' };
|
||||||
|
|
||||||
|
return {}; // If all renderers selected, renderer field not needed in query for speed
|
||||||
|
};
|
||||||
|
|
||||||
|
const findBrews = async (req, res)=>{
|
||||||
|
const title = req.query.title || '';
|
||||||
|
const author = req.query.author || '';
|
||||||
|
const page = Math.max(parseInt(req.query.page) || 1, 1);
|
||||||
|
const count = Math.max(parseInt(req.query.count) || 20, 10);
|
||||||
|
const skip = (page - 1) * count;
|
||||||
|
|
||||||
|
const combinedQuery = {
|
||||||
|
$and : [
|
||||||
|
{ published: true },
|
||||||
|
rendererConditions(req.query.legacy, req.query.v3),
|
||||||
|
titleConditions(title),
|
||||||
|
authorConditions(author)
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const projection = {
|
||||||
|
editId : 0,
|
||||||
|
googleId : 0,
|
||||||
|
text : 0,
|
||||||
|
textBin : 0,
|
||||||
|
version : 0
|
||||||
|
};
|
||||||
|
|
||||||
|
await HomebrewModel.find(combinedQuery, projection)
|
||||||
|
.skip(skip)
|
||||||
|
.limit(count)
|
||||||
|
.maxTimeMS(5000)
|
||||||
|
.exec()
|
||||||
|
.then((brews)=>{
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
|
||||||
|
const processedBrews = brews.map((brew)=>{
|
||||||
|
brew.authors = brew.authors.map((author)=>emailRegex.test(author) ? 'hidden' : author
|
||||||
|
);
|
||||||
|
return brew;
|
||||||
|
});
|
||||||
|
res.json({ brews: processedBrews, page });
|
||||||
|
})
|
||||||
|
.catch((error)=>{
|
||||||
|
throw { ...error, message: 'Error finding brews in Vault search', HBErrorCode: 90 };
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const findTotal = async (req, res)=>{
|
||||||
|
const title = req.query.title || '';
|
||||||
|
const author = req.query.author || '';
|
||||||
|
|
||||||
|
const combinedQuery = {
|
||||||
|
$and : [
|
||||||
|
{ published: true },
|
||||||
|
rendererConditions(req.query.legacy, req.query.v3),
|
||||||
|
titleConditions(title),
|
||||||
|
authorConditions(author)
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
await HomebrewModel.countDocuments(combinedQuery)
|
||||||
|
.then((totalBrews)=>{
|
||||||
|
console.log(`when returning, the total of brews is ${totalBrews} for the query ${JSON.stringify(combinedQuery)}`);
|
||||||
|
res.json({ totalBrews });
|
||||||
|
})
|
||||||
|
.catch((error)=>{
|
||||||
|
throw { ...error, message: 'Error finding brews in Vault search findTotal function', HBErrorCode: 91 };
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
router.get('/api/vault/total', asyncHandler(findTotal));
|
||||||
|
router.get('/api/vault', asyncHandler(findBrews));
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
58
shared/helpers.js
Normal file
58
shared/helpers.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
const _ = require('lodash');
|
||||||
|
const yaml = require('js-yaml');
|
||||||
|
const request = require('../client/homebrew/utils/request-middleware.js');
|
||||||
|
|
||||||
|
const splitTextStyleAndMetadata = (brew)=>{
|
||||||
|
brew.text = brew.text.replaceAll('\r\n', '\n');
|
||||||
|
if(brew.text.startsWith('```metadata')) {
|
||||||
|
const index = brew.text.indexOf('```\n\n');
|
||||||
|
const metadataSection = brew.text.slice(12, index - 1);
|
||||||
|
const metadata = yaml.load(metadataSection);
|
||||||
|
Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
|
||||||
|
brew.text = brew.text.slice(index + 5);
|
||||||
|
}
|
||||||
|
if(brew.text.startsWith('```css')) {
|
||||||
|
const index = brew.text.indexOf('```\n\n');
|
||||||
|
brew.style = brew.text.slice(7, index - 1);
|
||||||
|
brew.text = brew.text.slice(index + 5);
|
||||||
|
}
|
||||||
|
if(brew.text.startsWith('```snippets')) {
|
||||||
|
const index = brew.text.indexOf('```\n\n');
|
||||||
|
brew.snippets = brew.text.slice(11, index - 1);
|
||||||
|
brew.text = brew.text.slice(index + 5);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const printCurrentBrew = ()=>{
|
||||||
|
if(window.typeof !== 'undefined') {
|
||||||
|
window.frames['BrewRenderer'].contentWindow.print();
|
||||||
|
//Force DOM reflow; Print dialog causes a repaint, and @media print CSS somehow makes out-of-view pages disappear
|
||||||
|
const node = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0);
|
||||||
|
node.style.display='none';
|
||||||
|
node.offsetHeight; // accessing this is enough to trigger a reflow
|
||||||
|
node.style.display='';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchThemeBundle = async (obj, renderer, theme)=>{
|
||||||
|
if(!renderer || !theme) return;
|
||||||
|
const res = await request
|
||||||
|
.get(`/api/theme/${renderer}/${theme}`)
|
||||||
|
.catch((err)=>{
|
||||||
|
obj.setState({ error: err });
|
||||||
|
});
|
||||||
|
if(!res) return;
|
||||||
|
|
||||||
|
const themeBundle = res.body;
|
||||||
|
themeBundle.joinedStyles = themeBundle.styles.map((style)=>`<style>${style}</style>`).join('\n\n');
|
||||||
|
obj.setState((prevState)=>({
|
||||||
|
...prevState,
|
||||||
|
themeBundle : themeBundle
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
splitTextStyleAndMetadata,
|
||||||
|
printCurrentBrew,
|
||||||
|
fetchThemeBundle,
|
||||||
|
};
|
||||||
@@ -2,9 +2,8 @@ require('./renderWarnings.less');
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
|
|
||||||
const DISMISS_KEY = 'dismiss_render_warning';
|
import Dialog from '../../../client/components/dialog.jsx';
|
||||||
|
|
||||||
const RenderWarnings = createClass({
|
const RenderWarnings = createClass({
|
||||||
displayName : 'RenderWarnings',
|
displayName : 'RenderWarnings',
|
||||||
@@ -35,9 +34,6 @@ const RenderWarnings = createClass({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
checkWarnings : function(){
|
checkWarnings : function(){
|
||||||
const hideDismiss = localStorage.getItem(DISMISS_KEY);
|
|
||||||
if(hideDismiss) return this.setState({ warnings: {} });
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
warnings : _.reduce(this.warnings, (r, fn, type)=>{
|
warnings : _.reduce(this.warnings, (r, fn, type)=>{
|
||||||
const element = fn();
|
const element = fn();
|
||||||
@@ -46,20 +42,18 @@ const RenderWarnings = createClass({
|
|||||||
}, {})
|
}, {})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dismiss : function(){
|
|
||||||
localStorage.setItem(DISMISS_KEY, true);
|
|
||||||
this.checkWarnings();
|
|
||||||
},
|
|
||||||
render : function(){
|
render : function(){
|
||||||
if(_.isEmpty(this.state.warnings)) return null;
|
if(_.isEmpty(this.state.warnings)) return null;
|
||||||
|
|
||||||
return <div className='renderWarnings'>
|
const DISMISS_KEY = 'dismiss_render_warning';
|
||||||
<i className='fas fa-times dismiss' onClick={this.dismiss}/>
|
const DISMISS_TEXT = <i className='fas fa-times dismiss' />;
|
||||||
|
|
||||||
|
return <Dialog className='renderWarnings' dismissKey={DISMISS_KEY} closeText={DISMISS_TEXT}>
|
||||||
<i className='fas fa-exclamation-triangle ohno' />
|
<i className='fas fa-exclamation-triangle ohno' />
|
||||||
<h3>Render Warnings</h3>
|
<h3>Render Warnings</h3>
|
||||||
<small>If this homebrew is rendering badly if might be because of the following:</small>
|
<small>If this homebrew is rendering badly if might be because of the following:</small>
|
||||||
<ul>{_.values(this.state.warnings)}</ul>
|
<ul>{_.values(this.state.warnings)}</ul>
|
||||||
</div>;
|
</Dialog>;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,34 @@
|
|||||||
.renderWarnings {
|
.renderWarnings {
|
||||||
position : relative;
|
position : relative;
|
||||||
float : right;
|
float : right;
|
||||||
display : inline-block;
|
|
||||||
width : 350px;
|
width : 350px;
|
||||||
padding : 20px;
|
padding : 20px;
|
||||||
padding-bottom : 10px;
|
padding-bottom : 10px;
|
||||||
padding-left : 85px;
|
padding-left : 85px;
|
||||||
margin-bottom : 10px;
|
margin-bottom : 10px;
|
||||||
background-color : @yellow;
|
|
||||||
color : white;
|
color : white;
|
||||||
a{
|
background-color : @yellow;
|
||||||
font-weight : 800;
|
border : none;
|
||||||
}
|
a { font-weight : 800; }
|
||||||
i.ohno {
|
i.ohno {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 24px;
|
top : 24px;
|
||||||
left : 24px;
|
left : 24px;
|
||||||
opacity : 0.8;
|
|
||||||
font-size : 2.5em;
|
font-size : 2.5em;
|
||||||
|
opacity : 0.8;
|
||||||
}
|
}
|
||||||
i.dismiss{
|
button.dismiss {
|
||||||
position : absolute;
|
position : absolute;
|
||||||
top : 10px;
|
top : 10px;
|
||||||
right : 10px;
|
right : 10px;
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
|
background-color : transparent;
|
||||||
opacity : 0.6;
|
opacity : 0.6;
|
||||||
&:hover{
|
&:hover { opacity : 1; }
|
||||||
opacity : 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
small {
|
small {
|
||||||
opacity : 0.7;
|
|
||||||
font-size : 0.6em;
|
font-size : 0.6em;
|
||||||
|
opacity : 0.7;
|
||||||
}
|
}
|
||||||
h3 {
|
h3 {
|
||||||
font-size : 1.1em;
|
font-size : 1.1em;
|
||||||
@@ -45,9 +42,7 @@
|
|||||||
li {
|
li {
|
||||||
font-size : 0.8em;
|
font-size : 0.8em;
|
||||||
line-height : 1.6em;
|
line-height : 1.6em;
|
||||||
em{
|
em { font-weight : 800; }
|
||||||
font-weight : 800;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
84
shared/naturalcrit/codeEditor/autocompleteEmoji.js
Normal file
84
shared/naturalcrit/codeEditor/autocompleteEmoji.js
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
const diceFont = require('../../../themes/fonts/iconFonts/diceFont.js');
|
||||||
|
const elderberryInn = require('../../../themes/fonts/iconFonts/elderberryInn.js');
|
||||||
|
const fontAwesome = require('../../../themes/fonts/iconFonts/fontAwesome.js');
|
||||||
|
const gameIcons = require('../../../themes/fonts/iconFonts/gameIcons.js');
|
||||||
|
|
||||||
|
const emojis = {
|
||||||
|
...diceFont,
|
||||||
|
...elderberryInn,
|
||||||
|
...fontAwesome,
|
||||||
|
...gameIcons
|
||||||
|
};
|
||||||
|
|
||||||
|
const showAutocompleteEmoji = function(CodeMirror, editor) {
|
||||||
|
CodeMirror.commands.autocomplete = function(editor) {
|
||||||
|
editor.showHint({
|
||||||
|
completeSingle : false,
|
||||||
|
hint : function(editor) {
|
||||||
|
const cursor = editor.getCursor();
|
||||||
|
const line = cursor.line;
|
||||||
|
const lineContent = editor.getLine(line);
|
||||||
|
const start = lineContent.lastIndexOf(':', cursor.ch - 1) + 1;
|
||||||
|
const end = cursor.ch;
|
||||||
|
const currentWord = lineContent.slice(start, end);
|
||||||
|
|
||||||
|
|
||||||
|
const list = Object.keys(emojis).filter(function(emoji) {
|
||||||
|
return emoji.toLowerCase().indexOf(currentWord.toLowerCase()) >= 0;
|
||||||
|
}).sort((a, b)=>{
|
||||||
|
const lowerA = a.replace(/\d+/g, function(match) { // Temporarily convert any numbers in emoji string
|
||||||
|
return match.padStart(4, '0'); // to 4-digits, left-padded with 0's, to aid in
|
||||||
|
}).toLowerCase(); // sorting numbers, i.e., "d6, d10, d20", not "d10, d20, d6"
|
||||||
|
const lowerB = b.replace(/\d+/g, function(match) { // Also make lowercase for case-insensitive alpha sorting
|
||||||
|
return match.padStart(4, '0');
|
||||||
|
}).toLowerCase();
|
||||||
|
|
||||||
|
if(lowerA < lowerB)
|
||||||
|
return -1;
|
||||||
|
return 1;
|
||||||
|
}).map(function(emoji) {
|
||||||
|
return {
|
||||||
|
text : `${emoji}:`, // Text to output to editor when option is selected
|
||||||
|
render : function(element, self, data) { // How to display the option in the dropdown
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.innerHTML = `<i class="emojiPreview ${emojis[emoji]}"></i> ${emoji}`;
|
||||||
|
element.appendChild(div);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
list : list.length ? list : [],
|
||||||
|
from : CodeMirror.Pos(line, start),
|
||||||
|
to : CodeMirror.Pos(line, end)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
editor.on('inputRead', function(instance, change) {
|
||||||
|
const cursor = editor.getCursor();
|
||||||
|
const line = editor.getLine(cursor.line);
|
||||||
|
|
||||||
|
// Get the text from the start of the line to the cursor
|
||||||
|
const textToCursor = line.slice(0, cursor.ch);
|
||||||
|
|
||||||
|
// Do not autosuggest emojis in curly span/div/injector properties
|
||||||
|
if(line.includes('{')) {
|
||||||
|
const curlyToCursor = textToCursor.slice(textToCursor.indexOf(`{`));
|
||||||
|
const curlySpanRegex = /{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1$/g;
|
||||||
|
|
||||||
|
if(curlySpanRegex.test(curlyToCursor))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the text ends with ':xyz'
|
||||||
|
if(/:[^\s:]+$/.test(textToCursor)) {
|
||||||
|
CodeMirror.commands.autocomplete(editor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
showAutocompleteEmoji
|
||||||
|
};
|
||||||
@@ -3,11 +3,11 @@ require('./codeEditor.less');
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
|
||||||
const closeTag = require('./close-tag');
|
const closeTag = require('./close-tag');
|
||||||
|
const autoCompleteEmoji = require('./autocompleteEmoji');
|
||||||
|
|
||||||
let CodeMirror;
|
let CodeMirror;
|
||||||
if(typeof navigator !== 'undefined'){
|
if(typeof window !== 'undefined'){
|
||||||
CodeMirror = require('codemirror');
|
CodeMirror = require('codemirror');
|
||||||
|
|
||||||
//Language Modes
|
//Language Modes
|
||||||
@@ -36,9 +36,13 @@ if(typeof navigator !== 'undefined'){
|
|||||||
//XML code folding is a requirement of the auto-closing tag feature and is not enabled
|
//XML code folding is a requirement of the auto-closing tag feature and is not enabled
|
||||||
require('codemirror/addon/fold/xml-fold.js');
|
require('codemirror/addon/fold/xml-fold.js');
|
||||||
require('codemirror/addon/edit/closetag.js');
|
require('codemirror/addon/edit/closetag.js');
|
||||||
|
//Autocompletion
|
||||||
|
require('codemirror/addon/hint/show-hint.js');
|
||||||
|
|
||||||
const foldCode = require('./fold-code');
|
const foldPagesCode = require('./fold-pages');
|
||||||
foldCode.registerHomebreweryHelper(CodeMirror);
|
foldPagesCode.registerHomebreweryHelper(CodeMirror);
|
||||||
|
const foldCSSCode = require('./fold-css');
|
||||||
|
foldCSSCode.registerHomebreweryHelper(CodeMirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeEditor = createClass({
|
const CodeEditor = createClass({
|
||||||
@@ -60,6 +64,8 @@ const CodeEditor = createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editor : React.createRef(null),
|
||||||
|
|
||||||
componentDidMount : function() {
|
componentDidMount : function() {
|
||||||
this.buildEditor();
|
this.buildEditor();
|
||||||
const newDoc = CodeMirror.Doc(this.props.value, this.props.language);
|
const newDoc = CodeMirror.Doc(this.props.value, this.props.language);
|
||||||
@@ -99,7 +105,7 @@ const CodeEditor = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
buildEditor : function() {
|
buildEditor : function() {
|
||||||
this.codeMirror = CodeMirror(this.refs.editor, {
|
this.codeMirror = CodeMirror(this.editor.current, {
|
||||||
lineNumbers : true,
|
lineNumbers : true,
|
||||||
lineWrapping : this.props.wrap,
|
lineWrapping : this.props.wrap,
|
||||||
indentWithTabs : false,
|
indentWithTabs : false,
|
||||||
@@ -112,6 +118,10 @@ const CodeEditor = createClass({
|
|||||||
'Shift-Tab' : this.dedent,
|
'Shift-Tab' : this.dedent,
|
||||||
'Ctrl-B' : this.makeBold,
|
'Ctrl-B' : this.makeBold,
|
||||||
'Cmd-B' : this.makeBold,
|
'Cmd-B' : this.makeBold,
|
||||||
|
'Shift-Ctrl-=' : this.makeSuper,
|
||||||
|
'Shift-Cmd-=' : this.makeSuper,
|
||||||
|
'Ctrl-=' : this.makeSub,
|
||||||
|
'Cmd-=' : this.makeSub,
|
||||||
'Ctrl-I' : this.makeItalic,
|
'Ctrl-I' : this.makeItalic,
|
||||||
'Cmd-I' : this.makeItalic,
|
'Cmd-I' : this.makeItalic,
|
||||||
'Ctrl-U' : this.makeUnderline,
|
'Ctrl-U' : this.makeUnderline,
|
||||||
@@ -173,7 +183,10 @@ const CodeEditor = createClass({
|
|||||||
// return el;
|
// return el;
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add custom behaviors (auto-close curlies and auto-complete emojis)
|
||||||
closeTag.autoCloseCurlyBraces(CodeMirror, this.codeMirror);
|
closeTag.autoCloseCurlyBraces(CodeMirror, this.codeMirror);
|
||||||
|
autoCompleteEmoji.showAutocompleteEmoji(CodeMirror, this.codeMirror);
|
||||||
|
|
||||||
// Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works.
|
// Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works.
|
||||||
this.codeMirror.on('change', (cm)=>{this.props.onChange(cm.getValue());});
|
this.codeMirror.on('change', (cm)=>{this.props.onChange(cm.getValue());});
|
||||||
@@ -219,6 +232,25 @@ const CodeEditor = createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
makeSuper : function() {
|
||||||
|
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '^' && selection.slice(-1) === '^';
|
||||||
|
this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `^${selection}^`, 'around');
|
||||||
|
if(selection.length === 0){
|
||||||
|
const cursor = this.codeMirror.getCursor();
|
||||||
|
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
makeSub : function() {
|
||||||
|
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '^^' && selection.slice(-2) === '^^';
|
||||||
|
this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `^^${selection}^^`, 'around');
|
||||||
|
if(selection.length === 0){
|
||||||
|
const cursor = this.codeMirror.getCursor();
|
||||||
|
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
makeNbsp : function() {
|
makeNbsp : function() {
|
||||||
this.codeMirror.replaceSelection(' ', 'end');
|
this.codeMirror.replaceSelection(' ', 'end');
|
||||||
},
|
},
|
||||||
@@ -381,11 +413,11 @@ const CodeEditor = createClass({
|
|||||||
foldOptions : function(cm){
|
foldOptions : function(cm){
|
||||||
return {
|
return {
|
||||||
scanUp : true,
|
scanUp : true,
|
||||||
rangeFinder : CodeMirror.fold.homebrewery,
|
rangeFinder : this.props.language === 'css' ? CodeMirror.fold.homebrewerycss : CodeMirror.fold.homebrewery,
|
||||||
widget : (from, to)=>{
|
widget : (from, to)=>{
|
||||||
let text = '';
|
let text = '';
|
||||||
let currentLine = from.line;
|
let currentLine = from.line;
|
||||||
const maxLength = 50;
|
let maxLength = 50;
|
||||||
|
|
||||||
let foldPreviewText = '';
|
let foldPreviewText = '';
|
||||||
while (currentLine <= to.line && text.length <= maxLength) {
|
while (currentLine <= to.line && text.length <= maxLength) {
|
||||||
@@ -400,10 +432,15 @@ const CodeEditor = createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
text = foldPreviewText || `Lines ${from.line+1}-${to.line+1}`;
|
text = foldPreviewText || `Lines ${from.line+1}-${to.line+1}`;
|
||||||
|
text = text.replace('{', '').trim();
|
||||||
|
|
||||||
|
// Truncate data URLs at `data:`
|
||||||
|
const startOfData = text.indexOf('data:');
|
||||||
|
if(startOfData > 0)
|
||||||
|
maxLength = Math.min(startOfData + 5, maxLength);
|
||||||
|
|
||||||
text = text.trim();
|
|
||||||
if(text.length > maxLength)
|
if(text.length > maxLength)
|
||||||
text = `${text.substr(0, maxLength)}...`;
|
text = `${text.slice(0, maxLength)}...`;
|
||||||
|
|
||||||
return `\u21A4 ${text} \u21A6`;
|
return `\u21A4 ${text} \u21A6`;
|
||||||
}
|
}
|
||||||
@@ -413,10 +450,11 @@ const CodeEditor = createClass({
|
|||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <>
|
return <>
|
||||||
<link href={`../homebrew/cm-themes/${this.props.editorTheme}.css`} rel='stylesheet' />
|
<link href={`../homebrew/cm-themes/${this.props.editorTheme}.css`} type='text/css' rel='stylesheet' />
|
||||||
<div className='codeEditor' ref='editor' style={this.props.style}/>
|
<div className='codeEditor' ref={this.editor} style={this.props.style}/>
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = CodeEditor;
|
module.exports = CodeEditor;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
@import (less) 'codemirror/addon/fold/foldgutter.css';
|
@import (less) 'codemirror/addon/fold/foldgutter.css';
|
||||||
@import (less) 'codemirror/addon/search/matchesonscrollbar.css';
|
@import (less) 'codemirror/addon/search/matchesonscrollbar.css';
|
||||||
@import (less) 'codemirror/addon/dialog/dialog.css';
|
@import (less) 'codemirror/addon/dialog/dialog.css';
|
||||||
|
@import (less) 'codemirror/addon/hint/show-hint.css';
|
||||||
|
|
||||||
|
//Icon fonts included so they can appear in emoji autosuggest dropdown
|
||||||
|
@import (less) './themes/fonts/iconFonts/diceFont.less';
|
||||||
|
@import (less) './themes/fonts/iconFonts/elderberryInn.less';
|
||||||
|
@import (less) './themes/fonts/iconFonts/gameIcons.less';
|
||||||
|
@import (less) './themes/fonts/iconFonts/fontAwesome.less';
|
||||||
|
|
||||||
@keyframes sourceMoveAnimation {
|
@keyframes sourceMoveAnimation {
|
||||||
50% {background-color: red; color: white;}
|
50% {background-color: red; color: white;}
|
||||||
@@ -24,6 +31,17 @@
|
|||||||
animation-duration: 0.4s;
|
animation-duration: 0.4s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.CodeMirror-vscrollbar {
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
width: 20px;
|
||||||
|
background: linear-gradient(90deg, #858585 15px, #808080 15px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//.cm-tab {
|
//.cm-tab {
|
||||||
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right;
|
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right;
|
||||||
//}
|
//}
|
||||||
@@ -34,3 +52,8 @@
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.emojiPreview {
|
||||||
|
font-size: 1.5em;
|
||||||
|
line-height: 1.2em;
|
||||||
|
}
|
||||||
44
shared/naturalcrit/codeEditor/fold-css.js
Normal file
44
shared/naturalcrit/codeEditor/fold-css.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
module.exports = {
|
||||||
|
registerHomebreweryHelper : function(CodeMirror) {
|
||||||
|
CodeMirror.registerHelper('fold', 'homebrewerycss', function(cm, start) {
|
||||||
|
|
||||||
|
// BRACE FOLDING
|
||||||
|
const startMatcher = /\{[ \t]*$/;
|
||||||
|
const endMatcher = /\}[ \t]*$/;
|
||||||
|
const activeLine = cm.getLine(start.line);
|
||||||
|
|
||||||
|
|
||||||
|
if(activeLine.match(startMatcher)) {
|
||||||
|
const lastLineNo = cm.lastLine();
|
||||||
|
let end = start.line + 1;
|
||||||
|
let braceCount = 1;
|
||||||
|
|
||||||
|
while (end < lastLineNo) {
|
||||||
|
const curLine = cm.getLine(end);
|
||||||
|
if(curLine.match(startMatcher)) braceCount++;
|
||||||
|
if(curLine.match(endMatcher)) braceCount--;
|
||||||
|
if(braceCount == 0) break;
|
||||||
|
++end;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
from : CodeMirror.Pos(start.line, 0),
|
||||||
|
to : CodeMirror.Pos(end, cm.getLine(end).length)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// @import and data-url folding
|
||||||
|
const importMatcher = /^@import.*?;/;
|
||||||
|
const dataURLMatcher = /url\(.*?data\:.*\)/;
|
||||||
|
|
||||||
|
if(activeLine.match(importMatcher) || activeLine.match(dataURLMatcher)) {
|
||||||
|
return {
|
||||||
|
from : CodeMirror.Pos(start.line, 0),
|
||||||
|
to : CodeMirror.Pos(start.line, activeLine.length)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,8 +3,60 @@ const _ = require('lodash');
|
|||||||
const Marked = require('marked');
|
const Marked = require('marked');
|
||||||
const MarkedExtendedTables = require('marked-extended-tables');
|
const MarkedExtendedTables = require('marked-extended-tables');
|
||||||
const { markedSmartypantsLite: MarkedSmartypantsLite } = require('marked-smartypants-lite');
|
const { markedSmartypantsLite: MarkedSmartypantsLite } = require('marked-smartypants-lite');
|
||||||
const { gfmHeadingId: MarkedGFMHeadingId } = require('marked-gfm-heading-id');
|
const { gfmHeadingId: MarkedGFMHeadingId, resetHeadings: MarkedGFMResetHeadingIDs } = require('marked-gfm-heading-id');
|
||||||
|
const { markedEmoji: MarkedEmojis } = require('marked-emoji');
|
||||||
|
|
||||||
|
//Icon fonts included so they can appear in emoji autosuggest dropdown
|
||||||
|
const diceFont = require('../../themes/fonts/iconFonts/diceFont.js');
|
||||||
|
const elderberryInn = require('../../themes/fonts/iconFonts/elderberryInn.js');
|
||||||
|
const fontAwesome = require('../../themes/fonts/iconFonts/fontAwesome.js');
|
||||||
|
const gameIcons = require('../../themes/fonts/iconFonts/gameIcons.js');
|
||||||
|
|
||||||
|
const MathParser = require('expr-eval').Parser;
|
||||||
const renderer = new Marked.Renderer();
|
const renderer = new Marked.Renderer();
|
||||||
|
const tokenizer = new Marked.Tokenizer();
|
||||||
|
|
||||||
|
//Limit math features to simple items
|
||||||
|
const mathParser = new MathParser({
|
||||||
|
operators : {
|
||||||
|
// These default to true, but are included to be explicit
|
||||||
|
add : true,
|
||||||
|
subtract : true,
|
||||||
|
multiply : true,
|
||||||
|
divide : true,
|
||||||
|
power : true,
|
||||||
|
round : true,
|
||||||
|
floor : true,
|
||||||
|
ceil : true,
|
||||||
|
abs : true,
|
||||||
|
|
||||||
|
sin : false, cos : false, tan : false, asin : false, acos : false,
|
||||||
|
atan : false, sinh : false, cosh : false, tanh : false, asinh : false,
|
||||||
|
acosh : false, atanh : false, sqrt : false, cbrt : false, log : false,
|
||||||
|
log2 : false, ln : false, lg : false, log10 : false, expm1 : false,
|
||||||
|
log1p : false, trunc : false, join : false, sum : false, indexOf : false,
|
||||||
|
'-' : false, '+' : false, exp : false, not : false, length : false,
|
||||||
|
'!' : false, sign : false, random : false, fac : false, min : false,
|
||||||
|
max : false, hypot : false, pyt : false, pow : false, atan2 : false,
|
||||||
|
'if' : false, gamma : false, roundTo : false, map : false, fold : false,
|
||||||
|
filter : false,
|
||||||
|
|
||||||
|
remainder : false, factorial : false,
|
||||||
|
comparison : false, concatenate : false,
|
||||||
|
logical : false, assignment : false,
|
||||||
|
array : false, fndef : false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Add sign function
|
||||||
|
mathParser.functions.sign = function (a) {
|
||||||
|
if(a >= 0) return '+';
|
||||||
|
return '-';
|
||||||
|
};
|
||||||
|
// Add signed function
|
||||||
|
mathParser.functions.signed = function (a) {
|
||||||
|
if(a >= 0) return `+${a}`;
|
||||||
|
return `${a}`;
|
||||||
|
};
|
||||||
|
|
||||||
//Processes the markdown within an HTML block if it's just a class-wrapper
|
//Processes the markdown within an HTML block if it's just a class-wrapper
|
||||||
renderer.html = function (html) {
|
renderer.html = function (html) {
|
||||||
@@ -17,7 +69,7 @@ renderer.html = function (html) {
|
|||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't wrap {{ Divs or {{ empty Spans in <p> tags
|
// Don't wrap {{ Spans alone on a line, or {{ Divs in <p> tags
|
||||||
renderer.paragraph = function(text){
|
renderer.paragraph = function(text){
|
||||||
let match;
|
let match;
|
||||||
if(text.startsWith('<div') || text.startsWith('</div'))
|
if(text.startsWith('<div') || text.startsWith('</div'))
|
||||||
@@ -28,24 +80,65 @@ renderer.paragraph = function(text){
|
|||||||
return `<p>${text}</p>\n`;
|
return `<p>${text}</p>\n`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Fix local links in the Preview iFrame to link inside the frame
|
||||||
|
renderer.link = function (href, title, text) {
|
||||||
|
let self = false;
|
||||||
|
if(href[0] == '#') {
|
||||||
|
self = true;
|
||||||
|
}
|
||||||
|
href = cleanUrl(href);
|
||||||
|
|
||||||
|
if(href === null) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
let out = `<a href="${escape(href)}"`;
|
||||||
|
if(title) {
|
||||||
|
out += ` title="${title}"`;
|
||||||
|
}
|
||||||
|
if(self) {
|
||||||
|
out += ' target="_self"';
|
||||||
|
}
|
||||||
|
out += `>${text}</a>`;
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Expose `src` attribute as `--HB_src` to make the URL accessible via CSS
|
||||||
|
renderer.image = function (href, title, text) {
|
||||||
|
href = cleanUrl(href);
|
||||||
|
if (href === null)
|
||||||
|
return text;
|
||||||
|
|
||||||
|
let out = `<img src="${href}" alt="${text}" style="--HB_src:url(${href});"`;
|
||||||
|
if (title)
|
||||||
|
out += ` title="${title}"`;
|
||||||
|
|
||||||
|
out += '>';
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable default reflink behavior, as it steps on our variables extension
|
||||||
|
tokenizer.def = function () {
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
const mustacheSpans = {
|
const mustacheSpans = {
|
||||||
name : 'mustacheSpans',
|
name : 'mustacheSpans',
|
||||||
level : 'inline', // Is this a block-level or inline-level tokenizer?
|
level : 'inline', // Is this a block-level or inline-level tokenizer?
|
||||||
start(src) { return src.match(/{{[^{]/)?.index; }, // Hint to Marked.js to stop and check for a match
|
start(src) { return src.match(/{{[^{]/)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const completeSpan = /^{{[^\n]*}}/; // Regex for the complete token
|
const completeSpan = /^{{[^\n]*}}/; // Regex for the complete token
|
||||||
const inlineRegex = /{{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1 *|}}/g;
|
const inlineRegex = /{{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *|}}/g;
|
||||||
const match = completeSpan.exec(src);
|
const match = completeSpan.exec(src);
|
||||||
if(match) {
|
if(match) {
|
||||||
//Find closing delimiter
|
//Find closing delimiter
|
||||||
let blockCount = 0;
|
let blockCount = 0;
|
||||||
let tags = '';
|
let tags = {};
|
||||||
let endTags = 0;
|
let endTags = 0;
|
||||||
let endToken = 0;
|
let endToken = 0;
|
||||||
let delim;
|
let delim;
|
||||||
while (delim = inlineRegex.exec(match[0])) {
|
while (delim = inlineRegex.exec(match[0])) {
|
||||||
if(!tags) {
|
if(_.isEmpty(tags)) {
|
||||||
tags = ` ${processStyleTags(delim[0].substring(2))}`;
|
tags = processStyleTags(delim[0].substring(2));
|
||||||
endTags = delim[0].length;
|
endTags = delim[0].length;
|
||||||
}
|
}
|
||||||
if(delim[0].startsWith('{{')) {
|
if(delim[0].startsWith('{{')) {
|
||||||
@@ -74,7 +167,14 @@ const mustacheSpans = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<span class="inline-block${token.tags}>${this.parser.parseInline(token.tokens)}</span>`; // parseInline to turn child tokens into HTML
|
const tags = token.tags;
|
||||||
|
tags.classes = ['inline-block', tags.classes].join(' ').trim();
|
||||||
|
return `<span` +
|
||||||
|
`${tags.classes ? ` class="${tags.classes}"` : ''}` +
|
||||||
|
`${tags.id ? ` id="${tags.id}"` : ''}` +
|
||||||
|
`${tags.styles ? ` style="${tags.styles}"` : ''}` +
|
||||||
|
`${tags.attributes ? ` ${Object.entries(tags.attributes).map(([key, value])=>`${key}="${value}"`).join(' ')}` : ''}` +
|
||||||
|
`>${this.parser.parseInline(token.tokens)}</span>`; // parseInline to turn child tokens into HTML
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,19 +184,19 @@ const mustacheDivs = {
|
|||||||
start(src) { return src.match(/\n *{{[^{]/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
start(src) { return src.match(/\n *{{[^{]/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const completeBlock = /^ *{{[^\n}]* *\n.*\n *}}/s; // Regex for the complete token
|
const completeBlock = /^ *{{[^\n}]* *\n.*\n *}}/s; // Regex for the complete token
|
||||||
const blockRegex = /^ *{{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1 *$|^ *}}$/gm;
|
const blockRegex = /^ *{{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *$|^ *}}$/gm;
|
||||||
const match = completeBlock.exec(src);
|
const match = completeBlock.exec(src);
|
||||||
if(match) {
|
if(match) {
|
||||||
//Find closing delimiter
|
//Find closing delimiter
|
||||||
let blockCount = 0;
|
let blockCount = 0;
|
||||||
let tags = '';
|
let tags = {};
|
||||||
let endTags = 0;
|
let endTags = 0;
|
||||||
let endToken = 0;
|
let endToken = 0;
|
||||||
let delim;
|
let delim;
|
||||||
while (delim = blockRegex.exec(match[0])?.[0].trim()) {
|
while (delim = blockRegex.exec(match[0])?.[0].trim()) {
|
||||||
if(!tags) {
|
if(_.isEmpty(tags)) {
|
||||||
tags = ` ${processStyleTags(delim.substring(2))}`;
|
tags = processStyleTags(delim.substring(2));
|
||||||
endTags = delim.length;
|
endTags = delim.length + src.indexOf(delim);
|
||||||
}
|
}
|
||||||
if(delim.startsWith('{{')) {
|
if(delim.startsWith('{{')) {
|
||||||
blockCount++;
|
blockCount++;
|
||||||
@@ -123,7 +223,14 @@ const mustacheDivs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
return `<div class="block${token.tags}>${this.parser.parse(token.tokens)}</div>`; // parseInline to turn child tokens into HTML
|
const tags = token.tags;
|
||||||
|
tags.classes = ['block', tags.classes].join(' ').trim();
|
||||||
|
return `<div` +
|
||||||
|
`${tags.classes ? ` class="${tags.classes}"` : ''}` +
|
||||||
|
`${tags.id ? ` id="${tags.id}"` : ''}` +
|
||||||
|
`${tags.styles ? ` style="${tags.styles}"` : ''}` +
|
||||||
|
`${tags.attributes ? ` ${Object.entries(tags.attributes).map(([key, value])=>`${key}="${value}"`).join(' ')}` : ''}` +
|
||||||
|
`>${this.parser.parse(token.tokens)}</div>`; // parse to turn child tokens into HTML
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -132,30 +239,46 @@ const mustacheInjectInline = {
|
|||||||
level : 'inline',
|
level : 'inline',
|
||||||
start(src) { return src.match(/ *{[^{\n]/)?.index; }, // Hint to Marked.js to stop and check for a match
|
start(src) { return src.match(/ *{[^{\n]/)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const inlineRegex = /^ *{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1}/g;
|
const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/g;
|
||||||
const match = inlineRegex.exec(src);
|
const match = inlineRegex.exec(src);
|
||||||
if(match) {
|
if(match) {
|
||||||
const lastToken = tokens[tokens.length - 1];
|
const lastToken = tokens[tokens.length - 1];
|
||||||
if(!lastToken || lastToken.type == 'mustacheInjectInline')
|
if(!lastToken || lastToken.type == 'mustacheInjectInline')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const tags = ` ${processStyleTags(match[1])}`;
|
const tags = processStyleTags(match[1]);
|
||||||
lastToken.originalType = lastToken.type;
|
lastToken.originalType = lastToken.type;
|
||||||
lastToken.type = 'mustacheInjectInline';
|
lastToken.type = 'mustacheInjectInline';
|
||||||
lastToken.tags = tags;
|
lastToken.injectedTags = tags;
|
||||||
return {
|
return {
|
||||||
type : 'text', // Should match "name" above
|
type : 'mustacheInjectInline', // Should match "name" above
|
||||||
raw : match[0], // Text to consume from the source
|
raw : match[0], // Text to consume from the source
|
||||||
text : ''
|
text : ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
|
if(!token.originalType){
|
||||||
|
return;
|
||||||
|
}
|
||||||
token.type = token.originalType;
|
token.type = token.originalType;
|
||||||
const text = this.parser.parseInline([token]);
|
const text = this.parser.parseInline([token]);
|
||||||
const openingTag = /(<[^\s<>]+)([^\n<>]*>.*)/s.exec(text);
|
const originalTags = extractHTMLStyleTags(text);
|
||||||
|
const injectedTags = token.injectedTags;
|
||||||
|
const tags = {
|
||||||
|
id : injectedTags.id || originalTags.id || null,
|
||||||
|
classes : [originalTags.classes, injectedTags.classes].join(' ').trim() || null,
|
||||||
|
styles : [originalTags.styles, injectedTags.styles].join(' ').trim() || null,
|
||||||
|
attributes : Object.assign(originalTags.attributes ?? {}, injectedTags.attributes ?? {})
|
||||||
|
};
|
||||||
|
const openingTag = /(<[^\s<>]+)[^\n<>]*(>.*)/s.exec(text);
|
||||||
if(openingTag) {
|
if(openingTag) {
|
||||||
return `${openingTag[1]} class="${token.tags}${openingTag[2]}`;
|
return `${openingTag[1]}` +
|
||||||
|
`${tags.classes ? ` class="${tags.classes}"` : ''}` +
|
||||||
|
`${tags.id ? ` id="${tags.id}"` : ''}` +
|
||||||
|
`${tags.styles ? ` style="${tags.styles}"` : ''}` +
|
||||||
|
`${!_.isEmpty(tags.attributes) ? ` ${Object.entries(tags.attributes).map(([key, value])=>`${key}="${value}"`).join(' ')}` : ''}` +
|
||||||
|
`${openingTag[2]}`; // parse to turn child tokens into HTML
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
@@ -167,7 +290,7 @@ const mustacheInjectBlock = {
|
|||||||
level : 'block',
|
level : 'block',
|
||||||
start(src) { return src.match(/\n *{[^{\n]/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
start(src) { return src.match(/\n *{[^{\n]/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const inlineRegex = /^ *{(?=((?::(?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':{}\s]*)*))\1}/ym;
|
const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/ym;
|
||||||
const match = inlineRegex.exec(src);
|
const match = inlineRegex.exec(src);
|
||||||
if(match) {
|
if(match) {
|
||||||
const lastToken = tokens[tokens.length - 1];
|
const lastToken = tokens[tokens.length - 1];
|
||||||
@@ -175,7 +298,7 @@ const mustacheInjectBlock = {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
lastToken.originalType = 'mustacheInjectBlock';
|
lastToken.originalType = 'mustacheInjectBlock';
|
||||||
lastToken.tags = ` ${processStyleTags(match[1])}`;
|
lastToken.injectedTags = processStyleTags(match[1]);
|
||||||
return {
|
return {
|
||||||
type : 'mustacheInjectBlock', // Should match "name" above
|
type : 'mustacheInjectBlock', // Should match "name" above
|
||||||
raw : match[0], // Text to consume from the source
|
raw : match[0], // Text to consume from the source
|
||||||
@@ -189,9 +312,22 @@ const mustacheInjectBlock = {
|
|||||||
}
|
}
|
||||||
token.type = token.originalType;
|
token.type = token.originalType;
|
||||||
const text = this.parser.parse([token]);
|
const text = this.parser.parse([token]);
|
||||||
const openingTag = /(<[^\s<>]+)([^\n<>]*>.*)/s.exec(text);
|
const originalTags = extractHTMLStyleTags(text);
|
||||||
|
const injectedTags = token.injectedTags;
|
||||||
|
const tags = {
|
||||||
|
id : injectedTags.id || originalTags.id || null,
|
||||||
|
classes : [originalTags.classes, injectedTags.classes].join(' ').trim() || null,
|
||||||
|
styles : [originalTags.styles, injectedTags.styles].join(' ').trim() || null,
|
||||||
|
attributes : Object.assign(originalTags.attributes ?? {}, injectedTags.attributes ?? {})
|
||||||
|
};
|
||||||
|
const openingTag = /(<[^\s<>]+)[^\n<>]*(>.*)/s.exec(text);
|
||||||
if(openingTag) {
|
if(openingTag) {
|
||||||
return `${openingTag[1]} class="${token.tags}${openingTag[2]}`;
|
return `${openingTag[1]}` +
|
||||||
|
`${tags.classes ? ` class="${tags.classes}"` : ''}` +
|
||||||
|
`${tags.id ? ` id="${tags.id}"` : ''}` +
|
||||||
|
`${tags.styles ? ` style="${tags.styles}"` : ''}` +
|
||||||
|
`${!_.isEmpty(tags.attributes) ? ` ${Object.entries(tags.attributes).map(([key, value])=>`${key}="${value}"`).join(' ')}` : ''}` +
|
||||||
|
`${openingTag[2]}`; // parse to turn child tokens into HTML
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
@@ -206,25 +342,83 @@ const mustacheInjectBlock = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const definitionLists = {
|
const superSubScripts = {
|
||||||
name : 'definitionLists',
|
name : 'superSubScript',
|
||||||
|
level : 'inline',
|
||||||
|
start(src) { return src.match(/\^/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
|
tokenizer(src, tokens) {
|
||||||
|
const superRegex = /^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/m;
|
||||||
|
const subRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m;
|
||||||
|
let isSuper = false;
|
||||||
|
let match = subRegex.exec(src);
|
||||||
|
if(!match){
|
||||||
|
match = superRegex.exec(src);
|
||||||
|
if(match)
|
||||||
|
isSuper = true;
|
||||||
|
}
|
||||||
|
if(match?.length) {
|
||||||
|
return {
|
||||||
|
type : 'superSubScript', // Should match "name" above
|
||||||
|
raw : match[0], // Text to consume from the source
|
||||||
|
tag : isSuper ? 'sup' : 'sub',
|
||||||
|
tokens : this.lexer.inlineTokens(match[1])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
renderer(token) {
|
||||||
|
return `<${token.tag}>${this.parser.parseInline(token.tokens)}</${token.tag}>`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const forcedParagraphBreaks = {
|
||||||
|
name : 'hardBreaks',
|
||||||
level : 'block',
|
level : 'block',
|
||||||
start(src) { return src.match(/^.*?::.*/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
start(src) { return src.match(/\n:+$/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
|
tokenizer(src, tokens) {
|
||||||
|
const regex = /^(:+)(?:\n|$)/ym;
|
||||||
|
const match = regex.exec(src);
|
||||||
|
if(match?.length) {
|
||||||
|
return {
|
||||||
|
type : 'hardBreaks', // Should match "name" above
|
||||||
|
raw : match[0], // Text to consume from the source
|
||||||
|
length : match[1].length,
|
||||||
|
text : ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
renderer(token) {
|
||||||
|
return `<div class='blank'></div>`.repeat(token.length).concat('\n');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const definitionListsSingleLine = {
|
||||||
|
name : 'definitionListsSingleLine',
|
||||||
|
level : 'block',
|
||||||
|
start(src) { return src.match(/\n[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym;
|
const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym;
|
||||||
let match;
|
let match;
|
||||||
let endIndex = 0;
|
let endIndex = 0;
|
||||||
const definitions = [];
|
const definitions = [];
|
||||||
while (match = regex.exec(src)) {
|
while (match = regex.exec(src)) {
|
||||||
|
const originalLine = match[0]; // This line and below to handle conflict with emojis
|
||||||
|
let firstLine = originalLine; // Remove in V4 when definitionListsInline updated to
|
||||||
|
this.lexer.inlineTokens(firstLine.trim()) // require spaces around `::`
|
||||||
|
.filter((t)=>t.type == 'emoji')
|
||||||
|
.map((emoji)=>firstLine = firstLine.replace(emoji.raw, 'x'.repeat(emoji.raw.length)));
|
||||||
|
|
||||||
|
const newMatch = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym.exec(firstLine);
|
||||||
|
if(newMatch) {
|
||||||
definitions.push({
|
definitions.push({
|
||||||
dt : this.lexer.inlineTokens(match[1].trim()),
|
dt : this.lexer.inlineTokens(originalLine.slice(0, newMatch[1].length).trim()),
|
||||||
dd : this.lexer.inlineTokens(match[2].trim())
|
dd : this.lexer.inlineTokens(originalLine.slice(newMatch[1].length + 2).trim())
|
||||||
});
|
});
|
||||||
|
} // End of emoji hack.
|
||||||
endIndex = regex.lastIndex;
|
endIndex = regex.lastIndex;
|
||||||
}
|
}
|
||||||
if(definitions.length) {
|
if(definitions.length) {
|
||||||
return {
|
return {
|
||||||
type : 'definitionLists',
|
type : 'definitionListsSingleLine',
|
||||||
raw : src.slice(0, endIndex),
|
raw : src.slice(0, endIndex),
|
||||||
definitions
|
definitions
|
||||||
};
|
};
|
||||||
@@ -238,55 +432,336 @@ const definitionLists = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists] });
|
const definitionListsMultiLine = {
|
||||||
Marked.use(mustacheInjectBlock);
|
name : 'definitionListsMultiLine',
|
||||||
Marked.use({ renderer: renderer, mangle: false });
|
level : 'block',
|
||||||
Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite());
|
start(src) { return src.match(/\n[^\n]*\n::[^:\n]/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
|
tokenizer(src, tokens) {
|
||||||
//Fix local links in the Preview iFrame to link inside the frame
|
const regex = /(\n?\n?(?!::)[^\n]+?(?=\n::[^:\n]))|\n::([^:\n](?:.|\n)*?(?=(?:\n::)|(?:\n\n)|$))/y;
|
||||||
renderer.link = function (href, title, text) {
|
let match;
|
||||||
let self = false;
|
let endIndex = 0;
|
||||||
if(href[0] == '#') {
|
const definitions = [];
|
||||||
self = true;
|
while (match = regex.exec(src)) {
|
||||||
|
if(match[1]) {
|
||||||
|
if(this.lexer.blockTokens(match[1].trim())[0]?.type !== 'paragraph') // DT must not be another block-level token besides <p>
|
||||||
|
break;
|
||||||
|
definitions.push({
|
||||||
|
dt : this.lexer.inlineTokens(match[1].trim()),
|
||||||
|
dds : []
|
||||||
|
});
|
||||||
}
|
}
|
||||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
if(match[2] && definitions.length) {
|
||||||
|
definitions[definitions.length - 1].dds.push(
|
||||||
if(href === null) {
|
this.lexer.inlineTokens(match[2].trim().replace(/\s/g, ' '))
|
||||||
return text;
|
);
|
||||||
}
|
}
|
||||||
let out = `<a href="${escape(href)}"`;
|
endIndex = regex.lastIndex;
|
||||||
if(title) {
|
|
||||||
out += ` title="${title}"`;
|
|
||||||
}
|
}
|
||||||
if(self) {
|
if(definitions.length) {
|
||||||
out += ' target="_self"';
|
return {
|
||||||
|
type : 'definitionListsMultiLine',
|
||||||
|
raw : src.slice(0, endIndex),
|
||||||
|
definitions
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
renderer(token) {
|
||||||
|
let returnVal = `<dl>`;
|
||||||
|
token.definitions.forEach((def)=>{
|
||||||
|
const dds = def.dds.map((s)=>{
|
||||||
|
return `\n<dd>${this.parser.parseInline(s).trim()}</dd>`;
|
||||||
|
}).join('');
|
||||||
|
returnVal += `<dt>${this.parser.parseInline(def.dt)}</dt>${dds}\n`;
|
||||||
|
});
|
||||||
|
returnVal = returnVal.trim();
|
||||||
|
return `${returnVal}</dl>`;
|
||||||
}
|
}
|
||||||
out += `>${text}</a>`;
|
|
||||||
return out;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const nonWordAndColonTest = /[^\w:]/g;
|
//v=====--------------------< Variable Handling >-------------------=====v// 242 lines
|
||||||
const cleanUrl = function (sanitize, base, href) {
|
const replaceVar = function(input, hoist=false, allowUnresolved=false) {
|
||||||
if(sanitize) {
|
const regex = /([!$]?)\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]/g;
|
||||||
let prot;
|
const match = regex.exec(input);
|
||||||
|
|
||||||
|
const prefix = match[1];
|
||||||
|
const label = match[2];
|
||||||
|
|
||||||
|
//v=====--------------------< HANDLE MATH >-------------------=====v//
|
||||||
|
const mathRegex = /[a-z]+\(|[+\-*/^(),]/g;
|
||||||
|
const matches = label.split(mathRegex);
|
||||||
|
const mathVars = matches.filter((match)=>isNaN(match))?.map((s)=>s.trim()); // Capture any variable names
|
||||||
|
|
||||||
|
let replacedLabel = label;
|
||||||
|
|
||||||
|
if(prefix[0] == '$' && mathVars?.[0] !== label.trim()) {// If there was mathy stuff not captured, let's do math!
|
||||||
|
mathVars?.forEach((variable)=>{
|
||||||
|
const foundVar = lookupVar(variable, globalPageNumber, hoist);
|
||||||
|
if(foundVar && foundVar.resolved && foundVar.content && !isNaN(foundVar.content)) // Only subsitute math values if fully resolved, not empty strings, and numbers
|
||||||
|
replacedLabel = replacedLabel.replaceAll(new RegExp(`(?<!\\w)(${variable})(?!\\w)`, 'g'), foundVar.content);
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prot = decodeURIComponent(unescape(href))
|
return mathParser.evaluate(replacedLabel);
|
||||||
.replace(nonWordAndColonTest, '')
|
} catch (error) {
|
||||||
.toLowerCase();
|
return undefined; // Return undefined if invalid math result
|
||||||
} catch (e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if(prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//^=====--------------------< HANDLE MATH >-------------------=====^//
|
||||||
|
|
||||||
|
const foundVar = lookupVar(label, globalPageNumber, hoist);
|
||||||
|
|
||||||
|
if(!foundVar || (!foundVar.resolved && !allowUnresolved))
|
||||||
|
return undefined; // Return undefined if not found, or parially-resolved vars are not allowed
|
||||||
|
|
||||||
|
// url or <url> "title" or 'title' or (title)
|
||||||
|
const linkRegex = /^([^<\s][^\s]*|<.*?>)(?: ("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\((?:\\\(|\\\)|[^()])*\)))?$/m;
|
||||||
|
const linkMatch = linkRegex.exec(foundVar.content);
|
||||||
|
|
||||||
|
const href = linkMatch ? linkMatch[1] : null; //TODO: TRIM OFF < > IF PRESENT
|
||||||
|
const title = linkMatch ? linkMatch[2]?.slice(1, -1) : null;
|
||||||
|
|
||||||
|
if(!prefix[0] && href) // Link
|
||||||
|
return `[${label}](${href}${title ? ` "${title}"` : ''})`;
|
||||||
|
|
||||||
|
if(prefix[0] == '!' && href) // Image
|
||||||
|
return ``;
|
||||||
|
|
||||||
|
if(prefix[0] == '$') // Variable
|
||||||
|
return foundVar.content;
|
||||||
|
};
|
||||||
|
|
||||||
|
const lookupVar = function(label, index, hoist=false) {
|
||||||
|
while (index >= 0) {
|
||||||
|
if(globalVarsList[index]?.[label] !== undefined)
|
||||||
|
return globalVarsList[index][label];
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hoist) { //If normal lookup failed, attempt hoisting
|
||||||
|
index = Object.keys(globalVarsList).length; // Move index to start from last page
|
||||||
|
while (index >= 0) {
|
||||||
|
if(globalVarsList[index]?.[label] !== undefined)
|
||||||
|
return globalVarsList[index][label];
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
const processVariableQueue = function() {
|
||||||
|
let resolvedOne = true;
|
||||||
|
let finalLoop = false;
|
||||||
|
while (resolvedOne || finalLoop) { // Loop through queue until no more variable calls can be resolved
|
||||||
|
resolvedOne = false;
|
||||||
|
for (const item of varsQueue) {
|
||||||
|
if(item.type == 'text')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(item.type == 'varDefBlock') {
|
||||||
|
const regex = /[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]/g;
|
||||||
|
let match;
|
||||||
|
let resolved = true;
|
||||||
|
let tempContent = item.content;
|
||||||
|
while (match = regex.exec(item.content)) { // regex to find variable calls
|
||||||
|
const value = replaceVar(match[0], true);
|
||||||
|
|
||||||
|
if(value == undefined)
|
||||||
|
resolved = false;
|
||||||
|
else
|
||||||
|
tempContent = tempContent.replaceAll(match[0], value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(resolved == true || item.content != tempContent) {
|
||||||
|
resolvedOne = true;
|
||||||
|
item.content = tempContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
globalVarsList[globalPageNumber][item.varName] = {
|
||||||
|
content : item.content,
|
||||||
|
resolved : resolved
|
||||||
|
};
|
||||||
|
|
||||||
|
if(resolved)
|
||||||
|
item.type = 'resolved';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.type == 'varCallBlock' || item.type == 'varCallInline') {
|
||||||
|
const value = replaceVar(item.content, true, finalLoop); // final loop will just use the best value so far
|
||||||
|
|
||||||
|
if(value == undefined)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
resolvedOne = true;
|
||||||
|
item.content = value;
|
||||||
|
item.type = 'text';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
varsQueue = varsQueue.filter((item)=>item.type !== 'resolved'); // Remove any fully-resolved variable definitions
|
||||||
|
|
||||||
|
if(finalLoop)
|
||||||
|
break;
|
||||||
|
if(!resolvedOne)
|
||||||
|
finalLoop = true;
|
||||||
|
}
|
||||||
|
varsQueue = varsQueue.filter((item)=>item.type !== 'varDefBlock');
|
||||||
|
};
|
||||||
|
|
||||||
|
function MarkedVariables() {
|
||||||
|
return {
|
||||||
|
hooks : {
|
||||||
|
preprocess(src) {
|
||||||
|
const codeBlockSkip = /^(?: {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+|^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})(?:[^\n]*)(?:\n|$)(?:|(?:[\s\S]*?)(?:\n|$))(?: {0,3}\2[~`]* *(?=\n|$))|`[^`]*?`/;
|
||||||
|
const blockDefRegex = /^[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]:(?!\() *((?:\n? *[^\s].*)+)(?=\n+|$)/; //Matches 3, [4]:5
|
||||||
|
const blockCallRegex = /^[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\](?=\n|$)/; //Matches 6, [7]
|
||||||
|
const inlineDefRegex = /([!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\])\(([^\n]+)\)/; //Matches 8, 9[10](11)
|
||||||
|
const inlineCallRegex = /[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\](?!\()/; //Matches 12, [13]
|
||||||
|
|
||||||
|
// Combine regexes and wrap in parens like so: (regex1)|(regex2)|(regex3)|(regex4)
|
||||||
|
const combinedRegex = new RegExp([codeBlockSkip, blockDefRegex, blockCallRegex, inlineDefRegex, inlineCallRegex].map((s)=>`(${s.source})`).join('|'), 'gm');
|
||||||
|
|
||||||
|
let lastIndex = 0;
|
||||||
|
let match;
|
||||||
|
while ((match = combinedRegex.exec(src)) !== null) {
|
||||||
|
// Format any matches into tokens and store
|
||||||
|
if(match.index > lastIndex) { // Any non-variable stuff
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'text',
|
||||||
|
varName : null,
|
||||||
|
content : src.slice(lastIndex, match.index)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(match[1]) {
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'text',
|
||||||
|
varName : null,
|
||||||
|
content : match[0]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(match[3]) { // Block Definition
|
||||||
|
const label = match[4] ? match[4].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||||
|
const content = match[5] ? match[5].trim().replace(/[ \t]+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||||
|
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'varDefBlock',
|
||||||
|
varName : label,
|
||||||
|
content : content
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(match[6]) { // Block Call
|
||||||
|
const label = match[7] ? match[7].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||||
|
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'varCallBlock',
|
||||||
|
varName : label,
|
||||||
|
content : match[0]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(match[8]) { // Inline Definition
|
||||||
|
const label = match[10] ? match[10].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||||
|
let content = match[11] ? match[11].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||||
|
|
||||||
|
// In case of nested (), find the correct matching end )
|
||||||
|
let level = 0;
|
||||||
|
let i;
|
||||||
|
for (i = 0; i < content.length; i++) {
|
||||||
|
if(content[i] === '\\') {
|
||||||
|
i++;
|
||||||
|
} else if(content[i] === '(') {
|
||||||
|
level++;
|
||||||
|
} else if(content[i] === ')') {
|
||||||
|
level--;
|
||||||
|
if(level < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(i > -1) {
|
||||||
|
combinedRegex.lastIndex = combinedRegex.lastIndex - (content.length - i);
|
||||||
|
content = content.slice(0, i).trim().replace(/\s+/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'varDefBlock',
|
||||||
|
varName : label,
|
||||||
|
content : content
|
||||||
|
});
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'varCallInline',
|
||||||
|
varName : label,
|
||||||
|
content : match[9]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(match[12]) { // Inline Call
|
||||||
|
const label = match[13] ? match[13].trim().replace(/\s+/g, ' ') : null; // Trim edge spaces and shorten blocks of whitespace to 1 space
|
||||||
|
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'varCallInline',
|
||||||
|
varName : label,
|
||||||
|
content : match[0]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
lastIndex = combinedRegex.lastIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lastIndex < src.length) {
|
||||||
|
varsQueue.push(
|
||||||
|
{ type : 'text',
|
||||||
|
varName : null,
|
||||||
|
content : src.slice(lastIndex)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
processVariableQueue();
|
||||||
|
|
||||||
|
const output = varsQueue.map((item)=>item.content).join('');
|
||||||
|
varsQueue = []; // Must clear varsQueue because custom HTML renderer uses Marked.parse which will preprocess again without clearing the array
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
//^=====--------------------< Variable Handling >-------------------=====^//
|
||||||
|
|
||||||
|
// Emoji options
|
||||||
|
// To add more icon fonts, need to do these things
|
||||||
|
// 1) Add the font file as .woff2 to themes/fonts/iconFonts folder
|
||||||
|
// 2) Create a .less file mapping CSS class names to the font character
|
||||||
|
// 3) Create a .js file mapping Autosuggest names to CSS class names
|
||||||
|
// 4) Import the .less file into shared/naturalcrit/codeEditor/codeEditor.less
|
||||||
|
// 5) Import the .less file into themes/V3/blank.style.less
|
||||||
|
// 6) Import the .js file to shared/naturalcrit/codeEditor/autocompleteEmoji.js and add to `emojis` object
|
||||||
|
// 7) Import the .js file here to markdown.js, and add to `emojis` object below
|
||||||
|
const MarkedEmojiOptions = {
|
||||||
|
emojis : {
|
||||||
|
...diceFont,
|
||||||
|
...elderberryInn,
|
||||||
|
...fontAwesome,
|
||||||
|
...gameIcons,
|
||||||
|
},
|
||||||
|
renderer : (token)=>`<i class="${token.emoji}"></i>`
|
||||||
|
};
|
||||||
|
|
||||||
|
const tableTerminators = [
|
||||||
|
`:+\\n`, // hardBreak
|
||||||
|
` *{[^\n]+}`, // blockInjector
|
||||||
|
` *{{[^{\n]*\n.*?\n}}` // mustacheDiv
|
||||||
|
]
|
||||||
|
|
||||||
|
Marked.use(MarkedVariables());
|
||||||
|
Marked.use({ extensions : [definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks, superSubScripts,
|
||||||
|
mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||||
|
Marked.use(mustacheInjectBlock);
|
||||||
|
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
|
||||||
|
Marked.use(MarkedExtendedTables(tableTerminators), MarkedGFMHeadingId({ globalSlugs: true }), MarkedSmartypantsLite(), MarkedEmojis(MarkedEmojiOptions));
|
||||||
|
|
||||||
|
function cleanUrl(href) {
|
||||||
try {
|
try {
|
||||||
href = encodeURI(href).replace(/%25/g, '%');
|
href = encodeURI(href).replace(/%25/g, '%');
|
||||||
} catch (e) {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return href;
|
return href;
|
||||||
};
|
}
|
||||||
|
|
||||||
const escapeTest = /[&<>"']/;
|
const escapeTest = /[&<>"']/;
|
||||||
const escapeReplace = /[&<>"']/g;
|
const escapeReplace = /[&<>"']/g;
|
||||||
@@ -326,24 +801,79 @@ const voidTags = new Set([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const processStyleTags = (string)=>{
|
const processStyleTags = (string)=>{
|
||||||
//split tags up. quotes can only occur right after colons.
|
//split tags up. quotes can only occur right after : or =.
|
||||||
//TODO: can we simplify to just split on commas?
|
//TODO: can we simplify to just split on commas?
|
||||||
const tags = string.match(/(?:[^, ":]+|:(?:"[^"]*"|))+/g);
|
const tags = string.match(/(?:[^, ":=]+|[:=](?:"[^"]*"|))+/g);
|
||||||
|
|
||||||
if(!tags) return '"';
|
const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0] || null;
|
||||||
|
const classes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('='))).join(' ') || null;
|
||||||
|
const attributes = _.remove(tags, (tag)=>(tag.includes('='))).map((tag)=>tag.replace(/="?([^"]*)"?/g, '="$1"'))
|
||||||
|
?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="'))
|
||||||
|
.reduce((obj, attr)=>{
|
||||||
|
const index = attr.indexOf('=');
|
||||||
|
let [key, value] = [attr.substring(0, index), attr.substring(index + 1)];
|
||||||
|
value = value.replace(/"/g, '');
|
||||||
|
obj[key] = value;
|
||||||
|
return obj;
|
||||||
|
}, {}) || null;
|
||||||
|
const styles = tags?.length ? tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;').trim()).join(' ') : null;
|
||||||
|
|
||||||
const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0];
|
return {
|
||||||
const classes = _.remove(tags, (tag)=>!tag.includes(':'));
|
id : id,
|
||||||
const styles = tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;'));
|
classes : classes,
|
||||||
return `${classes.join(' ')}" ${id ? `id="${id}"` : ''} ${styles.length ? `style="${styles.join(' ')}"` : ''}`;
|
styles : styles,
|
||||||
|
attributes : _.isEmpty(attributes) ? null : attributes
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
//Given a string representing an HTML element, extract all of its properties (id, class, style, and other attributes)
|
||||||
|
const extractHTMLStyleTags = (htmlString)=>{
|
||||||
|
const firstElementOnly = htmlString.split('>')[0];
|
||||||
|
const id = firstElementOnly.match(/id="([^"]*)"/)?.[1] || null;
|
||||||
|
const classes = firstElementOnly.match(/class="([^"]*)"/)?.[1] || null;
|
||||||
|
const styles = firstElementOnly.match(/style="([^"]*)"/)?.[1] || null;
|
||||||
|
const attributes = firstElementOnly.match(/[a-zA-Z]+="[^"]*"/g)
|
||||||
|
?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="'))
|
||||||
|
.reduce((obj, attr)=>{
|
||||||
|
const index = attr.indexOf('=');
|
||||||
|
let [key, value] = [attr.substring(0, index), attr.substring(index + 1)];
|
||||||
|
value = value.replace(/"/g, '');
|
||||||
|
obj[key] = value;
|
||||||
|
return obj;
|
||||||
|
}, {}) || null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id : id,
|
||||||
|
classes : classes,
|
||||||
|
styles : styles,
|
||||||
|
attributes : _.isEmpty(attributes) ? null : attributes
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const globalVarsList = {};
|
||||||
|
let varsQueue = [];
|
||||||
|
let globalPageNumber = 0;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
marked : Marked,
|
marked : Marked,
|
||||||
render : (rawBrewText)=>{
|
render : (rawBrewText, pageNumber=0)=>{
|
||||||
rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n<div class='columnSplit'></div>\n`)
|
globalVarsList[pageNumber] = {}; //Reset global links for current page, to ensure values are parsed in order
|
||||||
.replace(/^(:+)$/gm, (match)=>`${`<div class='blank'></div>`.repeat(match.length)}\n`);
|
varsQueue = []; //Could move into MarkedVariables()
|
||||||
return Marked.parse(rawBrewText);
|
globalPageNumber = pageNumber;
|
||||||
|
if(pageNumber==0) {
|
||||||
|
MarkedGFMResetHeadingIDs();
|
||||||
|
}
|
||||||
|
|
||||||
|
rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n<div class='columnSplit'></div>\n`);
|
||||||
|
const opts = Marked.defaults;
|
||||||
|
|
||||||
|
rawBrewText = opts.hooks.preprocess(rawBrewText);
|
||||||
|
const tokens = Marked.lexer(rawBrewText, opts);
|
||||||
|
|
||||||
|
Marked.walkTokens(tokens, opts.walkTokens);
|
||||||
|
|
||||||
|
const html = Marked.parser(tokens, opts);
|
||||||
|
return opts.hooks.postprocess(html);
|
||||||
},
|
},
|
||||||
|
|
||||||
validate : (rawBrewText)=>{
|
validate : (rawBrewText)=>{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require('./nav.less');
|
require('client/homebrew/navbar/navbar.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const { useState, useRef, useEffect } = React;
|
const { useState, useRef, useEffect } = React;
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
@@ -47,8 +47,8 @@ const Nav = {
|
|||||||
color : null
|
color : null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleClick : function(){
|
handleClick : function(e){
|
||||||
this.props.onClick();
|
this.props.onClick(e);
|
||||||
},
|
},
|
||||||
render : function(){
|
render : function(){
|
||||||
const classes = cx('navItem', this.props.color, this.props.className);
|
const classes = cx('navItem', this.props.color, this.props.className);
|
||||||
@@ -104,7 +104,7 @@ const Nav = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`navDropdownContainer ${props.className}`}
|
<div className={`navDropdownContainer ${props.className ?? ''}`}
|
||||||
ref={myRef}
|
ref={myRef}
|
||||||
onMouseEnter = { props.trigger.includes('hover') ? ()=>handleDropdown(true) : undefined }
|
onMouseEnter = { props.trigger.includes('hover') ? ()=>handleDropdown(true) : undefined }
|
||||||
onMouseLeave = { props.trigger.includes('hover') ? ()=>handleDropdown(false) : undefined }
|
onMouseLeave = { props.trigger.includes('hover') ? ()=>handleDropdown(false) : undefined }
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
@import '../styles/colors';
|
|
||||||
@keyframes glideDropDown {
|
|
||||||
0% {transform : translate(0px, -100%);
|
|
||||||
opacity : 0;
|
|
||||||
background-color: #333;}
|
|
||||||
100% {transform : translate(0px, 0px);
|
|
||||||
opacity : 1;
|
|
||||||
background-color: #333;}
|
|
||||||
}
|
|
||||||
nav{
|
|
||||||
background-color : #333;
|
|
||||||
.navContent{
|
|
||||||
position : relative;
|
|
||||||
display : flex;
|
|
||||||
justify-content : space-between;
|
|
||||||
z-index : 2;
|
|
||||||
}
|
|
||||||
.navSection{
|
|
||||||
display : flex;
|
|
||||||
align-items : center;
|
|
||||||
}
|
|
||||||
.navLogo{
|
|
||||||
display : block;
|
|
||||||
margin-top : 0px;
|
|
||||||
margin-right : 8px;
|
|
||||||
margin-left : 8px;
|
|
||||||
color : white;
|
|
||||||
text-decoration : none;
|
|
||||||
&:hover{
|
|
||||||
.name{ color : @orange; }
|
|
||||||
svg{ fill : @orange }
|
|
||||||
}
|
|
||||||
svg{
|
|
||||||
height : 13px;
|
|
||||||
margin-right : 0.2em;
|
|
||||||
cursor : pointer;
|
|
||||||
fill : white;
|
|
||||||
}
|
|
||||||
span.name{
|
|
||||||
font-family : 'CodeLight';
|
|
||||||
font-size : 15px;
|
|
||||||
span.crit{
|
|
||||||
font-family : 'CodeBold';
|
|
||||||
}
|
|
||||||
small{
|
|
||||||
font-family : 'Open Sans';
|
|
||||||
font-size : 0.3em;
|
|
||||||
font-weight : 800;
|
|
||||||
text-transform : uppercase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.navItem{
|
|
||||||
#backgroundColorsHover;
|
|
||||||
.animate(background-color);
|
|
||||||
padding : 8px 12px;
|
|
||||||
cursor : pointer;
|
|
||||||
background-color : #333;
|
|
||||||
font-size : 10px;
|
|
||||||
font-weight : 800;
|
|
||||||
color : white;
|
|
||||||
text-decoration : none;
|
|
||||||
text-transform : uppercase;
|
|
||||||
line-height : 13px;
|
|
||||||
i{
|
|
||||||
margin-left : 5px;
|
|
||||||
font-size : 13px;
|
|
||||||
float : right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.navSection:last-child .navItem{
|
|
||||||
border-left : 1px solid #666;
|
|
||||||
}
|
|
||||||
.navDropdownContainer{
|
|
||||||
position: relative;
|
|
||||||
.navDropdown {
|
|
||||||
position : absolute;
|
|
||||||
top : 28px;
|
|
||||||
left : 0px;
|
|
||||||
z-index : 10000;
|
|
||||||
width : 100%;
|
|
||||||
overflow : hidden auto;
|
|
||||||
max-height : calc(100vh - 28px);
|
|
||||||
.navItem{
|
|
||||||
animation-name: glideDropDown;
|
|
||||||
animation-duration: 0.4s;
|
|
||||||
position : relative;
|
|
||||||
display : block;
|
|
||||||
width : 100%;
|
|
||||||
vertical-align : middle;
|
|
||||||
padding : 8px 5px;
|
|
||||||
border : 1px solid #888;
|
|
||||||
border-bottom : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
require('./splitPane.less');
|
require('./splitPane.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const createClass = require('create-react-class');
|
const createClass = require('create-react-class');
|
||||||
const _ = require('lodash');
|
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
|
||||||
const SplitPane = createClass({
|
const SplitPane = createClass({
|
||||||
@@ -9,7 +8,8 @@ const SplitPane = createClass({
|
|||||||
getDefaultProps : function() {
|
getDefaultProps : function() {
|
||||||
return {
|
return {
|
||||||
storageKey : 'naturalcrit-pane-split',
|
storageKey : 'naturalcrit-pane-split',
|
||||||
onDragFinish : function(){} //fires when dragging
|
onDragFinish : function(){}, //fires when dragging
|
||||||
|
showDividerButtons : true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -19,11 +19,13 @@ const SplitPane = createClass({
|
|||||||
windowWidth : 0,
|
windowWidth : 0,
|
||||||
isDragging : false,
|
isDragging : false,
|
||||||
moveSource : false,
|
moveSource : false,
|
||||||
moveBrew : false,
|
moveBrew : false
|
||||||
showMoveArrows : true
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pane1 : React.createRef(null),
|
||||||
|
pane2 : React.createRef(null),
|
||||||
|
|
||||||
componentDidMount : function() {
|
componentDidMount : function() {
|
||||||
const dividerPos = window.localStorage.getItem(this.props.storageKey);
|
const dividerPos = window.localStorage.getItem(this.props.storageKey);
|
||||||
if(dividerPos){
|
if(dividerPos){
|
||||||
@@ -137,17 +139,18 @@ const SplitPane = createClass({
|
|||||||
render : function(){
|
render : function(){
|
||||||
return <div className='splitPane' onPointerMove={this.handleMove} onPointerUp={this.handleUp}>
|
return <div className='splitPane' onPointerMove={this.handleMove} onPointerUp={this.handleUp}>
|
||||||
<Pane
|
<Pane
|
||||||
ref='pane1'
|
|
||||||
width={this.state.currentDividerPos}
|
width={this.state.currentDividerPos}
|
||||||
>
|
>
|
||||||
{React.cloneElement(this.props.children[0], {
|
{React.cloneElement(this.props.children[0], {
|
||||||
|
...(this.props.showDividerButtons && {
|
||||||
moveBrew: this.state.moveBrew,
|
moveBrew: this.state.moveBrew,
|
||||||
moveSource: this.state.moveSource,
|
moveSource: this.state.moveSource,
|
||||||
setMoveArrows : this.setMoveArrows
|
setMoveArrows: this.setMoveArrows,
|
||||||
|
}),
|
||||||
})}
|
})}
|
||||||
</Pane>
|
</Pane>
|
||||||
{this.renderDivider()}
|
{this.renderDivider()}
|
||||||
<Pane ref='pane2' isDragging={this.state.isDragging}>{this.props.children[1]}</Pane>
|
<Pane isDragging={this.state.isDragging}>{this.props.children[1]}</Pane>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const stylelint = require('stylelint');
|
const stylelint = require('stylelint');
|
||||||
const { isNumber } = require('stylelint/lib/utils/validateTypes');
|
const { isNumber } = require('stylelint/lib/utils/validateTypes.cjs');
|
||||||
|
|
||||||
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
||||||
const ruleName = 'naturalcrit/declaration-block-multi-line-min-declarations';
|
const ruleName = 'naturalcrit/declaration-block-multi-line-min-declarations';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const stylelint = require('stylelint');
|
const stylelint = require('stylelint');
|
||||||
const { isNumber } = require('stylelint/lib/utils/validateTypes');
|
const { isNumber } = require('stylelint/lib/utils/validateTypes.cjs');
|
||||||
|
|
||||||
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
||||||
const ruleName = 'naturalcrit/declaration-colon-min-space-before';
|
const ruleName = 'naturalcrit/declaration-colon-min-space-before';
|
||||||
|
|||||||
103
tests/markdown/definition-lists.test.js
Normal file
103
tests/markdown/definition-lists.test.js
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/* eslint-disable max-lines */
|
||||||
|
|
||||||
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
|
||||||
|
describe('Inline Definition Lists', ()=>{
|
||||||
|
test('No Term 1 Definition', function() {
|
||||||
|
const source = ':: My First Definition\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt></dt><dd>My First Definition</dd>\n</dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Single Definition Term', function() {
|
||||||
|
const source = 'My term :: My First Definition\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>My term</dt><dd>My First Definition</dd>\n</dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple Definition Terms', function() {
|
||||||
|
const source = 'Term 1::Definition of Term 1\nTerm 2::Definition of Term 2\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt><dd>Definition of Term 1</dd>\n<dt>Term 2</dt><dd>Definition of Term 2</dd>\n</dl>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Multiline Definition Lists', ()=>{
|
||||||
|
test('Single Term, Single Definition', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Single Term, Plural Definitions', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\n::Definition 2\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1</dd>\n<dd>Definition 2</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple Term, Single Definitions', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\n\nTerm 2\n::Definition 1\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1</dd>\n<dt>Term 2</dt>\n<dd>Definition 1</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple Term, Plural Definitions', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\n::Definition 2\n\nTerm 2\n::Definition 1\n::Definition 2\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1</dd>\n<dd>Definition 2</dd>\n<dt>Term 2</dt>\n<dd>Definition 1</dd>\n<dd>Definition 2</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Single Term, Single multi-line definition', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\nand more and\nmore and more\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1 and more and more and more</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Single Term, Plural multi-line definitions', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\nand more and more\n::Definition 2\nand more\nand more\n::Definition 3\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1 and more and more</dd>\n<dd>Definition 2 and more and more</dd>\n<dd>Definition 3</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple Term, Single multi-line definition', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\nand more and more\n\nTerm 2\n::Definition 1\n::Definition 2\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1 and more and more</dd>\n<dt>Term 2</dt>\n<dd>Definition 1</dd>\n<dd>Definition 2</dd></dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple Term, Single multi-line definition, followed by an inline dl', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\nand more and more\n\nTerm 2\n::Definition 1\n::Definition 2\n\n::Inline Definition (no term)';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1 and more and more</dd>\n<dt>Term 2</dt>\n<dd>Definition 1</dd>\n<dd>Definition 2</dd></dl><dl><dt></dt><dd>Inline Definition (no term)</dd>\n</dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple Term, Single multi-line definition, followed by paragraph', function() {
|
||||||
|
const source = 'Term 1\n::Definition 1\nand more and more\n\nTerm 2\n::Definition 1\n::Definition 2\n\nParagraph';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt>\n<dd>Definition 1 and more and more</dd>\n<dt>Term 2</dt>\n<dd>Definition 1</dd>\n<dd>Definition 2</dd></dl><p>Paragraph</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Block Token cannot be the Term of a multi-line definition', function() {
|
||||||
|
const source = '## Header\n::Definition 1 of a single-line DL\n::Definition 1 of another single-line DL';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<h2 id="header">Header</h2>\n<dl><dt></dt><dd>Definition 1 of a single-line DL</dd>\n<dt></dt><dd>Definition 1 of another single-line DL</dd>\n</dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Inline DL has priority over Multiline', function() {
|
||||||
|
const source = 'Term 1 :: Inline definition 1\n:: Inline definition 2 (no DT)';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<dl><dt>Term 1</dt><dd>Inline definition 1</dd>\n<dt></dt><dd>Inline definition 2 (no DT)</dd>\n</dl>');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiline Definition Term must have at least one non-empty Definition', function() {
|
||||||
|
const source = 'Term 1\n::';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>Term 1</p>\n<div class='blank'></div><div class='blank'></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiline Definition List must have at least one non-newline character after ::', function() {
|
||||||
|
const source = 'Term 1\n::\nDefinition 1\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>Term 1</p>\n<div class='blank'></div><div class='blank'></div>\n<p>Definition 1</p>`);
|
||||||
|
});
|
||||||
|
});
|
||||||
58
tests/markdown/emojis.test.js
Normal file
58
tests/markdown/emojis.test.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
const dedent = require('dedent-tabs').default;
|
||||||
|
|
||||||
|
// Marked.js adds line returns after closing tags on some default tokens.
|
||||||
|
// This removes those line returns for comparison sake.
|
||||||
|
String.prototype.trimReturns = function(){
|
||||||
|
return this.replace(/\r?\n|\r/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
const emoji = 'df_d12_2';
|
||||||
|
|
||||||
|
describe(`When emojis/icons are active`, ()=>{
|
||||||
|
it('when a word is between two colons (:word:), and a matching emoji exists, it is rendered as an emoji', function() {
|
||||||
|
const source = `:${emoji}:`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><i class="df d12-2"></i></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('when a word is between two colons (:word:), and no matching emoji exists, it is not parsed', function() {
|
||||||
|
const source = `:invalid:`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>:invalid:</p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('two valid emojis with no whitespace are prioritized over definition lists', function() {
|
||||||
|
const source = `:${emoji}::${emoji}:`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><i class="df d12-2"></i><i class="df d12-2"></i></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('definition lists that are not also part of an emoji can coexist with normal emojis', function() {
|
||||||
|
const source = `definition :: term ${emoji}::${emoji}:`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<dl><dt>definition</dt><dd>term df_d12_2:<i class="df d12-2"></i></dd></dl>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('A valid emoji is compatible with curly injectors', function() {
|
||||||
|
const source = `:${emoji}:{color:blue,myClass}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><i class="df d12-2 myClass" style="color:blue;"></i></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Emojis are not parsed inside of curly span CSS blocks', function() {
|
||||||
|
const source = `{{color:${emoji} text}}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<span class="inline-block" style="color:df_d12_2;">text</span>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Emojis are not parsed inside of curly div CSS blocks', function() {
|
||||||
|
const source = dedent`{{color:${emoji}
|
||||||
|
text
|
||||||
|
}}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="color:df_d12_2;"><p>text</p></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// another test of the editor to confirm an autocomplete menu opens
|
||||||
|
});
|
||||||
47
tests/markdown/hard-breaks.test.js
Normal file
47
tests/markdown/hard-breaks.test.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* eslint-disable max-lines */
|
||||||
|
|
||||||
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
|
||||||
|
describe('Hard Breaks', ()=>{
|
||||||
|
test('Single Break', function() {
|
||||||
|
const source = ':\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class='blank'></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Double Break', function() {
|
||||||
|
const source = '::\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class='blank'></div><div class='blank'></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Triple Break', function() {
|
||||||
|
const source = ':::\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class='blank'></div><div class='blank'></div><div class='blank'></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Many Break', function() {
|
||||||
|
const source = '::::::::::\n\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div><div class='blank'></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Multiple sets of Breaks', function() {
|
||||||
|
const source = ':::\n:::\n:::';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class='blank'></div><div class='blank'></div><div class='blank'></div>\n<div class='blank'></div><div class='blank'></div><div class='blank'></div>\n<div class='blank'></div><div class='blank'></div><div class='blank'></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Break directly between two paragraphs', function() {
|
||||||
|
const source = 'Line 1\n::\nLine 2';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>Line 1</p>\n<div class='blank'></div><div class='blank'></div>\n<p>Line 2</p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Ignored inside a code block', function() {
|
||||||
|
const source = '```\n\n:\n\n```\n';
|
||||||
|
const rendered = Markdown.render(source).trim();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<pre><code>\n:\n</code></pre>`);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -13,137 +13,134 @@ String.prototype.trimReturns = function(){
|
|||||||
// Remove the `.failing()` method once you have fixed the issue.
|
// Remove the `.failing()` method once you have fixed the issue.
|
||||||
|
|
||||||
describe('Inline: When using the Inline syntax {{ }}', ()=>{
|
describe('Inline: When using the Inline syntax {{ }}', ()=>{
|
||||||
it.failing('Renders a mustache span with text only', function() {
|
it('Renders a mustache span with text only', function() {
|
||||||
const source = '{{ text}}';
|
const source = '{{ text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text only, but with spaces', function() {
|
it('Renders a mustache span with text only, but with spaces', function() {
|
||||||
const source = '{{ this is a text}}';
|
const source = '{{ this is a text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block">this is a text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block">this is a text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders an empty mustache span', function() {
|
it('Renders an empty mustache span', function() {
|
||||||
const source = '{{}}';
|
const source = '{{}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block"></span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block"></span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with just a space', function() {
|
it('Renders a mustache span with just a space', function() {
|
||||||
const source = '{{ }}';
|
const source = '{{ }}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block"></span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block"></span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with a few spaces only', function() {
|
it('Renders a mustache span with a few spaces only', function() {
|
||||||
const source = '{{ }}';
|
const source = '{{ }}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block"></span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block"></span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and class', function() {
|
it('Renders a mustache span with text and class', function() {
|
||||||
const source = '{{my-class text}}';
|
const source = '{{my-class text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag.
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block my-class">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block my-class">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and two classes', function() {
|
it('Renders a mustache span with text and two classes', function() {
|
||||||
const source = '{{my-class,my-class2 text}}';
|
const source = '{{my-class,my-class2 text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag.
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block my-class my-class2">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block my-class my-class2">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text with spaces and class', function() {
|
it('Renders a mustache span with text with spaces and class', function() {
|
||||||
const source = '{{my-class this is a text}}';
|
const source = '{{my-class this is a text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block my-class">this is a text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block my-class">this is a text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and id', function() {
|
it('Renders a mustache span with text and id', function() {
|
||||||
const source = '{{#my-span text}}';
|
const source = '{{#my-span text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s before closing `>` in opening tag, and another after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" id="my-span">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" id="my-span">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and two ids', function() {
|
it('Renders a mustache span with text and two ids', function() {
|
||||||
const source = '{{#my-span,#my-favorite-span text}}';
|
const source = '{{#my-span,#my-favorite-span text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s before closing `>` in opening tag, and another after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" id="my-span">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" id="my-span">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and css property', function() {
|
it('Renders a mustache span with text and css property', function() {
|
||||||
const source = '{{color:red text}}';
|
const source = '{{color:red text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and two css properties', function() {
|
it('Renders a mustache span with text and two css properties', function() {
|
||||||
const source = '{{color:red,padding:5px text}}';
|
const source = '{{color:red,padding:5px text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red; padding:5px;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red; padding:5px;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and css property which contains quotes', function() {
|
it('Renders a mustache span with text and css property which contains quotes', function() {
|
||||||
const source = '{{font-family:"trebuchet ms" text}}';
|
const source = '{{font-family:"trebuchet ms" text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="font-family:trebuchet ms;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="font-family:trebuchet ms;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text and two css properties which contains quotes', function() {
|
it('Renders a mustache span with text and two css properties which contains quotes', function() {
|
||||||
const source = '{{font-family:"trebuchet ms",padding:"5px 10px" text}}';
|
const source = '{{font-family:"trebuchet ms",padding:"5px 10px" text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="font-family:trebuchet ms; padding:5px 10px;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="font-family:trebuchet ms; padding:5px 10px;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it.failing('Renders a mustache span with text with quotes and css property which contains quotes', function() {
|
it('Renders a mustache span with text with quotes and css property which contains double quotes', function() {
|
||||||
const source = '{{font-family:"trebuchet ms" text "with quotes"}}';
|
const source = '{{font-family:"trebuchet ms" text "with quotes"}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="font-family:trebuchet ms;">text “with quotes”</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="font-family:trebuchet ms;">text “with quotes”</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('Renders a mustache span with text with quotes and css property which contains double and simple quotes', function() {
|
||||||
|
const source = `{{--stringVariable:"'string'" text "with quotes"}}`;
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<span class="inline-block" style="--stringVariable:'string';">text “with quotes”</span>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Renders a mustache span with text, id, class and a couple of css properties', function() {
|
it('Renders a mustache span with text, id, class and a couple of css properties', function() {
|
||||||
const source = '{{pen,#author,color:orange,font-family:"trebuchet ms" text}}';
|
const source = '{{pen,#author,color:orange,font-family:"trebuchet ms" text}}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block pen" id="author" style="color:orange; font-family:trebuchet ms;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block pen" id="author" style="color:orange; font-family:trebuchet ms;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Renders a span with added attributes', function() {
|
||||||
|
const source = 'Text and {{pen,#author,color:orange,font-family:"trebuchet ms",a="b and c",d=e, text}} and more text!';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>Text and <span class="inline-block pen" id="author" style="color:orange; font-family:trebuchet ms;" a="b and c" d="e">text</span> and more text!</p>\n');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// BLOCK SYNTAX
|
// BLOCK SYNTAX
|
||||||
|
|
||||||
describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{
|
describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{
|
||||||
it.failing('Renders a div with text only', function() {
|
it('Renders a div with text only', function() {
|
||||||
const source = dedent`{{
|
const source = dedent`{{
|
||||||
text
|
text
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block"><p>text</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block"><p>text</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders an empty div', function() {
|
it('Renders an empty div', function() {
|
||||||
const source = dedent`{{
|
const source = dedent`{{
|
||||||
|
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds extra \s after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block"></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block"></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -151,52 +148,62 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{
|
|||||||
const source = dedent`{{
|
const source = dedent`{{
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// this actually renders in HB as '{{ }}'...
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>{{}}</p>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>{{}}</p>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a div with a single class', function() {
|
it('Renders a div with a single class', function() {
|
||||||
const source = dedent`{{cat
|
const source = dedent`{{cat
|
||||||
|
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat"></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat"></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a div with a single class and text', function() {
|
it('Renders a div with a single class and text', function() {
|
||||||
const source = dedent`{{cat
|
const source = dedent`{{cat
|
||||||
Sample text.
|
Sample text.
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat"><p>Sample text.</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat"><p>Sample text.</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a div with two classes and text', function() {
|
it('Renders a div with two classes and text', function() {
|
||||||
const source = dedent`{{cat,dog
|
const source = dedent`{{cat,dog
|
||||||
Sample text.
|
Sample text.
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat dog"><p>Sample text.</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat dog"><p>Sample text.</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a div with a style and text', function() {
|
it('Renders a div with a style and text', function() {
|
||||||
const source = dedent`{{color:red
|
const source = dedent`{{color:red
|
||||||
Sample text.
|
Sample text.
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds two extra \s before closing `>` in opening tag
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="color:red;"><p>Sample text.</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="color:red;"><p>Sample text.</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a div with a class, style and text', function() {
|
it('Renders a div with a style that has a string variable, and text', function() {
|
||||||
|
const source = dedent`{{--stringVariable:"'string'"
|
||||||
|
Sample text.
|
||||||
|
}}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="--stringVariable:'string';"><p>Sample text.</p></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a div with a style that has a string variable, and text', function() {
|
||||||
|
const source = dedent`{{--stringVariable:"'string'"
|
||||||
|
Sample text.
|
||||||
|
}}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="--stringVariable:'string';"><p>Sample text.</p></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a div with a class, style and text', function() {
|
||||||
const source = dedent`{{cat,color:red
|
const source = dedent`{{cat,color:red
|
||||||
Sample text.
|
Sample text.
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds extra \s after the class attribute
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat" style="color:red;"><p>Sample text.</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat" style="color:red;"><p>Sample text.</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -208,14 +215,27 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{
|
|||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat" id="dog" style="color:red;"><p>Sample text.</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block cat" id="dog" style="color:red;"><p>Sample text.</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a div with a single ID', function() {
|
it('Renders a div with a single ID', function() {
|
||||||
const source = dedent`{{#cat,#dog
|
const source = dedent`{{#cat,#dog
|
||||||
Sample text.
|
Sample text.
|
||||||
}}`;
|
}}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
// FIXME: adds extra \s before closing `>` in opening tag, and another after class names
|
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" id="cat"><p>Sample text.</p></div>`);
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" id="cat"><p>Sample text.</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Renders a div with an ID, class, style and text, and a variable assignment', function() {
|
||||||
|
const source = dedent`{{color:red,cat,#dog,a="b and c",d="e"
|
||||||
|
Sample text.
|
||||||
|
}}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class=\"block cat\" id=\"dog\" style=\"color:red;\" a=\"b and c\" d=\"e\"><p>Sample text.</p></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a div with added attributes', function() {
|
||||||
|
const source = '{{pen,#author,color:orange,font-family:"trebuchet ms",a="b and c",d=e\nText and text and more text!\n}}\n';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block pen" id="author" style="color:orange; font-family:trebuchet ms;" a="b and c" d="e"><p>Text and text and more text!</p>\n</div>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// MUSTACHE INJECTION SYNTAX
|
// MUSTACHE INJECTION SYNTAX
|
||||||
@@ -223,91 +243,212 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{
|
|||||||
describe('Injection: When an injection tag follows an element', ()=>{
|
describe('Injection: When an injection tag follows an element', ()=>{
|
||||||
// FIXME: Most of these fail because injections currently replace attributes, rather than append to. Or just minor extra whitespace issues.
|
// FIXME: Most of these fail because injections currently replace attributes, rather than append to. Or just minor extra whitespace issues.
|
||||||
describe('and that element is an inline-block', ()=>{
|
describe('and that element is an inline-block', ()=>{
|
||||||
it.failing('Renders a span "text" with no injection', function() {
|
it('Renders a span "text" with no injection', function() {
|
||||||
const source = '{{ text}}{}';
|
const source = '{{ text}}{}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a span "text" with injected Class name', function() {
|
it('Renders a span "text" with injected Class name', function() {
|
||||||
const source = '{{ text}}{ClassName}';
|
const source = '{{ text}}{ClassName}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block ClassName">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block ClassName">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a span "text" with injected style', function() {
|
it('Renders a span "text" with injected attribute', function() {
|
||||||
|
const source = '{{ text}}{a="b and c"}';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" a="b and c">text</span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with injected style', function() {
|
||||||
const source = '{{ text}}{color:red}';
|
const source = '{{ text}}{color:red}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a span "text" with two injected styles', function() {
|
it('Renders a span "text" with injected style using a string variable', function() {
|
||||||
|
const source = `{{ text}}{--stringVariable:"'string'"}`;
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<span class="inline-block" style="--stringVariable:'string';">text</span>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with two injected styles', function() {
|
||||||
const source = '{{ text}}{color:red,background:blue}';
|
const source = '{{ text}}{color:red,background:blue}';
|
||||||
const rendered = Markdown.render(source);
|
const rendered = Markdown.render(source);
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red; background:blue;">text</span>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:red; background:blue;">text</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders an emphasis element with injected Class name', function() {
|
it('Renders a span "text" with its own ID, overwritten with an injected ID', function() {
|
||||||
|
const source = '{{#oldId text}}{#newId}';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" id="newId">text</span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own attributes, overwritten with an injected attribute, plus a new one', function() {
|
||||||
|
const source = '{{attrA="old",attrB="old" text}}{attrA="new",attrC="new"}';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" attrA="new" attrB="old" attrC="new">text</span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own attributes, overwritten with an injected attribute, ignoring "class", "style", and "id"', function() {
|
||||||
|
const source = '{{attrA="old",attrB="old" text}}{attrA="new",attrC="new",class="new",style="new",id="new"}';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" attrA="new" attrB="old" attrC="new">text</span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own styles, appended with injected styles', function() {
|
||||||
|
const source = '{{color:blue,height:10px text}}{width:10px,color:red}';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block" style="color:blue; height:10px; width:10px; color:red;">text</span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own classes, appended with injected classes', function() {
|
||||||
|
const source = '{{classA,classB text}}{classA,classC}';
|
||||||
|
const rendered = Markdown.render(source);
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<span class="inline-block classA classB classA classC">text</span>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders an emphasis element with injected Class name', function() {
|
||||||
const source = '*emphasis*{big}';
|
const source = '*emphasis*{big}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><em class="big">emphasis</em></p>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><em class="big">emphasis</em></p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders a code element with injected style', function() {
|
it('Renders a code element with injected style', function() {
|
||||||
const source = '`code`{background:gray}';
|
const source = '`code`{background:gray}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><code style="background:gray;">code</code></p>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><code style="background:gray;">code</code></p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders an image element with injected style', function() {
|
it('Renders an image element with injected style', function() {
|
||||||
const source = '{position:absolute}';
|
const source = '{position:absolute}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><img src="http://i.imgur.com/hMna6G0.png" alt="homebrew mug" style="position:absolute;"></p>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><img style="--HB_src:url(https://i.imgur.com/hMna6G0.png); position:absolute;" src="https://i.imgur.com/hMna6G0.png" alt="alt text"></p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('Renders an element modified by only the first of two consecutive injections', function() {
|
it('Renders an element modified by only the first of two consecutive injections', function() {
|
||||||
const source = '{{ text}}{color:red}{background:blue}';
|
const source = '{{ text}}{color:red}{background:blue}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><span class="inline-block" style="color:red;">text</span>{background:blue}</p>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p><span class="inline-block" style="color:red;">text</span>{background:blue}</p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Renders an parent and child element, each modified by an injector', function() {
|
||||||
|
const source = dedent`**bolded text**{color:red}
|
||||||
|
{color:blue}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p style="color:blue;"><strong style="color:red;">bolded text</strong></p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders an image with added attributes', function() {
|
||||||
|
const source = ` {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><img style="--HB_src:url(https://i.imgur.com/hMna6G0.png); position:absolute; bottom:20px; left:130px; width:220px;" src="https://i.imgur.com/hMna6G0.png" alt="homebrew mug" a="b and c" d="e"></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders an image with "=" in the url, and added attributes', function() {
|
||||||
|
const source = ` {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><img style="--HB_src:url(https://i.imgur.com/hMna6G0.png?auth=12345&height=1024); position:absolute; bottom:20px; left:130px; width:220px;" src="https://i.imgur.com/hMna6G0.png?auth=12345&height=1024" alt="homebrew mug" a="b and c" d="e"></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders an image and added attributes with "=" in the value, ', function() {
|
||||||
|
const source = ` {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e,otherUrl="url?auth=12345"}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p><img style="--HB_src:url(https://i.imgur.com/hMna6G0.png); position:absolute; bottom:20px; left:130px; width:220px;" src="https://i.imgur.com/hMna6G0.png" alt="homebrew mug" a="b and c" d="e" otherUrl="url?auth=12345"></p>`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and that element is a block', ()=>{
|
describe('and that element is a block', ()=>{
|
||||||
it.failing('renders a div "text" with no injection', function() {
|
it('renders a div "text" with no injection', function() {
|
||||||
const source = '{{\ntext\n}}\n{}';
|
const source = '{{\ntext\n}}\n{}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block"><p>text</p></div>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block"><p>text</p></div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('renders a div "text" with injected Class name', function() {
|
it('renders a div "text" with injected Class name', function() {
|
||||||
const source = '{{\ntext\n}}\n{ClassName}';
|
const source = '{{\ntext\n}}\n{ClassName}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block ClassName"><p>text</p></div>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block ClassName"><p>text</p></div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('renders a div "text" with injected style', function() {
|
it('renders a div "text" with injected style', function() {
|
||||||
const source = '{{\ntext\n}}\n{color:red}';
|
const source = '{{\ntext\n}}\n{color:red}';
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" style="color:red;"><p>text</p></div>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" style="color:red;"><p>text</p></div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('renders a div "text" with two injected styles', function() {
|
it('renders a div "text" with two injected styles', function() {
|
||||||
const source = dedent`{{
|
const source = dedent`{{
|
||||||
text
|
text
|
||||||
}}
|
}}
|
||||||
{color:red,background:blue}`;
|
{color:red,background:blue}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" style="color:red; background:blue;"><p>text</p></div>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="color:red; background:blue;"><p>text</p></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('renders an h2 header "text" with injected class name', function() {
|
it('renders a div "text" with injected variable string', function() {
|
||||||
|
const source = dedent`{{
|
||||||
|
text
|
||||||
|
}}
|
||||||
|
{--stringVariable:"'string'"}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<div class="block" style="--stringVariable:'string';"><p>text</p></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own ID, overwritten with an injected ID', function() {
|
||||||
|
const source = dedent`{{#oldId
|
||||||
|
text
|
||||||
|
}}
|
||||||
|
{#newId}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" id="newId"><p>text</p></div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own attributes, overwritten with an injected attribute, plus a new one', function() {
|
||||||
|
const source = dedent`{{attrA="old",attrB="old"
|
||||||
|
text
|
||||||
|
}}
|
||||||
|
{attrA="new",attrC="new"}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" attrA="new" attrB="old" attrC="new"><p>text</p></div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own attributes, overwritten with an injected attribute, ignoring "class", "style", and "id"', function() {
|
||||||
|
const source = dedent`{{attrA="old",attrB="old"
|
||||||
|
text
|
||||||
|
}}
|
||||||
|
{attrA="new",attrC="new",class="new",style="new",id="new"}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" attrA="new" attrB="old" attrC="new"><p>text</p></div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own styles, appended with injected styles', function() {
|
||||||
|
const source = dedent`{{color:blue,height:10px
|
||||||
|
text
|
||||||
|
}}
|
||||||
|
{width:10px,color:red}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block" style="color:blue; height:10px; width:10px; color:red;"><p>text</p></div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders a span "text" with its own classes, appended with injected classes', function() {
|
||||||
|
const source = dedent`{{classA,classB
|
||||||
|
text
|
||||||
|
}}
|
||||||
|
{classA,classC}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<div class="block classA classB classA classC"><p>text</p></div>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders an h2 header "text" with injected class name', function() {
|
||||||
const source = dedent`## text
|
const source = dedent`## text
|
||||||
{ClassName}`;
|
{ClassName}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<h2 class="ClassName">text</h2>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<h2 class="ClassName" id="text">text</h2>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('renders a table with injected class name', function() {
|
it('renders a table with injected class name', function() {
|
||||||
const source = dedent`| Experience Points | Level |
|
const source = dedent`| Experience Points | Level |
|
||||||
|:------------------|:-----:|
|
|:------------------|:-----:|
|
||||||
| 0 | 1 |
|
| 0 | 1 |
|
||||||
@@ -329,15 +470,15 @@ describe('Injection: When an injection tag follows an element', ()=>{
|
|||||||
// expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`...`); // FIXME: expect this to be injected into <ul>? Currently injects into last <li>
|
// expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`...`); // FIXME: expect this to be injected into <ul>? Currently injects into last <li>
|
||||||
// });
|
// });
|
||||||
|
|
||||||
it.failing('renders an h2 header "text" with injected class name, and "secondInjection" as regular text on the next line.', function() {
|
it('renders an h2 header "text" with injected class name, and "secondInjection" as regular text on the next line.', function() {
|
||||||
const source = dedent`## text
|
const source = dedent`## text
|
||||||
{ClassName}
|
{ClassName}
|
||||||
{secondInjection}`;
|
{secondInjection}`;
|
||||||
const rendered = Markdown.render(source).trimReturns();
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<h2 class="ClassName">text</h2><p>{secondInjection}</p>');
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<h2 class="ClassName" id="text">text</h2><p>{secondInjection}</p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it.failing('renders a div nested into another div, the inner with class=innerDiv and the other class=outerDiv', function() {
|
it('renders a div nested into another div, the inner with class=innerDiv and the other class=outerDiv', function() {
|
||||||
const source = dedent`{{
|
const source = dedent`{{
|
||||||
outer text
|
outer text
|
||||||
{{
|
{{
|
||||||
|
|||||||
405
tests/markdown/variables.test.js
Normal file
405
tests/markdown/variables.test.js
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
/* eslint-disable max-lines */
|
||||||
|
|
||||||
|
const dedent = require('dedent-tabs').default;
|
||||||
|
const Markdown = require('naturalcrit/markdown.js');
|
||||||
|
|
||||||
|
// Marked.js adds line returns after closing tags on some default tokens.
|
||||||
|
// This removes those line returns for comparison sake.
|
||||||
|
String.prototype.trimReturns = function(){
|
||||||
|
return this.replace(/\r?\n|\r/g, '').trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
renderAllPages = function(pages){
|
||||||
|
const outputs = [];
|
||||||
|
pages.forEach((page, index)=>{
|
||||||
|
const output = Markdown.render(page, index);
|
||||||
|
outputs.push(output);
|
||||||
|
});
|
||||||
|
|
||||||
|
return outputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Adding `.failing()` method to `describe` or `it` will make failing tests "pass" as long as they continue to fail.
|
||||||
|
// Remove the `.failing()` method once you have fixed the issue.
|
||||||
|
|
||||||
|
describe('Block-level variables', ()=>{
|
||||||
|
it('Handles variable assignment and recall with simple text', function() {
|
||||||
|
const source = dedent`
|
||||||
|
[var]: string
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>string</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles variable assignment and recall with multiline string', function() {
|
||||||
|
const source = dedent`
|
||||||
|
[var]: string
|
||||||
|
across multiple
|
||||||
|
lines
|
||||||
|
|
||||||
|
$[var]`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>string across multiple lines</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles variable assignment and recall with tables', function() {
|
||||||
|
const source = dedent`
|
||||||
|
[var]:
|
||||||
|
##### Title
|
||||||
|
| H1 | H2 |
|
||||||
|
|:---|:--:|
|
||||||
|
| A | B |
|
||||||
|
| C | D |
|
||||||
|
|
||||||
|
$[var]`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<h5 id="title">Title</h5>
|
||||||
|
<table><thead><tr><th align=left>H1</th>
|
||||||
|
<th align=center>H2</th>
|
||||||
|
</tr></thead><tbody><tr><td align=left>A</td>
|
||||||
|
<td align=center>B</td>
|
||||||
|
</tr><tr><td align=left>C</td>
|
||||||
|
<td align=center>D</td>
|
||||||
|
</tr></tbody></table>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Hoists undefined variables', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
[var]: string`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>string</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Hoists last instance of variable', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
[var]: string
|
||||||
|
|
||||||
|
[var]: new string`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>new string</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles complex hoisting', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[titleAndName]: $[title] $[fullName]
|
||||||
|
|
||||||
|
$[title]: Mr.
|
||||||
|
|
||||||
|
$[fullName]: $[firstName] $[lastName]
|
||||||
|
|
||||||
|
[firstName]: Bob
|
||||||
|
|
||||||
|
Welcome, $[titleAndName]!
|
||||||
|
|
||||||
|
[lastName]: Jacob
|
||||||
|
|
||||||
|
[lastName]: $[lastName]son
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>Welcome, Mr. Bob Jacobson!</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles variable reassignment', function() {
|
||||||
|
const source = dedent`
|
||||||
|
[var]: one
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
[var]: two
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>one</p><p>two</p>'.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles variable reassignment with hoisting', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
[var]: one
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
[var]: two
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>two</p><p>one</p><p>two</p>'.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Ignores undefined variables that can\'t be hoisted', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var](My name is $[first] $[last])
|
||||||
|
|
||||||
|
$[last]: Jones
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>My name is $[first] Jones</p>`.trimReturns());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Inline-level variables', ()=>{
|
||||||
|
it('Handles variable assignment and recall with simple text', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var](string)
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>string</p><p>string</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Hoists undefined variables when possible', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var](My name is $[name] Jones)
|
||||||
|
|
||||||
|
[name]: Bob`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>My name is Bob Jones</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Hoists last instance of variable', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var](My name is $[name] Jones)
|
||||||
|
|
||||||
|
$[name](Bob)
|
||||||
|
|
||||||
|
[name]: Bill`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>My name is Bill Jones</p> <p>Bob</p>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Only captures nested parens if balanced', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[var1](A variable (with nested parens) inside)
|
||||||
|
|
||||||
|
$[var1]
|
||||||
|
|
||||||
|
$[var2](A variable ) with unbalanced parens)
|
||||||
|
|
||||||
|
$[var2]`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p>A variable (with nested parens) inside</p>
|
||||||
|
<p>A variable (with nested parens) inside</p>
|
||||||
|
<p>A variable with unbalanced parens)</p>
|
||||||
|
<p>A variable</p>
|
||||||
|
`.trimReturns());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Math', ()=>{
|
||||||
|
it('Handles simple math using numbers only', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[1 + 3 * 5 - (1 / 4)]
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>15.75</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles round function', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[round(1/4)]`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>0</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles floor function', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[floor(0.6)]`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>0</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles ceil function', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[ceil(0.2)]`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>1</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles nested functions', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[ceil(floor(round(0.6)))]`;
|
||||||
|
const rendered = Markdown.render(source).replace(/\s/g, ' ').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>1</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles simple math with variables', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[num1]: 5
|
||||||
|
|
||||||
|
$[num2]: 4
|
||||||
|
|
||||||
|
Answer is $[answer]($[1 + 3 * num1 - (1 / num2)]).
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>Answer is 15.75.</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles variable incrementing', function() {
|
||||||
|
const source = dedent`
|
||||||
|
$[num1]: 5
|
||||||
|
|
||||||
|
Increment num1 to get $[num1]($[num1 + 1]) and again to $[num1]($[num1 + 1]).
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('<p>Increment num1 to get 6 and again to 7.</p>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Code blocks', ()=>{
|
||||||
|
it('Ignores all variables in fenced code blocks', function() {
|
||||||
|
const source = dedent`
|
||||||
|
\`\`\`
|
||||||
|
[var]: string
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
$[var](new string)
|
||||||
|
\`\`\`
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<pre><code>
|
||||||
|
[var]: string
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
$[var](new string)
|
||||||
|
</code></pre>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Ignores all variables in indented code blocks', function() {
|
||||||
|
const source = dedent`
|
||||||
|
test
|
||||||
|
|
||||||
|
[var]: string
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
$[var](new string)
|
||||||
|
`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p>test</p>
|
||||||
|
|
||||||
|
<pre><code>
|
||||||
|
[var]: string
|
||||||
|
|
||||||
|
$[var]
|
||||||
|
|
||||||
|
$[var](new string)
|
||||||
|
</code></pre>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Ignores all variables in inline code blocks', function() {
|
||||||
|
const source = '[var](Hello) `[link](url)`. This `[var] does not work`';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p><a href="Hello">var</a> <code>[link](url)</code>. This <code>[var] does not work</code></p>`.trimReturns());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Normal Links and Images', ()=>{
|
||||||
|
it('Renders normal images', function() {
|
||||||
|
const source = ``;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p><img src="url" alt="alt text" style="--HB_src:url(url);"></p>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders normal images with a title', function() {
|
||||||
|
const source = 'An image !';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p>An image <img src="url" alt="alt text" style="--HB_src:url(url);" title="and title">!</p>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Applies curly injectors to images', function() {
|
||||||
|
const source = `{width:100px}`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p><img style="--HB_src:url(url); width:100px;" src="url" alt="alt text"></p>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders normal links', function() {
|
||||||
|
const source = 'A Link to my [website](url)!';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p>A Link to my <a href="url">website</a>!</p>`.trimReturns());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Renders normal links with a title', function() {
|
||||||
|
const source = 'A Link to my [website](url "and title")!';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(dedent`
|
||||||
|
<p>A Link to my <a href="url" title="and title">website</a>!</p>`.trimReturns());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Cross-page variables', ()=>{
|
||||||
|
it('Handles variable assignment and recall across pages', function() {
|
||||||
|
const source0 = `[var]: string`;
|
||||||
|
const source1 = `$[var]`;
|
||||||
|
const rendered = renderAllPages([source0, source1]).join('\n\\page\n').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${[source0, source1].join('\n\\page\n')}`, { showPrefix: false }).toBe('\\page<p>string</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles hoisting across pages', function() {
|
||||||
|
const source0 = `$[var]`;
|
||||||
|
const source1 = `[var]: string`;
|
||||||
|
renderAllPages([source0, source1]).join('\n\\page\n').trimReturns(); //Requires one full render of document before hoisting is picked up
|
||||||
|
const rendered = renderAllPages([source0, source1]).join('\n\\page\n').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${[source0, source1].join('\n\\page\n')}`, { showPrefix: false }).toBe('<p>string</p>\\page');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Handles reassignment and hoisting across pages', function() {
|
||||||
|
const source0 = `$[var]\n\n[var]: one\n\n$[var]`;
|
||||||
|
const source1 = `[var]: two\n\n$[var]`;
|
||||||
|
renderAllPages([source0, source1]).join('\n\\page\n').trimReturns(); //Requires one full render of document before hoisting is picked up
|
||||||
|
const rendered = renderAllPages([source0, source1]).join('\n\\page\n').trimReturns();
|
||||||
|
expect(rendered, `Input:\n${[source0, source1].join('\n\\page\n')}`, { showPrefix: false }).toBe('<p>two</p><p>one</p>\\page<p>two</p>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Math function parameter handling', ()=>{
|
||||||
|
it('allows variables in single-parameter functions', function() {
|
||||||
|
const source = '[var]:4.1\n\n$[floor(var)]';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>4</p>`);
|
||||||
|
});
|
||||||
|
it('allows one variable and a number in two-parameter functions', function() {
|
||||||
|
const source = '[var]:4\n\n$[min(1,var)]';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>1</p>`);
|
||||||
|
});
|
||||||
|
it('allows two variables in two-parameter functions', function() {
|
||||||
|
const source = '[var1]:4\n\n[var2]:8\n\n$[min(var1,var2)]';
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p>4</p>`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Variable names that are subsets of other names', ()=>{
|
||||||
|
it('do not conflict with function names', function() {
|
||||||
|
const source = `[a]: -1\n\n$[abs(a)]`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered).toBe('<p>1</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('do not conflict with other variable names', function() {
|
||||||
|
const source = `[ab]: 2\n\n[aba]: 8\n\n[ba]: 4\n\n$[ab + aba + ba]`;
|
||||||
|
const rendered = Markdown.render(source).trimReturns();
|
||||||
|
expect(rendered).toBe('<p>14</p>');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -40,7 +40,7 @@ body {
|
|||||||
-webkit-column-gap : 1cm;
|
-webkit-column-gap : 1cm;
|
||||||
-moz-column-gap : 1cm;
|
-moz-column-gap : 1cm;
|
||||||
}
|
}
|
||||||
.phb{
|
.phb, .page{
|
||||||
.useColumns();
|
.useColumns();
|
||||||
counter-increment : phb-page-numbers;
|
counter-increment : phb-page-numbers;
|
||||||
position : relative;
|
position : relative;
|
||||||
@@ -59,6 +59,9 @@ body {
|
|||||||
page-break-before : always;
|
page-break-before : always;
|
||||||
page-break-after : always;
|
page-break-after : always;
|
||||||
contain : size;
|
contain : size;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phb{
|
||||||
//*****************************
|
//*****************************
|
||||||
// * BASE
|
// * BASE
|
||||||
// *****************************/
|
// *****************************/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "5e PHB",
|
"name" : "5e PHB",
|
||||||
"renderer" : "V3",
|
"renderer" : "V3",
|
||||||
"baseTheme" : false,
|
"baseTheme" : "Blank",
|
||||||
"baseSnippets" : false
|
"baseSnippets" : false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,41 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
name : 'Table of Contents',
|
name : 'Table of Contents',
|
||||||
icon : 'fas fa-book',
|
icon : 'fas fa-book',
|
||||||
gen : TableOfContentsGen
|
gen : TableOfContentsGen,
|
||||||
|
experimental : true,
|
||||||
|
subsnippets : [
|
||||||
|
{
|
||||||
|
name : 'Table of Contents',
|
||||||
|
icon : 'fas fa-book',
|
||||||
|
gen : TableOfContentsGen,
|
||||||
|
experimental : true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'Include in ToC up to H3',
|
||||||
|
icon : 'fas fa-dice-three',
|
||||||
|
gen : dedent `\n{{tocDepthH3
|
||||||
|
}}\n`,
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'Include in ToC up to H4',
|
||||||
|
icon : 'fas fa-dice-four',
|
||||||
|
gen : dedent `\n{{tocDepthH4
|
||||||
|
}}\n`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'Include in ToC up to H5',
|
||||||
|
icon : 'fas fa-dice-five',
|
||||||
|
gen : dedent `\n{{tocDepthH5
|
||||||
|
}}\n`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'Include in ToC up to H6',
|
||||||
|
icon : 'fas fa-dice-six',
|
||||||
|
gen : dedent `\n{{tocDepthH6
|
||||||
|
}}\n`,
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'Index',
|
name : 'Index',
|
||||||
@@ -315,7 +349,7 @@ module.exports = [
|
|||||||
/* Ink Friendly */
|
/* Ink Friendly */
|
||||||
*:is(.page,.monster,.note,.descriptive) {
|
*:is(.page,.monster,.note,.descriptive) {
|
||||||
background : white !important;
|
background : white !important;
|
||||||
filter : drop-shadow(0px 0px 3px #888) !important;
|
box-shadow : 1px 4px 14px #888 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page img {
|
.page img {
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ module.exports = function(classname){
|
|||||||
|
|
||||||
#### Equipment
|
#### Equipment
|
||||||
You start with the following equipment, in addition to the equipment granted by your background:
|
You start with the following equipment, in addition to the equipment granted by your background:
|
||||||
- *(a)* a martial weapon and a shield or *(b)* two martial weapons
|
- (*a*) a martial weapon and a shield or (*b*) two martial weapons
|
||||||
- *(a)* five javelins or *(b)* any simple melee weapon
|
- (*a*) five javelins or (*b*) any simple melee weapon
|
||||||
- ${_.sample(['10 lint fluffs', '1 button', 'a cherished lost sock'])}
|
- ${_.sample(['10 lint fluffs', '1 button', 'a cherished lost sock'])}
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -149,8 +149,6 @@ module.exports = {
|
|||||||

|

|
||||||
|
|
||||||
Homebrewery.Naturalcrit.com
|
Homebrewery.Naturalcrit.com
|
||||||
}}
|
}}`;
|
||||||
|
|
||||||
\page`;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user