From 2c6ec37e6a796d2d7be7be58ac0e3c6c8bbd6a18 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 18 Feb 2019 05:03:26 +0000 Subject: [PATCH 01/14] media description support --- src/components/attachment/attachment.vue | 2 +- src/components/media_modal/media_modal.vue | 2 ++ src/components/post_status_form/post_status_form.js | 3 +++ src/components/post_status_form/post_status_form.vue | 6 ++++++ src/components/still-image/still-image.js | 3 ++- src/components/still-image/still-image.vue | 2 ++ src/i18n/en.json | 1 + src/services/api/api.service.js | 4 +++- src/services/status_poster/status_poster.service.js | 5 +++-- 9 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index a7e217c1..98f772c0 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -51,7 +51,6 @@ :class="{'hidden': hidden && preloadImage }" :href="attachment.url" target="_blank" - :title="attachment.description" @click="openModal" > diff --git a/src/components/media_modal/media_modal.vue b/src/components/media_modal/media_modal.vue index 80d2a8b9..d52f00a5 100644 --- a/src/components/media_modal/media_modal.vue +++ b/src/components/media_modal/media_modal.vue @@ -8,6 +8,8 @@ v-if="type === 'image'" class="modal-image" :src="currentMedia.url" + :alt="currentMedia.description" + :title="currentMedia.description" @touchstart.stop="mediaTouchStart" @touchmove.stop="mediaTouchMove" @click="hide" diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 9027566f..df2999f2 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -78,6 +78,7 @@ const PostStatusForm = { nsfw: false, files: [], poll: {}, + mediaDescriptions: {}, visibility: scope, contentType }, @@ -190,6 +191,7 @@ const PostStatusForm = { visibility: newStatus.visibility, sensitive: newStatus.nsfw, media: newStatus.files, + mediaDescriptions: newStatus.mediaDescriptions || {}, store: this.$store, inReplyToStatusId: this.replyTo, contentType: newStatus.contentType, @@ -200,6 +202,7 @@ const PostStatusForm = { status: '', spoilerText: '', files: [], + mediaDescriptions: {}, visibility: newStatus.visibility, contentType: newStatus.contentType, poll: {} diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index e3d8d087..551df948 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -266,6 +266,7 @@ :href="file.url" >{{ file.url }} +
{ const form = new FormData() const pollOptions = poll.options || [] @@ -644,6 +645,7 @@ const postStatus = ({ form.append('poll[options][]', option) }) } + form.append('descriptions', JSON.stringify(mediaDescriptions)) if (inReplyToStatusId) { form.append('in_reply_to_id', inReplyToStatusId) } diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js index 9e904d3a..090ff673 100644 --- a/src/services/status_poster/status_poster.service.js +++ b/src/services/status_poster/status_poster.service.js @@ -1,7 +1,7 @@ import { map } from 'lodash' import apiService from '../api/api.service.js' -const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, media = [], inReplyToStatusId = undefined, contentType = 'text/plain' }) => { +const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, media = [], inReplyToStatusId = undefined, contentType = 'text/plain', mediaDescriptions = {} }) => { const mediaIds = map(media, 'id') return apiService.postStatus({ @@ -13,7 +13,8 @@ const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, m mediaIds, inReplyToStatusId, contentType, - poll }) + poll, + mediaDescriptions }) .then((data) => { if (!data.error) { store.dispatch('addNewStatuses', { From 1ff55e17b1931f0578458256f4ca912e3c50e0cc Mon Sep 17 00:00:00 2001 From: xenofem Date: Sun, 28 Jun 2020 02:16:58 -0400 Subject: [PATCH 02/14] fix invalid end tag on input element --- src/components/post_status_form/post_status_form.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 551df948..6eefc853 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -266,7 +266,7 @@ :href="file.url" >{{ file.url }}
- +
Date: Sun, 28 Jun 2020 02:31:57 -0400 Subject: [PATCH 03/14] fix vue style warnings --- src/components/post_status_form/post_status_form.vue | 6 +++++- src/components/still-image/still-image.vue | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 6eefc853..49291455 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -266,7 +266,11 @@ :href="file.url" >{{ file.url }}
- +
Date: Sun, 28 Jun 2020 16:05:22 -0400 Subject: [PATCH 04/14] suppress enter key on media description input field --- src/components/post_status_form/post_status_form.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 49291455..76fa30d8 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -270,6 +270,7 @@ v-model="newStatus.mediaDescriptions[file.id]" type="text" :placeholder="$t('post_status.media_description')" + @keydown.enter.prevent="" >
From 96d2c86d3bc1c26da2ca46ec04fb27a9de348e47 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Mon, 29 Jun 2020 14:48:22 +0300 Subject: [PATCH 05/14] change placeholders to use descriptions, use icons with placeholders, change uploads to use attachment component --- src/components/attachment/attachment.js | 28 ++++++--- src/components/attachment/attachment.vue | 28 +++++---- src/components/media_modal/media_modal.vue | 8 +++ .../post_status_form/post_status_form.js | 4 +- .../post_status_form/post_status_form.vue | 60 ++++++------------- .../video_attachment/video_attachment.vue | 2 + src/modules/media_viewer.js | 2 +- static/fontello.json | 6 ++ 8 files changed, 75 insertions(+), 63 deletions(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index b832e10f..561a5a98 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -8,7 +8,6 @@ const Attachment = { props: [ 'attachment', 'nsfw', - 'statusId', 'size', 'allowPlay', 'setMedia', @@ -30,9 +29,21 @@ const Attachment = { VideoAttachment }, computed: { - usePlaceHolder () { + usePlaceholder () { return this.size === 'hide' || this.type === 'unknown' }, + placeholderName () { + if (this.attachment.description === '' || !this.attachment.description) { + return this.type.toUpperCase() + } + return this.attachment.description + }, + placeholderIconClass () { + if (this.type === 'image') return 'icon-picture' + if (this.type === 'video') return 'icon-video' + if (this.type === 'audio') return 'icon-music' + return 'icon-link' + }, referrerpolicy () { return this.$store.state.instance.mediaProxyAvailable ? '' : 'no-referrer' }, @@ -51,6 +62,12 @@ const Attachment = { fullwidth () { return this.type === 'html' || this.type === 'audio' }, + useModal () { + return this.size === 'hide' ? ['image', 'video', 'audio'] + : this.mergedConfig.playVideosInModal + ? ['image', 'video'] + : ['image'] + }, ...mapGetters(['mergedConfig']) }, methods: { @@ -60,12 +77,7 @@ const Attachment = { } }, openModal (event) { - const modalTypes = this.mergedConfig.playVideosInModal - ? ['image', 'video'] - : ['image'] - if (fileTypeService.fileMatchesSomeType(modalTypes, this.attachment) || - this.usePlaceHolder - ) { + if (this.useModal) { event.stopPropagation() event.preventDefault() this.setMedia() diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 98f772c0..a18bf186 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -1,6 +1,6 @@