mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Compare commits
298 Commits
more-front
...
split-comp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
2
.babelrc
2
.babelrc
@@ -15,6 +15,7 @@
|
|||||||
"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",
|
||||||
@@ -43,6 +44,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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|||||||
1
Aptfile
1
Aptfile
@@ -3,3 +3,4 @@ libprotobuf-dev
|
|||||||
ffmpeg
|
ffmpeg
|
||||||
libxdamage1
|
libxdamage1
|
||||||
libxfixes3
|
libxfixes3
|
||||||
|
libicu-dev
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
|
|||||||
ffmpeg \
|
ffmpeg \
|
||||||
file \
|
file \
|
||||||
git \
|
git \
|
||||||
|
icu-dev \
|
||||||
imagemagick@edge \
|
imagemagick@edge \
|
||||||
libpq \
|
libpq \
|
||||||
libxml2 \
|
libxml2 \
|
||||||
|
|||||||
4
Gemfile
4
Gemfile
@@ -18,8 +18,11 @@ 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'
|
||||||
@@ -34,6 +37,7 @@ gem 'http_accept_language', '~> 2.1'
|
|||||||
gem 'httplog', '~> 0.99'
|
gem 'httplog', '~> 0.99'
|
||||||
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'
|
||||||
|
|||||||
126
Gemfile.lock
126
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)
|
||||||
@@ -160,7 +169,7 @@ GEM
|
|||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
http (~> 2.0)
|
http (~> 2.0)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.6)
|
||||||
hamlit (2.8.1)
|
hamlit (2.8.4)
|
||||||
temple (>= 0.8.0)
|
temple (>= 0.8.0)
|
||||||
thor
|
thor
|
||||||
tilt
|
tilt
|
||||||
@@ -181,9 +190,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)
|
||||||
@@ -199,6 +208,7 @@ GEM
|
|||||||
terminal-table (>= 1.5.1)
|
terminal-table (>= 1.5.1)
|
||||||
jmespath (1.3.1)
|
jmespath (1.3.1)
|
||||||
json (2.1.0)
|
json (2.1.0)
|
||||||
|
jsonapi-renderer (0.1.2)
|
||||||
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)
|
||||||
@@ -248,8 +258,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 +281,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 +307,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 +333,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 +383,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 +404,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 +415,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 +452,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 +463,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)
|
||||||
@@ -475,6 +485,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 +494,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 +502,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)
|
||||||
@@ -514,6 +527,7 @@ DEPENDENCIES
|
|||||||
link_header (~> 0.0)
|
link_header (~> 0.0)
|
||||||
lograge (~> 0.5)
|
lograge (~> 0.5)
|
||||||
microformats2 (~> 3.0)
|
microformats2 (~> 3.0)
|
||||||
|
mime-types (~> 3.1)
|
||||||
nokogiri (~> 1.7)
|
nokogiri (~> 1.7)
|
||||||
oj (~> 3.0)
|
oj (~> 3.0)
|
||||||
ostatus2 (~> 2.0)
|
ostatus2 (~> 2.0)
|
||||||
|
|||||||
@@ -2,4 +2,6 @@ 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?
|
||||||
|
|||||||
6
Vagrantfile
vendored
6
Vagrantfile
vendored
@@ -37,14 +37,18 @@ sudo apt-get install \
|
|||||||
yarn \
|
yarn \
|
||||||
libprotobuf-dev \
|
libprotobuf-dev \
|
||||||
libreadline-dev \
|
libreadline-dev \
|
||||||
|
libicu-dev \
|
||||||
-y
|
-y
|
||||||
|
|
||||||
# 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,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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,14 +9,13 @@ 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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -46,10 +47,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
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
class Api::V1::SearchController < Api::BaseController
|
class Api::V1::SearchController < Api::BaseController
|
||||||
RESULTS_LIMIT = 5
|
RESULTS_LIMIT = 5
|
||||||
|
|
||||||
|
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
|
||||||
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
|
||||||
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,17 @@ 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 || {},
|
||||||
|
current_account: current_account,
|
||||||
|
token: current_session.token,
|
||||||
|
admin: Account.find_local(Setting.site_contact_username),
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,9 +34,11 @@ 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_boost_modal,
|
:setting_boost_modal,
|
||||||
:setting_delete_modal,
|
:setting_delete_modal,
|
||||||
:setting_auto_play_gif,
|
:setting_auto_play_gif,
|
||||||
|
:setting_system_font_ui,
|
||||||
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)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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.
20
app/javascript/glitch/actions/local_settings.js
Normal file
20
app/javascript/glitch/actions/local_settings.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export const LOCAL_SETTING_CHANGE = 'LOCAL_SETTING_CHANGE';
|
||||||
|
|
||||||
|
export function changeLocalSetting(key, value) {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch({
|
||||||
|
type: LOCAL_SETTING_CHANGE,
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(saveLocalSettings());
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function saveLocalSettings() {
|
||||||
|
return (_, getState) => {
|
||||||
|
const localSettings = getState().get('local_settings').toJS();
|
||||||
|
localStorage.setItem('mastodon-settings', JSON.stringify(localSettings));
|
||||||
|
};
|
||||||
|
};
|
||||||
112
app/javascript/glitch/components/account/header.js
Normal file
112
app/javascript/glitch/components/account/header.js
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
// 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';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||||
|
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
||||||
|
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class Header extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
account: ImmutablePropTypes.map,
|
||||||
|
me: PropTypes.number.isRequired,
|
||||||
|
onFollow: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { account, me, intl } = this.props;
|
||||||
|
|
||||||
|
if (!account) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let displayName = account.get('display_name');
|
||||||
|
let info = '';
|
||||||
|
let actionBtn = '';
|
||||||
|
let lockedIcon = '';
|
||||||
|
|
||||||
|
if (displayName.length === 0) {
|
||||||
|
displayName = account.get('username');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (me !== account.get('id') && account.getIn(['relationship', 'followed_by'])) {
|
||||||
|
info = <span className='account--follows-info'><FormattedMessage id='account.follows_you' defaultMessage='Follows you' /></span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (me !== account.get('id')) {
|
||||||
|
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'])) {
|
||||||
|
actionBtn = (
|
||||||
|
<div className='account--action-button'>
|
||||||
|
<IconButton size={26} icon={account.getIn(['relationship', 'following']) ? 'user-times' : 'user-plus'} active={account.getIn(['relationship', 'following'])} title={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={this.props.onFollow} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account.get('locked')) {
|
||||||
|
lockedIcon = <i className='fa fa-lock' />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
|
||||||
|
const { text, metadata } = processBio(account.get('note'));
|
||||||
|
|
||||||
|
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')} {lockedIcon}</span>
|
||||||
|
<div className='account__header__content' dangerouslySetInnerHTML={{ __html: emojify(text) }} />
|
||||||
|
|
||||||
|
{info}
|
||||||
|
{actionBtn}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{metadata.length && (
|
||||||
|
<table className='account__metadata'>
|
||||||
|
{(() => {
|
||||||
|
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;
|
||||||
|
})()}
|
||||||
|
</table>
|
||||||
|
) || null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
112
app/javascript/glitch/components/compose/advanced_options.js
Normal file
112
app/javascript/glitch/components/compose/advanced_options.js
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import Toggle from 'react-toggle';
|
||||||
|
import { injectIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import IconButton from '../../../mastodon/components/icon_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',
|
||||||
|
};
|
||||||
|
|
||||||
|
@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,
|
||||||
|
};
|
||||||
|
|
||||||
|
onToggleDropdown = () => {
|
||||||
|
this.setState({ open: !this.state.open });
|
||||||
|
};
|
||||||
|
|
||||||
|
onGlobalClick = (e) => {
|
||||||
|
if (e.target !== this.node && !this.node.contains(e.target) && this.state.open) {
|
||||||
|
this.setState({ open: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
window.addEventListener('click', this.onGlobalClick);
|
||||||
|
window.addEventListener('touchstart', this.onGlobalClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
window.removeEventListener('click', this.onGlobalClick);
|
||||||
|
window.removeEventListener('touchstart', this.onGlobalClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
state = {
|
||||||
|
open: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClick = (e) => {
|
||||||
|
const option = e.currentTarget.getAttribute('data-index');
|
||||||
|
e.preventDefault();
|
||||||
|
this.props.onChange(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleHandler(option) {
|
||||||
|
return () => this.props.onChange(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
setRef = (c) => {
|
||||||
|
this.node = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { open } = this.state;
|
||||||
|
const { intl, values } = this.props;
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{ icon: 'wifi', shortText: messages.local_only_short, longText: messages.local_only_long, key: 'do_not_federate' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const anyEnabled = values.some((enabled) => enabled);
|
||||||
|
const optionElems = options.map((option) => {
|
||||||
|
const active = values.get(option.key);
|
||||||
|
return (
|
||||||
|
<div role='button' className='advanced-options-dropdown__option' key={option.key} >
|
||||||
|
<div className='advanced-options-dropdown__option__toggle'>
|
||||||
|
<Toggle checked={active} onChange={this.toggleHandler(option.key)} />
|
||||||
|
</div>
|
||||||
|
<div className='advanced-options-dropdown__option__content'>
|
||||||
|
<strong>{intl.formatMessage(option.shortText)}</strong>
|
||||||
|
{intl.formatMessage(option.longText)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
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>);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
93
app/javascript/glitch/components/notification/index.js
Normal file
93
app/javascript/glitch/components/notification/index.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import AccountContainer from '../../../mastodon/containers/account_container';
|
||||||
|
import Permalink from '../../../mastodon/components/permalink';
|
||||||
|
import emojify from '../../../mastodon/emoji';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import StatusContainer from '../../containers/status';
|
||||||
|
|
||||||
|
export default class Notification extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
notification: ImmutablePropTypes.map.isRequired,
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
renderFollow (notification) {
|
||||||
|
const account = notification.get('account');
|
||||||
|
const displayName = account.get('display_name').length > 0 ? account.get('display_name') : account.get('username');
|
||||||
|
const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
|
||||||
|
const link = <Permalink className='notification__display-name' href={account.get('url')} title={account.get('acct')} to={`/accounts/${account.get('id')}`} dangerouslySetInnerHTML={displayNameHTML} />;
|
||||||
|
return (
|
||||||
|
<div className='notification notification-follow'>
|
||||||
|
<div className='notification__message'>
|
||||||
|
<div className='notification__favourite-icon-wrapper'>
|
||||||
|
<i className='fa fa-fw fa-user-plus' />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormattedMessage id='notification.follow' defaultMessage='{name} followed you' values={{ name: link }} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<AccountContainer id={account.get('id')} withNote={false} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderMention (notification) {
|
||||||
|
return (
|
||||||
|
<StatusContainer
|
||||||
|
id={notification.get('status')}
|
||||||
|
withDismiss
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderFavourite (notification) {
|
||||||
|
return (
|
||||||
|
<StatusContainer
|
||||||
|
id={notification.get('status')}
|
||||||
|
account={notification.get('account')}
|
||||||
|
prepend='favourite'
|
||||||
|
muted
|
||||||
|
withDismiss
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderReblog (notification) {
|
||||||
|
return (
|
||||||
|
<StatusContainer
|
||||||
|
id={notification.get('status')}
|
||||||
|
account={notification.get('account')}
|
||||||
|
prepend='reblog'
|
||||||
|
muted
|
||||||
|
withDismiss
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { notification } = this.props;
|
||||||
|
|
||||||
|
switch(notification.get('type')) {
|
||||||
|
case 'follow':
|
||||||
|
return this.renderFollow(notification);
|
||||||
|
case 'mention':
|
||||||
|
return this.renderMention(notification);
|
||||||
|
case 'favourite':
|
||||||
|
return this.renderFavourite(notification);
|
||||||
|
case 'reblog':
|
||||||
|
return this.renderReblog(notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
221
app/javascript/glitch/components/settings/index.js
Normal file
221
app/javascript/glitch/components/settings/index.js
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import SettingsItem from './item';
|
||||||
|
|
||||||
|
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 Settings extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
toggleSetting: PropTypes.func.isRequired,
|
||||||
|
changeSetting: PropTypes.func.isRequired,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
currentIndex: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
General = () => {
|
||||||
|
const { intl } = this.props;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.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={this.props.changeSetting}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.layout' defaultMessage='Layout:' />
|
||||||
|
</SettingsItem>
|
||||||
|
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['stretch']}
|
||||||
|
id='mastodon-settings--stretch'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' />
|
||||||
|
</SettingsItem>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
CollapsedStatuses = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'enabled']}
|
||||||
|
id='mastodon-settings--collapsed-enabled'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' />
|
||||||
|
</SettingsItem>
|
||||||
|
<section>
|
||||||
|
<h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'auto', 'all']}
|
||||||
|
id='mastodon-settings--collapsed-auto-all'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' />
|
||||||
|
</SettingsItem>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'auto', 'notifications']}
|
||||||
|
id='mastodon-settings--collapsed-auto-notifications'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' />
|
||||||
|
</SettingsItem>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'auto', 'lengthy']}
|
||||||
|
id='mastodon-settings--collapsed-auto-lengthy'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' />
|
||||||
|
</SettingsItem>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'auto', 'replies']}
|
||||||
|
id='mastodon-settings--collapsed-auto-replies'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' />
|
||||||
|
</SettingsItem>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'auto', 'media']}
|
||||||
|
id='mastodon-settings--collapsed-auto-media'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' />
|
||||||
|
</SettingsItem>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'backgrounds', 'user_backgrounds']}
|
||||||
|
id='mastodon-settings--collapsed-user-backgrouns'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' />
|
||||||
|
</SettingsItem>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['collapsed', 'backgrounds', 'preview_images']}
|
||||||
|
id='mastodon-settings--collapsed-preview-images'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
dependsOn={[['collapsed', 'enabled']]}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' />
|
||||||
|
</SettingsItem>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Media = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['media', 'letterbox']}
|
||||||
|
id='mastodon-settings--media-letterbox'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' />
|
||||||
|
</SettingsItem>
|
||||||
|
<SettingsItem
|
||||||
|
settings={this.props.settings}
|
||||||
|
item={['media', 'fullwidth']}
|
||||||
|
id='mastodon-settings--media-fullwidth'
|
||||||
|
onChange={this.props.toggleSetting}
|
||||||
|
>
|
||||||
|
<FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' />
|
||||||
|
</SettingsItem>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
navigateTo = (e) =>
|
||||||
|
this.setState({ currentIndex: +e.currentTarget.getAttribute('data-mastodon-navigation_index') });
|
||||||
|
|
||||||
|
render () {
|
||||||
|
|
||||||
|
const { General, CollapsedStatuses, Media, navigateTo } = this;
|
||||||
|
const { onClose } = this.props;
|
||||||
|
const { currentIndex } = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='modal-root__modal settings-modal'>
|
||||||
|
|
||||||
|
<nav className='settings-modal__navigation'>
|
||||||
|
<a onClick={navigateTo} role='button' data-mastodon-navigation_index='0' tabIndex='0' className={`settings-modal__navigation-item${currentIndex === 0 ? ' active' : ''}`}>
|
||||||
|
<FormattedMessage id='settings.general' defaultMessage='General' />
|
||||||
|
</a>
|
||||||
|
<a onClick={navigateTo} role='button' data-mastodon-navigation_index='1' tabIndex='0' className={`settings-modal__navigation-item${currentIndex === 1 ? ' active' : ''}`}>
|
||||||
|
<FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' />
|
||||||
|
</a>
|
||||||
|
<a onClick={navigateTo} role='button' data-mastodon-navigation_index='2' tabIndex='0' className={`settings-modal__navigation-item${currentIndex === 2 ? ' active' : ''}`}>
|
||||||
|
<FormattedMessage id='settings.media' defaultMessage='Media' />
|
||||||
|
</a>
|
||||||
|
<a href='/settings/preferences' className='settings-modal__navigation-item'>
|
||||||
|
<i className='fa fa-fw fa-cog' /> <FormattedMessage id='settings.preferences' defaultMessage='User preferences' />
|
||||||
|
</a>
|
||||||
|
<a onClick={onClose} role='button' tabIndex='0' className='settings-modal__navigation-close'>
|
||||||
|
<FormattedMessage id='settings.close' defaultMessage='Close' />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className='settings-modal__content'>
|
||||||
|
{
|
||||||
|
[
|
||||||
|
<General />,
|
||||||
|
<CollapsedStatuses />,
|
||||||
|
<Media />,
|
||||||
|
][currentIndex] || <General />
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
79
app/javascript/glitch/components/settings/item.js
Normal file
79
app/javascript/glitch/components/settings/item.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
|
export default class SettingsItem extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
|
item: PropTypes.array.isRequired,
|
||||||
|
id: PropTypes.string.isRequired,
|
||||||
|
options: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
value: PropTypes.string.isRequired,
|
||||||
|
message: PropTypes.object.isRequired,
|
||||||
|
})),
|
||||||
|
dependsOn: PropTypes.array,
|
||||||
|
dependsOnNot: PropTypes.array,
|
||||||
|
children: PropTypes.element.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleChange = (e) => {
|
||||||
|
const { item, onChange } = this.props;
|
||||||
|
onChange(item, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
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} selected={currentValue === opt.value} value={opt.value} >
|
||||||
|
{opt.message}
|
||||||
|
</option>
|
||||||
|
));
|
||||||
|
return (
|
||||||
|
<label htmlFor={id}>
|
||||||
|
<p>{children}</p>
|
||||||
|
<p>
|
||||||
|
<select
|
||||||
|
id={id}
|
||||||
|
disabled={!enabled}
|
||||||
|
onBlur={this.handleChange}
|
||||||
|
>
|
||||||
|
{optionElems}
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<label htmlFor={id}>
|
||||||
|
<input
|
||||||
|
id={id}
|
||||||
|
type='checkbox'
|
||||||
|
checked={settings.getIn(item)}
|
||||||
|
onChange={this.handleChange}
|
||||||
|
disabled={!enabled}
|
||||||
|
/>
|
||||||
|
{children}
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
159
app/javascript/glitch/components/status/action_bar.js
Normal file
159
app/javascript/glitch/components/status/action_bar.js
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import RelativeTimestamp from '../../../mastodon/components/relative_timestamp';
|
||||||
|
import IconButton from '../../../mastodon/components/icon_button';
|
||||||
|
import DropdownMenu from '../../../mastodon/components/dropdown_menu';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
||||||
|
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
||||||
|
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
||||||
|
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
||||||
|
reply: { id: 'status.reply', defaultMessage: 'Reply' },
|
||||||
|
replyAll: { id: 'status.replyAll', defaultMessage: 'Reply to thread' },
|
||||||
|
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
|
||||||
|
cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' },
|
||||||
|
favourite: { id: 'status.favourite', defaultMessage: 'Favourite' },
|
||||||
|
open: { id: 'status.open', defaultMessage: 'Expand this status' },
|
||||||
|
report: { id: 'status.report', defaultMessage: 'Report @{name}' },
|
||||||
|
muteConversation: { id: 'status.mute_conversation', defaultMessage: 'Mute conversation' },
|
||||||
|
unmuteConversation: { id: 'status.unmute_conversation', defaultMessage: 'Unmute conversation' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class StatusActionBar extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
status: ImmutablePropTypes.map.isRequired,
|
||||||
|
onReply: PropTypes.func,
|
||||||
|
onFavourite: PropTypes.func,
|
||||||
|
onReblog: PropTypes.func,
|
||||||
|
onDelete: PropTypes.func,
|
||||||
|
onMention: PropTypes.func,
|
||||||
|
onMute: PropTypes.func,
|
||||||
|
onBlock: PropTypes.func,
|
||||||
|
onReport: PropTypes.func,
|
||||||
|
onMuteConversation: PropTypes.func,
|
||||||
|
me: PropTypes.number.isRequired,
|
||||||
|
withDismiss: PropTypes.bool,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Avoid checking props that are functions (and whose equality will always
|
||||||
|
// evaluate to false. See react-immutable-pure-component for usage.
|
||||||
|
updateOnProps = [
|
||||||
|
'status',
|
||||||
|
'me',
|
||||||
|
'withDismiss',
|
||||||
|
]
|
||||||
|
|
||||||
|
handleReplyClick = () => {
|
||||||
|
this.props.onReply(this.props.status, this.context.router.history);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleFavouriteClick = () => {
|
||||||
|
this.props.onFavourite(this.props.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleReblogClick = (e) => {
|
||||||
|
this.props.onReblog(this.props.status, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDeleteClick = () => {
|
||||||
|
this.props.onDelete(this.props.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMentionClick = () => {
|
||||||
|
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMuteClick = () => {
|
||||||
|
this.props.onMute(this.props.status.get('account'));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleBlockClick = () => {
|
||||||
|
this.props.onBlock(this.props.status.get('account'));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOpen = () => {
|
||||||
|
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleReport = () => {
|
||||||
|
this.props.onReport(this.props.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleConversationMuteClick = () => {
|
||||||
|
this.props.onMuteConversation(this.props.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { status, me, intl, withDismiss } = this.props;
|
||||||
|
const reblogDisabled = status.get('visibility') === 'private' || status.get('visibility') === 'direct';
|
||||||
|
const mutingConversation = status.get('muted');
|
||||||
|
|
||||||
|
let menu = [];
|
||||||
|
let reblogIcon = 'retweet';
|
||||||
|
let replyIcon;
|
||||||
|
let replyTitle;
|
||||||
|
|
||||||
|
menu.push({ text: intl.formatMessage(messages.open), action: this.handleOpen });
|
||||||
|
menu.push(null);
|
||||||
|
|
||||||
|
if (withDismiss) {
|
||||||
|
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
||||||
|
menu.push(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status.getIn(['account', 'id']) === me) {
|
||||||
|
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
||||||
|
} else {
|
||||||
|
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
||||||
|
menu.push(null);
|
||||||
|
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
||||||
|
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||||
|
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (status.get('visibility') === 'direct') {
|
||||||
|
reblogIcon = 'envelope';
|
||||||
|
} else if (status.get('visibility') === 'private') {
|
||||||
|
reblogIcon = 'lock';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (status.get('in_reply_to_id', null) === null) {
|
||||||
|
replyIcon = 'reply';
|
||||||
|
replyTitle = intl.formatMessage(messages.reply);
|
||||||
|
} else {
|
||||||
|
replyIcon = 'reply-all';
|
||||||
|
replyTitle = intl.formatMessage(messages.replyAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='status__action-bar'>
|
||||||
|
<IconButton className='status__action-bar-button' title={replyTitle} icon={replyIcon} onClick={this.handleReplyClick} />
|
||||||
|
<IconButton className='status__action-bar-button' disabled={reblogDisabled} active={status.get('reblogged')} title={reblogDisabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} icon={reblogIcon} onClick={this.handleReblogClick} />
|
||||||
|
<IconButton className='status__action-bar-button star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} />
|
||||||
|
|
||||||
|
<div className='status__action-bar-dropdown'>
|
||||||
|
<DropdownMenu items={menu} icon='ellipsis-h' size={18} direction='right' ariaLabel='More' />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
239
app/javascript/glitch/components/status/content.js
Normal file
239
app/javascript/glitch/components/status/content.js
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import emojify from '../../../mastodon/emoji';
|
||||||
|
import { isRtl } from '../../../mastodon/rtl';
|
||||||
|
import Permalink from '../../../mastodon/components/permalink';
|
||||||
|
|
||||||
|
export default class StatusContent extends React.PureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
status: ImmutablePropTypes.map.isRequired,
|
||||||
|
expanded: PropTypes.oneOf([true, false, null]),
|
||||||
|
setExpansion: PropTypes.func,
|
||||||
|
onHeightUpdate: PropTypes.func,
|
||||||
|
media: PropTypes.element,
|
||||||
|
mediaIcon: PropTypes.string,
|
||||||
|
parseClick: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
hidden: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
const node = this.node;
|
||||||
|
const links = node.querySelectorAll('a');
|
||||||
|
|
||||||
|
for (var i = 0; i < links.length; ++i) {
|
||||||
|
let link = links[i];
|
||||||
|
let mention = this.props.status.get('mentions').find(item => link.href === item.get('url'));
|
||||||
|
|
||||||
|
if (mention) {
|
||||||
|
link.addEventListener('click', this.onMentionClick.bind(this, mention), false);
|
||||||
|
link.setAttribute('title', mention.get('acct'));
|
||||||
|
} else if (link.textContent[0] === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[link.previousSibling.textContent.length - 1] === '#')) {
|
||||||
|
link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false);
|
||||||
|
} else {
|
||||||
|
link.addEventListener('click', this.onLinkClick.bind(this), false);
|
||||||
|
link.setAttribute('target', '_blank');
|
||||||
|
link.setAttribute('rel', 'noopener');
|
||||||
|
link.setAttribute('title', link.href);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate () {
|
||||||
|
if (this.props.onHeightUpdate) {
|
||||||
|
this.props.onHeightUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLinkClick = (e) => {
|
||||||
|
if (this.props.expanded === false) {
|
||||||
|
if (this.props.parseClick) this.props.parseClick(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMentionClick = (mention, e) => {
|
||||||
|
if (this.props.parseClick) {
|
||||||
|
this.props.parseClick(e, `/accounts/${mention.get('id')}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onHashtagClick = (hashtag, e) => {
|
||||||
|
hashtag = hashtag.replace(/^#/, '').toLowerCase();
|
||||||
|
|
||||||
|
if (this.props.parseClick) {
|
||||||
|
this.props.parseClick(e, `/timelines/tag/${hashtag}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMouseDown = (e) => {
|
||||||
|
this.startXY = [e.clientX, e.clientY];
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMouseUp = (e) => {
|
||||||
|
const { parseClick } = this.props;
|
||||||
|
|
||||||
|
if (!this.startXY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [ startX, startY ] = this.startXY;
|
||||||
|
const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)];
|
||||||
|
|
||||||
|
if (e.target.localName === 'button' || e.target.localName === 'a' || (e.target.parentNode && (e.target.parentNode.localName === 'button' || e.target.parentNode.localName === 'a'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deltaX + deltaY < 5 && e.button === 0 && parseClick) {
|
||||||
|
parseClick(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.startXY = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSpoilerClick = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (this.props.setExpansion) {
|
||||||
|
this.props.setExpansion(this.props.expanded ? null : true);
|
||||||
|
} else {
|
||||||
|
this.setState({ hidden: !this.state.hidden });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setRef = (c) => {
|
||||||
|
this.node = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { status, media, mediaIcon } = this.props;
|
||||||
|
|
||||||
|
const hidden = (
|
||||||
|
this.props.setExpansion ?
|
||||||
|
!this.props.expanded :
|
||||||
|
this.state.hidden
|
||||||
|
);
|
||||||
|
|
||||||
|
const content = { __html: emojify(status.get('content')) };
|
||||||
|
const spoilerContent = {
|
||||||
|
__html: emojify(escapeTextContentForBrowser(
|
||||||
|
status.get('spoiler_text', '')
|
||||||
|
)),
|
||||||
|
};
|
||||||
|
const directionStyle = { direction: 'ltr' };
|
||||||
|
|
||||||
|
if (isRtl(status.get('search_index'))) {
|
||||||
|
directionStyle.direction = 'rtl';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status.get('spoiler_text').length > 0) {
|
||||||
|
let mentionsPlaceholder = '';
|
||||||
|
|
||||||
|
const mentionLinks = status.get('mentions').map(item => (
|
||||||
|
<Permalink
|
||||||
|
to={`/accounts/${item.get('id')}`}
|
||||||
|
href={item.get('url')}
|
||||||
|
key={item.get('id')}
|
||||||
|
className='mention'
|
||||||
|
>
|
||||||
|
@<span>{item.get('username')}</span>
|
||||||
|
</Permalink>
|
||||||
|
)).reduce((aggregate, item) => [...aggregate, item, ' '], []);
|
||||||
|
|
||||||
|
const toggleText = hidden ? [
|
||||||
|
<FormattedMessage
|
||||||
|
id='status.show_more'
|
||||||
|
defaultMessage='Show more'
|
||||||
|
key='0'
|
||||||
|
/>,
|
||||||
|
mediaIcon ? (
|
||||||
|
<i
|
||||||
|
className={
|
||||||
|
`fa fa-fw fa-${mediaIcon} status__content__spoiler-icon`
|
||||||
|
}
|
||||||
|
aria-hidden='true'
|
||||||
|
key='1'
|
||||||
|
/>
|
||||||
|
) : null,
|
||||||
|
] : [
|
||||||
|
<FormattedMessage
|
||||||
|
id='status.show_less'
|
||||||
|
defaultMessage='Show less'
|
||||||
|
key='0'
|
||||||
|
/>,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (hidden) {
|
||||||
|
mentionsPlaceholder = <div>{mentionLinks}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='status__content status__content--with-action' ref={this.setRef}>
|
||||||
|
<p
|
||||||
|
style={{ marginBottom: hidden && status.get('mentions').isEmpty() ? '0px' : null }}
|
||||||
|
onMouseDown={this.handleMouseDown}
|
||||||
|
onMouseUp={this.handleMouseUp}
|
||||||
|
>
|
||||||
|
<span dangerouslySetInnerHTML={spoilerContent} />
|
||||||
|
{' '}
|
||||||
|
<button tabIndex='0' className='status__content__spoiler-link' onClick={this.handleSpoilerClick}>
|
||||||
|
{toggleText}
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{mentionsPlaceholder}
|
||||||
|
|
||||||
|
<div className={`status__content__spoiler ${!hidden ? 'status__content__spoiler--visible' : ''}`}>
|
||||||
|
<div
|
||||||
|
style={directionStyle}
|
||||||
|
onMouseDown={this.handleMouseDown}
|
||||||
|
onMouseUp={this.handleMouseUp}
|
||||||
|
dangerouslySetInnerHTML={content}
|
||||||
|
/>
|
||||||
|
{media}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (this.props.parseClick) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={this.setRef}
|
||||||
|
className='status__content status__content--with-action'
|
||||||
|
style={directionStyle}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
onMouseDown={this.handleMouseDown}
|
||||||
|
onMouseUp={this.handleMouseUp}
|
||||||
|
dangerouslySetInnerHTML={content}
|
||||||
|
/>
|
||||||
|
{media}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={this.setRef}
|
||||||
|
className='status__content'
|
||||||
|
style={directionStyle}
|
||||||
|
>
|
||||||
|
<div dangerouslySetInnerHTML={content} />
|
||||||
|
{media}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
79
app/javascript/glitch/components/status/gallery/index.js
Normal file
79
app/javascript/glitch/components/status/gallery/index.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import IconButton from '../../../../mastodon/components/icon_button';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import StatusGalleryItem from './item';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
toggle_visible: { id: 'media_gallery.toggle_visible', defaultMessage: 'Toggle visibility' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class StatusGallery extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
sensitive: PropTypes.bool,
|
||||||
|
media: ImmutablePropTypes.list.isRequired,
|
||||||
|
letterbox: PropTypes.bool,
|
||||||
|
fullwidth: PropTypes.bool,
|
||||||
|
height: PropTypes.number.isRequired,
|
||||||
|
onOpenMedia: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
autoPlayGif: PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
visible: !this.props.sensitive,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleOpen = () => {
|
||||||
|
this.setState({ visible: !this.state.visible });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClick = (index) => {
|
||||||
|
this.props.onOpenMedia(this.props.media, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { media, intl, sensitive, letterbox, fullwidth } = this.props;
|
||||||
|
|
||||||
|
let children;
|
||||||
|
|
||||||
|
if (!this.state.visible) {
|
||||||
|
let warning;
|
||||||
|
|
||||||
|
if (sensitive) {
|
||||||
|
warning = <FormattedMessage id='status.sensitive_warning' defaultMessage='Sensitive content' />;
|
||||||
|
} else {
|
||||||
|
warning = <FormattedMessage id='status.media_hidden' defaultMessage='Media hidden' />;
|
||||||
|
}
|
||||||
|
|
||||||
|
children = (
|
||||||
|
<div role='button' tabIndex='0' className='media-spoiler' onClick={this.handleOpen}>
|
||||||
|
<span className='media-spoiler__warning'>{warning}</span>
|
||||||
|
<span className='media-spoiler__trigger'><FormattedMessage id='status.sensitive_toggle' defaultMessage='Click to view' /></span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const size = media.take(4).size;
|
||||||
|
children = media.take(4).map((attachment, i) => <StatusGalleryItem key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} autoPlayGif={this.props.autoPlayGif} index={i} size={size} letterbox={letterbox} />);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`media-gallery ${fullwidth ? 'full-width' : ''}`} style={{ height: `${this.props.height}px` }}>
|
||||||
|
<div className={`spoiler-button ${this.state.visible ? 'spoiler-button--visible' : ''}`}>
|
||||||
|
<IconButton title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} overlay onClick={this.handleOpen} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
132
app/javascript/glitch/components/status/gallery/item.js
Normal file
132
app/javascript/glitch/components/status/gallery/item.js
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { isIOS } from '../../../../mastodon/is_mobile';
|
||||||
|
|
||||||
|
export default class StatusGalleryItem extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
attachment: ImmutablePropTypes.map.isRequired,
|
||||||
|
index: PropTypes.number.isRequired,
|
||||||
|
size: PropTypes.number.isRequired,
|
||||||
|
letterbox: PropTypes.bool,
|
||||||
|
onClick: PropTypes.func.isRequired,
|
||||||
|
autoPlayGif: PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClick = (e) => {
|
||||||
|
const { index, onClick } = this.props;
|
||||||
|
|
||||||
|
if (e.button === 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
onClick(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { attachment, index, size, letterbox } = this.props;
|
||||||
|
|
||||||
|
let width = 50;
|
||||||
|
let height = 100;
|
||||||
|
let top = 'auto';
|
||||||
|
let left = 'auto';
|
||||||
|
let bottom = 'auto';
|
||||||
|
let right = 'auto';
|
||||||
|
|
||||||
|
if (size === 1) {
|
||||||
|
width = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size === 4 || (size === 3 && index > 0)) {
|
||||||
|
height = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size === 2) {
|
||||||
|
if (index === 0) {
|
||||||
|
right = '2px';
|
||||||
|
} else {
|
||||||
|
left = '2px';
|
||||||
|
}
|
||||||
|
} else if (size === 3) {
|
||||||
|
if (index === 0) {
|
||||||
|
right = '2px';
|
||||||
|
} else if (index > 0) {
|
||||||
|
left = '2px';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index === 1) {
|
||||||
|
bottom = '2px';
|
||||||
|
} else if (index > 1) {
|
||||||
|
top = '2px';
|
||||||
|
}
|
||||||
|
} else if (size === 4) {
|
||||||
|
if (index === 0 || index === 2) {
|
||||||
|
right = '2px';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index === 1 || index === 3) {
|
||||||
|
left = '2px';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index < 2) {
|
||||||
|
bottom = '2px';
|
||||||
|
} else {
|
||||||
|
top = '2px';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let thumbnail = '';
|
||||||
|
|
||||||
|
if (attachment.get('type') === 'image') {
|
||||||
|
const previewUrl = attachment.get('preview_url');
|
||||||
|
const previewWidth = attachment.getIn(['meta', 'small', 'width']);
|
||||||
|
|
||||||
|
const originalUrl = attachment.get('url');
|
||||||
|
const originalWidth = attachment.getIn(['meta', 'original', 'width']);
|
||||||
|
|
||||||
|
const srcSet = `${originalUrl} ${originalWidth}w, ${previewUrl} ${previewWidth}w`;
|
||||||
|
const sizes = `(min-width: 1025px) ${320 * (width / 100)}px, ${width}vw`;
|
||||||
|
|
||||||
|
thumbnail = (
|
||||||
|
<a
|
||||||
|
className='media-gallery__item-thumbnail'
|
||||||
|
href={attachment.get('remote_url') || originalUrl}
|
||||||
|
onClick={this.handleClick}
|
||||||
|
target='_blank'
|
||||||
|
>
|
||||||
|
<img className={letterbox ? 'letterbox' : ''} src={previewUrl} srcSet={srcSet} sizes={sizes} alt='' />
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
} else if (attachment.get('type') === 'gifv') {
|
||||||
|
const autoPlay = !isIOS() && this.props.autoPlayGif;
|
||||||
|
|
||||||
|
thumbnail = (
|
||||||
|
<div className={`media-gallery__gifv ${autoPlay ? 'autoplay' : ''}`}>
|
||||||
|
<video
|
||||||
|
className={`media-gallery__item-gifv-thumbnail${letterbox ? ' letterbox' : ''}`}
|
||||||
|
role='application'
|
||||||
|
src={attachment.get('url')}
|
||||||
|
onClick={this.handleClick}
|
||||||
|
autoPlay={autoPlay}
|
||||||
|
loop
|
||||||
|
muted
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span className='media-gallery__gifv__label'>GIF</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='media-gallery__item' key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
|
||||||
|
{thumbnail}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
247
app/javascript/glitch/components/status/header.js
Normal file
247
app/javascript/glitch/components/status/header.js
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<StatusHeader>`
|
||||||
|
================
|
||||||
|
|
||||||
|
Originally a part of `<Status>`, but extracted into a separate
|
||||||
|
component for better documentation and maintainance by
|
||||||
|
@kibi@glitch.social as a part of glitch-soc/mastodon.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import Avatar from '../../../mastodon/components/avatar';
|
||||||
|
import AvatarOverlay from '../../../mastodon/components/avatar_overlay';
|
||||||
|
import DisplayName from '../../../mastodon/components/display_name';
|
||||||
|
import IconButton from '../../../mastodon/components/icon_button';
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Inital setup:
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The `messages` constant is used to define any messages that we need
|
||||||
|
from inside props. In our case, these are the `collapse` and
|
||||||
|
`uncollapse` messages used with our collapse/uncollapse buttons.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
collapse: { id: 'status.collapse', defaultMessage: 'Collapse' },
|
||||||
|
uncollapse: { id: 'status.uncollapse', defaultMessage: 'Uncollapse' },
|
||||||
|
public: { id: 'privacy.public.short', defaultMessage: 'Public' },
|
||||||
|
unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
|
||||||
|
private: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
||||||
|
direct: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
The `<StatusHeader>` component:
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
The `<StatusHeader>` component wraps together the header information
|
||||||
|
(avatar, display name) and upper buttons and icons (collapsing, media
|
||||||
|
icons) into a single `<header>` element.
|
||||||
|
|
||||||
|
### Props
|
||||||
|
|
||||||
|
- __`account`, `friend` (`ImmutablePropTypes.map`) :__
|
||||||
|
These give the accounts associated with the status. `account` is
|
||||||
|
the author of the post; `friend` will have their avatar appear
|
||||||
|
in the overlay if provided.
|
||||||
|
|
||||||
|
- __`mediaIcon` (`PropTypes.string`) :__
|
||||||
|
If a mediaIcon should be placed in the header, this string
|
||||||
|
specifies it.
|
||||||
|
|
||||||
|
- __`collapsible`, `collapsed` (`PropTypes.bool`) :__
|
||||||
|
These props tell whether a post can be, and is, collapsed.
|
||||||
|
|
||||||
|
- __`parseClick` (`PropTypes.func`) :__
|
||||||
|
This function will be called when the user clicks inside the header
|
||||||
|
information.
|
||||||
|
|
||||||
|
- __`setExpansion` (`PropTypes.func`) :__
|
||||||
|
This function is used to set the expansion state of the post.
|
||||||
|
|
||||||
|
- __`intl` (`PropTypes.object`) :__
|
||||||
|
This is our internationalization object, provided by
|
||||||
|
`injectIntl()`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class StatusHeader extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
|
friend: ImmutablePropTypes.map,
|
||||||
|
mediaIcon: PropTypes.string,
|
||||||
|
collapsible: PropTypes.bool,
|
||||||
|
collapsed: PropTypes.bool,
|
||||||
|
parseClick: PropTypes.func.isRequired,
|
||||||
|
setExpansion: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
visibility: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### Implementation
|
||||||
|
|
||||||
|
#### `handleCollapsedClick()`.
|
||||||
|
|
||||||
|
`handleCollapsedClick()` is just a simple callback for our collapsing
|
||||||
|
button. It calls `setExpansion` to set the collapsed state of the
|
||||||
|
status.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
handleCollapsedClick = (e) => {
|
||||||
|
const { collapsed, setExpansion } = this.props;
|
||||||
|
if (e.button === 0) {
|
||||||
|
setExpansion(collapsed ? null : false);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `handleAccountClick()`.
|
||||||
|
|
||||||
|
`handleAccountClick()` handles any clicks on the header info. It calls
|
||||||
|
`parseClick()` with our `account` as the anticipatory `destination`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
handleAccountClick = (e) => {
|
||||||
|
const { account, parseClick } = this.props;
|
||||||
|
parseClick(e, `/accounts/${+account.get('id')}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `render()`.
|
||||||
|
|
||||||
|
`render()` actually puts our element on the screen. `<StatusHeader>`
|
||||||
|
has a very straightforward rendering process.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const {
|
||||||
|
account,
|
||||||
|
friend,
|
||||||
|
mediaIcon,
|
||||||
|
collapsible,
|
||||||
|
collapsed,
|
||||||
|
intl,
|
||||||
|
visibility,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
const visibilityClass = {
|
||||||
|
public: 'globe',
|
||||||
|
unlisted: 'unlock-alt',
|
||||||
|
private: 'lock',
|
||||||
|
direct: 'envelope',
|
||||||
|
}[visibility];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<header className='status__info'>
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
We have to include the status icons before the header content because
|
||||||
|
it is rendered as a float.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
<div className='status__info__icons'>
|
||||||
|
{mediaIcon ? (
|
||||||
|
<i
|
||||||
|
className={`fa fa-fw fa-${mediaIcon}`}
|
||||||
|
aria-hidden='true'
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
{(
|
||||||
|
<i
|
||||||
|
className={`status__visibility-icon fa fa-fw fa-${visibilityClass}`}
|
||||||
|
title={intl.formatMessage(messages[visibility])}
|
||||||
|
aria-hidden='true'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{collapsible ? (
|
||||||
|
<IconButton
|
||||||
|
className='status__collapse-button'
|
||||||
|
animate flip
|
||||||
|
active={collapsed}
|
||||||
|
title={
|
||||||
|
collapsed ?
|
||||||
|
intl.formatMessage(messages.uncollapse) :
|
||||||
|
intl.formatMessage(messages.collapse)
|
||||||
|
}
|
||||||
|
icon='angle-double-up'
|
||||||
|
onClick={this.handleCollapsedClick}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This begins our header content. It is all wrapped inside of a link
|
||||||
|
which gets handled by `handleAccountClick`. We use an `<AvatarOverlay>`
|
||||||
|
if we have a `friend` and a normal `<Avatar>` if we don't.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
<a
|
||||||
|
href={account.get('url')}
|
||||||
|
className='status__display-name'
|
||||||
|
onClick={this.handleAccountClick}
|
||||||
|
>
|
||||||
|
<div className='status__avatar'>{
|
||||||
|
friend ? (
|
||||||
|
<AvatarOverlay
|
||||||
|
staticSrc={account.get('avatar_static')}
|
||||||
|
overlaySrc={friend.get('avatar_static')}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Avatar
|
||||||
|
src={account.get('avatar')}
|
||||||
|
staticSrc={account.get('avatar_static')}
|
||||||
|
size={48}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}</div>
|
||||||
|
<DisplayName account={account} />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
719
app/javascript/glitch/components/status/index.js
Normal file
719
app/javascript/glitch/components/status/index.js
Normal file
@@ -0,0 +1,719 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<Status>`
|
||||||
|
==========
|
||||||
|
|
||||||
|
Original file by @gargron@mastodon.social et al as part of
|
||||||
|
tootsuite/mastodon. *Heavily* rewritten (and documented!) by
|
||||||
|
@kibi@glitch.social as a part of glitch-soc/mastodon. The following
|
||||||
|
features have been added:
|
||||||
|
|
||||||
|
- Better separating the "guts" of statuses from their wrapper(s)
|
||||||
|
- Collapsing statuses
|
||||||
|
- Moving images inside of CWs
|
||||||
|
|
||||||
|
A number of aspects of this original file have been split off into
|
||||||
|
their own components for better maintainance; for these, see:
|
||||||
|
|
||||||
|
- <StatusHeader>
|
||||||
|
- <StatusPrepend>
|
||||||
|
|
||||||
|
…And, of course, the other <Status>-related components as well.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import scheduleIdleTask from '../../../mastodon/features/ui/util/schedule_idle_task';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import StatusPrepend from './prepend';
|
||||||
|
import StatusHeader from './header';
|
||||||
|
import StatusContent from './content';
|
||||||
|
import StatusActionBar from './action_bar';
|
||||||
|
import StatusGallery from './gallery';
|
||||||
|
import StatusVideoPlayer from './video_player';
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
The `<Status>` component:
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
The `<Status>` component is a container for statuses. It consists of a
|
||||||
|
few parts:
|
||||||
|
|
||||||
|
- The `<StatusPrepend>`, which contains tangential information about
|
||||||
|
the status, such as who reblogged it.
|
||||||
|
- The `<StatusHeader>`, which contains the avatar and username of the
|
||||||
|
status author, as well as a media icon and the "collapse" toggle.
|
||||||
|
- The `<StatusContent>`, which contains the content of the status.
|
||||||
|
- The `<StatusActionBar>`, which provides actions to be performed
|
||||||
|
on statuses, like reblogging or sending a reply.
|
||||||
|
|
||||||
|
### Context
|
||||||
|
|
||||||
|
- __`router` (`PropTypes.object`) :__
|
||||||
|
We need to get our router from the surrounding React context.
|
||||||
|
|
||||||
|
### Props
|
||||||
|
|
||||||
|
- __`id` (`PropTypes.number`) :__
|
||||||
|
The id of the status.
|
||||||
|
|
||||||
|
- __`status` (`ImmutablePropTypes.map`) :__
|
||||||
|
The status object, straight from the store.
|
||||||
|
|
||||||
|
- __`account` (`ImmutablePropTypes.map`) :__
|
||||||
|
Don't be confused by this one! This is **not** the account which
|
||||||
|
posted the status, but the associated account with any further
|
||||||
|
action (eg, a reblog or a favourite).
|
||||||
|
|
||||||
|
- __`settings` (`ImmutablePropTypes.map`) :__
|
||||||
|
These are our local settings, fetched from our store. We need this
|
||||||
|
to determine how best to collapse our statuses, among other things.
|
||||||
|
|
||||||
|
- __`me` (`PropTypes.number`) :__
|
||||||
|
This is the id of the currently-signed-in user.
|
||||||
|
|
||||||
|
- __`onFavourite`, `onReblog`, `onModalReblog`, `onDelete`,
|
||||||
|
`onMention`, `onMute`, `onMuteConversation`, onBlock`, `onReport`,
|
||||||
|
`onOpenMedia`, `onOpenVideo` (`PropTypes.func`) :__
|
||||||
|
These are all functions passed through from the
|
||||||
|
`<StatusContainer>`. We don't deal with them directly here.
|
||||||
|
|
||||||
|
- __`reblogModal`, `deleteModal` (`PropTypes.bool`) :__
|
||||||
|
These tell whether or not the user has modals activated for
|
||||||
|
reblogging and deleting statuses. They are used by the `onReblog`
|
||||||
|
and `onDelete` functions, but we don't deal with them here.
|
||||||
|
|
||||||
|
- __`autoPlayGif` (`PropTypes.bool`) :__
|
||||||
|
This tells the frontend whether or not to autoplay gifs!
|
||||||
|
|
||||||
|
- __`muted` (`PropTypes.bool`) :__
|
||||||
|
This has nothing to do with a user or conversation mute! "Muted" is
|
||||||
|
what Mastodon internally calls the subdued look of statuses in the
|
||||||
|
notifications column. This should be `true` for notifications, and
|
||||||
|
`false` otherwise.
|
||||||
|
|
||||||
|
- __`collapse` (`PropTypes.bool`) :__
|
||||||
|
This prop signals a directive from a higher power to (un)collapse
|
||||||
|
a status. Most of the time it should be `undefined`, in which case
|
||||||
|
we do nothing.
|
||||||
|
|
||||||
|
- __`prepend` (`PropTypes.string`) :__
|
||||||
|
The type of prepend: `'reblogged_by'`, `'reblog'`, or
|
||||||
|
`'favourite'`.
|
||||||
|
|
||||||
|
- __`withDismiss` (`PropTypes.bool`) :__
|
||||||
|
Whether or not the status can be dismissed. Used for notifications.
|
||||||
|
|
||||||
|
- __`intersectionObserverWrapper` (`PropTypes.object`) :__
|
||||||
|
This holds our intersection observer. In Mastodon parlance,
|
||||||
|
an "intersection" is just when the status is viewable onscreen.
|
||||||
|
|
||||||
|
### State
|
||||||
|
|
||||||
|
- __`isExpanded` :__
|
||||||
|
Should be either `true`, `false`, or `null`. The meanings of
|
||||||
|
these values are as follows:
|
||||||
|
|
||||||
|
- __`true` :__ The status contains a CW and the CW is expanded.
|
||||||
|
- __`false` :__ The status is collapsed.
|
||||||
|
- __`null` :__ The status is not collapsed or expanded.
|
||||||
|
|
||||||
|
- __`isIntersecting` :__
|
||||||
|
This boolean tells us whether or not the status is currently
|
||||||
|
onscreen.
|
||||||
|
|
||||||
|
- __`isHidden` :__
|
||||||
|
This boolean tells us if the status has been unrendered to save
|
||||||
|
CPUs.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router : PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
id : PropTypes.number,
|
||||||
|
status : ImmutablePropTypes.map,
|
||||||
|
account : ImmutablePropTypes.map,
|
||||||
|
settings : ImmutablePropTypes.map,
|
||||||
|
me : PropTypes.number,
|
||||||
|
onFavourite : PropTypes.func,
|
||||||
|
onReblog : PropTypes.func,
|
||||||
|
onModalReblog : PropTypes.func,
|
||||||
|
onDelete : PropTypes.func,
|
||||||
|
onMention : PropTypes.func,
|
||||||
|
onMute : PropTypes.func,
|
||||||
|
onMuteConversation : PropTypes.func,
|
||||||
|
onBlock : PropTypes.func,
|
||||||
|
onReport : PropTypes.func,
|
||||||
|
onOpenMedia : PropTypes.func,
|
||||||
|
onOpenVideo : PropTypes.func,
|
||||||
|
reblogModal : PropTypes.bool,
|
||||||
|
deleteModal : PropTypes.bool,
|
||||||
|
autoPlayGif : PropTypes.bool,
|
||||||
|
muted : PropTypes.bool,
|
||||||
|
collapse : PropTypes.bool,
|
||||||
|
prepend : PropTypes.string,
|
||||||
|
withDismiss : PropTypes.bool,
|
||||||
|
intersectionObserverWrapper : PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
isExpanded : null,
|
||||||
|
isIntersecting : true,
|
||||||
|
isHidden : false,
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### Implementation
|
||||||
|
|
||||||
|
#### `updateOnProps` and `updateOnStates`.
|
||||||
|
|
||||||
|
`updateOnProps` and `updateOnStates` tell the component when to update.
|
||||||
|
We specify them explicitly because some of our props are dynamically=
|
||||||
|
generated functions, which would otherwise always trigger an update.
|
||||||
|
Of course, this means that if we add an important prop, we will need
|
||||||
|
to remember to specify it here.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
updateOnProps = [
|
||||||
|
'status',
|
||||||
|
'account',
|
||||||
|
'settings',
|
||||||
|
'prepend',
|
||||||
|
'me',
|
||||||
|
'boostModal',
|
||||||
|
'autoPlayGif',
|
||||||
|
'muted',
|
||||||
|
'collapse',
|
||||||
|
]
|
||||||
|
|
||||||
|
updateOnStates = [
|
||||||
|
'isExpanded',
|
||||||
|
]
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `componentWillReceiveProps()`.
|
||||||
|
|
||||||
|
If our settings have changed to disable collapsed statuses, then we
|
||||||
|
need to make sure that we uncollapse every one. We do that by watching
|
||||||
|
for changes to `settings.collapsed.enabled` in
|
||||||
|
`componentWillReceiveProps()`.
|
||||||
|
|
||||||
|
We also need to watch for changes on the `collapse` prop---if this
|
||||||
|
changes to anything other than `undefined`, then we need to collapse or
|
||||||
|
uncollapse our status accordingly.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
componentWillReceiveProps (nextProps) {
|
||||||
|
if (!nextProps.settings.getIn(['collapsed', 'enabled'])) {
|
||||||
|
this.setExpansion(true);
|
||||||
|
} else if (
|
||||||
|
nextProps.collapse !== this.props.collapse &&
|
||||||
|
nextProps.collapse !== undefined
|
||||||
|
) this.setExpansion(nextProps.collapse ? false : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `componentDidMount()`.
|
||||||
|
|
||||||
|
When mounting, we just check to see if our status should be collapsed,
|
||||||
|
and collapse it if so. We don't need to worry about whether collapsing
|
||||||
|
is enabled here, because `setExpansion()` already takes that into
|
||||||
|
account.
|
||||||
|
|
||||||
|
The cases where a status should be collapsed are:
|
||||||
|
|
||||||
|
- The `collapse` prop has been set to `true`
|
||||||
|
- The user has decided in local settings to collapse all statuses.
|
||||||
|
- The user has decided to collapse all notifications ('muted'
|
||||||
|
statuses).
|
||||||
|
- The user has decided to collapse long statuses and the status is
|
||||||
|
over 400px (without media, or 650px with).
|
||||||
|
- The status is a reply and the user has decided to collapse all
|
||||||
|
replies.
|
||||||
|
- The status contains media and the user has decided to collapse all
|
||||||
|
statuses with media.
|
||||||
|
|
||||||
|
We also start up our intersection observer to monitor our statuses.
|
||||||
|
`componentMounted` lets us know that everything has been set up
|
||||||
|
properly and our intersection observer is good to go.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
const { node, handleIntersection } = this;
|
||||||
|
const {
|
||||||
|
status,
|
||||||
|
settings,
|
||||||
|
collapse,
|
||||||
|
muted,
|
||||||
|
id,
|
||||||
|
intersectionObserverWrapper,
|
||||||
|
} = this.props;
|
||||||
|
const autoCollapseSettings = settings.getIn(['collapsed', 'auto']);
|
||||||
|
|
||||||
|
if (
|
||||||
|
collapse ||
|
||||||
|
autoCollapseSettings.get('all') || (
|
||||||
|
autoCollapseSettings.get('notifications') && muted
|
||||||
|
) || (
|
||||||
|
autoCollapseSettings.get('lengthy') &&
|
||||||
|
node.clientHeight > (
|
||||||
|
status.get('media_attachments').size && !muted ? 650 : 400
|
||||||
|
)
|
||||||
|
) || (
|
||||||
|
autoCollapseSettings.get('replies') &&
|
||||||
|
status.get('in_reply_to_id', null) !== null
|
||||||
|
) || (
|
||||||
|
autoCollapseSettings.get('media') &&
|
||||||
|
!(status.get('spoiler_text').length) &&
|
||||||
|
status.get('media_attachments').size
|
||||||
|
)
|
||||||
|
) this.setExpansion(false);
|
||||||
|
|
||||||
|
if (!intersectionObserverWrapper) return;
|
||||||
|
else intersectionObserverWrapper.observe(
|
||||||
|
id,
|
||||||
|
node,
|
||||||
|
handleIntersection
|
||||||
|
);
|
||||||
|
|
||||||
|
this.componentMounted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `shouldComponentUpdate()`.
|
||||||
|
|
||||||
|
If the status is about to be both offscreen (not intersecting) and
|
||||||
|
hidden, then we only need to update it if it's not that way currently.
|
||||||
|
If the status is moving from offscreen to onscreen, then we *have* to
|
||||||
|
re-render, so that we can unhide the element if necessary.
|
||||||
|
|
||||||
|
If neither of these cases are true, we can leave it up to our
|
||||||
|
`updateOnProps` and `updateOnStates` arrays.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
shouldComponentUpdate (nextProps, nextState) {
|
||||||
|
switch (true) {
|
||||||
|
case !nextState.isIntersecting && nextState.isHidden:
|
||||||
|
return this.state.isIntersecting || !this.state.isHidden;
|
||||||
|
case nextState.isIntersecting && !this.state.isIntersecting:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.shouldComponentUpdate(nextProps, nextState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `componentDidUpdate()`.
|
||||||
|
|
||||||
|
If our component is being rendered for any reason and an update has
|
||||||
|
triggered, this will save its height.
|
||||||
|
|
||||||
|
This is, frankly, a bit overkill, as the only instance when we
|
||||||
|
actually *need* to update the height right now should be when the
|
||||||
|
value of `isExpanded` has changed. But it makes for more readable
|
||||||
|
code and prevents bugs in the future where the height isn't set
|
||||||
|
properly after some change.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
componentDidUpdate () {
|
||||||
|
if (
|
||||||
|
this.state.isIntersecting || !this.state.isHidden
|
||||||
|
) this.saveHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `componentWillUnmount()`.
|
||||||
|
|
||||||
|
If our component is about to unmount, then we'd better unset
|
||||||
|
`this.componentMounted`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.componentMounted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `handleIntersection()`.
|
||||||
|
|
||||||
|
`handleIntersection()` either hides the status (if it is offscreen) or
|
||||||
|
unhides it (if it is onscreen). It's called by
|
||||||
|
`intersectionObserverWrapper.observe()`.
|
||||||
|
|
||||||
|
If our status isn't intersecting, we schedule an idle task (using the
|
||||||
|
aptly-named `scheduleIdleTask()`) to hide the status at the next
|
||||||
|
available opportunity.
|
||||||
|
|
||||||
|
tootsuite/mastodon left us with the following enlightening comment
|
||||||
|
regarding this function:
|
||||||
|
|
||||||
|
> Edge 15 doesn't support isIntersecting, but we can infer it
|
||||||
|
|
||||||
|
It then implements a polyfill (intersectionRect.height > 0) which isn't
|
||||||
|
actually sufficient. The short answer is, this behaviour isn't really
|
||||||
|
supported on Edge but we can get kinda close.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
handleIntersection = (entry) => {
|
||||||
|
const isIntersecting = (
|
||||||
|
typeof entry.isIntersecting === 'boolean' ?
|
||||||
|
entry.isIntersecting :
|
||||||
|
entry.intersectionRect.height > 0
|
||||||
|
);
|
||||||
|
this.setState(
|
||||||
|
(prevState) => {
|
||||||
|
if (prevState.isIntersecting && !isIntersecting) {
|
||||||
|
scheduleIdleTask(this.hideIfNotIntersecting);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
isIntersecting : isIntersecting,
|
||||||
|
isHidden : false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `hideIfNotIntersecting()`.
|
||||||
|
|
||||||
|
This function will hide the status if we're still not intersecting.
|
||||||
|
Hiding the status means that it will just render an empty div instead
|
||||||
|
of actual content, which saves RAMS and CPUs or some such.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
hideIfNotIntersecting = () => {
|
||||||
|
if (!this.componentMounted) return;
|
||||||
|
this.setState(
|
||||||
|
(prevState) => ({ isHidden: !prevState.isIntersecting })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `saveHeight()`.
|
||||||
|
|
||||||
|
`saveHeight()` saves the height of our status so that when whe hide it
|
||||||
|
we preserve its dimensions. We only want to store our height, though,
|
||||||
|
if our status has content (otherwise, it would imply that it is
|
||||||
|
already hidden).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
saveHeight = () => {
|
||||||
|
if (this.node && this.node.children.length) {
|
||||||
|
this.height = this.node.getBoundingClientRect().height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `setExpansion()`.
|
||||||
|
|
||||||
|
`setExpansion()` sets the value of `isExpanded` in our state. It takes
|
||||||
|
one argument, `value`, which gives the desired value for `isExpanded`.
|
||||||
|
The default for this argument is `null`.
|
||||||
|
|
||||||
|
`setExpansion()` automatically checks for us whether toot collapsing
|
||||||
|
is enabled, so we don't have to.
|
||||||
|
|
||||||
|
We use a `switch` statement to simplify our code.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
setExpansion = (value) => {
|
||||||
|
switch (true) {
|
||||||
|
case value === undefined || value === null:
|
||||||
|
this.setState({ isExpanded: null });
|
||||||
|
break;
|
||||||
|
case !value && this.props.settings.getIn(['collapsed', 'enabled']):
|
||||||
|
this.setState({ isExpanded: false });
|
||||||
|
break;
|
||||||
|
case !!value:
|
||||||
|
this.setState({ isExpanded: true });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `handleRef()`.
|
||||||
|
|
||||||
|
`handleRef()` just saves a reference to our status node to `this.node`.
|
||||||
|
It also saves our height, in case the height of our node has changed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
handleRef = (node) => {
|
||||||
|
this.node = node;
|
||||||
|
this.saveHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `parseClick()`.
|
||||||
|
|
||||||
|
`parseClick()` takes a click event and responds appropriately.
|
||||||
|
If our status is collapsed, then clicking on it should uncollapse it.
|
||||||
|
If `Shift` is held, then clicking on it should collapse it.
|
||||||
|
Otherwise, we open the url handed to us in `destination`, if
|
||||||
|
applicable.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
parseClick = (e, destination) => {
|
||||||
|
const { router } = this.context;
|
||||||
|
const { status } = this.props;
|
||||||
|
const { isExpanded } = this.state;
|
||||||
|
if (destination === undefined) {
|
||||||
|
destination = `/statuses/${
|
||||||
|
status.getIn(['reblog', 'id'], status.get('id'))
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
if (e.button === 0) {
|
||||||
|
if (isExpanded === false) this.setExpansion(null);
|
||||||
|
else if (e.shiftKey) {
|
||||||
|
this.setExpansion(false);
|
||||||
|
document.getSelection().removeAllRanges();
|
||||||
|
} else router.history.push(destination);
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `render()`.
|
||||||
|
|
||||||
|
`render()` actually puts our element on the screen. The particulars of
|
||||||
|
this operation are further explained in the code below.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { parseClick, setExpansion, handleRef } = this;
|
||||||
|
const {
|
||||||
|
status,
|
||||||
|
account,
|
||||||
|
settings,
|
||||||
|
collapsed,
|
||||||
|
muted,
|
||||||
|
prepend,
|
||||||
|
intersectionObserverWrapper,
|
||||||
|
onOpenVideo,
|
||||||
|
onOpenMedia,
|
||||||
|
autoPlayGif,
|
||||||
|
...other
|
||||||
|
} = this.props;
|
||||||
|
const { isExpanded, isIntersecting, isHidden } = this.state;
|
||||||
|
let background = null;
|
||||||
|
let attachments = null;
|
||||||
|
let media = null;
|
||||||
|
let mediaIcon = null;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
If we don't have a status, then we don't render anything.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (status === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
If our status is offscreen and hidden, then we render an empty <div> in
|
||||||
|
its place. We fill it with "content" but note that opacity is set to 0.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!isIntersecting && isHidden) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={this.handleRef}
|
||||||
|
data-id={status.get('id')}
|
||||||
|
style={{
|
||||||
|
height : `${this.height}px`,
|
||||||
|
opacity : 0,
|
||||||
|
overflow : 'hidden',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
status.getIn(['account', 'display_name']) ||
|
||||||
|
status.getIn(['account', 'username'])
|
||||||
|
}
|
||||||
|
{status.get('content')}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
If user backgrounds for collapsed statuses are enabled, then we
|
||||||
|
initialize our background accordingly. This will only be rendered if
|
||||||
|
the status is collapsed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (
|
||||||
|
settings.getIn(['collapsed', 'backgrounds', 'user_backgrounds'])
|
||||||
|
) background = status.getIn(['account', 'header']);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This handles our media attachments. Note that we don't show media on
|
||||||
|
muted (notification) statuses. If the media type is unknown, then we
|
||||||
|
simply ignore it.
|
||||||
|
|
||||||
|
After we have generated our appropriate media element and stored it in
|
||||||
|
`media`, we snatch the thumbnail to use as our `background` if media
|
||||||
|
backgrounds for collapsed statuses are enabled.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
attachments = status.get('media_attachments');
|
||||||
|
if (attachments.size && !muted) {
|
||||||
|
if (attachments.some((item) => item.get('type') === 'unknown')) {
|
||||||
|
|
||||||
|
} else if (
|
||||||
|
attachments.getIn([0, 'type']) === 'video'
|
||||||
|
) {
|
||||||
|
media = ( // Media type is 'video'
|
||||||
|
<StatusVideoPlayer
|
||||||
|
media={attachments.get(0)}
|
||||||
|
sensitive={status.get('sensitive')}
|
||||||
|
letterbox={settings.getIn(['media', 'letterbox'])}
|
||||||
|
fullwidth={settings.getIn(['media', 'fullwidth'])}
|
||||||
|
height={250}
|
||||||
|
onOpenVideo={onOpenVideo}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
mediaIcon = 'video-camera';
|
||||||
|
} else { // Media type is 'image' or 'gifv'
|
||||||
|
media = (
|
||||||
|
<StatusGallery
|
||||||
|
media={attachments}
|
||||||
|
sensitive={status.get('sensitive')}
|
||||||
|
letterbox={settings.getIn(['media', 'letterbox'])}
|
||||||
|
fullwidth={settings.getIn(['media', 'fullwidth'])}
|
||||||
|
height={250}
|
||||||
|
onOpenMedia={onOpenMedia}
|
||||||
|
autoPlayGif={autoPlayGif}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
mediaIcon = 'picture-o';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!status.get('sensitive') &&
|
||||||
|
!(status.get('spoiler_text').length > 0) &&
|
||||||
|
settings.getIn(['collapsed', 'backgrounds', 'preview_images'])
|
||||||
|
) background = attachments.getIn([0, 'preview_url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Finally, we can render our status. We just put the pieces together
|
||||||
|
from above. We only render the action bar if the status isn't
|
||||||
|
collapsed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (
|
||||||
|
<article
|
||||||
|
className={
|
||||||
|
`status${
|
||||||
|
muted ? ' muted' : ''
|
||||||
|
} status-${status.get('visibility')}${
|
||||||
|
isExpanded === false ? ' collapsed' : ''
|
||||||
|
}${
|
||||||
|
isExpanded === false && background ? ' has-background' : ''
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
style={{
|
||||||
|
backgroundImage: (
|
||||||
|
isExpanded === false && background ?
|
||||||
|
`url(${background})` :
|
||||||
|
'none'
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
ref={handleRef}
|
||||||
|
>
|
||||||
|
{prepend && account ? (
|
||||||
|
<StatusPrepend
|
||||||
|
type={prepend}
|
||||||
|
account={account}
|
||||||
|
parseClick={parseClick}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
<StatusHeader
|
||||||
|
account={status.get('account')}
|
||||||
|
friend={account}
|
||||||
|
mediaIcon={mediaIcon}
|
||||||
|
visibility={status.get('visibility')}
|
||||||
|
collapsible={settings.getIn(['collapsed', 'enabled'])}
|
||||||
|
collapsed={isExpanded === false}
|
||||||
|
parseClick={parseClick}
|
||||||
|
setExpansion={setExpansion}
|
||||||
|
/>
|
||||||
|
<StatusContent
|
||||||
|
status={status}
|
||||||
|
media={media}
|
||||||
|
mediaIcon={mediaIcon}
|
||||||
|
expanded={isExpanded}
|
||||||
|
setExpansion={this.setExpansion}
|
||||||
|
onHeightUpdate={this.saveHeight}
|
||||||
|
parseClick={parseClick}
|
||||||
|
/>
|
||||||
|
{isExpanded !== false ? (
|
||||||
|
<StatusActionBar
|
||||||
|
{...other}
|
||||||
|
status={status}
|
||||||
|
account={status.get('account')}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
164
app/javascript/glitch/components/status/prepend.js
Normal file
164
app/javascript/glitch/components/status/prepend.js
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<StatusPrepend>`
|
||||||
|
=================
|
||||||
|
|
||||||
|
Originally a part of `<Status>`, but extracted into a separate
|
||||||
|
component for better documentation and maintainance by
|
||||||
|
@kibi@glitch.social as a part of glitch-soc/mastodon.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import emojify from '../../../mastodon/emoji';
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
The `<StatusPrepend>` component:
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The `<StatusPrepend>` component holds a status's prepend, ie the text
|
||||||
|
that says “X reblogged this,” etc. It is represented by an `<aside>`
|
||||||
|
element.
|
||||||
|
|
||||||
|
### Props
|
||||||
|
|
||||||
|
- __`type` (`PropTypes.string`) :__
|
||||||
|
The type of prepend. One of `'reblogged_by'`, `'reblog'`,
|
||||||
|
`'favourite'`.
|
||||||
|
|
||||||
|
- __`account` (`ImmutablePropTypes.map`) :__
|
||||||
|
The account associated with the prepend.
|
||||||
|
|
||||||
|
- __`parseClick` (`PropTypes.func.isRequired`) :__
|
||||||
|
Our click parsing function.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default class StatusPrepend extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
type: PropTypes.string.isRequired,
|
||||||
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
|
parseClick: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
### Implementation
|
||||||
|
|
||||||
|
#### `handleClick()`.
|
||||||
|
|
||||||
|
This is just a small wrapper for `parseClick()` that gets fired when
|
||||||
|
an account link is clicked.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
handleClick = (e) => {
|
||||||
|
const { account, parseClick } = this.props;
|
||||||
|
parseClick(e, `/accounts/${+account.get('id')}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `<Message>`.
|
||||||
|
|
||||||
|
`<Message>` is a quick functional React component which renders the
|
||||||
|
actual prepend message based on our provided `type`. First we create a
|
||||||
|
`link` for the account's name, and then use `<FormattedMessage>` to
|
||||||
|
generate the message.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
Message = () => {
|
||||||
|
const { type, account } = this.props;
|
||||||
|
let link = (
|
||||||
|
<a
|
||||||
|
onClick={this.handleClick}
|
||||||
|
href={account.get('url')}
|
||||||
|
className='status__display-name'
|
||||||
|
>
|
||||||
|
<b
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html : emojify(escapeTextContentForBrowser(
|
||||||
|
account.get('display_name') || account.get('username')
|
||||||
|
)),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
switch (type) {
|
||||||
|
case 'reblogged_by':
|
||||||
|
return (
|
||||||
|
<FormattedMessage
|
||||||
|
id='status.reblogged_by'
|
||||||
|
defaultMessage='{name} boosted'
|
||||||
|
values={{ name : link }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case 'favourite':
|
||||||
|
return (
|
||||||
|
<FormattedMessage
|
||||||
|
id='notification.favourite'
|
||||||
|
defaultMessage='{name} favourited your status'
|
||||||
|
values={{ name : link }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case 'reblog':
|
||||||
|
return (
|
||||||
|
<FormattedMessage
|
||||||
|
id='notification.reblog'
|
||||||
|
defaultMessage='{name} boosted your status'
|
||||||
|
values={{ name : link }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#### `render()`.
|
||||||
|
|
||||||
|
Our `render()` is incredibly simple; we just render the icon and then
|
||||||
|
the `<Message>` inside of an <aside>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { Message } = this;
|
||||||
|
const { type } = this.props;
|
||||||
|
|
||||||
|
return !type ? null : (
|
||||||
|
<aside className={type === 'reblogged_by' ? 'status__prepend' : 'notification__message'}>
|
||||||
|
<div className={type === 'reblogged_by' ? 'status__prepend-icon-wrapper' : 'notification__favourite-icon-wrapper'}>
|
||||||
|
<i
|
||||||
|
className={`fa fa-fw fa-${
|
||||||
|
type === 'favourite' ? 'star star-icon' : 'retweet'
|
||||||
|
} status__prepend-icon`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Message />
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
199
app/javascript/glitch/components/status/video_player.js
Normal file
199
app/javascript/glitch/components/status/video_player.js
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import IconButton from '../../../mastodon/components/icon_button';
|
||||||
|
import { isIOS } from '../../../mastodon/is_mobile';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
toggle_sound: { id: 'video_player.toggle_sound', defaultMessage: 'Toggle sound' },
|
||||||
|
toggle_visible: { id: 'video_player.toggle_visible', defaultMessage: 'Toggle visibility' },
|
||||||
|
expand_video: { id: 'video_player.expand', defaultMessage: 'Expand video' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class StatusVideoPlayer extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
media: ImmutablePropTypes.map.isRequired,
|
||||||
|
letterbox: PropTypes.bool,
|
||||||
|
fullwidth: PropTypes.bool,
|
||||||
|
height: PropTypes.number,
|
||||||
|
sensitive: PropTypes.bool,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
autoplay: PropTypes.bool,
|
||||||
|
onOpenVideo: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
height: 110,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
visible: !this.props.sensitive,
|
||||||
|
preview: true,
|
||||||
|
muted: true,
|
||||||
|
hasAudio: true,
|
||||||
|
videoError: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClick = () => {
|
||||||
|
this.setState({ muted: !this.state.muted });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleVideoClick = (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
const node = this.video;
|
||||||
|
|
||||||
|
if (node.paused) {
|
||||||
|
node.play();
|
||||||
|
} else {
|
||||||
|
node.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOpen = () => {
|
||||||
|
this.setState({ preview: !this.state.preview });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleVisibility = () => {
|
||||||
|
this.setState({
|
||||||
|
visible: !this.state.visible,
|
||||||
|
preview: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleExpand = () => {
|
||||||
|
this.video.pause();
|
||||||
|
this.props.onOpenVideo(this.props.media, this.video.currentTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
setRef = (c) => {
|
||||||
|
this.video = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLoadedData = () => {
|
||||||
|
if (('WebkitAppearance' in document.documentElement.style && this.video.audioTracks.length === 0) || this.video.mozHasAudio === false) {
|
||||||
|
this.setState({ hasAudio: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleVideoError = () => {
|
||||||
|
this.setState({ videoError: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
if (!this.video) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.video.addEventListener('loadeddata', this.handleLoadedData);
|
||||||
|
this.video.addEventListener('error', this.handleVideoError);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate () {
|
||||||
|
if (!this.video) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.video.addEventListener('loadeddata', this.handleLoadedData);
|
||||||
|
this.video.addEventListener('error', this.handleVideoError);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
if (!this.video) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.video.removeEventListener('loadeddata', this.handleLoadedData);
|
||||||
|
this.video.removeEventListener('error', this.handleVideoError);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { media, intl, letterbox, fullwidth, height, sensitive, autoplay } = this.props;
|
||||||
|
|
||||||
|
let spoilerButton = (
|
||||||
|
<div className={`status__video-player-spoiler ${this.state.visible ? 'status__video-player-spoiler--visible' : ''}`}>
|
||||||
|
<IconButton overlay title={intl.formatMessage(messages.toggle_visible)} icon={this.state.visible ? 'eye' : 'eye-slash'} onClick={this.handleVisibility} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
let expandButton = (
|
||||||
|
<div className='status__video-player-expand'>
|
||||||
|
<IconButton overlay title={intl.formatMessage(messages.expand_video)} icon='expand' onClick={this.handleExpand} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
let muteButton = '';
|
||||||
|
|
||||||
|
if (this.state.hasAudio) {
|
||||||
|
muteButton = (
|
||||||
|
<div className='status__video-player-mute'>
|
||||||
|
<IconButton overlay title={intl.formatMessage(messages.toggle_sound)} icon={this.state.muted ? 'volume-off' : 'volume-up'} onClick={this.handleClick} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.state.visible) {
|
||||||
|
if (sensitive) {
|
||||||
|
return (
|
||||||
|
<div role='button' tabIndex='0' style={{ height: `${height}px` }} className={`media-spoiler ${fullwidth ? 'full-width' : ''}`} onClick={this.handleVisibility}>
|
||||||
|
{spoilerButton}
|
||||||
|
<span className='media-spoiler__warning'><FormattedMessage id='status.sensitive_warning' defaultMessage='Sensitive content' /></span>
|
||||||
|
<span className='media-spoiler__trigger'><FormattedMessage id='status.sensitive_toggle' defaultMessage='Click to view' /></span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div role='button' tabIndex='0' style={{ height: `${height}px` }} className={`media-spoiler ${fullwidth ? 'full-width' : ''}`} onClick={this.handleVisibility}>
|
||||||
|
{spoilerButton}
|
||||||
|
<span className='media-spoiler__warning'><FormattedMessage id='status.media_hidden' defaultMessage='Media hidden' /></span>
|
||||||
|
<span className='media-spoiler__trigger'><FormattedMessage id='status.sensitive_toggle' defaultMessage='Click to view' /></span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.preview && !autoplay) {
|
||||||
|
return (
|
||||||
|
<div role='button' tabIndex='0' className={`media-spoiler-video ${fullwidth ? 'full-width' : ''}`} style={{ height: `${height}px`, backgroundImage: `url(${media.get('preview_url')})` }} onClick={this.handleOpen}>
|
||||||
|
{spoilerButton}
|
||||||
|
<div className='media-spoiler-video-play-icon'><i className='fa fa-play' /></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.videoError) {
|
||||||
|
return (
|
||||||
|
<div style={{ height: `${height}px` }} className='video-error-cover' >
|
||||||
|
<span className='media-spoiler__warning'><FormattedMessage id='video_player.video_error' defaultMessage='Video could not be played' /></span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`status__video-player ${fullwidth ? 'full-width' : ''}`} style={{ height: `${height}px` }}>
|
||||||
|
{spoilerButton}
|
||||||
|
{muteButton}
|
||||||
|
{expandButton}
|
||||||
|
|
||||||
|
<video
|
||||||
|
className={`status__video-player-video${letterbox ? ' letterbox' : ''}`}
|
||||||
|
role='button'
|
||||||
|
tabIndex='0'
|
||||||
|
ref={this.setRef}
|
||||||
|
src={media.get('url')}
|
||||||
|
autoPlay={!isIOS()}
|
||||||
|
loop
|
||||||
|
muted={this.state.muted}
|
||||||
|
onClick={this.handleVideoClick}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
22
app/javascript/glitch/containers/compose/advanced_options.js
Normal file
22
app/javascript/glitch/containers/compose/advanced_options.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { changeComposeAdvancedOption } from '../../../mastodon/actions/compose';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import ComposeAdvancedOptions from '../../components/compose/advanced_options';
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
values: state.getIn(['compose', 'advanced_options']),
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
||||||
|
onChange (option) {
|
||||||
|
dispatch(changeComposeAdvancedOption(option));
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(ComposeAdvancedOptions);
|
||||||
21
app/javascript/glitch/containers/notification/index.js
Normal file
21
app/javascript/glitch/containers/notification/index.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { makeGetNotification } from '../../../mastodon/selectors';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import Notification from '../../components/notification';
|
||||||
|
|
||||||
|
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);
|
||||||
27
app/javascript/glitch/containers/settings/index.js
Normal file
27
app/javascript/glitch/containers/settings/index.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Package imports //
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { closeModal } from '../../../mastodon/actions/modal';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import { changeLocalSetting } from '../../actions/local_settings';
|
||||||
|
import Settings from '../../components/settings';
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
settings: state.get('local_settings'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
toggleSetting (setting, e) {
|
||||||
|
dispatch(changeLocalSetting(setting, e.target.checked));
|
||||||
|
},
|
||||||
|
changeSetting (setting, e) {
|
||||||
|
dispatch(changeLocalSetting(setting, e.target.value));
|
||||||
|
},
|
||||||
|
onClose () {
|
||||||
|
dispatch(closeModal());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(Settings);
|
||||||
252
app/javascript/glitch/containers/status/index.js
Normal file
252
app/javascript/glitch/containers/status/index.js
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
`<StatusContainer>`
|
||||||
|
===================
|
||||||
|
|
||||||
|
Original file by @gargron@mastodon.social et al as part of
|
||||||
|
tootsuite/mastodon. Documentation by @kibi@glitch.social. The code
|
||||||
|
detecting reblogs has been moved here from <Status>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Imports:
|
||||||
|
--------
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package imports //
|
||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import {
|
||||||
|
defineMessages,
|
||||||
|
injectIntl,
|
||||||
|
FormattedMessage,
|
||||||
|
} from 'react-intl';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { makeGetStatus } from '../../../mastodon/selectors';
|
||||||
|
import {
|
||||||
|
replyCompose,
|
||||||
|
mentionCompose,
|
||||||
|
} from '../../../mastodon/actions/compose';
|
||||||
|
import {
|
||||||
|
reblog,
|
||||||
|
favourite,
|
||||||
|
unreblog,
|
||||||
|
unfavourite,
|
||||||
|
} from '../../../mastodon/actions/interactions';
|
||||||
|
import {
|
||||||
|
blockAccount,
|
||||||
|
muteAccount,
|
||||||
|
} from '../../../mastodon/actions/accounts';
|
||||||
|
import {
|
||||||
|
muteStatus,
|
||||||
|
unmuteStatus,
|
||||||
|
deleteStatus,
|
||||||
|
} from '../../../mastodon/actions/statuses';
|
||||||
|
import { initReport } from '../../../mastodon/actions/reports';
|
||||||
|
import { openModal } from '../../../mastodon/actions/modal';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import Status from '../../components/status';
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Inital setup:
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The `messages` constant is used to define any messages that we will
|
||||||
|
need in our component. In our case, these are the various confirmation
|
||||||
|
messages used with statuses.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
deleteConfirm : {
|
||||||
|
id : 'confirmations.delete.confirm',
|
||||||
|
defaultMessage : 'Delete',
|
||||||
|
},
|
||||||
|
deleteMessage : {
|
||||||
|
id : 'confirmations.delete.message',
|
||||||
|
defaultMessage : 'Are you sure you want to delete this status?',
|
||||||
|
},
|
||||||
|
blockConfirm : {
|
||||||
|
id : 'confirmations.block.confirm',
|
||||||
|
defaultMessage : 'Block',
|
||||||
|
},
|
||||||
|
muteConfirm : {
|
||||||
|
id : 'confirmations.mute.confirm',
|
||||||
|
defaultMessage : 'Mute',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
State mapping:
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The `mapStateToProps()` function maps various state properties to the
|
||||||
|
props of our component. We wrap this in a `makeMapStateToProps()`
|
||||||
|
function to give us closure and preserve `getStatus()` across function
|
||||||
|
calls.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const makeMapStateToProps = () => {
|
||||||
|
const getStatus = makeGetStatus();
|
||||||
|
|
||||||
|
const mapStateToProps = (state, ownProps) => {
|
||||||
|
|
||||||
|
let status = getStatus(state, ownProps.id);
|
||||||
|
let reblogStatus = status.get('reblog', null);
|
||||||
|
let account = undefined;
|
||||||
|
let prepend = undefined;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Here we process reblogs. If our status is a reblog, then we create a
|
||||||
|
`prependMessage` to pass along to our `<Status>` along with the
|
||||||
|
reblogger's `account`, and set `coreStatus` (the one we will actually
|
||||||
|
render) to the status which has been reblogged.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (reblogStatus !== null && typeof reblogStatus === 'object') {
|
||||||
|
account = status.get('account');
|
||||||
|
status = reblogStatus;
|
||||||
|
prepend = 'reblogged_by';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Here are the props we pass to `<Status>`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return {
|
||||||
|
status : status,
|
||||||
|
account : account || ownProps.account,
|
||||||
|
me : state.getIn(['meta', 'me']),
|
||||||
|
settings : state.get('local_settings'),
|
||||||
|
prepend : prepend || ownProps.prepend,
|
||||||
|
reblogModal : state.getIn(['meta', 'boost_modal']),
|
||||||
|
deleteModal : state.getIn(['meta', 'delete_modal']),
|
||||||
|
autoPlayGif : state.getIn(['meta', 'auto_play_gif']),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return mapStateToProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* * * * */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Dispatch mapping:
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The `mapDispatchToProps()` function maps dispatches to our store to the
|
||||||
|
various props of our component. We need to provide dispatches for all
|
||||||
|
of the things you can do with a status: reply, reblog, favourite, et
|
||||||
|
cetera.
|
||||||
|
|
||||||
|
For a few of these dispatches, we open up confirmation modals; the rest
|
||||||
|
just immediately execute their corresponding actions.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
|
|
||||||
|
onReply (status, router) {
|
||||||
|
dispatch(replyCompose(status, router));
|
||||||
|
},
|
||||||
|
|
||||||
|
onModalReblog (status) {
|
||||||
|
dispatch(reblog(status));
|
||||||
|
},
|
||||||
|
|
||||||
|
onReblog (status, e) {
|
||||||
|
if (status.get('reblogged')) {
|
||||||
|
dispatch(unreblog(status));
|
||||||
|
} else {
|
||||||
|
if (e.shiftKey || !this.reblogModal) {
|
||||||
|
this.onModalReblog(status);
|
||||||
|
} else {
|
||||||
|
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onFavourite (status) {
|
||||||
|
if (status.get('favourited')) {
|
||||||
|
dispatch(unfavourite(status));
|
||||||
|
} else {
|
||||||
|
dispatch(favourite(status));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onDelete (status) {
|
||||||
|
if (!this.deleteModal) {
|
||||||
|
dispatch(deleteStatus(status.get('id')));
|
||||||
|
} else {
|
||||||
|
dispatch(openModal('CONFIRM', {
|
||||||
|
message: intl.formatMessage(messages.deleteMessage),
|
||||||
|
confirm: intl.formatMessage(messages.deleteConfirm),
|
||||||
|
onConfirm: () => dispatch(deleteStatus(status.get('id'))),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onMention (account, router) {
|
||||||
|
dispatch(mentionCompose(account, router));
|
||||||
|
},
|
||||||
|
|
||||||
|
onOpenMedia (media, index) {
|
||||||
|
dispatch(openModal('MEDIA', { media, index }));
|
||||||
|
},
|
||||||
|
|
||||||
|
onOpenVideo (media, time) {
|
||||||
|
dispatch(openModal('VIDEO', { media, time }));
|
||||||
|
},
|
||||||
|
|
||||||
|
onBlock (account) {
|
||||||
|
dispatch(openModal('CONFIRM', {
|
||||||
|
message: <FormattedMessage id='confirmations.block.message' defaultMessage='Are you sure you want to block {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
||||||
|
confirm: intl.formatMessage(messages.blockConfirm),
|
||||||
|
onConfirm: () => dispatch(blockAccount(account.get('id'))),
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
onReport (status) {
|
||||||
|
dispatch(initReport(status.get('account'), status));
|
||||||
|
},
|
||||||
|
|
||||||
|
onMute (account) {
|
||||||
|
dispatch(openModal('CONFIRM', {
|
||||||
|
message: <FormattedMessage id='confirmations.mute.message' defaultMessage='Are you sure you want to mute {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
|
||||||
|
confirm: intl.formatMessage(messages.muteConfirm),
|
||||||
|
onConfirm: () => dispatch(muteAccount(account.get('id'))),
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
onMuteConversation (status) {
|
||||||
|
if (status.get('muted')) {
|
||||||
|
dispatch(unmuteStatus(status.get('id')));
|
||||||
|
} else {
|
||||||
|
dispatch(muteStatus(status.get('id')));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default injectIntl(
|
||||||
|
connect(makeMapStateToProps, mapDispatchToProps)(Status)
|
||||||
|
);
|
||||||
44
app/javascript/glitch/reducers/local_settings.js
Normal file
44
app/javascript/glitch/reducers/local_settings.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Package imports //
|
||||||
|
import Immutable from 'immutable';
|
||||||
|
|
||||||
|
// Mastodon imports //
|
||||||
|
import { STORE_HYDRATE } from '../../mastodon/actions/store';
|
||||||
|
|
||||||
|
// Our imports //
|
||||||
|
import { LOCAL_SETTING_CHANGE } from '../actions/local_settings';
|
||||||
|
|
||||||
|
const initialState = Immutable.fromJS({
|
||||||
|
layout : 'auto',
|
||||||
|
stretch : true,
|
||||||
|
collapsed : {
|
||||||
|
enabled : true,
|
||||||
|
auto : {
|
||||||
|
all : false,
|
||||||
|
notifications : true,
|
||||||
|
lengthy : true,
|
||||||
|
replies : false,
|
||||||
|
media : false,
|
||||||
|
},
|
||||||
|
backgrounds : {
|
||||||
|
user_backgrounds : false,
|
||||||
|
preview_images : false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
media : {
|
||||||
|
letterbox : true,
|
||||||
|
fullwidth : true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const hydrate = (state, localSettings) => state.mergeDeep(localSettings);
|
||||||
|
|
||||||
|
export default function localSettings(state = initialState, action) {
|
||||||
|
switch(action.type) {
|
||||||
|
case STORE_HYDRATE:
|
||||||
|
return hydrate(state, action.state.get('local_settings'));
|
||||||
|
case LOCAL_SETTING_CHANGE:
|
||||||
|
return state.setIn(action.key, action.value);
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
380
app/javascript/glitch/util/bio_metadata.js
Normal file
380
app/javascript/glitch/util/bio_metadata.js
Normal file
@@ -0,0 +1,380 @@
|
|||||||
|
/*********************************************************************\
|
||||||
|
|
||||||
|
To my lovely code maintainers,
|
||||||
|
|
||||||
|
The syntax recognized by the Mastodon frontend for its bio metadata
|
||||||
|
feature is a subset of that provided by the YAML 1.2 specification.
|
||||||
|
In particular, Mastodon recognizes metadata which is provided as an
|
||||||
|
implicit YAML map, where each key-value pair takes up only a single
|
||||||
|
line (no multi-line values are permitted). To simplify the level of
|
||||||
|
processing required, Mastodon metadata frontmatter has been limited
|
||||||
|
to only allow those characters in the `c-printable` set, as defined
|
||||||
|
by the YAML 1.2 specification, instead of permitting those from the
|
||||||
|
`nb-json` characters inside double-quoted strings like YAML proper.
|
||||||
|
¶ It is important to note that Mastodon only borrows the *syntax*
|
||||||
|
of YAML, not its semantics. This is to say, Mastodon won't make any
|
||||||
|
attempt to interpret the data it receives. `true` will not become a
|
||||||
|
boolean; `56` will not be interpreted as a number. Rather, each key
|
||||||
|
and every value will be read as a string, and as a string they will
|
||||||
|
remain. The order of the pairs is unchanged, and any duplicate keys
|
||||||
|
are preserved. However, YAML escape sequences will be replaced with
|
||||||
|
the proper interpretations according to the YAML 1.2 specification.
|
||||||
|
¶ The implementation provided below interprets `<br>` as `\n` and
|
||||||
|
allows for an open <p> tag at the beginning of the bio. It replaces
|
||||||
|
the escaped character entities `'` and `"` with single or
|
||||||
|
double quotes, respectively, prior to processing. However, no other
|
||||||
|
escaped characters are replaced, not even those which might have an
|
||||||
|
impact on the syntax otherwise. These minor allowances are provided
|
||||||
|
because the Mastodon backend will insert these things automatically
|
||||||
|
into a bio before sending it through the API, so it is important we
|
||||||
|
account for them. Aside from this, the YAML frontmatter must be the
|
||||||
|
very first thing in the bio, leading with three consecutive hyphen-
|
||||||
|
minues (`---`), and ending with the same or, alternatively, instead
|
||||||
|
with three periods (`...`). No limits have been set with respect to
|
||||||
|
the number of characters permitted in the frontmatter, although one
|
||||||
|
should note that only limited space is provided for them in the UI.
|
||||||
|
¶ The regular expression used to check the existence of, and then
|
||||||
|
process, the YAML frontmatter has been split into a number of small
|
||||||
|
components in the code below, in the vain hope that it will be much
|
||||||
|
easier to read and to maintain. I leave it to the future readers of
|
||||||
|
this code to determine the extent of my successes in this endeavor.
|
||||||
|
|
||||||
|
Sending love + warmth eternal,
|
||||||
|
- kibigo [@kibi@glitch.social]
|
||||||
|
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
/* CONVENIENCE FUNCTIONS */
|
||||||
|
|
||||||
|
const unirex = str => new RegExp(str, 'u');
|
||||||
|
const rexstr = exp => '(?:' + exp.source + ')';
|
||||||
|
|
||||||
|
/* CHARACTER CLASSES */
|
||||||
|
|
||||||
|
const DOCUMENT_START = /^/;
|
||||||
|
const DOCUMENT_END = /$/;
|
||||||
|
const ALLOWED_CHAR = // `c-printable` in the YAML 1.2 spec.
|
||||||
|
/[\t\n\r\x20-\x7e\x85\xa0-\ud7ff\ue000-\ufffd\u{10000}-\u{10FFFF}]/u;
|
||||||
|
const WHITE_SPACE = /[ \t]/;
|
||||||
|
const INDENTATION = / */; // Indentation must be only spaces.
|
||||||
|
const LINE_BREAK = /\r?\n|\r|<br\s*\/?>/;
|
||||||
|
const ESCAPE_CHAR = /[0abt\tnvfre "\/\\N_LP]/;
|
||||||
|
const HEXADECIMAL_CHARS = /[0-9a-fA-F]/;
|
||||||
|
const INDICATOR = /[-?:,[\]{}&#*!|>'"%@`]/;
|
||||||
|
const FLOW_CHAR = /[,[\]{}]/;
|
||||||
|
|
||||||
|
/* NEGATED CHARACTER CLASSES */
|
||||||
|
|
||||||
|
const NOT_WHITE_SPACE = unirex('(?!' + rexstr(WHITE_SPACE) + ')[^]');
|
||||||
|
const NOT_LINE_BREAK = unirex('(?!' + rexstr(LINE_BREAK) + ')[^]');
|
||||||
|
const NOT_INDICATOR = unirex('(?!' + rexstr(INDICATOR) + ')[^]');
|
||||||
|
const NOT_FLOW_CHAR = unirex('(?!' + rexstr(FLOW_CHAR) + ')[^]');
|
||||||
|
const NOT_ALLOWED_CHAR = unirex(
|
||||||
|
'(?!' + rexstr(ALLOWED_CHAR) + ')[^]'
|
||||||
|
);
|
||||||
|
|
||||||
|
/* BASIC CONSTRUCTS */
|
||||||
|
|
||||||
|
const ANY_WHITE_SPACE = unirex(rexstr(WHITE_SPACE) + '*');
|
||||||
|
const ANY_ALLOWED_CHARS = unirex(rexstr(ALLOWED_CHAR) + '*');
|
||||||
|
const NEW_LINE = unirex(
|
||||||
|
rexstr(ANY_WHITE_SPACE) + rexstr(LINE_BREAK)
|
||||||
|
);
|
||||||
|
const SOME_NEW_LINES = unirex(
|
||||||
|
'(?:' + rexstr(ANY_WHITE_SPACE) + rexstr(LINE_BREAK) + ')+'
|
||||||
|
);
|
||||||
|
const POSSIBLE_STARTS = unirex(
|
||||||
|
rexstr(DOCUMENT_START) + rexstr(/<p[^<>]*>/) + '?'
|
||||||
|
);
|
||||||
|
const POSSIBLE_ENDS = unirex(
|
||||||
|
rexstr(SOME_NEW_LINES) + '|' +
|
||||||
|
rexstr(DOCUMENT_END) + '|' +
|
||||||
|
rexstr(/<\/p>/)
|
||||||
|
);
|
||||||
|
const CHARACTER_ESCAPE = unirex(
|
||||||
|
rexstr(/\\/) +
|
||||||
|
'(?:' +
|
||||||
|
rexstr(ESCAPE_CHAR) + '|' +
|
||||||
|
rexstr(/x/) + rexstr(HEXADECIMAL_CHARS) + '{2}' + '|' +
|
||||||
|
rexstr(/u/) + rexstr(HEXADECIMAL_CHARS) + '{4}' + '|' +
|
||||||
|
rexstr(/U/) + rexstr(HEXADECIMAL_CHARS) + '{8}' +
|
||||||
|
')'
|
||||||
|
);
|
||||||
|
const ESCAPED_CHAR = unirex(
|
||||||
|
rexstr(/(?!["\\])/) + rexstr(NOT_LINE_BREAK) + '|' +
|
||||||
|
rexstr(CHARACTER_ESCAPE)
|
||||||
|
);
|
||||||
|
const ANY_ESCAPED_CHARS = unirex(
|
||||||
|
rexstr(ESCAPED_CHAR) + '*'
|
||||||
|
);
|
||||||
|
const ESCAPED_APOS = unirex(
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' + rexstr(/[^']|''/)
|
||||||
|
);
|
||||||
|
const ANY_ESCAPED_APOS = unirex(
|
||||||
|
rexstr(ESCAPED_APOS) + '*'
|
||||||
|
);
|
||||||
|
const FIRST_KEY_CHAR = unirex(
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_WHITE_SPACE) + ')' +
|
||||||
|
rexstr(NOT_INDICATOR) + '|' +
|
||||||
|
rexstr(/[?:-]/) +
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_WHITE_SPACE) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_FLOW_CHAR) + ')'
|
||||||
|
);
|
||||||
|
const FIRST_VALUE_CHAR = unirex(
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_WHITE_SPACE) + ')' +
|
||||||
|
rexstr(NOT_INDICATOR) + '|' +
|
||||||
|
rexstr(/[?:-]/) +
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_WHITE_SPACE) + ')'
|
||||||
|
// Flow indicators are allowed in values.
|
||||||
|
);
|
||||||
|
const LATER_KEY_CHAR = unirex(
|
||||||
|
rexstr(WHITE_SPACE) + '|' +
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_WHITE_SPACE) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_FLOW_CHAR) + ')' +
|
||||||
|
rexstr(/[^:#]#?/) + '|' +
|
||||||
|
rexstr(/:/) + '(?=' + rexstr(NOT_WHITE_SPACE) + ')'
|
||||||
|
);
|
||||||
|
const LATER_VALUE_CHAR = unirex(
|
||||||
|
rexstr(WHITE_SPACE) + '|' +
|
||||||
|
'(?=' + rexstr(NOT_LINE_BREAK) + ')' +
|
||||||
|
'(?=' + rexstr(NOT_WHITE_SPACE) + ')' +
|
||||||
|
// Flow indicators are allowed in values.
|
||||||
|
rexstr(/[^:#]#?/) + '|' +
|
||||||
|
rexstr(/:/) + '(?=' + rexstr(NOT_WHITE_SPACE) + ')'
|
||||||
|
);
|
||||||
|
|
||||||
|
/* YAML CONSTRUCTS */
|
||||||
|
|
||||||
|
const YAML_START = unirex(
|
||||||
|
rexstr(ANY_WHITE_SPACE) + rexstr(/---/)
|
||||||
|
);
|
||||||
|
const YAML_END = unirex(
|
||||||
|
rexstr(ANY_WHITE_SPACE) + rexstr(/(?:---|\.\.\.)/)
|
||||||
|
);
|
||||||
|
const YAML_LOOKAHEAD = unirex(
|
||||||
|
'(?=' +
|
||||||
|
rexstr(YAML_START) +
|
||||||
|
rexstr(ANY_ALLOWED_CHARS) + rexstr(NEW_LINE) +
|
||||||
|
rexstr(YAML_END) + rexstr(POSSIBLE_ENDS) +
|
||||||
|
')'
|
||||||
|
);
|
||||||
|
const YAML_DOUBLE_QUOTE = unirex(
|
||||||
|
rexstr(/"/) + rexstr(ANY_ESCAPED_CHARS) + rexstr(/"/)
|
||||||
|
);
|
||||||
|
const YAML_SINGLE_QUOTE = unirex(
|
||||||
|
rexstr(/'/) + rexstr(ANY_ESCAPED_APOS) + rexstr(/'/)
|
||||||
|
);
|
||||||
|
const YAML_SIMPLE_KEY = unirex(
|
||||||
|
rexstr(FIRST_KEY_CHAR) + rexstr(LATER_KEY_CHAR) + '*'
|
||||||
|
);
|
||||||
|
const YAML_SIMPLE_VALUE = unirex(
|
||||||
|
rexstr(FIRST_VALUE_CHAR) + rexstr(LATER_VALUE_CHAR) + '*'
|
||||||
|
);
|
||||||
|
const YAML_KEY = unirex(
|
||||||
|
rexstr(YAML_DOUBLE_QUOTE) + '|' +
|
||||||
|
rexstr(YAML_SINGLE_QUOTE) + '|' +
|
||||||
|
rexstr(YAML_SIMPLE_KEY)
|
||||||
|
);
|
||||||
|
const YAML_VALUE = unirex(
|
||||||
|
rexstr(YAML_DOUBLE_QUOTE) + '|' +
|
||||||
|
rexstr(YAML_SINGLE_QUOTE) + '|' +
|
||||||
|
rexstr(YAML_SIMPLE_VALUE)
|
||||||
|
);
|
||||||
|
const YAML_SEPARATOR = unirex(
|
||||||
|
rexstr(ANY_WHITE_SPACE) +
|
||||||
|
':' + rexstr(WHITE_SPACE) +
|
||||||
|
rexstr(ANY_WHITE_SPACE)
|
||||||
|
);
|
||||||
|
const YAML_LINE = unirex(
|
||||||
|
'(' + rexstr(YAML_KEY) + ')' +
|
||||||
|
rexstr(YAML_SEPARATOR) +
|
||||||
|
'(' + rexstr(YAML_VALUE) + ')'
|
||||||
|
);
|
||||||
|
|
||||||
|
/* FRONTMATTER REGEX */
|
||||||
|
|
||||||
|
const YAML_FRONTMATTER = unirex(
|
||||||
|
rexstr(POSSIBLE_STARTS) +
|
||||||
|
rexstr(YAML_LOOKAHEAD) +
|
||||||
|
rexstr(YAML_START) + rexstr(SOME_NEW_LINES) +
|
||||||
|
'(?:' +
|
||||||
|
'(' + rexstr(INDENTATION) + ')' +
|
||||||
|
rexstr(YAML_LINE) + rexstr(SOME_NEW_LINES) +
|
||||||
|
'(?:' +
|
||||||
|
'\\1' + rexstr(YAML_LINE) + rexstr(SOME_NEW_LINES) +
|
||||||
|
'){0,4}' +
|
||||||
|
')?' +
|
||||||
|
rexstr(YAML_END) + rexstr(POSSIBLE_ENDS)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* SEARCHES */
|
||||||
|
|
||||||
|
const FIND_YAML_LINES = unirex(
|
||||||
|
rexstr(NEW_LINE) + rexstr(INDENTATION) + rexstr(YAML_LINE)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* STRING PROCESSING */
|
||||||
|
|
||||||
|
function processString(str) {
|
||||||
|
switch (str.charAt(0)) {
|
||||||
|
case '"':
|
||||||
|
return str
|
||||||
|
.substring(1, str.length - 1)
|
||||||
|
.replace(/\\0/g, '\x00')
|
||||||
|
.replace(/\\a/g, '\x07')
|
||||||
|
.replace(/\\b/g, '\x08')
|
||||||
|
.replace(/\\t/g, '\x09')
|
||||||
|
.replace(/\\\x09/g, '\x09')
|
||||||
|
.replace(/\\n/g, '\x0a')
|
||||||
|
.replace(/\\v/g, '\x0b')
|
||||||
|
.replace(/\\f/g, '\x0c')
|
||||||
|
.replace(/\\r/g, '\x0d')
|
||||||
|
.replace(/\\e/g, '\x1b')
|
||||||
|
.replace(/\\ /g, '\x20')
|
||||||
|
.replace(/\\"/g, '\x22')
|
||||||
|
.replace(/\\\//g, '\x2f')
|
||||||
|
.replace(/\\\\/g, '\x5c')
|
||||||
|
.replace(/\\N/g, '\x85')
|
||||||
|
.replace(/\\_/g, '\xa0')
|
||||||
|
.replace(/\\L/g, '\u2028')
|
||||||
|
.replace(/\\P/g, '\u2029')
|
||||||
|
.replace(
|
||||||
|
new RegExp(
|
||||||
|
unirex(
|
||||||
|
rexstr(/\\x/) + '(' + rexstr(HEXADECIMAL_CHARS) + '{2})'
|
||||||
|
), 'gu'
|
||||||
|
), (_, n) => String.fromCodePoint('0x' + n)
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
new RegExp(
|
||||||
|
unirex(
|
||||||
|
rexstr(/\\u/) + '(' + rexstr(HEXADECIMAL_CHARS) + '{4})'
|
||||||
|
), 'gu'
|
||||||
|
), (_, n) => String.fromCodePoint('0x' + n)
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
new RegExp(
|
||||||
|
unirex(
|
||||||
|
rexstr(/\\U/) + '(' + rexstr(HEXADECIMAL_CHARS) + '{8})'
|
||||||
|
), 'gu'
|
||||||
|
), (_, n) => String.fromCodePoint('0x' + n)
|
||||||
|
);
|
||||||
|
case '\'':
|
||||||
|
return str
|
||||||
|
.substring(1, str.length - 1)
|
||||||
|
.replace(/''/g, '\'');
|
||||||
|
default:
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* BIO PROCESSING */
|
||||||
|
|
||||||
|
export function processBio(content) {
|
||||||
|
content = content.replace(/"/g, '"').replace(/'/g, '\'');
|
||||||
|
let result = {
|
||||||
|
text: content,
|
||||||
|
metadata: [],
|
||||||
|
};
|
||||||
|
let yaml = content.match(YAML_FRONTMATTER);
|
||||||
|
if (!yaml) return result;
|
||||||
|
else yaml = yaml[0];
|
||||||
|
let start = content.search(YAML_START);
|
||||||
|
let end = start + yaml.length - yaml.search(YAML_START);
|
||||||
|
result.text = content.substr(0, start) + content.substr(end);
|
||||||
|
let metadata = null;
|
||||||
|
let query = new RegExp(FIND_YAML_LINES, 'g');
|
||||||
|
while ((metadata = query.exec(yaml))) {
|
||||||
|
result.metadata.push([
|
||||||
|
processString(metadata[1]),
|
||||||
|
processString(metadata[2]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* BIO CREATION */
|
||||||
|
|
||||||
|
export function createBio(note, data) {
|
||||||
|
if (!note) note = '';
|
||||||
|
let frontmatter = '';
|
||||||
|
if ((data && data.length) || note.match(/^\s*---\s+/)) {
|
||||||
|
if (!data) frontmatter = '---\n...\n';
|
||||||
|
else {
|
||||||
|
frontmatter += '---\n';
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
let key = '' + data[i][0];
|
||||||
|
let val = '' + data[i][1];
|
||||||
|
|
||||||
|
// Key processing
|
||||||
|
if (key === (key.match(YAML_SIMPLE_KEY) || [])[0]) /* do nothing */;
|
||||||
|
else if (key.indexOf('\'') === -1 && key === (key.match(ANY_ESCAPED_APOS) || [])[0]) key = '\'' + key + '\'';
|
||||||
|
else {
|
||||||
|
key = key
|
||||||
|
.replace(/\x00/g, '\\0')
|
||||||
|
.replace(/\x07/g, '\\a')
|
||||||
|
.replace(/\x08/g, '\\b')
|
||||||
|
.replace(/\x0a/g, '\\n')
|
||||||
|
.replace(/\x0b/g, '\\v')
|
||||||
|
.replace(/\x0c/g, '\\f')
|
||||||
|
.replace(/\x0d/g, '\\r')
|
||||||
|
.replace(/\x1b/g, '\\e')
|
||||||
|
.replace(/\x22/g, '\\"')
|
||||||
|
.replace(/\x5c/g, '\\\\');
|
||||||
|
let badchars = key.match(
|
||||||
|
new RegExp(rexstr(NOT_ALLOWED_CHAR), 'gu')
|
||||||
|
) || [];
|
||||||
|
for (let j = 0; j < badchars.length; j++) {
|
||||||
|
key = key.replace(
|
||||||
|
badchars[i],
|
||||||
|
'\\u' + badchars[i].codePointAt(0).toLocaleString('en', {
|
||||||
|
useGrouping: false,
|
||||||
|
minimumIntegerDigits: 4,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
key = '"' + key + '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value processing
|
||||||
|
if (val === (val.match(YAML_SIMPLE_VALUE) || [])[0]) /* do nothing */;
|
||||||
|
else if (val.indexOf('\'') === -1 && val === (val.match(ANY_ESCAPED_APOS) || [])[0]) val = '\'' + val + '\'';
|
||||||
|
else {
|
||||||
|
val = val
|
||||||
|
.replace(/\x00/g, '\\0')
|
||||||
|
.replace(/\x07/g, '\\a')
|
||||||
|
.replace(/\x08/g, '\\b')
|
||||||
|
.replace(/\x0a/g, '\\n')
|
||||||
|
.replace(/\x0b/g, '\\v')
|
||||||
|
.replace(/\x0c/g, '\\f')
|
||||||
|
.replace(/\x0d/g, '\\r')
|
||||||
|
.replace(/\x1b/g, '\\e')
|
||||||
|
.replace(/\x22/g, '\\"')
|
||||||
|
.replace(/\x5c/g, '\\\\');
|
||||||
|
let badchars = val.match(
|
||||||
|
new RegExp(rexstr(NOT_ALLOWED_CHAR), 'gu')
|
||||||
|
) || [];
|
||||||
|
for (let j = 0; j < badchars.length; j++) {
|
||||||
|
val = val.replace(
|
||||||
|
badchars[i],
|
||||||
|
'\\u' + badchars[i].codePointAt(0).toLocaleString('en', {
|
||||||
|
useGrouping: false,
|
||||||
|
minimumIntegerDigits: 4,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
val = '"' + val + '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
frontmatter += key + ': ' + val + '\n';
|
||||||
|
}
|
||||||
|
frontmatter += '...\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return frontmatter + note;
|
||||||
|
}
|
||||||
BIN
app/javascript/images/cloud2.png
Normal file
BIN
app/javascript/images/cloud2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
BIN
app/javascript/images/cloud3.png
Normal file
BIN
app/javascript/images/cloud3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
BIN
app/javascript/images/cloud4.png
Normal file
BIN
app/javascript/images/cloud4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
app/javascript/images/elephant-fren.png
Normal file
BIN
app/javascript/images/elephant-fren.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" height="1000" width="1000"><path d="M500 0a500 500 0 0 0-353.553 146.447 500 500 0 1 0 707.106 707.106A500 500 0 0 0 500 0zm-.059 280.05h107.12c-19.071 13.424-26.187 51.016-27.12 73.843V562.05c0 44.32-35.68 80-80 80s-80-35.68-80-80v-202c0-44.32 35.68-80 80-80zm-.441 52c-15.464 0-28 12.537-28 28 0 15.465 12.536 28 28 28s28-12.535 28-28c0-15.463-12.536-28-28-28zm-279.059 7.9c44.32 0 80 35.68 80 80v206.157c.933 22.827 8.049 60.42 27.12 73.842H220.44c-44.32 0-80-35.68-80-80v-200c0-44.32 35.68-80 80-80zm559.12 0c44.32 0 80 35.68 80 80v200c0 44.32-35.68 80-80 80H672.44c19.071-13.424 26.187-51.016 27.12-73.843V419.95c0-44.32 35.68-80 80-80zM220 392c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28zm560 0c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28zm-280.5 40.05c-15.464 0-28 12.537-28 28 0 15.465 12.536 28 28 28s28-12.535 28-28c0-15.463-12.536-28-28-28zM220 491.95c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28zm560 0c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28zM499.5 532c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28zM220 591.95c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28zm560 0c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28z" fill="#189efc"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" height="1000" width="1000"><path d="M500 0a500 500 0 0 0-353.553 146.447 500 500 0 1 0 707.106 707.106A500 500 0 0 0 500 0zm-.059 280.05h107.12c-19.071 13.424-26.187 51.016-27.12 73.843V562.05c0 44.32-35.68 80-80 80s-80-35.68-80-80v-202c0-44.32 35.68-80 80-80zm-.441 52c-15.464 0-28 12.537-28 28 0 15.465 12.536 28 28 28s28-12.535 28-28c0-15.463-12.536-28-28-28zm-279.059 7.9c44.32 0 80 35.68 80 80v206.157c.933 22.827 8.049 60.42 27.12 73.842H220.44c-44.32 0-80-35.68-80-80v-200c0-44.32 35.68-80 80-80zm559.12 0c44.32 0 80 35.68 80 80v200c0 44.32-35.68 80-80 80H672.44c19.071-13.424 26.187-51.016 27.12-73.843V419.95c0-44.32 35.68-80 80-80zM220 392c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28zm560 0c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28zm-280.5 40.05c-15.464 0-28 12.537-28 28 0 15.465 12.536 28 28 28s28-12.535 28-28c0-15.463-12.536-28-28-28zM220 491.95c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28zm560 0c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28zM499.5 532c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28zM220 591.95c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28zm560 0c-15.464 0-28 12.535-28 28 0 15.463 12.536 28 28 28s28-12.537 28-28c0-15.465-12.536-28-28-28z" fill="#fff"/></svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -1,5 +1,4 @@
|
|||||||
import api, { getLinks } from '../api';
|
import api, { getLinks } from '../api';
|
||||||
import Immutable from 'immutable';
|
|
||||||
|
|
||||||
export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
|
export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
|
||||||
export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS';
|
export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS';
|
||||||
@@ -597,7 +596,7 @@ export function authorizeFollowRequest(id) {
|
|||||||
|
|
||||||
api(getState)
|
api(getState)
|
||||||
.post(`/api/v1/follow_requests/${id}/authorize`)
|
.post(`/api/v1/follow_requests/${id}/authorize`)
|
||||||
.then(response => dispatch(authorizeFollowRequestSuccess(id)))
|
.then(() => dispatch(authorizeFollowRequestSuccess(id)))
|
||||||
.catch(error => dispatch(authorizeFollowRequestFail(id, error)));
|
.catch(error => dispatch(authorizeFollowRequestFail(id, error)));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -631,7 +630,7 @@ export function rejectFollowRequest(id) {
|
|||||||
|
|
||||||
api(getState)
|
api(getState)
|
||||||
.post(`/api/v1/follow_requests/${id}/reject`)
|
.post(`/api/v1/follow_requests/${id}/reject`)
|
||||||
.then(response => dispatch(rejectFollowRequestSuccess(id)))
|
.then(() => dispatch(rejectFollowRequestSuccess(id)))
|
||||||
.catch(error => dispatch(rejectFollowRequestFail(id, error)));
|
.catch(error => dispatch(rejectFollowRequestFail(id, error)));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
25
app/javascript/mastodon/actions/bundles.js
Normal file
25
app/javascript/mastodon/actions/bundles.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
export const BUNDLE_FETCH_REQUEST = 'BUNDLE_FETCH_REQUEST';
|
||||||
|
export const BUNDLE_FETCH_SUCCESS = 'BUNDLE_FETCH_SUCCESS';
|
||||||
|
export const BUNDLE_FETCH_FAIL = 'BUNDLE_FETCH_FAIL';
|
||||||
|
|
||||||
|
export function fetchBundleRequest(skipLoading) {
|
||||||
|
return {
|
||||||
|
type: BUNDLE_FETCH_REQUEST,
|
||||||
|
skipLoading,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchBundleSuccess(skipLoading) {
|
||||||
|
return {
|
||||||
|
type: BUNDLE_FETCH_SUCCESS,
|
||||||
|
skipLoading,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchBundleFail(error, skipLoading) {
|
||||||
|
return {
|
||||||
|
type: BUNDLE_FETCH_FAIL,
|
||||||
|
error,
|
||||||
|
skipLoading,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ export const COMPOSE_SUGGESTION_SELECT = 'COMPOSE_SUGGESTION_SELECT';
|
|||||||
export const COMPOSE_MOUNT = 'COMPOSE_MOUNT';
|
export const COMPOSE_MOUNT = 'COMPOSE_MOUNT';
|
||||||
export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT';
|
export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT';
|
||||||
|
|
||||||
|
export const COMPOSE_ADVANCED_OPTIONS_CHANGE = 'COMPOSE_ADVANCED_OPTIONS_CHANGE';
|
||||||
export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
|
export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
|
||||||
export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
||||||
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
||||||
@@ -73,11 +74,14 @@ export function mentionCompose(account, router) {
|
|||||||
|
|
||||||
export function submitCompose() {
|
export function submitCompose() {
|
||||||
return function (dispatch, getState) {
|
return function (dispatch, getState) {
|
||||||
const status = emojione.shortnameToUnicode(getState().getIn(['compose', 'text'], ''));
|
let status = emojione.shortnameToUnicode(getState().getIn(['compose', 'text'], ''));
|
||||||
if (!status || !status.length) {
|
if (!status || !status.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(submitComposeRequest());
|
dispatch(submitComposeRequest());
|
||||||
|
if (getState().getIn(['compose', 'advanced_options', 'do_not_federate'])) {
|
||||||
|
status = status + ' 👁️';
|
||||||
|
}
|
||||||
api(getState).post('/api/v1/statuses', {
|
api(getState).post('/api/v1/statuses', {
|
||||||
status,
|
status,
|
||||||
in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null),
|
in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null),
|
||||||
@@ -244,6 +248,13 @@ export function unmountCompose() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function changeComposeAdvancedOption(option) {
|
||||||
|
return {
|
||||||
|
type: COMPOSE_ADVANCED_OPTIONS_CHANGE,
|
||||||
|
option: option,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function changeComposeSensitivity() {
|
export function changeComposeSensitivity() {
|
||||||
return {
|
return {
|
||||||
type: COMPOSE_SENSITIVITY_CHANGE,
|
type: COMPOSE_SENSITIVITY_CHANGE,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export function blockDomain(domain, accountId) {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(blockDomainRequest(domain));
|
dispatch(blockDomainRequest(domain));
|
||||||
|
|
||||||
api(getState).post('/api/v1/domain_blocks', { domain }).then(response => {
|
api(getState).post('/api/v1/domain_blocks', { domain }).then(() => {
|
||||||
dispatch(blockDomainSuccess(domain, accountId));
|
dispatch(blockDomainSuccess(domain, accountId));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
dispatch(blockDomainFail(domain, err));
|
dispatch(blockDomainFail(domain, err));
|
||||||
@@ -51,7 +51,7 @@ export function unblockDomain(domain, accountId) {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(unblockDomainRequest(domain));
|
dispatch(unblockDomainRequest(domain));
|
||||||
|
|
||||||
api(getState).delete('/api/v1/domain_blocks', { params: { domain } }).then(response => {
|
api(getState).delete('/api/v1/domain_blocks', { params: { domain } }).then(() => {
|
||||||
dispatch(unblockDomainSuccess(domain, accountId));
|
dispatch(unblockDomainSuccess(domain, accountId));
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
dispatch(unblockDomainFail(domain, err));
|
dispatch(unblockDomainFail(domain, err));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import api, { getLinks } from '../api';
|
import api, { getLinks } from '../api';
|
||||||
import Immutable from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import IntlMessageFormat from 'intl-messageformat';
|
import IntlMessageFormat from 'intl-messageformat';
|
||||||
import { fetchRelationships } from './accounts';
|
import { fetchRelationships } from './accounts';
|
||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
@@ -17,7 +17,7 @@ export const NOTIFICATIONS_EXPAND_FAIL = 'NOTIFICATIONS_EXPAND_FAIL';
|
|||||||
export const NOTIFICATIONS_CLEAR = 'NOTIFICATIONS_CLEAR';
|
export const NOTIFICATIONS_CLEAR = 'NOTIFICATIONS_CLEAR';
|
||||||
export const NOTIFICATIONS_SCROLL_TOP = 'NOTIFICATIONS_SCROLL_TOP';
|
export const NOTIFICATIONS_SCROLL_TOP = 'NOTIFICATIONS_SCROLL_TOP';
|
||||||
|
|
||||||
const messages = defineMessages({
|
defineMessages({
|
||||||
mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
|
mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ export function refreshNotificationsFail(error, skipLoading) {
|
|||||||
|
|
||||||
export function expandNotifications() {
|
export function expandNotifications() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const items = getState().getIn(['notifications', 'items'], Immutable.List());
|
const items = getState().getIn(['notifications', 'items'], ImmutableList());
|
||||||
|
|
||||||
if (getState().getIn(['notifications', 'isLoading']) || items.size === 0) {
|
if (getState().getIn(['notifications', 'isLoading']) || items.size === 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import api from '../api';
|
import api from '../api';
|
||||||
|
import { openModal, closeModal } from './modal';
|
||||||
|
|
||||||
export const REPORT_INIT = 'REPORT_INIT';
|
export const REPORT_INIT = 'REPORT_INIT';
|
||||||
export const REPORT_CANCEL = 'REPORT_CANCEL';
|
export const REPORT_CANCEL = 'REPORT_CANCEL';
|
||||||
@@ -11,10 +12,14 @@ export const REPORT_STATUS_TOGGLE = 'REPORT_STATUS_TOGGLE';
|
|||||||
export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE';
|
export const REPORT_COMMENT_CHANGE = 'REPORT_COMMENT_CHANGE';
|
||||||
|
|
||||||
export function initReport(account, status) {
|
export function initReport(account, status) {
|
||||||
return {
|
return dispatch => {
|
||||||
type: REPORT_INIT,
|
dispatch({
|
||||||
account,
|
type: REPORT_INIT,
|
||||||
status,
|
account,
|
||||||
|
status,
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(openModal('REPORT'));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,7 +45,10 @@ export function submitReport() {
|
|||||||
account_id: getState().getIn(['reports', 'new', 'account_id']),
|
account_id: getState().getIn(['reports', 'new', 'account_id']),
|
||||||
status_ids: getState().getIn(['reports', 'new', 'status_ids']),
|
status_ids: getState().getIn(['reports', 'new', 'status_ids']),
|
||||||
comment: getState().getIn(['reports', 'new', 'comment']),
|
comment: getState().getIn(['reports', 'new', 'comment']),
|
||||||
}).then(response => dispatch(submitReportSuccess(response.data))).catch(error => dispatch(submitReportFail(error)));
|
}).then(response => {
|
||||||
|
dispatch(closeModal());
|
||||||
|
dispatch(submitReportSuccess(response.data));
|
||||||
|
}).catch(error => dispatch(submitReportFail(error)));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export function deleteStatus(id) {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(deleteStatusRequest(id));
|
dispatch(deleteStatusRequest(id));
|
||||||
|
|
||||||
api(getState).delete(`/api/v1/statuses/${id}`).then(response => {
|
api(getState).delete(`/api/v1/statuses/${id}`).then(() => {
|
||||||
dispatch(deleteStatusSuccess(id));
|
dispatch(deleteStatusSuccess(id));
|
||||||
dispatch(deleteFromTimelines(id));
|
dispatch(deleteFromTimelines(id));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -152,7 +152,7 @@ export function muteStatus(id) {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(muteStatusRequest(id));
|
dispatch(muteStatusRequest(id));
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${id}/mute`).then(response => {
|
api(getState).post(`/api/v1/statuses/${id}/mute`).then(() => {
|
||||||
dispatch(muteStatusSuccess(id));
|
dispatch(muteStatusSuccess(id));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(muteStatusFail(id, error));
|
dispatch(muteStatusFail(id, error));
|
||||||
@@ -186,7 +186,7 @@ export function unmuteStatus(id) {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(unmuteStatusRequest(id));
|
dispatch(unmuteStatusRequest(id));
|
||||||
|
|
||||||
api(getState).post(`/api/v1/statuses/${id}/unmute`).then(response => {
|
api(getState).post(`/api/v1/statuses/${id}/unmute`).then(() => {
|
||||||
dispatch(unmuteStatusSuccess(id));
|
dispatch(unmuteStatusSuccess(id));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(unmuteStatusFail(id, error));
|
dispatch(unmuteStatusFail(id, error));
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import Immutable from 'immutable';
|
import { Iterable, fromJS } from 'immutable';
|
||||||
|
|
||||||
export const STORE_HYDRATE = 'STORE_HYDRATE';
|
export const STORE_HYDRATE = 'STORE_HYDRATE';
|
||||||
|
export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
|
||||||
|
|
||||||
const convertState = rawState =>
|
const convertState = rawState =>
|
||||||
Immutable.fromJS(rawState, (k, v) =>
|
fromJS(rawState, (k, v) =>
|
||||||
Immutable.Iterable.isIndexed(v) ? v.toList() : v.toMap().mapKeys(x =>
|
Iterable.isIndexed(v) ? v.toList() : v.toMap().mapKeys(x =>
|
||||||
Number.isNaN(x * 1) ? x : x * 1));
|
Number.isNaN(x * 1) ? x : x * 1));
|
||||||
|
|
||||||
export function hydrateStore(rawState) {
|
export function hydrateStore(rawState) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import api, { getLinks } from '../api';
|
import api, { getLinks } from '../api';
|
||||||
import Immutable from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
||||||
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
||||||
@@ -66,13 +66,13 @@ export function refreshTimelineRequest(timeline, skipLoading) {
|
|||||||
|
|
||||||
export function refreshTimeline(timelineId, path, params = {}) {
|
export function refreshTimeline(timelineId, path, params = {}) {
|
||||||
return function (dispatch, getState) {
|
return function (dispatch, getState) {
|
||||||
const timeline = getState().getIn(['timelines', timelineId], Immutable.Map());
|
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
||||||
|
|
||||||
if (timeline.get('isLoading') || timeline.get('online')) {
|
if (timeline.get('isLoading') || timeline.get('online')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = timeline.get('items', Immutable.List());
|
const ids = timeline.get('items', ImmutableList());
|
||||||
const newestId = ids.size > 0 ? ids.first() : null;
|
const newestId = ids.size > 0 ? ids.first() : null;
|
||||||
|
|
||||||
let skipLoading = timeline.get('loaded');
|
let skipLoading = timeline.get('loaded');
|
||||||
@@ -111,8 +111,8 @@ export function refreshTimelineFail(timeline, error, skipLoading) {
|
|||||||
|
|
||||||
export function expandTimeline(timelineId, path, params = {}) {
|
export function expandTimeline(timelineId, path, params = {}) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const timeline = getState().getIn(['timelines', timelineId], Immutable.Map());
|
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
||||||
const ids = timeline.get('items', Immutable.List());
|
const ids = timeline.get('items', ImmutableList());
|
||||||
|
|
||||||
if (timeline.get('isLoading') || ids.size === 0) {
|
if (timeline.get('isLoading') || ids.size === 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ const messages = defineMessages({
|
|||||||
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
|
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
|
||||||
});
|
});
|
||||||
|
|
||||||
class Account extends ImmutablePureComponent {
|
@injectIntl
|
||||||
|
export default class Account extends ImmutablePureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
@@ -82,5 +83,3 @@ class Account extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectIntl(Account);
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||||||
|
|
||||||
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
|
||||||
|
|
||||||
class AttachmentList extends ImmutablePureComponent {
|
export default class AttachmentList extends ImmutablePureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
media: ImmutablePropTypes.list.isRequired,
|
media: ImmutablePropTypes.list.isRequired,
|
||||||
@@ -31,5 +31,3 @@ class AttachmentList extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AttachmentList;
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const textAtCursorMatchesToken = (str, caretPosition) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class AutosuggestTextarea extends ImmutablePureComponent {
|
export default class AutosuggestTextarea extends ImmutablePureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
value: PropTypes.string,
|
value: PropTypes.string,
|
||||||
@@ -196,5 +196,3 @@ class AutosuggestTextarea extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AutosuggestTextarea;
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class Avatar extends React.PureComponent {
|
export default class Avatar extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
src: PropTypes.string.isRequired,
|
src: PropTypes.string.isRequired,
|
||||||
@@ -66,5 +66,3 @@ class Avatar extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Avatar;
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class AvatarOverlay extends React.PureComponent {
|
export default class AvatarOverlay extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
staticSrc: PropTypes.string.isRequired,
|
staticSrc: PropTypes.string.isRequired,
|
||||||
@@ -28,5 +28,3 @@ class AvatarOverlay extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AvatarOverlay;
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
class Button extends React.PureComponent {
|
export default class Button extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
text: PropTypes.node,
|
text: PropTypes.node,
|
||||||
@@ -61,5 +61,3 @@ class Button extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Button;
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import scrollTop from '../scroll';
|
import scrollTop from '../scroll';
|
||||||
|
|
||||||
class Column extends React.PureComponent {
|
export default class Column extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
@@ -41,5 +41,3 @@ class Column extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Column;
|
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ import React from 'react';
|
|||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class ColumnBackButton extends React.PureComponent {
|
export default class ColumnBackButton extends React.PureComponent {
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
router: PropTypes.object,
|
router: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
if (window.history && window.history.length === 1) this.context.router.history.push('/');
|
// if history is exhausted, or we would leave mastodon, just go to root.
|
||||||
else this.context.router.history.goBack();
|
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
|
||||||
|
this.context.router.history.push('/');
|
||||||
|
} else {
|
||||||
|
this.context.router.history.goBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@@ -23,5 +27,3 @@ class ColumnBackButton extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ColumnBackButton;
|
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ import React from 'react';
|
|||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class ColumnBackButtonSlim extends React.PureComponent {
|
export default class ColumnBackButtonSlim extends React.PureComponent {
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
router: PropTypes.object,
|
router: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
if (window.history && window.history.length === 1) this.context.router.history.push('/');
|
// if history is exhausted, or we would leave mastodon, just go to root.
|
||||||
else this.context.router.history.goBack();
|
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
|
||||||
|
this.context.router.history.push('/');
|
||||||
|
} else {
|
||||||
|
this.context.router.history.goBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@@ -25,5 +29,3 @@ class ColumnBackButtonSlim extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ColumnBackButtonSlim;
|
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
class ColumnCollapsable extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
icon: PropTypes.string.isRequired,
|
|
||||||
title: PropTypes.string,
|
|
||||||
fullHeight: PropTypes.number.isRequired,
|
|
||||||
children: PropTypes.node,
|
|
||||||
onCollapse: PropTypes.func,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
collapsed: true,
|
|
||||||
animating: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleToggleCollapsed = () => {
|
|
||||||
const currentState = this.state.collapsed;
|
|
||||||
|
|
||||||
this.setState({ collapsed: !currentState, animating: true });
|
|
||||||
|
|
||||||
if (!currentState && this.props.onCollapse) {
|
|
||||||
this.props.onCollapse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleTransitionEnd = () => {
|
|
||||||
this.setState({ animating: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { icon, title, fullHeight, children } = this.props;
|
|
||||||
const { collapsed, animating } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`column-collapsable ${collapsed ? 'collapsed' : ''}`} onTransitionEnd={this.handleTransitionEnd}>
|
|
||||||
<div role='button' tabIndex='0' title={`${title}`} className='column-collapsable__button column-icon' onClick={this.handleToggleCollapsed}>
|
|
||||||
<i className={`fa fa-${icon}`} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='column-collapsable__content' style={{ height: `${fullHeight}px` }}>
|
|
||||||
{(!collapsed || animating) && children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ColumnCollapsable;
|
|
||||||
@@ -3,14 +3,14 @@ import PropTypes from 'prop-types';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
class ColumnHeader extends React.PureComponent {
|
export default class ColumnHeader extends React.PureComponent {
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
router: PropTypes.object,
|
router: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.node.isRequired,
|
||||||
icon: PropTypes.string.isRequired,
|
icon: PropTypes.string.isRequired,
|
||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
multiColumn: PropTypes.bool,
|
multiColumn: PropTypes.bool,
|
||||||
@@ -45,8 +45,12 @@ class ColumnHeader extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleBackClick = () => {
|
handleBackClick = () => {
|
||||||
if (window.history && window.history.length === 1) this.context.router.history.push('/');
|
// if history is exhausted, or we would leave mastodon, just go to root.
|
||||||
else this.context.router.history.goBack();
|
if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) {
|
||||||
|
this.context.router.history.push('/');
|
||||||
|
} else {
|
||||||
|
this.context.router.history.goBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTransitionEnd = () => {
|
handleTransitionEnd = () => {
|
||||||
@@ -132,7 +136,7 @@ class ColumnHeader extends React.PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={collapsibleClassName} onTransitionEnd={this.handleTransitionEnd}>
|
<div className={collapsibleClassName} onTransitionEnd={this.handleTransitionEnd}>
|
||||||
<div>
|
<div className='column-header__collapsible-inner'>
|
||||||
{(!collapsed || animating) && collapsedContent}
|
{(!collapsed || animating) && collapsedContent}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -141,5 +145,3 @@ class ColumnHeader extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ColumnHeader;
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
import emojify from '../emoji';
|
import emojify from '../emoji';
|
||||||
|
|
||||||
class DisplayName extends React.PureComponent {
|
export default class DisplayName extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
@@ -21,5 +21,3 @@ class DisplayName extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DisplayName;
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import Dropdown, { DropdownTrigger, DropdownContent } from 'react-simple-dropdown';
|
import Dropdown, { DropdownTrigger, DropdownContent } from 'react-simple-dropdown';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class DropdownMenu extends React.PureComponent {
|
export default class DropdownMenu extends React.PureComponent {
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
router: PropTypes.object,
|
router: PropTypes.object,
|
||||||
@@ -14,6 +14,7 @@ class DropdownMenu extends React.PureComponent {
|
|||||||
size: PropTypes.number.isRequired,
|
size: PropTypes.number.isRequired,
|
||||||
direction: PropTypes.string,
|
direction: PropTypes.string,
|
||||||
ariaLabel: PropTypes.string,
|
ariaLabel: PropTypes.string,
|
||||||
|
disabled: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@@ -56,7 +57,7 @@ class DropdownMenu extends React.PureComponent {
|
|||||||
return <li key={`sep-${i}`} className='dropdown__sep' />;
|
return <li key={`sep-${i}`} className='dropdown__sep' />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { text, action, href = '#' } = item;
|
const { text, href = '#' } = item;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className='dropdown__content-list-item' key={`${text}-${i}`}>
|
<li className='dropdown__content-list-item' key={`${text}-${i}`}>
|
||||||
@@ -68,9 +69,19 @@ class DropdownMenu extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { icon, items, size, direction, ariaLabel } = this.props;
|
const { icon, items, size, direction, ariaLabel, disabled } = this.props;
|
||||||
const { expanded } = this.state;
|
const { expanded } = this.state;
|
||||||
const directionClass = (direction === 'left') ? 'dropdown__left' : 'dropdown__right';
|
const directionClass = (direction === 'left') ? 'dropdown__left' : 'dropdown__right';
|
||||||
|
const iconStyle = { fontSize: `${size}px`, width: `${size}px`, lineHeight: `${size}px` };
|
||||||
|
const iconClassname = `fa fa-fw fa-${icon} dropdown__icon`;
|
||||||
|
|
||||||
|
if (disabled) {
|
||||||
|
return (
|
||||||
|
<div className='icon-button disabled' style={iconStyle} aria-label={ariaLabel}>
|
||||||
|
<i className={iconClassname} aria-hidden />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const dropdownItems = expanded && (
|
const dropdownItems = expanded && (
|
||||||
<ul className='dropdown__content-list'>
|
<ul className='dropdown__content-list'>
|
||||||
@@ -80,8 +91,8 @@ class DropdownMenu extends React.PureComponent {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown ref={this.setRef} onShow={this.handleShow} onHide={this.handleHide}>
|
<Dropdown ref={this.setRef} onShow={this.handleShow} onHide={this.handleHide}>
|
||||||
<DropdownTrigger className='icon-button' style={{ fontSize: `${size}px`, width: `${size}px`, lineHeight: `${size}px` }} aria-label={ariaLabel}>
|
<DropdownTrigger className='icon-button' style={iconStyle} aria-label={ariaLabel}>
|
||||||
<i className={`fa fa-fw fa-${icon} dropdown__icon`} aria-hidden />
|
<i className={iconClassname} aria-hidden />
|
||||||
</DropdownTrigger>
|
</DropdownTrigger>
|
||||||
|
|
||||||
<DropdownContent className={directionClass}>
|
<DropdownContent className={directionClass}>
|
||||||
@@ -92,5 +103,3 @@ class DropdownMenu extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DropdownMenu;
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
class ExtendedVideoPlayer extends React.PureComponent {
|
export default class ExtendedVideoPlayer extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
src: PropTypes.string.isRequired,
|
src: PropTypes.string.isRequired,
|
||||||
@@ -44,5 +44,3 @@ class ExtendedVideoPlayer extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ExtendedVideoPlayer;
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user