Skip to content

Commit

Permalink
Improve image description user experience (mastodon#10036)
Browse files Browse the repository at this point in the history
* 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 mastodon#10036 (comment))
  • Loading branch information
BenLubar authored and Gargron committed Feb 14, 2019
1 parent 1fcf385 commit 56f2029
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/chewy/statuses_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
opacity: 0;
transition: opacity .1s ease;

input {
textarea {
background: transparent;
color: $secondary-text-color;
border: 0;
Expand Down

0 comments on commit 56f2029

Please sign in to comment.