mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Compare commits
490 Commits
more-front
...
glitch-fav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ef0c3c5e9 | ||
|
|
cb69e35b3b | ||
|
|
e82021e0e6 | ||
|
|
8925731c98 | ||
|
|
4c233b4f3a | ||
|
|
b7cf758fbe | ||
|
|
7e5691804d | ||
|
|
7232cdf7e8 | ||
|
|
9f97c8c750 | ||
|
|
edadc93757 | ||
|
|
a6ea7e282f | ||
|
|
e5c0aa6493 | ||
|
|
02744f29ef | ||
|
|
a31d24ee18 | ||
|
|
6957c5b5c6 | ||
|
|
696bcff6bf | ||
|
|
f52ce92f2b | ||
|
|
c80046a77b | ||
|
|
ebf5a06084 | ||
|
|
23e854cb91 | ||
|
|
de105d64d5 | ||
|
|
07d93716aa | ||
|
|
88b5e0b703 | ||
|
|
32fa312b2a | ||
|
|
1306d637a2 | ||
|
|
462b3752e4 | ||
|
|
029f2c4545 | ||
|
|
b3e7beb7c5 | ||
|
|
a549d1ae6b | ||
|
|
467456f7a1 | ||
|
|
2374d63536 | ||
|
|
117eb3b2bc | ||
|
|
de985a30bc | ||
|
|
06d905f415 | ||
|
|
0ad41be0f3 | ||
|
|
d6f5dbff3e | ||
|
|
1e665a0bf4 | ||
|
|
ef16089c6d | ||
|
|
4b4ea1f929 | ||
|
|
45af29912f | ||
|
|
9075c90c46 | ||
|
|
63a2566007 | ||
|
|
43cad817e8 | ||
|
|
ed4c754fff | ||
|
|
1e0c7a0afc | ||
|
|
3a3b556065 | ||
|
|
9244f6b628 | ||
|
|
ff26b72333 | ||
|
|
6803935c4d | ||
|
|
3757546f1b | ||
|
|
a677ac8384 | ||
|
|
bdbfb10cff | ||
|
|
4d661e1183 | ||
|
|
dd28b557ae | ||
|
|
0e0f18ce7c | ||
|
|
7964bfccdb | ||
|
|
3c515f2cd2 | ||
|
|
852acbd738 | ||
|
|
db73ac92d7 | ||
|
|
6913426e48 | ||
|
|
3ba7c1e725 | ||
|
|
9b74a12045 | ||
|
|
4cd82d442e | ||
|
|
74a0cc6a11 | ||
|
|
311871eefc | ||
|
|
a929f7e6ac | ||
|
|
cf51e07bde | ||
|
|
984d2d4cb6 | ||
|
|
8d6c3cd48a | ||
|
|
0244019ca1 | ||
|
|
604654ccb4 | ||
|
|
3817704806 | ||
|
|
d4c6bf770d | ||
|
|
399f9f4a4e | ||
|
|
f2390e2803 | ||
|
|
dbaa6a0e13 | ||
|
|
7bf7ed6123 | ||
|
|
a390abdefb | ||
|
|
c1bc5e14eb | ||
|
|
0efd7e7406 | ||
|
|
4b911fea03 | ||
|
|
e7edb4d1ee | ||
|
|
d235224692 | ||
|
|
1fcdaafa6f | ||
|
|
f24b81e27f | ||
|
|
e01966f7b8 | ||
|
|
dcb9497148 | ||
|
|
4f2513337f | ||
|
|
015269914e | ||
|
|
bbdcfd6baf | ||
|
|
f0d6550f16 | ||
|
|
8400bee3b1 | ||
|
|
bc1f9dc24b | ||
|
|
cdc349a2d1 | ||
|
|
c2c93f8cd6 | ||
|
|
9fc082ea81 | ||
|
|
4c7a9adb98 | ||
|
|
030e5cec58 | ||
|
|
716f4cb11c | ||
|
|
a5a07da892 | ||
|
|
72108b20e2 | ||
|
|
0a678cf377 | ||
|
|
7a77f7b3bb | ||
|
|
767117f9b0 | ||
|
|
fb7f06a752 | ||
|
|
df74e26baf | ||
|
|
d69fa9e1f4 | ||
|
|
0b4006fc47 | ||
|
|
0ccd47f413 | ||
|
|
02f896c12e | ||
|
|
bb4c3831b2 | ||
|
|
3267e4a785 | ||
|
|
89b988cab5 | ||
|
|
4d42a38954 | ||
|
|
8387b3928e | ||
|
|
afa52e4d63 | ||
|
|
8949aad030 | ||
|
|
c0c7af2194 | ||
|
|
f5382ec085 | ||
|
|
407073d7a2 | ||
|
|
7f4375822a | ||
|
|
719ab720a7 | ||
|
|
b11ac88692 | ||
|
|
c727eae441 | ||
|
|
681c33d1f4 | ||
|
|
7f35947d8e | ||
|
|
68941d4dfa | ||
|
|
1d2616b79b | ||
|
|
d4b097a88c | ||
|
|
902c5cf7ca | ||
|
|
b15f790221 | ||
|
|
a47c2e8890 | ||
|
|
d0aad1ac85 | ||
|
|
21b04af524 | ||
|
|
a3202fd51e | ||
|
|
1cceefce33 | ||
|
|
033f970af3 | ||
|
|
d1c3e35d3f | ||
|
|
a6328fc1b1 | ||
|
|
35b868eeca | ||
|
|
3ea02314b9 | ||
|
|
4715161a93 | ||
|
|
144db8ea1d | ||
|
|
bc4202d00b | ||
|
|
09cfc079b0 | ||
|
|
695439775e | ||
|
|
05cd37097c | ||
|
|
08d021916d | ||
|
|
99f24ab0c7 | ||
|
|
3a526e2369 | ||
|
|
bd915d9398 | ||
|
|
8c45cd0e36 | ||
|
|
3fbf1bf35a | ||
|
|
cd9b2ab2f7 | ||
|
|
de397f3bc1 | ||
|
|
72bd73f605 | ||
|
|
1896a154f5 | ||
|
|
1618b68bfa | ||
|
|
c1f201c49a | ||
|
|
8d224ad23b | ||
|
|
e2685ccc81 | ||
|
|
51e3ac2534 | ||
|
|
75aafc932e | ||
|
|
c42092ba7a | ||
|
|
999170d898 | ||
|
|
37430a3401 | ||
|
|
0fa9dd8527 | ||
|
|
489d162477 | ||
|
|
9008ab3407 | ||
|
|
87b96f8d33 | ||
|
|
a49be27145 | ||
|
|
27b2355738 | ||
|
|
eeb5923e89 | ||
|
|
a9067167bb | ||
|
|
a9a0c854e1 | ||
|
|
0c7c188c45 | ||
|
|
c2753fdfb4 | ||
|
|
c29c20ab3c | ||
|
|
6ce806f913 | ||
|
|
35fda84ba8 | ||
|
|
5770d461b2 | ||
|
|
2e0645c26c | ||
|
|
880a5eb25c | ||
|
|
e48d3bfd01 | ||
|
|
5abb3d8150 | ||
|
|
66b1174d25 | ||
|
|
c45a75ad34 | ||
|
|
3567ac3d3e | ||
|
|
43f868de3d | ||
|
|
f41590912d | ||
|
|
183f993b01 | ||
|
|
e53fbb4a09 | ||
|
|
79d898ae0a | ||
|
|
bcf7ee48e9 | ||
|
|
297921fce5 | ||
|
|
056b5ed72f | ||
|
|
74eff5456c | ||
|
|
1764c32b9e | ||
|
|
60d27b4302 | ||
|
|
b21ab498f8 | ||
|
|
1c6c6b271c | ||
|
|
08d19778d5 | ||
|
|
e6c81a635b | ||
|
|
f93de3a516 | ||
|
|
e19eefe219 | ||
|
|
8784bd79d0 | ||
|
|
31366334cb | ||
|
|
425acecfdb | ||
|
|
29f314a502 | ||
|
|
cc68d1945b | ||
|
|
7bacdd718a | ||
|
|
958fe0f7db | ||
|
|
e670fa2af6 | ||
|
|
a3d93e8bbe | ||
|
|
7a889a8e12 | ||
|
|
d081d4a422 | ||
|
|
34ccc058fa | ||
|
|
7f9a353b94 | ||
|
|
31490e0d6c | ||
|
|
9f7a5aac1e | ||
|
|
945c5812d3 | ||
|
|
ca45bd0361 | ||
|
|
63baab088d | ||
|
|
2b9721d1b3 | ||
|
|
617208053c | ||
|
|
667b567606 | ||
|
|
4aa6cd66fc | ||
|
|
1c6cbdd4e4 | ||
|
|
f8212da329 | ||
|
|
4122a837fa | ||
|
|
5fa2dd6e65 | ||
|
|
307f3e0dd7 | ||
|
|
fc4c74660b | ||
|
|
caf938562e | ||
|
|
8e2b1f79e4 | ||
|
|
345290a905 | ||
|
|
ce3a371eee | ||
|
|
8781a8e203 | ||
|
|
37c832cdf7 | ||
|
|
2fb78fefc6 | ||
|
|
f68fa930ea | ||
|
|
007ab330e6 | ||
|
|
794781d121 | ||
|
|
91cacb1e8f | ||
|
|
46f5d3a2e9 | ||
|
|
76318f8830 | ||
|
|
852bda3d32 | ||
|
|
0324f807f4 | ||
|
|
864e3f8d9c | ||
|
|
102466ac58 | ||
|
|
dc2b8bdecd | ||
|
|
e3c2183c12 | ||
|
|
63b77f2320 | ||
|
|
8fecd80108 | ||
|
|
86f8df7903 | ||
|
|
348d6f5e75 | ||
|
|
00df69bc89 | ||
|
|
7a549f830e | ||
|
|
3f82d8b979 | ||
|
|
9fe6cfca48 | ||
|
|
ebd2dde688 | ||
|
|
6e1261f277 | ||
|
|
91d548f7e6 | ||
|
|
76eda2fc21 | ||
|
|
d41cec90cf | ||
|
|
7859e6ad45 | ||
|
|
3464bb30f8 | ||
|
|
1c1819a78a | ||
|
|
8b2cad5637 | ||
|
|
2d6128672f | ||
|
|
185b41beb4 | ||
|
|
2083000027 | ||
|
|
d87d70e89a | ||
|
|
18d3fa953b | ||
|
|
f76e71825d | ||
|
|
6bf6d35637 | ||
|
|
9c03fd9cae | ||
|
|
34c8a46d7d | ||
|
|
26949607d2 | ||
|
|
e7c0d87d98 | ||
|
|
6d106d3943 | ||
|
|
0c7ee5c792 | ||
|
|
bba75c15f1 | ||
|
|
a37cf9548c | ||
|
|
5e6acf9601 | ||
|
|
b52a5e6bd6 | ||
|
|
bb194ddb3c | ||
|
|
4cbbea5881 | ||
|
|
167c392efd | ||
|
|
193f354d3e | ||
|
|
6b67b91eb1 | ||
|
|
6b77424660 | ||
|
|
301c185878 | ||
|
|
cb7f54891f | ||
|
|
f6ce1a9592 | ||
|
|
aee64b996c | ||
|
|
0c71c0ccc8 | ||
|
|
49e82c1e0f | ||
|
|
556cede00f | ||
|
|
b73ee36949 | ||
|
|
dd49c10cdb | ||
|
|
85d5249479 | ||
|
|
a38b34c37a | ||
|
|
1921ab40ea | ||
|
|
976c18aa5f | ||
|
|
4cddef1cea | ||
|
|
cbe94b88e2 | ||
|
|
275c5b51ed | ||
|
|
ff9f2088f7 | ||
|
|
f85dbe83c8 | ||
|
|
a9c326b200 | ||
|
|
92f1c474f3 | ||
|
|
a6d02cff36 | ||
|
|
be94f9e35d | ||
|
|
e282580101 | ||
|
|
331f0953e9 | ||
|
|
133b892e0d | ||
|
|
60da49f856 | ||
|
|
d1d94216d1 | ||
|
|
bf50e3e5ae | ||
|
|
15227c713d | ||
|
|
30736f4886 | ||
|
|
c58877862d | ||
|
|
0e310f1ee3 | ||
|
|
7dd4d9de96 | ||
|
|
a978b88997 | ||
|
|
6dd5eac7fc | ||
|
|
968354923e | ||
|
|
59ddf81a45 | ||
|
|
3a7106f05a | ||
|
|
5c7a4f0b32 | ||
|
|
0e09048537 | ||
|
|
7362469d89 | ||
|
|
1273fbf86e | ||
|
|
46f83bb28b | ||
|
|
ec2daae71c | ||
|
|
b525caf40a | ||
|
|
fc65b691df | ||
|
|
651c3d643c | ||
|
|
a27879c0cf | ||
|
|
049cea30b0 | ||
|
|
b342c81c17 | ||
|
|
ead14f5bf0 | ||
|
|
cc4cba8afd | ||
|
|
99889ea57d | ||
|
|
19690d3e33 | ||
|
|
0b371da971 | ||
|
|
2d8ebdcc72 | ||
|
|
595c6de32c | ||
|
|
0a53ca444a | ||
|
|
f79c10162e | ||
|
|
60b2b56d38 | ||
|
|
6cbbdc805f | ||
|
|
b6a19e7b89 | ||
|
|
71bc75e6ac | ||
|
|
e4fee6c138 | ||
|
|
7d8e3721ae | ||
|
|
fb421a1f46 | ||
|
|
7b1d233f4f | ||
|
|
03f9648377 | ||
|
|
6107e95404 | ||
|
|
36805a39db | ||
|
|
ab4632a41e | ||
|
|
2a9805b987 | ||
|
|
126f929c39 | ||
|
|
ddafde942c | ||
|
|
da42bfadb5 | ||
|
|
6ad72728f6 | ||
|
|
64d9c016bd | ||
|
|
12e7c81dd8 | ||
|
|
e6300de142 | ||
|
|
16d0aed403 | ||
|
|
da9317fa56 | ||
|
|
be92babd00 | ||
|
|
e2dd576a1b | ||
|
|
8f2c91568c | ||
|
|
98eaa2aa27 | ||
|
|
a6f5111c79 | ||
|
|
59503a88ae | ||
|
|
5df7bc3a8b | ||
|
|
42b8220632 | ||
|
|
c806fef865 | ||
|
|
49ba78d6f8 | ||
|
|
a91d968cab | ||
|
|
646de92781 | ||
|
|
ae2b722f55 | ||
|
|
7b53d4bbca | ||
|
|
4f36aad6e8 | ||
|
|
7aeb9168b0 | ||
|
|
f53ed108b0 | ||
|
|
285038972b | ||
|
|
56ca33a6d3 | ||
|
|
aeff898137 | ||
|
|
b323e00bf3 | ||
|
|
a520b118e4 | ||
|
|
93fc8aa14c | ||
|
|
c0a665865e | ||
|
|
38a1299975 | ||
|
|
96e1f75679 | ||
|
|
3a99552f0c | ||
|
|
22cc5c0dec | ||
|
|
e5563843a2 | ||
|
|
c972e1ee1f | ||
|
|
efa425206c | ||
|
|
e60f27d649 | ||
|
|
6a50e73089 | ||
|
|
b1f9892e63 | ||
|
|
d6e3918d92 | ||
|
|
5e8d037e27 | ||
|
|
ed7dc1704d | ||
|
|
6909bbdc9e | ||
|
|
436ce03772 | ||
|
|
ddc6b85912 | ||
|
|
4bc237fcfe | ||
|
|
efacfec3ed | ||
|
|
d821aba002 | ||
|
|
8ea779e59a | ||
|
|
4ce1540094 | ||
|
|
67243bda31 | ||
|
|
8f991831b8 | ||
|
|
7eda83a36a | ||
|
|
87efa38721 | ||
|
|
f7301bd5b9 | ||
|
|
099a3b4eac | ||
|
|
3d4e21f1ec | ||
|
|
68dca26a5d | ||
|
|
af178d0ba6 | ||
|
|
e4326b3f12 | ||
|
|
b8a5052d53 | ||
|
|
7427680e75 | ||
|
|
ca0d30c04b | ||
|
|
da05cde721 | ||
|
|
4c37f629bc | ||
|
|
ddba5d3b8c | ||
|
|
1fc096ec75 | ||
|
|
21c2bc119c | ||
|
|
d23293c762 | ||
|
|
ceb545c080 | ||
|
|
a70468aa56 | ||
|
|
138e5a0b1e | ||
|
|
79dacea962 | ||
|
|
8b23bf7cbd | ||
|
|
f1a60d4b81 | ||
|
|
2513d92c54 | ||
|
|
414dfb3955 | ||
|
|
67adbcc60c | ||
|
|
4e6b5e7879 | ||
|
|
453b9c6e7e | ||
|
|
d9b9bb8c5e | ||
|
|
40ecbfd4a9 | ||
|
|
4fe45dda9a | ||
|
|
4bd7482a7a | ||
|
|
93c52301ad | ||
|
|
0d3ec19e89 | ||
|
|
62a75891ab | ||
|
|
b27842dc70 | ||
|
|
39b6b37b74 | ||
|
|
65528fc54e | ||
|
|
382572c213 | ||
|
|
9bc593d675 | ||
|
|
09f7ad3614 | ||
|
|
7c2ea42cd5 | ||
|
|
ea785d0baf | ||
|
|
a337c5dbe5 | ||
|
|
c0979381a4 | ||
|
|
676f577e7e | ||
|
|
c1a8e3d1eb | ||
|
|
0c44316b22 | ||
|
|
2211e8d1cd | ||
|
|
3783cadf2d | ||
|
|
a071047c13 | ||
|
|
281f07244b | ||
|
|
6f34a6a77f | ||
|
|
e078919f07 | ||
|
|
7b13e6efc2 | ||
|
|
3f59238207 | ||
|
|
eff9416469 | ||
|
|
6fbb3841a6 | ||
|
|
d8c4781377 | ||
|
|
bc6e958229 | ||
|
|
a6d8d1036a | ||
|
|
3d403a013d | ||
|
|
9ca02a00a6 | ||
|
|
3e8e9c8ae4 | ||
|
|
7bc1805827 | ||
|
|
e27f792c24 | ||
|
|
98fab24bea | ||
|
|
f566c47dda | ||
|
|
0190aac240 | ||
|
|
cc382c5006 |
5
.babelrc
5
.babelrc
@@ -15,13 +15,15 @@
|
|||||||
"plugins": [
|
"plugins": [
|
||||||
"syntax-dynamic-import",
|
"syntax-dynamic-import",
|
||||||
["transform-object-rest-spread", { "useBuiltIns": true }],
|
["transform-object-rest-spread", { "useBuiltIns": true }],
|
||||||
|
"transform-decorators-legacy",
|
||||||
"transform-class-properties",
|
"transform-class-properties",
|
||||||
[
|
[
|
||||||
"react-intl",
|
"react-intl",
|
||||||
{
|
{
|
||||||
"messagesDir": "./build/messages"
|
"messagesDir": "./build/messages"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"preval"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"development": {
|
"development": {
|
||||||
@@ -43,6 +45,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"transform-react-inline-elements",
|
||||||
[
|
[
|
||||||
"transform-runtime",
|
"transform-runtime",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ SMTP_FROM_ADDRESS=notifications@${APP_NAME}.nanoapp.io
|
|||||||
# PAPERCLIP_ROOT_URL=/system
|
# PAPERCLIP_ROOT_URL=/system
|
||||||
|
|
||||||
# Optional asset host for multi-server setups
|
# Optional asset host for multi-server setups
|
||||||
# CDN_HOST=assets.example.com
|
# CDN_HOST=https://assets.example.com
|
||||||
|
|
||||||
# S3 (optional)
|
# S3 (optional)
|
||||||
# S3_ENABLED=true
|
# S3_ENABLED=true
|
||||||
|
|||||||
@@ -31,6 +31,17 @@ PAPERCLIP_SECRET=
|
|||||||
SECRET_KEY_BASE=
|
SECRET_KEY_BASE=
|
||||||
OTP_SECRET=
|
OTP_SECRET=
|
||||||
|
|
||||||
|
# VAPID keys (used for push notifications
|
||||||
|
# You can generate the keys using the following command (first is the private key, second is the public one)
|
||||||
|
# You should only generate this once per instance. If you later decide to change it, all push subscription will
|
||||||
|
# be invalidated, requiring the users to access the website again to resubscribe.
|
||||||
|
#
|
||||||
|
# Generate with `rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
|
||||||
|
#
|
||||||
|
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html
|
||||||
|
VAPID_PRIVATE_KEY=
|
||||||
|
VAPID_PUBLIC_KEY=
|
||||||
|
|
||||||
# Registrations
|
# Registrations
|
||||||
# Single user mode will disable registrations and redirect frontpage to the first profile
|
# Single user mode will disable registrations and redirect frontpage to the first profile
|
||||||
# SINGLE_USER_MODE=true
|
# SINGLE_USER_MODE=true
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
root: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
browser: true
|
browser: true
|
||||||
node: false
|
node: true
|
||||||
es6: true
|
es6: true
|
||||||
|
|
||||||
parser: babel-eslint
|
parser: babel-eslint
|
||||||
@@ -52,8 +54,14 @@ rules:
|
|||||||
no-mixed-spaces-and-tabs: warn
|
no-mixed-spaces-and-tabs: warn
|
||||||
no-nested-ternary: warn
|
no-nested-ternary: warn
|
||||||
no-trailing-spaces: warn
|
no-trailing-spaces: warn
|
||||||
|
no-undef: error
|
||||||
no-unreachable: error
|
no-unreachable: error
|
||||||
no-unused-expressions: error
|
no-unused-expressions: error
|
||||||
|
no-unused-vars:
|
||||||
|
- error
|
||||||
|
- vars: all
|
||||||
|
args: after-used
|
||||||
|
ignoreRestSiblings: true
|
||||||
object-curly-spacing:
|
object-curly-spacing:
|
||||||
- error
|
- error
|
||||||
- always
|
- always
|
||||||
@@ -81,7 +89,10 @@ rules:
|
|||||||
- 2
|
- 2
|
||||||
react/jsx-no-bind: error
|
react/jsx-no-bind: error
|
||||||
react/jsx-no-duplicate-props: error
|
react/jsx-no-duplicate-props: error
|
||||||
|
react/jsx-no-undef: error
|
||||||
react/jsx-tag-spacing: error
|
react/jsx-tag-spacing: error
|
||||||
|
react/jsx-uses-react: error
|
||||||
|
react/jsx-uses-vars: error
|
||||||
react/jsx-wrap-multilines: error
|
react/jsx-wrap-multilines: error
|
||||||
react/no-multi-comp: off
|
react/no-multi-comp: off
|
||||||
react/no-string-refs: error
|
react/no-string-refs: error
|
||||||
|
|||||||
14
.gitattributes
vendored
Normal file
14
.gitattributes
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
*.eot -text
|
||||||
|
*.gif -text
|
||||||
|
*.gz -text
|
||||||
|
*.ico -text
|
||||||
|
*.jpg -text
|
||||||
|
*.mp3 -text
|
||||||
|
*.ogg -text
|
||||||
|
*.png -text
|
||||||
|
*.ttf -text
|
||||||
|
*.webm -text
|
||||||
|
*.woff -text
|
||||||
|
*.woff2 -text
|
||||||
|
spec/fixtures/requests/** -text !eol
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,6 +21,7 @@ public/system
|
|||||||
public/assets
|
public/assets
|
||||||
public/packs
|
public/packs
|
||||||
public/packs-test
|
public/packs-test
|
||||||
|
public/sw.js
|
||||||
.env
|
.env
|
||||||
.env.production
|
.env.production
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ plugins:
|
|||||||
- last 2 versions
|
- last 2 versions
|
||||||
- IE >= 11
|
- IE >= 11
|
||||||
- iOS >= 9
|
- iOS >= 9
|
||||||
|
postcss-object-fit-images: {}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ cache:
|
|||||||
- public/assets
|
- public/assets
|
||||||
- public/packs-test
|
- public/packs-test
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: false
|
sudo: required
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
@@ -32,6 +32,7 @@ addons:
|
|||||||
- g++-6
|
- g++-6
|
||||||
- libprotobuf-dev
|
- libprotobuf-dev
|
||||||
- protobuf-compiler
|
- protobuf-compiler
|
||||||
|
- libicu-dev
|
||||||
|
|
||||||
rvm:
|
rvm:
|
||||||
- 2.3.4
|
- 2.3.4
|
||||||
|
|||||||
2
Aptfile
2
Aptfile
@@ -3,3 +3,5 @@ libprotobuf-dev
|
|||||||
ffmpeg
|
ffmpeg
|
||||||
libxdamage1
|
libxdamage1
|
||||||
libxfixes3
|
libxfixes3
|
||||||
|
libicu-dev
|
||||||
|
libidn11-dev
|
||||||
|
|||||||
@@ -1,3 +1,36 @@
|
|||||||
|
# Contributing to Mastodon Glitch Edition #
|
||||||
|
|
||||||
|
Thank you for your interest in contributing to the `glitch-soc` project!
|
||||||
|
Here are some guidelines, and ways you can help.
|
||||||
|
|
||||||
|
> (This document is a bit of a work-in-progress, so please bear with us.
|
||||||
|
> If you don't see what you're looking for here, please don't hesitate to reach out!)
|
||||||
|
|
||||||
|
## Planning ##
|
||||||
|
|
||||||
|
Right now a lot of the planning for this project takes place in our development Discord, or through GitHub Issues and Projects.
|
||||||
|
We're working on ways to improve the planning structure and better solicit feedback, and if you feel like you can help in this respect, feel free to give us a holler.
|
||||||
|
|
||||||
|
## Documentation ##
|
||||||
|
|
||||||
|
The documentation for this repository is available at [`glitch-soc/docs`](https://github.com/glitch-soc/docs) (online at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/)).
|
||||||
|
Right now, we've mostly focused on the features that make this fork different from upstream in some manner.
|
||||||
|
Adding screenshots, improving descriptions, and so forth are all ways to help contribute to the project even if you don't know any code.
|
||||||
|
|
||||||
|
## Frontend Development ##
|
||||||
|
|
||||||
|
Check out [the documentation here](https://glitch-soc.github.io/docs/contributing/frontend/) for more information.
|
||||||
|
|
||||||
|
## Backend Development ##
|
||||||
|
|
||||||
|
See the guidelines below.
|
||||||
|
|
||||||
|
- - -
|
||||||
|
|
||||||
|
You should also try to follow the guidelines set out in the original `CONTRIBUTING.md` from `tootsuite/mastodon`, reproduced below.
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
|
||||||
CONTRIBUTING
|
CONTRIBUTING
|
||||||
============
|
============
|
||||||
|
|
||||||
@@ -49,3 +82,5 @@ It is expected that you have a working development environment set up (see back-
|
|||||||
* If you are introducing new strings, they must be using localization methods
|
* If you are introducing new strings, they must be using localization methods
|
||||||
|
|
||||||
If the JavaScript or CSS assets won't compile due to a syntax error, it's a good sign that the pull request isn't ready for submission yet.
|
If the JavaScript or CSS assets won't compile due to a syntax error, it's a good sign that the pull request isn't ready for submission yet.
|
||||||
|
|
||||||
|
</blockquote>
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ EXPOSE 3000 4000
|
|||||||
WORKDIR /mastodon
|
WORKDIR /mastodon
|
||||||
|
|
||||||
RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
|
RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
|
||||||
|
&& echo "@edge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
|
||||||
&& apk -U upgrade \
|
&& apk -U upgrade \
|
||||||
&& apk add -t build-dependencies \
|
&& apk add -t build-dependencies \
|
||||||
build-base \
|
build-base \
|
||||||
|
icu-dev \
|
||||||
|
libidn-dev \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
libxslt-dev \
|
libxslt-dev \
|
||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
@@ -25,7 +28,9 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
|
|||||||
ffmpeg \
|
ffmpeg \
|
||||||
file \
|
file \
|
||||||
git \
|
git \
|
||||||
|
icu-libs \
|
||||||
imagemagick@edge \
|
imagemagick@edge \
|
||||||
|
libidn \
|
||||||
libpq \
|
libpq \
|
||||||
libxml2 \
|
libxml2 \
|
||||||
libxslt \
|
libxslt \
|
||||||
@@ -34,7 +39,7 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
|
|||||||
protobuf \
|
protobuf \
|
||||||
su-exec \
|
su-exec \
|
||||||
tini \
|
tini \
|
||||||
&& npm install -g npm@3 && npm install -g yarn \
|
yarn@edge \
|
||||||
&& update-ca-certificates \
|
&& update-ca-certificates \
|
||||||
&& rm -rf /tmp/* /var/cache/apk/*
|
&& rm -rf /tmp/* /var/cache/apk/*
|
||||||
|
|
||||||
|
|||||||
11
Gemfile
11
Gemfile
@@ -18,22 +18,27 @@ gem 'aws-sdk', '~> 2.9'
|
|||||||
gem 'paperclip', '~> 5.1'
|
gem 'paperclip', '~> 5.1'
|
||||||
gem 'paperclip-av-transcoder', '~> 0.6'
|
gem 'paperclip-av-transcoder', '~> 0.6'
|
||||||
|
|
||||||
|
gem 'active_model_serializers', '~> 0.10'
|
||||||
gem 'addressable', '~> 2.5'
|
gem 'addressable', '~> 2.5'
|
||||||
gem 'bootsnap'
|
gem 'bootsnap'
|
||||||
|
gem 'browser'
|
||||||
|
gem 'charlock_holmes', '~> 0.7.3'
|
||||||
gem 'cld3', '~> 3.1'
|
gem 'cld3', '~> 3.1'
|
||||||
gem 'devise', '~> 4.2'
|
gem 'devise', '~> 4.2'
|
||||||
gem 'devise-two-factor', '~> 3.0'
|
gem 'devise-two-factor', '~> 3.0'
|
||||||
gem 'doorkeeper', '~> 4.2'
|
gem 'doorkeeper', '~> 4.2'
|
||||||
gem 'fast_blank', '~> 1.0'
|
gem 'fast_blank', '~> 1.0'
|
||||||
gem 'goldfinger', '~> 1.2'
|
gem 'goldfinger', '~> 2.0'
|
||||||
gem 'hiredis', '~> 0.6'
|
gem 'hiredis', '~> 0.6'
|
||||||
gem 'redis-namespace', '~> 1.5'
|
gem 'redis-namespace', '~> 1.5'
|
||||||
gem 'htmlentities', '~> 4.3'
|
gem 'htmlentities', '~> 4.3'
|
||||||
gem 'http', '~> 2.2'
|
gem 'http', '~> 2.2'
|
||||||
gem 'http_accept_language', '~> 2.1'
|
gem 'http_accept_language', '~> 2.1'
|
||||||
gem 'httplog', '~> 0.99'
|
gem 'httplog', '~> 0.99'
|
||||||
|
gem 'idn-ruby', require: 'idn'
|
||||||
gem 'kaminari', '~> 1.0'
|
gem 'kaminari', '~> 1.0'
|
||||||
gem 'link_header', '~> 0.0'
|
gem 'link_header', '~> 0.0'
|
||||||
|
gem 'mime-types', '~> 3.1'
|
||||||
gem 'nokogiri', '~> 1.7'
|
gem 'nokogiri', '~> 1.7'
|
||||||
gem 'oj', '~> 3.0'
|
gem 'oj', '~> 3.0'
|
||||||
gem 'ostatus2', '~> 2.0'
|
gem 'ostatus2', '~> 2.0'
|
||||||
@@ -46,6 +51,7 @@ gem 'rack-timeout', '~> 0.4'
|
|||||||
gem 'rails-i18n', '~> 5.0'
|
gem 'rails-i18n', '~> 5.0'
|
||||||
gem 'rails-settings-cached', '~> 0.6'
|
gem 'rails-settings-cached', '~> 0.6'
|
||||||
gem 'redis', '~> 3.3', require: ['redis', 'redis/connection/hiredis']
|
gem 'redis', '~> 3.3', require: ['redis', 'redis/connection/hiredis']
|
||||||
|
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
|
||||||
gem 'rqrcode', '~> 0.10'
|
gem 'rqrcode', '~> 0.10'
|
||||||
gem 'ruby-oembed', '~> 0.12', require: 'oembed'
|
gem 'ruby-oembed', '~> 0.12', require: 'oembed'
|
||||||
gem 'sanitize', '~> 4.4'
|
gem 'sanitize', '~> 4.4'
|
||||||
@@ -60,6 +66,7 @@ gem 'statsd-instrument', '~> 2.1'
|
|||||||
gem 'twitter-text', '~> 1.14'
|
gem 'twitter-text', '~> 1.14'
|
||||||
gem 'tzinfo-data', '~> 1.2017'
|
gem 'tzinfo-data', '~> 1.2017'
|
||||||
gem 'webpacker', '~> 2.0'
|
gem 'webpacker', '~> 2.0'
|
||||||
|
gem 'webpush'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'fabrication', '~> 2.16'
|
gem 'fabrication', '~> 2.16'
|
||||||
@@ -73,7 +80,7 @@ group :test do
|
|||||||
gem 'capybara', '~> 2.14'
|
gem 'capybara', '~> 2.14'
|
||||||
gem 'climate_control', '~> 0.2'
|
gem 'climate_control', '~> 0.2'
|
||||||
gem 'faker', '~> 1.7'
|
gem 'faker', '~> 1.7'
|
||||||
gem 'microformats2', '~> 3.0'
|
gem 'microformats', '~> 4.0'
|
||||||
gem 'rails-controller-testing', '~> 1.0'
|
gem 'rails-controller-testing', '~> 1.0'
|
||||||
gem 'rspec-sidekiq', '~> 3.0'
|
gem 'rspec-sidekiq', '~> 3.0'
|
||||||
gem 'simplecov', '~> 0.14', require: false
|
gem 'simplecov', '~> 0.14', require: false
|
||||||
|
|||||||
154
Gemfile.lock
154
Gemfile.lock
@@ -1,47 +1,52 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actioncable (5.1.1)
|
actioncable (5.1.2)
|
||||||
actionpack (= 5.1.1)
|
actionpack (= 5.1.2)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (~> 0.6.1)
|
websocket-driver (~> 0.6.1)
|
||||||
actionmailer (5.1.1)
|
actionmailer (5.1.2)
|
||||||
actionpack (= 5.1.1)
|
actionpack (= 5.1.2)
|
||||||
actionview (= 5.1.1)
|
actionview (= 5.1.2)
|
||||||
activejob (= 5.1.1)
|
activejob (= 5.1.2)
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
actionpack (5.1.1)
|
actionpack (5.1.2)
|
||||||
actionview (= 5.1.1)
|
actionview (= 5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
rack-test (~> 0.6.3)
|
rack-test (~> 0.6.3)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
actionview (5.1.1)
|
actionview (5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||||
|
active_model_serializers (0.10.6)
|
||||||
|
actionpack (>= 4.1, < 6)
|
||||||
|
activemodel (>= 4.1, < 6)
|
||||||
|
case_transform (>= 0.2)
|
||||||
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.2)
|
||||||
active_record_query_trace (1.5.4)
|
active_record_query_trace (1.5.4)
|
||||||
activejob (5.1.1)
|
activejob (5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (5.1.1)
|
activemodel (5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
activerecord (5.1.1)
|
activerecord (5.1.2)
|
||||||
activemodel (= 5.1.1)
|
activemodel (= 5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
arel (~> 8.0)
|
arel (~> 8.0)
|
||||||
activesupport (5.1.1)
|
activesupport (5.1.2)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.5.1)
|
addressable (2.5.1)
|
||||||
public_suffix (~> 2.0, >= 2.0.2)
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
airbrussh (1.2.0)
|
airbrussh (1.3.0)
|
||||||
sshkit (>= 1.6.1, != 1.7.0)
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
annotate (2.7.2)
|
annotate (2.7.2)
|
||||||
activerecord (>= 3.2, < 6.0)
|
activerecord (>= 3.2, < 6.0)
|
||||||
@@ -52,13 +57,13 @@ GEM
|
|||||||
encryptor (~> 3.0.0)
|
encryptor (~> 3.0.0)
|
||||||
av (0.9.0)
|
av (0.9.0)
|
||||||
cocaine (~> 0.5.3)
|
cocaine (~> 0.5.3)
|
||||||
aws-sdk (2.9.37)
|
aws-sdk (2.10.6)
|
||||||
aws-sdk-resources (= 2.9.37)
|
aws-sdk-resources (= 2.10.6)
|
||||||
aws-sdk-core (2.9.37)
|
aws-sdk-core (2.10.6)
|
||||||
aws-sigv4 (~> 1.0)
|
aws-sigv4 (~> 1.0)
|
||||||
jmespath (~> 1.0)
|
jmespath (~> 1.0)
|
||||||
aws-sdk-resources (2.9.37)
|
aws-sdk-resources (2.10.6)
|
||||||
aws-sdk-core (= 2.9.37)
|
aws-sdk-core (= 2.10.6)
|
||||||
aws-sigv4 (1.0.0)
|
aws-sigv4 (1.0.0)
|
||||||
bcrypt (3.1.11)
|
bcrypt (3.1.11)
|
||||||
better_errors (2.1.1)
|
better_errors (2.1.1)
|
||||||
@@ -67,9 +72,10 @@ GEM
|
|||||||
rack (>= 0.9.0)
|
rack (>= 0.9.0)
|
||||||
binding_of_caller (0.7.2)
|
binding_of_caller (0.7.2)
|
||||||
debug_inspector (>= 0.0.1)
|
debug_inspector (>= 0.0.1)
|
||||||
bootsnap (1.0.0)
|
bootsnap (1.1.1)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
brakeman (3.6.2)
|
brakeman (3.6.2)
|
||||||
|
browser (2.4.0)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
bullet (5.5.1)
|
bullet (5.5.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
@@ -77,7 +83,7 @@ GEM
|
|||||||
bundler-audit (0.5.0)
|
bundler-audit (0.5.0)
|
||||||
bundler (~> 1.2)
|
bundler (~> 1.2)
|
||||||
thor (~> 0.18)
|
thor (~> 0.18)
|
||||||
capistrano (3.8.1)
|
capistrano (3.8.2)
|
||||||
airbrussh (>= 1.0.0)
|
airbrussh (>= 1.0.0)
|
||||||
i18n
|
i18n
|
||||||
rake (>= 10.0.0)
|
rake (>= 10.0.0)
|
||||||
@@ -93,15 +99,18 @@ GEM
|
|||||||
sshkit (~> 1.3)
|
sshkit (~> 1.3)
|
||||||
capistrano-yarn (2.0.2)
|
capistrano-yarn (2.0.2)
|
||||||
capistrano (~> 3.0)
|
capistrano (~> 3.0)
|
||||||
capybara (2.14.2)
|
capybara (2.14.4)
|
||||||
addressable
|
addressable
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (~> 2.0)
|
xpath (~> 2.0)
|
||||||
|
case_transform (0.2)
|
||||||
|
activesupport
|
||||||
|
charlock_holmes (0.7.3)
|
||||||
chunky_png (1.3.8)
|
chunky_png (1.3.8)
|
||||||
cld3 (3.1.2)
|
cld3 (3.1.3)
|
||||||
ffi (>= 1.1.0, < 1.10.0)
|
ffi (>= 1.1.0, < 1.10.0)
|
||||||
climate_control (0.2.0)
|
climate_control (0.2.0)
|
||||||
cocaine (0.5.8)
|
cocaine (0.5.8)
|
||||||
@@ -141,9 +150,9 @@ GEM
|
|||||||
thread
|
thread
|
||||||
thread_safe
|
thread_safe
|
||||||
encryptor (3.0.0)
|
encryptor (3.0.0)
|
||||||
erubi (1.6.0)
|
erubi (1.6.1)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
et-orbi (1.0.4)
|
et-orbi (1.0.5)
|
||||||
tzinfo
|
tzinfo
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
fabrication (2.16.1)
|
fabrication (2.16.1)
|
||||||
@@ -156,11 +165,12 @@ GEM
|
|||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.4)
|
||||||
globalid (0.4.0)
|
globalid (0.4.0)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
goldfinger (1.2.0)
|
goldfinger (2.0.0)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.5)
|
||||||
http (~> 2.0)
|
http (~> 2.2)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.8)
|
||||||
hamlit (2.8.1)
|
oj (~> 3.0)
|
||||||
|
hamlit (2.8.4)
|
||||||
temple (>= 0.8.0)
|
temple (>= 0.8.0)
|
||||||
thor
|
thor
|
||||||
tilt
|
tilt
|
||||||
@@ -172,6 +182,7 @@ GEM
|
|||||||
hashdiff (0.3.4)
|
hashdiff (0.3.4)
|
||||||
highline (1.7.8)
|
highline (1.7.8)
|
||||||
hiredis (0.6.1)
|
hiredis (0.6.1)
|
||||||
|
hkdf (0.3.0)
|
||||||
htmlentities (4.3.4)
|
htmlentities (4.3.4)
|
||||||
http (2.2.2)
|
http (2.2.2)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
@@ -181,9 +192,9 @@ GEM
|
|||||||
http-cookie (1.0.3)
|
http-cookie (1.0.3)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http-form_data (1.0.3)
|
http-form_data (1.0.3)
|
||||||
http_accept_language (2.1.0)
|
http_accept_language (2.1.1)
|
||||||
http_parser.rb (0.6.0)
|
http_parser.rb (0.6.0)
|
||||||
httplog (0.99.3)
|
httplog (0.99.4)
|
||||||
colorize
|
colorize
|
||||||
rack
|
rack
|
||||||
i18n (0.8.4)
|
i18n (0.8.4)
|
||||||
@@ -197,8 +208,11 @@ GEM
|
|||||||
parser (>= 2.2.3.0)
|
parser (>= 2.2.3.0)
|
||||||
rainbow (~> 2.2)
|
rainbow (~> 2.2)
|
||||||
terminal-table (>= 1.5.1)
|
terminal-table (>= 1.5.1)
|
||||||
|
idn-ruby (0.1.0)
|
||||||
jmespath (1.3.1)
|
jmespath (1.3.1)
|
||||||
json (2.1.0)
|
json (2.1.0)
|
||||||
|
jsonapi-renderer (0.1.2)
|
||||||
|
jwt (1.5.6)
|
||||||
kaminari (1.0.1)
|
kaminari (1.0.1)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
kaminari-actionview (= 1.0.1)
|
kaminari-actionview (= 1.0.1)
|
||||||
@@ -228,8 +242,10 @@ GEM
|
|||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
mail (2.6.6)
|
mail (2.6.6)
|
||||||
mime-types (>= 1.16, < 4)
|
mime-types (>= 1.16, < 4)
|
||||||
|
mario-redis-lock (1.2.0)
|
||||||
|
redis (~> 3, >= 3.0.5)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
microformats2 (3.1.0)
|
microformats (4.0.7)
|
||||||
json
|
json
|
||||||
nokogiri
|
nokogiri
|
||||||
mime-types (3.1)
|
mime-types (3.1)
|
||||||
@@ -248,8 +264,8 @@ GEM
|
|||||||
mini_portile2 (~> 2.2.0)
|
mini_portile2 (~> 2.2.0)
|
||||||
nokogumbo (1.4.13)
|
nokogumbo (1.4.13)
|
||||||
nokogiri
|
nokogiri
|
||||||
oj (3.1.0)
|
oj (3.2.0)
|
||||||
openssl (2.0.3)
|
openssl (2.0.4)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
ostatus2 (2.0.1)
|
ostatus2 (2.0.1)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
@@ -271,7 +287,7 @@ GEM
|
|||||||
parallel
|
parallel
|
||||||
parser (2.4.0.0)
|
parser (2.4.0.0)
|
||||||
ast (~> 2.2)
|
ast (~> 2.2)
|
||||||
pg (0.20.0)
|
pg (0.21.0)
|
||||||
pghero (1.7.0)
|
pghero (1.7.0)
|
||||||
activerecord
|
activerecord
|
||||||
pkg-config (1.2.3)
|
pkg-config (1.2.3)
|
||||||
@@ -297,17 +313,17 @@ GEM
|
|||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rack-timeout (0.4.2)
|
rack-timeout (0.4.2)
|
||||||
rails (5.1.1)
|
rails (5.1.2)
|
||||||
actioncable (= 5.1.1)
|
actioncable (= 5.1.2)
|
||||||
actionmailer (= 5.1.1)
|
actionmailer (= 5.1.2)
|
||||||
actionpack (= 5.1.1)
|
actionpack (= 5.1.2)
|
||||||
actionview (= 5.1.1)
|
actionview (= 5.1.2)
|
||||||
activejob (= 5.1.1)
|
activejob (= 5.1.2)
|
||||||
activemodel (= 5.1.1)
|
activemodel (= 5.1.2)
|
||||||
activerecord (= 5.1.1)
|
activerecord (= 5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
bundler (>= 1.3.0, < 2.0)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
railties (= 5.1.1)
|
railties (= 5.1.2)
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-controller-testing (1.0.2)
|
rails-controller-testing (1.0.2)
|
||||||
actionpack (~> 5.x, >= 5.0.1)
|
actionpack (~> 5.x, >= 5.0.1)
|
||||||
@@ -323,9 +339,9 @@ GEM
|
|||||||
railties (~> 5.0)
|
railties (~> 5.0)
|
||||||
rails-settings-cached (0.6.5)
|
rails-settings-cached (0.6.5)
|
||||||
rails (>= 4.2.0)
|
rails (>= 4.2.0)
|
||||||
railties (5.1.1)
|
railties (5.1.2)
|
||||||
actionpack (= 5.1.1)
|
actionpack (= 5.1.2)
|
||||||
activesupport (= 5.1.1)
|
activesupport (= 5.1.2)
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
@@ -373,7 +389,7 @@ GEM
|
|||||||
rspec-expectations (~> 3.6.0)
|
rspec-expectations (~> 3.6.0)
|
||||||
rspec-mocks (~> 3.6.0)
|
rspec-mocks (~> 3.6.0)
|
||||||
rspec-support (~> 3.6.0)
|
rspec-support (~> 3.6.0)
|
||||||
rspec-sidekiq (3.0.1)
|
rspec-sidekiq (3.0.3)
|
||||||
rspec-core (~> 3.0, >= 3.0.0)
|
rspec-core (~> 3.0, >= 3.0.0)
|
||||||
sidekiq (>= 2.4.0)
|
sidekiq (>= 2.4.0)
|
||||||
rspec-support (3.6.0)
|
rspec-support (3.6.0)
|
||||||
@@ -394,10 +410,10 @@ GEM
|
|||||||
nokogiri (>= 1.4.4)
|
nokogiri (>= 1.4.4)
|
||||||
nokogumbo (~> 1.4.1)
|
nokogumbo (~> 1.4.1)
|
||||||
sass (3.4.24)
|
sass (3.4.24)
|
||||||
scss_lint (0.53.0)
|
scss_lint (0.54.0)
|
||||||
rake (>= 0.9, < 13)
|
rake (>= 0.9, < 13)
|
||||||
sass (~> 3.4.20)
|
sass (~> 3.4.20)
|
||||||
sidekiq (5.0.2)
|
sidekiq (5.0.3)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
connection_pool (~> 2.2, >= 2.2.0)
|
connection_pool (~> 2.2, >= 2.2.0)
|
||||||
rack-protection (>= 1.5.0)
|
rack-protection (>= 1.5.0)
|
||||||
@@ -405,7 +421,7 @@ GEM
|
|||||||
sidekiq-bulk (0.1.1)
|
sidekiq-bulk (0.1.1)
|
||||||
activesupport
|
activesupport
|
||||||
sidekiq
|
sidekiq
|
||||||
sidekiq-scheduler (2.1.5)
|
sidekiq-scheduler (2.1.7)
|
||||||
redis (~> 3)
|
redis (~> 3)
|
||||||
rufus-scheduler (~> 3.2)
|
rufus-scheduler (~> 3.2)
|
||||||
sidekiq (>= 3)
|
sidekiq (>= 3)
|
||||||
@@ -442,7 +458,7 @@ GEM
|
|||||||
thread (0.2.2)
|
thread (0.2.2)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.7)
|
tilt (2.0.7)
|
||||||
twitter-text (1.14.5)
|
twitter-text (1.14.6)
|
||||||
unf (~> 0.1.0)
|
unf (~> 0.1.0)
|
||||||
tzinfo (1.2.3)
|
tzinfo (1.2.3)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
@@ -453,7 +469,7 @@ GEM
|
|||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.4)
|
unf_ext (0.0.7.4)
|
||||||
unicode-display_width (1.2.1)
|
unicode-display_width (1.3.0)
|
||||||
uniform_notifier (1.10.0)
|
uniform_notifier (1.10.0)
|
||||||
warden (1.2.7)
|
warden (1.2.7)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
@@ -465,6 +481,9 @@ GEM
|
|||||||
activesupport (>= 4.2)
|
activesupport (>= 4.2)
|
||||||
multi_json (~> 1.2)
|
multi_json (~> 1.2)
|
||||||
railties (>= 4.2)
|
railties (>= 4.2)
|
||||||
|
webpush (0.3.2)
|
||||||
|
hkdf (~> 0.2)
|
||||||
|
jwt
|
||||||
websocket-driver (0.6.5)
|
websocket-driver (0.6.5)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.2)
|
websocket-extensions (0.1.2)
|
||||||
@@ -475,6 +494,7 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
active_model_serializers (~> 0.10)
|
||||||
active_record_query_trace (~> 1.5)
|
active_record_query_trace (~> 1.5)
|
||||||
addressable (~> 2.5)
|
addressable (~> 2.5)
|
||||||
annotate (~> 2.7)
|
annotate (~> 2.7)
|
||||||
@@ -483,6 +503,7 @@ DEPENDENCIES
|
|||||||
binding_of_caller (~> 0.7)
|
binding_of_caller (~> 0.7)
|
||||||
bootsnap
|
bootsnap
|
||||||
brakeman (~> 3.6)
|
brakeman (~> 3.6)
|
||||||
|
browser
|
||||||
bullet (~> 5.5)
|
bullet (~> 5.5)
|
||||||
bundler-audit (~> 0.5)
|
bundler-audit (~> 0.5)
|
||||||
capistrano (~> 3.8)
|
capistrano (~> 3.8)
|
||||||
@@ -490,6 +511,7 @@ DEPENDENCIES
|
|||||||
capistrano-rbenv (~> 2.1)
|
capistrano-rbenv (~> 2.1)
|
||||||
capistrano-yarn (~> 2.0)
|
capistrano-yarn (~> 2.0)
|
||||||
capybara (~> 2.14)
|
capybara (~> 2.14)
|
||||||
|
charlock_holmes (~> 0.7.3)
|
||||||
cld3 (~> 3.1)
|
cld3 (~> 3.1)
|
||||||
climate_control (~> 0.2)
|
climate_control (~> 0.2)
|
||||||
devise (~> 4.2)
|
devise (~> 4.2)
|
||||||
@@ -500,7 +522,7 @@ DEPENDENCIES
|
|||||||
faker (~> 1.7)
|
faker (~> 1.7)
|
||||||
fast_blank (~> 1.0)
|
fast_blank (~> 1.0)
|
||||||
fuubar (~> 2.2)
|
fuubar (~> 2.2)
|
||||||
goldfinger (~> 1.2)
|
goldfinger (~> 2.0)
|
||||||
hamlit-rails (~> 0.2)
|
hamlit-rails (~> 0.2)
|
||||||
hiredis (~> 0.6)
|
hiredis (~> 0.6)
|
||||||
htmlentities (~> 4.3)
|
htmlentities (~> 4.3)
|
||||||
@@ -508,12 +530,15 @@ DEPENDENCIES
|
|||||||
http_accept_language (~> 2.1)
|
http_accept_language (~> 2.1)
|
||||||
httplog (~> 0.99)
|
httplog (~> 0.99)
|
||||||
i18n-tasks (~> 0.9)
|
i18n-tasks (~> 0.9)
|
||||||
|
idn-ruby
|
||||||
kaminari (~> 1.0)
|
kaminari (~> 1.0)
|
||||||
letter_opener (~> 1.4)
|
letter_opener (~> 1.4)
|
||||||
letter_opener_web (~> 1.3)
|
letter_opener_web (~> 1.3)
|
||||||
link_header (~> 0.0)
|
link_header (~> 0.0)
|
||||||
lograge (~> 0.5)
|
lograge (~> 0.5)
|
||||||
microformats2 (~> 3.0)
|
mario-redis-lock (~> 1.2)
|
||||||
|
microformats (~> 4.0)
|
||||||
|
mime-types (~> 3.1)
|
||||||
nokogiri (~> 1.7)
|
nokogiri (~> 1.7)
|
||||||
oj (~> 3.0)
|
oj (~> 3.0)
|
||||||
ostatus2 (~> 2.0)
|
ostatus2 (~> 2.0)
|
||||||
@@ -559,9 +584,10 @@ DEPENDENCIES
|
|||||||
uglifier (~> 3.2)
|
uglifier (~> 3.2)
|
||||||
webmock (~> 3.0)
|
webmock (~> 3.0)
|
||||||
webpacker (~> 2.0)
|
webpacker (~> 2.0)
|
||||||
|
webpush
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.4.1p111
|
ruby 2.4.1p111
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.15.1
|
1.15.2
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -1,5 +1,11 @@
|
|||||||
Mastodon Glitch Edition
|
# Mastodon Glitch Edition #
|
||||||
========
|
|
||||||
Now with automated deploys!
|
> Now with automated deploys!
|
||||||
|
|
||||||
|
[](https://travis-ci.org/glitch-soc/mastodon)
|
||||||
|
|
||||||
So here's the deal: we all work on this code, and then it runs on dev.glitch.social and anyone who uses that does so absolutely at their own risk. can you dig it?
|
So here's the deal: we all work on this code, and then it runs on dev.glitch.social and anyone who uses that does so absolutely at their own risk. can you dig it?
|
||||||
|
|
||||||
|
- You can view documentation for this project at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/).
|
||||||
|
- And contributing guidelines are available [here](CONTRIBUTING.md) and [here](https://glitch-soc.github.io/docs/contributing/).
|
||||||
|
|
||||||
|
|||||||
7
Vagrantfile
vendored
7
Vagrantfile
vendored
@@ -35,6 +35,8 @@ sudo apt-get install \
|
|||||||
postgresql-contrib \
|
postgresql-contrib \
|
||||||
protobuf-compiler \
|
protobuf-compiler \
|
||||||
yarn \
|
yarn \
|
||||||
|
libicu-dev \
|
||||||
|
libidn11-dev \
|
||||||
libprotobuf-dev \
|
libprotobuf-dev \
|
||||||
libreadline-dev \
|
libreadline-dev \
|
||||||
-y
|
-y
|
||||||
@@ -42,9 +44,12 @@ sudo apt-get install \
|
|||||||
# Install rvm
|
# Install rvm
|
||||||
read RUBY_VERSION < .ruby-version
|
read RUBY_VERSION < .ruby-version
|
||||||
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
||||||
curl -sSL https://get.rvm.io | bash -s stable --ruby=$RUBY_VERSION
|
curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer | bash -s stable --ruby=$RUBY_VERSION
|
||||||
source /home/vagrant/.rvm/scripts/rvm
|
source /home/vagrant/.rvm/scripts/rvm
|
||||||
|
|
||||||
|
# Install Ruby
|
||||||
|
rvm install ruby-$RUBY_VERSION
|
||||||
|
|
||||||
# Configure database
|
# Configure database
|
||||||
sudo -u postgres createuser -U postgres vagrant -s
|
sudo -u postgres createuser -U postgres vagrant -s
|
||||||
sudo -u postgres createdb -U postgres mastodon_development
|
sudo -u postgres createdb -U postgres mastodon_development
|
||||||
|
|||||||
2
app.json
2
app.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "Mastodon",
|
"name": "Mastodon",
|
||||||
"description": "A GNU Social-compatible microblogging server",
|
"description": "A GNU Social-compatible microblogging server",
|
||||||
"repository": "https://github.com/tootsuite/mastodon",
|
"repository": "https://github.com/tootsuite/mastodon",
|
||||||
"logo": "https://github.com/tootsuite/mastodon/raw/master/app/assets/images/logo.png",
|
"logo": "https://github.com/tootsuite/mastodon/raw/master/app/javascript/images/logo.svg",
|
||||||
"env": {
|
"env": {
|
||||||
"HEROKU": {
|
"HEROKU": {
|
||||||
"description": "Leave this as true",
|
"description": "Leave this as true",
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
class AboutController < ApplicationController
|
class AboutController < ApplicationController
|
||||||
before_action :set_body_classes
|
before_action :set_body_classes
|
||||||
before_action :set_instance_presenter, only: [:show, :more]
|
before_action :set_instance_presenter, only: [:show, :more, :terms]
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
|
||||||
|
@initial_state_json = serializable_resource.to_json
|
||||||
|
end
|
||||||
|
|
||||||
def more; end
|
def more; end
|
||||||
|
|
||||||
@@ -15,6 +18,7 @@ class AboutController < ApplicationController
|
|||||||
def new_user
|
def new_user
|
||||||
User.new.tap(&:build_account)
|
User.new.tap(&:build_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :new_user
|
helper_method :new_user
|
||||||
|
|
||||||
def set_instance_presenter
|
def set_instance_presenter
|
||||||
@@ -24,4 +28,11 @@ class AboutController < ApplicationController
|
|||||||
def set_body_classes
|
def set_body_classes
|
||||||
@body_classes = 'about-body'
|
@body_classes = 'about-body'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initial_state_params
|
||||||
|
{
|
||||||
|
settings: {},
|
||||||
|
token: current_session&.token,
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
class AccountsController < ApplicationController
|
class AccountsController < ApplicationController
|
||||||
include AccountControllerConcern
|
include AccountControllerConcern
|
||||||
|
include SignatureVerification
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -12,10 +13,12 @@ class AccountsController < ApplicationController
|
|||||||
|
|
||||||
format.atom do
|
format.atom do
|
||||||
@entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
@entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||||
render xml: AtomSerializer.render(AtomSerializer.new.feed(@account, @entries.to_a))
|
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.to_a))
|
||||||
end
|
end
|
||||||
|
|
||||||
format.activitystreams2
|
format.json do
|
||||||
|
render json: @account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
27
app/controllers/activitypub/outboxes_controller.rb
Normal file
27
app/controllers/activitypub/outboxes_controller.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ActivityPub::OutboxesController < Api::BaseController
|
||||||
|
before_action :set_account
|
||||||
|
|
||||||
|
def show
|
||||||
|
@statuses = @account.statuses.permitted_for(@account, current_account).paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||||
|
@statuses = cache_collection(@statuses, Status)
|
||||||
|
|
||||||
|
render json: outbox_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find_local!(params[:account_username])
|
||||||
|
end
|
||||||
|
|
||||||
|
def outbox_presenter
|
||||||
|
ActivityPub::CollectionPresenter.new(
|
||||||
|
id: account_outbox_url(@account),
|
||||||
|
type: :ordered,
|
||||||
|
size: @account.statuses_count,
|
||||||
|
items: @statuses
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -22,8 +22,8 @@ module Admin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def redownload
|
def redownload
|
||||||
@account.avatar = @account.avatar_remote_url
|
@account.reset_avatar!
|
||||||
@account.header = @account.header_remote_url
|
@account.reset_header!
|
||||||
@account.save!
|
@account.save!
|
||||||
|
|
||||||
redirect_to admin_account_path(@account.id)
|
redirect_to admin_account_path(@account.id)
|
||||||
|
|||||||
@@ -6,15 +6,26 @@ module Admin
|
|||||||
@instances = ordered_instances
|
@instances = ordered_instances
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def resubscribe
|
||||||
|
params.require(:by_domain)
|
||||||
|
Pubsubhubbub::SubscribeWorker.push_bulk(subscribeable_accounts.pluck(:id))
|
||||||
|
redirect_to admin_instances_path
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def paginated_instances
|
def paginated_instances
|
||||||
Account.remote.by_domain_accounts.page(params[:page])
|
Account.remote.by_domain_accounts.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :paginated_instances
|
helper_method :paginated_instances
|
||||||
|
|
||||||
def ordered_instances
|
def ordered_instances
|
||||||
paginated_instances.map { |account| Instance.new(account) }
|
paginated_instances.map { |account| Instance.new(account) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def subscribeable_accounts
|
||||||
|
Account.with_followers.remote.where(domain: params[:by_domain])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,14 @@ module Admin
|
|||||||
include Authorization
|
include Authorization
|
||||||
|
|
||||||
before_action :set_report
|
before_action :set_report
|
||||||
before_action :set_status
|
before_action :set_status, only: [:update, :destroy]
|
||||||
|
|
||||||
|
def create
|
||||||
|
@form = Form::StatusBatch.new(form_status_batch_params)
|
||||||
|
flash[:alert] = t('admin.statuses.failed_to_execute') unless @form.save
|
||||||
|
|
||||||
|
redirect_to admin_report_path(@report)
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@status.update(status_params)
|
@status.update(status_params)
|
||||||
@@ -15,7 +22,7 @@ module Admin
|
|||||||
def destroy
|
def destroy
|
||||||
authorize @status, :destroy?
|
authorize @status, :destroy?
|
||||||
RemovalWorker.perform_async(@status.id)
|
RemovalWorker.perform_async(@status.id)
|
||||||
redirect_to admin_report_path(@report)
|
render json: @status
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -24,6 +31,10 @@ module Admin
|
|||||||
params.require(:status).permit(:sensitive)
|
params.require(:status).permit(:sensitive)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def form_status_batch_params
|
||||||
|
params.require(:form_status_batch).permit(:action, status_ids: [])
|
||||||
|
end
|
||||||
|
|
||||||
def set_report
|
def set_report
|
||||||
@report = Report.find(params[:report_id])
|
@report = Report.find(params[:report_id])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ module Admin
|
|||||||
@reports = filtered_reports.page(params[:page])
|
@reports = filtered_reports.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@form = Form::StatusBatch.new
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
process_report
|
process_report
|
||||||
|
|||||||
@@ -8,13 +8,21 @@ module Admin
|
|||||||
site_title
|
site_title
|
||||||
site_description
|
site_description
|
||||||
site_extended_description
|
site_extended_description
|
||||||
|
site_terms
|
||||||
open_registrations
|
open_registrations
|
||||||
closed_registrations_message
|
closed_registrations_message
|
||||||
|
open_deletion
|
||||||
|
timeline_preview
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
BOOLEAN_SETTINGS = %w(
|
||||||
|
open_registrations
|
||||||
|
open_deletion
|
||||||
|
timeline_preview
|
||||||
).freeze
|
).freeze
|
||||||
BOOLEAN_SETTINGS = %w(open_registrations).freeze
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@settings = Setting.all_as_records
|
@admin_settings = Form::AdminSettings.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -23,19 +31,19 @@ module Admin
|
|||||||
setting.update(value: value_for_update(key, value))
|
setting.update(value: value_for_update(key, value))
|
||||||
end
|
end
|
||||||
|
|
||||||
flash[:notice] = 'Success!'
|
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
||||||
redirect_to edit_admin_settings_path
|
redirect_to edit_admin_settings_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def settings_params
|
def settings_params
|
||||||
params.permit(ADMIN_SETTINGS)
|
params.require(:form_admin_settings).permit(ADMIN_SETTINGS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def value_for_update(key, value)
|
def value_for_update(key, value)
|
||||||
if BOOLEAN_SETTINGS.include?(key)
|
if BOOLEAN_SETTINGS.include?(key)
|
||||||
value == 'true'
|
value == '1'
|
||||||
else
|
else
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|||||||
69
app/controllers/admin/statuses_controller.rb
Normal file
69
app/controllers/admin/statuses_controller.rb
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Admin
|
||||||
|
class StatusesController < BaseController
|
||||||
|
include Authorization
|
||||||
|
|
||||||
|
helper_method :current_params
|
||||||
|
|
||||||
|
before_action :set_account
|
||||||
|
before_action :set_status, only: [:update, :destroy]
|
||||||
|
|
||||||
|
PAR_PAGE = 20
|
||||||
|
|
||||||
|
def index
|
||||||
|
@statuses = @account.statuses
|
||||||
|
if params[:media]
|
||||||
|
account_media_status_ids = @account.media_attachments.attached.reorder(nil).select(:status_id).distinct
|
||||||
|
@statuses.merge!(Status.where(id: account_media_status_ids))
|
||||||
|
end
|
||||||
|
@statuses = @statuses.preload(:media_attachments, :mentions).page(params[:page]).per(PAR_PAGE)
|
||||||
|
|
||||||
|
@form = Form::StatusBatch.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@form = Form::StatusBatch.new(form_status_batch_params)
|
||||||
|
flash[:alert] = t('admin.statuses.failed_to_execute') unless @form.save
|
||||||
|
|
||||||
|
redirect_to admin_account_statuses_path(@account.id, current_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@status.update(status_params)
|
||||||
|
redirect_to admin_account_statuses_path(@account.id, current_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
authorize @status, :destroy?
|
||||||
|
RemovalWorker.perform_async(@status.id)
|
||||||
|
render json: @status
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def status_params
|
||||||
|
params.require(:status).permit(:sensitive)
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_status_batch_params
|
||||||
|
params.require(:form_status_batch).permit(:action, status_ids: [])
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_status
|
||||||
|
@status = @account.statuses.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find(params[:account_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_params
|
||||||
|
page = (params[:page] || 1).to_i
|
||||||
|
{
|
||||||
|
media: params[:media],
|
||||||
|
page: page > 1 && page,
|
||||||
|
}.select { |_, value| value.present? }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::ActivityPub::ActivitiesController < Api::BaseController
|
|
||||||
include Authorization
|
|
||||||
|
|
||||||
# before_action :set_follow, only: [:show_follow]
|
|
||||||
before_action :set_status, only: [:show_status]
|
|
||||||
|
|
||||||
respond_to :activitystreams2
|
|
||||||
|
|
||||||
# Show a status in AS2 format, as either an Announce (reblog) or a Create (post) activity.
|
|
||||||
def show_status
|
|
||||||
authorize @status, :show?
|
|
||||||
|
|
||||||
if @status.reblog?
|
|
||||||
render :show_status_announce
|
|
||||||
else
|
|
||||||
render :show_status_create
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_status
|
|
||||||
@status = Status.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::ActivityPub::NotesController < Api::BaseController
|
|
||||||
include Authorization
|
|
||||||
|
|
||||||
before_action :set_status
|
|
||||||
|
|
||||||
respond_to :activitystreams2
|
|
||||||
|
|
||||||
def show
|
|
||||||
authorize @status, :show?
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_status
|
|
||||||
@status = Status.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::ActivityPub::OutboxController < Api::BaseController
|
|
||||||
before_action :set_account
|
|
||||||
|
|
||||||
respond_to :activitystreams2
|
|
||||||
|
|
||||||
def show
|
|
||||||
if params[:max_id] || params[:since_id]
|
|
||||||
show_outbox_page
|
|
||||||
else
|
|
||||||
show_base_outbox
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def show_base_outbox
|
|
||||||
@statuses = Status.as_outbox_timeline(@account)
|
|
||||||
@statuses = cache_collection(@statuses)
|
|
||||||
|
|
||||||
set_maps(@statuses)
|
|
||||||
|
|
||||||
set_first_last_page(@statuses)
|
|
||||||
|
|
||||||
render :show
|
|
||||||
end
|
|
||||||
|
|
||||||
def show_outbox_page
|
|
||||||
all_statuses = Status.as_outbox_timeline(@account)
|
|
||||||
@statuses = all_statuses.paginate_by_max_id(limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id])
|
|
||||||
|
|
||||||
all_statuses = cache_collection(all_statuses)
|
|
||||||
@statuses = cache_collection(@statuses)
|
|
||||||
|
|
||||||
set_maps(@statuses)
|
|
||||||
|
|
||||||
set_first_last_page(all_statuses)
|
|
||||||
|
|
||||||
@next_page_url = api_activitypub_outbox_url(pagination_params(max_id: @statuses.last.id)) unless @statuses.empty?
|
|
||||||
@prev_page_url = api_activitypub_outbox_url(pagination_params(since_id: @statuses.first.id)) unless @statuses.empty?
|
|
||||||
|
|
||||||
@paginated = @next_page_url || @prev_page_url
|
|
||||||
@part_of_url = api_activitypub_outbox_url
|
|
||||||
|
|
||||||
set_pagination_headers(@next_page_url, @prev_page_url)
|
|
||||||
|
|
||||||
render :show_page
|
|
||||||
end
|
|
||||||
|
|
||||||
def cache_collection(raw)
|
|
||||||
super(raw, Status)
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_account
|
|
||||||
@account = Account.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_first_last_page(statuses) # rubocop:disable Style/AccessorMethodName
|
|
||||||
return if statuses.empty?
|
|
||||||
|
|
||||||
@first_page_url = api_activitypub_outbox_url(max_id: statuses.first.id + 1)
|
|
||||||
@last_page_url = api_activitypub_outbox_url(since_id: statuses.last.id - 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
|
||||||
params.permit(:local, :limit).merge(core_params)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -17,11 +17,7 @@ class Api::BaseController < ApplicationController
|
|||||||
render json: { error: 'Record not found' }, status: 404
|
render json: { error: 'Record not found' }, status: 404
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from Goldfinger::Error do
|
rescue_from HTTP::Error, Mastodon::UnexpectedResponseError do
|
||||||
render json: { error: 'Remote account could not be resolved' }, status: 422
|
|
||||||
end
|
|
||||||
|
|
||||||
rescue_from HTTP::Error do
|
|
||||||
render json: { error: 'Remote data could not be fetched' }, status: 503
|
render json: { error: 'Remote data could not be fetched' }, status: 503
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ class Api::OEmbedController < Api::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@stream_entry = find_stream_entry.stream_entry
|
@stream_entry = find_stream_entry.stream_entry
|
||||||
@width = maxwidth_or_default
|
render json: @stream_entry, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default
|
||||||
@height = maxheight_or_default
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::PushController < Api::BaseController
|
class Api::PushController < Api::BaseController
|
||||||
|
include SignatureVerification
|
||||||
|
|
||||||
def update
|
def update
|
||||||
response, status = process_push_request
|
response, status = process_push_request
|
||||||
render plain: response, status: status
|
render plain: response, status: status
|
||||||
@@ -11,7 +13,7 @@ class Api::PushController < Api::BaseController
|
|||||||
def process_push_request
|
def process_push_request
|
||||||
case hub_mode
|
case hub_mode
|
||||||
when 'subscribe'
|
when 'subscribe'
|
||||||
Pubsubhubbub::SubscribeService.new.call(account_from_topic, hub_callback, hub_secret, hub_lease_seconds)
|
Pubsubhubbub::SubscribeService.new.call(account_from_topic, hub_callback, hub_secret, hub_lease_seconds, verified_domain)
|
||||||
when 'unsubscribe'
|
when 'unsubscribe'
|
||||||
Pubsubhubbub::UnsubscribeService.new.call(account_from_topic, hub_callback)
|
Pubsubhubbub::UnsubscribeService.new.call(account_from_topic, hub_callback)
|
||||||
else
|
else
|
||||||
@@ -57,6 +59,10 @@ class Api::PushController < Api::BaseController
|
|||||||
TagManager.instance.web_domain?(hub_topic_domain)
|
TagManager.instance.web_domain?(hub_topic_domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def verified_domain
|
||||||
|
return signed_request_account.domain if signed_request_account
|
||||||
|
end
|
||||||
|
|
||||||
def hub_topic_domain
|
def hub_topic_domain
|
||||||
hub_topic_uri.host + (hub_topic_uri.port ? ":#{hub_topic_uri.port}" : '')
|
hub_topic_uri.host + (hub_topic_uri.port ? ":#{hub_topic_uri.port}" : '')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Api::SubscriptionsController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lease_seconds_or_default
|
def lease_seconds_or_default
|
||||||
(params['hub.lease_seconds'] || 86_400).to_i.seconds
|
(params['hub.lease_seconds'] || 1.day).to_i.seconds
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@account = current_account
|
@account = current_account
|
||||||
render 'api/v1/accounts/show'
|
render json: @account, serializer: REST::CredentialAccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
current_account.update!(account_params)
|
current_account.update!(account_params)
|
||||||
@account = current_account
|
@account = current_account
|
||||||
render 'api/v1/accounts/show'
|
render json: @account, serializer: REST::CredentialAccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render 'api/v1/accounts/index'
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render 'api/v1/accounts/index'
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -8,16 +8,15 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = Account.where(id: account_ids).select('id')
|
@accounts = Account.where(id: account_ids).select('id')
|
||||||
@following = Account.following_map(account_ids, current_user.account_id)
|
render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
@followed_by = Account.followed_by_map(account_ids, current_user.account_id)
|
|
||||||
@blocking = Account.blocking_map(account_ids, current_user.account_id)
|
|
||||||
@muting = Account.muting_map(account_ids, current_user.account_id)
|
|
||||||
@requested = Account.requested_map(account_ids, current_user.account_id)
|
|
||||||
@domain_blocking = Account.domain_blocking_map(account_ids, current_user.account_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def relationships
|
||||||
|
AccountRelationshipsPresenter.new(@accounts, current_user.account_id)
|
||||||
|
end
|
||||||
|
|
||||||
def account_ids
|
def account_ids
|
||||||
@_account_ids ||= Array(params[:id]).map(&:to_i)
|
@_account_ids ||= Array(params[:id]).map(&:to_i)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ class Api::V1::Accounts::SearchController < Api::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@accounts = account_search
|
@accounts = account_search
|
||||||
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
render 'api/v1/accounts/index'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@statuses = load_statuses
|
@statuses = load_statuses
|
||||||
|
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -18,9 +19,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
cached_account_statuses.tap do |statuses|
|
cached_account_statuses
|
||||||
set_maps(statuses)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_account_statuses
|
def cached_account_statuses
|
||||||
|
|||||||
@@ -8,49 +8,38 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
render json: @account, serializer: REST::AccountSerializer
|
||||||
|
end
|
||||||
|
|
||||||
def follow
|
def follow
|
||||||
FollowService.new.call(current_user.account, @account.acct)
|
FollowService.new.call(current_user.account, @account.acct)
|
||||||
set_relationship
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
render :relationship
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def block
|
def block
|
||||||
BlockService.new.call(current_user.account, @account)
|
BlockService.new.call(current_user.account, @account)
|
||||||
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
@following = { @account.id => false }
|
|
||||||
@followed_by = { @account.id => false }
|
|
||||||
@blocking = { @account.id => true }
|
|
||||||
@requested = { @account.id => false }
|
|
||||||
@muting = { @account.id => current_account.muting?(@account.id) }
|
|
||||||
@domain_blocking = { @account.id => current_account.domain_blocking?(@account.domain) }
|
|
||||||
|
|
||||||
render :relationship
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def mute
|
def mute
|
||||||
MuteService.new.call(current_user.account, @account)
|
MuteService.new.call(current_user.account, @account)
|
||||||
set_relationship
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
render :relationship
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def unfollow
|
def unfollow
|
||||||
UnfollowService.new.call(current_user.account, @account)
|
UnfollowService.new.call(current_user.account, @account)
|
||||||
set_relationship
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
render :relationship
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def unblock
|
def unblock
|
||||||
UnblockService.new.call(current_user.account, @account)
|
UnblockService.new.call(current_user.account, @account)
|
||||||
set_relationship
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
render :relationship
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def unmute
|
def unmute
|
||||||
UnmuteService.new.call(current_user.account, @account)
|
UnmuteService.new.call(current_user.account, @account)
|
||||||
set_relationship
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
render :relationship
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -59,12 +48,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
@account = Account.find(params[:id])
|
@account = Account.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_relationship
|
def relationships
|
||||||
@following = Account.following_map([@account.id], current_user.account_id)
|
AccountRelationshipsPresenter.new([@account.id], current_user.account_id)
|
||||||
@followed_by = Account.followed_by_map([@account.id], current_user.account_id)
|
|
||||||
@blocking = Account.blocking_map([@account.id], current_user.account_id)
|
|
||||||
@muting = Account.muting_map([@account.id], current_user.account_id)
|
|
||||||
@requested = Account.requested_map([@account.id], current_user.account_id)
|
|
||||||
@domain_blocking = Account.domain_blocking_map([@account.id], current_user.account_id)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class Api::V1::AppsController < Api::BaseController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@app = Doorkeeper::Application.create!(application_options)
|
@app = Doorkeeper::Application.create!(application_options)
|
||||||
|
render json: @app, serializer: REST::ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Api::V1::BlocksController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -9,21 +9,18 @@ class Api::V1::FavouritesController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@statuses = load_statuses
|
@statuses = load_statuses
|
||||||
|
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
cached_favourites.tap do |statuses|
|
cached_favourites
|
||||||
set_maps(statuses)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_favourites
|
def cached_favourites
|
||||||
cache_collection(
|
cache_collection(
|
||||||
Status.where(
|
Status.reorder(nil).joins(:favourites).merge(results),
|
||||||
id: results.map(&:status_id)
|
|
||||||
),
|
|
||||||
Status
|
Status
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class Api::V1::FollowRequestsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorize
|
def authorize
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Api::V1::FollowsController < Api::BaseController
|
|||||||
raise ActiveRecord::RecordNotFound if follow_params[:uri].blank?
|
raise ActiveRecord::RecordNotFound if follow_params[:uri].blank?
|
||||||
|
|
||||||
@account = FollowService.new.call(current_user.account, target_uri).try(:target_account)
|
@account = FollowService.new.call(current_user.account, target_uri).try(:target_account)
|
||||||
render :show
|
render json: @account, serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -3,5 +3,7 @@
|
|||||||
class Api::V1::InstancesController < Api::BaseController
|
class Api::V1::InstancesController < Api::BaseController
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
render json: {}, serializer: REST::InstanceSerializer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class Api::V1::MediaController < Api::BaseController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@media = current_account.media_attachments.create!(file: media_params[:file])
|
@media = current_account.media_attachments.create!(file: media_params[:file])
|
||||||
|
render json: @media, serializer: REST::MediaAttachmentSerializer
|
||||||
rescue Paperclip::Errors::NotIdentifiedByImageMagickError
|
rescue Paperclip::Errors::NotIdentifiedByImageMagickError
|
||||||
render json: file_type_error, status: 422
|
render json: file_type_error, status: 422
|
||||||
rescue Paperclip::Error
|
rescue Paperclip::Error
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Api::V1::MutesController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@notifications = load_notifications
|
@notifications = load_notifications
|
||||||
set_maps_for_notification_target_statuses
|
render json: @notifications, each_serializer: REST::NotificationSerializer, relationships: StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@notification = current_account.notifications.find(params[:id])
|
@notification = current_account.notifications.find(params[:id])
|
||||||
|
render json: @notification, serializer: REST::NotificationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear
|
def clear
|
||||||
@@ -23,11 +24,20 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
dismiss
|
||||||
|
end
|
||||||
|
|
||||||
def dismiss
|
def dismiss
|
||||||
current_account.notifications.find_by!(id: params[:id]).destroy!
|
current_account.notifications.find_by!(id: params[:id]).destroy!
|
||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy_multiple
|
||||||
|
current_account.notifications.where(id: params[:ids]).destroy_all
|
||||||
|
render_empty
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_notifications
|
def load_notifications
|
||||||
@@ -46,10 +56,6 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||||||
current_account.notifications.browserable(exclude_types)
|
current_account.notifications.browserable(exclude_types)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_maps_for_notification_target_statuses
|
|
||||||
set_maps target_statuses_from_notifications
|
|
||||||
end
|
|
||||||
|
|
||||||
def target_statuses_from_notifications
|
def target_statuses_from_notifications
|
||||||
@notifications.reject { |notification| notification.target_status.nil? }.map(&:target_status)
|
@notifications.reject { |notification| notification.target_status.nil? }.map(&:target_status)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Api::V1::ReportsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@reports = current_account.reports
|
@reports = current_account.reports
|
||||||
|
render json: @reports, each_serializer: REST::ReportSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -17,7 +18,10 @@ class Api::V1::ReportsController < Api::BaseController
|
|||||||
status_ids: reported_status_ids,
|
status_ids: reported_status_ids,
|
||||||
comment: report_params[:comment]
|
comment: report_params[:comment]
|
||||||
)
|
)
|
||||||
render :show
|
|
||||||
|
User.admins.includes(:account).each { |u| AdminMailer.new_report(u.account, @report).deliver_later }
|
||||||
|
|
||||||
|
render json: @report, serializer: REST::ReportSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::SearchController < Api::BaseController
|
class Api::V1::SearchController < Api::BaseController
|
||||||
RESULTS_LIMIT = 5
|
RESULTS_LIMIT = 10
|
||||||
|
|
||||||
|
before_action -> { doorkeeper_authorize! :read }
|
||||||
|
before_action :require_user!
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search = OpenStruct.new(search_results)
|
@search = Search.new(search_results)
|
||||||
|
render json: @search, serializer: REST::SearchSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render 'api/v1/statuses/accounts'
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@status = favourited_status
|
@status = favourited_status
|
||||||
render 'api/v1/statuses/show'
|
render json: @status, serializer: REST::StatusSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@@ -19,7 +19,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
|
|||||||
|
|
||||||
UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
|
UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
|
||||||
|
|
||||||
render 'api/v1/statuses/show'
|
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ class Api::V1::Statuses::MutesController < Api::BaseController
|
|||||||
current_account.mute_conversation!(@conversation)
|
current_account.mute_conversation!(@conversation)
|
||||||
@mutes_map = { @conversation.id => true }
|
@mutes_map = { @conversation.id => true }
|
||||||
|
|
||||||
render 'api/v1/statuses/show'
|
render json: @status, serializer: REST::StatusSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
current_account.unmute_conversation!(@conversation)
|
current_account.unmute_conversation!(@conversation)
|
||||||
@mutes_map = { @conversation.id => false }
|
@mutes_map = { @conversation.id => false }
|
||||||
|
|
||||||
render 'api/v1/statuses/show'
|
render json: @status, serializer: REST::StatusSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render 'api/v1/statuses/accounts'
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@status = ReblogService.new.call(current_user.account, status_for_reblog)
|
@status = ReblogService.new.call(current_user.account, status_for_reblog)
|
||||||
render 'api/v1/statuses/show'
|
render json: @status, serializer: REST::StatusSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@@ -20,7 +20,7 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
|
|||||||
authorize status_for_destroy, :unreblog?
|
authorize status_for_destroy, :unreblog?
|
||||||
RemovalWorker.perform_async(status_for_destroy.id)
|
RemovalWorker.perform_async(status_for_destroy.id)
|
||||||
|
|
||||||
render 'api/v1/statuses/show'
|
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Api::V1::StatusesController < Api::BaseController
|
|||||||
def show
|
def show
|
||||||
cached = Rails.cache.read(@status.cache_key)
|
cached = Rails.cache.read(@status.cache_key)
|
||||||
@status = cached unless cached.nil?
|
@status = cached unless cached.nil?
|
||||||
|
render json: @status, serializer: REST::StatusSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def context
|
def context
|
||||||
@@ -21,15 +22,20 @@ class Api::V1::StatusesController < Api::BaseController
|
|||||||
loaded_ancestors = cache_collection(ancestors_results, Status)
|
loaded_ancestors = cache_collection(ancestors_results, Status)
|
||||||
loaded_descendants = cache_collection(descendants_results, Status)
|
loaded_descendants = cache_collection(descendants_results, Status)
|
||||||
|
|
||||||
@context = OpenStruct.new(ancestors: loaded_ancestors, descendants: loaded_descendants)
|
@context = Context.new(ancestors: loaded_ancestors, descendants: loaded_descendants)
|
||||||
statuses = [@status] + @context[:ancestors] + @context[:descendants]
|
statuses = [@status] + @context.ancestors + @context.descendants
|
||||||
|
|
||||||
set_maps(statuses)
|
render json: @context, serializer: REST::ContextSerializer, relationships: StatusRelationshipsPresenter.new(statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def card
|
def card
|
||||||
@card = PreviewCard.find_by(status: @status)
|
@card = PreviewCard.find_by(status: @status)
|
||||||
render_empty if @card.nil?
|
|
||||||
|
if @card.nil?
|
||||||
|
render_empty
|
||||||
|
else
|
||||||
|
render json: @card, serializer: REST::PreviewCardSerializer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -43,7 +49,7 @@ class Api::V1::StatusesController < Api::BaseController
|
|||||||
application: doorkeeper_token.application,
|
application: doorkeeper_token.application,
|
||||||
idempotency: request.headers['Idempotency-Key'])
|
idempotency: request.headers['Idempotency-Key'])
|
||||||
|
|
||||||
render :show
|
render json: @status, serializer: REST::StatusSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|||||||
@@ -9,15 +9,13 @@ class Api::V1::Timelines::HomeController < Api::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@statuses = load_statuses
|
@statuses = load_statuses
|
||||||
render 'api/v1/timelines/show'
|
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
cached_home_statuses.tap do |statuses|
|
cached_home_statuses
|
||||||
set_maps(statuses)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_home_statuses
|
def cached_home_statuses
|
||||||
|
|||||||
@@ -7,15 +7,13 @@ class Api::V1::Timelines::PublicController < Api::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@statuses = load_statuses
|
@statuses = load_statuses
|
||||||
render 'api/v1/timelines/show'
|
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
cached_public_statuses.tap do |statuses|
|
cached_public_statuses
|
||||||
set_maps(statuses)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_public_statuses
|
def cached_public_statuses
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class Api::V1::Timelines::TagController < Api::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@statuses = load_statuses
|
@statuses = load_statuses
|
||||||
render 'api/v1/timelines/show'
|
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -18,9 +18,7 @@ class Api::V1::Timelines::TagController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
cached_tagged_statuses.tap do |statuses|
|
cached_tagged_statuses
|
||||||
set_maps(statuses)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_tagged_statuses
|
def cached_tagged_statuses
|
||||||
|
|||||||
52
app/controllers/api/web/push_subscriptions_controller.rb
Normal file
52
app/controllers/api/web/push_subscriptions_controller.rb
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::Web::PushSubscriptionsController < Api::BaseController
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
before_action :require_user!
|
||||||
|
|
||||||
|
def create
|
||||||
|
params.require(:subscription).require(:endpoint)
|
||||||
|
params.require(:subscription).require(:keys).require([:auth, :p256dh])
|
||||||
|
|
||||||
|
active_session = current_session
|
||||||
|
|
||||||
|
unless active_session.web_push_subscription.nil?
|
||||||
|
active_session.web_push_subscription.destroy!
|
||||||
|
active_session.update!(web_push_subscription: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Mobile devices do not support regular notifications, so we enable push notifications by default
|
||||||
|
alerts_enabled = active_session.detection.device.mobile? || active_session.detection.device.tablet?
|
||||||
|
|
||||||
|
data = {
|
||||||
|
alerts: {
|
||||||
|
follow: alerts_enabled,
|
||||||
|
favourite: alerts_enabled,
|
||||||
|
reblog: alerts_enabled,
|
||||||
|
mention: alerts_enabled,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
web_subscription = ::Web::PushSubscription.create!(
|
||||||
|
endpoint: params[:subscription][:endpoint],
|
||||||
|
key_p256dh: params[:subscription][:keys][:p256dh],
|
||||||
|
key_auth: params[:subscription][:keys][:auth],
|
||||||
|
data: data
|
||||||
|
)
|
||||||
|
|
||||||
|
active_session.update!(web_push_subscription: web_subscription)
|
||||||
|
|
||||||
|
render json: web_subscription.as_payload
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
params.require([:id, :data])
|
||||||
|
|
||||||
|
web_subscription = ::Web::PushSubscription.find(params[:id])
|
||||||
|
|
||||||
|
web_subscription.update!(data: params[:data])
|
||||||
|
|
||||||
|
render json: web_subscription.as_payload
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base
|
|||||||
include UserTrackingConcern
|
include UserTrackingConcern
|
||||||
|
|
||||||
helper_method :current_account
|
helper_method :current_account
|
||||||
|
helper_method :current_session
|
||||||
helper_method :single_user_mode?
|
helper_method :single_user_mode?
|
||||||
|
|
||||||
rescue_from ActionController::RoutingError, with: :not_found
|
rescue_from ActionController::RoutingError, with: :not_found
|
||||||
@@ -68,6 +69,10 @@ class ApplicationController < ActionController::Base
|
|||||||
@current_account ||= current_user.try(:account)
|
@current_account ||= current_user.try(:account)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_session
|
||||||
|
@current_session ||= SessionActivation.find_by(session_id: cookies.signed['_session_id'])
|
||||||
|
end
|
||||||
|
|
||||||
def cache_collection(raw, klass)
|
def cache_collection(raw, klass)
|
||||||
return raw unless klass.respond_to?(:with_includes)
|
return raw unless klass.respond_to?(:with_includes)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||||||
|
|
||||||
before_action :check_enabled_registrations, only: [:new, :create]
|
before_action :check_enabled_registrations, only: [:new, :create]
|
||||||
before_action :configure_sign_up_params, only: [:create]
|
before_action :configure_sign_up_params, only: [:create]
|
||||||
|
before_action :set_sessions, only: [:edit, :update]
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
not_found
|
not_found
|
||||||
@@ -41,4 +42,8 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||||||
def determine_layout
|
def determine_layout
|
||||||
%w(edit update).include?(action_name) ? 'admin' : 'auth'
|
%w(edit update).include?(action_name) ? 'admin' : 'auth'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_sessions
|
||||||
|
@sessions = current_user.session_activations
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class AuthorizeFollowsController < ApplicationController
|
|||||||
if @account.nil?
|
if @account.nil?
|
||||||
render :error
|
render :error
|
||||||
else
|
else
|
||||||
redirect_to web_url("accounts/#{@account.id}")
|
render :success
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||||
render :error
|
render :error
|
||||||
|
|||||||
87
app/controllers/concerns/signature_verification.rb
Normal file
87
app/controllers/concerns/signature_verification.rb
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Implemented according to HTTP signatures (Draft 6)
|
||||||
|
# <https://tools.ietf.org/html/draft-cavage-http-signatures-06>
|
||||||
|
module SignatureVerification
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def signed_request?
|
||||||
|
request.headers['Signature'].present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def signed_request_account
|
||||||
|
return @signed_request_account if defined?(@signed_request_account)
|
||||||
|
|
||||||
|
unless signed_request?
|
||||||
|
@signed_request_account = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
raw_signature = request.headers['Signature']
|
||||||
|
signature_params = {}
|
||||||
|
|
||||||
|
raw_signature.split(',').each do |part|
|
||||||
|
parsed_parts = part.match(/([a-z]+)="([^"]+)"/i)
|
||||||
|
next if parsed_parts.nil? || parsed_parts.size != 3
|
||||||
|
signature_params[parsed_parts[1]] = parsed_parts[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
if incompatible_signature?(signature_params)
|
||||||
|
@signed_request_account = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
account = ResolveRemoteAccountService.new.call(signature_params['keyId'].gsub(/\Aacct:/, ''))
|
||||||
|
|
||||||
|
if account.nil?
|
||||||
|
@signed_request_account = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
signature = Base64.decode64(signature_params['signature'])
|
||||||
|
compare_signed_string = build_signed_string(signature_params['headers'])
|
||||||
|
|
||||||
|
if account.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, signature, compare_signed_string)
|
||||||
|
@signed_request_account = account
|
||||||
|
@signed_request_account
|
||||||
|
else
|
||||||
|
@signed_request_account = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def build_signed_string(signed_headers)
|
||||||
|
signed_headers = 'date' if signed_headers.blank?
|
||||||
|
|
||||||
|
signed_headers.split(' ').map do |signed_header|
|
||||||
|
if signed_header == Request::REQUEST_TARGET
|
||||||
|
"#{Request::REQUEST_TARGET}: #{request.method.downcase} #{request.path}"
|
||||||
|
else
|
||||||
|
"#{signed_header}: #{request.headers[to_header_name(signed_header)]}"
|
||||||
|
end
|
||||||
|
end.join("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def matches_time_window?
|
||||||
|
begin
|
||||||
|
time_sent = DateTime.httpdate(request.headers['Date'])
|
||||||
|
rescue ArgumentError
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
(Time.now.utc - time_sent).abs <= 30
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_header_name(name)
|
||||||
|
name.split(/-/).map(&:capitalize).join('-')
|
||||||
|
end
|
||||||
|
|
||||||
|
def incompatible_signature?(signature_params)
|
||||||
|
signature_params['keyId'].blank? ||
|
||||||
|
signature_params['signature'].blank? ||
|
||||||
|
signature_params['algorithm'].blank? ||
|
||||||
|
signature_params['algorithm'] != 'rsa-sha256' ||
|
||||||
|
!signature_params['keyId'].start_with?('acct:')
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -5,5 +5,24 @@ class FollowerAccountsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@follows = Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
@follows = Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
|
||||||
|
format.json do
|
||||||
|
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def collection_presenter
|
||||||
|
ActivityPub::CollectionPresenter.new(
|
||||||
|
id: account_followers_url(@account),
|
||||||
|
type: :ordered,
|
||||||
|
size: @account.followers_count,
|
||||||
|
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,5 +5,24 @@ class FollowingAccountsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@follows = Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
@follows = Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
|
||||||
|
format.json do
|
||||||
|
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def collection_presenter
|
||||||
|
ActivityPub::CollectionPresenter.new(
|
||||||
|
id: account_following_index_url(@account),
|
||||||
|
type: :ordered,
|
||||||
|
size: @account.following_count,
|
||||||
|
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,14 +2,10 @@
|
|||||||
|
|
||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :set_initial_state_json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@body_classes = 'app-body'
|
@body_classes = 'app-body'
|
||||||
@token = find_or_create_access_token.token
|
|
||||||
@web_settings = Web::Setting.find_by(user: current_user)&.data || {}
|
|
||||||
@admin = Account.find_local(Setting.site_contact_username)
|
|
||||||
@streaming_api_base_url = Rails.configuration.x.streaming_api_base_url
|
|
||||||
@frontend = (params[:frontend] and Rails.configuration.x.available_frontends.include? params[:frontend] + '.js') ? params[:frontend] : 'mastodon'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -18,13 +14,18 @@ class HomeController < ApplicationController
|
|||||||
redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in?
|
redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_create_access_token
|
def set_initial_state_json
|
||||||
Doorkeeper::AccessToken.find_or_create_for(
|
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
|
||||||
Doorkeeper::Application.where(superapp: true).first,
|
@initial_state_json = serializable_resource.to_json
|
||||||
current_user.id,
|
end
|
||||||
Doorkeeper::OAuth::Scopes.from_string('read write follow'),
|
|
||||||
Doorkeeper.configuration.access_token_expires_in,
|
def initial_state_params
|
||||||
Doorkeeper.configuration.refresh_token_enabled?
|
{
|
||||||
)
|
settings: Web::Setting.find_by(user: current_user)&.data || {},
|
||||||
|
push_subscription: current_account.user.web_push_subscription(current_session),
|
||||||
|
current_account: current_account,
|
||||||
|
token: current_session.token,
|
||||||
|
admin: Account.find_local(Setting.site_contact_username),
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,9 +34,13 @@ class Settings::PreferencesController < ApplicationController
|
|||||||
def user_settings_params
|
def user_settings_params
|
||||||
params.require(:user).permit(
|
params.require(:user).permit(
|
||||||
:setting_default_privacy,
|
:setting_default_privacy,
|
||||||
|
:setting_default_sensitive,
|
||||||
|
:setting_unfollow_modal,
|
||||||
:setting_boost_modal,
|
:setting_boost_modal,
|
||||||
:setting_delete_modal,
|
:setting_delete_modal,
|
||||||
:setting_auto_play_gif,
|
:setting_auto_play_gif,
|
||||||
|
:setting_system_font_ui,
|
||||||
|
:setting_noindex,
|
||||||
notification_emails: %i(follow follow_request reblog favourite mention digest),
|
notification_emails: %i(follow follow_request reblog favourite mention digest),
|
||||||
interactions: %i(must_be_follower must_be_following)
|
interactions: %i(must_be_follower must_be_following)
|
||||||
)
|
)
|
||||||
|
|||||||
17
app/controllers/settings/sessions_controller.rb
Normal file
17
app/controllers/settings/sessions_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Settings::SessionsController < ApplicationController
|
||||||
|
before_action :set_session, only: :destroy
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@session.destroy!
|
||||||
|
flash[:notice] = I18n.t('sessions.revoke_success')
|
||||||
|
redirect_to edit_user_registration_path
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_session
|
||||||
|
@session = current_user.session_activations.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -7,7 +7,9 @@ module Settings
|
|||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :verify_otp_required, only: [:create]
|
before_action :verify_otp_required, only: [:create]
|
||||||
|
|
||||||
def show; end
|
def show
|
||||||
|
@confirmation = Form::TwoFactorConfirmation.new
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
current_user.otp_secret = User.generate_otp_secret(32)
|
current_user.otp_secret = User.generate_otp_secret(32)
|
||||||
@@ -16,13 +18,23 @@ module Settings
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
current_user.otp_required_for_login = false
|
if current_user.validate_and_consume_otp!(confirmation_params[:code])
|
||||||
current_user.save!
|
current_user.otp_required_for_login = false
|
||||||
redirect_to settings_two_factor_authentication_path
|
current_user.save!
|
||||||
|
redirect_to settings_two_factor_authentication_path
|
||||||
|
else
|
||||||
|
flash.now[:alert] = I18n.t('two_factor_authentication.wrong_code')
|
||||||
|
@confirmation = Form::TwoFactorConfirmation.new
|
||||||
|
render :show
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def confirmation_params
|
||||||
|
params.require(:form_two_factor_confirmation).permit(:code)
|
||||||
|
end
|
||||||
|
|
||||||
def verify_otp_required
|
def verify_otp_required
|
||||||
redirect_to settings_two_factor_authentication_path if current_user.otp_required_for_login?
|
redirect_to settings_two_factor_authentication_path if current_user.otp_required_for_login?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,10 +11,22 @@ class StatusesController < ApplicationController
|
|||||||
before_action :check_account_suspension
|
before_action :check_account_suspension
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ancestors = @status.reply? ? cache_collection(@status.ancestors(current_account), Status) : []
|
respond_to do |format|
|
||||||
@descendants = cache_collection(@status.descendants(current_account), Status)
|
format.html do
|
||||||
|
@ancestors = @status.reply? ? cache_collection(@status.ancestors(current_account), Status) : []
|
||||||
|
@descendants = cache_collection(@status.descendants(current_account), Status)
|
||||||
|
|
||||||
render 'stream_entries/show'
|
render 'stream_entries/show'
|
||||||
|
end
|
||||||
|
|
||||||
|
format.json do
|
||||||
|
render json: @status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def activity
|
||||||
|
render json: @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
class StreamEntriesController < ApplicationController
|
class StreamEntriesController < ApplicationController
|
||||||
include Authorization
|
include Authorization
|
||||||
|
include SignatureVerification
|
||||||
|
|
||||||
layout 'public'
|
layout 'public'
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ class StreamEntriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
format.atom do
|
format.atom do
|
||||||
render xml: AtomSerializer.render(AtomSerializer.new.entry(@stream_entry, true))
|
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.entry(@stream_entry, true))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,26 @@ class TagsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@tag = Tag.find_by!(name: params[:id].downcase)
|
@tag = Tag.find_by!(name: params[:id].downcase)
|
||||||
@statuses = @tag.nil? ? [] : Status.as_tag_timeline(@tag, current_account, params[:local]).paginate_by_max_id(20, params[:max_id])
|
@statuses = Status.as_tag_timeline(@tag, current_account, params[:local]).paginate_by_max_id(20, params[:max_id])
|
||||||
@statuses = cache_collection(@statuses, Status)
|
@statuses = cache_collection(@statuses, Status)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
|
||||||
|
format.json do
|
||||||
|
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def collection_presenter
|
||||||
|
ActivityPub::CollectionPresenter.new(
|
||||||
|
id: tag_url(@tag),
|
||||||
|
type: :ordered,
|
||||||
|
size: @tag.statuses.count,
|
||||||
|
items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Activitystreams2BuilderHelper
|
|
||||||
# Gets a usable name for an account, using display name or username.
|
|
||||||
def account_name(account)
|
|
||||||
account.display_name.presence || account.username
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -6,15 +6,21 @@ module Admin::FilterHelper
|
|||||||
|
|
||||||
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS
|
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS
|
||||||
|
|
||||||
def filter_link_to(text, more_params)
|
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
||||||
new_url = filtered_url_for(more_params)
|
new_url = filtered_url_for(link_to_params)
|
||||||
link_to text, new_url, class: filter_link_class(new_url)
|
new_class = filtered_url_for(link_class_params)
|
||||||
|
link_to text, new_url, class: filter_link_class(new_class)
|
||||||
end
|
end
|
||||||
|
|
||||||
def table_link_to(icon, text, path, options = {})
|
def table_link_to(icon, text, path, options = {})
|
||||||
link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
|
link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def selected?(more_params)
|
||||||
|
new_url = filtered_url_for(more_params)
|
||||||
|
filter_link_class(new_url) == 'selected' ? true : false
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def filter_params(more_params)
|
def filter_params(more_params)
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ module ApplicationHelper
|
|||||||
Rails.env.production? ? site_title : "#{site_title} (Dev)"
|
Rails.env.production? ? site_title : "#{site_title} (Dev)"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fa_icon(icon)
|
def fa_icon(icon, attributes = {})
|
||||||
content_tag(:i, nil, class: 'fa ' + icon.split(' ').map { |cl| "fa-#{cl}" }.join(' '))
|
class_names = attributes[:class]&.split(' ') || []
|
||||||
|
class_names << 'fa'
|
||||||
|
class_names += icon.split(' ').map { |cl| "fa-#{cl}" }
|
||||||
|
|
||||||
|
content_tag(:i, nil, attributes.merge(class: class_names.join(' ')))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
24
app/helpers/emoji_helper.rb
Normal file
24
app/helpers/emoji_helper.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EmojiHelper
|
||||||
|
def emojify(text)
|
||||||
|
return text if text.blank?
|
||||||
|
|
||||||
|
text.gsub(emoji_pattern) do |match|
|
||||||
|
emoji = Emoji.instance.unicode($1) # rubocop:disable Style/PerlBackrefs
|
||||||
|
|
||||||
|
if emoji
|
||||||
|
emoji
|
||||||
|
else
|
||||||
|
match
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def emoji_pattern
|
||||||
|
@emoji_pattern ||=
|
||||||
|
/(?<=[^[:alnum:]:]|\n|^)
|
||||||
|
(#{Emoji.instance.names.map { |name| Regexp.escape(name) }.join('|')})
|
||||||
|
(?=[^[:alnum:]:]|$)/x
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module HttpHelper
|
|
||||||
def http_client(options = {})
|
|
||||||
timeout = { write: 10, connect: 10, read: 10 }.merge(options)
|
|
||||||
|
|
||||||
HTTP.headers(user_agent: user_agent)
|
|
||||||
.timeout(:per_operation, timeout)
|
|
||||||
.follow
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def user_agent
|
|
||||||
@user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Mastodon::Version}; +http://#{Rails.configuration.x.local_domain}/)"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -11,7 +11,7 @@ module RoutingHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_asset_url(source)
|
def full_asset_url(source, options = {})
|
||||||
Rails.configuration.x.use_s3 ? source : URI.join(root_url, ActionController::Base.helpers.asset_url(source)).to_s
|
Rails.configuration.x.use_s3 ? source : URI.join(root_url, ActionController::Base.helpers.asset_url(source, options)).to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ module SettingsHelper
|
|||||||
io: 'Ido',
|
io: 'Ido',
|
||||||
it: 'Italiano',
|
it: 'Italiano',
|
||||||
ja: '日本語',
|
ja: '日本語',
|
||||||
|
ko: '한국어',
|
||||||
nl: 'Nederlands',
|
nl: 'Nederlands',
|
||||||
no: 'Norsk',
|
no: 'Norsk',
|
||||||
oc: 'Occitan',
|
oc: 'Occitan',
|
||||||
@@ -41,4 +42,16 @@ module SettingsHelper
|
|||||||
def hash_to_object(hash)
|
def hash_to_object(hash)
|
||||||
HashObject.new(hash)
|
HashObject.new(hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def session_device_icon(session)
|
||||||
|
device = session.detection.device
|
||||||
|
|
||||||
|
if device.mobile?
|
||||||
|
'mobile'
|
||||||
|
elsif device.tablet?
|
||||||
|
'tablet'
|
||||||
|
else
|
||||||
|
'desktop'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
BIN
app/javascript/fonts/montserrat/Montserrat-Medium.ttf
Normal file
BIN
app/javascript/fonts/montserrat/Montserrat-Medium.ttf
Normal file
Binary file not shown.
93
app/javascript/glitch/actions/local_settings.js
Normal file
93
app/javascript/glitch/actions/local_settings.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`actions/local_settings`
|
||||||
|
========================
|
||||||
|
|
||||||
|
> For more information on the contents of this file, please contact:
|
||||||
|
>
|
||||||
|
> - kibigo! [@kibi@glitch.social]
|
||||||
|
|
||||||
|
This file provides our Redux actions related to local settings. It
|
||||||
|
consists of the following:
|
||||||
|
|
||||||
|
- __`changesLocalSetting(key, value)` :__
|
||||||
|
Changes the local setting with the given `key` to the given
|
||||||
|
`value`. `key` **MUST** be an array of strings, as required by
|
||||||
|
`Immutable.Map.prototype.getIn()`.
|
||||||
|
|
||||||
|
- __`saveLocalSettings()` :__
|
||||||
|
Saves the local settings to `localStorage` as a JSON object. We
|
||||||
|
shouldn't ever need to call this ourselves.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Constants:
|
||||||
|
----------
|
||||||
|
|
||||||
|
We provide the following constants:
|
||||||
|
|
||||||
|
- __`LOCAL_SETTING_CHANGE` :__
|
||||||
|
This string constant is used to dispatch a setting change to our
|
||||||
|
reducer in `reducers/local_settings`, where the setting is
|
||||||
|
actually changed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const LOCAL_SETTING_CHANGE = 'LOCAL_SETTING_CHANGE';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
`changeLocalSetting(key, value)`:
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
Changes the local setting with the given `key` to the given `value`.
|
||||||
|
`key` **MUST** be an array of strings, as required by
|
||||||
|
`Immutable.Map.prototype.getIn()`.
|
||||||
|
|
||||||
|
To accomplish this, we just dispatch a `LOCAL_SETTING_CHANGE` to our
|
||||||
|
reducer in `reducers/local_settings`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function changeLocalSetting(key, value) {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch({
|
||||||
|
type: LOCAL_SETTING_CHANGE,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(saveLocalSettings());
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
`saveLocalSettings()`:
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Saves the local settings to `localStorage` as a JSON object.
|
||||||
|
`changeLocalSetting()` calls this whenever it changes a setting. We
|
||||||
|
shouldn't ever need to call this ourselves.
|
||||||
|
|
||||||
|
> __TODO :__
|
||||||
|
> Right now `saveLocalSettings()` doesn't keep track of which user
|
||||||
|
> is currently signed in, but it might be better to give each user
|
||||||
|
> their *own* local settings.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function saveLocalSettings() {
|
||||||
|
return (_, getState) => {
|
||||||
|
const localSettings = getState().get('local_settings').toJS();
|
||||||
|
localStorage.setItem('mastodon-settings', JSON.stringify(localSettings));
|
||||||
|
};
|
||||||
|
};
|
||||||
241
app/javascript/glitch/components/account/header.js
Normal file
241
app/javascript/glitch/components/account/header.js
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<AccountHeader>`
|
||||||
|
=================
|
||||||
|
|
||||||
|
> For more information on the contents of this file, please contact:
|
||||||
|
>
|
||||||
|
> - kibigo! [@kibi@glitch.social]
|
||||||
|
|
||||||
|
Original file by @gargron@mastodon.social et al as part of
|
||||||
|
tootsuite/mastodon. We've expanded it in order to handle user bio
|
||||||
|
frontmatter.
|
||||||
|
|
||||||
|
The `<AccountHeader>` component provides the header for account
|
||||||
|
timelines. It is a fairly simple component which mostly just consists
|
||||||
|
of a `render()` method.
|
||||||
|
|
||||||
|
__Props:__
|
||||||
|
|
||||||
|
- __`account` (`ImmutablePropTypes.map`) :__
|
||||||
|
The account to render a header for.
|
||||||
|
|
||||||
|
- __`me` (`PropTypes.number.isRequired`) :__
|
||||||
|
The id of the currently-signed-in account.
|
||||||
|
|
||||||
|
- __`onFollow` (`PropTypes.func.isRequired`) :__
|
||||||
|
The function to call when the user clicks the "follow" button.
|
||||||
|
|
||||||
|
- __`intl` (`PropTypes.object.isRequired`) :__
|
||||||
|
Our internationalization object, inserted by `@injectIntl`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import emojify from '../../../mastodon/emoji';
|
||||||
|
import IconButton from '../../../mastodon/components/icon_button';
|
||||||
|
import Avatar from '../../../mastodon/components/avatar';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import { processBio } from '../../util/bio_metadata';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Inital setup:
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The `messages` constant is used to define any messages that we need
|
||||||
|
from inside props. In our case, these are the `unfollow`, `follow`, and
|
||||||
|
`requested` messages used in the `title` of our buttons.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||||
|
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
||||||
|
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' },
|
||||||
|
});
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Implementation:
|
||||||
|
---------------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class AccountHeader extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
account : ImmutablePropTypes.map,
|
||||||
|
me : PropTypes.number.isRequired,
|
||||||
|
onFollow : PropTypes.func.isRequired,
|
||||||
|
intl : PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `render()`
|
||||||
|
|
||||||
|
The `render()` function is used to render our component.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { account, me, intl } = this.props;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
If no `account` is provided, then we can't render a header. Otherwise,
|
||||||
|
we get the `displayName` for the account, if available. If it's blank,
|
||||||
|
then we set the `displayName` to just be the `username` of the account.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!account) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let displayName = account.get('display_name');
|
||||||
|
let info = '';
|
||||||
|
let actionBtn = '';
|
||||||
|
let following = false;
|
||||||
|
|
||||||
|
if (displayName.length === 0) {
|
||||||
|
displayName = account.get('username');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Next, we handle the account relationships. If the account follows the
|
||||||
|
user, then we add an `info` message. If the user has requested a
|
||||||
|
follow, then we disable the `actionBtn` and display an hourglass.
|
||||||
|
Otherwise, if the account isn't blocked, we set the `actionBtn` to the
|
||||||
|
appropriate icon.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (me !== account.get('id')) {
|
||||||
|
if (account.getIn(['relationship', 'followed_by'])) {
|
||||||
|
info = (
|
||||||
|
<span className='account--follows-info'>
|
||||||
|
<FormattedMessage id='account.follows_you' defaultMessage='Follows you' />
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (account.getIn(['relationship', 'requested'])) {
|
||||||
|
actionBtn = (
|
||||||
|
<div className='account--action-button'>
|
||||||
|
<IconButton size={26} disabled icon='hourglass' title={intl.formatMessage(messages.requested)} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (!account.getIn(['relationship', 'blocking'])) {
|
||||||
|
following = account.getIn(['relationship', 'following']);
|
||||||
|
actionBtn = (
|
||||||
|
<div className='account--action-button'>
|
||||||
|
<IconButton
|
||||||
|
size={26}
|
||||||
|
icon={following ? 'user-times' : 'user-plus'}
|
||||||
|
active={following}
|
||||||
|
title={intl.formatMessage(following ? messages.unfollow : messages.follow)}
|
||||||
|
onClick={this.props.onFollow}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
`displayNameHTML` processes the `displayName` and prepares it for
|
||||||
|
insertion into the document. Meanwhile, we extract the `text` and
|
||||||
|
`metadata` from our account's `note` using `processBio()`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const displayNameHTML = {
|
||||||
|
__html : emojify(escapeTextContentForBrowser(displayName)),
|
||||||
|
};
|
||||||
|
const { text, metadata } = processBio(account.get('note'));
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Here, we render our component using all the things we've defined above.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='account__header__wrapper'>
|
||||||
|
<div
|
||||||
|
className='account__header'
|
||||||
|
style={{ backgroundImage: `url(${account.get('header')})` }}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<a href={account.get('url')} target='_blank' rel='noopener'>
|
||||||
|
<span className='account__header__avatar'>
|
||||||
|
<Avatar
|
||||||
|
src={account.get('avatar')}
|
||||||
|
staticSrc={account.get('avatar_static')}
|
||||||
|
size={90}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
className='account__header__display-name'
|
||||||
|
dangerouslySetInnerHTML={displayNameHTML}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
<span className='account__header__username'>
|
||||||
|
@{account.get('acct')}
|
||||||
|
{account.get('locked') ? <i className='fa fa-lock' /> : null}
|
||||||
|
</span>
|
||||||
|
<div className='account__header__content' dangerouslySetInnerHTML={{ __html: emojify(text) }} />
|
||||||
|
|
||||||
|
{info}
|
||||||
|
{actionBtn}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{metadata.length && (
|
||||||
|
<table className='account__metadata'>
|
||||||
|
<tbody>
|
||||||
|
{(() => {
|
||||||
|
let data = [];
|
||||||
|
for (let i = 0; i < metadata.length; i++) {
|
||||||
|
data.push(
|
||||||
|
<tr key={i}>
|
||||||
|
<th scope='row'><div dangerouslySetInnerHTML={{ __html: emojify(metadata[i][0]) }} /></th>
|
||||||
|
<td><div dangerouslySetInnerHTML={{ __html: emojify(metadata[i][1]) }} /></td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
})()}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
) || null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<NotificationPurgeButtonsContainer>`
|
||||||
|
=========================
|
||||||
|
|
||||||
|
This container connects `<NotificationPurgeButtons>`s to the Redux store.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import NotificationPurgeButtons from './notification_purge_buttons';
|
||||||
|
import {
|
||||||
|
deleteMarkedNotifications,
|
||||||
|
enterNotificationClearingMode,
|
||||||
|
} from '../../../../mastodon/actions/notifications';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Dispatch mapping:
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The `mapDispatchToProps()` function maps dispatches to our store to the
|
||||||
|
various props of our component. We only need to provide a dispatch for
|
||||||
|
deleting notifications.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
onEnterCleaningMode(yes) {
|
||||||
|
dispatch(enterNotificationClearingMode(yes));
|
||||||
|
},
|
||||||
|
|
||||||
|
onDeleteMarkedNotifications() {
|
||||||
|
dispatch(deleteMarkedNotifications());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
active: state.getIn(['notifications', 'cleaningMode']),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(NotificationPurgeButtons);
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* Buttons widget for controlling the notification clearing mode.
|
||||||
|
* In idle state, the cleaning mode button is shown. When the mode is active,
|
||||||
|
* a Confirm and Abort buttons are shown in its place.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
enter : { id: 'notification_purge.start', defaultMessage: 'Enter notification cleaning mode' },
|
||||||
|
accept : { id: 'notification_purge.confirm', defaultMessage: 'Dismiss selected notifications' },
|
||||||
|
abort : { id: 'notification_purge.abort', defaultMessage: 'Leave cleaning mode' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class NotificationPurgeButtons extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
// Nukes all marked notifications
|
||||||
|
onDeleteMarkedNotifications : PropTypes.func.isRequired,
|
||||||
|
// Enables or disables the mode
|
||||||
|
// and also clears the marked status of all notifications
|
||||||
|
onEnterCleaningMode : PropTypes.func.isRequired,
|
||||||
|
// Active state, changed via onStateChange()
|
||||||
|
active: PropTypes.bool.isRequired,
|
||||||
|
// i18n
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
onEnterBtnClick = () => {
|
||||||
|
this.props.onEnterCleaningMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
onAcceptBtnClick = () => {
|
||||||
|
this.props.onDeleteMarkedNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
onAbortBtnClick = () => {
|
||||||
|
this.props.onEnterCleaningMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { intl, active } = this.props;
|
||||||
|
|
||||||
|
const msgEnter = intl.formatMessage(messages.enter);
|
||||||
|
const msgAccept = intl.formatMessage(messages.accept);
|
||||||
|
const msgAbort = intl.formatMessage(messages.abort);
|
||||||
|
|
||||||
|
let enterButton, acceptButton, abortButton;
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
acceptButton = (
|
||||||
|
<button
|
||||||
|
className='active'
|
||||||
|
aria-label={msgAccept}
|
||||||
|
title={msgAccept}
|
||||||
|
onClick={this.onAcceptBtnClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-check' />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
abortButton = (
|
||||||
|
<button
|
||||||
|
className='active'
|
||||||
|
aria-label={msgAbort}
|
||||||
|
title={msgAbort}
|
||||||
|
onClick={this.onAbortBtnClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-times' />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
enterButton = (
|
||||||
|
<button
|
||||||
|
aria-label={msgEnter}
|
||||||
|
title={msgEnter}
|
||||||
|
onClick={this.onEnterBtnClick}
|
||||||
|
>
|
||||||
|
<i className='fa fa-eraser' />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='column-header__notif-cleaning-buttons'>
|
||||||
|
{acceptButton}{abortButton}{enterButton}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<ComposeAdvancedOptionsContainer>`
|
||||||
|
===================================
|
||||||
|
|
||||||
|
This container connects `<ComposeAdvancedOptions>` to the Redux store.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { toggleComposeAdvancedOption } from '../../../../mastodon/actions/compose';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import ComposeAdvancedOptions from '.';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
State mapping:
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The `mapStateToProps()` function maps various state properties to the
|
||||||
|
props of our component. The only property we care about is
|
||||||
|
`compose.advanced_options`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
values: state.getIn(['compose', 'advanced_options']),
|
||||||
|
});
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Dispatch mapping:
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The `mapDispatchToProps()` function maps dispatches to our store to the
|
||||||
|
various props of our component. We just need to provide a dispatch for
|
||||||
|
when an advanced option toggle changes.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
||||||
|
onChange (option) {
|
||||||
|
dispatch(toggleComposeAdvancedOption(option));
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(ComposeAdvancedOptions);
|
||||||
@@ -0,0 +1,241 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<ComposeAdvancedOptions>`
|
||||||
|
==========================
|
||||||
|
|
||||||
|
> For more information on the contents of this file, please contact:
|
||||||
|
>
|
||||||
|
> - surinna [@srn@dev.glitch.social]
|
||||||
|
|
||||||
|
This adds an advanced options dropdown to the toot compose box, for
|
||||||
|
toggles that don't necessarily fit elsewhere.
|
||||||
|
|
||||||
|
__Props:__
|
||||||
|
|
||||||
|
- __`values` (`ImmutablePropTypes.contains(…).isRequired`) :__
|
||||||
|
An Immutable map with the following values:
|
||||||
|
|
||||||
|
- __`do_not_federate` (`PropTypes.bool.isRequired`) :__
|
||||||
|
Specifies whether or not to federate the status.
|
||||||
|
|
||||||
|
- __`onChange` (`PropTypes.func.isRequired`) :__
|
||||||
|
The function to call when a toggle is changed. We pass this from
|
||||||
|
our container to the toggle.
|
||||||
|
|
||||||
|
- __`intl` (`PropTypes.object.isRequired`) :__
|
||||||
|
Our internationalization object, inserted by `@injectIntl`.
|
||||||
|
|
||||||
|
__State:__
|
||||||
|
|
||||||
|
- __`open` :__
|
||||||
|
This tells whether the dropdown is currently open or closed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { injectIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import IconButton from '../../../../mastodon/components/icon_button';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import ComposeAdvancedOptionsToggle from './toggle';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Inital setup:
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The `messages` constant is used to define any messages that we need
|
||||||
|
from inside props. These are the various titles and labels on our
|
||||||
|
toggles.
|
||||||
|
|
||||||
|
`iconStyle` styles the icon used for the dropdown button.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
local_only_short :
|
||||||
|
{ id: 'advanced-options.local-only.short', defaultMessage: 'Local-only' },
|
||||||
|
local_only_long :
|
||||||
|
{ id: 'advanced-options.local-only.long', defaultMessage: 'Do not post to other instances' },
|
||||||
|
advanced_options_icon_title :
|
||||||
|
{ id: 'advanced_options.icon_title', defaultMessage: 'Advanced options' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const iconStyle = {
|
||||||
|
height : null,
|
||||||
|
lineHeight : '27px',
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Implementation:
|
||||||
|
---------------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class ComposeAdvancedOptions extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
values : ImmutablePropTypes.contains({
|
||||||
|
do_not_federate : PropTypes.bool.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
onChange : PropTypes.func.isRequired,
|
||||||
|
intl : PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
open: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `onToggleDropdown()`
|
||||||
|
|
||||||
|
This function toggles the opening and closing of the advanced options
|
||||||
|
dropdown.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
onToggleDropdown = () => {
|
||||||
|
this.setState({ open: !this.state.open });
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `onGlobalClick(e)`
|
||||||
|
|
||||||
|
This function closes the advanced options dropdown if you click
|
||||||
|
anywhere else on the screen.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
onGlobalClick = (e) => {
|
||||||
|
if (e.target !== this.node && !this.node.contains(e.target) && this.state.open) {
|
||||||
|
this.setState({ open: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `componentDidMount()`, `componentWillUnmount()`
|
||||||
|
|
||||||
|
This function closes the advanced options dropdown if you click
|
||||||
|
anywhere else on the screen.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
window.addEventListener('click', this.onGlobalClick);
|
||||||
|
window.addEventListener('touchstart', this.onGlobalClick);
|
||||||
|
}
|
||||||
|
componentWillUnmount () {
|
||||||
|
window.removeEventListener('click', this.onGlobalClick);
|
||||||
|
window.removeEventListener('touchstart', this.onGlobalClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `setRef(c)`
|
||||||
|
|
||||||
|
`setRef()` stores a reference to the dropdown's `<div> in `this.node`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
setRef = (c) => {
|
||||||
|
this.node = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `render()`
|
||||||
|
|
||||||
|
`render()` actually puts our component on the screen.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { open } = this.state;
|
||||||
|
const { intl, values } = this.props;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
The `options` array provides all of the available advanced options
|
||||||
|
alongside their icon, text, and name.
|
||||||
|
|
||||||
|
*/
|
||||||
|
const options = [
|
||||||
|
{ icon: 'wifi', shortText: messages.local_only_short, longText: messages.local_only_long, name: 'do_not_federate' },
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
`anyEnabled` tells us if any of our advanced options have been enabled.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const anyEnabled = values.some((enabled) => enabled);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
`optionElems` takes our `options` and creates
|
||||||
|
`<ComposeAdvancedOptionsToggle>`s out of them. We use the `name` of the
|
||||||
|
toggle as its `key` so that React can keep track of it.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const optionElems = options.map((option) => {
|
||||||
|
return (
|
||||||
|
<ComposeAdvancedOptionsToggle
|
||||||
|
onChange={this.props.onChange}
|
||||||
|
active={values.get(option.name)}
|
||||||
|
key={option.name}
|
||||||
|
name={option.name}
|
||||||
|
shortText={intl.formatMessage(option.shortText)}
|
||||||
|
longText={intl.formatMessage(option.longText)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Finally, we can render our component.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={this.setRef} className={`advanced-options-dropdown ${open ? 'open' : ''} ${anyEnabled ? 'active' : ''} `}>
|
||||||
|
<div className='advanced-options-dropdown__value'>
|
||||||
|
<IconButton
|
||||||
|
className='advanced-options-dropdown__value'
|
||||||
|
title={intl.formatMessage(messages.advanced_options_icon_title)}
|
||||||
|
icon='ellipsis-h' active={open || anyEnabled}
|
||||||
|
size={18}
|
||||||
|
style={iconStyle}
|
||||||
|
onClick={this.onToggleDropdown}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='advanced-options-dropdown__dropdown'>
|
||||||
|
{optionElems}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<ComposeAdvancedOptionsToggle>`
|
||||||
|
================================
|
||||||
|
|
||||||
|
> For more information on the contents of this file, please contact:
|
||||||
|
>
|
||||||
|
> - surinna [@srn@dev.glitch.social]
|
||||||
|
|
||||||
|
This creates the toggle used by `<ComposeAdvancedOptions>`.
|
||||||
|
|
||||||
|
__Props:__
|
||||||
|
|
||||||
|
- __`onChange` (`PropTypes.func`) :__
|
||||||
|
This provides the function to call when the toggle is
|
||||||
|
(de-?)activated.
|
||||||
|
|
||||||
|
- __`active` (`PropTypes.bool`) :__
|
||||||
|
This prop controls whether the toggle is currently active or not.
|
||||||
|
|
||||||
|
- __`name` (`PropTypes.string`) :__
|
||||||
|
This identifies the toggle, and is sent to `onChange()` when it is
|
||||||
|
called.
|
||||||
|
|
||||||
|
- __`shortText` (`PropTypes.string`) :__
|
||||||
|
This is a short string used as the title of the toggle.
|
||||||
|
|
||||||
|
- __`longText` (`PropTypes.string`) :__
|
||||||
|
This is a longer string used as a subtitle for the toggle.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import Toggle from 'react-toggle';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Implementation:
|
||||||
|
---------------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default class ComposeAdvancedOptionsToggle extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
active: PropTypes.bool.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
shortText: PropTypes.string.isRequired,
|
||||||
|
longText: PropTypes.string.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `onToggle()`
|
||||||
|
|
||||||
|
The `onToggle()` function simply calls the `onChange()` prop with the
|
||||||
|
toggle's `name`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
onToggle = () => {
|
||||||
|
this.props.onChange(this.props.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### `render()`
|
||||||
|
|
||||||
|
The `render()` function is used to render our component. We just render
|
||||||
|
a `<Toggle>` and place next to it our text.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { active, shortText, longText } = this.props;
|
||||||
|
return (
|
||||||
|
<div role='button' tabIndex='0' className='advanced-options-dropdown__option' onClick={this.onToggle}>
|
||||||
|
<div className='advanced-options-dropdown__option__toggle'>
|
||||||
|
<Toggle checked={active} onChange={this.onToggle} />
|
||||||
|
</div>
|
||||||
|
<div className='advanced-options-dropdown__option__content'>
|
||||||
|
<strong>{shortText}</strong>
|
||||||
|
{longText}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
app/javascript/glitch/components/local_settings/container.js
Normal file
24
app/javascript/glitch/components/local_settings/container.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { closeModal } from 'mastodon/actions/modal';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import { changeLocalSetting } from 'glitch/actions/local_settings';
|
||||||
|
import LocalSettings from '.';
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
settings: state.get('local_settings'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
onChange (setting, value) {
|
||||||
|
dispatch(changeLocalSetting(setting, value));
|
||||||
|
},
|
||||||
|
onClose () {
|
||||||
|
dispatch(closeModal());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(LocalSettings);
|
||||||
50
app/javascript/glitch/components/local_settings/index.js
Normal file
50
app/javascript/glitch/components/local_settings/index.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Package imports
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
|
// Our imports
|
||||||
|
import LocalSettingsPage from './page';
|
||||||
|
import LocalSettingsNavigation from './navigation';
|
||||||
|
|
||||||
|
// Stylesheet imports
|
||||||
|
import './style';
|
||||||
|
|
||||||
|
export default class LocalSettings extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
currentIndex: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
navigateTo = (index) =>
|
||||||
|
this.setState({ currentIndex: +index });
|
||||||
|
|
||||||
|
render () {
|
||||||
|
|
||||||
|
const { navigateTo } = this;
|
||||||
|
const { onChange, onClose, settings } = this.props;
|
||||||
|
const { currentIndex } = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='glitch modal-root__modal local-settings'>
|
||||||
|
<LocalSettingsNavigation
|
||||||
|
index={currentIndex}
|
||||||
|
onClose={onClose}
|
||||||
|
onNavigate={navigateTo}
|
||||||
|
/>
|
||||||
|
<LocalSettingsPage
|
||||||
|
index={currentIndex}
|
||||||
|
onChange={onChange}
|
||||||
|
settings={settings}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// Package imports
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { injectIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
// Our imports
|
||||||
|
import LocalSettingsNavigationItem from './item';
|
||||||
|
|
||||||
|
// Stylesheet imports
|
||||||
|
import './style';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
general: { id: 'settings.general', defaultMessage: 'General' },
|
||||||
|
collapsed: { id: 'settings.collapsed_statuses', defaultMessage: 'Collapsed toots' },
|
||||||
|
media: { id: 'settings.media', defaultMessage: 'Media' },
|
||||||
|
preferences: { id: 'settings.preferences', defaultMessage: 'Preferences' },
|
||||||
|
close: { id: 'settings.close', defaultMessage: 'Close' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class LocalSettingsNavigation extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
index : PropTypes.number,
|
||||||
|
intl : PropTypes.object.isRequired,
|
||||||
|
onClose : PropTypes.func.isRequired,
|
||||||
|
onNavigate : PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
render () {
|
||||||
|
|
||||||
|
const { index, intl, onClose, onNavigate } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav className='glitch local-settings__navigation'>
|
||||||
|
<LocalSettingsNavigationItem
|
||||||
|
active={index === 0}
|
||||||
|
index={0}
|
||||||
|
onNavigate={onNavigate}
|
||||||
|
title={intl.formatMessage(messages.general)}
|
||||||
|
/>
|
||||||
|
<LocalSettingsNavigationItem
|
||||||
|
active={index === 1}
|
||||||
|
index={1}
|
||||||
|
onNavigate={onNavigate}
|
||||||
|
title={intl.formatMessage(messages.collapsed)}
|
||||||
|
/>
|
||||||
|
<LocalSettingsNavigationItem
|
||||||
|
active={index === 2}
|
||||||
|
index={2}
|
||||||
|
onNavigate={onNavigate}
|
||||||
|
title={intl.formatMessage(messages.media)}
|
||||||
|
/>
|
||||||
|
<LocalSettingsNavigationItem
|
||||||
|
active={index === 3}
|
||||||
|
href='/settings/preferences'
|
||||||
|
index={3}
|
||||||
|
icon='cog'
|
||||||
|
title={intl.formatMessage(messages.preferences)}
|
||||||
|
/>
|
||||||
|
<LocalSettingsNavigationItem
|
||||||
|
active={index === 4}
|
||||||
|
className='close'
|
||||||
|
index={4}
|
||||||
|
onNavigate={onClose}
|
||||||
|
title={intl.formatMessage(messages.close)}
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Package imports
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
// Stylesheet imports
|
||||||
|
import './style';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
export default class LocalSettingsPage extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
active: PropTypes.bool,
|
||||||
|
className: PropTypes.string,
|
||||||
|
href: PropTypes.string,
|
||||||
|
icon: PropTypes.string,
|
||||||
|
index: PropTypes.number.isRequired,
|
||||||
|
onNavigate: PropTypes.func,
|
||||||
|
title: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClick = (e) => {
|
||||||
|
const { index, onNavigate } = this.props;
|
||||||
|
if (onNavigate) {
|
||||||
|
onNavigate(index);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { handleClick } = this;
|
||||||
|
const {
|
||||||
|
active,
|
||||||
|
className,
|
||||||
|
href,
|
||||||
|
icon,
|
||||||
|
onNavigate,
|
||||||
|
title,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
const finalClassName = classNames('glitch', 'local-settings__navigation__item', {
|
||||||
|
active,
|
||||||
|
}, className);
|
||||||
|
|
||||||
|
const iconElem = icon ? <i className={`fa fa-fw fa-${icon}`} /> : null;
|
||||||
|
|
||||||
|
if (href) return (
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
className={finalClassName}
|
||||||
|
>
|
||||||
|
{iconElem} {title}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
else if (onNavigate) return (
|
||||||
|
<a
|
||||||
|
onClick={handleClick}
|
||||||
|
role='button'
|
||||||
|
tabIndex='0'
|
||||||
|
className={finalClassName}
|
||||||
|
>
|
||||||
|
{iconElem} {title}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
@import 'variables';
|
||||||
|
|
||||||
|
.glitch.local-settings__navigation__item {
|
||||||
|
display: block;
|
||||||
|
padding: 15px 20px;
|
||||||
|
color: inherit;
|
||||||
|
background: $primary-text-color;
|
||||||
|
border-bottom: 1px $ui-primary-color solid;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
outline: none;
|
||||||
|
transition: background .3s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: $ui-secondary-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background: $ui-highlight-color;
|
||||||
|
color: $primary-text-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.close, &.close:hover {
|
||||||
|
background: $error-value-color;
|
||||||
|
color: $primary-text-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@import 'variables';
|
||||||
|
|
||||||
|
.glitch.local-settings__navigation {
|
||||||
|
background: $primary-text-color;
|
||||||
|
color: $ui-base-color;
|
||||||
|
width: 200px;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 20px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
183
app/javascript/glitch/components/local_settings/page/index.js
Normal file
183
app/javascript/glitch/components/local_settings/page/index.js
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
// Package imports
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
|
||||||
|
|
||||||
|
// Our imports
|
||||||
|
import LocalSettingsPageItem from './item';
|
||||||
|
|
||||||
|
// Stylesheet imports
|
||||||
|
import './style';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
layout_auto: { id: 'layout.auto', defaultMessage: 'Auto' },
|
||||||
|
layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' },
|
||||||
|
layout_mobile: { id: 'layout.single', defaultMessage: 'Mobile' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class LocalSettingsPage extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
index : PropTypes.number,
|
||||||
|
intl : PropTypes.object.isRequired,
|
||||||
|
onChange : PropTypes.func.isRequired,
|
||||||
|
settings : ImmutablePropTypes.map.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
pages = [
|
||||||
|
({ intl, onChange, settings }) => (
|
||||||
|
<div className='glitch local-settings__page general'>
|
||||||
|
<h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['layout']}
|
||||||
|
id='mastodon-settings--layout'
|
||||||
|
options={[
|
||||||
|
{ value: 'auto', message: intl.formatMessage(messages.layout_auto) },
|
||||||
|
{ value: 'multiple', message: intl.formatMessage(messages.layout_desktop) },
|
||||||
|
{ value: 'single', message: intl.formatMessage(messages.layout_mobile) },
|
||||||
|
]}
|
||||||
|
onChange={onChange}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.layout' defaultMessage='Layout:' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['stretch']}
|
||||||
|
id='mastodon-settings--stretch'
|
||||||
|
onChange={onChange}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['navbar_under']}
|
||||||
|
id='mastodon-settings--navbar_under'
|
||||||
|
onChange={onChange}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.navbar_under' defaultMessage='Navbar at the bottom (Mobile only)' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
({ onChange, settings }) => (
|
||||||
|
<div className='glitch local-settings__page collapsed'>
|
||||||
|
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'enabled']}
|
||||||
|
id='mastodon-settings--collapsed-enabled'
|
||||||
|
onChange={onChange}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<section>
|
||||||
|
<h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'auto', 'all']}
|
||||||
|
id='mastodon-settings--collapsed-auto-all'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'auto', 'notifications']}
|
||||||
|
id='mastodon-settings--collapsed-auto-notifications'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'auto', 'lengthy']}
|
||||||
|
id='mastodon-settings--collapsed-auto-lengthy'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'auto', 'replies']}
|
||||||
|
id='mastodon-settings--collapsed-auto-replies'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'auto', 'media']}
|
||||||
|
id='mastodon-settings--collapsed-auto-media'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'backgrounds', 'user_backgrounds']}
|
||||||
|
id='mastodon-settings--collapsed-user-backgrouns'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['collapsed', 'backgrounds', 'preview_images']}
|
||||||
|
id='mastodon-settings--collapsed-preview-images'
|
||||||
|
onChange={onChange}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
({ onChange, settings }) => (
|
||||||
|
<div className='glitch local-settings__page media'>
|
||||||
|
<h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['media', 'letterbox']}
|
||||||
|
id='mastodon-settings--media-letterbox'
|
||||||
|
onChange={onChange}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
<LocalSettingsPageItem
|
||||||
|
settings={settings}
|
||||||
|
item={['media', 'fullwidth']}
|
||||||
|
id='mastodon-settings--media-fullwidth'
|
||||||
|
onChange={onChange}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' />
|
||||||
|
</LocalSettingsPageItem>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { pages } = this;
|
||||||
|
const { index, intl, onChange, settings } = this.props;
|
||||||
|
const CurrentPage = pages[index] || pages[0];
|
||||||
|
|
||||||
|
return <CurrentPage intl={intl} onChange={onChange} settings={settings} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
// Package imports
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
|
// Stylesheet imports
|
||||||
|
import './style';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
export default class LocalSettingsPageItem extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
children: PropTypes.element.isRequired,
|
||||||
|
dependsOn: PropTypes.array,
|
||||||
|
dependsOnNot: PropTypes.array,
|
||||||
|
id: PropTypes.string.isRequired,
|
||||||
|
item: PropTypes.array.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
options: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
value: PropTypes.string.isRequired,
|
||||||
|
message: PropTypes.string.isRequired,
|
||||||
|
})),
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleChange = e => {
|
||||||
|
const { target } = e;
|
||||||
|
const { item, onChange, options } = this.props;
|
||||||
|
if (options && options.length > 0) onChange(item, target.value);
|
||||||
|
else onChange(item, target.checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { handleChange } = this;
|
||||||
|
const { settings, item, id, options, children, dependsOn, dependsOnNot } = this.props;
|
||||||
|
let enabled = true;
|
||||||
|
|
||||||
|
if (dependsOn) {
|
||||||
|
for (let i = 0; i < dependsOn.length; i++) {
|
||||||
|
enabled = enabled && settings.getIn(dependsOn[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dependsOnNot) {
|
||||||
|
for (let i = 0; i < dependsOnNot.length; i++) {
|
||||||
|
enabled = enabled && !settings.getIn(dependsOnNot[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options && options.length > 0) {
|
||||||
|
const currentValue = settings.getIn(item);
|
||||||
|
const optionElems = options && options.length > 0 && options.map((opt) => (
|
||||||
|
<option
|
||||||
|
key={opt.value}
|
||||||
|
value={opt.value}
|
||||||
|
>
|
||||||
|
{opt.message}
|
||||||
|
</option>
|
||||||
|
));
|
||||||
|
return (
|
||||||
|
<label className='glitch local-settings__page__item' htmlFor={id}>
|
||||||
|
<p>{children}</p>
|
||||||
|
<p>
|
||||||
|
<select
|
||||||
|
id={id}
|
||||||
|
disabled={!enabled}
|
||||||
|
onBlur={handleChange}
|
||||||
|
onChange={handleChange}
|
||||||
|
value={currentValue}
|
||||||
|
>
|
||||||
|
{optionElems}
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
} else return (
|
||||||
|
<label className='glitch local-settings__page__item' htmlFor={id}>
|
||||||
|
<input
|
||||||
|
id={id}
|
||||||
|
type='checkbox'
|
||||||
|
checked={settings.getIn(item)}
|
||||||
|
onChange={handleChange}
|
||||||
|
disabled={!enabled}
|
||||||
|
/>
|
||||||
|
{children}
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
@import 'variables';
|
||||||
|
|
||||||
|
.glitch.local-settings__page__item {
|
||||||
|
select {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
@import 'variables';
|
||||||
|
|
||||||
|
.glitch.local-settings__page {
|
||||||
|
display: block;
|
||||||
|
flex: auto;
|
||||||
|
padding: 15px 20px 15px 20px;
|
||||||
|
width: 360px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
34
app/javascript/glitch/components/local_settings/style.scss
Normal file
34
app/javascript/glitch/components/local_settings/style.scss
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
@import 'variables';
|
||||||
|
|
||||||
|
.glitch.local-settings {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
background: $ui-secondary-color;
|
||||||
|
color: $ui-base-color;
|
||||||
|
border-radius: 8px;
|
||||||
|
height: 80vh;
|
||||||
|
width: 80vw;
|
||||||
|
max-width: 740px;
|
||||||
|
max-height: 450px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 24px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/javascript/glitch/components/notification/container.js
Normal file
55
app/javascript/glitch/components/notification/container.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<NotificationContainer>`
|
||||||
|
=========================
|
||||||
|
|
||||||
|
This container connects `<Notification>`s to the Redux store.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { makeGetNotification } from '../../../mastodon/selectors';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import Notification from '.';
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
State mapping:
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The `mapStateToProps()` function maps various state properties to the
|
||||||
|
props of our component. We wrap this in `makeMapStateToProps()` so that
|
||||||
|
we only have to call `makeGetNotification()` once instead of every
|
||||||
|
time.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const makeMapStateToProps = () => {
|
||||||
|
const getNotification = makeGetNotification();
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({
|
||||||
|
notification: getNotification(state, props.notification, props.accountId),
|
||||||
|
settings: state.get('local_settings'),
|
||||||
|
});
|
||||||
|
|
||||||
|
return mapStateToProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
export default connect(makeMapStateToProps)(Notification);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user