From a1cb313d4f8aa40fe79b00602a780c25e3869dd0 Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 24 Jun 2019 22:39:01 +0900 Subject: [PATCH 1/8] =?UTF-8?q?Card=20API=E3=81=A7=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=82=82=E5=8F=96=E3=82=8C=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/CardController.php | 2 ++ app/Metadata.php | 2 +- app/Tag.php | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/CardController.php b/app/Http/Controllers/Api/CardController.php index e5578d2..a336830 100644 --- a/app/Http/Controllers/Api/CardController.php +++ b/app/Http/Controllers/Api/CardController.php @@ -51,6 +51,8 @@ class CardController $metadata->tags()->sync($tagIds); } + $metadata->load('tags'); + $response = response($metadata); if (!config('app.debug')) { $response = $response->setCache(['public' => true, 'max_age' => 86400]); diff --git a/app/Metadata.php b/app/Metadata.php index d516b0b..2abd321 100644 --- a/app/Metadata.php +++ b/app/Metadata.php @@ -11,7 +11,7 @@ class Metadata extends Model protected $keyType = 'string'; protected $fillable = ['url', 'title', 'description', 'image', 'expires_at']; - protected $visible = ['url', 'title', 'description', 'image', 'expires_at']; + protected $visible = ['url', 'title', 'description', 'image', 'expires_at', 'tags']; protected $dates = ['created_at', 'updated_at', 'expires_at']; diff --git a/app/Tag.php b/app/Tag.php index 7d4cb9a..479d972 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -11,6 +11,9 @@ class Tag extends Model protected $fillable = [ 'name' ]; + protected $visible = [ + 'name' + ]; public function ejaculations() { From b8482e0e3c1a01ea72b0c7b8decefd901d5ccb4e Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 11 Jun 2019 22:16:40 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=83=97=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC=E3=81=A8?= =?UTF-8?q?=E3=82=BF=E3=82=B0=E5=80=99=E8=A3=9C=E9=81=B8=E6=8A=9E=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/checkin.ts | 38 ++++++++++- .../assets/js/components/MetadataPreview.vue | 66 +++++++++++++++++++ resources/assets/js/components/TagInput.vue | 5 ++ .../assets/sass/components/_link-card.scss | 23 ++++++- resources/views/ejaculation/checkin.blade.php | 7 +- resources/views/ejaculation/edit.blade.php | 7 +- 6 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 resources/assets/js/components/MetadataPreview.vue diff --git a/resources/assets/js/checkin.ts b/resources/assets/js/checkin.ts index 7e54285..fb79cc7 100644 --- a/resources/assets/js/checkin.ts +++ b/resources/assets/js/checkin.ts @@ -1,9 +1,45 @@ import Vue from 'vue'; import TagInput from "./components/TagInput.vue"; +import MetadataPreview from './components/MetadataPreview.vue'; + +export const bus = new Vue({name: "EventBus"}); new Vue({ el: '#app', + data: { + metadata: null + }, components: { - TagInput + TagInput, + MetadataPreview + }, + mounted() { + // TODO: 編集モード時はすぐにメタデータを取得する + }, + methods: { + // オカズリンクの変更時 + onChangeLink(event: Event) { + if (event.target instanceof HTMLInputElement) { + const url = event.target.value; + + if (url.trim() === '' || !/^https?:\/\//.test(url)) { + this.metadata = null; + return; + } + + $.ajax({ + url: '/api/checkin/card', + method: 'get', + type: 'json', + data: { + url + } + }).then(data => { + this.metadata = data; + }).catch(e => { + this.metadata = null; + }); + } + } } }); diff --git a/resources/assets/js/components/MetadataPreview.vue b/resources/assets/js/components/MetadataPreview.vue new file mode 100644 index 0000000..aa3a542 --- /dev/null +++ b/resources/assets/js/components/MetadataPreview.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/resources/assets/js/components/TagInput.vue b/resources/assets/js/components/TagInput.vue index a2c1ff3..5da6bfb 100644 --- a/resources/assets/js/components/TagInput.vue +++ b/resources/assets/js/components/TagInput.vue @@ -17,6 +17,7 @@ -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/ejaculation/edit.blade.php b/resources/views/ejaculation/edit.blade.php index 73b16d4..25f2215 100644 --- a/resources/views/ejaculation/edit.blade.php +++ b/resources/views/ejaculation/edit.blade.php @@ -53,7 +53,9 @@
- + オカズのURLを貼り付けて登録することができます。 @@ -62,6 +64,7 @@ @endif
+
@@ -97,4 +100,4 @@ @push('script') -@endpush \ No newline at end of file +@endpush From da19806a3d09b88f1ab252635d89b7137ec87910 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 26 Jun 2019 23:20:53 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E6=99=82=E7=82=B9=E3=81=A7=E3=82=AA=E3=82=AB?= =?UTF-8?q?=E3=82=BA=E3=83=AA=E3=83=B3=E3=82=AF=E3=81=ABURL=E3=81=8C?= =?UTF-8?q?=E5=85=A5=E5=8A=9B=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=80=81=E3=81=99=E3=81=90=E3=81=AB=E3=83=A1?= =?UTF-8?q?=E3=82=BF=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/checkin.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/resources/assets/js/checkin.ts b/resources/assets/js/checkin.ts index fb79cc7..abd4beb 100644 --- a/resources/assets/js/checkin.ts +++ b/resources/assets/js/checkin.ts @@ -14,7 +14,11 @@ new Vue({ MetadataPreview }, mounted() { - // TODO: 編集モード時はすぐにメタデータを取得する + // オカズリンクにURLがセットされている場合は、すぐにメタデータを取得する + const linkInput = this.$el.querySelector("#link"); + if (linkInput && /^https?:\/\//.test(linkInput.value)) { + this.fetchMetadata(linkInput.value); + } }, methods: { // オカズリンクの変更時 @@ -27,19 +31,23 @@ new Vue({ return; } - $.ajax({ - url: '/api/checkin/card', - method: 'get', - type: 'json', - data: { - url - } - }).then(data => { - this.metadata = data; - }).catch(e => { - this.metadata = null; - }); + this.fetchMetadata(url); } + }, + // メタデータの取得 + fetchMetadata(url: string) { + $.ajax({ + url: '/api/checkin/card', + method: 'get', + type: 'json', + data: { + url + } + }).then(data => { + this.metadata = data; + }).catch(e => { + this.metadata = null; + }); } } }); From 0ad0b268bc799f316843ef07f50cebfb72964f5f Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 26 Jun 2019 23:23:06 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=E6=97=A2=E3=81=AB=E5=85=A5=E5=8A=9B?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E3=82=92=E4=BA=8C=E9=87=8D=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/components/TagInput.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/TagInput.vue b/resources/assets/js/components/TagInput.vue index 5da6bfb..6c7908e 100644 --- a/resources/assets/js/components/TagInput.vue +++ b/resources/assets/js/components/TagInput.vue @@ -30,7 +30,7 @@ buffer: string = ""; created() { - bus.$on("add-tag", (tag: string) => this.tags.push(tag)); + bus.$on("add-tag", (tag: string) => this.tags.indexOf(tag) === -1 && this.tags.push(tag)); } onKeyDown(event: KeyboardEvent) { @@ -79,4 +79,4 @@ border: 0; outline: 0; } - \ No newline at end of file + From d8cdf218b7016259b1f6528d5e1f0565d8951e8e Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 27 Jun 2019 23:50:59 +0900 Subject: [PATCH 5/8] Update resources/assets/sass/components/_link-card.scss Co-Authored-By: Aoi Irie --- resources/assets/sass/components/_link-card.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/assets/sass/components/_link-card.scss b/resources/assets/sass/components/_link-card.scss index 5d1e358..511c927 100644 --- a/resources/assets/sass/components/_link-card.scss +++ b/resources/assets/sass/components/_link-card.scss @@ -42,7 +42,11 @@ display: flex; &:not([display=none]) { - height: $height; + min-height: $height; + + img { + position: absolute; + } } } From 0aed1d9ebe4200ba03cf186d04835517ed04eaf6 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 27 Jun 2019 23:48:19 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=E7=94=BB=E5=83=8F=E3=82=92=E5=90=AB?= =?UTF-8?q?=E3=81=BE=E3=81=AA=E3=81=84=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=81=AE=E5=A0=B4=E5=90=88=E3=80=81=E3=82=B5=E3=83=A0?= =?UTF-8?q?=E3=83=8D=E3=82=A4=E3=83=AB=E3=82=92=E9=9D=9E=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/js/components/MetadataPreview.vue | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/resources/assets/js/components/MetadataPreview.vue b/resources/assets/js/components/MetadataPreview.vue index aa3a542..215ecf6 100644 --- a/resources/assets/js/components/MetadataPreview.vue +++ b/resources/assets/js/components/MetadataPreview.vue @@ -3,10 +3,10 @@