From 0700d32a6ffc3e482bb002b538bda7c6e91ca691 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 9 Jun 2018 13:52:13 +0200 Subject: [PATCH 01/64] Add an apache build --- Dockerfile.apache | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Dockerfile.apache diff --git a/Dockerfile.apache b/Dockerfile.apache new file mode 100644 index 000000000..5cc31d739 --- /dev/null +++ b/Dockerfile.apache @@ -0,0 +1,31 @@ +FROM php:7-apache + +ARG COMPOSER_VERSION="1.6.5" +ARG COMPOSER_CHECKSUM="67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef0be3434" + +RUN apt-get update \ + && apt-get install -y --no-install-recommends libmagickwand-dev git \ + && docker-php-ext-install pdo_mysql pcntl \ + && pecl install imagick \ + && docker-php-ext-enable imagick pcntl imagick \ + && curl -LsS https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /tmp/composer.phar \ + && echo "${COMPOSER_CHECKSUM} /tmp/composer.phar" | sha256sum -c - \ + && install -m0755 -o root -g root /tmp/composer.phar /usr/bin/composer.phar \ + && ln -sf /usr/bin/composer.phar /usr/bin/composer \ + && rm /tmp/composer.phar + +COPY . /var/www/html/ + +WORKDIR /var/www/html +RUN install -d -m0755 -o www-data -g www-data \ + /var/www/html/storage \ + /var/www/html/storage/framework \ + /var/www/html/storage/logs \ + /var/www/html/storage/framework/sessions \ + /var/www/html/storage/framework/views \ + /var/www/html/storage/framework/cache && \ + composer install --prefer-source --no-interaction + +VOLUME ["/var/www/html"] + +ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" From d76851732a91256026cabf3dd2dca7e7debea820 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 9 Jun 2018 15:18:44 +0200 Subject: [PATCH 02/64] Set a proper path for public documents --- Dockerfile.apache | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Dockerfile.apache b/Dockerfile.apache index 5cc31d739..e41ffd1b2 100644 --- a/Dockerfile.apache +++ b/Dockerfile.apache @@ -14,18 +14,19 @@ RUN apt-get update \ && ln -sf /usr/bin/composer.phar /usr/bin/composer \ && rm /tmp/composer.phar -COPY . /var/www/html/ +COPY . /var/www/ -WORKDIR /var/www/html +WORKDIR /var/www/ RUN install -d -m0755 -o www-data -g www-data \ - /var/www/html/storage \ - /var/www/html/storage/framework \ - /var/www/html/storage/logs \ - /var/www/html/storage/framework/sessions \ - /var/www/html/storage/framework/views \ - /var/www/html/storage/framework/cache && \ - composer install --prefer-source --no-interaction + /var/www/storage \ + /var/www/storage/framework \ + /var/www/storage/logs \ + /var/www/storage/framework/sessions \ + /var/www/storage/framework/views \ + /var/www/storage/framework/cache \ + && composer install --prefer-source --no-interaction \ + && rm -rf html && mv public html -VOLUME ["/var/www/html"] +VOLUME ["/var/www/storage"] ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" From b005b3a22cf73f74650660fb4603cabfe96ffc0a Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 9 Jun 2018 17:41:26 +0200 Subject: [PATCH 03/64] Link html to public instead of renaming --- Dockerfile.apache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.apache b/Dockerfile.apache index e41ffd1b2..7b00d420e 100644 --- a/Dockerfile.apache +++ b/Dockerfile.apache @@ -25,7 +25,7 @@ RUN install -d -m0755 -o www-data -g www-data \ /var/www/storage/framework/views \ /var/www/storage/framework/cache \ && composer install --prefer-source --no-interaction \ - && rm -rf html && mv public html + && rm -rf html && ln -s public html VOLUME ["/var/www/storage"] From be13d1aa980934919a76b8226ea8a5f5701c05a5 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 9 Jun 2018 17:45:57 +0200 Subject: [PATCH 04/64] Enable apache rewrite mod --- Dockerfile.apache | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.apache b/Dockerfile.apache index 7b00d420e..bc26b7e54 100644 --- a/Dockerfile.apache +++ b/Dockerfile.apache @@ -8,6 +8,7 @@ RUN apt-get update \ && docker-php-ext-install pdo_mysql pcntl \ && pecl install imagick \ && docker-php-ext-enable imagick pcntl imagick \ + && a2enmod rewrite \ && curl -LsS https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /tmp/composer.phar \ && echo "${COMPOSER_CHECKSUM} /tmp/composer.phar" | sha256sum -c - \ && install -m0755 -o root -g root /tmp/composer.phar /usr/bin/composer.phar \ From 1af0b8abbb0da9eaf5a78467d581e9563bbef984 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sun, 10 Jun 2018 20:06:22 +0200 Subject: [PATCH 05/64] Configure trust proxies --- config/trustproxies.php | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 config/trustproxies.php diff --git a/config/trustproxies.php b/config/trustproxies.php new file mode 100644 index 000000000..44ddf94a8 --- /dev/null +++ b/config/trustproxies.php @@ -0,0 +1,56 @@ +getClientIp() + * always gets the originating client IP, no matter + * how many proxies that client's request has + * subsequently passed through. + */ + 'proxies' => explode(env('TRUST_PROXIES', ''), ','), + + /* + * Default Header Names + * + * Change these if the proxy does + * not send the default header names. + * + * Note that headers such as X-Forwarded-For + * are transformed to HTTP_X_FORWARDED_FOR format. + * + * The following are Symfony defaults, found in + * \Symfony\Component\HttpFoundation\Request::$trustedHeaders + * + * You may optionally set headers to 'null' here if you'd like + * for them to be considered untrusted instead. Ex: + * + * Illuminate\Http\Request::HEADER_CLIENT_HOST => null, + * + * WARNING: If you're using AWS Elastic Load Balancing or Heroku, + * the FORWARDED and X_FORWARDED_HOST headers should be set to null + * as they are currently unsupported there. + */ + 'headers' => [ + (defined('Illuminate\Http\Request::HEADER_FORWARDED') ? Illuminate\Http\Request::HEADER_FORWARDED : 'forwarded') => 'FORWARDED', + Illuminate\Http\Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', + Illuminate\Http\Request::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST', + Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO', + Illuminate\Http\Request::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT', + ] +]; From 994aed07521c53109a3bce37107492762703f4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Fri, 8 Jun 2018 22:29:57 -0700 Subject: [PATCH 06/64] Add info about max bio length, make names length customizable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak --- .../Controllers/Auth/RegisterController.php | 2 +- app/Http/Controllers/SettingsController.php | 4 ++-- config/pixelfed.php | 24 +++++++++++++++++-- resources/views/settings/home.blade.php | 5 +++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 1b9de0513..6d6f4d535 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -54,7 +54,7 @@ class RegisterController extends Controller $rules = [ - 'name' => 'required|string|max:255', + 'name' => 'required|string|max' . config('pixelfed.max_name_length'), 'username' => 'required|alpha_dash|min:2|max:15|unique:users', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:6|confirmed', diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 4beb45418..c367fdd7d 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -21,8 +21,8 @@ class SettingsController extends Controller public function homeUpdate(Request $request) { $this->validate($request, [ - 'name' => 'required|string|max:30', - 'bio' => 'nullable|string|max:125' + 'name' => 'required|string|max:' . config('pixelfed.max_name_length'), + 'bio' => 'nullable|string|max:' . config('pixelfed.max_bio_length') ]); $changes = false; diff --git a/config/pixelfed.php b/config/pixelfed.php index 9a872e74c..fcac7d0e5 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -96,5 +96,25 @@ return [ | */ 'max_caption_length' => env('MAX_CAPTION_LENGTH', 150), - -]; \ No newline at end of file + + /* + |-------------------------------------------------------------------------- + | Bio length limit + |-------------------------------------------------------------------------- + | + | Change the bio length limit for user profiles. + | + */ + 'max_bio_length' => env('MAX_BIO_LENGTH', 125), + + /* + |-------------------------------------------------------------------------- + | User name length limit + |-------------------------------------------------------------------------- + | + | Change the length limit for user names. + | + */ + 'max_name_length' => env('MAX_NAME_LENGTH', 30), + +]; diff --git a/resources/views/settings/home.blade.php b/resources/views/settings/home.blade.php index ec451b6bb..d8642b60f 100644 --- a/resources/views/settings/home.blade.php +++ b/resources/views/settings/home.blade.php @@ -24,6 +24,9 @@
+ + Max length: {{config('pixelfed.max_bio_length')}} characters. +
@@ -86,4 +89,4 @@
-@endsection \ No newline at end of file +@endsection From eddeb5e7886793a9d4c6268338695445f09c7acc Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Tue, 12 Jun 2018 20:49:52 +0200 Subject: [PATCH 07/64] Improve the support for a trust proxy --- config/trustedproxy.php | 27 ++++++++++++++++++++ config/trustproxies.php | 56 ----------------------------------------- 2 files changed, 27 insertions(+), 56 deletions(-) create mode 100644 config/trustedproxy.php delete mode 100644 config/trustproxies.php diff --git a/config/trustedproxy.php b/config/trustedproxy.php new file mode 100644 index 000000000..c1760266c --- /dev/null +++ b/config/trustedproxy.php @@ -0,0 +1,27 @@ +getClientIp() + * always gets the originating client IP, no matter + * how many proxies that client's request has + * subsequently passed through. + */ + 'proxies' => explode(env('TRUST_PROXIES', ''), ','), +]; diff --git a/config/trustproxies.php b/config/trustproxies.php deleted file mode 100644 index 44ddf94a8..000000000 --- a/config/trustproxies.php +++ /dev/null @@ -1,56 +0,0 @@ -getClientIp() - * always gets the originating client IP, no matter - * how many proxies that client's request has - * subsequently passed through. - */ - 'proxies' => explode(env('TRUST_PROXIES', ''), ','), - - /* - * Default Header Names - * - * Change these if the proxy does - * not send the default header names. - * - * Note that headers such as X-Forwarded-For - * are transformed to HTTP_X_FORWARDED_FOR format. - * - * The following are Symfony defaults, found in - * \Symfony\Component\HttpFoundation\Request::$trustedHeaders - * - * You may optionally set headers to 'null' here if you'd like - * for them to be considered untrusted instead. Ex: - * - * Illuminate\Http\Request::HEADER_CLIENT_HOST => null, - * - * WARNING: If you're using AWS Elastic Load Balancing or Heroku, - * the FORWARDED and X_FORWARDED_HOST headers should be set to null - * as they are currently unsupported there. - */ - 'headers' => [ - (defined('Illuminate\Http\Request::HEADER_FORWARDED') ? Illuminate\Http\Request::HEADER_FORWARDED : 'forwarded') => 'FORWARDED', - Illuminate\Http\Request::HEADER_CLIENT_IP => 'X_FORWARDED_FOR', - Illuminate\Http\Request::HEADER_CLIENT_HOST => 'X_FORWARDED_HOST', - Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO', - Illuminate\Http\Request::HEADER_CLIENT_PORT => 'X_FORWARDED_PORT', - ] -]; From b412616c285cd0258c469956d38aaf52670034dc Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Tue, 12 Jun 2018 20:56:42 +0200 Subject: [PATCH 08/64] Add a start script and automatically migrate the db --- Dockerfile.apache => docker/Dockerfile.apache | 2 ++ Dockerfile => docker/Dockerfile.fpm | 0 docker/start.sh | 6 ++++++ 3 files changed, 8 insertions(+) rename Dockerfile.apache => docker/Dockerfile.apache (97%) rename Dockerfile => docker/Dockerfile.fpm (100%) create mode 100755 docker/start.sh diff --git a/Dockerfile.apache b/docker/Dockerfile.apache similarity index 97% rename from Dockerfile.apache rename to docker/Dockerfile.apache index bc26b7e54..8450d7792 100644 --- a/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -31,3 +31,5 @@ RUN install -d -m0755 -o www-data -g www-data \ VOLUME ["/var/www/storage"] ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" + +CMD /var/www/docker/start.sh diff --git a/Dockerfile b/docker/Dockerfile.fpm similarity index 100% rename from Dockerfile rename to docker/Dockerfile.fpm diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 000000000..bbf6327be --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mkdir -p storage/framework/{cache,sessions,views,logs} +php artisan migrate + +exec apache2-foreground From 91a8f919de189554baf753f0ca1182f34da03665 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Tue, 12 Jun 2018 21:48:14 +0200 Subject: [PATCH 09/64] Fix a typo in the proxy configuration --- config/trustedproxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/trustedproxy.php b/config/trustedproxy.php index c1760266c..0a0776ada 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -23,5 +23,5 @@ return [ * how many proxies that client's request has * subsequently passed through. */ - 'proxies' => explode(env('TRUST_PROXIES', ''), ','), + 'proxies' => explode(',', env('TRUST_PROXIES', '')), ]; From 9cc3406a12285d60e546efaaca031c24b6ef248b Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Tue, 12 Jun 2018 22:48:43 +0200 Subject: [PATCH 10/64] Create missing directories in storage --- docker/start.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/start.sh b/docker/start.sh index bbf6327be..962bcb6f7 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,6 +1,8 @@ #!/bin/sh -mkdir -p storage/framework/{cache,sessions,views,logs} +mkdir -p storage/app/public/avatars +mkdir -p storage/{debugbar,logs} +mkdir -p storage/framework/{cache,sessions,views,testing} php artisan migrate exec apache2-foreground From ecd867fa304d7feed22f83202e64a341be5be63b Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 09:02:46 +0200 Subject: [PATCH 11/64] Add a Dockerfile symlink for automated builds --- Dockerfile | 1 + 1 file changed, 1 insertion(+) create mode 120000 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 120000 index 000000000..098369ddb --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +docker/Dockerfile.apache \ No newline at end of file From 964b8e5d6365582bb6fbbe12edb910c8029d0a03 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 09:50:38 +0200 Subject: [PATCH 12/64] Handle storage folder creation properly --- docker/Dockerfile.apache | 8 +++++--- docker/start.sh | 8 +++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index 8450d7792..9839ad303 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -5,7 +5,7 @@ ARG COMPOSER_CHECKSUM="67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef RUN apt-get update \ && apt-get install -y --no-install-recommends libmagickwand-dev git \ - && docker-php-ext-install pdo_mysql pcntl \ + && docker-php-ext-install pdo_mysql pcntl gd \ && pecl install imagick \ && docker-php-ext-enable imagick pcntl imagick \ && a2enmod rewrite \ @@ -15,6 +15,8 @@ RUN apt-get update \ && ln -sf /usr/bin/composer.phar /usr/bin/composer \ && rm /tmp/composer.phar +ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" + COPY . /var/www/ WORKDIR /var/www/ @@ -25,11 +27,11 @@ RUN install -d -m0755 -o www-data -g www-data \ /var/www/storage/framework/sessions \ /var/www/storage/framework/views \ /var/www/storage/framework/cache \ + && cp -r storage storage.skel \ + && cp docker/env .env \ && composer install --prefer-source --no-interaction \ && rm -rf html && ln -s public html VOLUME ["/var/www/storage"] -ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" - CMD /var/www/docker/start.sh diff --git a/docker/start.sh b/docker/start.sh index 962bcb6f7..5925d3f28 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,8 +1,6 @@ -#!/bin/sh +#!/bin/bash -mkdir -p storage/app/public/avatars -mkdir -p storage/{debugbar,logs} -mkdir -p storage/framework/{cache,sessions,views,testing} -php artisan migrate +cp -r storage.skel/* storage/ +php artisan migrate --force exec apache2-foreground From b956675977ef8bd8ab9642b3ed16a84ea45dd0ad Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 09:58:56 +0200 Subject: [PATCH 13/64] Add missing env file --- docker/env | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docker/env diff --git a/docker/env b/docker/env new file mode 100644 index 000000000..03a4edb9f --- /dev/null +++ b/docker/env @@ -0,0 +1,49 @@ +APP_NAME="${APP_NAME}" +APP_ENV=local +APP_KEY="${APP_KEY}" +APP_DEBUG=false +APP_URL=${APP_URL} + +LOG_CHANNEL=stack + +DB_CONNECTION=mysql +DB_HOST=${DB_HOST} +DB_PORT=3306 +DB_DATABASE="${DB_DATABASE}" +DB_USERNAME="${DB_USERNAME}" +DB_PASSWORD="${DB_PASSWORD}" + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=120 +QUEUE_DRIVER=sync + +REDIS_HOST="${REDIS_HOST}" +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_DRIVER=smtp +MAIL_HOST=${MAIL_HOST} +MAIL_PORT="${MAIL_PORT}" +MAIL_USERNAME="${MAIL_USERNAME}" +MAIL_PASSWORD="${MAIL_PASSWORD}" +MAIL_ENCRYPTION="${MAIL_ENCRYPTION}" + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +SESSION_DOMAIN="${SESSION_DOMAIN}" +SESSION_SECURE_COOKIE=true +API_BASE="/api/1/" +API_SEARCH="/api/search" + +OPEN_REGISTRATION=true + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" +MIX_APP_URL="${APP_URL}" +MIX_API_BASE="${API_BASE}" +MIX_API_SEARCH="${API_SEARCH}" From 862e9231d1d8ca05a86164c6649332edc6e646c5 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 10:35:38 +0200 Subject: [PATCH 14/64] Use the storage structure from git --- .dockerignore | 1 - docker/Dockerfile.apache | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index e47e3356b..559772097 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -storage data Dockerfile docker-compose*.yml diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index 9839ad303..0a95c2f81 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -20,13 +20,8 @@ ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" COPY . /var/www/ WORKDIR /var/www/ -RUN install -d -m0755 -o www-data -g www-data \ - /var/www/storage \ - /var/www/storage/framework \ - /var/www/storage/logs \ - /var/www/storage/framework/sessions \ - /var/www/storage/framework/views \ - /var/www/storage/framework/cache \ +RUN find storage -name .gitignore -exec rm {} + \ + && chown -R www-data:www-data /var/www/storage && cp -r storage storage.skel \ && cp docker/env .env \ && composer install --prefer-source --no-interaction \ From a70ec47ef1ccad10d7b5c255bc2eb08122417159 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 12:23:13 +0200 Subject: [PATCH 15/64] Build gd with jpeg support --- docker/Dockerfile.apache | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index 0a95c2f81..16f80aa6d 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -5,8 +5,14 @@ ARG COMPOSER_CHECKSUM="67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef RUN apt-get update \ && apt-get install -y --no-install-recommends libmagickwand-dev git \ + libfreetype6-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev \ && docker-php-ext-install pdo_mysql pcntl gd \ && pecl install imagick \ + && docker-php-ext-configure gd \ + --with-freetype-dir=/usr/lib/x86_64-linux-gnu/ \ + --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \ + --with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \ + --with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \ && docker-php-ext-enable imagick pcntl imagick \ && a2enmod rewrite \ && curl -LsS https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /tmp/composer.phar \ @@ -21,7 +27,7 @@ COPY . /var/www/ WORKDIR /var/www/ RUN find storage -name .gitignore -exec rm {} + \ - && chown -R www-data:www-data /var/www/storage + && chown -R www-data:www-data /var/www/storage \ && cp -r storage storage.skel \ && cp docker/env .env \ && composer install --prefer-source --no-interaction \ From 583abdf37a1718725860eccd5c07f5a0729b8cda Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 22:27:45 +0200 Subject: [PATCH 16/64] Include missing dependencies for image optimization, slim the image and run horizon --- docker/Dockerfile.apache | 29 ++++++++++++++++------------- docker/env | 11 ++++++++++- docker/start.sh | 3 +++ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index 16f80aa6d..ce9afc73b 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -4,31 +4,34 @@ ARG COMPOSER_VERSION="1.6.5" ARG COMPOSER_CHECKSUM="67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef0be3434" RUN apt-get update \ - && apt-get install -y --no-install-recommends libmagickwand-dev git \ - libfreetype6-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev \ - && docker-php-ext-install pdo_mysql pcntl gd \ - && pecl install imagick \ + && apt-get install -y --no-install-recommends git \ + optipng pngquant jpegoptim gifsicle \ + libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libmagickwand-6.q16-3 \ + libfreetype6-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libmagickwand-dev \ + && docker-php-source extract \ && docker-php-ext-configure gd \ --with-freetype-dir=/usr/lib/x86_64-linux-gnu/ \ --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \ --with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \ --with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \ - && docker-php-ext-enable imagick pcntl imagick \ + && docker-php-ext-install pdo_mysql pcntl gd exif \ + && pecl install imagick \ + && docker-php-ext-enable imagick pcntl imagick gd exif \ && a2enmod rewrite \ - && curl -LsS https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /tmp/composer.phar \ - && echo "${COMPOSER_CHECKSUM} /tmp/composer.phar" | sha256sum -c - \ - && install -m0755 -o root -g root /tmp/composer.phar /usr/bin/composer.phar \ - && ln -sf /usr/bin/composer.phar /usr/bin/composer \ - && rm /tmp/composer.phar + && curl -LsS https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /usr/bin/composer \ + && echo "${COMPOSER_CHECKSUM} /usr/bin/composer" | sha256sum -c - \ + && chmod 755 /usr/bin/composer \ + && apt-get autoremove --purge -y \ + libfreetype6-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libmagickwand-dev \ + && rm -rf /var/cache/apt \ + && docker-php-source delete ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" COPY . /var/www/ WORKDIR /var/www/ -RUN find storage -name .gitignore -exec rm {} + \ - && chown -R www-data:www-data /var/www/storage \ - && cp -r storage storage.skel \ +RUN cp -r storage storage.skel \ && cp docker/env .env \ && composer install --prefer-source --no-interaction \ && rm -rf html && ln -s public html diff --git a/docker/env b/docker/env index 03a4edb9f..0f2f9c597 100644 --- a/docker/env +++ b/docker/env @@ -40,7 +40,16 @@ SESSION_SECURE_COOKIE=true API_BASE="/api/1/" API_SEARCH="/api/search" -OPEN_REGISTRATION=true +OPEN_REGISTRATION=${OPEN_REGISTRATION} +MAX_CAPTION_LENGTH=${MAX_CAPTION_LENGTH} +MAX_PHOTO_SIZE=${MAX_PHOTO_SIZE} +ENFORCE_EMAIL_VERIFICATION=${ENFORCE_EMAIL_VERIFICATION} +REMOTE_FOLLOW=${REMOTE_FOLLOW} +ACTIVITY_PUB=${ACTIVITY_PUB} + +RECAPTCHA_ENABLED=${RECAPTCHA_ENABLED} +RECAPTCHA_PUBLIC_KEY=${RECAPTCHA_PUBLIC_KEY} +RECAPTCHA_PRIVATE_KEY=${RECAPTCHA_PRIVATE_KEY} MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/docker/start.sh b/docker/start.sh index 5925d3f28..e716d8ee0 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,6 +1,9 @@ #!/bin/bash cp -r storage.skel/* storage/ +chown -R www-data:www-data storage/ php artisan migrate --force +php artisan storage:link +php artisan horizon & exec apache2-foreground From 4998830fa1d0de7629447f732543ae6103cb4a7c Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 22:31:16 +0200 Subject: [PATCH 17/64] Update the docker compose to use the apache image --- docker-compose.yml | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8e9ccd4c1..3867c2029 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,35 +1,28 @@ --- version: '3' services: - nginx: - image: nginx:alpine - networks: - - internal - - external - ports: - - 3000:80 - volumes: - - "php-storage:/var/www/html" - - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf - depends_on: - - php - php: + pixelfed: build: . image: pixelfed volumes: - "php-storage:/var/www/html" networks: + - external - internal environment: + # The full list of available variables is documented in docker/env - DB_HOST=mysql - DB_DATABASE=pixelfed - DB_USERNAME=${DB_USERNAME:-pixelfed} - DB_PASSWORD=${DB_PASSWORD:-pixelfed} - REDIS_HOST=redis - - APP_KEY=${APP_KEY} - env_file: - - ./.env + - APP_KEY=SetYourAppKeyHere + - APP_NAME=Pixelfed + - APP_URL=https://your.url + - MAIL_HOST=mail.host + - MAIL_FROM_ADDRESS=noreply@your.url + - MAIL_FROM_NAME=Pixelfed mysql: image: mysql:5.7 @@ -40,8 +33,6 @@ services: - MYSQL_USER=${DB_USERNAME:-pixelfed} - MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed} - MYSQL_RANDOM_ROOT_PASSWORD="true" - env_file: - - ./.env volumes: - "mysql-data:/var/lib/mysql" From d327aeba2b74d171ebbb640c9c9fb1c2e311677f Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sat, 16 Jun 2018 23:51:33 +0200 Subject: [PATCH 18/64] Enable redis queuing by default and link horizon properly --- docker/env | 5 +++-- docker/start.sh | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/env b/docker/env index 0f2f9c597..a42252474 100644 --- a/docker/env +++ b/docker/env @@ -4,7 +4,7 @@ APP_KEY="${APP_KEY}" APP_DEBUG=false APP_URL=${APP_URL} -LOG_CHANNEL=stack +LOG_CHANNEL=stderr DB_CONNECTION=mysql DB_HOST=${DB_HOST} @@ -17,7 +17,8 @@ BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file SESSION_LIFETIME=120 -QUEUE_DRIVER=sync +QUEUE_DRIVER=redis +HORIZON_PREFIX=horizon-pixelfed REDIS_HOST="${REDIS_HOST}" REDIS_PASSWORD=null diff --git a/docker/start.sh b/docker/start.sh index e716d8ee0..a2165980e 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -o allexport +source .env +set +o allexport + cp -r storage.skel/* storage/ chown -R www-data:www-data storage/ php artisan migrate --force From cce25eb77123d1608a995a6097ace64572e7d7ba Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Sun, 17 Jun 2018 10:20:21 +0200 Subject: [PATCH 19/64] Use environment variables only (no .env file) and separate horizon --- docker-compose.yml | 63 +++++++++++++++++++++++++--------------- docker/Dockerfile.apache | 19 +++++++++++- docker/env | 59 ------------------------------------- docker/start.sh | 16 ++++++---- 4 files changed, 68 insertions(+), 89 deletions(-) delete mode 100644 docker/env diff --git a/docker-compose.yml b/docker-compose.yml index 3867c2029..884b8bd4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,40 +1,56 @@ --- version: '3' + +# In order to set configuration, please use a .env file in +# your compose project directory (the same directory as your +# docker-compose.yml), and set database options, application +# name, key, and other settings there. +# A list of available settings is available in .env.example +# +# The services should scale properly across a swarm cluster +# if the volumes are properly shared between cluster members. + services: - pixelfed: - build: . + app: + # Uncomment to build a local copy of the image + # build: . image: pixelfed + # If you have a traefik running, uncomment this to expose Pixelfed + # labels: + # - traefik.enable=true + # - traefik.frontend.rule=Host:your.url + # - traefik.port=80 + env_file: + - ./.env volumes: - - "php-storage:/var/www/html" + - "app-storage:/var/www/storage" networks: - external - internal - environment: - # The full list of available variables is documented in docker/env - - DB_HOST=mysql - - DB_DATABASE=pixelfed - - DB_USERNAME=${DB_USERNAME:-pixelfed} - - DB_PASSWORD=${DB_PASSWORD:-pixelfed} - - REDIS_HOST=redis - - APP_KEY=SetYourAppKeyHere - - APP_NAME=Pixelfed - - APP_URL=https://your.url - - MAIL_HOST=mail.host - - MAIL_FROM_ADDRESS=noreply@your.url - - MAIL_FROM_NAME=Pixelfed - mysql: + # Uncomment if you set HORIZON_EMBED to false and wish to run a local worker + # worker: + # image: pixelfed + # env_file: + # - ./.env + # volumes: + # - "app-storage:/var/www/storage" + # networks: + # - internal + # command: php artisan horizon + + db: image: mysql:5.7 networks: - internal environment: - MYSQL_DATABASE=pixelfed - - MYSQL_USER=${DB_USERNAME:-pixelfed} - - MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed} - - MYSQL_RANDOM_ROOT_PASSWORD="true" + - MYSQL_USER=${DB_USERNAME} + - MYSQL_PASSWORD=${DB_PASSWORD} + - MYSQL_RANDOM_ROOT_PASSWORD=true volumes: - - "mysql-data:/var/lib/mysql" + - "db-data:/var/lib/mysql" redis: image: redis:alpine @@ -43,10 +59,11 @@ services: networks: - internal +# Adjust your volume data in order to store data where you wish volumes: redis-data: - mysql-data: - php-storage: + db-data: + app-storage: networks: internal: diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index ce9afc73b..03cbbddfc 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -32,10 +32,27 @@ COPY . /var/www/ WORKDIR /var/www/ RUN cp -r storage storage.skel \ - && cp docker/env .env \ && composer install --prefer-source --no-interaction \ && rm -rf html && ln -s public html VOLUME ["/var/www/storage"] +ENV APP_ENV=production \ + APP_DEBUG=false \ + LOG_CHANNEL=stderr \ + DB_CONNECTION=mysql \ + DB_PORT=3306 \ + DB_HOST=db \ + BROADCAST_DRIVER=log \ + QUEUE_DRIVER=redis \ + HORIZON_PREFIX=horizon-pixelfed \ + REDIS_HOST=redis \ + SESSION_SECURE_COOKIE=true \ + API_BASE="/api/1/" \ + API_SEARCH="/api/search" \ + OPEN_REGISTRATION=true \ + ENFORCE_EMAIL_VERIFICATION=true \ + REMOTE_FOLLOW=false \ + ACTIVITY_PUB=false + CMD /var/www/docker/start.sh diff --git a/docker/env b/docker/env deleted file mode 100644 index a42252474..000000000 --- a/docker/env +++ /dev/null @@ -1,59 +0,0 @@ -APP_NAME="${APP_NAME}" -APP_ENV=local -APP_KEY="${APP_KEY}" -APP_DEBUG=false -APP_URL=${APP_URL} - -LOG_CHANNEL=stderr - -DB_CONNECTION=mysql -DB_HOST=${DB_HOST} -DB_PORT=3306 -DB_DATABASE="${DB_DATABASE}" -DB_USERNAME="${DB_USERNAME}" -DB_PASSWORD="${DB_PASSWORD}" - -BROADCAST_DRIVER=log -CACHE_DRIVER=file -SESSION_DRIVER=file -SESSION_LIFETIME=120 -QUEUE_DRIVER=redis -HORIZON_PREFIX=horizon-pixelfed - -REDIS_HOST="${REDIS_HOST}" -REDIS_PASSWORD=null -REDIS_PORT=6379 - -MAIL_DRIVER=smtp -MAIL_HOST=${MAIL_HOST} -MAIL_PORT="${MAIL_PORT}" -MAIL_USERNAME="${MAIL_USERNAME}" -MAIL_PASSWORD="${MAIL_PASSWORD}" -MAIL_ENCRYPTION="${MAIL_ENCRYPTION}" - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_APP_CLUSTER=mt1 - -SESSION_DOMAIN="${SESSION_DOMAIN}" -SESSION_SECURE_COOKIE=true -API_BASE="/api/1/" -API_SEARCH="/api/search" - -OPEN_REGISTRATION=${OPEN_REGISTRATION} -MAX_CAPTION_LENGTH=${MAX_CAPTION_LENGTH} -MAX_PHOTO_SIZE=${MAX_PHOTO_SIZE} -ENFORCE_EMAIL_VERIFICATION=${ENFORCE_EMAIL_VERIFICATION} -REMOTE_FOLLOW=${REMOTE_FOLLOW} -ACTIVITY_PUB=${ACTIVITY_PUB} - -RECAPTCHA_ENABLED=${RECAPTCHA_ENABLED} -RECAPTCHA_PUBLIC_KEY=${RECAPTCHA_PUBLIC_KEY} -RECAPTCHA_PRIVATE_KEY=${RECAPTCHA_PRIVATE_KEY} - -MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" -MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" -MIX_APP_URL="${APP_URL}" -MIX_API_BASE="${API_BASE}" -MIX_API_SEARCH="${API_SEARCH}" diff --git a/docker/start.sh b/docker/start.sh index a2165980e..be374a914 100755 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,13 +1,17 @@ #!/bin/bash -set -o allexport -source .env -set +o allexport - +# Create the storage tree if needed and fix permissions cp -r storage.skel/* storage/ chown -R www-data:www-data storage/ -php artisan migrate --force php artisan storage:link -php artisan horizon & +# Migrate database if the app was upgraded +php artisan migrate --force + +# Run a worker if it is set as embedded +if [ HORIZON_EMBED = true ]; then + php artisan horizon & +fi + +# Finally run Apache exec apache2-foreground From a7b86d639078ac3a27cba72349959421d924e590 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Wed, 1 Aug 2018 22:36:28 +0200 Subject: [PATCH 20/64] Add the bcmath dependency, fix the Docker build --- docker/Dockerfile.apache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index 03cbbddfc..9772a6833 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -14,7 +14,7 @@ RUN apt-get update \ --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \ --with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \ --with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \ - && docker-php-ext-install pdo_mysql pcntl gd exif \ + && docker-php-ext-install pdo_mysql pcntl gd exif bcmath \ && pecl install imagick \ && docker-php-ext-enable imagick pcntl imagick gd exif \ && a2enmod rewrite \ From 47225b99df5b24a8d853be5b6eb7f58d01e34890 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Thu, 16 Aug 2018 04:56:37 +0200 Subject: [PATCH 21/64] Provide a PHP config file to set the upload limit --- docker/php.ini | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docker/php.ini diff --git a/docker/php.ini b/docker/php.ini new file mode 100644 index 000000000..7fc73c567 --- /dev/null +++ b/docker/php.ini @@ -0,0 +1,5 @@ +file_uploads = On +memory_limit = 64M +upload_max_filesize = 64M +post_max_size = 64M +max_execution_time = 600 From 577242423cce956a8120ff34755f0a305a2abf1f Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Mon, 20 Aug 2018 08:41:02 +0200 Subject: [PATCH 22/64] Fix search results look --- resources/assets/sass/custom.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index 5aa67fb47..90dbb8bbe 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -298,3 +298,13 @@ details summary::-webkit-details-marker { .profile-avatar img { object-fit: cover; } + +.tt-menu { + padding: 0 !important; + border-radius: 0 0 0.25rem 0.25rem !important; +} + +.tt-dataset .alert { + border: 0 !important; + border-radius: 0 !important; +} From 02197696dceb3871c72082899b7edf53bf71ac26 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Mon, 20 Aug 2018 15:42:49 +0200 Subject: [PATCH 23/64] Actually deploy the PHP configuration --- docker/Dockerfile.apache | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile.apache b/docker/Dockerfile.apache index 9772a6833..ef3e2e37e 100644 --- a/docker/Dockerfile.apache +++ b/docker/Dockerfile.apache @@ -32,6 +32,7 @@ COPY . /var/www/ WORKDIR /var/www/ RUN cp -r storage storage.skel \ + && cp /var/www/docker/php.ini /usr/local/etc/php/conf.d/pixelfed.ini \ && composer install --prefer-source --no-interaction \ && rm -rf html && ln -s public html From da27cc6ce3f81faf7f7baa9c48b11d5f0bc52951 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 22 Aug 2018 22:45:25 -0600 Subject: [PATCH 24/64] Add Crypto Unit Test --- tests/Unit/CryptoTest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/Unit/CryptoTest.php diff --git a/tests/Unit/CryptoTest.php b/tests/Unit/CryptoTest.php new file mode 100644 index 000000000..15ecac713 --- /dev/null +++ b/tests/Unit/CryptoTest.php @@ -0,0 +1,31 @@ +assertTrue(class_exists('\phpseclib\Crypt\RSA')); + } + + public function testRSASigning() + { + $rsa = new \phpseclib\Crypt\RSA(); + extract($rsa->createKey()); + $rsa->loadKey($privatekey); + $plaintext = 'pixelfed rsa test'; + $signature = $rsa->sign($plaintext); + $rsa->loadKey($publickey); + $this->assertTrue($rsa->verify($plaintext, $signature)); + } +} From 5224d7cd96327eddbb7b0610914bd79da1677cd4 Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Thu, 23 Aug 2018 22:43:47 +0200 Subject: [PATCH 25/64] Move Dockerfiles to contrib/ --- .dockerignore | 1 + Dockerfile | 2 +- {docker => contrib/docker}/Dockerfile.apache | 6 ++++-- {docker => contrib/docker}/Dockerfile.fpm | 0 {docker => contrib/docker}/php.ini | 0 {docker => contrib/docker}/start.sh | 0 6 files changed, 6 insertions(+), 3 deletions(-) rename {docker => contrib/docker}/Dockerfile.apache (94%) rename {docker => contrib/docker}/Dockerfile.fpm (100%) rename {docker => contrib/docker}/php.ini (100%) rename {docker => contrib/docker}/start.sh (100%) diff --git a/.dockerignore b/.dockerignore index 559772097..53c27d576 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,5 @@ data +contrib Dockerfile docker-compose*.yml .dockerignore diff --git a/Dockerfile b/Dockerfile index 098369ddb..2f722aa37 120000 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -docker/Dockerfile.apache \ No newline at end of file +contrib/docker/Dockerfile.apache \ No newline at end of file diff --git a/docker/Dockerfile.apache b/contrib/docker/Dockerfile.apache similarity index 94% rename from docker/Dockerfile.apache rename to contrib/docker/Dockerfile.apache index ef3e2e37e..7db56d9e8 100644 --- a/docker/Dockerfile.apache +++ b/contrib/docker/Dockerfile.apache @@ -32,10 +32,12 @@ COPY . /var/www/ WORKDIR /var/www/ RUN cp -r storage storage.skel \ - && cp /var/www/docker/php.ini /usr/local/etc/php/conf.d/pixelfed.ini \ && composer install --prefer-source --no-interaction \ && rm -rf html && ln -s public html +COPY contrib/docker/php.ini /usr/local/etc/php/conf.d/pixelfed.ini +COPY contrib/docker/start.sh /start.sh + VOLUME ["/var/www/storage"] ENV APP_ENV=production \ @@ -56,4 +58,4 @@ ENV APP_ENV=production \ REMOTE_FOLLOW=false \ ACTIVITY_PUB=false -CMD /var/www/docker/start.sh +CMD /start.sh diff --git a/docker/Dockerfile.fpm b/contrib/docker/Dockerfile.fpm similarity index 100% rename from docker/Dockerfile.fpm rename to contrib/docker/Dockerfile.fpm diff --git a/docker/php.ini b/contrib/docker/php.ini similarity index 100% rename from docker/php.ini rename to contrib/docker/php.ini diff --git a/docker/start.sh b/contrib/docker/start.sh similarity index 100% rename from docker/start.sh rename to contrib/docker/start.sh From c82d0fb3890f3b445e541feee204edccb464aa8e Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Thu, 23 Aug 2018 22:57:22 +0200 Subject: [PATCH 26/64] Fix the docker build --- .dockerignore | 2 +- contrib/docker/Dockerfile.apache | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 53c27d576..70376cdf4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ data -contrib Dockerfile +contrib/docker/Dockerfile.* docker-compose*.yml .dockerignore .git diff --git a/contrib/docker/Dockerfile.apache b/contrib/docker/Dockerfile.apache index 7db56d9e8..481db4647 100644 --- a/contrib/docker/Dockerfile.apache +++ b/contrib/docker/Dockerfile.apache @@ -32,12 +32,10 @@ COPY . /var/www/ WORKDIR /var/www/ RUN cp -r storage storage.skel \ + && cp contrib/docker/php.ini /usr/local/etc/php/conf.d/pixelfed.ini \ && composer install --prefer-source --no-interaction \ && rm -rf html && ln -s public html -COPY contrib/docker/php.ini /usr/local/etc/php/conf.d/pixelfed.ini -COPY contrib/docker/start.sh /start.sh - VOLUME ["/var/www/storage"] ENV APP_ENV=production \ @@ -58,4 +56,4 @@ ENV APP_ENV=production \ REMOTE_FOLLOW=false \ ACTIVITY_PUB=false -CMD /start.sh +CMD /var/www/contrib/docker/start.sh From 1d3cddc83116ceb261a4183c30585ff41d27ab87 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 18:28:16 -0600 Subject: [PATCH 27/64] Update profile localizations --- resources/lang/en/profile.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/lang/en/profile.php b/resources/lang/en/profile.php index 9fb9d10db..24278aba8 100644 --- a/resources/lang/en/profile.php +++ b/resources/lang/en/profile.php @@ -6,4 +6,7 @@ return [ 'emptyFollowing' => 'This user is not following anyone yet!', 'emptySaved' => 'You haven’t saved any post yet!', 'savedWarning' => 'Only you can see what you’ve saved', + 'privateProfileWarning' => 'This Account is Private', + 'alreadyFollow' => 'Already follow :username?', + 'loginToSeeProfile' => 'to see their photos and videos.', ]; From e91bd452d5a0c25ca7e546ec74afe9d396ebe9f4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 18:31:56 -0600 Subject: [PATCH 28/64] Add private profile layout --- resources/views/profile/private.blade.php | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 resources/views/profile/private.blade.php diff --git a/resources/views/profile/private.blade.php b/resources/views/profile/private.blade.php new file mode 100644 index 000000000..dda823e33 --- /dev/null +++ b/resources/views/profile/private.blade.php @@ -0,0 +1,33 @@ +@extends('layouts.app',['title' => $user->username . " on " . config('app.name')]) + +@section('content') + +@include('profile.partial.private-info') + +
+
+
+
+

+ {{__('profile.privateProfileWarning')}} +

+ + @if(Auth::check()) +

{{ __('profile.alreadyFollow', ['username'=>$user->username])}}

+

{{__('Log in')}}

+

{{__('profile.loginToSeeProfile')}}

+ @endif +
+
+
+
+ +@endsection + +@push('meta') + + +@if($user->remote_url) + +@endif +@endpush \ No newline at end of file From 05ca453ffc1482f8e574a3206c5019f0ed8b8e99 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 18:57:32 -0600 Subject: [PATCH 29/64] Update verify_email view --- resources/views/account/verify_email.blade.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/views/account/verify_email.blade.php b/resources/views/account/verify_email.blade.php index 99ae26f3c..f79cdfc5f 100644 --- a/resources/views/account/verify_email.blade.php +++ b/resources/views/account/verify_email.blade.php @@ -5,7 +5,12 @@
@if (session('status'))
- {{ session('status') }} +

{{ session('status') }}

+
+ @endif + @if (session('error')) +
+

{{ session('error') }}

@endif
From 3d7e38d02a97248ca7ffe020ab9e448bbb6aea9d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 18:58:41 -0600 Subject: [PATCH 30/64] Add admin reports view --- resources/views/admin/reports/home.blade.php | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 resources/views/admin/reports/home.blade.php diff --git a/resources/views/admin/reports/home.blade.php b/resources/views/admin/reports/home.blade.php new file mode 100644 index 000000000..bc1d7228d --- /dev/null +++ b/resources/views/admin/reports/home.blade.php @@ -0,0 +1,57 @@ +@extends('admin.partial.template') + +@section('section') +
+

Reports

+
+ +
+ + + + + + + + + + + + + + @foreach($reports as $report) + + + + + + @if(!$report->admin_seen) + + @else + + @endif + + + @endforeach + +
#ReporterTypeReportedStatusCreated
+ + {{$report->id}} + + {{$report->reporter->username}}{{$report->type}}{{str_limit($report->reported()->url(), 25)}}UnresolvedResolved{{$report->created_at->diffForHumans(null, true, true, true)}}
+
+ {{$reports->links()}} +
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file From c2f029a8906a90e7527fdf8f0320b9225eb3e8cf Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:01:02 -0600 Subject: [PATCH 31/64] Add admin report template view --- resources/views/admin/reports/show.blade.php | 167 +++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 resources/views/admin/reports/show.blade.php diff --git a/resources/views/admin/reports/show.blade.php b/resources/views/admin/reports/show.blade.php new file mode 100644 index 000000000..e199d00d6 --- /dev/null +++ b/resources/views/admin/reports/show.blade.php @@ -0,0 +1,167 @@ +@extends('admin.partial.template') + +@section('section') +
+

Report #{{$report->id}} - {{ucfirst($report->type)}}

+
+ +
+
+
Reported: {{$report->reported()->url()}}
+
Reported by: {{$report->reporter->username}} admin
+

+ Message: + {{$report->message ?? 'No message provided.'}} +

+ + @if(!$report->admin_seen) + Ignore + {{-- Request Mod Feedback --}} + Add CW + Unlist/Hide + Delete + Shadowban User + Ban User + @else +

Resolved {{$report->admin_seen->diffForHumans()}}

+ @endif +
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ Reporter +
+
    +
  • Joined {{$report->reporter->created_at->diffForHumans()}}
  • +
  • Total Reports: {{App\Report::whereProfileId($report->reporter->id)->count()}}
  • +
  • Total Reported: {{App\Report::whereReportedProfileId($report->reporter->id)->count()}}
  • +
+
+
+
+
+
+ Reported +
+
    +
  • Joined {{$report->reportedUser->created_at->diffForHumans()}}
  • +
  • Total Reports: {{App\Report::whereProfileId($report->reportedUser->id)->count()}}
  • +
  • Total Reported: {{App\Report::whereReportedProfileId($report->reportedUser->id)->count()}}
  • +
+
+
+
+
+
+
+
+ +{{--
+
+
+
+ +
+
+
+
+
+

admin ignored this report. 2m

+
+
+

admin ignored this report. 2m

+
+
+

admin ignored this report. 2m

+
+
+
+
+
--}} + + +{{--
+
+
+
+ +
+
+
+
+
+
+
+
+ [username]: {{str_limit('Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.', 150)}} 2m +
+
+
+
+
+
+ me: {{str_limit('Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.', 150)}} 2m +
+
+
+
+
+
+ me: {{str_limit('Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.', 150)}} 2m +
+
+
+
+
+ +
+
+
--}} +@endsection + +@push('scripts') + +@endpush \ No newline at end of file From 20293ca2584bfe7b276ddab80b974b1c04233e69 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:02:22 -0600 Subject: [PATCH 32/64] Add admin backup settings view --- .../views/admin/settings/backups.blade.php | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 resources/views/admin/settings/backups.blade.php diff --git a/resources/views/admin/settings/backups.blade.php b/resources/views/admin/settings/backups.blade.php new file mode 100644 index 000000000..7aa6ceba4 --- /dev/null +++ b/resources/views/admin/settings/backups.blade.php @@ -0,0 +1,74 @@ +@extends('admin.partial.template') + +@section('section') +
+

Site Backups

+
+
+
+
+
+
Settings
+
+
+
+ +
+ + +
+ + Enable automated backups with your own strategy. + +
+
+ + + + Select the backup frequency. + +
+
+ + + + You can use local, S3, or any S3 compatible object storage API to store backups. + +
+
+
+
+
+
+
+
Current Backups
+
+ @foreach($files as $file) + @if($file->isFile()) +
  • +

    {{$file->getFilename()}}

    +

    + + Size: {{App\Util\Lexer\PrettyNumber::convert($file->getSize())}} + + + Created: {{\Carbon\Carbon::createFromTimestamp($file->getMTime())->diffForHumans()}}

    + +

    +
  • + @endif + @endforeach +
    +
    + +
    +
    +@endsection \ No newline at end of file From 6344c8046243bce111cfa960ba12a89b25f81fc3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:04:20 -0600 Subject: [PATCH 33/64] Add admin maintenance settings view --- resources/views/admin/settings/maintenance.blade.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 resources/views/admin/settings/maintenance.blade.php diff --git a/resources/views/admin/settings/maintenance.blade.php b/resources/views/admin/settings/maintenance.blade.php new file mode 100644 index 000000000..9182e94d0 --- /dev/null +++ b/resources/views/admin/settings/maintenance.blade.php @@ -0,0 +1,9 @@ +@extends('admin.partial.template') + +@section('section') +
    +

    Maintenance

    +
    +
    + +@endsection \ No newline at end of file From ffb53df2fc113a20ff0caf74ca4f5c2bd4d72202 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:04:48 -0600 Subject: [PATCH 34/64] Add admin storage settings view --- .../views/admin/settings/storage.blade.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 resources/views/admin/settings/storage.blade.php diff --git a/resources/views/admin/settings/storage.blade.php b/resources/views/admin/settings/storage.blade.php new file mode 100644 index 000000000..294c84e3d --- /dev/null +++ b/resources/views/admin/settings/storage.blade.php @@ -0,0 +1,30 @@ +@extends('admin.partial.template') + +@section('section') +
    +

    Storage

    +
    +
    + +
    +
    +
    +
    +
    +
    + + Used: {{$storage->prettyTotal}} + + + {{$storage->percentUsed}}% Used + + + Free: {{$storage->prettyFree}} + +
    +
    + +
    +@endsection \ No newline at end of file From 2e1e1cf8fd005ac8b65a45fbaf4d88b3b2fd5901 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:06:15 -0600 Subject: [PATCH 35/64] Add admin system settings view --- .../views/admin/settings/system.blade.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 resources/views/admin/settings/system.blade.php diff --git a/resources/views/admin/settings/system.blade.php b/resources/views/admin/settings/system.blade.php new file mode 100644 index 000000000..b64f02a07 --- /dev/null +++ b/resources/views/admin/settings/system.blade.php @@ -0,0 +1,39 @@ +@extends('admin.partial.template') + +@section('section') +
    +

    System

    +
    +
    +
    +
    +
    +
    +

    {{config('pixelfed.version')}}

    +
    + +
    + +
    +
    +

    {{DB::select( DB::raw("select version()") )[0]->{'version()'} }}

    +
    + +
    +
    +
    +
    +
    +

    {{phpversion()}}

    +
    + +
    +{{--
    +
    +

    +
    + +
    --}} +
    +
    +@endsection \ No newline at end of file From eccef3fbdfb8f8f867c088120226c82e2156587a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:09:34 -0600 Subject: [PATCH 36/64] Add new nav partial --- resources/views/layouts/partial/noauthnav.blade.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 resources/views/layouts/partial/noauthnav.blade.php diff --git a/resources/views/layouts/partial/noauthnav.blade.php b/resources/views/layouts/partial/noauthnav.blade.php new file mode 100644 index 000000000..797f1362e --- /dev/null +++ b/resources/views/layouts/partial/noauthnav.blade.php @@ -0,0 +1,8 @@ + From 4b25418659217dafb720aac4072ca63adead2820 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:10:04 -0600 Subject: [PATCH 37/64] Add new base layout for non auth users --- resources/views/layouts/anon.blade.php | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 resources/views/layouts/anon.blade.php diff --git a/resources/views/layouts/anon.blade.php b/resources/views/layouts/anon.blade.php new file mode 100644 index 000000000..4621b821c --- /dev/null +++ b/resources/views/layouts/anon.blade.php @@ -0,0 +1,40 @@ + + + + + + + + + + + + + {{ $title or config('app.name', 'Laravel') }} + + @if(isset($title)) + + + + @endif + + @stack('meta') + + + + + + + + @stack('styles') + + + @include('layouts.partial.noauthnav') +
    + @yield('content') +
    + @include('layouts.partial.footer') + + @stack('scripts') + + From 119dab0cb1fe9229a49db2613b4a8b84ac9b3060 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:11:32 -0600 Subject: [PATCH 38/64] Add new profile partial for private profiles --- .../profile/partial/private-info.blade.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 resources/views/profile/partial/private-info.blade.php diff --git a/resources/views/profile/partial/private-info.blade.php b/resources/views/profile/partial/private-info.blade.php new file mode 100644 index 000000000..1e69755f1 --- /dev/null +++ b/resources/views/profile/partial/private-info.blade.php @@ -0,0 +1,32 @@ +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + {{$user->username}} +
    +
    +
    + {{$user->statuses()->whereNull('reblog_of_id')->whereNull('in_reply_to_id')->count()}} + Posts +
    +
    +

    + {{$user->name}} + @if($user->remote_url) + REMOTE PROFILE + @endif +

    +

    {{$user->bio}}

    +

    {{str_limit($user->website, 30)}}

    +
    +
    +
    +
    +
    From fcd43097d6a8668c5b4bb39b6a822a862361fc6f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:12:30 -0600 Subject: [PATCH 39/64] Update profile partial, allow hidden follower counts --- resources/views/profile/partial/user-info.blade.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/views/profile/partial/user-info.blade.php b/resources/views/profile/partial/user-info.blade.php index 75326885f..0f51a8e4b 100644 --- a/resources/views/profile/partial/user-info.blade.php +++ b/resources/views/profile/partial/user-info.blade.php @@ -57,18 +57,22 @@ Posts
    + @if($settings->show_profile_follower_count) + @endif + @if($settings->show_profile_following_count) + @endif

    {{$user->name}} From 1bf67943f5de63ab661d4bf965c99bcb67f9f36d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:16:36 -0600 Subject: [PATCH 40/64] Add abuse report forms --- .../views/report/abusive/comment.blade.php | 45 +++++++++++++++++++ resources/views/report/abusive/post.blade.php | 45 +++++++++++++++++++ .../views/report/abusive/profile.blade.php | 45 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 resources/views/report/abusive/comment.blade.php create mode 100644 resources/views/report/abusive/post.blade.php create mode 100644 resources/views/report/abusive/profile.blade.php diff --git a/resources/views/report/abusive/comment.blade.php b/resources/views/report/abusive/comment.blade.php new file mode 100644 index 000000000..aa7c70678 --- /dev/null +++ b/resources/views/report/abusive/comment.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') + +

    +
    +
    +
    + Report Abusive/Harmful Comment +
    +
    +
    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    +
    +
    +
    +
    +
    + +@endsection \ No newline at end of file diff --git a/resources/views/report/abusive/post.blade.php b/resources/views/report/abusive/post.blade.php new file mode 100644 index 000000000..9957a3802 --- /dev/null +++ b/resources/views/report/abusive/post.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') + +
    +
    +
    +
    + Report Abusive/Harmful Post +
    +
    +
    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    +
    +
    +
    +
    +
    + +@endsection \ No newline at end of file diff --git a/resources/views/report/abusive/profile.blade.php b/resources/views/report/abusive/profile.blade.php new file mode 100644 index 000000000..6b9ca4991 --- /dev/null +++ b/resources/views/report/abusive/profile.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') + +
    +
    +
    +
    + Report Abusive/Harmful Profile +
    +
    +
    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    +
    +
    +
    +
    +
    + +@endsection \ No newline at end of file From a0a64669ffefca1a978b03223501675f5da69022 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:17:21 -0600 Subject: [PATCH 41/64] Add sensitive report forms --- .../views/report/sensitive/comment.blade.php | 45 +++++++++++++++++++ .../views/report/sensitive/post.blade.php | 45 +++++++++++++++++++ .../views/report/sensitive/profile.blade.php | 45 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 resources/views/report/sensitive/comment.blade.php create mode 100644 resources/views/report/sensitive/post.blade.php create mode 100644 resources/views/report/sensitive/profile.blade.php diff --git a/resources/views/report/sensitive/comment.blade.php b/resources/views/report/sensitive/comment.blade.php new file mode 100644 index 000000000..5313098ba --- /dev/null +++ b/resources/views/report/sensitive/comment.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') + +
    +
    +
    +
    + Report Sensitive Comment +
    +
    +
    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    +
    +
    +
    +
    +
    + +@endsection \ No newline at end of file diff --git a/resources/views/report/sensitive/post.blade.php b/resources/views/report/sensitive/post.blade.php new file mode 100644 index 000000000..bb6e47e17 --- /dev/null +++ b/resources/views/report/sensitive/post.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') + +
    +
    +
    +
    + Report Sensitive Post +
    +
    +
    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    +
    +
    +
    +
    +
    + +@endsection \ No newline at end of file diff --git a/resources/views/report/sensitive/profile.blade.php b/resources/views/report/sensitive/profile.blade.php new file mode 100644 index 000000000..c6b00befd --- /dev/null +++ b/resources/views/report/sensitive/profile.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') + +
    +
    +
    +
    + Report Sensitive Profile +
    +
    +
    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    +
    +
    +
    +
    +
    + +@endsection \ No newline at end of file From 87a7fc5cdde942d7cf06cc16416c7aec81cd0e42 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 23 Aug 2018 19:18:23 -0600 Subject: [PATCH 42/64] Update spam report forms --- resources/views/report/spam/post.blade.php | 39 ++++++++++--------- resources/views/report/spam/profile.blade.php | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/resources/views/report/spam/post.blade.php b/resources/views/report/spam/post.blade.php index b12228801..a9d6f88b6 100644 --- a/resources/views/report/spam/post.blade.php +++ b/resources/views/report/spam/post.blade.php @@ -9,26 +9,29 @@ Report Post Spam
    -
    -

    Please select one of the following options.

    -
    -
    -

    - This comment contains spam -

    +
    +
    + @csrf + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    +
    - - -
    + +

    Learn more about our reporting guidelines and policy.

    diff --git a/resources/views/report/spam/profile.blade.php b/resources/views/report/spam/profile.blade.php index 9e4a36e6f..6ee85c67d 100644 --- a/resources/views/report/spam/profile.blade.php +++ b/resources/views/report/spam/profile.blade.php @@ -28,7 +28,7 @@ This users profile contains spam

    -
    +

    Learn more about our reporting guidelines and policy.

    From 2a3aa3f85bc44e36f531ea06e464ddaea396421a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 Aug 2018 21:15:19 -0600 Subject: [PATCH 43/64] Update RemoteFollow Pipeline --- app/Jobs/RemoteFollowPipeline/RemoteFollowImportRecent.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Jobs/RemoteFollowPipeline/RemoteFollowImportRecent.php b/app/Jobs/RemoteFollowPipeline/RemoteFollowImportRecent.php index 1cb6a7828..9341babcb 100644 --- a/app/Jobs/RemoteFollowPipeline/RemoteFollowImportRecent.php +++ b/app/Jobs/RemoteFollowPipeline/RemoteFollowImportRecent.php @@ -13,6 +13,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use App\Jobs\StatusPipeline\NewStatusPipeline; +use App\Jobs\ImageOptimizePipeline\ImageThumbnail; class RemoteFollowImportRecent implements ShouldQueue { @@ -216,7 +217,9 @@ class RemoteFollowImportRecent implements ShouldQueue $media->size = 0; $media->mime = $mime; $media->save(); - + + ImageThumbnail::dispatch($media); + return true; } catch (Exception $e) { return false; From ee195834443b3c7eed774ef7cf31b76d71bd452e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 Aug 2018 22:12:21 -0600 Subject: [PATCH 44/64] Add HTTPSignature util --- .../ActivityPub/Concern/HTTPSignature.php | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 app/Util/ActivityPub/Concern/HTTPSignature.php diff --git a/app/Util/ActivityPub/Concern/HTTPSignature.php b/app/Util/ActivityPub/Concern/HTTPSignature.php new file mode 100644 index 000000000..e612243d1 --- /dev/null +++ b/app/Util/ActivityPub/Concern/HTTPSignature.php @@ -0,0 +1,94 @@ +is_url === false) { + return true; + } + + $url = $this->profile; + try { + $url = filter_var($url, FILTER_VALIDATE_URL); + $parsed = parse_url($url, PHP_URL_HOST); + if(!$parsed || in_array($parsed, $this->localhosts)) { + return false; + } + } catch (Exception $e) { + return false; + } + return true; + } + + public function fetchPublicKey($profile, bool $is_url = true) + { + $this->profile = $profile; + $this->is_url = $is_url; + $valid = $this->validateUrl(); + if(!$valid) { + throw new \Exception('Invalid URL provided'); + } + if($is_url && isset($profile->public_key) && $profile->public_key) { + return $profile->public_key; + } + + try { + $url = $this->profile; + $res = Zttp::timeout(60)->withoutVerifying()->withHeaders([ + 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', + 'User-Agent' => 'PixelFedBot v0.1 - https://pixelfed.org' + ])->get($url); + $actor = json_decode($res->getBody(), true); + } catch (Exception $e) { + throw new Exception('Unable to fetch public key'); + } + + return $actor['publicKey']['publicKeyPem']; + } + + public function sendSignedObject($senderProfile, $url, $body) + { + $profile = $senderProfile; + $context = new Context([ + 'keys' => [$profile->keyId() => $profile->private_key], + 'algorithm' => 'rsa-sha256', + 'headers' => ['(request-target)', 'Date'], + ]); + + $handlerStack = GuzzleHttpSignatures::defaultHandlerFromContext($context); + $client = new Client(['handler' => $handlerStack]); + + $headers = [ + 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', + 'Date' => date('D, d M Y h:i:s') . ' GMT', + 'Content-Type' => 'application/activity+json', + 'User-Agent' => 'PixelFedBot - https://pixelfed.org' + ]; + + $response = $client->post($url, [ + 'options' => [ + 'allow_redirects' => false, + 'verify' => true, + 'timeout' => 30 + ], + 'headers' => $headers, + 'body' => $body + ]); + + return $response->getBody(); + } + + +} \ No newline at end of file From 24ee5b129713406e6591889d0c6d47a3c2633e38 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 Aug 2018 22:13:54 -0600 Subject: [PATCH 45/64] Update httpsig util --- app/Util/ActivityPub/Concern/HTTPSignature.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Util/ActivityPub/Concern/HTTPSignature.php b/app/Util/ActivityPub/Concern/HTTPSignature.php index e612243d1..aa4f1fe9a 100644 --- a/app/Util/ActivityPub/Concern/HTTPSignature.php +++ b/app/Util/ActivityPub/Concern/HTTPSignature.php @@ -46,7 +46,7 @@ class HTTPSignature { try { $url = $this->profile; - $res = Zttp::timeout(60)->withoutVerifying()->withHeaders([ + $res = Zttp::timeout(30)->withHeaders([ 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'User-Agent' => 'PixelFedBot v0.1 - https://pixelfed.org' ])->get($url); From 60923af8978dc9f452e6057d2ece7395afe43c8e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 00:00:20 -0600 Subject: [PATCH 46/64] Update Report model --- app/Report.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Report.php b/app/Report.php index 879a8df36..495f400ed 100644 --- a/app/Report.php +++ b/app/Report.php @@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model; class Report extends Model { + protected $dates = ['admin_seen']; + public function url() { return url('/i/admin/reports/show/' . $this->id); From b92cc8f41eedaf43942597fe3b44aecb2319df39 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 00:00:45 -0600 Subject: [PATCH 47/64] Update Profile model --- app/Profile.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Profile.php b/app/Profile.php index c620582b1..4487f81b6 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -143,7 +143,11 @@ class Profile extends Model public function statusCount() { - return $this->statuses()->whereHas('media')->count(); + return $this->statuses() + ->whereHas('media') + ->whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') + ->count(); } public function recommendFollowers() @@ -159,6 +163,7 @@ class Profile extends Model ->whereNotIn('following_id', $follows) ->whereIn('profile_id', $following) ->orderByRaw('rand()') + ->distinct('id') ->limit(3) ->pluck('following_id'); $recommended = []; From 2e7bd0058998e1704cb50b8a6198ca073eea3cdb Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Fri, 6 Jul 2018 10:43:50 +0200 Subject: [PATCH 48/64] Expose RSS syndication feeds on profile page via tags. (Closes: #318) --- resources/views/profile/show.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index fa502ae1a..885d2388a 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -74,6 +74,7 @@ @push('meta') + @if(false == $settings->crawlable || $user->remote_url) @endif From 97917768f0b5d0018ad8b0629d299b9d59411614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Sun, 26 Aug 2018 18:53:20 +0200 Subject: [PATCH 49/64] 500 :) --- config/pixelfed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/pixelfed.php b/config/pixelfed.php index a62f29c3d..b675f4080 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -106,7 +106,7 @@ return [ | Change the caption length limit for new local posts. | */ - 'max_caption_length' => env('MAX_CAPTION_LENGTH', 150), + 'max_caption_length' => env('MAX_CAPTION_LENGTH', 500), /* |-------------------------------------------------------------------------- From 2d26ad1968140eefbcd3e4514b6e24da9b74a509 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 12:47:26 -0600 Subject: [PATCH 50/64] Update report views --- resources/views/report/not-interested.blade.php | 5 +++++ resources/views/report/spam.blade.php | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/resources/views/report/not-interested.blade.php b/resources/views/report/not-interested.blade.php index 687a19751..2b32daa0a 100644 --- a/resources/views/report/not-interested.blade.php +++ b/resources/views/report/not-interested.blade.php @@ -12,6 +12,11 @@

    You can unfollow or mute a user or hashtag from appearing in your timeline. Unless the content violates our terms of service, there is nothing we can do to remove it.

    +
    +

    + Learn more + about our reporting guidelines and policy.

    +
    diff --git a/resources/views/report/spam.blade.php b/resources/views/report/spam.blade.php index aff2fb3e8..50ce6e5eb 100644 --- a/resources/views/report/spam.blade.php +++ b/resources/views/report/spam.blade.php @@ -13,21 +13,30 @@

    Please select one of the following options.

    -
    + @switch(request()->query('type')) + + @case('comment') + -
    + @break + @case('post') + -
    + @break + @case('user') + + @break + @endswitch

    Learn more From 76fe2bff6ea1103a8afce3819e04d86e9e115e8a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 12:59:50 -0600 Subject: [PATCH 51/64] Update web routes, add report routes --- resources/views/report/form.blade.php | 91 ++++++++++++++++++++------- routes/web.php | 7 +++ 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/resources/views/report/form.blade.php b/resources/views/report/form.blade.php index ec7320aad..9718b53a0 100644 --- a/resources/views/report/form.blade.php +++ b/resources/views/report/form.blade.php @@ -5,41 +5,90 @@

    -
    -
    -

    This feature is not yet ready for production. Please try again later.

    -
    -
    - -
    -
    +
    +
    Report
    -
    -

    Please select one of the following options.

    +
    +

    Please select one of the following options.

    + @switch(request()->query('type')) + + @case('comment') + + @break + @case('post') + + + @break + @case('user') + + + + @break + @endswitch

    Learn more diff --git a/routes/web.php b/routes/web.php index 41625e378..4f9e4fe58 100644 --- a/routes/web.php +++ b/routes/web.php @@ -67,11 +67,18 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu Route::group(['prefix' => 'report'], function() { Route::get('/', 'ReportController@showForm')->name('report.form'); + Route::post('/', 'ReportController@formStore'); Route::get('not-interested', 'ReportController@notInterestedForm')->name('report.not-interested'); Route::get('spam', 'ReportController@spamForm')->name('report.spam'); Route::get('spam/comment', 'ReportController@spamCommentForm')->name('report.spam.comment'); Route::get('spam/post', 'ReportController@spamPostForm')->name('report.spam.post'); Route::get('spam/profile', 'ReportController@spamProfileForm')->name('report.spam.profile'); + Route::get('sensitive/comment', 'ReportController@sensitiveCommentForm')->name('report.sensitive.comment'); + Route::get('sensitive/post', 'ReportController@sensitivePostForm')->name('report.sensitive.post'); + Route::get('sensitive/profile', 'ReportController@sensitiveProfileForm')->name('report.sensitive.profile'); + Route::get('abusive/comment', 'ReportController@abusiveCommentForm')->name('report.abusive.comment'); + Route::get('abusive/post', 'ReportController@abusivePostForm')->name('report.abusive.post'); + Route::get('abusive/profile', 'ReportController@abusiveProfileForm')->name('report.abusive.profile'); }); }); From c52c841eac87797b300587d903e78947cd414901 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 13:02:18 -0600 Subject: [PATCH 52/64] Update TimelineController, add filters --- app/Http/Controllers/TimelineController.php | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/TimelineController.php b/app/Http/Controllers/TimelineController.php index 5cc84530e..9cbc579ed 100644 --- a/app/Http/Controllers/TimelineController.php +++ b/app/Http/Controllers/TimelineController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Auth; -use App\{Follower, Status, User}; +use App\{Follower, Profile, Status, User, UserFilter}; class TimelineController extends Controller { @@ -15,10 +15,16 @@ class TimelineController extends Controller public function personal() { + $pid = Auth::user()->profile->id; // TODO: Use redis for timelines - $following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id'); - $following->push(Auth::user()->profile->id); + $following = Follower::whereProfileId($pid)->pluck('following_id'); + $following->push($pid); + $filtered = UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id'); $timeline = Status::whereIn('profile_id', $following) + ->whereNotIn('profile_id', $filtered) ->orderBy('id','desc') ->withCount(['comments', 'likes']) ->simplePaginate(20); @@ -30,8 +36,18 @@ class TimelineController extends Controller { // TODO: Use redis for timelines // $timeline = Timeline::build()->local(); + $pid = Auth::user()->profile->id; + + $filtered = UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id'); + $private = Profile::whereIsPrivate(true)->pluck('id'); + $filtered = $filtered->merge($private); $timeline = Status::whereHas('media') + ->whereNotIn('profile_id', $filtered) ->whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') ->withCount(['comments', 'likes']) ->orderBy('id','desc') ->simplePaginate(20); From 17e099c20638ac32de021abf4f5baeacab542ff3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 13:05:45 -0600 Subject: [PATCH 53/64] Update ImageUpdate job, skip non gd-compatible mime types --- app/Jobs/ImageOptimizePipeline/ImageUpdate.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php index 5b21ea7e9..940610964 100644 --- a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php +++ b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php @@ -16,6 +16,12 @@ class ImageUpdate implements ShouldQueue protected $media; + protected $protectedMimes = [ + 'image/gif', + 'image/bmp', + 'video/mp4' + ]; + /** * Create a new job instance. * @@ -38,7 +44,7 @@ class ImageUpdate implements ShouldQueue $thumb = storage_path('app/'. $media->thumbnail_path); try { ImageOptimizer::optimize($thumb); - if($media->mime !== 'image/gif') + if(!in_array($media->mime, $this->protectedMimes)) { ImageOptimizer::optimize($path); } From b0babe819daa7a803c965bfd72905610a1665fa9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 13:10:26 -0600 Subject: [PATCH 54/64] Update ImageUpdate job, skip non gd-compatible mime types from generating a thumbnail --- app/Jobs/ImageOptimizePipeline/ImageUpdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php index 940610964..482176bec 100644 --- a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php +++ b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php @@ -43,9 +43,9 @@ class ImageUpdate implements ShouldQueue $path = storage_path('app/'. $media->media_path); $thumb = storage_path('app/'. $media->thumbnail_path); try { - ImageOptimizer::optimize($thumb); if(!in_array($media->mime, $this->protectedMimes)) { + ImageOptimizer::optimize($thumb); ImageOptimizer::optimize($path); } } catch (Exception $e) { From def210be190ff5e0e7bda76e67d3b82a94cdfb46 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 13:21:58 -0600 Subject: [PATCH 55/64] Add StoryController --- app/Http/Controllers/StoryController.php | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app/Http/Controllers/StoryController.php diff --git a/app/Http/Controllers/StoryController.php b/app/Http/Controllers/StoryController.php new file mode 100644 index 000000000..aafaa107e --- /dev/null +++ b/app/Http/Controllers/StoryController.php @@ -0,0 +1,11 @@ + Date: Sun, 26 Aug 2018 18:50:20 -0600 Subject: [PATCH 56/64] Fix migration --- .../2018_08_22_022306_update_settings_table.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/database/migrations/2018_08_22_022306_update_settings_table.php b/database/migrations/2018_08_22_022306_update_settings_table.php index 500612903..d6d198cc8 100644 --- a/database/migrations/2018_08_22_022306_update_settings_table.php +++ b/database/migrations/2018_08_22_022306_update_settings_table.php @@ -28,9 +28,11 @@ class UpdateSettingsTable extends Migration */ public function down() { - $table->dropColumn('show_profile_followers'); - $table->dropColumn('show_profile_follower_count'); - $table->dropColumn('show_profile_following'); - $table->dropColumn('show_profile_following_count'); + Schema::table('user_settings', function (Blueprint $table) { + $table->dropColumn('show_profile_followers'); + $table->dropColumn('show_profile_follower_count'); + $table->dropColumn('show_profile_following'); + $table->dropColumn('show_profile_following_count'); + }); } } From 37845e5f0441c2186ee70f9ff34b4cc184d9240c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 19:32:12 -0600 Subject: [PATCH 57/64] Add new migration for media table --- ...004653_update_media_table_add_alt_text.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 database/migrations/2018_08_27_004653_update_media_table_add_alt_text.php diff --git a/database/migrations/2018_08_27_004653_update_media_table_add_alt_text.php b/database/migrations/2018_08_27_004653_update_media_table_add_alt_text.php new file mode 100644 index 000000000..2071ba3b1 --- /dev/null +++ b/database/migrations/2018_08_27_004653_update_media_table_add_alt_text.php @@ -0,0 +1,44 @@ +string('original_sha256')->nullable()->index()->after('user_id'); + $table->string('optimized_sha256')->nullable()->index()->after('original_sha256'); + $table->string('caption')->nullable()->after('thumbnail_url'); + $table->string('hls_path')->nullable()->after('caption'); + $table->timestamp('hls_transcoded_at')->nullable()->after('processed_at'); + $table->string('key')->nullable(); + $table->json('metadata')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('media', function (Blueprint $table) { + $table->dropColumn('original_sha256'); + $table->dropColumn('optimized_sha256'); + $table->dropColumn('caption'); + $table->dropColumn('hls_path'); + $table->dropColumn('hls_transcoded_at'); + $table->dropColumn('key'); + $table->dropColumn('metadata'); + }); + } +} From 618518d71ad746cda9850b66c9eb3acf09d29bdc Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:04:59 -0600 Subject: [PATCH 58/64] Add new album view --- resources/views/status/show/album.blade.php | 65 +++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 resources/views/status/show/album.blade.php diff --git a/resources/views/status/show/album.blade.php b/resources/views/status/show/album.blade.php new file mode 100644 index 000000000..4dea9e76c --- /dev/null +++ b/resources/views/status/show/album.blade.php @@ -0,0 +1,65 @@ +@extends('layouts.app',['title' => $user->username . " posted a photo: " . $status->likes_count . " likes, " . $status->comments_count . " comments" ]) + +@section('content') + +

    +
    +
    + +
    + @if($status->is_nsfw) +
    + +

    CW / NSFW / Hidden Media

    +

    (click to show)

    +
    + @endif + + @if($status->is_nsfw) +
    + @endif +
    + @include('status.show.sidebar') +
    +
    +
    + +@endsection + +@push('meta') + + + +@endpush From 56e3f4f3e51cdbb6c7b301c80f4a3869b862bf65 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:05:35 -0600 Subject: [PATCH 59/64] Add new photo view --- resources/views/status/show/photo.blade.php | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 resources/views/status/show/photo.blade.php diff --git a/resources/views/status/show/photo.blade.php b/resources/views/status/show/photo.blade.php new file mode 100644 index 000000000..dba5bcb7a --- /dev/null +++ b/resources/views/status/show/photo.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.app',['title' => $user->username . " posted a photo: " . $status->likes_count . " likes, " . $status->comments_count . " comments" ]) + +@section('content') + +
    +
    +
    + +
    + @if($status->is_nsfw && $status->media_count == 1) +
    + +

    CW / NSFW / Hidden Media

    +

    (click to show)

    +
    + + + +
    + @elseif(!$status->is_nsfw && $status->media_count == 1) +
    + +
    + @endif +
    + @include('status.show.sidebar') +
    +
    +
    + +@endsection + +@push('meta') + + + +@endpush From 6c72c9fdb62129cc34ecbb3740e6fe990aba33d7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:05:54 -0600 Subject: [PATCH 60/64] Add status sidebar view --- resources/views/status/show/sidebar.blade.php | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 resources/views/status/show/sidebar.blade.php diff --git a/resources/views/status/show/sidebar.blade.php b/resources/views/status/show/sidebar.blade.php new file mode 100644 index 000000000..0c245375c --- /dev/null +++ b/resources/views/status/show/sidebar.blade.php @@ -0,0 +1,101 @@ +
    +
    + +
    + +
    +
    + {{$user->username}} +
    +
    +
    + +
    +
    +
    +
    +
    +

    + {{$status->profile->username}} + {!! $status->rendered ?? e($status->caption) !!} +

    +

    View all comments

    +
    + @foreach($replies as $item) +

    + {{ str_limit($item->profile->username, 15)}} + {!! $item->rendered ?? e($item->caption) !!} {{$item->created_at->diffForHumans(null, true, true ,true)}} +

    + @endforeach +
    +
    +
    +
    +
    + @if(Auth::check()) +
    + @csrf + + +
    +

    + + + @endif + +
    + @csrf + + +
    +
    +
    + + +
    +
    + +
    \ No newline at end of file From b33730de25546328682eabbc926e336cab7592d0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:06:47 -0600 Subject: [PATCH 61/64] Add basic video view --- resources/views/status/show/video.blade.php | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 resources/views/status/show/video.blade.php diff --git a/resources/views/status/show/video.blade.php b/resources/views/status/show/video.blade.php new file mode 100644 index 000000000..5babc6f68 --- /dev/null +++ b/resources/views/status/show/video.blade.php @@ -0,0 +1,50 @@ +@extends('layouts.app',['title' => $user->username . " posted a photo: " . $status->likes_count . " likes, " . $status->comments_count . " comments" ]) + +@section('content') + +
    +
    +
    + +
    + @if($status->is_nsfw && $status->media_count == 1) +
    + +

    CW / NSFW / Hidden Media

    +

    (click to show)

    +
    +
    + +
    +
    + @elseif(!$status->is_nsfw && $status->media_count == 1) +
    + +
    + @endif +
    + @include('status.show.sidebar') +
    +
    +
    + +@endsection + +@push('meta') + + + +@endpush From 8cc64437d22af29bca0a4e3546400b70733b0d2c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:19:37 -0600 Subject: [PATCH 62/64] Add status edit view --- resources/views/status/edit.blade.php | 91 +++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 resources/views/status/edit.blade.php diff --git a/resources/views/status/edit.blade.php b/resources/views/status/edit.blade.php new file mode 100644 index 000000000..ffb23cb37 --- /dev/null +++ b/resources/views/status/edit.blade.php @@ -0,0 +1,91 @@ +@extends('layouts.app') + +@section('content') + +
    +
    + +
    +
    + Edit Status + Back to post +
    +
    + @csrf +
    + +
    + is_nsfw==true?'checked=""':''}} disabled=""> + +
    +
    +
    +
    + + @foreach($status->media()->orderBy('order')->get() as $media) +
    +
    + Media #{{$media->order}} +
    +
    +
    + @csrf + +
    + +
    +
    +
    + + +
    +
    + + +
    +
    +
    +

    Last Updated: {{$media->updated_at->diffForHumans()}}

    + +
    +
    +
    +
    +
    + @endforeach + +
    +
    +@endsection + +@push('scripts') + +@endpush \ No newline at end of file From 35e7cd574a64059871a84f4c29687e8ce4ad3fce Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:23:46 -0600 Subject: [PATCH 63/64] Update web routes --- routes/web.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/web.php b/routes/web.php index 4f9e4fe58..9fa4f9f25 100644 --- a/routes/web.php +++ b/routes/web.php @@ -135,6 +135,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu Route::get('p/{username}/{id}/c/{cid}', 'CommentController@show'); Route::get('p/{username}/{id}/c', 'CommentController@showAll'); + Route::get('p/{username}/{id}/edit', 'StatusController@edit'); + Route::post('p/{username}/{id}/edit', 'StatusController@editStore'); Route::get('p/{username}/{id}', 'StatusController@show'); Route::get('{username}/saved', 'ProfileController@savedBookmarks'); Route::get('{username}/followers', 'ProfileController@followers'); From 83de8b98e642bad3616a7bcb220e643301685582 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Aug 2018 21:25:02 -0600 Subject: [PATCH 64/64] Update StatusController --- app/Http/Controllers/StatusController.php | 87 ++++++++++++++++++++--- 1 file changed, 76 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 57a7e41c1..6a9299939 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -21,17 +21,33 @@ class StatusController extends Controller ->withCount(['likes', 'comments', 'media']) ->findOrFail($id); - if(!$status->media_path && $status->in_reply_to_id) { - return redirect($status->url()); - } - if($request->wantsJson() && config('pixelfed.activitypub_enabled')) { return $this->showActivityPub($request, $status); } + $template = $this->detectTemplate($status); + $replies = Status::whereInReplyToId($status->id)->simplePaginate(30); - return view('status.show', compact('user', 'status', 'replies')); + return view($template, compact('user', 'status', 'replies')); + } + + protected function detectTemplate($status) + { + $template = Cache::rememberForever('template:status:type:'.$status->id, function () use($status) { + $template = 'status.show.photo'; + if(!$status->media_path && $status->in_reply_to_id) { + $template = 'status.reply'; + } + if($status->media->count() > 1) { + $template = 'status.show.album'; + } + if($status->viewType() == 'video') { + $template = 'status.show.video'; + } + return $template; + }); + return $template; } public function compose() @@ -42,11 +58,7 @@ class StatusController extends Controller public function store(Request $request) { - if(Auth::check() == false) - { - abort(403); - } - + $this->authCheck(); $user = Auth::user(); $size = Media::whereUserId($user->id)->sum('size') / 1000; @@ -56,7 +68,7 @@ class StatusController extends Controller } $this->validate($request, [ - 'photo.*' => 'required|mimes:jpeg,png,bmp,gif|max:' . config('pixelfed.max_photo_size'), + 'photo.*' => 'required|mimes:jpeg,png,gif|max:' . config('pixelfed.max_photo_size'), 'caption' => 'string|max:' . config('pixelfed.max_caption_length'), 'cw' => 'nullable|string', 'filter_class' => 'nullable|string', @@ -83,11 +95,13 @@ class StatusController extends Controller foreach ($photos as $k => $v) { $storagePath = "public/m/{$monthHash}/{$userHash}"; $path = $v->store($storagePath); + $hash = \hash_file('sha256', $v); $media = new Media; $media->status_id = $status->id; $media->profile_id = $profile->id; $media->user_id = $user->id; $media->media_path = $path; + $media->original_sha256 = $hash; $media->size = $v->getClientSize(); $media->mime = $v->getClientMimeType(); $media->filter_class = $request->input('filter_class'); @@ -172,6 +186,57 @@ class StatusController extends Controller return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json'); } + public function edit(Request $request, $username, $id) + { + $this->authCheck(); + $user = Auth::user()->profile; + $status = Status::whereProfileId($user->id) + ->with(['media']) + ->findOrFail($id); + return view('status.edit', compact('user', 'status')); + } + + + public function editStore(Request $request, $username, $id) + { + $this->authCheck(); + $user = Auth::user()->profile; + $status = Status::whereProfileId($user->id) + ->with(['media']) + ->findOrFail($id); + + $this->validate($request, [ + 'id' => 'required|integer|min:1', + 'caption' => 'nullable', + 'filter' => 'nullable|alpha_dash|max:30' + ]); + + $id = $request->input('id'); + $caption = $request->input('caption'); + $filter = $request->input('filter'); + + $media = Media::whereProfileId($user->id) + ->whereStatusId($status->id) + ->find($id); + + $changed = false; + + if($media->caption != $caption) { + $media->caption = $caption; + $changed = true; + } + + if($media->filter_class != $filter) { + $media->filter_class = $filter; + $changed = true; + } + + if($changed === true) { + $media->save(); + } + return response()->json([], 200); + } + protected function authCheck() { if(Auth::check() == false)