From dfea7f2f244864ffc8fc82975a8cf99ab4d63993 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 11:29:16 +0900 Subject: [PATCH 01/34] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=88=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/DLsiteResolver.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/MetadataResolver/DLsiteResolver.php b/app/MetadataResolver/DLsiteResolver.php index 866bde0..a2ead81 100644 --- a/app/MetadataResolver/DLsiteResolver.php +++ b/app/MetadataResolver/DLsiteResolver.php @@ -2,8 +2,6 @@ namespace App\MetadataResolver; -use Illuminate\Support\Facades\Log; - class DLsiteResolver implements Resolver { public function resolve(string $url): Metadata From 9eb42f19919c73eace6ecac084e3cbec098bb141 Mon Sep 17 00:00:00 2001 From: Eai Date: Mon, 14 Jan 2019 14:19:43 +0900 Subject: [PATCH 02/34] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=88=E3=81=AE=E5=89=8A=E9=99=A4?= =?UTF-8?q?=20(#23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/DLsiteResolver.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/MetadataResolver/DLsiteResolver.php b/app/MetadataResolver/DLsiteResolver.php index 866bde0..a2ead81 100644 --- a/app/MetadataResolver/DLsiteResolver.php +++ b/app/MetadataResolver/DLsiteResolver.php @@ -2,8 +2,6 @@ namespace App\MetadataResolver; -use Illuminate\Support\Facades\Log; - class DLsiteResolver implements Resolver { public function resolve(string $url): Metadata From 6105f6c8600222e9894045b7c3dbf4f180f6c93b Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 16:01:58 +0900 Subject: [PATCH 03/34] =?UTF-8?q?PixivResolver=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/MetadataResolver.php | 1 + app/MetadataResolver/PixivResolver.php | 88 +++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 app/MetadataResolver/PixivResolver.php diff --git a/app/MetadataResolver/MetadataResolver.php b/app/MetadataResolver/MetadataResolver.php index 8180589..528c73c 100644 --- a/app/MetadataResolver/MetadataResolver.php +++ b/app/MetadataResolver/MetadataResolver.php @@ -12,6 +12,7 @@ class MetadataResolver implements Resolver '~ec\.toranoana\.jp/tora_r/ec/item/.*~' => ToranoanaResolver::class, '~iwara\.tv/videos/.*~' => IwaraResolver::class, '~www\.dlsite\.com/.*/work/=/product_id/..\d+\.html~' => DLsiteResolver::class, + '~www\.pixiv\.net/member_illust\.php\?illust_id=\d+~' => PixivResolver::class, '/.*/' => OGPResolver::class ]; diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php new file mode 100644 index 0000000..30db7d5 --- /dev/null +++ b/app/MetadataResolver/PixivResolver.php @@ -0,0 +1,88 @@ +get($url); + if ($res->getStatusCode() === 200) { + $ogpResolver = new OGPResolver(); + $metadata = $ogpResolver->parse($res->getBody()); + + preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}_p0_square1200\.jpg~", $res->getBody(), $match); + $illust_thumbnail_url = $match[0]; + Log::debug($illust_thumbnail_url); + + $illust_url = $this->thumbnail_to_master_url($illust_thumbnail_url); + Log::debug($illust_url); + + // 指定ページに変換 + $illust_url = str_replace("p0_master", "p{$page}_master", $illust_url); + Log::debug($illust_url); + + $metadata->image = $this->proxize($illust_url);; + + return $metadata; + } else { + throw new \RuntimeException("{$res->getStatusCode()}: $url"); + } + }else { + $client = new \GuzzleHttp\Client(); + $res = $client->get($url); + if ($res->getStatusCode() === 200) { + $ogpResolver = new OGPResolver(); + $metadata = $ogpResolver->parse($res->getBody()); + + // OGP がデフォルト画像であるようならなんとかして画像を取得する + if (strpos($metadata->image, "pixiv_logo.gif") || strpos($metadata->image, "pictures.jpg")) { + + // 作品ページの場合のみ対応 + if(strpos(parse_url($url)["query"], "mode=medium")){ + preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}(_p0)?_square1200\.jpg~", $res->getBody(), $match); + $illust_thumbnail_url = $match[0]; + + $illust_url = $this->thumbnail_to_master_url($illust_thumbnail_url); + + $metadata->image = $this->proxize($illust_url);; + } + } + + return $metadata; + } else { + throw new \RuntimeException("{$res->getStatusCode()}: $url"); + } + + } + } +} From a645cb497f8bf3b5303f50e271fe00be82440734 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 16:03:46 +0900 Subject: [PATCH 04/34] =?UTF-8?q?=E8=AC=9D=E8=BE=9E=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/PixivResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index 30db7d5..6c82d59 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -14,7 +14,7 @@ class PixivResolver implements Resolver } public function proxize(string $url):string { - // pixiv.cat のプロキシ URL に変換する + // pixiv.cat のプロキシ URL に変換する HUGE THANKS TO PIXIV.CAT! $url = str_replace("i.pximg.net", "i.pixiv.cat", $url); return $url; } From b0a7504691b4068454c7c6e165a901bf7fe5a1e7 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 16:11:14 +0900 Subject: [PATCH 05/34] =?UTF-8?q?Logging=E3=81=AE=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=83=BB=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE=E8=AA=AC?= =?UTF-8?q?=E6=98=8E=E3=82=92=E3=81=BE=E3=81=A8=E3=82=82=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/PixivResolver.php | 40 +++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index 6c82d59..99c54b6 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -2,19 +2,31 @@ namespace App\MetadataResolver; -use Illuminate\Support\Facades\Log; - class PixivResolver implements Resolver { - public function thumbnail_to_master_url(string $url):string { - // 最大長辺 1200 の画像に変換 + + /** + * サムネイル画像 URL から最大長辺 1200px の画像 URL に変換する + * + * @param string サムネイル画像 URL + * @return string 1200px の画像 URL + */ + public function thumbnail_to_master_url(string $url):string + { $url = str_replace("/c/128x128", "", $url); $url = str_replace("square1200.jpg", "master1200.jpg", $url); return $url; } - public function proxize(string $url):string { - // pixiv.cat のプロキシ URL に変換する HUGE THANKS TO PIXIV.CAT! + /** + * 直リン可能な pixiv.cat のプロキシ URL に変換する + * HUGE THANKS TO PIXIV.CAT! + * + * @param string i.pximg URL + * @return string i.pixiv.cat URL + */ + public function proxize(string $url):string + { $url = str_replace("i.pximg.net", "i.pixiv.cat", $url); return $url; } @@ -30,9 +42,7 @@ class PixivResolver implements Resolver $page = $match[1]; // 未ログインでは漫画ページを開けないため、URL を作品ページに変換する - Log::debug($url); $url = str_replace("mode=manga_big", "mode=medium", $url); - Log::debug($url); $client = new \GuzzleHttp\Client(); $res = $client->get($url); @@ -42,22 +52,20 @@ class PixivResolver implements Resolver preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}_p0_square1200\.jpg~", $res->getBody(), $match); $illust_thumbnail_url = $match[0]; - Log::debug($illust_thumbnail_url); $illust_url = $this->thumbnail_to_master_url($illust_thumbnail_url); - Log::debug($illust_url); // 指定ページに変換 $illust_url = str_replace("p0_master", "p{$page}_master", $illust_url); - Log::debug($illust_url); - $metadata->image = $this->proxize($illust_url);; + $metadata->image = $this->proxize($illust_url); + ; return $metadata; } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); } - }else { + } else { $client = new \GuzzleHttp\Client(); $res = $client->get($url); if ($res->getStatusCode() === 200) { @@ -68,13 +76,14 @@ class PixivResolver implements Resolver if (strpos($metadata->image, "pixiv_logo.gif") || strpos($metadata->image, "pictures.jpg")) { // 作品ページの場合のみ対応 - if(strpos(parse_url($url)["query"], "mode=medium")){ + if (strpos(parse_url($url)["query"], "mode=medium")) { preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}(_p0)?_square1200\.jpg~", $res->getBody(), $match); $illust_thumbnail_url = $match[0]; $illust_url = $this->thumbnail_to_master_url($illust_thumbnail_url); - $metadata->image = $this->proxize($illust_url);; + $metadata->image = $this->proxize($illust_url); + ; } } @@ -82,7 +91,6 @@ class PixivResolver implements Resolver } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); } - } } } From e6abcc44026ec9fb8d8d764db698050f003b9d84 Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 14 Jan 2019 14:47:16 +0900 Subject: [PATCH 06/34] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E3=81=ABreCAPTCHA=E7=94=A8=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 +++ composer.json | 1 + composer.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 244e6a5..06c004b 100644 --- a/.env.example +++ b/.env.example @@ -35,3 +35,6 @@ SPARKPOST_SECRET= PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= + +NOCAPTCHA_SECRET= +NOCAPTCHA_SITEKEY= \ No newline at end of file diff --git a/composer.json b/composer.json index b309ae6..b64f2d1 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "type": "project", "require": { "php": ">=7.0.0", + "anhskohbo/no-captcha": "^3.0", "doctrine/dbal": "^2.9", "fideloper/proxy": "~3.3", "guzzlehttp/guzzle": "^6.3", diff --git a/composer.lock b/composer.lock index 0d47d7a..ac5ace9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,67 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "6ac4cd158b1f93a24e21fce57d4404c8", + "content-hash": "4a3dffd3f7adecbb805a02c43f5c1f25", "packages": [ + { + "name": "anhskohbo/no-captcha", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/anhskohbo/no-captcha.git", + "reference": "164715a2de0fded5979e7a9b7721785d72a4a7d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/anhskohbo/no-captcha/zipball/164715a2de0fded5979e7a9b7721785d72a4a7d3", + "reference": "164715a2de0fded5979e7a9b7721785d72a4a7d3", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.2", + "illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*", + "php": ">=5.5.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Anhskohbo\\NoCaptcha\\NoCaptchaServiceProvider" + ], + "aliases": { + "NoCaptcha": "Anhskohbo\\NoCaptcha\\Facades\\NoCaptcha" + } + } + }, + "autoload": { + "psr-4": { + "Anhskohbo\\NoCaptcha\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "anhskohbo", + "email": "anhskohbo@gmail.com" + } + ], + "description": "No CAPTCHA reCAPTCHA For Laravel.", + "keywords": [ + "captcha", + "laravel", + "laravel4", + "laravel5", + "no-captcha", + "recaptcha" + ], + "time": "2018-08-27T02:16:31+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "0.1", From fcdb9d7aba0f8cf17424b25a10ea551f2379dc2d Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 14 Jan 2019 15:01:50 +0900 Subject: [PATCH 07/34] =?UTF-8?q?reCAPTCHA=E3=81=AE=E8=A8=AD=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Auth/RegisterController.php | 1 + resources/lang/ja/validation.php | 4 ++++ resources/views/auth/register.blade.php | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index c68ed7e..d3052d1 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -51,6 +51,7 @@ class RegisterController extends Controller 'name' => 'required|string|regex:/^[a-zA-Z0-9_-]+$/u|max:15|unique:users', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:6|confirmed', + 'g-recaptcha-response' => 'required|captcha' ], ['name.regex' => 'ユーザー名には半角英数字とアンダーバー、ハイフンのみ使用できます。'], ['name' => 'ユーザー名'] diff --git a/resources/lang/ja/validation.php b/resources/lang/ja/validation.php index 7b11851..9c9217f 100644 --- a/resources/lang/ja/validation.php +++ b/resources/lang/ja/validation.php @@ -99,6 +99,10 @@ return [ 'attribute-name' => [ 'rule-name' => 'custom-message', ], + 'g-recaptcha-response' => [ + 'required' => '「私はロボットではありません」にチェックを入れてください。', + 'captcha' => 'reCAPTCHAチェックに失敗しました。何度試しても解決しない場合、管理者にお問い合わせください。', + ], ], /* diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 7ef6a7d..59b2fa9 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -2,6 +2,10 @@ @section('title', '新規登録') +@push('head') + {!! NoCaptcha::renderJs() !!} +@endpush + @section('content')

新規登録

@@ -53,6 +57,14 @@
+
+
+ {!! NoCaptcha::display() !!} +
+ @if ($errors->has('g-recaptcha-response')) +
{{ $errors->first('g-recaptcha-response') }}
+ @endif +
From 2299ac3fe74bb7cff22b4016f28287afcb525cef Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 14 Jan 2019 15:18:41 +0900 Subject: [PATCH 08/34] =?UTF-8?q?=E9=96=8B=E7=99=BA=E7=92=B0=E5=A2=83?= =?UTF-8?q?=E5=90=91=E3=81=91=E3=81=AE=E6=8E=AA=E7=BD=AE=E3=81=A8=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=80=81reCAPTCHA=E3=81=AF=E4=BB=BB=E6=84=8F=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=A8=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 4 +++- .../Controllers/Auth/RegisterController.php | 14 +++++++++---- resources/views/auth/register.blade.php | 20 +++++++++++-------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 06c004b..84e517d 100644 --- a/.env.example +++ b/.env.example @@ -36,5 +36,7 @@ PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= +# (Optional) reCAPTCHA Key +# https://www.google.com/recaptcha NOCAPTCHA_SECRET= -NOCAPTCHA_SITEKEY= \ No newline at end of file +NOCAPTCHA_SITEKEY= diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index d3052d1..0e79f03 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -47,12 +47,18 @@ class RegisterController extends Controller */ protected function validator(array $data) { - return Validator::make($data, [ + $rules = [ 'name' => 'required|string|regex:/^[a-zA-Z0-9_-]+$/u|max:15|unique:users', 'email' => 'required|string|email|max:255|unique:users', - 'password' => 'required|string|min:6|confirmed', - 'g-recaptcha-response' => 'required|captcha' - ], + 'password' => 'required|string|min:6|confirmed' + ]; + + // reCAPTCHAのキーが設定されている場合、判定を有効化 + if (!empty(config('captcha.secret'))) { + $rules['g-recaptcha-response'] = 'required|captcha'; + } + + return Validator::make($data, $rules, ['name.regex' => 'ユーザー名には半角英数字とアンダーバー、ハイフンのみ使用できます。'], ['name' => 'ユーザー名'] ); diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 59b2fa9..ff9fc34 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -3,7 +3,9 @@ @section('title', '新規登録') @push('head') - {!! NoCaptcha::renderJs() !!} + @if (!empty(config('captcha.secret'))) + {!! NoCaptcha::renderJs() !!} + @endif @endpush @section('content') @@ -57,14 +59,16 @@
-
-
- {!! NoCaptcha::display() !!} + @if (!empty(config('captcha.secret'))) +
+
+ {!! NoCaptcha::display() !!} +
+ @if ($errors->has('g-recaptcha-response')) +
{{ $errors->first('g-recaptcha-response') }}
+ @endif
- @if ($errors->has('g-recaptcha-response')) -
{{ $errors->first('g-recaptcha-response') }}
- @endif -
+ @endif
From d359a41033a93082bfb94e115723ab87fce31031 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 17:58:45 +0900 Subject: [PATCH 09/34] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E5=90=8D=E3=82=92camelCase=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/PixivResolver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index 99c54b6..996b82c 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -11,7 +11,7 @@ class PixivResolver implements Resolver * @param string サムネイル画像 URL * @return string 1200px の画像 URL */ - public function thumbnail_to_master_url(string $url):string + public function thumbnailToMasterUrl(string $url):string { $url = str_replace("/c/128x128", "", $url); $url = str_replace("square1200.jpg", "master1200.jpg", $url); @@ -53,7 +53,7 @@ class PixivResolver implements Resolver preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}_p0_square1200\.jpg~", $res->getBody(), $match); $illust_thumbnail_url = $match[0]; - $illust_url = $this->thumbnail_to_master_url($illust_thumbnail_url); + $illust_url = $this->thumbnailToMasterUrl($illust_thumbnail_url); // 指定ページに変換 $illust_url = str_replace("p0_master", "p{$page}_master", $illust_url); @@ -80,7 +80,7 @@ class PixivResolver implements Resolver preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}(_p0)?_square1200\.jpg~", $res->getBody(), $match); $illust_thumbnail_url = $match[0]; - $illust_url = $this->thumbnail_to_master_url($illust_thumbnail_url); + $illust_url = $this->thumbnailToMasterUrl($illust_thumbnail_url); $metadata->image = $this->proxize($illust_url); ; From 2d04ed8dd7ec2b3334f87ac7c3a12f8eef29e660 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 18:16:48 +0900 Subject: [PATCH 10/34] =?UTF-8?q?thumbnailToMasterUrl=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ドキュメントコメントを修正 - 変数名をより正確なものに修正 --- app/MetadataResolver/PixivResolver.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index 996b82c..86d00cd 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -8,14 +8,14 @@ class PixivResolver implements Resolver /** * サムネイル画像 URL から最大長辺 1200px の画像 URL に変換する * - * @param string サムネイル画像 URL + * @param string $thumbnail_url サムネイル画像 URL * @return string 1200px の画像 URL */ - public function thumbnailToMasterUrl(string $url):string + public function thumbnailToMasterUrl(string $thumbnail_url):string { - $url = str_replace("/c/128x128", "", $url); - $url = str_replace("square1200.jpg", "master1200.jpg", $url); - return $url; + $temp = str_replace("/c/128x128", "", $thumbnail_url); + $large_url = str_replace("square1200.jpg", "master1200.jpg", $temp); + return $large_url; } /** @@ -23,12 +23,14 @@ class PixivResolver implements Resolver * HUGE THANKS TO PIXIV.CAT! * * @param string i.pximg URL + * @param string $pixiv_url i.pximg URL * @return string i.pixiv.cat URL */ public function proxize(string $url):string { $url = str_replace("i.pximg.net", "i.pixiv.cat", $url); return $url; + return str_replace("i.pximg.net", "i.pixiv.cat", $pixiv_url); } public function resolve(string $url): Metadata From 6ff247acd7139e95601dbec83ca3ecf73f54c7dd Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 18:18:06 +0900 Subject: [PATCH 11/34] =?UTF-8?q?proxize=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ドキュメントコメントを修正 - 引数名をより正確なものに修正 --- app/MetadataResolver/PixivResolver.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index 86d00cd..ad82f48 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -22,14 +22,11 @@ class PixivResolver implements Resolver * 直リン可能な pixiv.cat のプロキシ URL に変換する * HUGE THANKS TO PIXIV.CAT! * - * @param string i.pximg URL * @param string $pixiv_url i.pximg URL * @return string i.pixiv.cat URL */ - public function proxize(string $url):string + public function proxize(string $pixiv_url):string { - $url = str_replace("i.pximg.net", "i.pixiv.cat", $url); - return $url; return str_replace("i.pximg.net", "i.pixiv.cat", $pixiv_url); } From 98e933b833ef600436cc922674987dffb93c7432 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 18:34:33 +0900 Subject: [PATCH 12/34] =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92camel?= =?UTF-8?q?Case=20=E3=81=AB=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/PixivResolver.php | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index ad82f48..c395892 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -8,32 +8,32 @@ class PixivResolver implements Resolver /** * サムネイル画像 URL から最大長辺 1200px の画像 URL に変換する * - * @param string $thumbnail_url サムネイル画像 URL + * @param string $thumbnailUrl サムネイル画像 URL * @return string 1200px の画像 URL */ - public function thumbnailToMasterUrl(string $thumbnail_url):string + public function thumbnailToMasterUrl(string $thumbnailUrl):string { - $temp = str_replace("/c/128x128", "", $thumbnail_url); - $large_url = str_replace("square1200.jpg", "master1200.jpg", $temp); - return $large_url; + $temp = str_replace("/c/128x128", "", $thumbnailUrl); + $largeUrl = str_replace("square1200.jpg", "master1200.jpg", $temp); + return $largeUrl; } /** * 直リン可能な pixiv.cat のプロキシ URL に変換する * HUGE THANKS TO PIXIV.CAT! * - * @param string $pixiv_url i.pximg URL + * @param string $pixivUrl i.pximg URL * @return string i.pixiv.cat URL */ - public function proxize(string $pixiv_url):string + public function proxize(string $pixivUrl):string { - return str_replace("i.pximg.net", "i.pixiv.cat", $pixiv_url); + return str_replace("i.pximg.net", "i.pixiv.cat", $pixivUrl); } public function resolve(string $url): Metadata { - preg_match("~illust_id=(\d+)~", parse_url($url)["query"], $illust_id); - $illust_id = $illust_id[1]; + preg_match("~illust_id=(\d+)~", parse_url($url)["query"], $match); + $illustId = $match[1]; // 漫画ページかつページ数あり if (strpos(parse_url($url)["query"], "mode=manga_big") && strpos(parse_url($url)["query"], "page=")) { @@ -49,15 +49,15 @@ class PixivResolver implements Resolver $ogpResolver = new OGPResolver(); $metadata = $ogpResolver->parse($res->getBody()); - preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}_p0_square1200\.jpg~", $res->getBody(), $match); - $illust_thumbnail_url = $match[0]; + preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illustId}_p0_square1200\.jpg~", $res->getBody(), $match); + $illustThumbnailUrl = $match[0]; - $illust_url = $this->thumbnailToMasterUrl($illust_thumbnail_url); + $illustUrl = $this->thumbnailToMasterUrl($illustThumbnailUrl); // 指定ページに変換 - $illust_url = str_replace("p0_master", "p{$page}_master", $illust_url); + $illustUrl = str_replace("p0_master", "p{$page}_master", $illustUrl); - $metadata->image = $this->proxize($illust_url); + $metadata->image = $this->proxize($illustUrl); ; return $metadata; @@ -76,12 +76,12 @@ class PixivResolver implements Resolver // 作品ページの場合のみ対応 if (strpos(parse_url($url)["query"], "mode=medium")) { - preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illust_id}(_p0)?_square1200\.jpg~", $res->getBody(), $match); - $illust_thumbnail_url = $match[0]; + preg_match("~https://i\.pximg\.net/c/128x128/img-master/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/{$illustId}(_p0)?_square1200\.jpg~", $res->getBody(), $match); + $illustThumbnailUrl = $match[0]; - $illust_url = $this->thumbnailToMasterUrl($illust_thumbnail_url); + $illustUrl = $this->thumbnailToMasterUrl($illustThumbnailUrl); - $metadata->image = $this->proxize($illust_url); + $metadata->image = $this->proxize($illustUrl); ; } } From d6e981ac39434c191727d228c699803c62e27624 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 18:35:34 +0900 Subject: [PATCH 13/34] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=BB?= =?UTF-8?q?=E3=83=9F=E3=82=B3=E3=83=AD=E3=83=B3=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/PixivResolver.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index c395892..c06f0e4 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -58,7 +58,6 @@ class PixivResolver implements Resolver $illustUrl = str_replace("p0_master", "p{$page}_master", $illustUrl); $metadata->image = $this->proxize($illustUrl); - ; return $metadata; } else { @@ -82,7 +81,6 @@ class PixivResolver implements Resolver $illustUrl = $this->thumbnailToMasterUrl($illustThumbnailUrl); $metadata->image = $this->proxize($illustUrl); - ; } } From 0e410ef342197647b594c73b5c3441f46453cb95 Mon Sep 17 00:00:00 2001 From: mohemohe Date: Mon, 14 Jan 2019 18:37:42 +0900 Subject: [PATCH 14/34] =?UTF-8?q?composer=20install=E3=81=A7dist=E3=81=8B?= =?UTF-8?q?=E3=82=89=E5=8F=96=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B=20(#26)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9301d92..4960985 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM php:7.1-apache ENV APACHE_DOCUMENT_ROOT /var/www/html/public RUN apt-get update \ - && apt-get install -y git libpq-dev \ + && apt-get install -y git libpq-dev unzip \ && docker-php-ext-install pdo_pgsql \ && curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/composer \ From 72ab8bf101d11a60d3ee9ecc152fc0e5aaceb5f3 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 22:55:01 +0900 Subject: [PATCH 15/34] =?UTF-8?q?FantiaResolver=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/FantiaResolver.php | 38 +++++++++++++++++++++++ app/MetadataResolver/MetadataResolver.php | 1 + 2 files changed, 39 insertions(+) create mode 100644 app/MetadataResolver/FantiaResolver.php diff --git a/app/MetadataResolver/FantiaResolver.php b/app/MetadataResolver/FantiaResolver.php new file mode 100644 index 0000000..8e95bba --- /dev/null +++ b/app/MetadataResolver/FantiaResolver.php @@ -0,0 +1,38 @@ +get($url); + if ($res->getStatusCode() === 200) { + $ogpResolver = new OGPResolver(); + $metadata = $ogpResolver->parse($res->getBody()); + + $dom = new \DOMDocument(); + @$dom->loadHTML(mb_convert_encoding($res->getBody(), 'HTML-ENTITIES', 'UTF-8')); + $xpath = new \DOMXPath($dom); + + $node = $xpath->query("//meta[@property='twitter:image']")->item(0); + $ogpUrl = $node->getAttribute('content'); + + preg_match("~https:\/\/fantia\.s3\.amazonaws\.com\/uploads\/post\/file\/{$postId}\/ogp_(.*?).jpg~", $ogpUrl, $match); + $uuid = $match[1]; + + // 大きい画像に変換 + $metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.jpg"; + + return $metadata; + } else { + throw new \RuntimeException("{$res->getStatusCode()}: $url"); + } + } +} diff --git a/app/MetadataResolver/MetadataResolver.php b/app/MetadataResolver/MetadataResolver.php index 528c73c..cec63a6 100644 --- a/app/MetadataResolver/MetadataResolver.php +++ b/app/MetadataResolver/MetadataResolver.php @@ -13,6 +13,7 @@ class MetadataResolver implements Resolver '~iwara\.tv/videos/.*~' => IwaraResolver::class, '~www\.dlsite\.com/.*/work/=/product_id/..\d+\.html~' => DLsiteResolver::class, '~www\.pixiv\.net/member_illust\.php\?illust_id=\d+~' => PixivResolver::class, + '~fantia\.jp/posts/\d+~' => FantiaResolver::class, '/.*/' => OGPResolver::class ]; From f134cbefa800527304f975555126d27c6809ef8b Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 23:08:37 +0900 Subject: [PATCH 16/34] =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=81=AB=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E3=81=8C=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/FantiaResolver.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/MetadataResolver/FantiaResolver.php b/app/MetadataResolver/FantiaResolver.php index 8e95bba..85584a3 100644 --- a/app/MetadataResolver/FantiaResolver.php +++ b/app/MetadataResolver/FantiaResolver.php @@ -24,11 +24,14 @@ class FantiaResolver implements Resolver $node = $xpath->query("//meta[@property='twitter:image']")->item(0); $ogpUrl = $node->getAttribute('content'); - preg_match("~https:\/\/fantia\.s3\.amazonaws\.com\/uploads\/post\/file\/{$postId}\/ogp_(.*?).jpg~", $ogpUrl, $match); - $uuid = $match[1]; + // 投稿に画像がない場合(ogp.jpgでない場合)のみ大きい画像に変換する + if($ogpUrl != "http://fantia.jp/images/ogp.jpg"){ + preg_match("~https:\/\/fantia\.s3\.amazonaws\.com\/uploads\/post\/file\/{$postId}\/ogp_(.*?).jpg~", $ogpUrl, $match); + $uuid = $match[1]; - // 大きい画像に変換 - $metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.jpg"; + // 大きい画像に変換 + $metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.jpg"; + } return $metadata; } else { From 3dedb57fe4f669215872d0f54860a8e9a139e45e Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 23:46:39 +0900 Subject: [PATCH 17/34] =?UTF-8?q?=E6=AD=A3=E8=A6=8F=E8=A1=A8=E7=8F=BE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/FantiaResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/MetadataResolver/FantiaResolver.php b/app/MetadataResolver/FantiaResolver.php index 85584a3..6720462 100644 --- a/app/MetadataResolver/FantiaResolver.php +++ b/app/MetadataResolver/FantiaResolver.php @@ -26,7 +26,7 @@ class FantiaResolver implements Resolver // 投稿に画像がない場合(ogp.jpgでない場合)のみ大きい画像に変換する if($ogpUrl != "http://fantia.jp/images/ogp.jpg"){ - preg_match("~https:\/\/fantia\.s3\.amazonaws\.com\/uploads\/post\/file\/{$postId}\/ogp_(.*?).jpg~", $ogpUrl, $match); + preg_match("~https://fantia\.s3\.amazonaws\.com/uploads/post/file/{$postId}/ogp_(.*?).jpg~", $ogpUrl, $match); $uuid = $match[1]; // 大きい画像に変換 From dcf31865a13902c69f964598f9adac9ed922568c Mon Sep 17 00:00:00 2001 From: eai04191 Date: Mon, 14 Jan 2019 23:50:15 +0900 Subject: [PATCH 18/34] =?UTF-8?q?=E6=8B=A1=E5=BC=B5=E5=AD=90=E3=81=8Cpng?= =?UTF-8?q?=E3=81=AE=E5=A0=B4=E5=90=88=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/FantiaResolver.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/MetadataResolver/FantiaResolver.php b/app/MetadataResolver/FantiaResolver.php index 6720462..3f801ca 100644 --- a/app/MetadataResolver/FantiaResolver.php +++ b/app/MetadataResolver/FantiaResolver.php @@ -26,11 +26,12 @@ class FantiaResolver implements Resolver // 投稿に画像がない場合(ogp.jpgでない場合)のみ大きい画像に変換する if($ogpUrl != "http://fantia.jp/images/ogp.jpg"){ - preg_match("~https://fantia\.s3\.amazonaws\.com/uploads/post/file/{$postId}/ogp_(.*?).jpg~", $ogpUrl, $match); + preg_match("~https://fantia\.s3\.amazonaws\.com/uploads/post/file/{$postId}/ogp_(.*?)\.(jpg|png)~", $ogpUrl, $match); $uuid = $match[1]; + $extension = $match[2]; // 大きい画像に変換 - $metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.jpg"; + $metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.{$extension}"; } return $metadata; From a2f797cbbedead59f1c6baef1ca70ad61bc4c3c1 Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 14 Jan 2019 18:19:28 +0900 Subject: [PATCH 19/34] =?UTF-8?q?=E7=8B=AC=E6=96=AD=E3=81=A8=E5=81=8F?= =?UTF-8?q?=E8=A6=8B=E3=81=AEphp-cs-fixer=E3=83=AB=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- .php_cs.dist | 26 +++ composer.json | 1 + composer.lock | 532 +++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 561 insertions(+), 2 deletions(-) create mode 100644 .php_cs.dist diff --git a/.gitignore b/.gitignore index 59247f3..f2e912f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ Homestead.yaml npm-debug.log yarn-error.log .env -*.iml \ No newline at end of file +*.iml +.php_cs +.php_cs.cache \ No newline at end of file diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..1bfcc9f --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,26 @@ +setRules([ + '@PSR2' => true, + 'array_syntax' => [ + 'syntax' => 'short' + ], + 'blank_line_before_return' => true, + 'function_typehint_space' => true, + 'method_separation' => true, + 'ordered_imports' => true, + 'return_type_declaration' => true, + 'new_with_braces' => true, + 'no_empty_statement' => true, + 'standardize_not_equals' => true + ]) + ->setFinder( + \PhpCsFixer\Finder::create() + ->exclude('bootstrap/cache') + ->exclude('resources/views') + ->exclude('storage') + ->exclude('vendor') + ->exclude('node_modules') + ->in(__DIR__) + ); diff --git a/composer.json b/composer.json index b64f2d1..12d430e 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "require-dev": { "barryvdh/laravel-debugbar": "^3.1", "filp/whoops": "~2.0", + "friendsofphp/php-cs-fixer": "^2.14", "fzaninotto/faker": "~1.4", "mockery/mockery": "~1.0", "phpunit/phpunit": "~6.0", diff --git a/composer.lock b/composer.lock index ac5ace9..0e3e49e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4a3dffd3f7adecbb805a02c43f5c1f25", + "content-hash": "9a0efd1b396f7a748eee3b98cbd7b6a6", "packages": [ { "name": "anhskohbo/no-captcha", @@ -3045,6 +3045,180 @@ ], "time": "2018-11-09T08:37:55+00:00" }, + { + "name": "composer/semver", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573", + "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.5 || ^5.0.5", + "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "time": "2016-08-30T16:08:34+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "dc523135366eb68f22268d069ea7749486458562" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/dc523135366eb68f22268d069ea7749486458562", + "reference": "dc523135366eb68f22268d069ea7749486458562", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2018-11-29T10:59:02+00:00" + }, + { + "name": "doctrine/annotations", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-12-06T07:11:42+00:00" + }, { "name": "doctrine/instantiator", "version": "1.1.0", @@ -3160,6 +3334,102 @@ ], "time": "2018-10-23T09:00:00+00:00" }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.14.0", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "b788ea0af899cedc8114dca7db119c93b6685da2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/b788ea0af899cedc8114dca7db119c93b6685da2", + "reference": "b788ea0af899cedc8114dca7db119c93b6685da2", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || ^7.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6", + "symfony/event-dispatcher": "^3.0 || ^4.0", + "symfony/filesystem": "^3.0 || ^4.0", + "symfony/finder": "^3.0 || ^4.0", + "symfony/options-resolver": "^3.0 || ^4.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0", + "symfony/stopwatch": "^3.0 || ^4.0" + }, + "conflict": { + "hhvm": "*" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.2", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1", + "phpunitgoodpractices/traits": "^1.5.1", + "symfony/phpunit-bridge": "^4.0" + }, + "suggest": { + "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "extra": { + "branch-alias": { + "dev-master": "2.14-dev" + } + }, + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2019-01-04T18:29:47+00:00" + }, { "name": "fzaninotto/faker", "version": "v1.8.0", @@ -3534,6 +3804,57 @@ "description": "Library for handling version information and constraints", "time": "2017-03-05T17:38:23+00:00" }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -4700,6 +5021,215 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "symfony/filesystem", + "version": "v4.2.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "c2ffd9a93f2d6c5be2f68a0aa7953cc229f871f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/c2ffd9a93f2d6c5be2f68a0aa7953cc229f871f8", + "reference": "c2ffd9a93f2d6c5be2f68a0aa7953cc229f871f8", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2019-01-03T09:07:35+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v4.2.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "fbcb106aeee72f3450298bf73324d2cc00d083d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/fbcb106aeee72f3450298bf73324d2cc00d083d1", + "reference": "fbcb106aeee72f3450298bf73324d2cc00d083d1", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2019-01-03T09:07:35+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9050816e2ca34a8e916c3a0ae8b9c2fccf68b631", + "reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v4.2.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "af62b35760fc92c8dbdce659b4eebdfe0e6a0472" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/af62b35760fc92c8dbdce659b4eebdfe0e6a0472", + "reference": "af62b35760fc92c8dbdce659b4eebdfe0e6a0472", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2019-01-03T09:07:35+00:00" + }, { "name": "symfony/thanks", "version": "v1.1.0", From faf0755ebde042cbdd421f902abdcdbbfbaf27b9 Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 15 Jan 2019 00:05:01 +0900 Subject: [PATCH 20/34] Reformat --- app/Ejaculation.php | 4 +++- app/Events/LinkDiscovered.php | 4 ++-- app/Facades/Formatter.php | 2 +- app/Http/Controllers/Auth/RegisterController.php | 8 +++++--- app/Http/Controllers/Controller.php | 6 +++--- app/Http/Controllers/EjaculationController.php | 8 +++++--- app/Http/Controllers/InfoController.php | 2 ++ app/Http/Controllers/SearchController.php | 2 +- app/Http/Controllers/UserController.php | 12 ++++++++---- app/Http/ViewComposers/ProfileComposer.php | 2 +- app/Listeners/LinkCollector.php | 2 +- app/MetadataResolver/DLsiteResolver.php | 3 ++- app/MetadataResolver/FantiaResolver.php | 2 +- app/MetadataResolver/IwaraResolver.php | 2 +- app/MetadataResolver/KomifloResolver.php | 2 +- app/MetadataResolver/MelonbooksResolver.php | 2 +- app/MetadataResolver/Metadata.php | 2 +- app/MetadataResolver/MetadataResolver.php | 5 +++-- app/MetadataResolver/NicoSeigaResolver.php | 2 +- app/MetadataResolver/NijieResolver.php | 2 +- app/MetadataResolver/OGPResolver.php | 3 ++- app/MetadataResolver/PixivResolver.php | 6 +++--- app/MetadataResolver/Resolver.php | 2 +- app/MetadataResolver/ToranoanaResolver.php | 3 ++- app/Providers/AuthServiceProvider.php | 2 +- app/Providers/BroadcastServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- app/User.php | 5 +++-- app/Utilities/Formatter.php | 3 ++- .../2014_10_12_000000_create_users_table.php | 4 ++-- ...014_10_12_100000_create_password_resets_table.php | 4 ++-- .../2017_07_18_142028_create_ejaculations_table.php | 4 ++-- .../2017_11_03_182707_create_information_table.php | 4 ++-- .../2018_01_04_230948_add_link_to_ejaculations.php | 4 ++-- .../2018_01_08_075844_create_tags_table.php | 4 ++-- .../2018_06_07_225520_create_metadata_table.php | 4 ++-- .../2018_06_08_014226_recreate_metadata_table.php | 4 ++-- ...2019_01_13_224305_change_link_on_ejaculations.php | 4 ++-- resources/lang/ja/validation.php | 2 +- routes/api.php | 3 ++- routes/web.php | 4 ++-- tests/Feature/ExampleTest.php | 4 ++-- tests/Unit/ExampleTest.php | 2 +- 44 files changed, 87 insertions(+), 68 deletions(-) diff --git a/app/Ejaculation.php b/app/Ejaculation.php index 48bdaf9..83b3ad2 100644 --- a/app/Ejaculation.php +++ b/app/Ejaculation.php @@ -30,6 +30,8 @@ class Ejaculation extends Model public function textTags() { - return implode(' ', $this->tags->map(function ($v) { return $v->name; })->all()); + return implode(' ', $this->tags->map(function ($v) { + return $v->name; + })->all()); } } diff --git a/app/Events/LinkDiscovered.php b/app/Events/LinkDiscovered.php index 0163dc6..4fa6198 100644 --- a/app/Events/LinkDiscovered.php +++ b/app/Events/LinkDiscovered.php @@ -2,9 +2,9 @@ namespace App\Events; -use Illuminate\Queue\SerializesModels; -use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; +use Illuminate\Foundation\Events\Dispatchable; +use Illuminate\Queue\SerializesModels; class LinkDiscovered { diff --git a/app/Facades/Formatter.php b/app/Facades/Formatter.php index ed43178..b629419 100644 --- a/app/Facades/Formatter.php +++ b/app/Facades/Formatter.php @@ -10,4 +10,4 @@ class Formatter extends Facade { return \App\Utilities\Formatter::class; } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 0e79f03..0f6dfcb 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers\Auth; -use App\User; use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Validator; +use App\User; use Illuminate\Foundation\Auth\RegistersUsers; +use Illuminate\Support\Facades\Validator; class RegisterController extends Controller { @@ -58,7 +58,9 @@ class RegisterController extends Controller $rules['g-recaptcha-response'] = 'required|captcha'; } - return Validator::make($data, $rules, + return Validator::make( + $data, + $rules, ['name.regex' => 'ユーザー名には半角英数字とアンダーバー、ハイフンのみ使用できます。'], ['name' => 'ユーザー名'] ); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 03e02a2..a0a2a8a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; -use Illuminate\Foundation\Bus\DispatchesJobs; -use Illuminate\Routing\Controller as BaseController; -use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; +use Illuminate\Foundation\Bus\DispatchesJobs; +use Illuminate\Foundation\Validation\ValidatesRequests; +use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { diff --git a/app/Http/Controllers/EjaculationController.php b/app/Http/Controllers/EjaculationController.php index 83f4dd9..84dc6da 100644 --- a/app/Http/Controllers/EjaculationController.php +++ b/app/Http/Controllers/EjaculationController.php @@ -2,14 +2,14 @@ namespace App\Http\Controllers; +use App\Ejaculation; use App\Events\LinkDiscovered; use App\Tag; use App\User; use Carbon\Carbon; -use Validator; -use App\Ejaculation; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Validator; class EjaculationController extends Controller { @@ -104,6 +104,7 @@ class EjaculationController extends Controller public function edit($id) { $ejaculation = Ejaculation::findOrFail($id); + return view('ejaculation.edit')->with(compact('ejaculation')); } @@ -166,6 +167,7 @@ class EjaculationController extends Controller $user = User::findOrFail($ejaculation->user_id); $ejaculation->tags()->detach(); $ejaculation->delete(); + return redirect()->route('user.profile', ['name' => $user->name])->with('status', '削除しました。'); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/InfoController.php b/app/Http/Controllers/InfoController.php index 6a43159..33ff29b 100644 --- a/app/Http/Controllers/InfoController.php +++ b/app/Http/Controllers/InfoController.php @@ -14,6 +14,7 @@ class InfoController extends Controller ->orderByDesc('pinned') ->orderByDesc('created_at') ->paginate(20); + return view('info.index')->with([ 'informations' => $informations, 'categories' => Information::CATEGORIES @@ -23,6 +24,7 @@ class InfoController extends Controller public function show($id) { $information = Information::findOrFail($id); + return view('info.show')->with([ 'info' => $information, 'category' => Information::CATEGORIES[$information->category] diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0b7205c..f0eb1d4 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -38,4 +38,4 @@ class SearchController extends Controller return view('search.relatedTag')->with(compact('inputs', 'results')); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index c07fada..b6cf901 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -21,7 +21,8 @@ class UserController extends Controller } // チェックインの取得 - $query = Ejaculation::select(DB::raw(<<<'SQL' + $query = Ejaculation::select(DB::raw( + <<<'SQL' id, ejaculated_date, note, @@ -63,7 +64,8 @@ SQL abort(404); } - $groupByDay = Ejaculation::select(DB::raw(<<<'SQL' + $groupByDay = Ejaculation::select(DB::raw( + <<<'SQL' to_char(ejaculated_date, 'YYYY/MM/DD') AS "date", count(*) AS "count" SQL @@ -73,7 +75,8 @@ SQL ->orderBy(DB::raw("to_char(ejaculated_date, 'YYYY/MM/DD')")) ->get(); - $groupByHour = Ejaculation::select(DB::raw(<<<'SQL' + $groupByHour = Ejaculation::select(DB::raw( + <<<'SQL' to_char(ejaculated_date, 'HH24') AS "hour", count(*) AS "count" SQL @@ -133,7 +136,8 @@ SQL } // チェックインの取得 - $query = Ejaculation::select(DB::raw(<<<'SQL' + $query = Ejaculation::select(DB::raw( + <<<'SQL' id, ejaculated_date, note, diff --git a/app/Http/ViewComposers/ProfileComposer.php b/app/Http/ViewComposers/ProfileComposer.php index 5a0f862..cbb9a85 100644 --- a/app/Http/ViewComposers/ProfileComposer.php +++ b/app/Http/ViewComposers/ProfileComposer.php @@ -58,4 +58,4 @@ SQL $view->with(compact('latestEjaculation', 'currentSession', 'summary')); } -} \ No newline at end of file +} diff --git a/app/Listeners/LinkCollector.php b/app/Listeners/LinkCollector.php index 3d34b89..81e97f1 100644 --- a/app/Listeners/LinkCollector.php +++ b/app/Listeners/LinkCollector.php @@ -7,8 +7,8 @@ use App\Metadata; use App\MetadataResolver\MetadataResolver; use App\Utilities\Formatter; use GuzzleHttp\Exception\TransferException; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class LinkCollector diff --git a/app/MetadataResolver/DLsiteResolver.php b/app/MetadataResolver/DLsiteResolver.php index a2ead81..ac1a717 100644 --- a/app/MetadataResolver/DLsiteResolver.php +++ b/app/MetadataResolver/DLsiteResolver.php @@ -12,9 +12,10 @@ class DLsiteResolver implements Resolver $ogpResolver = new OGPResolver(); $metadata = $ogpResolver->parse($res->getBody()); $metadata->image = str_replace("img_sam.jpg", "img_main.jpg", $metadata->image); + return $metadata; } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/FantiaResolver.php b/app/MetadataResolver/FantiaResolver.php index 3f801ca..8a998c4 100644 --- a/app/MetadataResolver/FantiaResolver.php +++ b/app/MetadataResolver/FantiaResolver.php @@ -25,7 +25,7 @@ class FantiaResolver implements Resolver $ogpUrl = $node->getAttribute('content'); // 投稿に画像がない場合(ogp.jpgでない場合)のみ大きい画像に変換する - if($ogpUrl != "http://fantia.jp/images/ogp.jpg"){ + if ($ogpUrl != "http://fantia.jp/images/ogp.jpg") { preg_match("~https://fantia\.s3\.amazonaws\.com/uploads/post/file/{$postId}/ogp_(.*?)\.(jpg|png)~", $ogpUrl, $match); $uuid = $match[1]; $extension = $match[2]; diff --git a/app/MetadataResolver/IwaraResolver.php b/app/MetadataResolver/IwaraResolver.php index d1bd8b9..60aaf1b 100644 --- a/app/MetadataResolver/IwaraResolver.php +++ b/app/MetadataResolver/IwaraResolver.php @@ -54,4 +54,4 @@ class IwaraResolver implements Resolver throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/KomifloResolver.php b/app/MetadataResolver/KomifloResolver.php index 81e0577..b09396a 100644 --- a/app/MetadataResolver/KomifloResolver.php +++ b/app/MetadataResolver/KomifloResolver.php @@ -27,4 +27,4 @@ class KomifloResolver implements Resolver throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/MelonbooksResolver.php b/app/MetadataResolver/MelonbooksResolver.php index 90d221a..2e8b7fb 100644 --- a/app/MetadataResolver/MelonbooksResolver.php +++ b/app/MetadataResolver/MelonbooksResolver.php @@ -26,4 +26,4 @@ class MelonbooksResolver implements Resolver throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/Metadata.php b/app/MetadataResolver/Metadata.php index ae2508b..070dc52 100644 --- a/app/MetadataResolver/Metadata.php +++ b/app/MetadataResolver/Metadata.php @@ -7,4 +7,4 @@ class Metadata public $title = ''; public $description = ''; public $image = ''; -} \ No newline at end of file +} diff --git a/app/MetadataResolver/MetadataResolver.php b/app/MetadataResolver/MetadataResolver.php index cec63a6..f1f43ed 100644 --- a/app/MetadataResolver/MetadataResolver.php +++ b/app/MetadataResolver/MetadataResolver.php @@ -21,11 +21,12 @@ class MetadataResolver implements Resolver { foreach ($this->rules as $pattern => $class) { if (preg_match($pattern, $url) === 1) { - $resolver = new $class; + $resolver = new $class(); + return $resolver->resolve($url); } } throw new \UnexpectedValueException('URL not matched.'); } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/NicoSeigaResolver.php b/app/MetadataResolver/NicoSeigaResolver.php index dbd81bc..3e6d5c0 100644 --- a/app/MetadataResolver/NicoSeigaResolver.php +++ b/app/MetadataResolver/NicoSeigaResolver.php @@ -21,4 +21,4 @@ class NicoSeigaResolver implements Resolver throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/NijieResolver.php b/app/MetadataResolver/NijieResolver.php index e0802e6..45b73de 100644 --- a/app/MetadataResolver/NijieResolver.php +++ b/app/MetadataResolver/NijieResolver.php @@ -37,4 +37,4 @@ class NijieResolver implements Resolver throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/OGPResolver.php b/app/MetadataResolver/OGPResolver.php index 43d1543..e51fe2f 100644 --- a/app/MetadataResolver/OGPResolver.php +++ b/app/MetadataResolver/OGPResolver.php @@ -41,6 +41,7 @@ class OGPResolver implements Resolver } } } + return ''; } -} \ No newline at end of file +} diff --git a/app/MetadataResolver/PixivResolver.php b/app/MetadataResolver/PixivResolver.php index c06f0e4..b859675 100644 --- a/app/MetadataResolver/PixivResolver.php +++ b/app/MetadataResolver/PixivResolver.php @@ -4,17 +4,17 @@ namespace App\MetadataResolver; class PixivResolver implements Resolver { - /** * サムネイル画像 URL から最大長辺 1200px の画像 URL に変換する * * @param string $thumbnailUrl サムネイル画像 URL * @return string 1200px の画像 URL */ - public function thumbnailToMasterUrl(string $thumbnailUrl):string + public function thumbnailToMasterUrl(string $thumbnailUrl): string { $temp = str_replace("/c/128x128", "", $thumbnailUrl); $largeUrl = str_replace("square1200.jpg", "master1200.jpg", $temp); + return $largeUrl; } @@ -25,7 +25,7 @@ class PixivResolver implements Resolver * @param string $pixivUrl i.pximg URL * @return string i.pixiv.cat URL */ - public function proxize(string $pixivUrl):string + public function proxize(string $pixivUrl): string { return str_replace("i.pximg.net", "i.pixiv.cat", $pixivUrl); } diff --git a/app/MetadataResolver/Resolver.php b/app/MetadataResolver/Resolver.php index cc54d28..a982822 100644 --- a/app/MetadataResolver/Resolver.php +++ b/app/MetadataResolver/Resolver.php @@ -5,4 +5,4 @@ namespace App\MetadataResolver; interface Resolver { public function resolve(string $url): Metadata; -} \ No newline at end of file +} diff --git a/app/MetadataResolver/ToranoanaResolver.php b/app/MetadataResolver/ToranoanaResolver.php index 84911e8..968fff6 100644 --- a/app/MetadataResolver/ToranoanaResolver.php +++ b/app/MetadataResolver/ToranoanaResolver.php @@ -14,9 +14,10 @@ class ToranoanaResolver implements Resolver $res = $client->get($url, ['cookies' => $cookieJar]); if ($res->getStatusCode() === 200) { $ogpResolver = new OGPResolver(); + return $ogpResolver->parse($res->getBody()); } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } -} \ No newline at end of file +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 9784b1a..e12ff88 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 352cce4..395c518 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Broadcast; +use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 4e1b51e..2993781 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 5ea48d3..548e4be 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace App\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/app/User.php b/app/User.php index 94fcf46..5469e52 100644 --- a/app/User.php +++ b/app/User.php @@ -2,8 +2,8 @@ namespace App; -use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Notifications\Notifiable; use Illuminate\Support\Facades\Auth; class User extends Authenticatable @@ -36,9 +36,10 @@ class User extends Authenticatable * @param int $size 画像サイズ * @return string Gravatar 画像URL */ - public function getProfileImageUrl($size = 30) : string + public function getProfileImageUrl($size = 30): string { $hash = md5(strtolower(trim($this->email))); + return '//www.gravatar.com/avatar/' . $hash . '?s=' . $size; } diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index c19e6f2..b7ea0e7 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -24,6 +24,7 @@ class Formatter $days = floor($value / 86400); $hours = floor($value % 86400 / 3600); $minutes = floor($value % 3600 / 60); + return "{$days}日 {$hours}時間 {$minutes}分"; } @@ -61,4 +62,4 @@ class Formatter return $url; } -} \ No newline at end of file +} diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 93d7dc8..ddf1941 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,8 +1,8 @@ 'パスワード', ], -]; \ No newline at end of file +]; diff --git a/routes/api.php b/routes/api.php index 4ef841a..73e72cd 100644 --- a/routes/api.php +++ b/routes/api.php @@ -40,5 +40,6 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv if (!config('app.debug')) { $response = $response->setCache(['public' => true, 'max_age' => 86400]); } + return $response; -}); \ No newline at end of file +}); diff --git a/routes/web.php b/routes/web.php index a4ba687..5699e7e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,7 +15,7 @@ Auth::routes(); Route::get('/', 'HomeController@index')->name('home'); -Route::get('/user', function() { +Route::get('/user', function () { return redirect()->route('user.profile', ['name' => Auth::user()->name]); })->middleware('auth')->name('user.profile'); Route::get('/user/{name?}', 'UserController@profile')->name('user.profile'); @@ -36,4 +36,4 @@ Route::get('/info/{id}', 'InfoController@show')->where('id', '[0-9]+')->name('in Route::redirect('/search', '/search/checkin', 301); Route::get('/search/checkin', 'SearchController@index')->name('search'); -Route::get('/search/related-tag', 'SearchController@relatedTag')->name('search.related-tag'); \ No newline at end of file +Route::get('/search/related-tag', 'SearchController@relatedTag')->name('search.related-tag'); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 486dc27..1467c89 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -2,10 +2,10 @@ namespace Tests\Feature; -use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\WithoutMiddleware; +use Tests\TestCase; class ExampleTest extends TestCase { diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 5663bb4..225d467 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -2,9 +2,9 @@ namespace Tests\Unit; -use Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\TestCase; class ExampleTest extends TestCase { From 938a4d695737865709dcc3c4dddd21a6a5f82bbe Mon Sep 17 00:00:00 2001 From: eai04191 Date: Tue, 15 Jan 2019 15:31:15 +0900 Subject: [PATCH 21/34] =?UTF-8?q?metadata=E3=83=86=E3=83=BC=E3=83=96?= =?UTF-8?q?=E3=83=AB=E3=81=ABexpires=5Fat=E3=82=AB=E3=83=A9=E3=83=A0?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit メタデータの有効期限が現在より過去の場合、メタデータを再取得する --- app/Metadata.php | 4 +-- ...9_01_15_143800_add_expires_on_metadata.php | 32 +++++++++++++++++++ routes/api.php | 5 +-- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2019_01_15_143800_add_expires_on_metadata.php diff --git a/app/Metadata.php b/app/Metadata.php index 98badb6..ef80075 100644 --- a/app/Metadata.php +++ b/app/Metadata.php @@ -10,6 +10,6 @@ class Metadata extends Model protected $primaryKey = 'url'; protected $keyType = 'string'; - protected $fillable = ['url', 'title', 'description', 'image']; - protected $visible = ['url', 'title', 'description', 'image']; + protected $fillable = ['url', 'title', 'description', 'image', 'expires_at']; + protected $visible = ['url', 'title', 'description', 'image', 'expires_at']; } diff --git a/database/migrations/2019_01_15_143800_add_expires_on_metadata.php b/database/migrations/2019_01_15_143800_add_expires_on_metadata.php new file mode 100644 index 0000000..46891e1 --- /dev/null +++ b/database/migrations/2019_01_15_143800_add_expires_on_metadata.php @@ -0,0 +1,32 @@ +timestamp('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('metadata', function (Blueprint $table) { + $table->removeColumn('expires_at'); + }); + } +} diff --git a/routes/api.php b/routes/api.php index 73e72cd..3f2b134 100644 --- a/routes/api.php +++ b/routes/api.php @@ -26,13 +26,14 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv $url = $formatter->normalizeUrl($request->input('url')); $metadata = App\Metadata::find($url); - if ($metadata == null) { + if ($metadata == null || new DateTime($metadata->expires_at) < new DateTime("now")) { $resolved = $resolver->resolve($url); $metadata = App\Metadata::create([ 'url' => $url, 'title' => $resolved->title, 'description' => $resolved->description, - 'image' => $resolved->image + 'image' => $resolved->image, + 'expires_at' => $resolved->expires_at ]); } From 5f01cc3430ac9258187ff8f6f43e50719310581c Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 15 Jan 2019 23:56:04 +0900 Subject: [PATCH 22/34] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=82=A8=E3=83=B3=E3=83=86=E3=82=A3=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=81=ABexpires=5Fat=E3=83=97=E3=83=AD=E3=83=91=E3=83=86?= =?UTF-8?q?=E3=82=A3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/Metadata.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/MetadataResolver/Metadata.php b/app/MetadataResolver/Metadata.php index 070dc52..dbe8654 100644 --- a/app/MetadataResolver/Metadata.php +++ b/app/MetadataResolver/Metadata.php @@ -2,9 +2,13 @@ namespace App\MetadataResolver; +use Carbon\Carbon; + class Metadata { public $title = ''; public $description = ''; public $image = ''; + /** @var Carbon|null */ + public $expires_at = null; } From acb9b5821db3c8ff756e6802e64d0418580e1762 Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 15 Jan 2019 23:58:14 +0900 Subject: [PATCH 23/34] =?UTF-8?q?expires=5Fat=E3=81=AB=E6=9C=89=E5=8A=B9?= =?UTF-8?q?=E3=81=AA=E5=80=A4=E3=81=8C=E8=A8=AD=E5=AE=9A=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=80=81=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AE?= =?UTF-8?q?=E6=9C=89=E5=8A=B9=E6=9C=9F=E9=99=90=E5=88=A4=E5=AE=9A=E3=82=92?= =?UTF-8?q?=E8=A1=8C=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.php b/routes/api.php index 3f2b134..db4aa59 100644 --- a/routes/api.php +++ b/routes/api.php @@ -26,7 +26,7 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv $url = $formatter->normalizeUrl($request->input('url')); $metadata = App\Metadata::find($url); - if ($metadata == null || new DateTime($metadata->expires_at) < new DateTime("now")) { + if ($metadata == null || ($metadata->expires_at !== null && new DateTime($metadata->expires_at) < new DateTime("now"))) { $resolved = $resolver->resolve($url); $metadata = App\Metadata::create([ 'url' => $url, From 810eea2a59a18512e18ef33dfaa2ec4a62ede951 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 16 Jan 2019 00:15:41 +0900 Subject: [PATCH 24/34] =?UTF-8?q?Metadata.expires=5Fat=E3=82=92Carbon?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Metadata.php | 2 ++ routes/api.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Metadata.php b/app/Metadata.php index ef80075..dc44009 100644 --- a/app/Metadata.php +++ b/app/Metadata.php @@ -12,4 +12,6 @@ class Metadata extends Model protected $fillable = ['url', 'title', 'description', 'image', 'expires_at']; protected $visible = ['url', 'title', 'description', 'image', 'expires_at']; + + protected $dates = ['created_at', 'updated_at', 'expires_at']; } diff --git a/routes/api.php b/routes/api.php index db4aa59..37e9139 100644 --- a/routes/api.php +++ b/routes/api.php @@ -26,7 +26,7 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv $url = $formatter->normalizeUrl($request->input('url')); $metadata = App\Metadata::find($url); - if ($metadata == null || ($metadata->expires_at !== null && new DateTime($metadata->expires_at) < new DateTime("now"))) { + if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { $resolved = $resolver->resolve($url); $metadata = App\Metadata::create([ 'url' => $url, From cd26ef6236952e90ec834e602ea60a0a5f680102 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 16 Jan 2019 00:17:43 +0900 Subject: [PATCH 25/34] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=81=AE=E6=9B=B4=E6=96=B0=E6=99=82=E3=81=AB=E5=A4=9A?= =?UTF-8?q?=E9=87=8D=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/routes/api.php b/routes/api.php index 37e9139..eb38041 100644 --- a/routes/api.php +++ b/routes/api.php @@ -28,8 +28,7 @@ Route::get('/checkin/card', function (Request $request, MetadataResolver $resolv $metadata = App\Metadata::find($url); if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { $resolved = $resolver->resolve($url); - $metadata = App\Metadata::create([ - 'url' => $url, + $metadata = App\Metadata::updateOrCreate(['url' => $url], [ 'title' => $resolved->title, 'description' => $resolved->description, 'image' => $resolved->image, From cef23a64cb7a5547fb9d9680ac30994ed98bfa98 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 16 Jan 2019 00:21:19 +0900 Subject: [PATCH 26/34] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=81=AE=E5=86=8D=E5=8F=96=E5=BE=97=E5=88=A4=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E6=99=82=E3=81=AE=E5=87=A6=E7=90=86=E3=81=AB=E3=82=82=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Listeners/LinkCollector.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Listeners/LinkCollector.php b/app/Listeners/LinkCollector.php index 81e97f1..0484f95 100644 --- a/app/Listeners/LinkCollector.php +++ b/app/Listeners/LinkCollector.php @@ -43,14 +43,14 @@ class LinkCollector // 無かったら取得 // TODO: ある程度古かったら再取得とかありだと思う $metadata = Metadata::find($url); - if ($metadata == null) { + if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { try { $resolved = $this->metadataResolver->resolve($url); - Metadata::create([ - 'url' => $url, + Metadata::updateOrCreate(['url' => $url], [ 'title' => $resolved->title, 'description' => $resolved->description, - 'image' => $resolved->image + 'image' => $resolved->image, + 'expires_at' => $resolved->expires_at ]); } catch (TransferException $e) { // 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す From 2ca6c4c60dde6c91a3eaf2c7526f413646d2d2e9 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 16 Jan 2019 00:42:05 +0900 Subject: [PATCH 27/34] =?UTF-8?q?Docker=E3=82=B3=E3=83=B3=E3=83=86?= =?UTF-8?q?=E3=83=8A=E5=86=85=E3=81=ABXdebug=E3=82=92=E5=B0=8E=E5=85=A5=20?= =?UTF-8?q?(#33)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * コンテナにxdebugをインストール * env fileをDockerに読ませるようにした * 環境変数 APP_DEBUG に応じてXdebugをロードしてApacheを起動するようにした * シェルスクリプトのWindows対策 (.gitattribute) --- .env.example | 12 ++++++------ .gitattributes | 1 + Dockerfile | 7 +++++++ dist/bin/tissue-entrypoint.sh | 8 ++++++++ dist/php.d/99-xdebug.ini | 5 +++++ docker-compose.yml | 9 ++------- 6 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 dist/bin/tissue-entrypoint.sh create mode 100644 dist/php.d/99-xdebug.ini diff --git a/.env.example b/.env.example index 84e517d..a41650b 100644 --- a/.env.example +++ b/.env.example @@ -5,12 +5,12 @@ APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret +DB_CONNECTION=pgsql +DB_HOST=db +DB_PORT=5432 +DB_DATABASE=tissue +DB_USERNAME=tissue +DB_PASSWORD=tissue BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/.gitattributes b/.gitattributes index 967315d..78179de 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,4 @@ *.scss linguist-vendored *.js linguist-vendored CHANGELOG.md export-ignore +*.sh text eol=lf \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4960985..65d49a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,17 @@ ENV APACHE_DOCUMENT_ROOT /var/www/html/public RUN apt-get update \ && apt-get install -y git libpq-dev unzip \ && docker-php-ext-install pdo_pgsql \ + && pecl install xdebug \ && curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/composer \ && sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \ && sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \ && a2enmod rewrite +COPY dist/bin /usr/local/bin/ +COPY dist/php.d /usr/local/etc/php/php.d/ + +ENTRYPOINT ["tissue-entrypoint.sh"] +CMD ["apache2-foreground"] + WORKDIR /var/www/html diff --git a/dist/bin/tissue-entrypoint.sh b/dist/bin/tissue-entrypoint.sh new file mode 100644 index 0000000..49280f5 --- /dev/null +++ b/dist/bin/tissue-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [[ "$APP_DEBUG" == "true" ]]; then + export PHP_INI_SCAN_DIR=":/usr/local/etc/php/php.d" +fi + +exec docker-php-entrypoint "$@" diff --git a/dist/php.d/99-xdebug.ini b/dist/php.d/99-xdebug.ini new file mode 100644 index 0000000..a6e8b8c --- /dev/null +++ b/dist/php.d/99-xdebug.ini @@ -0,0 +1,5 @@ +; Dockerでのデバッグ用設定 +zend_extension=xdebug.so +xdebug.remote_enable=true +xdebug.remote_autostart=true +xdebug.remote_host=host.docker.internal \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index f5fbae3..6055b8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,13 +3,8 @@ version: "3" services: web: build: . - environment: - DB_CONNECTION: pgsql - DB_HOST: db - DB_PORT: 5432 - DB_DATABASE: tissue - DB_USERNAME: tissue - DB_PASSWORD: tissue + env_file: + - .env volumes: - .:/var/www/html networks: From 64f8b47ae02f724583963de7b141073a53758566 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 16 Jan 2019 05:42:46 +0900 Subject: [PATCH 28/34] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E3=81=AE=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E6=AC=84=E3=81=AEtype=E3=82=92email=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/auth/login.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index fed7176..395cc11 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -13,7 +13,7 @@
- + @if ($errors->has('email'))
{{ $errors->first('email') }}
From 2a91aac56949c237ee380aec0ba6416d81ed9981 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 16 Jan 2019 22:57:26 +0900 Subject: [PATCH 29/34] chmod +x --- dist/bin/tissue-entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 dist/bin/tissue-entrypoint.sh diff --git a/dist/bin/tissue-entrypoint.sh b/dist/bin/tissue-entrypoint.sh old mode 100644 new mode 100755 From c38d3fa79974cc98dd3c22867b33b879e77fe20f Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 16 Jan 2019 23:19:44 +0900 Subject: [PATCH 30/34] =?UTF-8?q?=E6=96=B0=E8=A6=8F=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB=E6=AC=84?= =?UTF-8?q?=E3=81=AEtype=E3=82=92email=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/auth/register.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index ff9fc34..e84e9d4 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -27,7 +27,7 @@
- + @if ($errors->has('email'))
{{ $errors->first('email') }}
From ade52f40f48f7406b1a009bc1b06ccdaff0b4d7f Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 16 Jan 2019 23:20:19 +0900 Subject: [PATCH 31/34] =?UTF-8?q?=E3=83=91=E3=82=B9=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E5=86=8D=E7=99=BA=E8=A1=8C=E7=94=BB=E9=9D=A2=E3=81=AE?= =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E6=AC=84=E3=81=AEtype=E3=82=92email?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/auth/passwords/email.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php index c0fa9b6..7ecf31e 100644 --- a/resources/views/auth/passwords/email.blade.php +++ b/resources/views/auth/passwords/email.blade.php @@ -16,7 +16,7 @@
- + @if ($errors->has('email'))
{{ $errors->first('email') }}
From 497c19d06d5fea4edf59bf34d23fd39a686d15f3 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 16 Jan 2019 23:57:30 +0900 Subject: [PATCH 32/34] =?UTF-8?q?=E3=83=91=E3=82=B9=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E5=86=8D=E7=99=BA=E8=A1=8C(=E5=AE=9F=E8=A1=8C)?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB=E6=AC=84?= =?UTF-8?q?=E3=81=AEtype=E3=82=92email=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/auth/passwords/reset.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php index e9ab11c..b68e7c8 100644 --- a/resources/views/auth/passwords/reset.blade.php +++ b/resources/views/auth/passwords/reset.blade.php @@ -18,7 +18,7 @@
- + @if ($errors->has('email'))
{{ $errors->first('email') }}
From b04f167709293227382bb5bc9389e13841f30177 Mon Sep 17 00:00:00 2001 From: Eai Date: Thu, 17 Jan 2019 00:12:25 +0900 Subject: [PATCH 33/34] =?UTF-8?q?=E3=83=91=E3=83=96=E3=83=AA=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=BF=E3=82=A4=E3=83=A0=E3=83=A9=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=81=A8=E6=A4=9C=E7=B4=A2=E7=94=BB=E9=9D=A2=E3=81=A7=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AE=E5=90=8D=E5=89=8D?= =?UTF-8?q?=E3=82=92display=5Fname=E3=81=AB=E3=81=99=E3=82=8B=20(#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 現状では設定できないため同じだがこちらのほうが好ましいはず。 --- resources/views/home.blade.php | 2 +- resources/views/search/index.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 2098826..2b3b8d4 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -34,7 +34,7 @@
- @{{ $ejaculation->user->name }} + {{ $ejaculation->user->display_name }} {{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
diff --git a/resources/views/search/index.blade.php b/resources/views/search/index.blade.php index 1f48635..56440b1 100644 --- a/resources/views/search/index.blade.php +++ b/resources/views/search/index.blade.php @@ -10,7 +10,7 @@
- @{{ $ejaculation->user->name }} + {{ $ejaculation->user->display_name }} {{ $ejaculation->ejaculated_date->format('Y/m/d H:i') }}
From 3a1dc72cf7a543f68881b56a3c369cd1fae1e18e Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 17 Jan 2019 01:01:42 +0900 Subject: [PATCH 34/34] =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E4=BF=AE=E6=AD=A3=E6=99=82=E3=81=AE=E3=83=90?= =?UTF-8?q?=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=A7=E6=96=B0=E8=A6=8F=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=81=AB=E9=A3=9B=E3=81=B0=E3=81=95=E3=82=8C=E3=81=A6=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=86=E3=83=90=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20(#44)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #34 --- app/Http/Controllers/EjaculationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/EjaculationController.php b/app/Http/Controllers/EjaculationController.php index 84dc6da..4490677 100644 --- a/app/Http/Controllers/EjaculationController.php +++ b/app/Http/Controllers/EjaculationController.php @@ -134,7 +134,7 @@ class EjaculationController extends Controller }); if ($validator->fails()) { - return redirect()->route('checkin')->withErrors($validator)->withInput(); + return redirect()->route('checkin.edit', ['id' => $id])->withErrors($validator)->withInput(); } $ejaculation->fill([