Compare commits
2 Commits
compose-re
...
fix-upload
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4aa8d9d149 | ||
|
|
6ba67f92c9 |
@@ -1,6 +1,5 @@
|
|||||||
# Service dependencies
|
# Service dependencies
|
||||||
# You may set REDIS_URL instead for more advanced options
|
# You may set REDIS_URL instead for more advanced options
|
||||||
# You may also set REDIS_NAMESPACE to share Redis between multiple Mastodon servers
|
|
||||||
REDIS_HOST=redis
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
# You may set DATABASE_URL instead for more advanced options
|
# You may set DATABASE_URL instead for more advanced options
|
||||||
@@ -27,7 +26,7 @@ LOCAL_HTTPS=true
|
|||||||
# ALTERNATE_DOMAINS=example1.com,example2.com
|
# ALTERNATE_DOMAINS=example1.com,example2.com
|
||||||
|
|
||||||
# Application secrets
|
# Application secrets
|
||||||
# Generate each with the `RAILS_ENV=production bundle exec rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
|
# Generate each with the `rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)
|
||||||
PAPERCLIP_SECRET=
|
PAPERCLIP_SECRET=
|
||||||
SECRET_KEY_BASE=
|
SECRET_KEY_BASE=
|
||||||
OTP_SECRET=
|
OTP_SECRET=
|
||||||
@@ -37,7 +36,7 @@ OTP_SECRET=
|
|||||||
# You should only generate this once per instance. If you later decide to change it, all push subscription will
|
# You should only generate this once per instance. If you later decide to change it, all push subscription will
|
||||||
# be invalidated, requiring the users to access the website again to resubscribe.
|
# be invalidated, requiring the users to access the website again to resubscribe.
|
||||||
#
|
#
|
||||||
# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
|
# Generate with `rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
|
||||||
#
|
#
|
||||||
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html
|
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html
|
||||||
VAPID_PRIVATE_KEY=
|
VAPID_PRIVATE_KEY=
|
||||||
@@ -99,23 +98,6 @@ SMTP_FROM_ADDRESS=notifications@example.com
|
|||||||
# S3_ENDPOINT=
|
# S3_ENDPOINT=
|
||||||
# S3_SIGNATURE_VERSION=
|
# S3_SIGNATURE_VERSION=
|
||||||
|
|
||||||
# Swift (optional)
|
|
||||||
# SWIFT_ENABLED=true
|
|
||||||
# SWIFT_USERNAME=
|
|
||||||
# For Keystone V3, the value for SWIFT_TENANT should be the project name
|
|
||||||
# SWIFT_TENANT=
|
|
||||||
# SWIFT_PASSWORD=
|
|
||||||
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
|
|
||||||
# issues with token rate-limiting during high load.
|
|
||||||
# SWIFT_AUTH_URL=
|
|
||||||
# SWIFT_CONTAINER=
|
|
||||||
# SWIFT_OBJECT_URL=
|
|
||||||
# SWIFT_REGION=
|
|
||||||
# Defaults to 'default'
|
|
||||||
# SWIFT_DOMAIN_NAME=
|
|
||||||
# Defaults to 60 seconds. Set to 0 to disable
|
|
||||||
# SWIFT_CACHE_TTL=
|
|
||||||
|
|
||||||
# Optional alias for S3 if you want to use Cloudfront or Cloudflare in front
|
# Optional alias for S3 if you want to use Cloudfront or Cloudflare in front
|
||||||
# S3_CLOUDFRONT_HOST=
|
# S3_CLOUDFRONT_HOST=
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ env:
|
|||||||
browser: true
|
browser: true
|
||||||
node: true
|
node: true
|
||||||
es6: true
|
es6: true
|
||||||
jest: true
|
|
||||||
|
|
||||||
parser: babel-eslint
|
parser: babel-eslint
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- react
|
- react
|
||||||
- jsx-a11y
|
- jsx-a11y
|
||||||
- import
|
|
||||||
|
|
||||||
parserOptions:
|
parserOptions:
|
||||||
sourceType: module
|
sourceType: module
|
||||||
@@ -23,14 +21,8 @@ parserOptions:
|
|||||||
modules: true
|
modules: true
|
||||||
spread: true
|
spread: true
|
||||||
|
|
||||||
settings:
|
|
||||||
import/extensions:
|
|
||||||
- .js
|
|
||||||
import/ignore:
|
|
||||||
- node_modules
|
|
||||||
- \\.(css|scss|json)$
|
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
|
|
||||||
brace-style: warn
|
brace-style: warn
|
||||||
comma-dangle:
|
comma-dangle:
|
||||||
- error
|
- error
|
||||||
@@ -133,17 +125,3 @@ rules:
|
|||||||
jsx-a11y/role-supports-aria-props: off
|
jsx-a11y/role-supports-aria-props: off
|
||||||
jsx-a11y/scope: warn
|
jsx-a11y/scope: warn
|
||||||
jsx-a11y/tabindex-no-positive: warn
|
jsx-a11y/tabindex-no-positive: warn
|
||||||
|
|
||||||
import/extensions:
|
|
||||||
- error
|
|
||||||
- always
|
|
||||||
- js: never
|
|
||||||
import/newline-after-import: error
|
|
||||||
import/no-extraneous-dependencies:
|
|
||||||
- error
|
|
||||||
- devDependencies:
|
|
||||||
- "config/webpack/**"
|
|
||||||
- "app/javascript/mastodon/test_setup.js"
|
|
||||||
- "app/javascript/**/__tests__/**"
|
|
||||||
import/no-unresolved: error
|
|
||||||
import/no-webpack-loader-syntax: error
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.4.2
|
2.4.1
|
||||||
|
|||||||
@@ -26,16 +26,18 @@ addons:
|
|||||||
postgresql: 9.4
|
postgresql: 9.4
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
- trusty-media
|
- trusty-media
|
||||||
packages:
|
packages:
|
||||||
- ffmpeg
|
- ffmpeg
|
||||||
|
- g++-6
|
||||||
- libprotobuf-dev
|
- libprotobuf-dev
|
||||||
- protobuf-compiler
|
- protobuf-compiler
|
||||||
- libicu-dev
|
- libicu-dev
|
||||||
|
|
||||||
rvm:
|
rvm:
|
||||||
- 2.3.4
|
- 2.3.4
|
||||||
- 2.4.2
|
- 2.4.1
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- redis-server
|
- redis-server
|
||||||
@@ -53,5 +55,5 @@ before_script:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- travis_retry bundle exec parallel_test spec/ --group-by filesize --type rspec
|
- travis_retry bundle exec parallel_test spec/ --group-by filesize --type rspec
|
||||||
- yarn test
|
- npm test
|
||||||
- bundle exec i18n-tasks check-normalized && bundle exec i18n-tasks unused
|
- bundle exec i18n-tasks unused
|
||||||
|
|||||||
46
.yarnclean
@@ -1,46 +0,0 @@
|
|||||||
# test directories
|
|
||||||
__tests__
|
|
||||||
test
|
|
||||||
tests
|
|
||||||
powered-test
|
|
||||||
|
|
||||||
# asset directories
|
|
||||||
docs
|
|
||||||
doc
|
|
||||||
website
|
|
||||||
images
|
|
||||||
# assets
|
|
||||||
|
|
||||||
# examples
|
|
||||||
example
|
|
||||||
examples
|
|
||||||
|
|
||||||
# code coverage directories
|
|
||||||
coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# build scripts
|
|
||||||
Makefile
|
|
||||||
Gulpfile.js
|
|
||||||
Gruntfile.js
|
|
||||||
|
|
||||||
# configs
|
|
||||||
.tern-project
|
|
||||||
.gitattributes
|
|
||||||
.editorconfig
|
|
||||||
.*ignore
|
|
||||||
.eslintrc
|
|
||||||
.jshintrc
|
|
||||||
.flowconfig
|
|
||||||
.documentup.json
|
|
||||||
.yarn-metadata.json
|
|
||||||
.*.yml
|
|
||||||
*.yml
|
|
||||||
|
|
||||||
# misc
|
|
||||||
*.gz
|
|
||||||
*.md
|
|
||||||
|
|
||||||
# for specific ignore
|
|
||||||
!.svgo.yml
|
|
||||||
|
|
||||||
1
Aptfile
@@ -1,5 +1,4 @@
|
|||||||
ffmpeg
|
ffmpeg
|
||||||
libicu[0-9][0-9]
|
|
||||||
libicu-dev
|
libicu-dev
|
||||||
libidn11
|
libidn11
|
||||||
libidn11-dev
|
libidn11-dev
|
||||||
|
|||||||
17
CODEOWNERS
@@ -8,25 +8,8 @@
|
|||||||
# /config/locales/*.fr.yml @żelipapą
|
# /config/locales/*.fr.yml @żelipapą
|
||||||
# /config/locales/fr.yml @żelipapą
|
# /config/locales/fr.yml @żelipapą
|
||||||
|
|
||||||
# Polish
|
|
||||||
/app/javascript/mastodon/locales/pl.json @m4sk1n
|
/app/javascript/mastodon/locales/pl.json @m4sk1n
|
||||||
/app/views/user_mailer/*.pl.html.erb @m4sk1n
|
/app/views/user_mailer/*.pl.html.erb @m4sk1n
|
||||||
/app/views/user_mailer/*.pl.text.erb @m4sk1n
|
/app/views/user_mailer/*.pl.text.erb @m4sk1n
|
||||||
/config/locales/*.pl.yml @m4sk1n
|
/config/locales/*.pl.yml @m4sk1n
|
||||||
/config/locales/pl.yml @m4sk1n
|
/config/locales/pl.yml @m4sk1n
|
||||||
|
|
||||||
# French
|
|
||||||
/app/javascript/mastodon/locales/fr.json @aldarone
|
|
||||||
/app/javascript/mastodon/locales/whitelist_fr.json @aldarone
|
|
||||||
/app/views/user_mailer/*.fr.html.erb @aldarone
|
|
||||||
/app/views/user_mailer/*.fr.text.erb @aldarone
|
|
||||||
/config/locales/*.fr.yml @aldarone
|
|
||||||
/config/locales/fr.yml @aldarone
|
|
||||||
|
|
||||||
# Dutch
|
|
||||||
/app/javascript/mastodon/locales/nl.json @jeroenpraat
|
|
||||||
/app/javascript/mastodon/locales/whitelist_nl.json @jeroenpraat
|
|
||||||
/app/views/user_mailer/*.nl.html.erb @jeroenpraat
|
|
||||||
/app/views/user_mailer/*.nl.text.erb @jeroenpraat
|
|
||||||
/config/locales/*.nl.yml @jeroenpraat
|
|
||||||
/config/locales/nl.yml @jeroenpraat
|
|
||||||
|
|||||||
@@ -1,36 +1,3 @@
|
|||||||
# Contributing to Mastodon Glitch Edition #
|
|
||||||
|
|
||||||
Thank you for your interest in contributing to the `glitch-soc` project!
|
|
||||||
Here are some guidelines, and ways you can help.
|
|
||||||
|
|
||||||
> (This document is a bit of a work-in-progress, so please bear with us.
|
|
||||||
> If you don't see what you're looking for here, please don't hesitate to reach out!)
|
|
||||||
|
|
||||||
## Planning ##
|
|
||||||
|
|
||||||
Right now a lot of the planning for this project takes place in our development Discord, or through GitHub Issues and Projects.
|
|
||||||
We're working on ways to improve the planning structure and better solicit feedback, and if you feel like you can help in this respect, feel free to give us a holler.
|
|
||||||
|
|
||||||
## Documentation ##
|
|
||||||
|
|
||||||
The documentation for this repository is available at [`glitch-soc/docs`](https://github.com/glitch-soc/docs) (online at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/)).
|
|
||||||
Right now, we've mostly focused on the features that make this fork different from upstream in some manner.
|
|
||||||
Adding screenshots, improving descriptions, and so forth are all ways to help contribute to the project even if you don't know any code.
|
|
||||||
|
|
||||||
## Frontend Development ##
|
|
||||||
|
|
||||||
Check out [the documentation here](https://glitch-soc.github.io/docs/contributing/frontend/) for more information.
|
|
||||||
|
|
||||||
## Backend Development ##
|
|
||||||
|
|
||||||
See the guidelines below.
|
|
||||||
|
|
||||||
- - -
|
|
||||||
|
|
||||||
You should also try to follow the guidelines set out in the original `CONTRIBUTING.md` from `tootsuite/mastodon`, reproduced below.
|
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
|
|
||||||
CONTRIBUTING
|
CONTRIBUTING
|
||||||
============
|
============
|
||||||
|
|
||||||
@@ -82,5 +49,3 @@ It is expected that you have a working development environment set up (see back-
|
|||||||
* If you are introducing new strings, they must be using localization methods
|
* If you are introducing new strings, they must be using localization methods
|
||||||
|
|
||||||
If the JavaScript or CSS assets won't compile due to a syntax error, it's a good sign that the pull request isn't ready for submission yet.
|
If the JavaScript or CSS assets won't compile due to a syntax error, it's a good sign that the pull request isn't ready for submission yet.
|
||||||
|
|
||||||
</blockquote>
|
|
||||||
|
|||||||
21
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
FROM ruby:2.4.2-alpine3.6
|
FROM ruby:2.4.1-alpine3.6
|
||||||
|
|
||||||
LABEL maintainer="https://github.com/tootsuite/mastodon" \
|
LABEL maintainer="https://github.com/tootsuite/mastodon" \
|
||||||
description="A GNU Social-compatible microblogging server"
|
description="A GNU Social-compatible microblogging server"
|
||||||
@@ -7,8 +7,6 @@ ENV UID=991 GID=991 \
|
|||||||
RAILS_SERVE_STATIC_FILES=true \
|
RAILS_SERVE_STATIC_FILES=true \
|
||||||
RAILS_ENV=production NODE_ENV=production
|
RAILS_ENV=production NODE_ENV=production
|
||||||
|
|
||||||
ARG YARN_VERSION=1.1.0
|
|
||||||
ARG YARN_DOWNLOAD_SHA256=171c1f9ee93c488c0d774ac6e9c72649047c3f896277d88d0f805266519430f3
|
|
||||||
ARG LIBICONV_VERSION=1.15
|
ARG LIBICONV_VERSION=1.15
|
||||||
ARG LIBICONV_DOWNLOAD_SHA256=ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
|
ARG LIBICONV_DOWNLOAD_SHA256=ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
|
||||||
|
|
||||||
@@ -21,7 +19,6 @@ RUN apk -U upgrade \
|
|||||||
build-base \
|
build-base \
|
||||||
icu-dev \
|
icu-dev \
|
||||||
libidn-dev \
|
libidn-dev \
|
||||||
libressl \
|
|
||||||
libtool \
|
libtool \
|
||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
protobuf-dev \
|
protobuf-dev \
|
||||||
@@ -35,21 +32,16 @@ RUN apk -U upgrade \
|
|||||||
imagemagick \
|
imagemagick \
|
||||||
libidn \
|
libidn \
|
||||||
libpq \
|
libpq \
|
||||||
nodejs \
|
|
||||||
nodejs-npm \
|
nodejs-npm \
|
||||||
|
nodejs \
|
||||||
protobuf \
|
protobuf \
|
||||||
su-exec \
|
su-exec \
|
||||||
tini \
|
tini \
|
||||||
|
yarn \
|
||||||
&& update-ca-certificates \
|
&& update-ca-certificates \
|
||||||
&& mkdir -p /tmp/src /opt \
|
|
||||||
&& wget -O yarn.tar.gz "https://github.com/yarnpkg/yarn/releases/download/v$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
|
|
||||||
&& echo "$YARN_DOWNLOAD_SHA256 *yarn.tar.gz" | sha256sum -c - \
|
|
||||||
&& tar -xzf yarn.tar.gz -C /tmp/src \
|
|
||||||
&& rm yarn.tar.gz \
|
|
||||||
&& mv /tmp/src/yarn-v$YARN_VERSION /opt/yarn \
|
|
||||||
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
|
|
||||||
&& wget -O libiconv.tar.gz "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
|
&& wget -O libiconv.tar.gz "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
|
||||||
&& echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
|
&& echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
|
||||||
|
&& mkdir -p /tmp/src \
|
||||||
&& tar -xzf libiconv.tar.gz -C /tmp/src \
|
&& tar -xzf libiconv.tar.gz -C /tmp/src \
|
||||||
&& rm libiconv.tar.gz \
|
&& rm libiconv.tar.gz \
|
||||||
&& cd /tmp/src/libiconv-$LIBICONV_VERSION \
|
&& cd /tmp/src/libiconv-$LIBICONV_VERSION \
|
||||||
@@ -60,12 +52,11 @@ RUN apk -U upgrade \
|
|||||||
&& cd /mastodon \
|
&& cd /mastodon \
|
||||||
&& rm -rf /tmp/* /var/cache/apk/*
|
&& rm -rf /tmp/* /var/cache/apk/*
|
||||||
|
|
||||||
COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
|
COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/
|
||||||
|
|
||||||
RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
|
RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
|
||||||
&& bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
|
&& bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
|
||||||
&& yarn --pure-lockfile \
|
&& yarn --ignore-optional --pure-lockfile
|
||||||
&& yarn cache clean
|
|
||||||
|
|
||||||
COPY . /mastodon
|
COPY . /mastodon
|
||||||
|
|
||||||
|
|||||||
17
Gemfile
@@ -5,8 +5,8 @@ ruby '>= 2.3.0', '< 2.5.0'
|
|||||||
|
|
||||||
gem 'pkg-config', '~> 1.2'
|
gem 'pkg-config', '~> 1.2'
|
||||||
|
|
||||||
gem 'puma', '~> 3.10'
|
gem 'puma', '~> 3.8'
|
||||||
gem 'rails', '~> 5.1.4'
|
gem 'rails', '~> 5.1.0'
|
||||||
gem 'uglifier', '~> 3.2'
|
gem 'uglifier', '~> 3.2'
|
||||||
|
|
||||||
gem 'hamlit-rails', '~> 0.2'
|
gem 'hamlit-rails', '~> 0.2'
|
||||||
@@ -15,7 +15,6 @@ gem 'pghero', '~> 1.7'
|
|||||||
gem 'dotenv-rails', '~> 2.2'
|
gem 'dotenv-rails', '~> 2.2'
|
||||||
|
|
||||||
gem 'aws-sdk', '~> 2.9'
|
gem 'aws-sdk', '~> 2.9'
|
||||||
gem 'fog-openstack', '~> 0.1'
|
|
||||||
gem 'paperclip', '~> 5.1'
|
gem 'paperclip', '~> 5.1'
|
||||||
gem 'paperclip-av-transcoder', '~> 0.6'
|
gem 'paperclip-av-transcoder', '~> 0.6'
|
||||||
|
|
||||||
@@ -24,8 +23,7 @@ gem 'addressable', '~> 2.5'
|
|||||||
gem 'bootsnap'
|
gem 'bootsnap'
|
||||||
gem 'browser'
|
gem 'browser'
|
||||||
gem 'charlock_holmes', '~> 0.7.5'
|
gem 'charlock_holmes', '~> 0.7.5'
|
||||||
gem 'iso-639'
|
gem 'cld3', '~> 3.1'
|
||||||
gem 'cld3', '~> 3.2.0'
|
|
||||||
gem 'devise', '~> 4.2'
|
gem 'devise', '~> 4.2'
|
||||||
gem 'devise-two-factor', '~> 3.0'
|
gem 'devise-two-factor', '~> 3.0'
|
||||||
gem 'doorkeeper', '~> 4.2'
|
gem 'doorkeeper', '~> 4.2'
|
||||||
@@ -42,7 +40,6 @@ gem 'kaminari', '~> 1.0'
|
|||||||
gem 'link_header', '~> 0.0'
|
gem 'link_header', '~> 0.0'
|
||||||
gem 'mime-types', '~> 3.1'
|
gem 'mime-types', '~> 3.1'
|
||||||
gem 'nokogiri', '~> 1.7'
|
gem 'nokogiri', '~> 1.7'
|
||||||
gem 'nsa', '~> 0.2'
|
|
||||||
gem 'oj', '~> 3.0'
|
gem 'oj', '~> 3.0'
|
||||||
gem 'ostatus2', '~> 2.0'
|
gem 'ostatus2', '~> 2.0'
|
||||||
gem 'ox', '~> 2.5'
|
gem 'ox', '~> 2.5'
|
||||||
@@ -65,10 +62,10 @@ gem 'sidekiq-bulk', '~>0.1.1'
|
|||||||
gem 'simple-navigation', '~> 4.0'
|
gem 'simple-navigation', '~> 4.0'
|
||||||
gem 'simple_form', '~> 3.4'
|
gem 'simple_form', '~> 3.4'
|
||||||
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
|
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
|
||||||
gem 'strong_migrations'
|
gem 'statsd-instrument', '~> 2.1'
|
||||||
gem 'twitter-text', '~> 1.14'
|
gem 'twitter-text', '~> 1.14'
|
||||||
gem 'tzinfo-data', '~> 1.2017'
|
gem 'tzinfo-data', '~> 1.2017'
|
||||||
gem 'webpacker', '~> 3.0'
|
gem 'webpacker', '~> 2.0'
|
||||||
gem 'webpush'
|
gem 'webpush'
|
||||||
|
|
||||||
gem 'json-ld-preloaded', '~> 2.2.1'
|
gem 'json-ld-preloaded', '~> 2.2.1'
|
||||||
@@ -103,8 +100,8 @@ group :development do
|
|||||||
gem 'letter_opener', '~> 1.4'
|
gem 'letter_opener', '~> 1.4'
|
||||||
gem 'letter_opener_web', '~> 1.3'
|
gem 'letter_opener_web', '~> 1.3'
|
||||||
gem 'rubocop', require: false
|
gem 'rubocop', require: false
|
||||||
gem 'brakeman', '~> 4.0', require: false
|
gem 'brakeman', '~> 3.6', require: false
|
||||||
gem 'bundler-audit', '~> 0.6', require: false
|
gem 'bundler-audit', '~> 0.5', require: false
|
||||||
gem 'scss_lint', '~> 0.53', require: false
|
gem 'scss_lint', '~> 0.53', require: false
|
||||||
|
|
||||||
gem 'capistrano', '~> 3.8'
|
gem 'capistrano', '~> 3.8'
|
||||||
|
|||||||
217
Gemfile.lock
@@ -1,25 +1,25 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actioncable (5.1.4)
|
actioncable (5.1.3)
|
||||||
actionpack (= 5.1.4)
|
actionpack (= 5.1.3)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (~> 0.6.1)
|
websocket-driver (~> 0.6.1)
|
||||||
actionmailer (5.1.4)
|
actionmailer (5.1.3)
|
||||||
actionpack (= 5.1.4)
|
actionpack (= 5.1.3)
|
||||||
actionview (= 5.1.4)
|
actionview (= 5.1.3)
|
||||||
activejob (= 5.1.4)
|
activejob (= 5.1.3)
|
||||||
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.4)
|
actionpack (5.1.3)
|
||||||
actionview (= 5.1.4)
|
actionview (= 5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
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.4)
|
actionview (5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
@@ -30,16 +30,16 @@ GEM
|
|||||||
case_transform (>= 0.2)
|
case_transform (>= 0.2)
|
||||||
jsonapi-renderer (>= 0.1.1.beta1, < 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.4)
|
activejob (5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (5.1.4)
|
activemodel (5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
activerecord (5.1.4)
|
activerecord (5.1.3)
|
||||||
activemodel (= 5.1.4)
|
activemodel (= 5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
arel (~> 8.0)
|
arel (~> 8.0)
|
||||||
activesupport (5.1.4)
|
activesupport (5.1.3)
|
||||||
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)
|
||||||
@@ -57,33 +57,33 @@ 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.10.46)
|
aws-sdk (2.10.21)
|
||||||
aws-sdk-resources (= 2.10.46)
|
aws-sdk-resources (= 2.10.21)
|
||||||
aws-sdk-core (2.10.46)
|
aws-sdk-core (2.10.21)
|
||||||
aws-sigv4 (~> 1.0)
|
aws-sigv4 (~> 1.0)
|
||||||
jmespath (~> 1.0)
|
jmespath (~> 1.0)
|
||||||
aws-sdk-resources (2.10.46)
|
aws-sdk-resources (2.10.21)
|
||||||
aws-sdk-core (= 2.10.46)
|
aws-sdk-core (= 2.10.21)
|
||||||
aws-sigv4 (1.0.2)
|
aws-sigv4 (1.0.1)
|
||||||
bcrypt (3.1.11)
|
bcrypt (3.1.11)
|
||||||
better_errors (2.3.0)
|
better_errors (2.1.1)
|
||||||
coderay (>= 1.0.0)
|
coderay (>= 1.0.0)
|
||||||
erubi (>= 1.0.0)
|
erubis (>= 2.6.6)
|
||||||
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.1.3)
|
bootsnap (1.1.2)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
brakeman (4.0.1)
|
brakeman (3.7.2)
|
||||||
browser (2.5.1)
|
browser (2.4.0)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
bullet (5.6.1)
|
bullet (5.5.1)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
uniform_notifier (~> 1.10.0)
|
uniform_notifier (~> 1.10.0)
|
||||||
bundler-audit (0.6.0)
|
bundler-audit (0.6.0)
|
||||||
bundler (~> 1.2)
|
bundler (~> 1.2)
|
||||||
thor (~> 0.18)
|
thor (~> 0.18)
|
||||||
capistrano (3.9.1)
|
capistrano (3.8.2)
|
||||||
airbrussh (>= 1.0.0)
|
airbrussh (>= 1.0.0)
|
||||||
i18n
|
i18n
|
||||||
rake (>= 10.0.0)
|
rake (>= 10.0.0)
|
||||||
@@ -99,9 +99,9 @@ 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.15.1)
|
capybara (2.14.4)
|
||||||
addressable
|
addressable
|
||||||
mini_mime (>= 0.1.3)
|
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)
|
||||||
@@ -110,12 +110,12 @@ GEM
|
|||||||
activesupport
|
activesupport
|
||||||
charlock_holmes (0.7.5)
|
charlock_holmes (0.7.5)
|
||||||
chunky_png (1.3.8)
|
chunky_png (1.3.8)
|
||||||
cld3 (3.2.0)
|
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)
|
||||||
climate_control (>= 0.0.3, < 1.0)
|
climate_control (>= 0.0.3, < 1.0)
|
||||||
coderay (1.1.2)
|
coderay (1.1.1)
|
||||||
colorize (0.8.1)
|
colorize (0.8.1)
|
||||||
concurrent-ruby (1.0.5)
|
concurrent-ruby (1.0.5)
|
||||||
connection_pool (2.2.1)
|
connection_pool (2.2.1)
|
||||||
@@ -151,27 +151,15 @@ GEM
|
|||||||
thread_safe
|
thread_safe
|
||||||
encryptor (3.0.0)
|
encryptor (3.0.0)
|
||||||
erubi (1.6.1)
|
erubi (1.6.1)
|
||||||
|
erubis (2.7.0)
|
||||||
et-orbi (1.0.5)
|
et-orbi (1.0.5)
|
||||||
tzinfo
|
tzinfo
|
||||||
excon (0.59.0)
|
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
fabrication (2.16.3)
|
fabrication (2.16.2)
|
||||||
faker (1.8.4)
|
faker (1.7.3)
|
||||||
i18n (~> 0.5)
|
i18n (~> 0.5)
|
||||||
fast_blank (1.0.0)
|
fast_blank (1.0.0)
|
||||||
ffi (1.9.18)
|
ffi (1.9.18)
|
||||||
fog-core (1.45.0)
|
|
||||||
builder
|
|
||||||
excon (~> 0.58)
|
|
||||||
formatador (~> 0.2)
|
|
||||||
fog-json (1.0.2)
|
|
||||||
fog-core (~> 1.0)
|
|
||||||
multi_json (~> 1.10)
|
|
||||||
fog-openstack (0.1.21)
|
|
||||||
fog-core (>= 1.40)
|
|
||||||
fog-json (>= 1.0)
|
|
||||||
ipaddress (>= 0.8)
|
|
||||||
formatador (0.2.5)
|
|
||||||
fuubar (2.2.0)
|
fuubar (2.2.0)
|
||||||
rspec-core (~> 3.0)
|
rspec-core (~> 3.0)
|
||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.4)
|
||||||
@@ -193,7 +181,7 @@ GEM
|
|||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
hamster (3.0.0)
|
hamster (3.0.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
hashdiff (0.3.7)
|
hashdiff (0.3.5)
|
||||||
highline (1.7.8)
|
highline (1.7.8)
|
||||||
hiredis (0.6.1)
|
hiredis (0.6.1)
|
||||||
hkdf (0.3.0)
|
hkdf (0.3.0)
|
||||||
@@ -212,25 +200,23 @@ GEM
|
|||||||
colorize
|
colorize
|
||||||
rack
|
rack
|
||||||
i18n (0.8.6)
|
i18n (0.8.6)
|
||||||
i18n-tasks (0.9.18)
|
i18n-tasks (0.9.16)
|
||||||
activesupport (>= 4.0.2)
|
activesupport (>= 4.0.2)
|
||||||
ast (>= 2.1.0)
|
ast (>= 2.1.0)
|
||||||
easy_translate (>= 0.5.0)
|
easy_translate (>= 0.5.0)
|
||||||
erubi
|
erubis
|
||||||
highline (>= 1.7.3)
|
highline (>= 1.7.3)
|
||||||
i18n
|
i18n
|
||||||
parser (>= 2.2.3.0)
|
parser (>= 2.2.3.0)
|
||||||
rainbow (~> 2.2)
|
rainbow (~> 2.2)
|
||||||
terminal-table (>= 1.5.1)
|
terminal-table (>= 1.5.1)
|
||||||
idn-ruby (0.1.0)
|
idn-ruby (0.1.0)
|
||||||
ipaddress (0.8.3)
|
|
||||||
iso-639 (0.2.8)
|
|
||||||
jmespath (1.3.1)
|
jmespath (1.3.1)
|
||||||
json (2.1.0)
|
json (2.1.0)
|
||||||
json-ld (2.1.5)
|
json-ld (2.1.5)
|
||||||
multi_json (~> 1.12)
|
multi_json (~> 1.12)
|
||||||
rdf (~> 2.2)
|
rdf (~> 2.2)
|
||||||
json-ld-preloaded (2.2.2)
|
json-ld-preloaded (2.2.1)
|
||||||
json-ld (~> 2.1, >= 2.1.5)
|
json-ld (~> 2.1, >= 2.1.5)
|
||||||
multi_json (~> 1.11)
|
multi_json (~> 1.11)
|
||||||
rdf (~> 2.2)
|
rdf (~> 2.2)
|
||||||
@@ -257,11 +243,10 @@ GEM
|
|||||||
letter_opener (~> 1.0)
|
letter_opener (~> 1.0)
|
||||||
railties (>= 3.2)
|
railties (>= 3.2)
|
||||||
link_header (0.0.8)
|
link_header (0.0.8)
|
||||||
lograge (0.6.0)
|
lograge (0.5.1)
|
||||||
actionpack (>= 4, < 5.2)
|
actionpack (>= 4, < 5.2)
|
||||||
activesupport (>= 4, < 5.2)
|
activesupport (>= 4, < 5.2)
|
||||||
railties (>= 4, < 5.2)
|
railties (>= 4, < 5.2)
|
||||||
request_store (~> 1.0)
|
|
||||||
loofah (2.0.3)
|
loofah (2.0.3)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
mail (2.6.6)
|
mail (2.6.6)
|
||||||
@@ -276,33 +261,27 @@ GEM
|
|||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2016.0521)
|
mime-types-data (3.2016.0521)
|
||||||
mimemagic (0.3.2)
|
mimemagic (0.3.2)
|
||||||
mini_mime (0.1.4)
|
|
||||||
mini_portile2 (2.2.0)
|
mini_portile2 (2.2.0)
|
||||||
minitest (5.10.3)
|
minitest (5.10.3)
|
||||||
msgpack (1.1.0)
|
msgpack (1.1.0)
|
||||||
multi_json (1.12.2)
|
multi_json (1.12.1)
|
||||||
net-scp (1.2.1)
|
net-scp (1.2.1)
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh (4.2.0)
|
net-ssh (4.1.0)
|
||||||
nio4r (2.1.0)
|
nio4r (2.1.0)
|
||||||
nokogiri (1.8.0)
|
nokogiri (1.8.0)
|
||||||
mini_portile2 (~> 2.2.0)
|
mini_portile2 (~> 2.2.0)
|
||||||
nokogumbo (1.4.13)
|
nokogumbo (1.4.13)
|
||||||
nokogiri
|
nokogiri
|
||||||
nsa (0.2.4)
|
oj (3.3.4)
|
||||||
activesupport (>= 4.2, < 6)
|
openssl (2.0.4)
|
||||||
concurrent-ruby (~> 1.0.0)
|
|
||||||
sidekiq (>= 3.5.0)
|
|
||||||
statsd-ruby (~> 1.2.0)
|
|
||||||
oj (3.3.5)
|
|
||||||
openssl (2.0.5)
|
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
ostatus2 (2.0.1)
|
ostatus2 (2.0.1)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
http (~> 2.0)
|
http (~> 2.0)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.6)
|
||||||
openssl (~> 2.0)
|
openssl (~> 2.0)
|
||||||
ox (2.6.0)
|
ox (2.5.0)
|
||||||
paperclip (5.1.0)
|
paperclip (5.1.0)
|
||||||
activemodel (>= 4.2.0)
|
activemodel (>= 4.2.0)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
@@ -312,15 +291,15 @@ GEM
|
|||||||
paperclip-av-transcoder (0.6.4)
|
paperclip-av-transcoder (0.6.4)
|
||||||
av (~> 0.9.0)
|
av (~> 0.9.0)
|
||||||
paperclip (>= 2.5.2)
|
paperclip (>= 2.5.2)
|
||||||
parallel (1.12.0)
|
parallel (1.11.2)
|
||||||
parallel_tests (2.15.0)
|
parallel_tests (2.14.2)
|
||||||
parallel
|
parallel
|
||||||
parser (2.4.0.0)
|
parser (2.4.0.0)
|
||||||
ast (~> 2.2)
|
ast (~> 2.2)
|
||||||
pg (0.21.0)
|
pg (0.21.0)
|
||||||
pghero (1.7.0)
|
pghero (1.7.0)
|
||||||
activerecord
|
activerecord
|
||||||
pkg-config (1.2.7)
|
pkg-config (1.2.4)
|
||||||
powerpack (0.1.1)
|
powerpack (0.1.1)
|
||||||
pry (0.10.4)
|
pry (0.10.4)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
@@ -329,7 +308,7 @@ GEM
|
|||||||
pry-rails (0.3.6)
|
pry-rails (0.3.6)
|
||||||
pry (>= 0.10.4)
|
pry (>= 0.10.4)
|
||||||
public_suffix (3.0.0)
|
public_suffix (3.0.0)
|
||||||
puma (3.10.0)
|
puma (3.9.1)
|
||||||
pundit (1.1.0)
|
pundit (1.1.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
rabl (0.13.1)
|
rabl (0.13.1)
|
||||||
@@ -340,22 +319,20 @@ GEM
|
|||||||
rack-cors (0.4.1)
|
rack-cors (0.4.1)
|
||||||
rack-protection (2.0.0)
|
rack-protection (2.0.0)
|
||||||
rack
|
rack
|
||||||
rack-proxy (0.6.2)
|
rack-test (0.6.3)
|
||||||
rack
|
rack (>= 1.0)
|
||||||
rack-test (0.7.0)
|
|
||||||
rack (>= 1.0, < 3)
|
|
||||||
rack-timeout (0.4.2)
|
rack-timeout (0.4.2)
|
||||||
rails (5.1.4)
|
rails (5.1.3)
|
||||||
actioncable (= 5.1.4)
|
actioncable (= 5.1.3)
|
||||||
actionmailer (= 5.1.4)
|
actionmailer (= 5.1.3)
|
||||||
actionpack (= 5.1.4)
|
actionpack (= 5.1.3)
|
||||||
actionview (= 5.1.4)
|
actionview (= 5.1.3)
|
||||||
activejob (= 5.1.4)
|
activejob (= 5.1.3)
|
||||||
activemodel (= 5.1.4)
|
activemodel (= 5.1.3)
|
||||||
activerecord (= 5.1.4)
|
activerecord (= 5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
bundler (>= 1.3.0)
|
bundler (>= 1.3.0)
|
||||||
railties (= 5.1.4)
|
railties (= 5.1.3)
|
||||||
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)
|
||||||
@@ -371,16 +348,16 @@ GEM
|
|||||||
railties (~> 5.0)
|
railties (~> 5.0)
|
||||||
rails-settings-cached (0.6.6)
|
rails-settings-cached (0.6.6)
|
||||||
rails (>= 4.2.0)
|
rails (>= 4.2.0)
|
||||||
railties (5.1.4)
|
railties (5.1.3)
|
||||||
actionpack (= 5.1.4)
|
actionpack (= 5.1.3)
|
||||||
activesupport (= 5.1.4)
|
activesupport (= 5.1.3)
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rainbow (2.2.2)
|
rainbow (2.2.2)
|
||||||
rake
|
rake
|
||||||
rake (12.1.0)
|
rake (12.0.0)
|
||||||
rdf (2.2.9)
|
rdf (2.2.8)
|
||||||
hamster (~> 3.0)
|
hamster (~> 3.0)
|
||||||
link_header (~> 0.0, >= 0.0.8)
|
link_header (~> 0.0, >= 0.0.8)
|
||||||
rdf-normalize (0.3.2)
|
rdf-normalize (0.3.2)
|
||||||
@@ -404,7 +381,6 @@ GEM
|
|||||||
redis-store (>= 1.2, < 2)
|
redis-store (>= 1.2, < 2)
|
||||||
redis-store (1.3.0)
|
redis-store (1.3.0)
|
||||||
redis (>= 2.2)
|
redis (>= 2.2)
|
||||||
request_store (1.3.2)
|
|
||||||
responders (2.4.0)
|
responders (2.4.0)
|
||||||
actionpack (>= 4.2.0, < 5.3)
|
actionpack (>= 4.2.0, < 5.3)
|
||||||
railties (>= 4.2.0, < 5.3)
|
railties (>= 4.2.0, < 5.3)
|
||||||
@@ -419,7 +395,7 @@ GEM
|
|||||||
rspec-mocks (3.6.0)
|
rspec-mocks (3.6.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.6.0)
|
rspec-support (~> 3.6.0)
|
||||||
rspec-rails (3.6.1)
|
rspec-rails (3.6.0)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
@@ -431,15 +407,15 @@ GEM
|
|||||||
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)
|
||||||
rubocop (0.50.0)
|
rubocop (0.49.1)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 2.3.3.1, < 3.0)
|
parser (>= 2.3.3.1, < 3.0)
|
||||||
powerpack (~> 0.1)
|
powerpack (~> 0.1)
|
||||||
rainbow (>= 2.2.2, < 3.0)
|
rainbow (>= 1.99.1, < 3.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||||
ruby-oembed (0.12.0)
|
ruby-oembed (0.12.0)
|
||||||
ruby-progressbar (1.8.3)
|
ruby-progressbar (1.8.1)
|
||||||
rufus-scheduler (3.4.2)
|
rufus-scheduler (3.4.2)
|
||||||
et-orbi (~> 1.0)
|
et-orbi (~> 1.0)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
@@ -447,7 +423,7 @@ GEM
|
|||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.4.4)
|
nokogiri (>= 1.4.4)
|
||||||
nokogumbo (~> 1.4.1)
|
nokogumbo (~> 1.4.1)
|
||||||
sass (3.4.25)
|
sass (3.4.24)
|
||||||
scss_lint (0.54.0)
|
scss_lint (0.54.0)
|
||||||
rake (>= 0.9, < 13)
|
rake (>= 0.9, < 13)
|
||||||
sass (~> 3.4.20)
|
sass (~> 3.4.20)
|
||||||
@@ -459,12 +435,12 @@ GEM
|
|||||||
sidekiq-bulk (0.1.1)
|
sidekiq-bulk (0.1.1)
|
||||||
activesupport
|
activesupport
|
||||||
sidekiq
|
sidekiq
|
||||||
sidekiq-scheduler (2.1.9)
|
sidekiq-scheduler (2.1.8)
|
||||||
redis (~> 3)
|
redis (~> 3)
|
||||||
rufus-scheduler (~> 3.2)
|
rufus-scheduler (~> 3.2)
|
||||||
sidekiq (>= 3)
|
sidekiq (>= 3)
|
||||||
tilt (>= 1.4.0)
|
tilt (>= 1.4.0)
|
||||||
sidekiq-unique-jobs (5.0.10)
|
sidekiq-unique-jobs (5.0.9)
|
||||||
sidekiq (>= 4.0, <= 6.0)
|
sidekiq (>= 4.0, <= 6.0)
|
||||||
thor (~> 0)
|
thor (~> 0)
|
||||||
simple-navigation (4.0.5)
|
simple-navigation (4.0.5)
|
||||||
@@ -472,25 +448,23 @@ GEM
|
|||||||
simple_form (3.5.0)
|
simple_form (3.5.0)
|
||||||
actionpack (> 4, < 5.2)
|
actionpack (> 4, < 5.2)
|
||||||
activemodel (> 4, < 5.2)
|
activemodel (> 4, < 5.2)
|
||||||
simplecov (0.15.1)
|
simplecov (0.14.1)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1.0)
|
||||||
json (>= 1.8, < 3)
|
json (>= 1.8, < 3)
|
||||||
simplecov-html (~> 0.10.0)
|
simplecov-html (~> 0.10.0)
|
||||||
simplecov-html (0.10.2)
|
simplecov-html (0.10.1)
|
||||||
slop (3.6.0)
|
slop (3.6.0)
|
||||||
sprockets (3.7.1)
|
sprockets (3.7.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
rack (> 1, < 3)
|
rack (> 1, < 3)
|
||||||
sprockets-rails (3.2.1)
|
sprockets-rails (3.2.0)
|
||||||
actionpack (>= 4.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sshkit (1.14.0)
|
sshkit (1.13.1)
|
||||||
net-scp (>= 1.1.2)
|
net-scp (>= 1.1.2)
|
||||||
net-ssh (>= 2.8.0)
|
net-ssh (>= 2.8.0)
|
||||||
statsd-ruby (1.2.1)
|
statsd-instrument (2.1.4)
|
||||||
strong_migrations (0.1.9)
|
|
||||||
activerecord (>= 3.2.0)
|
|
||||||
temple (0.8.0)
|
temple (0.8.0)
|
||||||
terminal-table (1.8.0)
|
terminal-table (1.8.0)
|
||||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||||
@@ -513,13 +487,13 @@ GEM
|
|||||||
uniform_notifier (1.10.0)
|
uniform_notifier (1.10.0)
|
||||||
warden (1.2.7)
|
warden (1.2.7)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
webmock (3.1.0)
|
webmock (3.0.1)
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.3.6)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff
|
||||||
webpacker (3.0.1)
|
webpacker (2.0)
|
||||||
activesupport (>= 4.2)
|
activesupport (>= 4.2)
|
||||||
rack-proxy (>= 0.6.1)
|
multi_json (~> 1.2)
|
||||||
railties (>= 4.2)
|
railties (>= 4.2)
|
||||||
webpush (0.3.2)
|
webpush (0.3.2)
|
||||||
hkdf (~> 0.2)
|
hkdf (~> 0.2)
|
||||||
@@ -542,17 +516,17 @@ DEPENDENCIES
|
|||||||
better_errors (~> 2.1)
|
better_errors (~> 2.1)
|
||||||
binding_of_caller (~> 0.7)
|
binding_of_caller (~> 0.7)
|
||||||
bootsnap
|
bootsnap
|
||||||
brakeman (~> 4.0)
|
brakeman (~> 3.6)
|
||||||
browser
|
browser
|
||||||
bullet (~> 5.5)
|
bullet (~> 5.5)
|
||||||
bundler-audit (~> 0.6)
|
bundler-audit (~> 0.5)
|
||||||
capistrano (~> 3.8)
|
capistrano (~> 3.8)
|
||||||
capistrano-rails (~> 1.2)
|
capistrano-rails (~> 1.2)
|
||||||
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.5)
|
charlock_holmes (~> 0.7.5)
|
||||||
cld3 (~> 3.2.0)
|
cld3 (~> 3.1)
|
||||||
climate_control (~> 0.2)
|
climate_control (~> 0.2)
|
||||||
devise (~> 4.2)
|
devise (~> 4.2)
|
||||||
devise-two-factor (~> 3.0)
|
devise-two-factor (~> 3.0)
|
||||||
@@ -561,7 +535,6 @@ DEPENDENCIES
|
|||||||
fabrication (~> 2.16)
|
fabrication (~> 2.16)
|
||||||
faker (~> 1.7)
|
faker (~> 1.7)
|
||||||
fast_blank (~> 1.0)
|
fast_blank (~> 1.0)
|
||||||
fog-openstack (~> 0.1)
|
|
||||||
fuubar (~> 2.2)
|
fuubar (~> 2.2)
|
||||||
goldfinger (~> 2.0)
|
goldfinger (~> 2.0)
|
||||||
hamlit-rails (~> 0.2)
|
hamlit-rails (~> 0.2)
|
||||||
@@ -572,7 +545,6 @@ DEPENDENCIES
|
|||||||
httplog (~> 0.99)
|
httplog (~> 0.99)
|
||||||
i18n-tasks (~> 0.9)
|
i18n-tasks (~> 0.9)
|
||||||
idn-ruby
|
idn-ruby
|
||||||
iso-639
|
|
||||||
json-ld-preloaded (~> 2.2.1)
|
json-ld-preloaded (~> 2.2.1)
|
||||||
kaminari (~> 1.0)
|
kaminari (~> 1.0)
|
||||||
letter_opener (~> 1.4)
|
letter_opener (~> 1.4)
|
||||||
@@ -583,7 +555,6 @@ DEPENDENCIES
|
|||||||
microformats (~> 4.0)
|
microformats (~> 4.0)
|
||||||
mime-types (~> 3.1)
|
mime-types (~> 3.1)
|
||||||
nokogiri (~> 1.7)
|
nokogiri (~> 1.7)
|
||||||
nsa (~> 0.2)
|
|
||||||
oj (~> 3.0)
|
oj (~> 3.0)
|
||||||
ostatus2 (~> 2.0)
|
ostatus2 (~> 2.0)
|
||||||
ox (~> 2.5)
|
ox (~> 2.5)
|
||||||
@@ -594,13 +565,13 @@ DEPENDENCIES
|
|||||||
pghero (~> 1.7)
|
pghero (~> 1.7)
|
||||||
pkg-config (~> 1.2)
|
pkg-config (~> 1.2)
|
||||||
pry-rails (~> 0.3)
|
pry-rails (~> 0.3)
|
||||||
puma (~> 3.10)
|
puma (~> 3.8)
|
||||||
pundit (~> 1.1)
|
pundit (~> 1.1)
|
||||||
rabl (~> 0.13)
|
rabl (~> 0.13)
|
||||||
rack-attack (~> 5.0)
|
rack-attack (~> 5.0)
|
||||||
rack-cors (~> 0.4)
|
rack-cors (~> 0.4)
|
||||||
rack-timeout (~> 0.4)
|
rack-timeout (~> 0.4)
|
||||||
rails (~> 5.1.4)
|
rails (~> 5.1.0)
|
||||||
rails-controller-testing (~> 1.0)
|
rails-controller-testing (~> 1.0)
|
||||||
rails-i18n (~> 5.0)
|
rails-i18n (~> 5.0)
|
||||||
rails-settings-cached (~> 0.6)
|
rails-settings-cached (~> 0.6)
|
||||||
@@ -623,16 +594,16 @@ DEPENDENCIES
|
|||||||
simple_form (~> 3.4)
|
simple_form (~> 3.4)
|
||||||
simplecov (~> 0.14)
|
simplecov (~> 0.14)
|
||||||
sprockets-rails (~> 3.2)
|
sprockets-rails (~> 3.2)
|
||||||
strong_migrations
|
statsd-instrument (~> 2.1)
|
||||||
twitter-text (~> 1.14)
|
twitter-text (~> 1.14)
|
||||||
tzinfo-data (~> 1.2017)
|
tzinfo-data (~> 1.2017)
|
||||||
uglifier (~> 3.2)
|
uglifier (~> 3.2)
|
||||||
webmock (~> 3.0)
|
webmock (~> 3.0)
|
||||||
webpacker (~> 3.0)
|
webpacker (~> 2.0)
|
||||||
webpush
|
webpush
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.4.2p198
|
ruby 2.4.1p111
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.15.4
|
1.15.4
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
web: PORT=3000 bundle exec puma -C config/puma.rb
|
web: PORT=3000 bundle exec puma -C config/puma.rb
|
||||||
sidekiq: PORT=3000 bundle exec sidekiq
|
sidekiq: PORT=3000 bundle exec sidekiq
|
||||||
stream: PORT=4000 yarn run start
|
stream: PORT=4000 yarn run start
|
||||||
webpack: ./bin/webpack-dev-server --listen-host 0.0.0.0
|
webpack: ./bin/webpack-dev-server --host 0.0.0.0
|
||||||
|
|||||||
72
README.md
@@ -1,10 +1,70 @@
|
|||||||
# Mastodon Glitch Edition #
|

|
||||||
|
========
|
||||||
|
|
||||||
> Now with automated deploys!
|
[][travis]
|
||||||
|
[][code_climate]
|
||||||
|
|
||||||
[](https://travis-ci.org/glitch-soc/mastodon)
|
[travis]: https://travis-ci.org/tootsuite/mastodon
|
||||||
|
[code_climate]: https://codeclimate.com/github/tootsuite/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?
|
Mastodon is a free, open-source social network server. A decentralized solution to commercial platforms, it avoids the risks of a single company monopolizing your communication. Anyone can run Mastodon and participate in the social network seamlessly.
|
||||||
|
|
||||||
- You can view documentation for this project at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/).
|
An alternative implementation of the GNU social project. Based on [ActivityStreams](https://en.wikipedia.org/wiki/Activity_Streams_(format)), [Webfinger](https://en.wikipedia.org/wiki/WebFinger), [WebSub](https://en.wikipedia.org/wiki/WebSub) and [Salmon](https://en.wikipedia.org/wiki/Salmon_(protocol)).
|
||||||
- And contributing guidelines are available [here](CONTRIBUTING.md) and [here](https://glitch-soc.github.io/docs/contributing/).
|
|
||||||
|
Click on the screenshot to watch a demo of the UI:
|
||||||
|
|
||||||
|
[][youtube_demo]
|
||||||
|
|
||||||
|
[youtube_demo]: https://www.youtube.com/watch?v=YO1jQ8_rAMU
|
||||||
|
|
||||||
|
The project focus is a clean REST API and a good user interface. Ruby on Rails is used for the back-end, while React.js and Redux are used for the dynamic front-end. A static front-end for public resources (profiles and statuses) is also provided.
|
||||||
|
|
||||||
|
If you would like, you can [support the development of this project on Patreon][patreon]. Alternatively, you can donate to this BTC address: `17j2g7vpgHhLuXhN4bueZFCvdxxieyRVWd`
|
||||||
|
|
||||||
|
[patreon]: https://www.patreon.com/user?u=619786
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
- [List of Mastodon instances](https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/List-of-Mastodon-instances.md)
|
||||||
|
- [Use this tool to find Twitter friends on Mastodon](https://mastodon-bridge.herokuapp.com)
|
||||||
|
- [API overview](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md)
|
||||||
|
- [Frequently Asked Questions](https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/FAQ.md)
|
||||||
|
- [List of apps](https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/Apps.md)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Fully interoperable with GNU social and any OStatus platform**
|
||||||
|
Whatever implements Atom feeds, ActivityStreams, Salmon, WebSub and Webfinger is part of the network
|
||||||
|
- **Real-time timeline updates**
|
||||||
|
See the updates of people you're following appear in real-time in the UI via WebSockets
|
||||||
|
- **Federated thread resolving**
|
||||||
|
If someone you follow replies to a user unknown to the server, the server fetches the full thread so you can view it without leaving the UI
|
||||||
|
- **Media attachments like images and WebM**
|
||||||
|
Upload and view images and WebM videos attached to the updates
|
||||||
|
- **OAuth2 and a straightforward REST API**
|
||||||
|
Mastodon acts as an OAuth2 provider so 3rd party apps can use the API, which is RESTful and simple
|
||||||
|
- **Background processing for long-running tasks**
|
||||||
|
Mastodon tries to be as fast and responsive as possible, so all long-running tasks that can be delegated to background processing, are
|
||||||
|
- **Deployable via Docker**
|
||||||
|
You don't need to mess with dependencies and configuration if you want to try Mastodon, if you have Docker and Docker Compose the deployment is extremely easy
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
Please follow the [development guide](https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Development-guide.md) from the documentation repository.
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
There are guides in the documentation repository for [deploying on various platforms](https://github.com/tootsuite/documentation#running-mastodon).
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
You can open issues for bugs you've found or features you think are missing. You can also submit pull requests to this repository. [Here are the guidelines for code contributions](CONTRIBUTING.md)
|
||||||
|
|
||||||
|
**IRC channel**: #mastodon on irc.freenode.net
|
||||||
|
|
||||||
|
## Extra credits
|
||||||
|
|
||||||
|
- The [Emoji One](https://github.com/Ranks/emojione) pack has been used for the emojis
|
||||||
|
- The error page image courtesy of [Dopatwo](https://www.youtube.com/user/dopatwo)
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class AccountsController < ApplicationController
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@pinned_statuses = cache_collection(@account.pinned_statuses, Status) if show_pinned_statuses?
|
@pinned_statuses = cache_collection(@account.pinned_statuses, Status) unless media_requested?
|
||||||
@statuses = filtered_statuses.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
@statuses = filtered_statuses.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||||
@statuses = cache_collection(@statuses, Status)
|
@statuses = cache_collection(@statuses, Status)
|
||||||
@next_url = next_url unless @statuses.empty?
|
@next_url = next_url unless @statuses.empty?
|
||||||
@@ -22,24 +22,17 @@ class AccountsController < ApplicationController
|
|||||||
|
|
||||||
format.atom do
|
format.atom do
|
||||||
@entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
@entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||||
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.reject { |entry| entry.status.nil? }))
|
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.to_a))
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: @account,
|
render json: @account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
serializer: ActivityPub::ActorSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def show_pinned_statuses?
|
|
||||||
[replies_requested?, media_requested?, params[:max_id].present?, params[:since_id].present?].none?
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_statuses
|
def filtered_statuses
|
||||||
default_statuses.tap do |statuses|
|
default_statuses.tap do |statuses|
|
||||||
statuses.merge!(only_media_scope) if media_requested?
|
statuses.merge!(only_media_scope) if media_requested?
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ class ActivityPub::InboxesController < Api::BaseController
|
|||||||
if signed_request_account
|
if signed_request_account
|
||||||
upgrade_account
|
upgrade_account
|
||||||
process_payload
|
process_payload
|
||||||
head 202
|
head 201
|
||||||
else
|
else
|
||||||
[signature_verification_failure_reason, 401]
|
head 202
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -26,13 +26,8 @@ class ActivityPub::InboxesController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def upgrade_account
|
def upgrade_account
|
||||||
if signed_request_account.ostatus?
|
return unless signed_request_account.subscribed?
|
||||||
signed_request_account.update(last_webfingered_at: nil)
|
Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id)
|
||||||
ResolveRemoteAccountWorker.perform_async(signed_request_account.acct)
|
|
||||||
end
|
|
||||||
|
|
||||||
Pubsubhubbub::UnsubscribeWorker.perform_async(signed_request_account.id) if signed_request_account.subscribed?
|
|
||||||
DeliveryFailureTracker.track_inverse_success!(signed_request_account)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_payload
|
def process_payload
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Admin::AccountModerationNotesController < Admin::BaseController
|
|
||||||
def create
|
|
||||||
@account_moderation_note = current_account.account_moderation_notes.new(resource_params)
|
|
||||||
if @account_moderation_note.save
|
|
||||||
@target_account = @account_moderation_note.target_account
|
|
||||||
redirect_to admin_account_path(@target_account.id), notice: I18n.t('admin.account_moderation_notes.created_msg')
|
|
||||||
else
|
|
||||||
@account = @account_moderation_note.target_account
|
|
||||||
@moderation_notes = @account.targeted_moderation_notes.latest
|
|
||||||
render template: 'admin/accounts/show'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
@account_moderation_note = AccountModerationNote.find(params[:id])
|
|
||||||
@target_account = @account_moderation_note.target_account
|
|
||||||
@account_moderation_note.destroy
|
|
||||||
redirect_to admin_account_path(@target_account.id), notice: I18n.t('admin.account_moderation_notes.destroyed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:account_moderation_note).permit(
|
|
||||||
:content,
|
|
||||||
:target_account_id
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -9,10 +9,7 @@ module Admin
|
|||||||
@accounts = filtered_accounts.page(params[:page])
|
@accounts = filtered_accounts.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show; end
|
||||||
@account_moderation_note = current_account.account_moderation_notes.new(target_account: @account)
|
|
||||||
@moderation_notes = @account.targeted_moderation_notes.latest
|
|
||||||
end
|
|
||||||
|
|
||||||
def subscribe
|
def subscribe
|
||||||
Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
|
Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin
|
|
||||||
class CustomEmojisController < BaseController
|
|
||||||
before_action :set_custom_emoji, except: [:index, :new, :create]
|
|
||||||
|
|
||||||
def index
|
|
||||||
@custom_emojis = filtered_custom_emojis.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
|
||||||
@custom_emoji = CustomEmoji.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
@custom_emoji = CustomEmoji.new(resource_params)
|
|
||||||
|
|
||||||
if @custom_emoji.save
|
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.created_msg')
|
|
||||||
else
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
@custom_emoji.destroy
|
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.destroyed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
def copy
|
|
||||||
emoji = CustomEmoji.new(domain: nil, shortcode: @custom_emoji.shortcode, image: @custom_emoji.image)
|
|
||||||
|
|
||||||
if emoji.save
|
|
||||||
flash[:notice] = I18n.t('admin.custom_emojis.copied_msg')
|
|
||||||
else
|
|
||||||
flash[:alert] = I18n.t('admin.custom_emojis.copy_failed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to admin_custom_emojis_path(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def enable
|
|
||||||
@custom_emoji.update!(disabled: false)
|
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.enabled_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
def disable
|
|
||||||
@custom_emoji.update!(disabled: true)
|
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.disabled_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_custom_emoji
|
|
||||||
@custom_emoji = CustomEmoji.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:custom_emoji).permit(:shortcode, :image)
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_custom_emojis
|
|
||||||
CustomEmojiFilter.new(filter_params).results
|
|
||||||
end
|
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.permit(
|
|
||||||
:local,
|
|
||||||
:remote
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin
|
|
||||||
class EmailDomainBlocksController < BaseController
|
|
||||||
before_action :set_email_domain_block, only: [:show, :destroy]
|
|
||||||
|
|
||||||
def index
|
|
||||||
@email_domain_blocks = EmailDomainBlock.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
|
||||||
@email_domain_block = EmailDomainBlock.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
@email_domain_block = EmailDomainBlock.new(resource_params)
|
|
||||||
|
|
||||||
if @email_domain_block.save
|
|
||||||
redirect_to admin_email_domain_blocks_path, notice: I18n.t('admin.email_domain_blocks.created_msg')
|
|
||||||
else
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
@email_domain_block.destroy
|
|
||||||
redirect_to admin_email_domain_blocks_path, notice: I18n.t('admin.email_domain_blocks.destroyed_msg')
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_email_domain_block
|
|
||||||
@email_domain_block = EmailDomainBlock.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def resource_params
|
|
||||||
params.require(:email_domain_block).permit(:domain)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -14,12 +14,8 @@ module Admin
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def filtered_instances
|
|
||||||
InstanceFilter.new(filter_params).results
|
|
||||||
end
|
|
||||||
|
|
||||||
def paginated_instances
|
def paginated_instances
|
||||||
filtered_instances.page(params[:page])
|
Account.remote.by_domain_accounts.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :paginated_instances
|
helper_method :paginated_instances
|
||||||
@@ -31,11 +27,5 @@ module Admin
|
|||||||
def subscribeable_accounts
|
def subscribeable_accounts
|
||||||
Account.with_followers.remote.where(domain: params[:by_domain])
|
Account.with_followers.remote.where(domain: params[:by_domain])
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_params
|
|
||||||
params.permit(
|
|
||||||
:domain_name
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ module Admin
|
|||||||
closed_registrations_message
|
closed_registrations_message
|
||||||
open_deletion
|
open_deletion
|
||||||
timeline_preview
|
timeline_preview
|
||||||
bootstrap_timeline_accounts
|
|
||||||
thumbnail
|
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
BOOLEAN_SETTINGS = %w(
|
BOOLEAN_SETTINGS = %w(
|
||||||
@@ -23,24 +21,15 @@ module Admin
|
|||||||
timeline_preview
|
timeline_preview
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
UPLOAD_SETTINGS = %w(
|
|
||||||
thumbnail
|
|
||||||
).freeze
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@admin_settings = Form::AdminSettings.new
|
@admin_settings = Form::AdminSettings.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
settings_params.each do |key, value|
|
settings_params.each do |key, value|
|
||||||
if UPLOAD_SETTINGS.include?(key)
|
|
||||||
upload = SiteUpload.where(var: key).first_or_initialize(var: key)
|
|
||||||
upload.update(file: value)
|
|
||||||
else
|
|
||||||
setting = Setting.where(var: key).first_or_initialize(var: key)
|
setting = Setting.where(var: key).first_or_initialize(var: key)
|
||||||
setting.update(value: value_for_update(key, value))
|
setting.update(value: value_for_update(key, value))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
flash[:notice] = I18n.t('generic.changes_saved_msg')
|
||||||
redirect_to edit_admin_settings_path
|
redirect_to edit_admin_settings_path
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ class Api::SalmonController < Api::BaseController
|
|||||||
def update
|
def update
|
||||||
if verify_payload?
|
if verify_payload?
|
||||||
process_salmon
|
process_salmon
|
||||||
head 202
|
head 201
|
||||||
elsif payload.present?
|
|
||||||
[signature_verification_failure_reason, 401]
|
|
||||||
else
|
else
|
||||||
head 400
|
head 202
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController
|
|||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
accounts = Account.where(id: account_ids).select('id')
|
@accounts = Account.where(id: account_ids).select('id')
|
||||||
# .where doesn't guarantee that our results are in the same order
|
|
||||||
# we requested them, so return the "right" order to the requestor.
|
|
||||||
@accounts = accounts.index_by(&:id).values_at(*account_ids)
|
|
||||||
render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
|
render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
|
|
||||||
def follow
|
def follow
|
||||||
FollowService.new.call(current_user.account, @account.acct)
|
FollowService.new.call(current_user.account, @account.acct)
|
||||||
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
options = @account.locked? ? {} : { following_map: { @account.id => true }, requested_map: { @account.id => false } }
|
|
||||||
|
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships(options)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def block
|
def block
|
||||||
@@ -26,7 +23,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mute
|
def mute
|
||||||
MuteService.new.call(current_user.account, @account, notifications: params[:notifications])
|
MuteService.new.call(current_user.account, @account)
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -51,7 +48,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
@account = Account.find(params[:id])
|
@account = Account.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def relationships(options = {})
|
def relationships
|
||||||
AccountRelationshipsPresenter.new([@account.id], current_user.account_id, options)
|
AccountRelationshipsPresenter.new([@account.id], current_user.account_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::Apps::CredentialsController < Api::BaseController
|
|
||||||
before_action -> { doorkeeper_authorize! :read }
|
|
||||||
|
|
||||||
respond_to :json
|
|
||||||
|
|
||||||
def show
|
|
||||||
render json: doorkeeper_token.application, serializer: REST::StatusSerializer::ApplicationSerializer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::AppsController < Api::BaseController
|
class Api::V1::AppsController < Api::BaseController
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@app = Doorkeeper::Application.create!(application_options)
|
@app = Doorkeeper::Application.create!(application_options)
|
||||||
render json: @app, serializer: REST::ApplicationSerializer
|
render json: @app, serializer: REST::ApplicationSerializer
|
||||||
|
|||||||
@@ -15,13 +15,15 @@ class Api::V1::BlocksController < Api::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
paginated_blocks.map(&:target_account)
|
default_accounts.merge(paginated_blocks).to_a
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_accounts
|
||||||
|
Account.includes(:blocked_by).references(:blocked_by)
|
||||||
end
|
end
|
||||||
|
|
||||||
def paginated_blocks
|
def paginated_blocks
|
||||||
@paginated_blocks ||= Block.eager_load(:target_account)
|
Block.where(account: current_account).paginate_by_max_id(
|
||||||
.where(account: current_account)
|
|
||||||
.paginate_by_max_id(
|
|
||||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||||
params[:max_id],
|
params[:max_id],
|
||||||
params[:since_id]
|
params[:since_id]
|
||||||
@@ -39,21 +41,21 @@ class Api::V1::BlocksController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless paginated_blocks.empty?
|
unless @accounts.empty?
|
||||||
api_v1_blocks_url pagination_params(since_id: pagination_since_id)
|
api_v1_blocks_url pagination_params(since_id: pagination_since_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
paginated_blocks.last.id
|
@accounts.last.blocked_by_ids.last
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_since_id
|
def pagination_since_id
|
||||||
paginated_blocks.first.id
|
@accounts.first.blocked_by_ids.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def records_continue?
|
def records_continue?
|
||||||
paginated_blocks.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
@accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Api::V1::CustomEmojisController < Api::BaseController
|
|
||||||
respond_to :json
|
|
||||||
|
|
||||||
def index
|
|
||||||
render json: CustomEmoji.local.where(disabled: false), each_serializer: REST::CustomEmojiSerializer
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -10,12 +10,6 @@ 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)
|
||||||
|
|
||||||
if @account.nil?
|
|
||||||
username, domain = target_uri.split('@')
|
|
||||||
@account = Account.find_remote!(username, domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
render json: @account, serializer: REST::AccountSerializer
|
render json: @account, serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Api::V1::MediaController < Api::BaseController
|
|||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@media = current_account.media_attachments.create!(media_params)
|
@media = current_account.media_attachments.create!(file: media_params[:file])
|
||||||
render json: @media, serializer: REST::MediaAttachmentSerializer
|
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
|
||||||
@@ -18,16 +18,10 @@ class Api::V1::MediaController < Api::BaseController
|
|||||||
render json: processing_error, status: 500
|
render json: processing_error, status: 500
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
|
||||||
@media = current_account.media_attachments.where(status_id: nil).find(params[:id])
|
|
||||||
@media.update!(media_params)
|
|
||||||
render json: @media, serializer: REST::MediaAttachmentSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def media_params
|
def media_params
|
||||||
params.permit(:file, :description)
|
params.permit(:file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_type_error
|
def file_type_error
|
||||||
|
|||||||
@@ -8,15 +8,10 @@ class Api::V1::MutesController < Api::BaseController
|
|||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@data = @accounts = load_accounts
|
@accounts = load_accounts
|
||||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def details
|
|
||||||
@data = @mutes = load_mutes
|
|
||||||
render json: @mutes, each_serializer: REST::MuteSerializer
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
@@ -27,10 +22,6 @@ class Api::V1::MutesController < Api::BaseController
|
|||||||
Account.includes(:muted_by).references(:muted_by)
|
Account.includes(:muted_by).references(:muted_by)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_mutes
|
|
||||||
paginated_mutes.includes(:account, :target_account).to_a
|
|
||||||
end
|
|
||||||
|
|
||||||
def paginated_mutes
|
def paginated_mutes
|
||||||
Mute.where(account: current_account).paginate_by_max_id(
|
Mute.where(account: current_account).paginate_by_max_id(
|
||||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||||
@@ -45,34 +36,26 @@ class Api::V1::MutesController < Api::BaseController
|
|||||||
|
|
||||||
def next_path
|
def next_path
|
||||||
if records_continue?
|
if records_continue?
|
||||||
url_for pagination_params(max_id: pagination_max_id)
|
api_v1_mutes_url pagination_params(max_id: pagination_max_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prev_path
|
def prev_path
|
||||||
unless@data.empty?
|
unless @accounts.empty?
|
||||||
url_for pagination_params(since_id: pagination_since_id)
|
api_v1_mutes_url pagination_params(since_id: pagination_since_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_max_id
|
def pagination_max_id
|
||||||
if params[:action] == "details"
|
|
||||||
@mutes.last.id
|
|
||||||
else
|
|
||||||
@accounts.last.muted_by_ids.last
|
@accounts.last.muted_by_ids.last
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_since_id
|
def pagination_since_id
|
||||||
if params[:action] == "details"
|
|
||||||
@mutes.first.id
|
|
||||||
else
|
|
||||||
@accounts.first.muted_by_ids.first
|
@accounts.first.muted_by_ids.first
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def records_continue?
|
def records_continue?
|
||||||
@data.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
@accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pagination_params(core_params)
|
def pagination_params(core_params)
|
||||||
|
|||||||
@@ -24,20 +24,11 @@ class Api::V1::NotificationsController < Api::BaseController
|
|||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
|
||||||
dismiss
|
|
||||||
end
|
|
||||||
|
|
||||||
def dismiss
|
def dismiss
|
||||||
current_account.notifications.find_by!(id: params[:id]).destroy!
|
current_account.notifications.find_by!(id: params[:id]).destroy!
|
||||||
render_empty
|
render_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_multiple
|
|
||||||
current_account.notifications.where(id: params[:ids]).destroy_all
|
|
||||||
render_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_notifications
|
def load_notifications
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::SearchController < Api::BaseController
|
class Api::V1::SearchController < Api::BaseController
|
||||||
RESULTS_LIMIT = 10
|
RESULTS_LIMIT = 5
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :read }
|
before_action -> { doorkeeper_authorize! :read }
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
helper_method :current_account
|
helper_method :current_account
|
||||||
helper_method :current_session
|
helper_method :current_session
|
||||||
helper_method :current_theme
|
|
||||||
helper_method :single_user_mode?
|
helper_method :single_user_mode?
|
||||||
|
|
||||||
rescue_from ActionController::RoutingError, with: :not_found
|
rescue_from ActionController::RoutingError, with: :not_found
|
||||||
@@ -78,11 +77,6 @@ class ApplicationController < ActionController::Base
|
|||||||
@current_session ||= SessionActivation.find_by(session_id: cookies.signed['_session_id'])
|
@current_session ||= SessionActivation.find_by(session_id: cookies.signed['_session_id'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_theme
|
|
||||||
return Setting.default_settings['theme'] unless Themes.instance.names.include? current_user&.setting_theme
|
|
||||||
current_user.setting_theme
|
|
||||||
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)
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,4 @@
|
|||||||
|
|
||||||
class Auth::ConfirmationsController < Devise::ConfirmationsController
|
class Auth::ConfirmationsController < Devise::ConfirmationsController
|
||||||
layout 'auth'
|
layout 'auth'
|
||||||
|
|
||||||
def show
|
|
||||||
super do |user|
|
|
||||||
BootstrapTimelineWorker.perform_async(user.account_id) if user.errors.empty?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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]
|
before_action :set_sessions, only: [:edit, :update]
|
||||||
before_action :set_instance_presenter, only: [:new, :create, :update]
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
not_found
|
not_found
|
||||||
@@ -40,10 +39,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_instance_presenter
|
|
||||||
@instance_presenter = InstancePresenter.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def determine_layout
|
def determine_layout
|
||||||
%w(edit update).include?(action_name) ? 'admin' : 'auth'
|
%w(edit update).include?(action_name) ? 'admin' : 'auth'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ class Auth::SessionsController < Devise::SessionsController
|
|||||||
skip_before_action :require_no_authentication, only: [:create]
|
skip_before_action :require_no_authentication, only: [:create]
|
||||||
skip_before_action :check_suspension, only: [:destroy]
|
skip_before_action :check_suspension, only: [:destroy]
|
||||||
prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create]
|
prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create]
|
||||||
before_action :set_instance_presenter, only: [:new]
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
super do |resource|
|
super do |resource|
|
||||||
@@ -85,10 +84,6 @@ class Auth::SessionsController < Devise::SessionsController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_instance_presenter
|
|
||||||
@instance_presenter = InstancePresenter.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def home_paths(resource)
|
def home_paths(resource)
|
||||||
paths = [about_path]
|
paths = [about_path]
|
||||||
if single_user_mode? && resource.is_a?(User)
|
if single_user_mode? && resource.is_a?(User)
|
||||||
|
|||||||
@@ -9,15 +9,10 @@ module SignatureVerification
|
|||||||
request.headers['Signature'].present?
|
request.headers['Signature'].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def signature_verification_failure_reason
|
|
||||||
return @signature_verification_failure_reason if defined?(@signature_verification_failure_reason)
|
|
||||||
end
|
|
||||||
|
|
||||||
def signed_request_account
|
def signed_request_account
|
||||||
return @signed_request_account if defined?(@signed_request_account)
|
return @signed_request_account if defined?(@signed_request_account)
|
||||||
|
|
||||||
unless signed_request?
|
unless signed_request?
|
||||||
@signature_verification_failure_reason = 'Request not signed'
|
|
||||||
@signed_request_account = nil
|
@signed_request_account = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -32,7 +27,6 @@ module SignatureVerification
|
|||||||
end
|
end
|
||||||
|
|
||||||
if incompatible_signature?(signature_params)
|
if incompatible_signature?(signature_params)
|
||||||
@signature_verification_failure_reason = 'Incompatible request signature'
|
|
||||||
@signed_request_account = nil
|
@signed_request_account = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -40,7 +34,6 @@ module SignatureVerification
|
|||||||
account = account_from_key_id(signature_params['keyId'])
|
account = account_from_key_id(signature_params['keyId'])
|
||||||
|
|
||||||
if account.nil?
|
if account.nil?
|
||||||
@signature_verification_failure_reason = "Public key not found for key #{signature_params['keyId']}"
|
|
||||||
@signed_request_account = nil
|
@signed_request_account = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -48,21 +41,10 @@ module SignatureVerification
|
|||||||
signature = Base64.decode64(signature_params['signature'])
|
signature = Base64.decode64(signature_params['signature'])
|
||||||
compare_signed_string = build_signed_string(signature_params['headers'])
|
compare_signed_string = build_signed_string(signature_params['headers'])
|
||||||
|
|
||||||
if account.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, signature, compare_signed_string)
|
|
||||||
@signed_request_account = account
|
|
||||||
@signed_request_account
|
|
||||||
elsif account.possibly_stale?
|
|
||||||
account = account.refresh!
|
|
||||||
|
|
||||||
if account.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, signature, compare_signed_string)
|
if account.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, signature, compare_signed_string)
|
||||||
@signed_request_account = account
|
@signed_request_account = account
|
||||||
@signed_request_account
|
@signed_request_account
|
||||||
else
|
else
|
||||||
@signed_verification_failure_reason = "Verification failed for #{account.username}@#{account.domain} #{account.uri}"
|
|
||||||
@signed_request_account = nil
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@signed_verification_failure_reason = "Verification failed for #{account.username}@#{account.domain} #{account.uri}"
|
|
||||||
@signed_request_account = nil
|
@signed_request_account = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -117,7 +99,7 @@ module SignatureVerification
|
|||||||
ResolveRemoteAccountService.new.call(key_id.gsub(/\Aacct:/, ''))
|
ResolveRemoteAccountService.new.call(key_id.gsub(/\Aacct:/, ''))
|
||||||
elsif !ActivityPub::TagManager.instance.local_uri?(key_id)
|
elsif !ActivityPub::TagManager.instance.local_uri?(key_id)
|
||||||
account = ActivityPub::TagManager.instance.uri_to_resource(key_id, Account)
|
account = ActivityPub::TagManager.instance.uri_to_resource(key_id, Account)
|
||||||
account ||= ActivityPub::FetchRemoteKeyService.new.call(key_id, id: false)
|
account ||= ActivityPub::FetchRemoteKeyService.new.call(key_id)
|
||||||
account
|
account
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,14 +7,12 @@ module UserTrackingConcern
|
|||||||
UPDATE_SIGN_IN_HOURS = 24
|
UPDATE_SIGN_IN_HOURS = 24
|
||||||
|
|
||||||
included do
|
included do
|
||||||
before_action :set_user_activity
|
before_action :set_user_activity, if: %i(user_signed_in? user_needs_sign_in_update?)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_user_activity
|
def set_user_activity
|
||||||
return unless user_needs_sign_in_update?
|
|
||||||
|
|
||||||
# Mark as signed-in today
|
# Mark as signed-in today
|
||||||
current_user.update_tracked_fields!(request)
|
current_user.update_tracked_fields!(request)
|
||||||
|
|
||||||
@@ -23,7 +21,7 @@ module UserTrackingConcern
|
|||||||
end
|
end
|
||||||
|
|
||||||
def user_needs_sign_in_update?
|
def user_needs_sign_in_update?
|
||||||
user_signed_in? && (current_user.current_sign_in_at.nil? || current_user.current_sign_in_at < UPDATE_SIGN_IN_HOURS.hours.ago)
|
current_user.current_sign_in_at.nil? || current_user.current_sign_in_at < UPDATE_SIGN_IN_HOURS.hours.ago
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_needs_feed_update?
|
def user_needs_feed_update?
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class EmojisController < ApplicationController
|
|
||||||
before_action :set_emoji
|
|
||||||
|
|
||||||
def show
|
|
||||||
respond_to do |format|
|
|
||||||
format.json do
|
|
||||||
render json: @emoji,
|
|
||||||
serializer: ActivityPub::EmojiSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_emoji
|
|
||||||
@emoji = CustomEmoji.local.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -10,39 +10,19 @@ class FollowerAccountsController < ApplicationController
|
|||||||
format.html
|
format.html
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: collection_presenter,
|
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
serializer: ActivityPub::CollectionSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def page_url(page)
|
|
||||||
account_followers_url(@account, page: page) unless page.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
page = ActivityPub::CollectionPresenter.new(
|
|
||||||
id: account_followers_url(@account, page: params.fetch(:page, 1)),
|
|
||||||
type: :ordered,
|
|
||||||
size: @account.followers_count,
|
|
||||||
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) },
|
|
||||||
part_of: account_followers_url(@account),
|
|
||||||
next: page_url(@follows.next_page),
|
|
||||||
prev: page_url(@follows.prev_page)
|
|
||||||
)
|
|
||||||
if params[:page].present?
|
|
||||||
page
|
|
||||||
else
|
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_followers_url(@account),
|
id: account_followers_url(@account),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.followers_count,
|
size: @account.followers_count,
|
||||||
first: page
|
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|||||||
@@ -10,39 +10,19 @@ class FollowingAccountsController < ApplicationController
|
|||||||
format.html
|
format.html
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: collection_presenter,
|
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
serializer: ActivityPub::CollectionSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def page_url(page)
|
|
||||||
account_following_index_url(@account, page: page) unless page.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
page = ActivityPub::CollectionPresenter.new(
|
|
||||||
id: account_following_index_url(@account, page: params.fetch(:page, 1)),
|
|
||||||
type: :ordered,
|
|
||||||
size: @account.following_count,
|
|
||||||
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) },
|
|
||||||
part_of: account_following_index_url(@account),
|
|
||||||
next: page_url(@follows.next_page),
|
|
||||||
prev: page_url(@follows.prev_page)
|
|
||||||
)
|
|
||||||
if params[:page].present?
|
|
||||||
page
|
|
||||||
else
|
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_following_index_url(@account),
|
id: account_following_index_url(@account),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.following_count,
|
size: @account.following_count,
|
||||||
first: page
|
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|||||||
@@ -6,36 +6,12 @@ class HomeController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@body_classes = 'app-body'
|
@body_classes = 'app-body'
|
||||||
@frontend = (params[:frontend] and Rails.configuration.x.available_frontends.include? params[:frontend] + '.js') ? params[:frontend] : 'mastodon'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def authenticate_user!
|
def authenticate_user!
|
||||||
return if user_signed_in?
|
redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in?
|
||||||
|
|
||||||
matches = request.path.match(/\A\/web\/(statuses|accounts)\/([\d]+)\z/)
|
|
||||||
|
|
||||||
if matches
|
|
||||||
case matches[1]
|
|
||||||
when 'statuses'
|
|
||||||
status = Status.find_by(id: matches[2])
|
|
||||||
|
|
||||||
if status && (status.public_visibility? || status.unlisted_visibility?)
|
|
||||||
redirect_to(ActivityPub::TagManager.instance.url_for(status))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
when 'accounts'
|
|
||||||
account = Account.find_by(id: matches[2])
|
|
||||||
|
|
||||||
if account
|
|
||||||
redirect_to(ActivityPub::TagManager.instance.url_for(account))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to(default_redirect_path)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_initial_state_json
|
def set_initial_state_json
|
||||||
@@ -52,14 +28,4 @@ class HomeController < ApplicationController
|
|||||||
admin: Account.find_local(Setting.site_contact_username),
|
admin: Account.find_local(Setting.site_contact_username),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_redirect_path
|
|
||||||
if request.path.start_with?('/web')
|
|
||||||
new_user_session_path
|
|
||||||
elsif single_user_mode?
|
|
||||||
short_account_path(Account.first)
|
|
||||||
else
|
|
||||||
about_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ManifestsController < ApplicationController
|
class ManifestsController < ApplicationController
|
||||||
def show
|
before_action :set_instance_presenter
|
||||||
render json: InstancePresenter.new, serializer: ManifestSerializer
|
|
||||||
|
def show; end
|
||||||
|
|
||||||
|
def set_instance_presenter
|
||||||
|
@instance_presenter = InstancePresenter.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class MediaProxyController < ApplicationController
|
|
||||||
include RoutingHelper
|
|
||||||
|
|
||||||
def show
|
|
||||||
RedisLock.acquire(lock_options) do |lock|
|
|
||||||
if lock.acquired?
|
|
||||||
@media_attachment = MediaAttachment.remote.find(params[:id])
|
|
||||||
redownload! if @media_attachment.needs_redownload? && !reject_media?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to full_asset_url(@media_attachment.file.url(version))
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def redownload!
|
|
||||||
@media_attachment.file_remote_url = @media_attachment.remote_url
|
|
||||||
@media_attachment.created_at = Time.now.utc
|
|
||||||
@media_attachment.save!
|
|
||||||
end
|
|
||||||
|
|
||||||
def version
|
|
||||||
if request.path.ends_with?('/small')
|
|
||||||
:small
|
|
||||||
else
|
|
||||||
:original
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def lock_options
|
|
||||||
{ redis: Redis.current, key: "media_download:#{params[:id]}" }
|
|
||||||
end
|
|
||||||
|
|
||||||
def reject_media?
|
|
||||||
DomainBlock.find_by(domain: @media_attachment.account.domain)&.reject_media?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -9,7 +9,7 @@ class Settings::FollowerDomainsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@account = current_account
|
@account = current_account
|
||||||
@domains = current_account.followers.reorder('MIN(follows.id) DESC').group('accounts.domain').select('accounts.domain, count(accounts.id) as accounts_from_domain').page(params[:page]).per(10)
|
@domains = current_account.followers.reorder(nil).group('accounts.domain').select('accounts.domain, count(accounts.id) as accounts_from_domain').page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Settings::NotificationsController < ApplicationController
|
|
||||||
layout 'admin'
|
|
||||||
|
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def show; end
|
|
||||||
|
|
||||||
def update
|
|
||||||
user_settings.update(user_settings_params.to_h)
|
|
||||||
|
|
||||||
if current_user.save
|
|
||||||
redirect_to settings_notifications_path, notice: I18n.t('generic.changes_saved_msg')
|
|
||||||
else
|
|
||||||
render :show
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def user_settings
|
|
||||||
UserSettingsDecorator.new(current_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_settings_params
|
|
||||||
params.require(:user).permit(
|
|
||||||
notification_emails: %i(follow follow_request reblog favourite mention digest),
|
|
||||||
interactions: %i(must_be_follower must_be_following)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -39,10 +39,8 @@ class Settings::PreferencesController < ApplicationController
|
|||||||
:setting_boost_modal,
|
:setting_boost_modal,
|
||||||
:setting_delete_modal,
|
:setting_delete_modal,
|
||||||
:setting_auto_play_gif,
|
:setting_auto_play_gif,
|
||||||
:setting_reduce_motion,
|
|
||||||
:setting_system_font_ui,
|
:setting_system_font_ui,
|
||||||
:setting_noindex,
|
:setting_noindex,
|
||||||
:setting_theme,
|
|
||||||
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)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,19 +21,13 @@ class StatusesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: @status,
|
render json: @status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
serializer: ActivityPub::NoteSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def activity
|
def activity
|
||||||
render json: @status,
|
render json: @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
serializer: ActivityPub::ActivitySerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def embed
|
def embed
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class StreamEntriesController < ApplicationController
|
|||||||
@type = @stream_entry.activity_type.downcase
|
@type = @stream_entry.activity_type.downcase
|
||||||
|
|
||||||
raise ActiveRecord::RecordNotFound if @stream_entry.activity.nil?
|
raise ActiveRecord::RecordNotFound if @stream_entry.activity.nil?
|
||||||
authorize @stream_entry.activity, :show? if @stream_entry.hidden? || @stream_entry.local_only?
|
authorize @stream_entry.activity, :show? if @stream_entry.hidden?
|
||||||
rescue Mastodon::NotPermittedError
|
rescue Mastodon::NotPermittedError
|
||||||
# Reraise in order to get a 404
|
# Reraise in order to get a 404
|
||||||
raise ActiveRecord::RecordNotFound
|
raise ActiveRecord::RecordNotFound
|
||||||
|
|||||||
@@ -1,40 +1,24 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
before_action :set_body_classes
|
layout 'public'
|
||||||
before_action :set_instance_presenter
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@tag = Tag.find_by!(name: params[:id].downcase)
|
@tag = Tag.find_by!(name: params[:id].downcase)
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html do
|
|
||||||
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
|
|
||||||
@initial_state_json = serializable_resource.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
format.json do
|
|
||||||
@statuses = Status.as_tag_timeline(@tag, current_account, params[:local]).paginate_by_max_id(20, params[:max_id])
|
@statuses = Status.as_tag_timeline(@tag, current_account, params[:local]).paginate_by_max_id(20, params[:max_id])
|
||||||
@statuses = cache_collection(@statuses, Status)
|
@statuses = cache_collection(@statuses, Status)
|
||||||
|
|
||||||
render json: collection_presenter,
|
respond_to do |format|
|
||||||
serializer: ActivityPub::CollectionSerializer,
|
format.html
|
||||||
adapter: ActivityPub::Adapter,
|
|
||||||
content_type: 'application/activity+json'
|
format.json do
|
||||||
|
render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_body_classes
|
|
||||||
@body_classes = 'tag-body'
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_instance_presenter
|
|
||||||
@instance_presenter = InstancePresenter.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: tag_url(@tag),
|
id: tag_url(@tag),
|
||||||
@@ -43,11 +27,4 @@ class TagsController < ApplicationController
|
|||||||
items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
|
items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initial_state_params
|
|
||||||
{
|
|
||||||
settings: {},
|
|
||||||
token: current_session&.token,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Admin::AccountModerationNotesHelper
|
|
||||||
end
|
|
||||||
@@ -42,8 +42,4 @@ module ApplicationHelper
|
|||||||
|
|
||||||
content_tag(:i, nil, attributes.merge(class: class_names.join(' ')))
|
content_tag(:i, nil, attributes.merge(class: class_names.join(' ')))
|
||||||
end
|
end
|
||||||
|
|
||||||
def opengraph(property, content)
|
|
||||||
tag(:meta, content: content, property: property)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
24
app/helpers/emoji_helper.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module EmojiHelper
|
||||||
|
def emojify(text)
|
||||||
|
return text if text.blank?
|
||||||
|
|
||||||
|
text.gsub(emoji_pattern) do |match|
|
||||||
|
emoji = Emoji.instance.unicode($1) # rubocop:disable Style/PerlBackrefs
|
||||||
|
|
||||||
|
if emoji
|
||||||
|
emoji
|
||||||
|
else
|
||||||
|
match
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def emoji_pattern
|
||||||
|
@emoji_pattern ||=
|
||||||
|
/(?<=[^[:alnum:]:]|\n|^)
|
||||||
|
(#{Emoji.instance.names.map { |name| Regexp.escape(name) }.join('|')})
|
||||||
|
(?=[^[:alnum:]:]|$)/x
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -22,18 +22,7 @@ module JsonLdHelper
|
|||||||
graph.dump(:normalize)
|
graph.dump(:normalize)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_resource(uri, id)
|
def fetch_resource(uri)
|
||||||
unless id
|
|
||||||
json = fetch_resource_without_id_validation(uri)
|
|
||||||
return unless json
|
|
||||||
uri = json['id']
|
|
||||||
end
|
|
||||||
|
|
||||||
json = fetch_resource_without_id_validation(uri)
|
|
||||||
json.present? && json['id'] == uri ? json : nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch_resource_without_id_validation(uri)
|
|
||||||
response = build_request(uri).perform
|
response = build_request(uri).perform
|
||||||
return if response.code != 200
|
return if response.code != 200
|
||||||
body_to_json(response.to_s)
|
body_to_json(response.to_s)
|
||||||
|
|||||||
@@ -12,14 +12,8 @@ module RoutingHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def full_asset_url(source, options = {})
|
def full_asset_url(source, options = {})
|
||||||
source = ActionController::Base.helpers.asset_url(source, options) unless use_storage?
|
source = ActionController::Base.helpers.asset_url(source, options) unless Rails.configuration.x.use_s3
|
||||||
|
|
||||||
URI.join(root_url, source).to_s
|
URI.join(root_url, source).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def use_storage?
|
|
||||||
Rails.configuration.x.use_s3 || Rails.configuration.x.use_swift
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,11 +27,9 @@ module SettingsHelper
|
|||||||
pt: 'Português',
|
pt: 'Português',
|
||||||
'pt-BR': 'Português do Brasil',
|
'pt-BR': 'Português do Brasil',
|
||||||
ru: 'Русский',
|
ru: 'Русский',
|
||||||
sv: 'Svenska',
|
|
||||||
th: 'ภาษาไทย',
|
th: 'ภาษาไทย',
|
||||||
tr: 'Türkçe',
|
tr: 'Türkçe',
|
||||||
uk: 'Українська',
|
uk: 'Українська',
|
||||||
zh: '中文',
|
|
||||||
'zh-CN': '简体中文',
|
'zh-CN': '简体中文',
|
||||||
'zh-HK': '繁體中文(香港)',
|
'zh-HK': '繁體中文(香港)',
|
||||||
'zh-TW': '繁體中文(臺灣)',
|
'zh-TW': '繁體中文(臺灣)',
|
||||||
@@ -41,10 +39,6 @@ module SettingsHelper
|
|||||||
HUMAN_LOCALES[locale]
|
HUMAN_LOCALES[locale]
|
||||||
end
|
end
|
||||||
|
|
||||||
def filterable_languages
|
|
||||||
LanguageDetector.instance.language_names.select(&HUMAN_LOCALES.method(:key?))
|
|
||||||
end
|
|
||||||
|
|
||||||
def hash_to_object(hash)
|
def hash_to_object(hash)
|
||||||
HashObject.new(hash)
|
HashObject.new(hash)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`actions/local_settings`
|
|
||||||
========================
|
|
||||||
|
|
||||||
> For more information on the contents of this file, please contact:
|
|
||||||
>
|
|
||||||
> - kibigo! [@kibi@glitch.social]
|
|
||||||
|
|
||||||
This file provides our Redux actions related to local settings. It
|
|
||||||
consists of the following:
|
|
||||||
|
|
||||||
- __`changesLocalSetting(key, value)` :__
|
|
||||||
Changes the local setting with the given `key` to the given
|
|
||||||
`value`. `key` **MUST** be an array of strings, as required by
|
|
||||||
`Immutable.Map.prototype.getIn()`.
|
|
||||||
|
|
||||||
- __`saveLocalSettings()` :__
|
|
||||||
Saves the local settings to `localStorage` as a JSON object. We
|
|
||||||
shouldn't ever need to call this ourselves.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Constants:
|
|
||||||
----------
|
|
||||||
|
|
||||||
We provide the following constants:
|
|
||||||
|
|
||||||
- __`LOCAL_SETTING_CHANGE` :__
|
|
||||||
This string constant is used to dispatch a setting change to our
|
|
||||||
reducer in `reducers/local_settings`, where the setting is
|
|
||||||
actually changed.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const LOCAL_SETTING_CHANGE = 'LOCAL_SETTING_CHANGE';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
`changeLocalSetting(key, value)`:
|
|
||||||
---------------------------------
|
|
||||||
|
|
||||||
Changes the local setting with the given `key` to the given `value`.
|
|
||||||
`key` **MUST** be an array of strings, as required by
|
|
||||||
`Immutable.Map.prototype.getIn()`.
|
|
||||||
|
|
||||||
To accomplish this, we just dispatch a `LOCAL_SETTING_CHANGE` to our
|
|
||||||
reducer in `reducers/local_settings`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
export function changeLocalSetting(key, value) {
|
|
||||||
return dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: LOCAL_SETTING_CHANGE,
|
|
||||||
key,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
|
|
||||||
dispatch(saveLocalSettings());
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
`saveLocalSettings()`:
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
Saves the local settings to `localStorage` as a JSON object.
|
|
||||||
`changeLocalSetting()` calls this whenever it changes a setting. We
|
|
||||||
shouldn't ever need to call this ourselves.
|
|
||||||
|
|
||||||
> __TODO :__
|
|
||||||
> Right now `saveLocalSettings()` doesn't keep track of which user
|
|
||||||
> is currently signed in, but it might be better to give each user
|
|
||||||
> their *own* local settings.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
export function saveLocalSettings() {
|
|
||||||
return (_, getState) => {
|
|
||||||
const localSettings = getState().get('local_settings').toJS();
|
|
||||||
localStorage.setItem('mastodon-settings', JSON.stringify(localSettings));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<AccountHeader>`
|
|
||||||
=================
|
|
||||||
|
|
||||||
> For more information on the contents of this file, please contact:
|
|
||||||
>
|
|
||||||
> - kibigo! [@kibi@glitch.social]
|
|
||||||
|
|
||||||
Original file by @gargron@mastodon.social et al as part of
|
|
||||||
tootsuite/mastodon. We've expanded it in order to handle user bio
|
|
||||||
frontmatter.
|
|
||||||
|
|
||||||
The `<AccountHeader>` component provides the header for account
|
|
||||||
timelines. It is a fairly simple component which mostly just consists
|
|
||||||
of a `render()` method.
|
|
||||||
|
|
||||||
__Props:__
|
|
||||||
|
|
||||||
- __`account` (`ImmutablePropTypes.map`) :__
|
|
||||||
The account to render a header for.
|
|
||||||
|
|
||||||
- __`me` (`PropTypes.number.isRequired`) :__
|
|
||||||
The id of the currently-signed-in account.
|
|
||||||
|
|
||||||
- __`onFollow` (`PropTypes.func.isRequired`) :__
|
|
||||||
The function to call when the user clicks the "follow" button.
|
|
||||||
|
|
||||||
- __`intl` (`PropTypes.object.isRequired`) :__
|
|
||||||
Our internationalization object, inserted by `@injectIntl`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
import emojify from '../../../mastodon/features/emoji/emoji';
|
|
||||||
import IconButton from '../../../mastodon/components/icon_button';
|
|
||||||
import Avatar from '../../../mastodon/components/avatar';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import { processBio } from '../../util/bio_metadata';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Inital setup:
|
|
||||||
-------------
|
|
||||||
|
|
||||||
The `messages` constant is used to define any messages that we need
|
|
||||||
from inside props. In our case, these are the `unfollow`, `follow`, and
|
|
||||||
`requested` messages used in the `title` of our buttons.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
|
||||||
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
|
||||||
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' },
|
|
||||||
});
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Implementation:
|
|
||||||
---------------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class AccountHeader extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
account : ImmutablePropTypes.map,
|
|
||||||
me : PropTypes.string.isRequired,
|
|
||||||
onFollow : PropTypes.func.isRequired,
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
### `render()`
|
|
||||||
|
|
||||||
The `render()` function is used to render our component.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { account, me, intl } = this.props;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
If no `account` is provided, then we can't render a header. Otherwise,
|
|
||||||
we get the `displayName` for the account, if available. If it's blank,
|
|
||||||
then we set the `displayName` to just be the `username` of the account.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!account) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let displayName = account.get('display_name_html');
|
|
||||||
let info = '';
|
|
||||||
let actionBtn = '';
|
|
||||||
let following = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Next, we handle the account relationships. If the account follows the
|
|
||||||
user, then we add an `info` message. If the user has requested a
|
|
||||||
follow, then we disable the `actionBtn` and display an hourglass.
|
|
||||||
Otherwise, if the account isn't blocked, we set the `actionBtn` to the
|
|
||||||
appropriate icon.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (me !== account.get('id')) {
|
|
||||||
if (account.getIn(['relationship', 'followed_by'])) {
|
|
||||||
info = (
|
|
||||||
<span className='account--follows-info'>
|
|
||||||
<FormattedMessage id='account.follows_you' defaultMessage='Follows you' />
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (account.getIn(['relationship', 'requested'])) {
|
|
||||||
actionBtn = (
|
|
||||||
<div className='account--action-button'>
|
|
||||||
<IconButton size={26} disabled icon='hourglass' title={intl.formatMessage(messages.requested)} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else if (!account.getIn(['relationship', 'blocking'])) {
|
|
||||||
following = account.getIn(['relationship', 'following']);
|
|
||||||
actionBtn = (
|
|
||||||
<div className='account--action-button'>
|
|
||||||
<IconButton
|
|
||||||
size={26}
|
|
||||||
icon={following ? 'user-times' : 'user-plus'}
|
|
||||||
active={following}
|
|
||||||
title={intl.formatMessage(following ? messages.unfollow : messages.follow)}
|
|
||||||
onClick={this.props.onFollow}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
we extract the `text` and
|
|
||||||
`metadata` from our account's `note` using `processBio()`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const { text, metadata } = processBio(account.get('note'));
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Here, we render our component using all the things we've defined above.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='account__header__wrapper'>
|
|
||||||
<div
|
|
||||||
className='account__header'
|
|
||||||
style={{ backgroundImage: `url(${account.get('header')})` }}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<a href={account.get('url')} target='_blank' rel='noopener'>
|
|
||||||
<span className='account__header__avatar'>
|
|
||||||
<Avatar account={account} size={90} />
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
className='account__header__display-name'
|
|
||||||
dangerouslySetInnerHTML={{ __html: displayName }}
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
<span className='account__header__username'>
|
|
||||||
@{account.get('acct')}
|
|
||||||
{account.get('locked') ? <i className='fa fa-lock' /> : null}
|
|
||||||
</span>
|
|
||||||
<div className='account__header__content' dangerouslySetInnerHTML={{ __html: emojify(text) }} />
|
|
||||||
|
|
||||||
{info}
|
|
||||||
{actionBtn}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{metadata.length && (
|
|
||||||
<table className='account__metadata'>
|
|
||||||
<tbody>
|
|
||||||
{(() => {
|
|
||||||
let data = [];
|
|
||||||
for (let i = 0; i < metadata.length; i++) {
|
|
||||||
data.push(
|
|
||||||
<tr key={i}>
|
|
||||||
<th scope='row'><div dangerouslySetInnerHTML={{ __html: emojify(metadata[i][0]) }} /></th>
|
|
||||||
<td><div dangerouslySetInnerHTML={{ __html: emojify(metadata[i][1]) }} /></td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
})()}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
) || null}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<NotificationPurgeButtonsContainer>`
|
|
||||||
=========================
|
|
||||||
|
|
||||||
This container connects `<NotificationPurgeButtons>`s to the Redux store.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import NotificationPurgeButtons from './notification_purge_buttons';
|
|
||||||
import {
|
|
||||||
deleteMarkedNotifications,
|
|
||||||
enterNotificationClearingMode,
|
|
||||||
markAllNotifications,
|
|
||||||
} from '../../../../mastodon/actions/notifications';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import { openModal } from '../../../../mastodon/actions/modal';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Dispatch mapping:
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
The `mapDispatchToProps()` function maps dispatches to our store to the
|
|
||||||
various props of our component. We only need to provide a dispatch for
|
|
||||||
deleting notifications.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
clearMessage: { id: 'notifications.marked_clear_confirmation', defaultMessage: 'Are you sure you want to permanently clear all selected notifications?' },
|
|
||||||
clearConfirm: { id: 'notifications.marked_clear', defaultMessage: 'Clear selected notifications' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
|
||||||
onEnterCleaningMode(yes) {
|
|
||||||
dispatch(enterNotificationClearingMode(yes));
|
|
||||||
},
|
|
||||||
|
|
||||||
onDeleteMarked() {
|
|
||||||
dispatch(openModal('CONFIRM', {
|
|
||||||
message: intl.formatMessage(messages.clearMessage),
|
|
||||||
confirm: intl.formatMessage(messages.clearConfirm),
|
|
||||||
onConfirm: () => dispatch(deleteMarkedNotifications()),
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
onMarkAll() {
|
|
||||||
dispatch(markAllNotifications(true));
|
|
||||||
},
|
|
||||||
|
|
||||||
onMarkNone() {
|
|
||||||
dispatch(markAllNotifications(false));
|
|
||||||
},
|
|
||||||
|
|
||||||
onInvert() {
|
|
||||||
dispatch(markAllNotifications(null));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
markNewForDelete: state.getIn(['notifications', 'markNewForDelete']),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationPurgeButtons));
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
/**
|
|
||||||
* Buttons widget for controlling the notification clearing mode.
|
|
||||||
* In idle state, the cleaning mode button is shown. When the mode is active,
|
|
||||||
* a Confirm and Abort buttons are shown in its place.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
btnAll : { id: 'notification_purge.btn_all', defaultMessage: 'Select\nall' },
|
|
||||||
btnNone : { id: 'notification_purge.btn_none', defaultMessage: 'Select\nnone' },
|
|
||||||
btnInvert : { id: 'notification_purge.btn_invert', defaultMessage: 'Invert\nselection' },
|
|
||||||
btnApply : { id: 'notification_purge.btn_apply', defaultMessage: 'Clear\nselected' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class NotificationPurgeButtons extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
onDeleteMarked : PropTypes.func.isRequired,
|
|
||||||
onMarkAll : PropTypes.func.isRequired,
|
|
||||||
onMarkNone : PropTypes.func.isRequired,
|
|
||||||
onInvert : PropTypes.func.isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
markNewForDelete: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, markNewForDelete } = this.props;
|
|
||||||
|
|
||||||
//className='active'
|
|
||||||
return (
|
|
||||||
<div className='column-header__notif-cleaning-buttons'>
|
|
||||||
<button onClick={this.props.onMarkAll} className={markNewForDelete ? 'active' : ''}>
|
|
||||||
<b>∀</b><br />{intl.formatMessage(messages.btnAll)}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button onClick={this.props.onMarkNone} className={!markNewForDelete ? 'active' : ''}>
|
|
||||||
<b>∅</b><br />{intl.formatMessage(messages.btnNone)}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button onClick={this.props.onInvert}>
|
|
||||||
<b>¬</b><br />{intl.formatMessage(messages.btnInvert)}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button onClick={this.props.onDeleteMarked}>
|
|
||||||
<i className='fa fa-trash' /><br />{intl.formatMessage(messages.btnApply)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<ComposeAdvancedOptionsContainer>`
|
|
||||||
===================================
|
|
||||||
|
|
||||||
This container connects `<ComposeAdvancedOptions>` to the Redux store.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
import { toggleComposeAdvancedOption } from '../../../../mastodon/actions/compose';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import ComposeAdvancedOptions from '.';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
State mapping:
|
|
||||||
--------------
|
|
||||||
|
|
||||||
The `mapStateToProps()` function maps various state properties to the
|
|
||||||
props of our component. The only property we care about is
|
|
||||||
`compose.advanced_options`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
values: state.getIn(['compose', 'advanced_options']),
|
|
||||||
});
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Dispatch mapping:
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
The `mapDispatchToProps()` function maps dispatches to our store to the
|
|
||||||
various props of our component. We just need to provide a dispatch for
|
|
||||||
when an advanced option toggle changes.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onChange (option) {
|
|
||||||
dispatch(toggleComposeAdvancedOption(option));
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(ComposeAdvancedOptions);
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<ComposeAdvancedOptions>`
|
|
||||||
==========================
|
|
||||||
|
|
||||||
> For more information on the contents of this file, please contact:
|
|
||||||
>
|
|
||||||
> - surinna [@srn@dev.glitch.social]
|
|
||||||
|
|
||||||
This adds an advanced options dropdown to the toot compose box, for
|
|
||||||
toggles that don't necessarily fit elsewhere.
|
|
||||||
|
|
||||||
__Props:__
|
|
||||||
|
|
||||||
- __`values` (`ImmutablePropTypes.contains(…).isRequired`) :__
|
|
||||||
An Immutable map with the following values:
|
|
||||||
|
|
||||||
- __`do_not_federate` (`PropTypes.bool.isRequired`) :__
|
|
||||||
Specifies whether or not to federate the status.
|
|
||||||
|
|
||||||
- __`onChange` (`PropTypes.func.isRequired`) :__
|
|
||||||
The function to call when a toggle is changed. We pass this from
|
|
||||||
our container to the toggle.
|
|
||||||
|
|
||||||
- __`intl` (`PropTypes.object.isRequired`) :__
|
|
||||||
Our internationalization object, inserted by `@injectIntl`.
|
|
||||||
|
|
||||||
__State:__
|
|
||||||
|
|
||||||
- __`open` :__
|
|
||||||
This tells whether the dropdown is currently open or closed.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import ComposeAdvancedOptionsToggle from './toggle';
|
|
||||||
import ComposeDropdown from '../dropdown/index';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Inital setup:
|
|
||||||
-------------
|
|
||||||
|
|
||||||
The `messages` constant is used to define any messages that we need
|
|
||||||
from inside props. These are the various titles and labels on our
|
|
||||||
toggles.
|
|
||||||
|
|
||||||
`iconStyle` styles the icon used for the dropdown button.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
local_only_short :
|
|
||||||
{ id: 'advanced-options.local-only.short', defaultMessage: 'Local-only' },
|
|
||||||
local_only_long :
|
|
||||||
{ id: 'advanced-options.local-only.long', defaultMessage: 'Do not post to other instances' },
|
|
||||||
advanced_options_icon_title :
|
|
||||||
{ id: 'advanced_options.icon_title', defaultMessage: 'Advanced options' },
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Implementation:
|
|
||||||
---------------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class ComposeAdvancedOptions extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
values : ImmutablePropTypes.contains({
|
|
||||||
do_not_federate : PropTypes.bool.isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
onChange : PropTypes.func.isRequired,
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
### `render()`
|
|
||||||
|
|
||||||
`render()` actually puts our component on the screen.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, values } = this.props;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
The `options` array provides all of the available advanced options
|
|
||||||
alongside their icon, text, and name.
|
|
||||||
|
|
||||||
*/
|
|
||||||
const options = [
|
|
||||||
{ icon: 'wifi', shortText: messages.local_only_short, longText: messages.local_only_long, name: 'do_not_federate' },
|
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
`anyEnabled` tells us if any of our advanced options have been enabled.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const anyEnabled = values.some((enabled) => enabled);
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
`optionElems` takes our `options` and creates
|
|
||||||
`<ComposeAdvancedOptionsToggle>`s out of them. We use the `name` of the
|
|
||||||
toggle as its `key` so that React can keep track of it.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const optionElems = options.map((option) => {
|
|
||||||
return (
|
|
||||||
<ComposeAdvancedOptionsToggle
|
|
||||||
onChange={this.props.onChange}
|
|
||||||
active={values.get(option.name)}
|
|
||||||
key={option.name}
|
|
||||||
name={option.name}
|
|
||||||
shortText={intl.formatMessage(option.shortText)}
|
|
||||||
longText={intl.formatMessage(option.longText)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Finally, we can render our component.
|
|
||||||
|
|
||||||
*/
|
|
||||||
return (
|
|
||||||
<ComposeDropdown
|
|
||||||
title={intl.formatMessage(messages.advanced_options_icon_title)}
|
|
||||||
icon='home'
|
|
||||||
highlight={anyEnabled}
|
|
||||||
>
|
|
||||||
{optionElems}
|
|
||||||
</ComposeDropdown>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<ComposeAdvancedOptionsToggle>`
|
|
||||||
================================
|
|
||||||
|
|
||||||
> For more information on the contents of this file, please contact:
|
|
||||||
>
|
|
||||||
> - surinna [@srn@dev.glitch.social]
|
|
||||||
|
|
||||||
This creates the toggle used by `<ComposeAdvancedOptions>`.
|
|
||||||
|
|
||||||
__Props:__
|
|
||||||
|
|
||||||
- __`onChange` (`PropTypes.func`) :__
|
|
||||||
This provides the function to call when the toggle is
|
|
||||||
(de-?)activated.
|
|
||||||
|
|
||||||
- __`active` (`PropTypes.bool`) :__
|
|
||||||
This prop controls whether the toggle is currently active or not.
|
|
||||||
|
|
||||||
- __`name` (`PropTypes.string`) :__
|
|
||||||
This identifies the toggle, and is sent to `onChange()` when it is
|
|
||||||
called.
|
|
||||||
|
|
||||||
- __`shortText` (`PropTypes.string`) :__
|
|
||||||
This is a short string used as the title of the toggle.
|
|
||||||
|
|
||||||
- __`longText` (`PropTypes.string`) :__
|
|
||||||
This is a longer string used as a subtitle for the toggle.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Toggle from 'react-toggle';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Implementation:
|
|
||||||
---------------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default class ComposeAdvancedOptionsToggle extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
active: PropTypes.bool.isRequired,
|
|
||||||
name: PropTypes.string.isRequired,
|
|
||||||
shortText: PropTypes.string.isRequired,
|
|
||||||
longText: PropTypes.string.isRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
### `onToggle()`
|
|
||||||
|
|
||||||
The `onToggle()` function simply calls the `onChange()` prop with the
|
|
||||||
toggle's `name`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
onToggle = () => {
|
|
||||||
this.props.onChange(this.props.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
### `render()`
|
|
||||||
|
|
||||||
The `render()` function is used to render our component. We just render
|
|
||||||
a `<Toggle>` and place next to it our text.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { active, shortText, longText } = this.props;
|
|
||||||
return (
|
|
||||||
<div role='button' tabIndex='0' className='advanced-options-dropdown__option' onClick={this.onToggle}>
|
|
||||||
<div className='advanced-options-dropdown__option__toggle'>
|
|
||||||
<Toggle checked={active} onChange={this.onToggle} />
|
|
||||||
</div>
|
|
||||||
<div className='advanced-options-dropdown__option__content'>
|
|
||||||
<strong>{shortText}</strong>
|
|
||||||
{longText}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import ComposeDropdown from '../dropdown/index';
|
|
||||||
import { uploadCompose } from '../../../../mastodon/actions/compose';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import { openModal } from '../../../../mastodon/actions/modal';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
upload :
|
|
||||||
{ id: 'compose.attach.upload', defaultMessage: 'Upload a file' },
|
|
||||||
doodle :
|
|
||||||
{ id: 'compose.attach.doodle', defaultMessage: 'Draw something' },
|
|
||||||
attach :
|
|
||||||
{ id: 'compose.attach', defaultMessage: 'Attach...' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
// This horrible expression is copied from vanilla upload_button_container
|
|
||||||
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 3 || state.getIn(['compose', 'media_attachments']).some(m => m.get('type') === 'video')),
|
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
|
||||||
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
onSelectFile (files) {
|
|
||||||
dispatch(uploadCompose(files));
|
|
||||||
},
|
|
||||||
onOpenDoodle () {
|
|
||||||
dispatch(openModal('DOODLE', { noEsc: true }));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
@connect(mapStateToProps, mapDispatchToProps)
|
|
||||||
export default class ComposeAttachOptions extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
resetFileKey: PropTypes.number,
|
|
||||||
acceptContentTypes: ImmutablePropTypes.listOf(PropTypes.string).isRequired,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
onSelectFile: PropTypes.func.isRequired,
|
|
||||||
onOpenDoodle: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleItemClick = bt => {
|
|
||||||
if (bt === 'upload') {
|
|
||||||
this.fileElement.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bt === 'doodle') {
|
|
||||||
this.props.onOpenDoodle();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dropdown.setState({ open: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
handleFileChange = (e) => {
|
|
||||||
if (e.target.files.length > 0) {
|
|
||||||
this.props.onSelectFile(e.target.files);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setFileRef = (c) => {
|
|
||||||
this.fileElement = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
setDropdownRef = (c) => {
|
|
||||||
this.dropdown = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, resetFileKey, disabled, acceptContentTypes } = this.props;
|
|
||||||
|
|
||||||
const options = [
|
|
||||||
{ icon: 'cloud-upload', text: messages.upload, name: 'upload' },
|
|
||||||
{ icon: 'paint-brush', text: messages.doodle, name: 'doodle' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const optionElems = options.map((item) => {
|
|
||||||
const hdl = () => this.handleItemClick(item.name);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role='button'
|
|
||||||
tabIndex='0'
|
|
||||||
key={item.name}
|
|
||||||
onClick={hdl}
|
|
||||||
className='privacy-dropdown__option'
|
|
||||||
>
|
|
||||||
<div className='privacy-dropdown__option__icon'>
|
|
||||||
<i className={`fa fa-fw fa-${item.icon}`} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='privacy-dropdown__option__content'>
|
|
||||||
<strong>{intl.formatMessage(item.text)}</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<ComposeDropdown
|
|
||||||
title={intl.formatMessage(messages.attach)}
|
|
||||||
icon='paperclip'
|
|
||||||
disabled={disabled}
|
|
||||||
ref={this.setDropdownRef}
|
|
||||||
>
|
|
||||||
{optionElems}
|
|
||||||
</ComposeDropdown>
|
|
||||||
<input
|
|
||||||
key={resetFileKey}
|
|
||||||
ref={this.setFileRef}
|
|
||||||
type='file'
|
|
||||||
multiple={false}
|
|
||||||
accept={acceptContentTypes.toArray().join(',')}
|
|
||||||
onChange={this.handleFileChange}
|
|
||||||
disabled={disabled}
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
import IconButton from '../../../../mastodon/components/icon_button';
|
|
||||||
|
|
||||||
const iconStyle = {
|
|
||||||
height : null,
|
|
||||||
lineHeight : '27px',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class ComposeDropdown extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
icon: PropTypes.string,
|
|
||||||
highlight: PropTypes.bool,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
children: PropTypes.arrayOf(PropTypes.node).isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
open: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
onToggleDropdown = () => {
|
|
||||||
if (this.props.disabled) return;
|
|
||||||
this.setState({ open: !this.state.open });
|
|
||||||
};
|
|
||||||
|
|
||||||
setRef = (c) => {
|
|
||||||
this.node = c;
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { open } = this.state;
|
|
||||||
let { highlight, title, icon, disabled } = this.props;
|
|
||||||
|
|
||||||
if (!icon) icon = 'ellipsis-h';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref={this.setRef} className={`advanced-options-dropdown ${open ? 'open' : ''} ${highlight ? 'active' : ''} `}>
|
|
||||||
<div className='advanced-options-dropdown__value'>
|
|
||||||
<IconButton
|
|
||||||
className={'inverted'}
|
|
||||||
title={title}
|
|
||||||
icon={icon} active={open || highlight}
|
|
||||||
size={18}
|
|
||||||
style={iconStyle}
|
|
||||||
disabled={disabled}
|
|
||||||
onClick={this.onToggleDropdown}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className='advanced-options-dropdown__dropdown'>
|
|
||||||
{this.props.children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
import { closeModal } from '../../../mastodon/actions/modal';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import { changeLocalSetting } from '../../../glitch/actions/local_settings';
|
|
||||||
import LocalSettings from '.';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
settings: state.get('local_settings'),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
onChange (setting, value) {
|
|
||||||
dispatch(changeLocalSetting(setting, value));
|
|
||||||
},
|
|
||||||
onClose () {
|
|
||||||
dispatch(closeModal());
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(LocalSettings);
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
// Package imports
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
|
|
||||||
// Our imports
|
|
||||||
import LocalSettingsPage from './page';
|
|
||||||
import LocalSettingsNavigation from './navigation';
|
|
||||||
|
|
||||||
// Stylesheet imports
|
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
export default class LocalSettings extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
onClose: PropTypes.func.isRequired,
|
|
||||||
settings: ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
currentIndex: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
navigateTo = (index) =>
|
|
||||||
this.setState({ currentIndex: +index });
|
|
||||||
|
|
||||||
render () {
|
|
||||||
|
|
||||||
const { navigateTo } = this;
|
|
||||||
const { onChange, onClose, settings } = this.props;
|
|
||||||
const { currentIndex } = this.state;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='glitch modal-root__modal local-settings'>
|
|
||||||
<LocalSettingsNavigation
|
|
||||||
index={currentIndex}
|
|
||||||
onClose={onClose}
|
|
||||||
onNavigate={navigateTo}
|
|
||||||
/>
|
|
||||||
<LocalSettingsPage
|
|
||||||
index={currentIndex}
|
|
||||||
onChange={onChange}
|
|
||||||
settings={settings}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
// Package imports
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
// Our imports
|
|
||||||
import LocalSettingsNavigationItem from './item';
|
|
||||||
|
|
||||||
// Stylesheet imports
|
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
general: { id: 'settings.general', defaultMessage: 'General' },
|
|
||||||
collapsed: { id: 'settings.collapsed_statuses', defaultMessage: 'Collapsed toots' },
|
|
||||||
media: { id: 'settings.media', defaultMessage: 'Media' },
|
|
||||||
preferences: { id: 'settings.preferences', defaultMessage: 'Preferences' },
|
|
||||||
close: { id: 'settings.close', defaultMessage: 'Close' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class LocalSettingsNavigation extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
index : PropTypes.number,
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
onClose : PropTypes.func.isRequired,
|
|
||||||
onNavigate : PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
|
|
||||||
const { index, intl, onClose, onNavigate } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<nav className='glitch local-settings__navigation'>
|
|
||||||
<LocalSettingsNavigationItem
|
|
||||||
active={index === 0}
|
|
||||||
index={0}
|
|
||||||
onNavigate={onNavigate}
|
|
||||||
title={intl.formatMessage(messages.general)}
|
|
||||||
/>
|
|
||||||
<LocalSettingsNavigationItem
|
|
||||||
active={index === 1}
|
|
||||||
index={1}
|
|
||||||
onNavigate={onNavigate}
|
|
||||||
title={intl.formatMessage(messages.collapsed)}
|
|
||||||
/>
|
|
||||||
<LocalSettingsNavigationItem
|
|
||||||
active={index === 2}
|
|
||||||
index={2}
|
|
||||||
onNavigate={onNavigate}
|
|
||||||
title={intl.formatMessage(messages.media)}
|
|
||||||
/>
|
|
||||||
<LocalSettingsNavigationItem
|
|
||||||
active={index === 3}
|
|
||||||
href='/settings/preferences'
|
|
||||||
index={3}
|
|
||||||
icon='cog'
|
|
||||||
title={intl.formatMessage(messages.preferences)}
|
|
||||||
/>
|
|
||||||
<LocalSettingsNavigationItem
|
|
||||||
active={index === 4}
|
|
||||||
className='close'
|
|
||||||
index={4}
|
|
||||||
onNavigate={onClose}
|
|
||||||
title={intl.formatMessage(messages.close)}
|
|
||||||
/>
|
|
||||||
</nav>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
// Package imports
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
// Stylesheet imports
|
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
export default class LocalSettingsPage extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
active: PropTypes.bool,
|
|
||||||
className: PropTypes.string,
|
|
||||||
href: PropTypes.string,
|
|
||||||
icon: PropTypes.string,
|
|
||||||
index: PropTypes.number.isRequired,
|
|
||||||
onNavigate: PropTypes.func,
|
|
||||||
title: PropTypes.string,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleClick = (e) => {
|
|
||||||
const { index, onNavigate } = this.props;
|
|
||||||
if (onNavigate) {
|
|
||||||
onNavigate(index);
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { handleClick } = this;
|
|
||||||
const {
|
|
||||||
active,
|
|
||||||
className,
|
|
||||||
href,
|
|
||||||
icon,
|
|
||||||
onNavigate,
|
|
||||||
title,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const finalClassName = classNames('glitch', 'local-settings__navigation__item', {
|
|
||||||
active,
|
|
||||||
}, className);
|
|
||||||
|
|
||||||
const iconElem = icon ? <i className={`fa fa-fw fa-${icon}`} /> : null;
|
|
||||||
|
|
||||||
if (href) return (
|
|
||||||
<a
|
|
||||||
href={href}
|
|
||||||
className={finalClassName}
|
|
||||||
>
|
|
||||||
{iconElem} {title}
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
else if (onNavigate) return (
|
|
||||||
<a
|
|
||||||
onClick={handleClick}
|
|
||||||
role='button'
|
|
||||||
tabIndex='0'
|
|
||||||
className={finalClassName}
|
|
||||||
>
|
|
||||||
{iconElem} {title}
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
@import 'styles/mastodon/variables';
|
|
||||||
|
|
||||||
.glitch.local-settings__navigation__item {
|
|
||||||
display: block;
|
|
||||||
padding: 15px 20px;
|
|
||||||
color: inherit;
|
|
||||||
background: $primary-text-color;
|
|
||||||
border-bottom: 1px $ui-primary-color solid;
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: none;
|
|
||||||
outline: none;
|
|
||||||
transition: background .3s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: $ui-secondary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background: $ui-highlight-color;
|
|
||||||
color: $primary-text-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.close, &.close:hover {
|
|
||||||
background: $error-value-color;
|
|
||||||
color: $primary-text-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
@import 'styles/mastodon/variables';
|
|
||||||
|
|
||||||
.glitch.local-settings__navigation {
|
|
||||||
background: $primary-text-color;
|
|
||||||
color: $ui-base-color;
|
|
||||||
width: 200px;
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 20px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
// Package imports
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
|
|
||||||
|
|
||||||
// Our imports
|
|
||||||
import LocalSettingsPageItem from './item';
|
|
||||||
|
|
||||||
// Stylesheet imports
|
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
layout_auto: { id: 'layout.auto', defaultMessage: 'Auto' },
|
|
||||||
layout_desktop: { id: 'layout.desktop', defaultMessage: 'Desktop' },
|
|
||||||
layout_mobile: { id: 'layout.single', defaultMessage: 'Mobile' },
|
|
||||||
side_arm_none: { id: 'settings.side_arm.none', defaultMessage: 'None' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class LocalSettingsPage extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
index : PropTypes.number,
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
onChange : PropTypes.func.isRequired,
|
|
||||||
settings : ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
pages = [
|
|
||||||
({ intl, onChange, settings }) => (
|
|
||||||
<div className='glitch local-settings__page general'>
|
|
||||||
<h1><FormattedMessage id='settings.general' defaultMessage='General' /></h1>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['layout']}
|
|
||||||
id='mastodon-settings--layout'
|
|
||||||
options={[
|
|
||||||
{ value: 'auto', message: intl.formatMessage(messages.layout_auto) },
|
|
||||||
{ value: 'multiple', message: intl.formatMessage(messages.layout_desktop) },
|
|
||||||
{ value: 'single', message: intl.formatMessage(messages.layout_mobile) },
|
|
||||||
]}
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.layout' defaultMessage='Layout:' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['stretch']}
|
|
||||||
id='mastodon-settings--stretch'
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.wide_view' defaultMessage='Wide view (Desktop mode only)' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['navbar_under']}
|
|
||||||
id='mastodon-settings--navbar_under'
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.navbar_under' defaultMessage='Navbar at the bottom (Mobile only)' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<section>
|
|
||||||
<h2><FormattedMessage id='settings.compose_box_opts' defaultMessage='Compose box options' /></h2>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['side_arm']}
|
|
||||||
id='mastodon-settings--side_arm'
|
|
||||||
options={[
|
|
||||||
{ value: 'none', message: intl.formatMessage(messages.side_arm_none) },
|
|
||||||
{ value: 'direct', message: intl.formatMessage({ id: 'privacy.direct.short' }) },
|
|
||||||
{ value: 'private', message: intl.formatMessage({ id: 'privacy.private.short' }) },
|
|
||||||
{ value: 'unlisted', message: intl.formatMessage({ id: 'privacy.unlisted.short' }) },
|
|
||||||
{ value: 'public', message: intl.formatMessage({ id: 'privacy.public.short' }) },
|
|
||||||
]}
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.side_arm' defaultMessage='Secondary toot button:' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
({ onChange, settings }) => (
|
|
||||||
<div className='glitch local-settings__page collapsed'>
|
|
||||||
<h1><FormattedMessage id='settings.collapsed_statuses' defaultMessage='Collapsed toots' /></h1>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'enabled']}
|
|
||||||
id='mastodon-settings--collapsed-enabled'
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.enable_collapsed' defaultMessage='Enable collapsed toots' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<section>
|
|
||||||
<h2><FormattedMessage id='settings.auto_collapse' defaultMessage='Automatic collapsing' /></h2>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'auto', 'all']}
|
|
||||||
id='mastodon-settings--collapsed-auto-all'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.auto_collapse_all' defaultMessage='Everything' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'auto', 'notifications']}
|
|
||||||
id='mastodon-settings--collapsed-auto-notifications'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.auto_collapse_notifications' defaultMessage='Notifications' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'auto', 'lengthy']}
|
|
||||||
id='mastodon-settings--collapsed-auto-lengthy'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.auto_collapse_lengthy' defaultMessage='Lengthy toots' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'auto', 'replies']}
|
|
||||||
id='mastodon-settings--collapsed-auto-replies'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.auto_collapse_replies' defaultMessage='Replies' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'auto', 'media']}
|
|
||||||
id='mastodon-settings--collapsed-auto-media'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
dependsOnNot={[['collapsed', 'auto', 'all']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.auto_collapse_media' defaultMessage='Toots with media' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2><FormattedMessage id='settings.image_backgrounds' defaultMessage='Image backgrounds' /></h2>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'backgrounds', 'user_backgrounds']}
|
|
||||||
id='mastodon-settings--collapsed-user-backgrouns'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.image_backgrounds_users' defaultMessage='Give collapsed toots an image background' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['collapsed', 'backgrounds', 'preview_images']}
|
|
||||||
id='mastodon-settings--collapsed-preview-images'
|
|
||||||
onChange={onChange}
|
|
||||||
dependsOn={[['collapsed', 'enabled']]}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.image_backgrounds_media' defaultMessage='Preview collapsed toot media' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
({ onChange, settings }) => (
|
|
||||||
<div className='glitch local-settings__page media'>
|
|
||||||
<h1><FormattedMessage id='settings.media' defaultMessage='Media' /></h1>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['media', 'letterbox']}
|
|
||||||
id='mastodon-settings--media-letterbox'
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.media_letterbox' defaultMessage='Letterbox media' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
<LocalSettingsPageItem
|
|
||||||
settings={settings}
|
|
||||||
item={['media', 'fullwidth']}
|
|
||||||
id='mastodon-settings--media-fullwidth'
|
|
||||||
onChange={onChange}
|
|
||||||
>
|
|
||||||
<FormattedMessage id='settings.media_fullwidth' defaultMessage='Full-width media previews' />
|
|
||||||
</LocalSettingsPageItem>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { pages } = this;
|
|
||||||
const { index, intl, onChange, settings } = this.props;
|
|
||||||
const CurrentPage = pages[index] || pages[0];
|
|
||||||
|
|
||||||
return <CurrentPage intl={intl} onChange={onChange} settings={settings} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
// Package imports
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
|
|
||||||
// Stylesheet imports
|
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
export default class LocalSettingsPageItem extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
children: PropTypes.element.isRequired,
|
|
||||||
dependsOn: PropTypes.array,
|
|
||||||
dependsOnNot: PropTypes.array,
|
|
||||||
id: PropTypes.string.isRequired,
|
|
||||||
item: PropTypes.array.isRequired,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
options: PropTypes.arrayOf(PropTypes.shape({
|
|
||||||
value: PropTypes.string.isRequired,
|
|
||||||
message: PropTypes.string.isRequired,
|
|
||||||
})),
|
|
||||||
settings: ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleChange = e => {
|
|
||||||
const { target } = e;
|
|
||||||
const { item, onChange, options } = this.props;
|
|
||||||
if (options && options.length > 0) onChange(item, target.value);
|
|
||||||
else onChange(item, target.checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { handleChange } = this;
|
|
||||||
const { settings, item, id, options, children, dependsOn, dependsOnNot } = this.props;
|
|
||||||
let enabled = true;
|
|
||||||
|
|
||||||
if (dependsOn) {
|
|
||||||
for (let i = 0; i < dependsOn.length; i++) {
|
|
||||||
enabled = enabled && settings.getIn(dependsOn[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dependsOnNot) {
|
|
||||||
for (let i = 0; i < dependsOnNot.length; i++) {
|
|
||||||
enabled = enabled && !settings.getIn(dependsOnNot[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options && options.length > 0) {
|
|
||||||
const currentValue = settings.getIn(item);
|
|
||||||
const optionElems = options && options.length > 0 && options.map((opt) => (
|
|
||||||
<option
|
|
||||||
key={opt.value}
|
|
||||||
value={opt.value}
|
|
||||||
>
|
|
||||||
{opt.message}
|
|
||||||
</option>
|
|
||||||
));
|
|
||||||
return (
|
|
||||||
<label className='glitch local-settings__page__item' htmlFor={id}>
|
|
||||||
<p>{children}</p>
|
|
||||||
<p>
|
|
||||||
<select
|
|
||||||
id={id}
|
|
||||||
disabled={!enabled}
|
|
||||||
onBlur={handleChange}
|
|
||||||
onChange={handleChange}
|
|
||||||
value={currentValue}
|
|
||||||
>
|
|
||||||
{optionElems}
|
|
||||||
</select>
|
|
||||||
</p>
|
|
||||||
</label>
|
|
||||||
);
|
|
||||||
} else return (
|
|
||||||
<label className='glitch local-settings__page__item' htmlFor={id}>
|
|
||||||
<input
|
|
||||||
id={id}
|
|
||||||
type='checkbox'
|
|
||||||
checked={settings.getIn(item)}
|
|
||||||
onChange={handleChange}
|
|
||||||
disabled={!enabled}
|
|
||||||
/>
|
|
||||||
{children}
|
|
||||||
</label>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
@import 'styles/mastodon/variables';
|
|
||||||
|
|
||||||
.glitch.local-settings__page__item {
|
|
||||||
select {
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
@import 'styles/mastodon/variables';
|
|
||||||
|
|
||||||
.glitch.local-settings__page {
|
|
||||||
display: block;
|
|
||||||
flex: auto;
|
|
||||||
padding: 15px 20px 15px 20px;
|
|
||||||
width: 360px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
@import 'styles/mastodon/variables';
|
|
||||||
|
|
||||||
.glitch.local-settings {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
background: $ui-secondary-color;
|
|
||||||
color: $ui-base-color;
|
|
||||||
border-radius: 8px;
|
|
||||||
height: 80vh;
|
|
||||||
width: 80vw;
|
|
||||||
max-width: 740px;
|
|
||||||
max-height: 450px;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
label {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 24px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 20px;
|
|
||||||
margin-top: 20px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<NotificationContainer>`
|
|
||||||
=========================
|
|
||||||
|
|
||||||
This container connects `<Notification>`s to the Redux store.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import Notification from '.';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => {
|
|
||||||
// replace account id with object
|
|
||||||
let leNotif = props.notification.set('account', state.getIn(['accounts', props.notification.get('account')]));
|
|
||||||
|
|
||||||
// populate markedForDelete from state - is mysteriously lost somewhere
|
|
||||||
for (let n of state.getIn(['notifications', 'items'])) {
|
|
||||||
if (n.get('id') === props.notification.get('id')) {
|
|
||||||
leNotif = leNotif.set('markedForDelete', n.get('markedForDelete'));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ({
|
|
||||||
notification: leNotif,
|
|
||||||
settings: state.get('local_settings'),
|
|
||||||
notifCleaning: state.getIn(['notifications', 'cleaningMode']),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(Notification);
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
// `<NotificationFollow>`
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
// * * * * * * * //
|
|
||||||
|
|
||||||
// Imports
|
|
||||||
// -------
|
|
||||||
|
|
||||||
// Package imports.
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
// Mastodon imports.
|
|
||||||
import Permalink from '../../../mastodon/components/permalink';
|
|
||||||
import AccountContainer from '../../../mastodon/containers/account_container';
|
|
||||||
|
|
||||||
// Our imports.
|
|
||||||
import NotificationOverlayContainer from '../notification/overlay/container';
|
|
||||||
|
|
||||||
// * * * * * * * //
|
|
||||||
|
|
||||||
// Implementation
|
|
||||||
// --------------
|
|
||||||
|
|
||||||
export default class NotificationFollow extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
id : PropTypes.string.isRequired,
|
|
||||||
account : ImmutablePropTypes.map.isRequired,
|
|
||||||
notification : ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { account, notification } = this.props;
|
|
||||||
|
|
||||||
// Links to the display name.
|
|
||||||
const displayName = account.get('display_name_html') || account.get('username');
|
|
||||||
const link = (
|
|
||||||
<Permalink
|
|
||||||
className='notification__display-name'
|
|
||||||
href={account.get('url')}
|
|
||||||
title={account.get('acct')}
|
|
||||||
to={`/accounts/${account.get('id')}`}
|
|
||||||
dangerouslySetInnerHTML={{ __html: displayName }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
// Renders.
|
|
||||||
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} />
|
|
||||||
<NotificationOverlayContainer notification={notification} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import StatusContainer from '../status/container';
|
|
||||||
import NotificationFollow from './follow';
|
|
||||||
|
|
||||||
export default class Notification extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
notification: ImmutablePropTypes.map.isRequired,
|
|
||||||
settings: ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
renderFollow (notification) {
|
|
||||||
return (
|
|
||||||
<NotificationFollow
|
|
||||||
id={notification.get('id')}
|
|
||||||
account={notification.get('account')}
|
|
||||||
notification={notification}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderMention (notification) {
|
|
||||||
return (
|
|
||||||
<StatusContainer
|
|
||||||
id={notification.get('status')}
|
|
||||||
notification={notification}
|
|
||||||
withDismiss
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderFavourite (notification) {
|
|
||||||
return (
|
|
||||||
<StatusContainer
|
|
||||||
id={notification.get('status')}
|
|
||||||
account={notification.get('account')}
|
|
||||||
prepend='favourite'
|
|
||||||
muted
|
|
||||||
notification={notification}
|
|
||||||
withDismiss
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderReblog (notification) {
|
|
||||||
return (
|
|
||||||
<StatusContainer
|
|
||||||
id={notification.get('status')}
|
|
||||||
account={notification.get('account')}
|
|
||||||
prepend='reblog'
|
|
||||||
muted
|
|
||||||
notification={notification}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<NotificationOverlayContainer>`
|
|
||||||
=========================
|
|
||||||
|
|
||||||
This container connects `<NotificationOverlay>`s to the Redux store.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import NotificationOverlay from './notification_overlay';
|
|
||||||
import { markNotificationForDelete } from '../../../../mastodon/actions/notifications';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Dispatch mapping:
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
The `mapDispatchToProps()` function maps dispatches to our store to the
|
|
||||||
various props of our component. We only need to provide a dispatch for
|
|
||||||
deleting notifications.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
onMarkForDelete(id, yes) {
|
|
||||||
dispatch(markNotificationForDelete(id, yes));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
show: state.getIn(['notifications', 'cleaningMode']),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(NotificationOverlay);
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* Notification overlay
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
markForDeletion: { id: 'notification.markForDeletion', defaultMessage: 'Mark for deletion' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class NotificationOverlay extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
notification : ImmutablePropTypes.map.isRequired,
|
|
||||||
onMarkForDelete : PropTypes.func.isRequired,
|
|
||||||
show : PropTypes.bool.isRequired,
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
onToggleMark = () => {
|
|
||||||
const mark = !this.props.notification.get('markedForDelete');
|
|
||||||
const id = this.props.notification.get('id');
|
|
||||||
this.props.onMarkForDelete(id, mark);
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { notification, show, intl } = this.props;
|
|
||||||
|
|
||||||
const active = notification.get('markedForDelete');
|
|
||||||
const label = intl.formatMessage(messages.markForDeletion);
|
|
||||||
|
|
||||||
return show ? (
|
|
||||||
<div
|
|
||||||
aria-label={label}
|
|
||||||
role='checkbox'
|
|
||||||
aria-checked={active}
|
|
||||||
tabIndex={0}
|
|
||||||
className={`notification__dismiss-overlay ${active ? 'active' : ''}`}
|
|
||||||
onClick={this.onToggleMark}
|
|
||||||
>
|
|
||||||
<div className='wrappy'>
|
|
||||||
<div className='ckbox' aria-hidden='true' title={label}>
|
|
||||||
{active ? (<i className='fa fa-check' />) : ''}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
// 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 DropdownMenuContainer from '../../../mastodon/containers/dropdown_menu_container';
|
|
||||||
|
|
||||||
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' },
|
|
||||||
share: { id: 'status.share', defaultMessage: 'Share' },
|
|
||||||
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' },
|
|
||||||
pin: { id: 'status.pin', defaultMessage: 'Pin on profile' },
|
|
||||||
unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' },
|
|
||||||
embed: { id: 'status.embed', defaultMessage: 'Embed' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@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,
|
|
||||||
onEmbed: PropTypes.func,
|
|
||||||
onMuteConversation: PropTypes.func,
|
|
||||||
onPin: PropTypes.func,
|
|
||||||
me: PropTypes.string,
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleShareClick = () => {
|
|
||||||
navigator.share({
|
|
||||||
text: this.props.status.get('search_index'),
|
|
||||||
url: this.props.status.get('url'),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handleFavouriteClick = () => {
|
|
||||||
this.props.onFavourite(this.props.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleReblogClick = (e) => {
|
|
||||||
this.props.onReblog(this.props.status, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleDeleteClick = () => {
|
|
||||||
this.props.onDelete(this.props.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePinClick = () => {
|
|
||||||
this.props.onPin(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')}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleEmbed = () => {
|
|
||||||
this.props.onEmbed(this.props.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleReport = () => {
|
|
||||||
this.props.onReport(this.props.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleConversationMuteClick = () => {
|
|
||||||
this.props.onMuteConversation(this.props.status);
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { status, me, intl, withDismiss } = this.props;
|
|
||||||
|
|
||||||
const mutingConversation = status.get('muted');
|
|
||||||
const anonymousAccess = !me;
|
|
||||||
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'));
|
|
||||||
|
|
||||||
let menu = [];
|
|
||||||
let reblogIcon = 'retweet';
|
|
||||||
let replyIcon;
|
|
||||||
let replyTitle;
|
|
||||||
|
|
||||||
menu.push({ text: intl.formatMessage(messages.open), action: this.handleOpen });
|
|
||||||
|
|
||||||
if (publicStatus) {
|
|
||||||
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.push(null);
|
|
||||||
|
|
||||||
if (status.getIn(['account', 'id']) === me || withDismiss) {
|
|
||||||
menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick });
|
|
||||||
menu.push(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.getIn(['account', 'id']) === me) {
|
|
||||||
if (publicStatus) {
|
|
||||||
menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick });
|
|
||||||
}
|
|
||||||
|
|
||||||
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('in_reply_to_id', null) === null) {
|
|
||||||
replyIcon = 'reply';
|
|
||||||
replyTitle = intl.formatMessage(messages.reply);
|
|
||||||
} else {
|
|
||||||
replyIcon = 'reply-all';
|
|
||||||
replyTitle = intl.formatMessage(messages.replyAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
const shareButton = ('share' in navigator) && status.get('visibility') === 'public' && (
|
|
||||||
<IconButton className='status__action-bar-button' title={intl.formatMessage(messages.share)} icon='share-alt' onClick={this.handleShareClick} />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='status__action-bar'>
|
|
||||||
<IconButton className='status__action-bar-button' disabled={anonymousAccess} title={replyTitle} icon={replyIcon} onClick={this.handleReplyClick} />
|
|
||||||
<IconButton className='status__action-bar-button' disabled={anonymousAccess || !publicStatus} active={status.get('reblogged')} pressed={status.get('reblogged')} title={!publicStatus ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} icon={reblogIcon} onClick={this.handleReblogClick} />
|
|
||||||
<IconButton className='status__action-bar-button star-icon' disabled={anonymousAccess} animate active={status.get('favourited')} pressed={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} />
|
|
||||||
{shareButton}
|
|
||||||
|
|
||||||
<div className='status__action-bar-dropdown'>
|
|
||||||
<DropdownMenuContainer disabled={anonymousAccess} status={status} 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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,265 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<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,
|
|
||||||
pin,
|
|
||||||
unpin,
|
|
||||||
} from '../../../mastodon/actions/interactions';
|
|
||||||
import { blockAccount } from '../../../mastodon/actions/accounts';
|
|
||||||
import { initMuteModal } from '../../../mastodon/actions/mutes';
|
|
||||||
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 '.';
|
|
||||||
|
|
||||||
/* * * * */
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/* * * * */
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if(status === null) {
|
|
||||||
console.error(`ERROR! NULL STATUS! ${ownProps.id}`);
|
|
||||||
// work-around: find first good status
|
|
||||||
for (let k of state.get('statuses').keys()) {
|
|
||||||
status = getStatus(state, k);
|
|
||||||
if (status !== null) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onPin (status) {
|
|
||||||
if (status.get('pinned')) {
|
|
||||||
dispatch(unpin(status));
|
|
||||||
} else {
|
|
||||||
dispatch(pin(status));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onEmbed (status) {
|
|
||||||
dispatch(openModal('EMBED', { url: status.get('url') }));
|
|
||||||
},
|
|
||||||
|
|
||||||
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(initMuteModal(account));
|
|
||||||
},
|
|
||||||
|
|
||||||
onMuteConversation (status) {
|
|
||||||
if (status.get('muted')) {
|
|
||||||
dispatch(unmuteStatus(status.get('id')));
|
|
||||||
} else {
|
|
||||||
dispatch(muteStatus(status.get('id')));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default injectIntl(
|
|
||||||
connect(makeMapStateToProps, mapDispatchToProps)(Status)
|
|
||||||
);
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
import classnames from 'classnames';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
import { isRtl } from '../../../mastodon/rtl';
|
|
||||||
import Permalink from '../../../mastodon/components/permalink';
|
|
||||||
|
|
||||||
export default class StatusContent extends React.PureComponent {
|
|
||||||
|
|
||||||
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,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
hidden: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
const node = this.node;
|
|
||||||
const links = node.querySelectorAll('a');
|
|
||||||
|
|
||||||
for (let 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('title', link.href);
|
|
||||||
}
|
|
||||||
|
|
||||||
link.setAttribute('target', '_blank');
|
|
||||||
link.setAttribute('rel', 'noopener');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
parseClick,
|
|
||||||
disabled,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const hidden = (
|
|
||||||
this.props.setExpansion ?
|
|
||||||
!this.props.expanded :
|
|
||||||
this.state.hidden
|
|
||||||
);
|
|
||||||
|
|
||||||
const content = { __html: status.get('contentHtml') };
|
|
||||||
const spoilerContent = { __html: status.get('spoilerHtml') };
|
|
||||||
const directionStyle = { direction: 'ltr' };
|
|
||||||
const classNames = classnames('status__content', {
|
|
||||||
'status__content--with-action': parseClick && !disabled,
|
|
||||||
});
|
|
||||||
|
|
||||||
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={classNames}>
|
|
||||||
<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
|
|
||||||
ref={this.setRef}
|
|
||||||
style={directionStyle}
|
|
||||||
onMouseDown={this.handleMouseDown}
|
|
||||||
onMouseUp={this.handleMouseUp}
|
|
||||||
dangerouslySetInnerHTML={content}
|
|
||||||
/>
|
|
||||||
{media}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else if (parseClick) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={classNames}
|
|
||||||
style={directionStyle}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
ref={this.setRef}
|
|
||||||
onMouseDown={this.handleMouseDown}
|
|
||||||
onMouseUp={this.handleMouseUp}
|
|
||||||
dangerouslySetInnerHTML={content}
|
|
||||||
/>
|
|
||||||
{media}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className='status__content'
|
|
||||||
style={directionStyle}
|
|
||||||
>
|
|
||||||
<div ref={this.setRef} dangerouslySetInnerHTML={content} />
|
|
||||||
{media}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
// 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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
// 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,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleMouseEnter = (e) => {
|
|
||||||
if (this.hoverToPlay()) {
|
|
||||||
e.target.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMouseLeave = (e) => {
|
|
||||||
if (this.hoverToPlay()) {
|
|
||||||
e.target.pause();
|
|
||||||
e.target.currentTime = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hoverToPlay () {
|
|
||||||
const { attachment, autoPlayGif } = this.props;
|
|
||||||
return !autoPlayGif && attachment.get('type') === 'gifv';
|
|
||||||
}
|
|
||||||
|
|
||||||
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={attachment.get('description')}
|
|
||||||
title={attachment.get('description')}
|
|
||||||
/>
|
|
||||||
</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}
|
|
||||||
onMouseEnter={this.handleMouseEnter}
|
|
||||||
onMouseLeave={this.handleMouseLeave}
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<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';
|
|
||||||
import VisibilityIcon from './visibility_icon';
|
|
||||||
|
|
||||||
// * * * * * * * //
|
|
||||||
|
|
||||||
// Initial setup
|
|
||||||
// -------------
|
|
||||||
|
|
||||||
// Messages for use with internationalization stuff.
|
|
||||||
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 component
|
|
||||||
// -------------
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class StatusHeader extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
status: 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,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handles clicks on collapsed button
|
|
||||||
handleCollapsedClick = (e) => {
|
|
||||||
const { collapsed, setExpansion } = this.props;
|
|
||||||
if (e.button === 0) {
|
|
||||||
setExpansion(collapsed ? null : false);
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles clicks on account name/image
|
|
||||||
handleAccountClick = (e) => {
|
|
||||||
const { status, parseClick } = this.props;
|
|
||||||
parseClick(e, `/accounts/${+status.getIn(['account', 'id'])}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rendering.
|
|
||||||
render () {
|
|
||||||
const {
|
|
||||||
status,
|
|
||||||
friend,
|
|
||||||
mediaIcon,
|
|
||||||
collapsible,
|
|
||||||
collapsed,
|
|
||||||
intl,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const account = status.get('account');
|
|
||||||
|
|
||||||
return (
|
|
||||||
<header className='status__info'>
|
|
||||||
<a
|
|
||||||
href={account.get('url')}
|
|
||||||
target='_blank'
|
|
||||||
className='status__avatar'
|
|
||||||
onClick={this.handleAccountClick}
|
|
||||||
>
|
|
||||||
{
|
|
||||||
friend ? (
|
|
||||||
<AvatarOverlay account={account} friend={friend} />
|
|
||||||
) : (
|
|
||||||
<Avatar account={account} size={48} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
href={account.get('url')}
|
|
||||||
target='_blank'
|
|
||||||
className='status__display-name'
|
|
||||||
onClick={this.handleAccountClick}
|
|
||||||
>
|
|
||||||
<DisplayName account={account} />
|
|
||||||
</a>
|
|
||||||
<div className='status__info__icons'>
|
|
||||||
{mediaIcon ? (
|
|
||||||
<i
|
|
||||||
className={`fa fa-fw fa-${mediaIcon}`}
|
|
||||||
aria-hidden='true'
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{(
|
|
||||||
<VisibilityIcon visibility={status.get('visibility')} />
|
|
||||||
)}
|
|
||||||
{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>
|
|
||||||
|
|
||||||
</header>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,766 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<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 StatusPlayer from './player';
|
|
||||||
import NotificationOverlayContainer from '../notification/overlay/container';
|
|
||||||
|
|
||||||
/* * * * */
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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.string,
|
|
||||||
status : ImmutablePropTypes.map,
|
|
||||||
account : ImmutablePropTypes.map,
|
|
||||||
settings : ImmutablePropTypes.map,
|
|
||||||
notification : ImmutablePropTypes.map,
|
|
||||||
me : PropTypes.string,
|
|
||||||
onFavourite : PropTypes.func,
|
|
||||||
onReblog : PropTypes.func,
|
|
||||||
onModalReblog : PropTypes.func,
|
|
||||||
onDelete : PropTypes.func,
|
|
||||||
onPin : PropTypes.func,
|
|
||||||
onMention : PropTypes.func,
|
|
||||||
onMute : PropTypes.func,
|
|
||||||
onMuteConversation : PropTypes.func,
|
|
||||||
onBlock : PropTypes.func,
|
|
||||||
onEmbed : PropTypes.func,
|
|
||||||
onHeightChange : 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,
|
|
||||||
markedForDelete : 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',
|
|
||||||
'notification',
|
|
||||||
]
|
|
||||||
|
|
||||||
updateOnStates = [
|
|
||||||
'isExpanded',
|
|
||||||
'markedForDelete',
|
|
||||||
]
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
#### `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'])) {
|
|
||||||
if (this.state.isExpanded === false) {
|
|
||||||
this.setExpansion(null);
|
|
||||||
}
|
|
||||||
} 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 (!router) return;
|
|
||||||
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,
|
|
||||||
saveHeight,
|
|
||||||
handleRef,
|
|
||||||
} = this;
|
|
||||||
const { router } = this.context;
|
|
||||||
const {
|
|
||||||
status,
|
|
||||||
account,
|
|
||||||
settings,
|
|
||||||
collapsed,
|
|
||||||
muted,
|
|
||||||
prepend,
|
|
||||||
intersectionObserverWrapper,
|
|
||||||
onOpenVideo,
|
|
||||||
onOpenMedia,
|
|
||||||
autoPlayGif,
|
|
||||||
notification,
|
|
||||||
...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'
|
|
||||||
<StatusPlayer
|
|
||||||
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']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Here we prepare extra data-* attributes for CSS selectors.
|
|
||||||
Users can use those for theming, hiding avatars etc via UserStyle
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const selectorAttribs = {
|
|
||||||
'data-status-by': `@${status.getIn(['account', 'acct'])}`,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (prepend && account) {
|
|
||||||
const notifKind = {
|
|
||||||
favourite: 'favourited',
|
|
||||||
reblog: 'boosted',
|
|
||||||
reblogged_by: 'boosted',
|
|
||||||
}[prepend];
|
|
||||||
|
|
||||||
selectorAttribs[`data-${notifKind}-by`] = `@${account.get('acct')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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' : ''
|
|
||||||
}${
|
|
||||||
this.state.markedForDelete ? ' marked-for-delete' : ''
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
style={{
|
|
||||||
backgroundImage: (
|
|
||||||
isExpanded === false && background ?
|
|
||||||
`url(${background})` :
|
|
||||||
'none'
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
ref={handleRef}
|
|
||||||
{...selectorAttribs}
|
|
||||||
>
|
|
||||||
{prepend && account ? (
|
|
||||||
<StatusPrepend
|
|
||||||
type={prepend}
|
|
||||||
account={account}
|
|
||||||
parseClick={parseClick}
|
|
||||||
notificationId={this.props.notificationId}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
<StatusHeader
|
|
||||||
status={status}
|
|
||||||
friend={account}
|
|
||||||
mediaIcon={mediaIcon}
|
|
||||||
collapsible={settings.getIn(['collapsed', 'enabled'])}
|
|
||||||
collapsed={isExpanded === false}
|
|
||||||
parseClick={parseClick}
|
|
||||||
setExpansion={setExpansion}
|
|
||||||
/>
|
|
||||||
<StatusContent
|
|
||||||
status={status}
|
|
||||||
media={media}
|
|
||||||
mediaIcon={mediaIcon}
|
|
||||||
expanded={isExpanded}
|
|
||||||
setExpansion={setExpansion}
|
|
||||||
onHeightUpdate={saveHeight}
|
|
||||||
parseClick={parseClick}
|
|
||||||
disabled={!router}
|
|
||||||
/>
|
|
||||||
{isExpanded !== false ? (
|
|
||||||
<StatusActionBar
|
|
||||||
{...other}
|
|
||||||
status={status}
|
|
||||||
account={status.get('account')}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
{notification ? (
|
|
||||||
<NotificationOverlayContainer
|
|
||||||
notification={notification}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</article>
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,203 +0,0 @@
|
|||||||
// 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 StatusPlayer extends React.PureComponent {
|
|
||||||
|
|
||||||
static contextTypes = {
|
|
||||||
router: PropTypes.object,
|
|
||||||
};
|
|
||||||
|
|
||||||
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 = !this.context.router ? '' : (
|
|
||||||
<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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`<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 { FormattedMessage } from 'react-intl';
|
|
||||||
|
|
||||||
/* * * * */
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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,
|
|
||||||
notificationId: PropTypes.number,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
### 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 : account.get('display_name_html') || 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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
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' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class VisibilityIcon extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
visibility: PropTypes.string,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
withLabel: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { withLabel, visibility, intl } = this.props;
|
|
||||||
|
|
||||||
const visibilityClass = {
|
|
||||||
public: 'globe',
|
|
||||||
unlisted: 'unlock-alt',
|
|
||||||
private: 'lock',
|
|
||||||
direct: 'envelope',
|
|
||||||
}[visibility];
|
|
||||||
|
|
||||||
const label = intl.formatMessage(messages[visibility]);
|
|
||||||
|
|
||||||
const icon = (<i
|
|
||||||
className={`status__visibility-icon fa fa-fw fa-${visibilityClass}`}
|
|
||||||
title={label}
|
|
||||||
aria-hidden='true'
|
|
||||||
/>);
|
|
||||||
|
|
||||||
if (withLabel) {
|
|
||||||
return (<span style={{ whiteSpace: 'nowrap' }}>{icon} {label}</span>);
|
|
||||||
} else {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"getting_started.open_source_notice": "Glitchsoc is free open source software forked from {Mastodon}. You can contribute or report issues on GitHub at {github}.",
|
|
||||||
"layout.auto": "Auto",
|
|
||||||
"layout.current_is": "Your current layout is:",
|
|
||||||
"layout.desktop": "Desktop",
|
|
||||||
"layout.mobile": "Mobile",
|
|
||||||
"navigation_bar.app_settings": "App settings",
|
|
||||||
"getting_started.onboarding": "Show me around",
|
|
||||||
"onboarding.page_one.federation": "{domain} is an 'instance' of Mastodon. Mastodon is a network of independent servers joining up to make one larger social network. We call these servers instances.",
|
|
||||||
"onboarding.page_one.welcome": "Welcome to {domain}!",
|
|
||||||
"onboarding.page_six.github": "{domain} runs on Glitchsoc. Glitchsoc is a friendly {fork} of {Mastodon}, and is compatible with any Mastodon instance or app. Glitchsoc is entirely free and open-source. You can report bugs, request features, or contribute to the code on {github}.",
|
|
||||||
"settings.auto_collapse": "Automatic collapsing",
|
|
||||||
"settings.auto_collapse_all": "Everything",
|
|
||||||
"settings.auto_collapse_lengthy": "Lengthy toots",
|
|
||||||
"settings.auto_collapse_media": "Toots with media",
|
|
||||||
"settings.auto_collapse_notifications": "Notifications",
|
|
||||||
"settings.auto_collapse_replies": "Replies",
|
|
||||||
"settings.close": "Close",
|
|
||||||
"settings.collapsed_statuses": "Collapsed toots",
|
|
||||||
"settings.enable_collapsed": "Enable collapsed toots",
|
|
||||||
"settings.general": "General",
|
|
||||||
"settings.image_backgrounds": "Image backgrounds",
|
|
||||||
"settings.image_backgrounds_media": "Preview collapsed toot media",
|
|
||||||
"settings.image_backgrounds_users": "Give collapsed toots an image background",
|
|
||||||
"settings.media": "Media",
|
|
||||||
"settings.media_letterbox": "Letterbox media",
|
|
||||||
"settings.media_fullwidth": "Full-width media previews",
|
|
||||||
"settings.preferences": "User preferences",
|
|
||||||
"settings.wide_view": "Wide view (Desktop mode only)",
|
|
||||||
"settings.navbar_under": "Navbar at the bottom (Mobile only)",
|
|
||||||
"status.collapse": "Collapse",
|
|
||||||
"status.uncollapse": "Uncollapse",
|
|
||||||
|
|
||||||
"notification.markForDeletion": "Mark for deletion",
|
|
||||||
"notifications.clear": "Clear all my notifications",
|
|
||||||
"notifications.marked_clear_confirmation": "Are you sure you want to permanently clear all selected notifications?",
|
|
||||||
"notifications.marked_clear": "Clear selected notifications",
|
|
||||||
|
|
||||||
"notification_purge.btn_all": "Select\nall",
|
|
||||||
"notification_purge.btn_none": "Select\nnone",
|
|
||||||
"notification_purge.btn_invert": "Invert\nselection",
|
|
||||||
"notification_purge.btn_apply": "Clear\nselected"
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`reducers/local_settings`
|
|
||||||
========================
|
|
||||||
|
|
||||||
> For more information on the contents of this file, please contact:
|
|
||||||
>
|
|
||||||
> - kibigo! [@kibi@glitch.social]
|
|
||||||
|
|
||||||
This file provides our Redux reducers related to local settings. The
|
|
||||||
associated actions are:
|
|
||||||
|
|
||||||
- __`STORE_HYDRATE` :__
|
|
||||||
Used to hydrate the store with its initial values.
|
|
||||||
|
|
||||||
- __`LOCAL_SETTING_CHANGE` :__
|
|
||||||
Used to change the value of a local setting in the store.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Imports:
|
|
||||||
--------
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package imports //
|
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
|
||||||
|
|
||||||
// Mastodon imports //
|
|
||||||
import { STORE_HYDRATE } from '../../mastodon/actions/store';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import { LOCAL_SETTING_CHANGE } from '../actions/local_settings';
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
initialState:
|
|
||||||
-------------
|
|
||||||
|
|
||||||
You can see the default values for all of our local settings here.
|
|
||||||
These are only used if no previously-saved values exist.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
|
||||||
layout : 'auto',
|
|
||||||
stretch : true,
|
|
||||||
navbar_under : false,
|
|
||||||
side_arm : 'none',
|
|
||||||
collapsed : ImmutableMap({
|
|
||||||
enabled : true,
|
|
||||||
auto : ImmutableMap({
|
|
||||||
all : false,
|
|
||||||
notifications : true,
|
|
||||||
lengthy : true,
|
|
||||||
replies : false,
|
|
||||||
media : false,
|
|
||||||
}),
|
|
||||||
backgrounds : ImmutableMap({
|
|
||||||
user_backgrounds : false,
|
|
||||||
preview_images : false,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
media : ImmutableMap({
|
|
||||||
letterbox : true,
|
|
||||||
fullwidth : true,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Helper functions:
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
### `hydrate(state, localSettings)`
|
|
||||||
|
|
||||||
`hydrate()` is used to hydrate the `local_settings` part of our store
|
|
||||||
with its initial values. The `state` will probably just be the
|
|
||||||
`initialState`, and the `localSettings` should be whatever we pulled
|
|
||||||
from `localStorage`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
const hydrate = (state, localSettings) => state.mergeDeep(localSettings);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
`localSettings(state = initialState, action)`:
|
|
||||||
----------------------------------------------
|
|
||||||
|
|
||||||
This function holds our actual reducer.
|
|
||||||
|
|
||||||
If our action is `STORE_HYDRATE`, then we call `hydrate()` with the
|
|
||||||
`local_settings` property of the provided `action.state`.
|
|
||||||
|
|
||||||
If our action is `LOCAL_SETTING_CHANGE`, then we set `action.key` in
|
|
||||||
our state to the provided `action.value`. Note that `action.key` MUST
|
|
||||||
be an array, since we use `setIn()`.
|
|
||||||
|
|
||||||
> __Note :__
|
|
||||||
> We call this function `localSettings`, but its associated object
|
|
||||||
> in the store is `local_settings`.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,331 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
`util/bio_metadata`
|
|
||||||
===================
|
|
||||||
|
|
||||||
> For more information on the contents of this file, please contact:
|
|
||||||
>
|
|
||||||
> - kibigo! [@kibi@glitch.social]
|
|
||||||
|
|
||||||
This file provides two functions for dealing with bio metadata. The
|
|
||||||
functions are:
|
|
||||||
|
|
||||||
- __`processBio(content)` :__
|
|
||||||
Processes `content` to extract any frontmatter. The returned
|
|
||||||
object has two properties: `text`, which contains the text of
|
|
||||||
`content` sans-frontmatter, and `metadata`, which is an array
|
|
||||||
of key-value pairs (in two-element array format). If no
|
|
||||||
frontmatter was provided in `content`, then `metadata` will be
|
|
||||||
an empty array.
|
|
||||||
|
|
||||||
- __`createBio(note, data)` :__
|
|
||||||
Reverses the process in `processBio()`; takes a `note` and an
|
|
||||||
array of two-element arrays (which should give keys and values)
|
|
||||||
and outputs a string containing a well-formed bio with
|
|
||||||
frontmatter.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
|
|
||||||
/*********************************************************************\
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
UPDATE 19 Oct 2017: We no longer allow character escapes inside our
|
|
||||||
double-quoted strings for ease of processing. We now internally use
|
|
||||||
the name "ƔAML" in our code to clarify that this is Not Quite YAML.
|
|
||||||
|
|
||||||
Sending love + warmth eternal,
|
|
||||||
- kibigo [@kibi@glitch.social]
|
|
||||||
|
|
||||||
\*********************************************************************/
|
|
||||||
|
|
||||||
/* "u" FLAG COMPATABILITY */
|
|
||||||
|
|
||||||
let compat_mode = false;
|
|
||||||
try {
|
|
||||||
new RegExp('.', 'u');
|
|
||||||
} catch (e) {
|
|
||||||
compat_mode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CONVENIENCE FUNCTIONS */
|
|
||||||
|
|
||||||
const unirex = str => compat_mode ? new RegExp(str) : new RegExp(str, 'u');
|
|
||||||
const rexstr = exp => '(?:' + exp.source + ')';
|
|
||||||
|
|
||||||
/* CHARACTER CLASSES */
|
|
||||||
|
|
||||||
const DOCUMENT_START = /^/;
|
|
||||||
const DOCUMENT_END = /$/;
|
|
||||||
const ALLOWED_CHAR = unirex( // `c-printable` in the YAML 1.2 spec.
|
|
||||||
compat_mode ? '[\t\n\r\x20-\x7e\x85\xa0-\ufffd]' : '[\t\n\r\x20-\x7e\x85\xa0-\ud7ff\ue000-\ufffd\u{10000}-\u{10FFFF}]'
|
|
||||||
);
|
|
||||||
const WHITE_SPACE = /[ \t]/;
|
|
||||||
const LINE_BREAK = /\r?\n|\r|<br\s*\/?>/;
|
|
||||||
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(NEW_LINE) + ')+'
|
|
||||||
);
|
|
||||||
const POSSIBLE_STARTS = unirex(
|
|
||||||
rexstr(DOCUMENT_START) + rexstr(/<p[^<>]*>/) + '?'
|
|
||||||
);
|
|
||||||
const POSSIBLE_ENDS = unirex(
|
|
||||||
rexstr(SOME_NEW_LINES) + '|' +
|
|
||||||
rexstr(DOCUMENT_END) + '|' +
|
|
||||||
rexstr(/<\/p>/)
|
|
||||||
);
|
|
||||||
const QUOTE_CHAR = unirex(
|
|
||||||
'(?=' + rexstr(NOT_LINE_BREAK) + ')[^"]'
|
|
||||||
);
|
|
||||||
const ANY_QUOTE_CHAR = unirex(
|
|
||||||
rexstr(QUOTE_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 ƔAML_START = unirex(
|
|
||||||
rexstr(ANY_WHITE_SPACE) + '---'
|
|
||||||
);
|
|
||||||
const ƔAML_END = unirex(
|
|
||||||
rexstr(ANY_WHITE_SPACE) + '(?:---|\.\.\.)'
|
|
||||||
);
|
|
||||||
const ƔAML_LOOKAHEAD = unirex(
|
|
||||||
'(?=' +
|
|
||||||
rexstr(ƔAML_START) +
|
|
||||||
rexstr(ANY_ALLOWED_CHARS) + rexstr(NEW_LINE) +
|
|
||||||
rexstr(ƔAML_END) + rexstr(POSSIBLE_ENDS) +
|
|
||||||
')'
|
|
||||||
);
|
|
||||||
const ƔAML_DOUBLE_QUOTE = unirex(
|
|
||||||
'"' + rexstr(ANY_QUOTE_CHAR) + '"'
|
|
||||||
);
|
|
||||||
const ƔAML_SINGLE_QUOTE = unirex(
|
|
||||||
'\'' + rexstr(ANY_ESCAPED_APOS) + '\''
|
|
||||||
);
|
|
||||||
const ƔAML_SIMPLE_KEY = unirex(
|
|
||||||
rexstr(FIRST_KEY_CHAR) + rexstr(LATER_KEY_CHAR) + '*'
|
|
||||||
);
|
|
||||||
const ƔAML_SIMPLE_VALUE = unirex(
|
|
||||||
rexstr(FIRST_VALUE_CHAR) + rexstr(LATER_VALUE_CHAR) + '*'
|
|
||||||
);
|
|
||||||
const ƔAML_KEY = unirex(
|
|
||||||
rexstr(ƔAML_DOUBLE_QUOTE) + '|' +
|
|
||||||
rexstr(ƔAML_SINGLE_QUOTE) + '|' +
|
|
||||||
rexstr(ƔAML_SIMPLE_KEY)
|
|
||||||
);
|
|
||||||
const ƔAML_VALUE = unirex(
|
|
||||||
rexstr(ƔAML_DOUBLE_QUOTE) + '|' +
|
|
||||||
rexstr(ƔAML_SINGLE_QUOTE) + '|' +
|
|
||||||
rexstr(ƔAML_SIMPLE_VALUE)
|
|
||||||
);
|
|
||||||
const ƔAML_SEPARATOR = unirex(
|
|
||||||
rexstr(ANY_WHITE_SPACE) +
|
|
||||||
':' + rexstr(WHITE_SPACE) +
|
|
||||||
rexstr(ANY_WHITE_SPACE)
|
|
||||||
);
|
|
||||||
const ƔAML_LINE = unirex(
|
|
||||||
'(' + rexstr(ƔAML_KEY) + ')' +
|
|
||||||
rexstr(ƔAML_SEPARATOR) +
|
|
||||||
'(' + rexstr(ƔAML_VALUE) + ')'
|
|
||||||
);
|
|
||||||
|
|
||||||
/* FRONTMATTER REGEX */
|
|
||||||
|
|
||||||
const ƔAML_FRONTMATTER = unirex(
|
|
||||||
rexstr(POSSIBLE_STARTS) +
|
|
||||||
rexstr(ƔAML_LOOKAHEAD) +
|
|
||||||
rexstr(ƔAML_START) + rexstr(SOME_NEW_LINES) +
|
|
||||||
'(?:' +
|
|
||||||
rexstr(ANY_WHITE_SPACE) + rexstr(ƔAML_LINE) + rexstr(SOME_NEW_LINES) +
|
|
||||||
'){0,5}' +
|
|
||||||
rexstr(ƔAML_END) + rexstr(POSSIBLE_ENDS)
|
|
||||||
);
|
|
||||||
|
|
||||||
/* SEARCHES */
|
|
||||||
|
|
||||||
const FIND_ƔAML_LINE = unirex(
|
|
||||||
rexstr(NEW_LINE) + rexstr(ANY_WHITE_SPACE) + rexstr(ƔAML_LINE)
|
|
||||||
);
|
|
||||||
|
|
||||||
/* STRING PROCESSING */
|
|
||||||
|
|
||||||
function processString (str) {
|
|
||||||
switch (str.charAt(0)) {
|
|
||||||
case '"':
|
|
||||||
return str.substring(1, str.length - 1);
|
|
||||||
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 ɣaml = content.match(ƔAML_FRONTMATTER);
|
|
||||||
if (!ɣaml) {
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
ɣaml = ɣaml[0];
|
|
||||||
}
|
|
||||||
const start = content.search(ƔAML_START);
|
|
||||||
const end = start + ɣaml.length - ɣaml.search(ƔAML_START);
|
|
||||||
result.text = content.substr(end);
|
|
||||||
let metadata = null;
|
|
||||||
let query = new RegExp(rexstr(FIND_ƔAML_LINE), 'g'); // Some browsers don't allow flags unless both args are strings
|
|
||||||
while ((metadata = query.exec(ɣaml))) {
|
|
||||||
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(ƔAML_SIMPLE_KEY) || [])[0]) /* do nothing */;
|
|
||||||
else if (key === (key.match(ANY_QUOTE_CHAR) || [])[0]) key = '"' + key + '"';
|
|
||||||
else {
|
|
||||||
key = key
|
|
||||||
.replace(/'/g, '\'\'')
|
|
||||||
.replace(new RegExp(rexstr(NOT_ALLOWED_CHAR), compat_mode ? 'g' : 'gu'), '<27>');
|
|
||||||
key = '\'' + key + '\'';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value processing
|
|
||||||
if (val === (val.match(ƔAML_SIMPLE_VALUE) || [])[0]) /* do nothing */;
|
|
||||||
else if (val === (val.match(ANY_QUOTE_CHAR) || [])[0]) val = '"' + val + '"';
|
|
||||||
else {
|
|
||||||
key = key
|
|
||||||
.replace(/'/g, '\'\'')
|
|
||||||
.replace(new RegExp(rexstr(NOT_ALLOWED_CHAR), compat_mode ? 'g' : 'gu'), '<27>');
|
|
||||||
key = '\'' + key + '\'';
|
|
||||||
}
|
|
||||||
|
|
||||||
frontmatter += key + ': ' + val + '\n';
|
|
||||||
}
|
|
||||||
frontmatter += '...\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return frontmatter + note;
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216.4144 232.00976"><path d="M211.80734 139.0875c-3.18125 16.36625-28.4925 34.2775-57.5625 37.74875-15.15875 1.80875-30.08375 3.47125-45.99875 2.74125-26.0275-1.1925-46.565-6.2125-46.565-6.2125 0 2.53375.15625 4.94625.46875 7.2025 3.38375 25.68625 25.47 27.225 46.39125 27.9425 21.11625.7225 39.91875-5.20625 39.91875-5.20625l.8675 19.09s-14.77 7.93125-41.08125 9.39c-14.50875.7975-32.52375-.365-53.50625-5.91875C9.23234 213.82 1.40609 165.31125.20859 116.09125c-.365-14.61375-.14-28.39375-.14-39.91875 0-50.33 32.97625-65.0825 32.97625-65.0825C49.67234 3.45375 78.20359.2425 107.86484 0h.72875c29.66125.2425 58.21125 3.45375 74.8375 11.09 0 0 32.975 14.7525 32.975 65.0825 0 0 .41375 37.13375-4.59875 62.915" fill="#3088d4"/><path d="M177.50984 80.077v60.94125h-24.14375v-59.15c0-12.46875-5.24625-18.7975-15.74-18.7975-11.6025 0-17.4175 7.5075-17.4175 22.3525v32.37625H96.20734V85.42325c0-14.845-5.81625-22.3525-17.41875-22.3525-10.49375 0-15.74 6.32875-15.74 18.7975v59.15H38.90484V80.077c0-12.455 3.17125-22.3525 9.54125-29.675 6.56875-7.3225 15.17125-11.07625 25.85-11.07625 12.355 0 21.71125 4.74875 27.8975 14.2475l6.01375 10.08125 6.015-10.08125c6.185-9.49875 15.54125-14.2475 27.8975-14.2475 10.6775 0 19.28 3.75375 25.85 11.07625 6.36875 7.3225 9.54 17.22 9.54 29.675" fill="#fff"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="61.076954mm" height="65.47831mm" viewBox="0 0 216.4144 232.00976"><path d="M211.80734 139.0875c-3.18125 16.36625-28.4925 34.2775-57.5625 37.74875-15.15875 1.80875-30.08375 3.47125-45.99875 2.74125-26.0275-1.1925-46.565-6.2125-46.565-6.2125 0 2.53375.15625 4.94625.46875 7.2025 3.38375 25.68625 25.47 27.225 46.39125 27.9425 21.11625.7225 39.91875-5.20625 39.91875-5.20625l.8675 19.09s-14.77 7.93125-41.08125 9.39c-14.50875.7975-32.52375-.365-53.50625-5.91875C9.23234 213.82 1.40609 165.31125.20859 116.09125c-.365-14.61375-.14-28.39375-.14-39.91875 0-50.33 32.97625-65.0825 32.97625-65.0825C49.67234 3.45375 78.20359.2425 107.86484 0h.72875c29.66125.2425 58.21125 3.45375 74.8375 11.09 0 0 32.975 14.7525 32.975 65.0825 0 0 .41375 37.13375-4.59875 62.915" fill="#3088d4"/><path d="M177.50984 80.077v60.94125h-24.14375v-59.15c0-12.46875-5.24625-18.7975-15.74-18.7975-11.6025 0-17.4175 7.5075-17.4175 22.3525v32.37625H96.20734V85.42325c0-14.845-5.81625-22.3525-17.41875-22.3525-10.49375 0-15.74 6.32875-15.74 18.7975v59.15H38.90484V80.077c0-12.455 3.17125-22.3525 9.54125-29.675 6.56875-7.3225 15.17125-11.07625 25.85-11.07625 12.355 0 21.71125 4.74875 27.8975 14.2475l6.01375 10.08125 6.015-10.08125c6.185-9.49875 15.54125-14.2475 27.8975-14.2475 10.6775 0 19.28 3.75375 25.85 11.07625 6.36875 7.3225 9.54 17.22 9.54 29.675" fill="#fff"/></svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216.41507 232.00976"><path d="M211.80683 139.0875c-3.1825 16.36625-28.4925 34.2775-57.5625 37.74875-15.16 1.80875-30.0825 3.47125-45.99875 2.74125-26.0275-1.1925-46.565-6.2125-46.565-6.2125 0 2.53375.15625 4.94625.46875 7.2025 3.38375 25.68625 25.47 27.225 46.3925 27.9425 21.115.7225 39.91625-5.20625 39.91625-5.20625l.86875 19.09s-14.77 7.93125-41.08125 9.39c-14.50875.7975-32.52375-.365-53.50625-5.91875C9.23183 213.82 1.40558 165.31125.20808 116.09125c-.36375-14.61375-.14-28.39375-.14-39.91875 0-50.33 32.97625-65.0825 32.97625-65.0825C49.67058 3.45375 78.20308.2425 107.86433 0h.72875c29.66125.2425 58.21125 3.45375 74.8375 11.09 0 0 32.97625 14.7525 32.97625 65.0825 0 0 .4125 37.13375-4.6 62.915" fill="#3088d4"/><path d="M65.68743 96.45938c0 9.01375-7.3075 16.32125-16.3225 16.32125-9.01375 0-16.32-7.3075-16.32-16.32125 0-9.01375 7.30625-16.3225 16.32-16.3225 9.015 0 16.3225 7.30875 16.3225 16.3225M124.52893 96.45938c0 9.01375-7.30875 16.32125-16.3225 16.32125-9.01375 0-16.32125-7.3075-16.32125-16.32125 0-9.01375 7.3075-16.3225 16.32125-16.3225 9.01375 0 16.3225 7.30875 16.3225 16.3225M183.36933 96.45938c0 9.01375-7.3075 16.32125-16.32125 16.32125-9.01375 0-16.32125-7.3075-16.32125-16.32125 0-9.01375 7.3075-16.3225 16.32125-16.3225 9.01375 0 16.32125 7.30875 16.32125 16.3225" fill="#fff"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="61.077141mm" height="65.47831mm" viewBox="0 0 216.41507 232.00976"><path d="M211.80683 139.0875c-3.1825 16.36625-28.4925 34.2775-57.5625 37.74875-15.16 1.80875-30.0825 3.47125-45.99875 2.74125-26.0275-1.1925-46.565-6.2125-46.565-6.2125 0 2.53375.15625 4.94625.46875 7.2025 3.38375 25.68625 25.47 27.225 46.3925 27.9425 21.115.7225 39.91625-5.20625 39.91625-5.20625l.86875 19.09s-14.77 7.93125-41.08125 9.39c-14.50875.7975-32.52375-.365-53.50625-5.91875C9.23183 213.82 1.40558 165.31125.20808 116.09125c-.36375-14.61375-.14-28.39375-.14-39.91875 0-50.33 32.97625-65.0825 32.97625-65.0825C49.67058 3.45375 78.20308.2425 107.86433 0h.72875c29.66125.2425 58.21125 3.45375 74.8375 11.09 0 0 32.97625 14.7525 32.97625 65.0825 0 0 .4125 37.13375-4.6 62.915" fill="#3088d4"/><path d="M65.68743 96.45938c0 9.01375-7.3075 16.32125-16.3225 16.32125-9.01375 0-16.32-7.3075-16.32-16.32125 0-9.01375 7.30625-16.3225 16.32-16.3225 9.015 0 16.3225 7.30875 16.3225 16.3225M124.52893 96.45938c0 9.01375-7.30875 16.32125-16.3225 16.32125-9.01375 0-16.32125-7.3075-16.32125-16.32125 0-9.01375 7.3075-16.3225 16.32125-16.3225 9.01375 0 16.3225 7.30875 16.3225 16.3225M183.36933 96.45938c0 9.01375-7.3075 16.32125-16.32125 16.32125-9.01375 0-16.32125-7.3075-16.32125-16.32125 0-9.01375 7.3075-16.3225 16.32125-16.3225 9.01375 0 16.32125 7.30875 16.32125 16.3225" fill="#fff"/></svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 34 KiB |
BIN
app/javascript/images/mastodon_small.jpg
Normal file
|
After Width: | Height: | Size: 25 KiB |