]> cat aescling's git repositories - mastodon.git/commitdiff
Improve image description user experience (#10036)
authorBen Lubar <ben.lubar+github@gmail.com>
Thu, 14 Feb 2019 00:04:43 +0000 (18:04 -0600)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 14 Feb 2019 00:04:43 +0000 (01:04 +0100)
* Add image descriptions to searchable post content.

* Allow multi-line image descriptions.

* Request image descriptions in the same query as posts when creating the search index.

(see https://github.com/tootsuite/mastodon/pull/10036#discussion_r256551624)

app/chewy/statuses_index.rb
app/javascript/mastodon/features/compose/components/upload.js
app/javascript/styles/mastodon/components.scss

index d3104172c485d1d7b3feaf006857993425bd27c6..eafc1818b8f02f7ce2e7a9ae7324a24a7bd04da0 100644 (file)
@@ -31,7 +31,7 @@ class StatusesIndex < Chewy::Index
     },
   }
 
-  define_type ::Status.unscoped.without_reblogs do
+  define_type ::Status.unscoped.without_reblogs.includes(:media_attachments) do
     crutch :mentions do |collection|
       data = ::Mention.where(status_id: collection.map(&:id)).pluck(:status_id, :account_id)
       data.each.with_object({}) { |(id, name), result| (result[id] ||= []).push(name) }
@@ -50,7 +50,7 @@ class StatusesIndex < Chewy::Index
     root date_detection: false do
       field :account_id, type: 'long'
 
-      field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].join("\n\n") } do
+      field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].concat(status.media_attachments.map(&:description)).join("\n\n") } do
         field :stemmed, type: 'text', analyzer: 'content'
       end
 
index 038d7ee28af982a567d4c2825065a74158d4f8c7..629cbc36ac34cff657ac860c4db18007ea611219 100644 (file)
@@ -108,9 +108,8 @@ class Upload extends ImmutablePureComponent {
                 <label>
                   <span style={{ display: 'none' }}>{intl.formatMessage(messages.description)}</span>
 
-                  <input
+                  <textarea
                     placeholder={intl.formatMessage(messages.description)}
-                    type='text'
                     value={description}
                     maxLength={420}
                     onFocus={this.handleInputFocus}
index 8533e4eb5b8e5386a8f289ecb586f2498cd7f2f3..d88557559e496173f813e9193d353442e22ece53 100644 (file)
         opacity: 0;
         transition: opacity .1s ease;
 
-        input {
+        textarea {
           background: transparent;
           color: $secondary-text-color;
           border: 0;