From 609ca40e6967201957a28e213ff8a32c3227866d Mon Sep 17 00:00:00 2001 From: Moritz Heiber Date: Mon, 28 May 2018 17:30:36 +0200 Subject: [PATCH 01/52] Tweaked the Docker configuration --- .dockerignore | 1 + Dockerfile | 40 +++++++++++++++++++++++++------------ contrib/nginx.conf | 2 +- docker-compose.yml | 49 +++++++++++++++++++++++++++++++++------------- 4 files changed, 65 insertions(+), 27 deletions(-) diff --git a/.dockerignore b/.dockerignore index 5d4b8fcc0..10cb02760 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ storage data Dockerfile +docker-compose.yml .dockerignore .git .gitignore diff --git a/Dockerfile b/Dockerfile index c076c6672..ec457f905 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,33 @@ -FROM php:7.2-fpm-alpine +FROM php:7.2.6-fpm-alpine -RUN apk add --no-cache git imagemagick \ - && apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libtool \ - && docker-php-ext-install pdo_mysql pcntl \ - && pecl install imagick \ - && docker-php-ext-enable imagick \ - && apk del --purge .build +ARG COMPOSER_VERSION="1.6.5" +ARG COMPOSER_CHECKSUM="67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef0be3434" -RUN curl -sS https://getcomposer.org/installer | php \ - && mv composer.phar /usr/local/bin/ \ - && ln -s /usr/local/bin/composer.phar /usr/local/bin/composer +RUN apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libtool && \ + apk --no-cache add imagemagick 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 && \ + mkdir -p /var/www && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/sessions && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/views && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/cache && \ + rm /tmp/composer.phar && \ + apk del --purge .build -WORKDIR /var/www/html -COPY . . +COPY --chown=www-data . /var/www/html/pixelfed/ + +WORKDIR /var/www/html/pixelfed +USER www-data RUN composer install --prefer-source --no-interaction + +VOLUME ["/var/www/html"] +USER root ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" diff --git a/contrib/nginx.conf b/contrib/nginx.conf index c39103d5a..39cfbdf4d 100644 --- a/contrib/nginx.conf +++ b/contrib/nginx.conf @@ -4,7 +4,7 @@ server { server_name localhost; index index.php index.html; - root /var/www/html/public; + root /var/www/html/pixelfed/public; location / { try_files $uri $uri/ /index.php; diff --git a/docker-compose.yml b/docker-compose.yml index d9c39bd2f..b49b77a77 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,37 +3,58 @@ version: '3' services: nginx: image: nginx:alpine + networks: + - internal + - external ports: - 3000:80 volumes: - - .:/var/www/html + - "php-storage:/var/www/html" - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf depends_on: - - php + - php + php: build: . + image: pixelfed volumes: - - ./storage:/var/www/html/storage - depends_on: - - mysql - - redis + - "php-storage:/var/www/html" + networks: + - internal environment: - DB_HOST=mysql - DB_DATABASE=pixelfed - - DB_USERNAME=${DB_USERNAME} - - DB_PASSWORD=${DB_PASSWORD} + - DB_USERNAME=${DB_USERNAME:-pixelfed} + - DB_PASSWORD=${DB_PASSWORD:-pixelfed} - REDIS_HOST=redis - - APP_KEY=${APP_KEY} + - APP_KEY=${APP_KEY:-app_key} + mysql: image: mysql:5.7 + networks: + - internal environment: - MYSQL_DATABASE=pixelfed - - MYSQL_USER=${DB_USERNAME} - - MYSQL_PASSWORD=${DB_PASSWORD} + - MYSQL_USER=${DB_USERNAME:-pixelfed} + - MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed} + - MYSQL_RANDOM_ROOT_PASSWORD="true" volumes: - - ./docker-volumes/mysql:/var/lib/mysql + - "mysql-data:/var/lib/mysql" + redis: image: redis:alpine volumes: - - ./docker-volumes/redis:/data -... + - "redis-data:/data" + networks: + - internal + +volumes: + redis-data: + mysql-data: + php-storage: + +networks: + internal: + internal: true + external: + driver: bridge From 9baa229a120fc5d4dec1099f7ecc90af81391a32 Mon Sep 17 00:00:00 2001 From: Moritz Heiber Date: Tue, 29 May 2018 09:20:17 +0200 Subject: [PATCH 02/52] Simplified Dockerfile --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec457f905..91e37d04c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,12 +13,12 @@ RUN apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libt install -m0755 -o root -g root /tmp/composer.phar /usr/bin/composer.phar && \ ln -sf /usr/bin/composer.phar /usr/bin/composer && \ mkdir -p /var/www && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/sessions && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/views && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/cache && \ + install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed \ + /var/www/html/pixelfed/storage \ + /var/www/html/pixelfed/storage/framework \ + /var/www/html/pixelfed/storage/framework/sessions \ + /var/www/html/pixelfed/storage/framework/views \ + /var/www/html/pixelfed/storage/framework/cache && \ rm /tmp/composer.phar && \ apk del --purge .build From 32d54ecf658c9f0440fdffdb253743f185e99d18 Mon Sep 17 00:00:00 2001 From: Moritz Heiber Date: Tue, 29 May 2018 10:25:25 +0200 Subject: [PATCH 03/52] Fixed logs location in Dockerfile, added docker-compose-running.yml for running the application --- Dockerfile | 1 + docker-compose-running.yml | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 docker-compose-running.yml diff --git a/Dockerfile b/Dockerfile index 91e37d04c..bbb285efb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ RUN apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libt install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed \ /var/www/html/pixelfed/storage \ /var/www/html/pixelfed/storage/framework \ + /var/www/html/pixelfed/storage/logs \ /var/www/html/pixelfed/storage/framework/sessions \ /var/www/html/pixelfed/storage/framework/views \ /var/www/html/pixelfed/storage/framework/cache && \ diff --git a/docker-compose-running.yml b/docker-compose-running.yml new file mode 100644 index 000000000..8e9ccd4c1 --- /dev/null +++ b/docker-compose-running.yml @@ -0,0 +1,64 @@ +--- +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: + build: . + image: pixelfed + volumes: + - "php-storage:/var/www/html" + networks: + - internal + environment: + - 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 + + mysql: + 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" + env_file: + - ./.env + volumes: + - "mysql-data:/var/lib/mysql" + + redis: + image: redis:alpine + volumes: + - "redis-data:/data" + networks: + - internal + +volumes: + redis-data: + mysql-data: + php-storage: + +networks: + internal: + internal: true + external: + driver: bridge From 407095c13b72b22ce8f8e5657e88feaf28f894e7 Mon Sep 17 00:00:00 2001 From: Moritz Heiber Date: Tue, 29 May 2018 10:26:44 +0200 Subject: [PATCH 04/52] Also added the second docker-compose configuration file to dockerignore --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 10cb02760..e47e3356b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,7 @@ storage data Dockerfile -docker-compose.yml +docker-compose*.yml .dockerignore .git .gitignore From 5117f003fe547968aa1fbca851190b276d6dcec2 Mon Sep 17 00:00:00 2001 From: Moritz Heiber Date: Tue, 29 May 2018 12:30:50 +0200 Subject: [PATCH 05/52] Revert the changes to the docker-compose.yml, we can merge the files later if necessary --- docker-compose.yml | 49 +++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b49b77a77..d9c39bd2f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,58 +3,37 @@ version: '3' services: nginx: image: nginx:alpine - networks: - - internal - - external ports: - 3000:80 volumes: - - "php-storage:/var/www/html" + - .:/var/www/html - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf depends_on: - - php - + - php php: build: . - image: pixelfed volumes: - - "php-storage:/var/www/html" - networks: - - internal + - ./storage:/var/www/html/storage + depends_on: + - mysql + - redis environment: - DB_HOST=mysql - DB_DATABASE=pixelfed - - DB_USERNAME=${DB_USERNAME:-pixelfed} - - DB_PASSWORD=${DB_PASSWORD:-pixelfed} + - DB_USERNAME=${DB_USERNAME} + - DB_PASSWORD=${DB_PASSWORD} - REDIS_HOST=redis - - APP_KEY=${APP_KEY:-app_key} - + - APP_KEY=${APP_KEY} mysql: 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} volumes: - - "mysql-data:/var/lib/mysql" - + - ./docker-volumes/mysql:/var/lib/mysql redis: image: redis:alpine volumes: - - "redis-data:/data" - networks: - - internal - -volumes: - redis-data: - mysql-data: - php-storage: - -networks: - internal: - internal: true - external: - driver: bridge + - ./docker-volumes/redis:/data +... From 1fec6737280bfc4cdb179992838e0f1ee24cedfd Mon Sep 17 00:00:00 2001 From: Moritz Heiber Date: Thu, 31 May 2018 21:43:14 +0200 Subject: [PATCH 06/52] Replaced docker-compose.yml, run composer as root, create needed directories for application storage, revert changes to nginx.conf --- Dockerfile | 25 +++++++-------- contrib/nginx.conf | 2 +- docker-compose-running.yml | 64 -------------------------------------- docker-compose.yml | 55 +++++++++++++++++++++++--------- 4 files changed, 52 insertions(+), 94 deletions(-) delete mode 100644 docker-compose-running.yml diff --git a/Dockerfile b/Dockerfile index bbb285efb..c9ee294a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,23 +12,20 @@ RUN apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libt 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 && \ - mkdir -p /var/www && \ - install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed \ - /var/www/html/pixelfed/storage \ - /var/www/html/pixelfed/storage/framework \ - /var/www/html/pixelfed/storage/logs \ - /var/www/html/pixelfed/storage/framework/sessions \ - /var/www/html/pixelfed/storage/framework/views \ - /var/www/html/pixelfed/storage/framework/cache && \ rm /tmp/composer.phar && \ - apk del --purge .build + apk --no-cache del --purge .build -COPY --chown=www-data . /var/www/html/pixelfed/ +COPY . /var/www/html/ -WORKDIR /var/www/html/pixelfed -USER www-data -RUN composer install --prefer-source --no-interaction +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"] -USER root ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" diff --git a/contrib/nginx.conf b/contrib/nginx.conf index 39cfbdf4d..c39103d5a 100644 --- a/contrib/nginx.conf +++ b/contrib/nginx.conf @@ -4,7 +4,7 @@ server { server_name localhost; index index.php index.html; - root /var/www/html/pixelfed/public; + root /var/www/html/public; location / { try_files $uri $uri/ /index.php; diff --git a/docker-compose-running.yml b/docker-compose-running.yml deleted file mode 100644 index 8e9ccd4c1..000000000 --- a/docker-compose-running.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -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: - build: . - image: pixelfed - volumes: - - "php-storage:/var/www/html" - networks: - - internal - environment: - - 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 - - mysql: - 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" - env_file: - - ./.env - volumes: - - "mysql-data:/var/lib/mysql" - - redis: - image: redis:alpine - volumes: - - "redis-data:/data" - networks: - - internal - -volumes: - redis-data: - mysql-data: - php-storage: - -networks: - internal: - internal: true - external: - driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index d9c39bd2f..8e9ccd4c1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,37 +3,62 @@ version: '3' services: nginx: image: nginx:alpine + networks: + - internal + - external ports: - - 3000:80 + - 3000:80 volumes: - - .:/var/www/html - - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf + - "php-storage:/var/www/html" + - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf depends_on: - - php + - php + php: build: . + image: pixelfed volumes: - - ./storage:/var/www/html/storage - depends_on: - - mysql - - redis + - "php-storage:/var/www/html" + networks: + - internal environment: - DB_HOST=mysql - DB_DATABASE=pixelfed - - DB_USERNAME=${DB_USERNAME} - - DB_PASSWORD=${DB_PASSWORD} + - DB_USERNAME=${DB_USERNAME:-pixelfed} + - DB_PASSWORD=${DB_PASSWORD:-pixelfed} - REDIS_HOST=redis - APP_KEY=${APP_KEY} + env_file: + - ./.env + mysql: image: mysql:5.7 + networks: + - internal environment: - MYSQL_DATABASE=pixelfed - - MYSQL_USER=${DB_USERNAME} - - MYSQL_PASSWORD=${DB_PASSWORD} + - MYSQL_USER=${DB_USERNAME:-pixelfed} + - MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed} + - MYSQL_RANDOM_ROOT_PASSWORD="true" + env_file: + - ./.env volumes: - - ./docker-volumes/mysql:/var/lib/mysql + - "mysql-data:/var/lib/mysql" + redis: image: redis:alpine volumes: - - ./docker-volumes/redis:/data -... + - "redis-data:/data" + networks: + - internal + +volumes: + redis-data: + mysql-data: + php-storage: + +networks: + internal: + internal: true + external: + driver: bridge From b240ae3b4437c35bde70773b2ff4d0b690388570 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sat, 2 Jun 2018 06:14:49 +0200 Subject: [PATCH 07/52] Add css for changes in user's profile --- resources/assets/sass/custom.scss | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index e84a5dac5..dd208eb05 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -105,3 +105,49 @@ body, button, input, textarea { .notification-page .list-group-item:first-child { border-top: none; } + +.nav-topbar { + border-top: 1px solid $gray-300; +} +.nav-topbar .nav-item { + margin: -1px 1.5rem 0; +} +.nav-topbar .nav-link { + border: 1px solid transparent; + color: $gray-300; + padding: 0.75rem 0; +} +.nav-topbar .nav-link:focus, .nav-topbar .nav-link:hover { + border-top-color: $gray-300; +} +.nav-topbar .nav-link.disabled { + color: $gray-300; + background-color: transparent; + border-color: transparent; +} +.nav-topbar .nav-item.show .nav-link, .nav-topbar .nav-link.active { + color: $gray-600; + border-top-color: $gray-600; +} +.nav-topbar .dropdown-menu { + margin-top:-1px; +} + +.info-overlay { + position: relative; +} + +.info-overlay .info-overlay-text { + display: none; + position: absolute; +} + +.info-overlay:hover .info-overlay-text { + display: flex; +} + +.info-overlay-text { + width: 100%; + height: 100%; + background-color: rgba(0,0,0,0.5); +} From 3550c0b94c284eaf1958f157d149d9bdc68a4294 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sat, 2 Jun 2018 06:22:43 +0200 Subject: [PATCH 08/52] Add lower weight option --- resources/assets/sass/custom.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index dd208eb05..a145f48dd 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -151,3 +151,7 @@ body, button, input, textarea { height: 100%; background-color: rgba(0,0,0,0.5); } + +.font-weight-ultralight { + font-weight: 200 !important; +} From 2c190ba934e918a212dadeb1f76ee9514e166c27 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sat, 2 Jun 2018 06:25:12 +0200 Subject: [PATCH 09/52] Use new classes from stylesheet --- resources/views/profile/show.blade.php | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index bb6d57a65..f81e96dbb 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -4,19 +4,19 @@
-
-
-
+
+
+
-
+
- {{$user->username}} + {{$user->username}} @if($owner == true) - - Settings + + @elseif ($following == true) @@ -80,8 +80,8 @@
@if($owner == true)
-
-@endsection \ No newline at end of file +@endsection From 1b12cc2295680b970abaa69b6c1fb6a5864b3d8c Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sat, 2 Jun 2018 06:32:19 +0200 Subject: [PATCH 10/52] Replicate improvements from show --- resources/views/profile/followers.blade.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/views/profile/followers.blade.php b/resources/views/profile/followers.blade.php index 58e79a3b4..75ff0e939 100644 --- a/resources/views/profile/followers.blade.php +++ b/resources/views/profile/followers.blade.php @@ -4,16 +4,16 @@
-
-
-
+
+
+
-
+
-
- {{$profile->username}} +
+ {{$profile->username}}
From 2d008ea2eecd340a8f76ffb261194512971d48f5 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sat, 2 Jun 2018 06:33:15 +0200 Subject: [PATCH 11/52] Replicate improvements from show --- resources/views/profile/following.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/profile/following.blade.php b/resources/views/profile/following.blade.php index f04ca85e4..27aae9eca 100644 --- a/resources/views/profile/following.blade.php +++ b/resources/views/profile/following.blade.php @@ -4,16 +4,16 @@
-
-
-
+
+
+
-
+
- {{$profile->username}} + {{$profile->username}}
From b437b627802fcba7800e22569b47a20d645a21d2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 2 Jun 2018 15:29:33 -0600 Subject: [PATCH 12/52] Update Image class, remove PNG -> JPEG conversion and use orientate() method to detect proper orientation in Exif --- app/Util/Media/Image.php | 41 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/app/Util/Media/Image.php b/app/Util/Media/Image.php index a7d53d34a..db7641fd3 100644 --- a/app/Util/Media/Image.php +++ b/app/Util/Media/Image.php @@ -105,42 +105,25 @@ class Image { $orientation = $ratio['orientation']; try { - $img = Intervention::make($file); + $img = Intervention::make($file)->orientate(); $img->resize($aspect['width'], $aspect['height'], function ($constraint) { $constraint->aspectRatio(); }); - $converted = $this->convertPngToJpeg($path, $thumbnail, $img->extension); + $converted = $this->setBaseName($path, $thumbnail, $img->extension); $newPath = storage_path('app/'.$converted['path']); - $is_png = false; - - if($img->extension == 'png' || $converted['png'] == true) { - \Log::info('PNG detected, ' . json_encode([$img, $converted])); - $is_png = true; - $newPath = str_replace('.png', '.jpeg', $newPath); - $img->encode('jpg', 80)->save($newPath); - if(!$thumbnail) { - @unlink($file); - } - \Log::info('PNG SAVED, ' . json_encode([$img, $newPath])); - } else { - \Log::info('PNG not detected, ' . json_encode([$img, $converted])); - $img->save($newPath, 75); - } + + $img->save($newPath, 75); if(!$thumbnail) { $media->orientation = $orientation; } - if($is_png == true) { - if($thumbnail == false) { + if($thumbnail == true) { + $media->thumbnail_path = $converted['path']; + $media->thumbnail_url = url(Storage::url($converted['path'])); + } else { $media->media_path = $converted['path']; $media->mime = $img->mime; - } - } - - if($thumbnail == true) { - $media->thumbnail_path = $converted['path']; - $media->thumbnail_url = url(Storage::url($converted['path'])); } $media->save(); @@ -150,18 +133,14 @@ class Image { } } - public function convertPngToJpeg($basePath, $thumbnail = false, $extension) + public function setBaseName($basePath, $thumbnail = false, $extension) { $png = false; $path = explode('.', $basePath); $name = ($thumbnail == true) ? $path[0] . '_thumb' : $path[0]; $ext = last($path); $basePath = "{$name}.{$ext}"; - if($extension == 'png' || $ext == 'png') { - $ext = 'jpeg'; - $basePath = "{$name}.{$ext}"; - $png = true; - } + return ['path' => $basePath, 'png' => $png]; } From c53e9635370f377bf592f8b199544f1a9e472b01 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 2 Jun 2018 16:53:35 -0600 Subject: [PATCH 13/52] Add supported file types and max caption length to new post form. Closes #121 and #136 --- app/Http/Controllers/StatusController.php | 4 ++-- app/Providers/AppServiceProvider.php | 6 ++++- app/Util/Lexer/PrettyNumber.php | 16 +++++++++++++ config/pixelfed.php | 20 ++++++++++++++++ .../views/timeline/partial/new-form.blade.php | 23 +++++++++++++++++++ resources/views/timeline/personal.blade.php | 19 ++------------- resources/views/timeline/public.blade.php | 19 ++------------- 7 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 resources/views/timeline/partial/new-form.blade.php diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 0220b6d0f..317baf0b0 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -30,8 +30,8 @@ class StatusController extends Controller $user = Auth::user(); $this->validate($request, [ - 'photo' => 'required|image|max:15000', - 'caption' => 'string|max:150' + 'photo' => 'required|mimes:jpeg,png,bmp,gif|max:' . config('pixelfed.max_photo_size'), + 'caption' => 'string|max:' . config('pixelfed.max_caption_length') ]); $monthHash = hash('sha1', date('Y') . date('m')); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 60c2aec65..8a21a2a7d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -40,7 +40,6 @@ class AppServiceProvider extends ServiceProvider }); Blade::directive('prettySize', function($expression) { - $size = intval($expression); $precision = 0; $short = true; @@ -51,6 +50,11 @@ class AppServiceProvider extends ServiceProvider $res = round($size, $precision).$units[$i]; return ""; }); + + Blade::directive('maxFileSize', function() { + $value = config('pixelfed.max_photo_size'); + return \App\Util\Lexer\PrettyNumber::size($value, true); + }); } /** diff --git a/app/Util/Lexer/PrettyNumber.php b/app/Util/Lexer/PrettyNumber.php index 80227f6fe..23d7ab267 100644 --- a/app/Util/Lexer/PrettyNumber.php +++ b/app/Util/Lexer/PrettyNumber.php @@ -17,4 +17,20 @@ class PrettyNumber { return $expression; } + public static function size($expression, $kb = false) + { + if($kb) { + $expression = $expression * 1024; + } + $size = intval($expression); + $precision = 0; + $short = true; + $units = $short ? + ['B','k','M','G','T','P','E','Z','Y'] : + ['B','kB','MB','GB','TB','PB','EB','ZB','YB']; + for($i = 0; ($size / 1024) > 0.9; $i++, $size /= 1024) {} + $res = round($size, $precision).$units[$i]; + return $res; + } + } \ No newline at end of file diff --git a/config/pixelfed.php b/config/pixelfed.php index 9c33a56cf..9a872e74c 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -76,5 +76,25 @@ return [ 'remote_follow_enabled' => env('REMOTE_FOLLOW', false), 'activitypub_enabled' => env('ACTIVITY_PUB', false), + + /* + |-------------------------------------------------------------------------- + | Photo file size limit + |-------------------------------------------------------------------------- + | + | Update the max photo size, in KB. + | + */ + 'max_photo_size' => env('MAX_PHOTO_SIZE', 15000), + + /* + |-------------------------------------------------------------------------- + | Caption limit + |-------------------------------------------------------------------------- + | + | Change the caption length limit for new local posts. + | + */ + 'max_caption_length' => env('MAX_CAPTION_LENGTH', 150), ]; \ No newline at end of file diff --git a/resources/views/timeline/partial/new-form.blade.php b/resources/views/timeline/partial/new-form.blade.php new file mode 100644 index 000000000..104e4de57 --- /dev/null +++ b/resources/views/timeline/partial/new-form.blade.php @@ -0,0 +1,23 @@ +
+
New Post
+
+
+ @csrf +
+ + + + Max Size: @maxFileSize(). Supported formats: jpeg, png, gif, bmp. + +
+
+ + + + Max length: {{config('pixelfed.max_caption_length')}} characters. + +
+ +
+
+
\ No newline at end of file diff --git a/resources/views/timeline/personal.blade.php b/resources/views/timeline/personal.blade.php index b10490638..ce9415638 100644 --- a/resources/views/timeline/personal.blade.php +++ b/resources/views/timeline/personal.blade.php @@ -17,24 +17,9 @@
@endif -
-
New Post
-
-
- @csrf -
- - -
-
- - -
- -
-
-
+ @include('timeline.partial.new-form') +
@foreach($timeline as $item) diff --git a/resources/views/timeline/public.blade.php b/resources/views/timeline/public.blade.php index 7f5d9afd2..e5b814f1a 100644 --- a/resources/views/timeline/public.blade.php +++ b/resources/views/timeline/public.blade.php @@ -17,23 +17,8 @@
@endif -
-
New Post
-
-
- @csrf -
- - -
-
- - -
- -
-
-
+ + @include('timeline.partial.new-form')
@foreach($timeline as $item) From 35020b71084f39e170947cc92e7dc86a266533ca Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sun, 3 Jun 2018 01:47:06 +0200 Subject: [PATCH 14/52] Update look of status view --- resources/views/status/show.blade.php | 129 +++++++++++++------------- 1 file changed, 63 insertions(+), 66 deletions(-) diff --git a/resources/views/status/show.blade.php b/resources/views/status/show.blade.php index 7c882def9..54d9ae030 100644 --- a/resources/views/status/show.blade.php +++ b/resources/views/status/show.blade.php @@ -2,86 +2,83 @@ @section('content') -
-
- -
-
-
-
- +
+
+
+
+ +
+
+
+
+
+ +
+
-
-
-
- -
- -
-
-
-
- {{$status->profile->username}} -

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

- +
+
+
+

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

+
@foreach($status->comments->reverse()->take(10) as $item) -

- {{$item->profile->username}} - {!!$item->rendered!!} {{$item->created_at->diffForHumans(null, true, true ,true)}} -

+

+ {{$item->profile->username}} + {!!$item->rendered!!} {{$item->created_at->diffForHumans(null, true, true ,true)}} +

@endforeach -
-
-
-
-
+
+
+
+ @csrf - + - - @if(Auth::check()) - @if(Auth::user()->profile->id === $status->profile->id || Auth::user()->is_admin == true) -
- @csrf - - - -
- @endif - @endif - -
- @csrf - - -
-
-
- - -
-
-
+ + @if(Auth::check()) + @if(Auth::user()->profile->id === $status->profile->id || Auth::user()->is_admin == true) + + @csrf + + + +
+ @endif + @endif + +
@csrf - +
-
+
+ +
+
-@endsection \ No newline at end of file +@endsection From c4b9cc9eda1588e9787731e7a57b479bafab4b2d Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sun, 3 Jun 2018 01:52:50 +0200 Subject: [PATCH 15/52] Remove useless hr --- resources/views/status/show.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/status/show.blade.php b/resources/views/status/show.blade.php index 54d9ae030..7e6ddc5dd 100644 --- a/resources/views/status/show.blade.php +++ b/resources/views/status/show.blade.php @@ -22,7 +22,6 @@

{{$status->created_at->diffForHumans()}}

-

From 0440f8ba720e8eab4235d1ba326c9b48d7e7c665 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sun, 3 Jun 2018 01:53:54 +0200 Subject: [PATCH 16/52] Fix #90 --- resources/assets/sass/custom.scss | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index e84a5dac5..01bb1eda9 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -56,9 +56,7 @@ body, button, input, textarea { } .card.status-container .status-photo { - display: -webkit-box !important; - display: -ms-flexbox !important; - display: flex !important; + display: block !important; margin: auto !important; } From 66f285c2b1dca7eebfa10d684e98b23a63b04018 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sun, 3 Jun 2018 03:25:29 +0200 Subject: [PATCH 17/52] Add supporting classes to square based layout --- resources/views/profile/show.blade.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index f81e96dbb..8894cccab 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -101,12 +101,14 @@ @foreach($timeline as $status)

- - From ea119a28ed36a3861467bc9e82cd6e2cf0b62e09 Mon Sep 17 00:00:00 2001 From: Stasiek Michalski Date: Sun, 3 Jun 2018 03:28:58 +0200 Subject: [PATCH 18/52] Add CSS for added classes --- resources/assets/sass/custom.scss | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index bc24a07ed..a972f29d1 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -153,3 +153,23 @@ body, button, input, textarea { .font-weight-ultralight { font-weight: 200 !important; } + +.square { + position: relative; + width: 100%; +} + +.square::after { + content: ""; + display: block; + padding-bottom: 100%; +} + +.square-content { + position: absolute; + width: 100%; + height: 100%; + background-repeat: no-repeat; + background-size: cover; + background-position: 50%; +} From c36aeba532d8b9909d5db7e687197cc95b51e652 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 2 Jun 2018 19:41:27 -0600 Subject: [PATCH 19/52] Fix profile blade variables --- resources/views/profile/show.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index 8894cccab..7b691517f 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -105,8 +105,8 @@
- {{$item->likes()->count()}} - {{$item->comments()->count()}} + {{$status->likes()->count()}} + {{$status->comments()->count()}}
From 333577c240a25286c612790acee7fb9898e24bc7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 2 Jun 2018 19:41:53 -0600 Subject: [PATCH 20/52] Update compiled assets --- public/css/app.css | Bin 157579 -> 158641 bytes public/mix-manifest.json | Bin 184 -> 184 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 86c947d07c3d10146b939c3ab01a4cd0dd01970f..2da738eaa3442eff712d66652fdc524534c26756 100644 GIT binary patch delta 674 zcmZut&ubGw80AaRT0{ya*k)^FB}8mt)=gj=neD-Yo;*ke@10~O*`d2L>tvEvmxT!4 zytL#n;KBbv5Q3nHC&5ec)QboGCp?>Ml9Gkqz8~*xt0BISwh%&#%P-&)16FaN9W>FFm)#U=CdVFlx9Z#{yc9)^1T88^OZ5c|1 ztCX<@+x25YDHmPrG%vxQmSLlm>CRL_E)H=Z2h1D4Exki1G_+2fi^ffWmh<^z`B+c`AS>{ut1_u|PZ7E&DqL>+efXe!!!=$5`N=B!@i{`V08@EwQYAvHoYyq0&Dl`+?e18H(^ZX}l on)d+rsy+Ui;r28%zeU=IT_yX1qKoi6x0a6noZlM9w6L}EA52K^ZU6uP delta 39 xcmV+?0NDSr*9nWy34nwFv;y{Elj@KQmoLNtKeq*80vZFCqG$pZx0YxE8v{?p4zd6M diff --git a/public/mix-manifest.json b/public/mix-manifest.json index eb8b185763e456730c6dcac9cfdb183670f3205e..7d075bc34ac918703825ec142db010309796cbf8 100644 GIT binary patch delta 30 lcmdnNxPx&*yhxgbNt%g)VQP}8xsjn+s Date: Sat, 2 Jun 2018 20:22:44 -0600 Subject: [PATCH 21/52] Add padding to overlay --- resources/views/profile/show.blade.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index 7b691517f..ca7166401 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -104,9 +104,13 @@
-
- {{$status->likes()->count()}} - {{$status->comments()->count()}} +
+ + {{$status->likes()->count()}} + + + {{$status->comments()->count()}} +
From 3d657e0c5259c22da67c46f9e7a6e6eab427cd2e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 2 Jun 2018 20:26:49 -0600 Subject: [PATCH 22/52] Fix n+1 comment + like counts in status overlays --- app/Http/Controllers/ProfileController.php | 7 ++++++- resources/views/profile/show.blade.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index a9d9846c5..6777dbb49 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -32,7 +32,12 @@ class ProfileController extends Controller // TODO: refactor this mess $owner = Auth::check() && Auth::id() === $user->user_id; $following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; - $timeline = $user->statuses()->whereHas('media')->whereNull('in_reply_to_id')->orderBy('id','desc')->paginate(21); + $timeline = $user->statuses() + ->whereHas('media') + ->whereNull('in_reply_to_id') + ->orderBy('id','desc') + ->withCount(['comments', 'likes']) + ->simplePaginate(21); return view('profile.show', compact('user', 'owner', 'following', 'timeline')); } diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index ca7166401..c2206387a 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -106,10 +106,10 @@
- {{$status->likes()->count()}} + {{$status->likes_count}} - {{$status->comments()->count()}} + {{$status->comments_count}}
From 818fd765509bb422898cb4bb5899031dfac0b497 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 2 Jun 2018 21:03:37 -0600 Subject: [PATCH 23/52] Change assets to use mix() method for versioning --- resources/views/layouts/app.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index e25fe9249..58c55b131 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -14,7 +14,7 @@ - + @stack('styles') @@ -25,7 +25,7 @@
@include('layouts.partial.footer')
- + @stack('scripts') From 6c0817a5729823cc688b0b2a9f7832fe1dfef3ed Mon Sep 17 00:00:00 2001 From: trwnh Date: Sun, 3 Jun 2018 01:06:26 -0500 Subject: [PATCH 24/52] Fix #156 --- resources/assets/sass/custom.scss | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index a972f29d1..c40880736 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -61,32 +61,10 @@ body, button, input, textarea { } .card.status-container .status-comments { - height: 220px; overflow-y: scroll; border-bottom:1px solid rgba(0, 0, 0, 0.1); } -.card.status-container.orientation-square .status-comments { - height: 360px !important; -} - - -.card.status-container.orientation-portrait .status-comments { - height: 528px !important; -} - -.card.status-container.orientation-landscape .status-photo img { - max-height: 451px !important; -} - -.card.status-container.orientation-square .status-photo img { - max-height: 601px !important; -} - -.card.status-container.orientation-portrait .status-photo img { - max-height: 772px !important; -} - .no-caret.dropdown-toggle { text-decoration: none !important; } From b1a46f9b1596a865a2683c26ea8a9d4b7102c28b Mon Sep 17 00:00:00 2001 From: trwnh Date: Sun, 3 Jun 2018 01:17:27 -0500 Subject: [PATCH 25/52] Remove unnecessary block definition Default display model is already block, so need to redefine it --- resources/assets/sass/custom.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/assets/sass/custom.scss b/resources/assets/sass/custom.scss index c40880736..99ceeb8da 100644 --- a/resources/assets/sass/custom.scss +++ b/resources/assets/sass/custom.scss @@ -56,7 +56,6 @@ body, button, input, textarea { } .card.status-container .status-photo { - display: block !important; margin: auto !important; } From 32fa4c2e0b2f38391fd8647665a8fa9659201c8d Mon Sep 17 00:00:00 2001 From: trwnh Date: Sun, 3 Jun 2018 01:20:06 -0500 Subject: [PATCH 26/52] Singular footer margin Remove complexity and unnecessarily large gap --- resources/views/layouts/partial/footer.blade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/layouts/partial/footer.blade.php b/resources/views/layouts/partial/footer.blade.php index 7cc7f6551..382d513b4 100644 --- a/resources/views/layouts/partial/footer.blade.php +++ b/resources/views/layouts/partial/footer.blade.php @@ -1,6 +1,6 @@ - From 89646cf1c67092fb5ea0815dbf2b1e7199e93b26 Mon Sep 17 00:00:00 2001 From: trwnh Date: Sun, 3 Jun 2018 01:44:29 -0500 Subject: [PATCH 27/52] Offset only for md layout (followers) Fix #160 for followers list --- resources/views/profile/followers.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/profile/followers.blade.php b/resources/views/profile/followers.blade.php index 75ff0e939..59a4dc988 100644 --- a/resources/views/profile/followers.blade.php +++ b/resources/views/profile/followers.blade.php @@ -42,7 +42,7 @@
-
+
@if($followers->count() !== 0)
    @foreach($followers as $user) From 48240d319cc2a8031a7119b26dc0a33daec3ef2f Mon Sep 17 00:00:00 2001 From: trwnh Date: Sun, 3 Jun 2018 01:46:25 -0500 Subject: [PATCH 28/52] Define offset only for md layout (following) Fix #160 for following list --- resources/views/profile/following.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/profile/following.blade.php b/resources/views/profile/following.blade.php index 27aae9eca..e7909cb98 100644 --- a/resources/views/profile/following.blade.php +++ b/resources/views/profile/following.blade.php @@ -42,7 +42,7 @@
-
+
@if($following->count() !== 0)
    @foreach($following as $user) From d13f73db956e83f8f0e0bfd2d7733b896c788123 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Jun 2018 00:55:05 -0600 Subject: [PATCH 29/52] Update compiled assets --- public/css/app.css | Bin 158641 -> 158172 bytes public/mix-manifest.json | Bin 184 -> 184 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 2da738eaa3442eff712d66652fdc524534c26756..9342d305f1b90a356b4da3fbca02d5aab9538604 100644 GIT binary patch delta 34 qcmdmZo%7CR&W0AoEllqcrVF|NPWf>9s)7i{WOhy3NgvfHqG~WK!8)m&g>y0RWSsi+lh8 diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 7d075bc34ac918703825ec142db010309796cbf8..7caf1148de0f5927d09421874fd236610731ab01 100644 GIT binary patch delta 30 lcmdnNxPx&*yoga^N>Ykxa!R6+iK&5!kx62rf!V}jR{)m|31$EQ delta 30 lcmdnNxPx&*yhxgbNt%g)VQP}8xsjn+s Date: Sun, 3 Jun 2018 01:00:16 -0600 Subject: [PATCH 30/52] Update status view --- resources/views/status/show.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/status/show.blade.php b/resources/views/status/show.blade.php index 7e6ddc5dd..b427b4847 100644 --- a/resources/views/status/show.blade.php +++ b/resources/views/status/show.blade.php @@ -19,7 +19,7 @@
From 6d5c8fb90a2de5532f62919393af6724b8328931 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Jun 2018 01:15:38 -0600 Subject: [PATCH 31/52] Fix n+1 query in status view --- app/Http/Controllers/StatusController.php | 4 +++- resources/views/status/show.blade.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 317baf0b0..e1db420c8 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -13,7 +13,9 @@ class StatusController extends Controller public function show(Request $request, $username, int $id) { $user = Profile::whereUsername($username)->firstOrFail(); - $status = Status::whereProfileId($user->id)->findOrFail($id); + $status = Status::whereProfileId($user->id) + ->withCount('likes') + ->findOrFail($id); if(!$status->media_path && $status->in_reply_to_id) { return view('status.reply', compact('user', 'status')); } diff --git a/resources/views/status/show.blade.php b/resources/views/status/show.blade.php index b427b4847..0b0d7ab69 100644 --- a/resources/views/status/show.blade.php +++ b/resources/views/status/show.blade.php @@ -65,7 +65,7 @@
-