From c2bee07dbc12c799f412a39a4d5499264baac81e Mon Sep 17 00:00:00 2001 From: Anna e só Date: Sun, 10 Sep 2017 20:40:29 -0300 Subject: l10n: Full PT-BR translation (#4882) * devise.pt-BR.yml now fully translated * pt-BR.json now fully translated * pt-BR.yml partially translated; 46 lines left * pt-BR.yml now fully translated * simple_form.pt-BR.yml fully translated * doorkeeper.pt-BR.yml now fully translated * E-mail instructions on app/views/user_mailer added and fully translated * PT-BR translation for #4871 * Deleted an unwanted caracter on pt-BR.yml * Fixing typos on pt-BR.yml * Added translation for Pinned toots tab on pt-BR.json * Added missing translation for navigation_bar.pins --- .../user_mailer/confirmation_instructions.pt-BR.html.erb | 12 ++++++++++++ .../user_mailer/confirmation_instructions.pt-BR.text.erb | 12 ++++++++++++ app/views/user_mailer/password_change.pt-BR.html.erb | 3 +++ app/views/user_mailer/password_change.pt-BR.text.erb | 3 +++ .../user_mailer/reset_password_instructions.pt-BR.html.erb | 8 ++++++++ .../user_mailer/reset_password_instructions.pt-BR.text.erb | 8 ++++++++ 6 files changed, 46 insertions(+) create mode 100644 app/views/user_mailer/confirmation_instructions.pt-BR.html.erb create mode 100644 app/views/user_mailer/confirmation_instructions.pt-BR.text.erb create mode 100644 app/views/user_mailer/password_change.pt-BR.html.erb create mode 100644 app/views/user_mailer/password_change.pt-BR.text.erb create mode 100644 app/views/user_mailer/reset_password_instructions.pt-BR.html.erb create mode 100644 app/views/user_mailer/reset_password_instructions.pt-BR.text.erb (limited to 'app/views') diff --git a/app/views/user_mailer/confirmation_instructions.pt-BR.html.erb b/app/views/user_mailer/confirmation_instructions.pt-BR.html.erb new file mode 100644 index 000000000..80edcfda7 --- /dev/null +++ b/app/views/user_mailer/confirmation_instructions.pt-BR.html.erb @@ -0,0 +1,12 @@ +

Boas vindas, <%= @resource.email %>!

+ +

Você acabou de criar uma conta no <%= @instance %>.

+ +

Para confirmar o seu cadastro, por favor clique no link a seguir:
+<%= link_to 'Confirmar cadastro', confirmation_url(@resource, confirmation_token: @token) %> + +

Por favor, leia também os nossos <%= link_to 'termos de serviços', terms_url %>.

+ +

Atenciosamente,

+ +

A equipe do <%= @instance %>

diff --git a/app/views/user_mailer/confirmation_instructions.pt-BR.text.erb b/app/views/user_mailer/confirmation_instructions.pt-BR.text.erb new file mode 100644 index 000000000..95efb3436 --- /dev/null +++ b/app/views/user_mailer/confirmation_instructions.pt-BR.text.erb @@ -0,0 +1,12 @@ +Boas vindas, <%= @resource.email %>! + +Você acabou de criar uma conta no <%= @instance %>. + +Para confirmar o seu cadastro, por favor clique no link a seguir: +<%= confirmation_url(@resource, confirmation_token: @token) %> + +Por favor, leia também os nossos termos e condições de uso <%= terms_url %> + +Atenciosamente, + +A equipe do <%= @instance %> diff --git a/app/views/user_mailer/password_change.pt-BR.html.erb b/app/views/user_mailer/password_change.pt-BR.html.erb new file mode 100644 index 000000000..5f707ba09 --- /dev/null +++ b/app/views/user_mailer/password_change.pt-BR.html.erb @@ -0,0 +1,3 @@ +

Olá, <%= @resource.email %>!

+ +

Estamos te contatando para te notificar que a senha senha no <%= @instance %> foi modificada.

diff --git a/app/views/user_mailer/password_change.pt-BR.text.erb b/app/views/user_mailer/password_change.pt-BR.text.erb new file mode 100644 index 000000000..d8b76648c --- /dev/null +++ b/app/views/user_mailer/password_change.pt-BR.text.erb @@ -0,0 +1,3 @@ +Olá, <%= @resource.email %>! + +Estamos te contatando para te notificar que a senha senha no <%= @instance %> foi modificada. diff --git a/app/views/user_mailer/reset_password_instructions.pt-BR.html.erb b/app/views/user_mailer/reset_password_instructions.pt-BR.html.erb new file mode 100644 index 000000000..940438b7c --- /dev/null +++ b/app/views/user_mailer/reset_password_instructions.pt-BR.html.erb @@ -0,0 +1,8 @@ +

Olá, <%= @resource.email %>!

+ +

Alguém solicitou um link para mudar a sua senha no <%= @instance %>. Você pode fazer isso através do link abaixo:

+ +

<%= link_to 'Mudar a minha senha', edit_password_url(@resource, reset_password_token: @token) %>

+ +

Se você não solicitou isso, por favor ignore este e-mail.

+

A senha senha não será modificada até que você acesse o link acima e crie uma nova.

diff --git a/app/views/user_mailer/reset_password_instructions.pt-BR.text.erb b/app/views/user_mailer/reset_password_instructions.pt-BR.text.erb new file mode 100644 index 000000000..f574fe08f --- /dev/null +++ b/app/views/user_mailer/reset_password_instructions.pt-BR.text.erb @@ -0,0 +1,8 @@ +Olá, <%= @resource.email %>! + +Alguém solicitou um link para mudar a sua senha no <%= @instance %>. Você pode fazer isso através do link abaixo: + +<%= edit_password_url(@resource, reset_password_token: @token) %> + +Se você não solicitou isso, por favor ignore este e-mail. +A senha senha não será modificada até que você acesse o link acima e crie uma nova. -- cgit From 47d48fed8d398a1d1ebae01fcded0eb9f4f73c42 Mon Sep 17 00:00:00 2001 From: unarist Date: Mon, 11 Sep 2017 23:19:54 +0900 Subject: Reset preview image if avatar/header image selection was cancelled (#4893) --- app/javascript/packs/public.js | 4 ++-- app/views/settings/profiles/show.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'app/views') diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 1a274c4cb..ca6f9eac6 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -124,7 +124,7 @@ function main() { delegate(document, '#account_avatar', 'change', ({ target }) => { const avatar = document.querySelector('.card.compact .avatar img'); const [file] = target.files || []; - const url = URL.createObjectURL(file); + const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc; avatar.src = url; }); @@ -132,7 +132,7 @@ function main() { delegate(document, '#account_header', 'change', ({ target }) => { const header = document.querySelector('.card.compact'); const [file] = target.files || []; - const url = URL.createObjectURL(file); + const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc; header.style.backgroundImage = `url(${url})`; }); diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index e0fb613f8..7a06cd014 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -8,8 +8,8 @@ = f.input :display_name, placeholder: t('simple_form.labels.defaults.display_name'), hint: t('simple_form.hints.defaults.display_name', count: 30 - @account.display_name.size).html_safe = f.input :note, placeholder: t('simple_form.labels.defaults.note'), hint: t('simple_form.hints.defaults.note', count: 160 - @account.note.size).html_safe - .card.compact{ style: "background-image: url(#{@account.header.url(:original)})" } - .avatar= image_tag @account.avatar.url(:original) + .card.compact{ style: "background-image: url(#{@account.header.url(:original)})", data: { original_src: @account.header.url(:original) } } + .avatar= image_tag @account.avatar.url(:original), data: { original_src: @account.avatar.url(:original) } .fields-group = f.input :avatar, wrapper: :with_label, input_html: { accept: AccountAvatar::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.avatar') -- cgit From 8f8e6776306b07d5914ef39c895de0cab44ada7f Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 12 Sep 2017 05:39:38 +0200 Subject: Clean up and improve generated OpenGraph tags (#4901) - Return all images as og:image - Return videos as og:image (preview) and og:video - Return profile:username on profiles --- app/helpers/application_helper.rb | 4 ++++ app/serializers/oembed_serializer.rb | 2 +- app/views/accounts/_og.html.haml | 17 +++++++++-------- app/views/accounts/show.html.haml | 2 +- app/views/stream_entries/_og_description.html.haml | 4 ++-- app/views/stream_entries/_og_image.html.haml | 22 ++++++++++++++++++---- app/views/stream_entries/show.html.haml | 10 +++++----- spec/views/stream_entries/show.html.haml_spec.rb | 8 ++++---- 8 files changed, 44 insertions(+), 25 deletions(-) (limited to 'app/views') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 61d4442c1..6d625e7db 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -42,4 +42,8 @@ module ApplicationHelper content_tag(:i, nil, attributes.merge(class: class_names.join(' '))) end + + def opengraph(property, content) + tag(:meta, content: content, property: property) + end end diff --git a/app/serializers/oembed_serializer.rb b/app/serializers/oembed_serializer.rb index af03fd47a..0c8350e2d 100644 --- a/app/serializers/oembed_serializer.rb +++ b/app/serializers/oembed_serializer.rb @@ -45,7 +45,7 @@ class OEmbedSerializer < ActiveModel::Serializer height: height, } - content_tag(:iframe, nil, attributes) + content_tag(:script, nil, src: full_asset_url('embed.js'), async: true) + content_tag(:iframe, nil, attributes) + content_tag(:script, nil, src: full_asset_url('embed.js', skip_pipeline: true), async: true) end def width diff --git a/app/views/accounts/_og.html.haml b/app/views/accounts/_og.html.haml index 3ad39f391..1d16be590 100644 --- a/app/views/accounts/_og.html.haml +++ b/app/views/accounts/_og.html.haml @@ -1,8 +1,9 @@ -%meta{ property: 'og:url', content: url }/ -%meta{ property: 'og:site_name', content: site_title }/ -%meta{ property: 'og:title', content: [yield(:page_title).strip.presence, site_title].compact.join(' - ') }/ -%meta{ property: 'og:description', content: account.note }/ -%meta{ property: 'og:image', content: full_asset_url(account.avatar.url(:original)) }/ -%meta{ property: 'og:image:width', content: '120' }/ -%meta{ property: 'og:image:height', content: '120' }/ -%meta{ property: 'twitter:card', content: 'summary' }/ += opengraph 'og:url', url += opengraph 'og:site_name', site_title += opengraph 'og:title', [yield(:page_title).strip.presence, site_title].compact.join(' - ') += opengraph 'og:description', account.note += opengraph 'og:image', full_asset_url(account.avatar.url(:original)) += opengraph 'og:image:width', '120' += opengraph 'og:image:height', '120' += opengraph 'twitter:card', 'summary' += opengraph 'profile:username', account.local_username_and_domain diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index e0f9f869a..6c90b2c04 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -9,7 +9,7 @@ %link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/ %link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(@account) }/ - %meta{ property: 'og:type', content: 'profile' }/ + = opengraph 'og:type', 'profile' = render 'og', account: @account, url: short_account_url(@account, only_path: false) - if show_landing_strip? diff --git a/app/views/stream_entries/_og_description.html.haml b/app/views/stream_entries/_og_description.html.haml index 5762aca04..d2fa99e63 100644 --- a/app/views/stream_entries/_og_description.html.haml +++ b/app/views/stream_entries/_og_description.html.haml @@ -1,4 +1,4 @@ - if activity.is_a?(Status) && activity.spoiler_text? - %meta{ property: 'og:description', content: activity.spoiler_text }/ + = opengraph 'og:description', activity.spoiler_text - else - %meta{ property: 'og:description', content: activity.content }/ + = opengraph 'og:description', activity.content diff --git a/app/views/stream_entries/_og_image.html.haml b/app/views/stream_entries/_og_image.html.haml index f725209d8..66d9619b2 100644 --- a/app/views/stream_entries/_og_image.html.haml +++ b/app/views/stream_entries/_og_image.html.haml @@ -1,6 +1,20 @@ - if activity.is_a?(Status) && activity.non_sensitive_with_media? - %meta{ property: 'og:image', content: full_asset_url(activity.media_attachments.first.file.url(:small)) }/ + - activity.media_attachments.each do |media| + - if media.image? + = opengraph 'og:image', full_asset_url(media.file.url(:original)) + = opengraph 'og:image:type', media.file_content_type + = opengraph 'og:image:width', media.file.meta['original']['width'] + = opengraph 'og:image:height', media.file.meta['original']['height'] + - elsif media.video? + = opengraph 'og:image', full_asset_url(media.file.url(:small)) + = opengraph 'og:image:type', 'image/png' + = opengraph 'og:image:width', media.file.meta['small']['width'] + = opengraph 'og:image:height', media.file.meta['small']['height'] + = opengraph 'og:video', full_asset_url(media.file.url(:original)) + = opengraph 'og:video:type', media.file_content_type + = opengraph 'og:video:width', media.file.meta['small']['width'] + = opengraph 'og:video:height', media.file.meta['small']['height'] - else - %meta{ property: 'og:image', content: full_asset_url(account.avatar.url(:original)) }/ - %meta{ property: 'og:image:width', content: '120' }/ - %meta{ property: 'og:image:height', content: '120' }/ + = opengraph 'og:image', full_asset_url(account.avatar.url(:original)) + = opengraph 'og:image:width', '120' + = opengraph 'og:image:height','120' diff --git a/app/views/stream_entries/show.html.haml b/app/views/stream_entries/show.html.haml index 5ef72f804..1bb8a32b2 100644 --- a/app/views/stream_entries/show.html.haml +++ b/app/views/stream_entries/show.html.haml @@ -6,15 +6,15 @@ %link{ rel: 'alternate', type: 'application/json+oembed', href: api_oembed_url(url: account_stream_entry_url(@account, @stream_entry), format: 'json') }/ %link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(@stream_entry.activity) }/ - %meta{ property: 'og:site_name', content: site_title }/ - %meta{ property: 'og:type', content: 'article' }/ - %meta{ property: 'og:title', content: "#{@account.username} on #{site_hostname}" }/ - %meta{ property: 'og:url', content: account_stream_entry_url(@account, @stream_entry) }/ + = opengraph 'og:site_name', site_title + = opengraph 'og:type', 'article' + = opengraph 'og:title', "#{@account.username} on #{site_hostname}" + = opengraph 'og:url', account_stream_entry_url(@account, @stream_entry) = render 'stream_entries/og_description', activity: @stream_entry.activity = render 'stream_entries/og_image', activity: @stream_entry.activity, account: @account - %meta{ property: 'twitter:card', content: 'summary' }/ + = opengraph 'twitter:card', 'summary_large_image' - if show_landing_strip? = render partial: 'shared/landing_strip', locals: { account: @stream_entry.account } diff --git a/spec/views/stream_entries/show.html.haml_spec.rb b/spec/views/stream_entries/show.html.haml_spec.rb index 6cc3b117a..59ea40990 100644 --- a/spec/views/stream_entries/show.html.haml_spec.rb +++ b/spec/views/stream_entries/show.html.haml_spec.rb @@ -80,9 +80,9 @@ describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true d header_tags = view.content_for(:header_tags) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) end end -- cgit From af10c9fbfff237e45ff46355d118e6824ae05b79 Mon Sep 17 00:00:00 2001 From: unarist Date: Wed, 13 Sep 2017 06:06:10 +0900 Subject: Add section for protocol specific information on the admin page (#4910) This PR adds section for protocol specific information, then always show both of OStatus and ActivityPub. Specifically, this will help admins to check PuSH subscription status and unsubscribe manually, even `protocol` has been changed. This also includes below changes: * Add `overflow: hidden` to prevent float leaking * Add missing fields for ActivityPub --- app/javascript/styles/admin.scss | 8 +++ app/views/admin/accounts/show.html.haml | 109 +++++++++++++++++++------------- config/locales/en.yml | 2 + 3 files changed, 75 insertions(+), 44 deletions(-) (limited to 'app/views') diff --git a/app/javascript/styles/admin.scss b/app/javascript/styles/admin.scss index fa7859e38..87bc710af 100644 --- a/app/javascript/styles/admin.scss +++ b/app/javascript/styles/admin.scss @@ -97,6 +97,14 @@ margin-bottom: 40px; } + h3 { + color: $ui-secondary-color; + font-size: 20px; + line-height: 28px; + font-weight: 400; + margin-bottom: 30px; + } + h6 { font-size: 16px; color: $ui-secondary-color; diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 89355281a..3775b6721 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -37,29 +37,6 @@ %th= t('admin.accounts.protocol') %td= @account.protocol.humanize - - if @account.ostatus? - %tr - %th= t('admin.accounts.feed_url') - %td= link_to @account.remote_url, @account.remote_url - %tr - %th= t('admin.accounts.push_subscription_expires') - %td - - if @account.subscribed? - %time.formatted{ datetime: @account.subscription_expires_at.iso8601, title: l(@account.subscription_expires_at) } - = l @account.subscription_expires_at - - else - = t('admin.accounts.not_subscribed') - %tr - %th= t('admin.accounts.salmon_url') - %td= link_to @account.salmon_url, @account.salmon_url - - elsif @account.activitypub? - %tr - %th= t('admin.accounts.inbox_url') - %td= link_to @account.inbox_url, @account.inbox_url - %tr - %th= t('admin.accounts.outbox_url') - %td= link_to @account.outbox_url, @account.outbox_url - %tr %th= t('admin.accounts.follows') %td= @account.following_count @@ -82,29 +59,73 @@ %th= t('.targeted_reports') %td= link_to pluralize(@account.targeted_reports.count, t('.report')), admin_reports_path(target_account_id: @account.id) -%div{ style: 'float: right' } - - if @account.local? - = link_to t('admin.accounts.reset_password'), admin_account_reset_path(@account.id), method: :create, class: 'button' - - if @account.user&.otp_required_for_login? - = link_to t('admin.accounts.disable_two_factor_authentication'), admin_user_two_factor_authentication_path(@account.user.id), method: :delete, class: 'button' - - else - - if @account.ostatus? +%div{ style: 'overflow: hidden' } + %div{ style: 'float: right' } + - if @account.local? + = link_to t('admin.accounts.reset_password'), admin_account_reset_path(@account.id), method: :create, class: 'button' + - if @account.user&.otp_required_for_login? + = link_to t('admin.accounts.disable_two_factor_authentication'), admin_user_two_factor_authentication_path(@account.user.id), method: :delete, class: 'button' + - else + = link_to t('admin.accounts.redownload'), redownload_admin_account_path(@account.id), method: :post, class: 'button' + + %div{ style: 'float: left' } + - if @account.silenced? + = link_to t('admin.accounts.undo_silenced'), admin_account_silence_path(@account.id), method: :delete, class: 'button' + - else + = link_to t('admin.accounts.silence'), admin_account_silence_path(@account.id), method: :post, class: 'button' + + - if @account.local? + - unless @account.user_confirmed? + = link_to t('admin.accounts.confirm'), admin_account_confirmation_path(@account.id), method: :post, class: 'button' + + - if @account.suspended? + = link_to t('admin.accounts.undo_suspension'), admin_account_suspension_path(@account.id), method: :delete, class: 'button' + - else + = link_to t('admin.accounts.perform_full_suspension'), admin_account_suspension_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' + +- unless @account.local? + %hr + %h3 OStatus + + .table-wrapper + %table.table + %tbody + %tr + %th= t('admin.accounts.feed_url') + %td= link_to @account.remote_url, @account.remote_url + %tr + %th= t('admin.accounts.push_subscription_expires') + %td + - if @account.subscribed? + %time.formatted{ datetime: @account.subscription_expires_at.iso8601, title: l(@account.subscription_expires_at) } + = l @account.subscription_expires_at + - else + = t('admin.accounts.not_subscribed') + %tr + %th= t('admin.accounts.salmon_url') + %td= link_to @account.salmon_url, @account.salmon_url + + %div{ style: 'overflow: hidden' } + %div{ style: 'float: right' } = link_to @account.subscribed? ? t('admin.accounts.resubscribe') : t('admin.accounts.subscribe'), subscribe_admin_account_path(@account.id), method: :post, class: 'button' - if @account.subscribed? = link_to t('admin.accounts.unsubscribe'), unsubscribe_admin_account_path(@account.id), method: :post, class: 'button negative' - = link_to t('admin.accounts.redownload'), redownload_admin_account_path(@account.id), method: :post, class: 'button' - -%div{ style: 'float: left' } - - if @account.silenced? - = link_to t('admin.accounts.undo_silenced'), admin_account_silence_path(@account.id), method: :delete, class: 'button' - - else - = link_to t('admin.accounts.silence'), admin_account_silence_path(@account.id), method: :post, class: 'button' - - if @account.local? - - unless @account.user_confirmed? - = link_to t('admin.accounts.confirm'), admin_account_confirmation_path(@account.id), method: :post, class: 'button' + %hr + %h3 ActivityPub - - if @account.suspended? - = link_to t('admin.accounts.undo_suspension'), admin_account_suspension_path(@account.id), method: :delete, class: 'button' - - else - = link_to t('admin.accounts.perform_full_suspension'), admin_account_suspension_path(@account.id), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }, class: 'button' + .table-wrapper + %table.table + %tbody + %tr + %th= t('admin.accounts.inbox_url') + %td= link_to @account.inbox_url, @account.inbox_url + %tr + %th= t('admin.accounts.outbox_url') + %td= link_to @account.outbox_url, @account.outbox_url + %tr + %th= t('admin.accounts.shared_inbox_url') + %td= link_to @account.shared_inbox_url, @account.shared_inbox_url + %tr + %th= t('admin.accounts.followers_url') + %td= link_to @account.followers_url, @account.followers_url diff --git a/config/locales/en.yml b/config/locales/en.yml index 64fc556f3..e31f883ac 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -60,6 +60,7 @@ en: email: E-mail feed_url: Feed URL followers: Followers + followers_url: Followers URL follows: Follows inbox_url: Inbox URL ip: IP @@ -93,6 +94,7 @@ en: resubscribe: Resubscribe salmon_url: Salmon URL search: Search + shared_inbox_url: Shared Inbox URL show: created_reports: Reports created by this account report: report -- cgit From 9e2ff3ef71e917ba88a9062814f3e828f9199009 Mon Sep 17 00:00:00 2001 From: nullkal Date: Wed, 13 Sep 2017 18:34:07 +0900 Subject: Make instance names in into links to user list in the instance (#4924) --- app/views/admin/instances/_instance.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/views') diff --git a/app/views/admin/instances/_instance.html.haml b/app/views/admin/instances/_instance.html.haml index 435cd8f64..6efbbbe60 100644 --- a/app/views/admin/instances/_instance.html.haml +++ b/app/views/admin/instances/_instance.html.haml @@ -1,6 +1,6 @@ %tr %td.domain - = instance.domain + = link_to instance.domain, admin_accounts_path(by_domain: instance.domain) %td.count = instance.accounts_count %td -- cgit From da77f65c4684a8a9ee25c3e18f6f09824c765c2d Mon Sep 17 00:00:00 2001 From: nullkal Date: Wed, 13 Sep 2017 19:30:07 +0900 Subject: Add instance search feature (#4925) --- app/controllers/admin/instances_controller.rb | 12 +++++++++++- app/models/account.rb | 1 + app/models/instance_filter.rb | 28 +++++++++++++++++++++++++++ app/views/admin/instances/index.html.haml | 10 ++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 app/models/instance_filter.rb (limited to 'app/views') diff --git a/app/controllers/admin/instances_controller.rb b/app/controllers/admin/instances_controller.rb index 3296e08db..22f02e5d0 100644 --- a/app/controllers/admin/instances_controller.rb +++ b/app/controllers/admin/instances_controller.rb @@ -14,8 +14,12 @@ module Admin private + def filtered_instances + InstanceFilter.new(filter_params).results + end + def paginated_instances - Account.remote.by_domain_accounts.page(params[:page]) + filtered_instances.page(params[:page]) end helper_method :paginated_instances @@ -27,5 +31,11 @@ module Admin def subscribeable_accounts Account.with_followers.remote.where(domain: params[:by_domain]) end + + def filter_params + params.permit( + :domain_name + ) + end end end diff --git a/app/models/account.rb b/app/models/account.rb index 864b3cb6e..f175c7081 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -104,6 +104,7 @@ class Account < ApplicationRecord scope :by_domain_accounts, -> { group(:domain).select(:domain, 'COUNT(*) AS accounts_count').order('accounts_count desc') } scope :matches_username, ->(value) { where(arel_table[:username].matches("#{value}%")) } scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) } + scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) } delegate :email, :current_sign_in_ip, diff --git a/app/models/instance_filter.rb b/app/models/instance_filter.rb new file mode 100644 index 000000000..5073cf1fa --- /dev/null +++ b/app/models/instance_filter.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class InstanceFilter + attr_reader :params + + def initialize(params) + @params = params + end + + def results + scope = Account.remote.by_domain_accounts + params.each do |key, value| + scope.merge!(scope_for(key, value)) if value.present? + end + scope + end + + private + + def scope_for(key, value) + case key.to_s + when 'domain_name' + Account.matches_domain(value) + else + raise "Unknown filter: #{key}" + end + end +end diff --git a/app/views/admin/instances/index.html.haml b/app/views/admin/instances/index.html.haml index edbd3b217..3314ce077 100644 --- a/app/views/admin/instances/index.html.haml +++ b/app/views/admin/instances/index.html.haml @@ -1,6 +1,16 @@ - content_for :page_title do = t('admin.instances.title') += form_tag admin_instances_url, method: 'GET', class: 'simple_form' do + .fields-group + - %i(domain_name).each do |key| + .input.string.optional + = text_field_tag key, params[key], class: 'string optional', placeholder: I18n.t("admin.instances.#{key}") + + .actions + %button= t('admin.instances.search') + = link_to t('admin.instances.reset'), admin_instances_path, class: 'button negative' + .table-wrapper %table.table %thead -- cgit From 9239e4ce4d4e958e62552d4a01183d0295c020f5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 14 Sep 2017 00:04:30 +0200 Subject: Uploads for admin site settings (#4913) * Improve OpenGraph tags for about pages * Add thumbnail admin setting * Fix error * Fix up --- app/controllers/admin/settings_controller.rb | 14 ++++++-- app/javascript/images/mastodon_small.jpg | Bin 25199 -> 0 bytes app/javascript/images/preview.jpg | Bin 0 -> 292252 bytes app/models/site_upload.rb | 44 +++++++++++++++++++++++ app/presenters/instance_presenter.rb | 4 +++ app/serializers/rest/instance_serializer.rb | 8 ++++- app/views/about/_og.html.haml | 10 ++++++ app/views/about/more.html.haml | 11 +----- app/views/about/show.html.haml | 11 +----- app/views/admin/settings/edit.html.haml | 5 +++ config/locales/en.yml | 3 ++ db/migrate/20170913000752_create_site_uploads.rb | 10 ++++++ db/schema.rb | 14 +++++++- spec/fabricators/site_upload_fabricator.rb | 3 ++ spec/models/site_upload_spec.rb | 5 +++ spec/views/about/show.html.haml_spec.rb | 9 ++--- 16 files changed, 123 insertions(+), 28 deletions(-) delete mode 100644 app/javascript/images/mastodon_small.jpg create mode 100644 app/javascript/images/preview.jpg create mode 100644 app/models/site_upload.rb create mode 100644 app/views/about/_og.html.haml create mode 100644 db/migrate/20170913000752_create_site_uploads.rb create mode 100644 spec/fabricators/site_upload_fabricator.rb create mode 100644 spec/models/site_upload_spec.rb (limited to 'app/views') diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index c5e6fe4e5..a2f86b8a9 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -14,6 +14,7 @@ module Admin open_deletion timeline_preview bootstrap_timeline_accounts + thumbnail ).freeze BOOLEAN_SETTINGS = %w( @@ -22,14 +23,23 @@ module Admin timeline_preview ).freeze + UPLOAD_SETTINGS = %w( + thumbnail + ).freeze + def edit @admin_settings = Form::AdminSettings.new end def update settings_params.each do |key, value| - setting = Setting.where(var: key).first_or_initialize(var: key) - setting.update(value: value_for_update(key, value)) + if UPLOAD_SETTINGS.include?(key) + upload = SiteUpload.where(var: key).first_or_initialize(var: key) + upload.update(file: value) + else + setting = Setting.where(var: key).first_or_initialize(var: key) + setting.update(value: value_for_update(key, value)) + end end flash[:notice] = I18n.t('generic.changes_saved_msg') diff --git a/app/javascript/images/mastodon_small.jpg b/app/javascript/images/mastodon_small.jpg deleted file mode 100644 index 9c88ce3f7..000000000 Binary files a/app/javascript/images/mastodon_small.jpg and /dev/null differ diff --git a/app/javascript/images/preview.jpg b/app/javascript/images/preview.jpg new file mode 100644 index 000000000..ec2856748 Binary files /dev/null and b/app/javascript/images/preview.jpg differ diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb new file mode 100644 index 000000000..8ffdc8313 --- /dev/null +++ b/app/models/site_upload.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +# == Schema Information +# +# Table name: site_uploads +# +# id :integer not null, primary key +# var :string default(""), not null +# file_file_name :string +# file_content_type :string +# file_file_size :integer +# file_updated_at :datetime +# meta :json +# created_at :datetime not null +# updated_at :datetime not null +# + +class SiteUpload < ApplicationRecord + has_attached_file :file + + validates_attachment_content_type :file, content_type: /\Aimage\/.*\z/ + validates :var, presence: true, uniqueness: true + + before_save :set_meta + after_commit :clear_cache + + def cache_key + "site_uploads/#{var}" + end + + private + + def set_meta + tempfile = file.queued_for_write[:original] + + return if tempfile.nil? + + geometry = Paperclip::Geometry.from_file(tempfile) + self.meta = { width: geometry.width.to_i, height: geometry.height.to_i } + end + + def clear_cache + Rails.cache.delete(cache_key) + end +end diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb index 8104b7531..c9e3c31a1 100644 --- a/app/presenters/instance_presenter.rb +++ b/app/presenters/instance_presenter.rb @@ -35,4 +35,8 @@ class InstancePresenter def source_url Mastodon::Version.source_url end + + def thumbnail + @thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') } + end end diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index a97137909..2898011fd 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true class REST::InstanceSerializer < ActiveModel::Serializer + include RoutingHelper + attributes :uri, :title, :description, :email, - :version, :urls, :stats + :version, :urls, :stats, :thumbnail def uri Rails.configuration.x.local_domain @@ -24,6 +26,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer Mastodon::Version.to_s end + def thumbnail + full_asset_url(instance_presenter.thumbnail.file.url) if instance_presenter.thumbnail + end + def stats { user_count: instance_presenter.user_count, diff --git a/app/views/about/_og.html.haml b/app/views/about/_og.html.haml new file mode 100644 index 000000000..dbd476915 --- /dev/null +++ b/app/views/about/_og.html.haml @@ -0,0 +1,10 @@ +- thumbnail = @instance_presenter.thumbnail += opengraph 'og:site_name', t('about.hosted_on', domain: site_hostname) += opengraph 'og:url', about_url += opengraph 'og:type', 'website' += opengraph 'og:title', @instance_presenter.site_title += opengraph 'og:description', strip_tags(@instance_presenter.site_description.presence || t('about.about_mastodon_html')) += opengraph 'og:image', full_asset_url(thumbnail&.file&.url || asset_pack_path('preview.jpg', protocol: :request)) += opengraph 'og:image:width', thumbnail ? thumbnail.meta['width'] : '1200' += opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630' += opengraph 'twitter:card', 'summary_large_image' diff --git a/app/views/about/more.html.haml b/app/views/about/more.html.haml index 094188472..1a4e74643 100644 --- a/app/views/about/more.html.haml +++ b/app/views/about/more.html.haml @@ -3,16 +3,7 @@ - content_for :header_tags do = javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous' - - %meta{ property: 'og:site_name', content: site_title }/ - %meta{ property: 'og:url', content: about_url }/ - %meta{ property: 'og:type', content: 'website' }/ - %meta{ property: 'og:title', content: site_hostname }/ - %meta{ property: 'og:description', content: strip_tags(@instance_presenter.site_description.presence || t('about.about_mastodon_html')) }/ - %meta{ property: 'og:image', content: asset_pack_path('mastodon_small.jpg', protocol: :request) }/ - %meta{ property: 'og:image:width', content: '400' }/ - %meta{ property: 'og:image:height', content: '400' }/ - %meta{ property: 'twitter:card', content: 'summary' }/ + = render partial: 'og' .landing-page .header-wrapper.compact diff --git a/app/views/about/show.html.haml b/app/views/about/show.html.haml index 93270fe3d..0d311b895 100644 --- a/app/views/about/show.html.haml +++ b/app/views/about/show.html.haml @@ -4,16 +4,7 @@ - content_for :header_tags do %script#initial-state{ type: 'application/json' }!= json_escape(@initial_state_json) = javascript_pack_tag 'about', integrity: true, crossorigin: 'anonymous' - - %meta{ property: 'og:site_name', content: site_title }/ - %meta{ property: 'og:url', content: about_url }/ - %meta{ property: 'og:type', content: 'website' }/ - %meta{ property: 'og:title', content: site_hostname }/ - %meta{ property: 'og:description', content: strip_tags(@instance_presenter.site_description.presence || t('about.about_mastodon_html')) }/ - %meta{ property: 'og:image', content: asset_pack_path('mastodon_small.jpg', protocol: :request) }/ - %meta{ property: 'og:image:width', content: '400' }/ - %meta{ property: 'og:image:height', content: '400' }/ - %meta{ property: 'twitter:card', content: 'summary' }/ + = render partial: 'og' .landing-page .header-wrapper diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 50d019ec4..468166035 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -10,6 +10,11 @@ %hr/ + .fields-group + = f.input :thumbnail, as: :file, wrapper: :with_block_label, label: t('admin.settings.thumbnail.title'), hint: t('admin.settings.thumbnail.desc_html') + + %hr/ + .fields-group = f.input :timeline_preview, as: :boolean, wrapper: :with_label, label: t('admin.settings.timeline_preview.title'), hint: t('admin.settings.timeline_preview.desc_html') diff --git a/config/locales/en.yml b/config/locales/en.yml index 0cd57a64f..8b5f52b02 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -195,6 +195,9 @@ en: desc_html: You can write your own privacy policy, terms of service or other legalese. You can use HTML tags title: Custom terms of service site_title: Instance name + thumbnail: + desc_html: Used for previews via OpenGraph and API. 1200x630px recommended + title: Instance thumbnail timeline_preview: desc_html: Display public timeline on landing page title: Timeline preview diff --git a/db/migrate/20170913000752_create_site_uploads.rb b/db/migrate/20170913000752_create_site_uploads.rb new file mode 100644 index 000000000..2246e48cd --- /dev/null +++ b/db/migrate/20170913000752_create_site_uploads.rb @@ -0,0 +1,10 @@ +class CreateSiteUploads < ActiveRecord::Migration[5.1] + def change + create_table :site_uploads do |t| + t.string :var, default: '', null: false, index: { unique: true } + t.attachment :file + t.json :meta + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d8af0a1f8..f2ca2af69 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170905165803) do +ActiveRecord::Schema.define(version: 20170913000752) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -288,6 +288,18 @@ ActiveRecord::Schema.define(version: 20170905165803) do t.index ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true end + create_table "site_uploads", force: :cascade do |t| + t.string "var", default: "", null: false + t.string "file_file_name" + t.string "file_content_type" + t.integer "file_file_size" + t.datetime "file_updated_at" + t.json "meta" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["var"], name: "index_site_uploads_on_var", unique: true + end + create_table "status_pins", force: :cascade do |t| t.bigint "account_id", null: false t.bigint "status_id", null: false diff --git a/spec/fabricators/site_upload_fabricator.rb b/spec/fabricators/site_upload_fabricator.rb new file mode 100644 index 000000000..8f4e43ac9 --- /dev/null +++ b/spec/fabricators/site_upload_fabricator.rb @@ -0,0 +1,3 @@ +Fabricator(:site_upload) do + +end diff --git a/spec/models/site_upload_spec.rb b/spec/models/site_upload_spec.rb new file mode 100644 index 000000000..8745d54b8 --- /dev/null +++ b/spec/models/site_upload_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SiteUpload, type: :model do + +end diff --git a/spec/views/about/show.html.haml_spec.rb b/spec/views/about/show.html.haml_spec.rb index aa151dd27..724643cbc 100644 --- a/spec/views/about/show.html.haml_spec.rb +++ b/spec/views/about/show.html.haml_spec.rb @@ -15,15 +15,16 @@ describe 'about/show.html.haml', without_verify_partial_doubles: true do version_number: '1.0', source_url: 'https://github.com/tootsuite/mastodon', open_registrations: false, + thumbnail: nil, closed_registrations_message: 'yes') assign(:instance_presenter, instance_presenter) render header_tags = view.content_for(:header_tags) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) - expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) + expect(header_tags).to match(%r{}) end end -- cgit From 2bbf987a0a352a36ef0cc7f06fe366b60593e89c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 14 Sep 2017 03:39:10 +0200 Subject: Redesign video player (#4911) * Redesign video player * Use new video player on static public pages too * Use media gallery component on static public pages too * Pause video when hiding it * Full-screen sizing on WebKit * Add aria labels to video player buttons * Display link card on public status page * Fix fullscreen from modal sizing issue * Remove contain: strict property to fix fullscreen from columns --- app/javascript/mastodon/components/status.js | 19 +- .../mastodon/containers/card_container.js | 18 ++ .../mastodon/containers/media_gallery_container.js | 34 +++ .../mastodon/containers/video_container.js | 26 ++ .../mastodon/features/status/components/card.js | 10 +- .../features/status/components/detailed_status.js | 19 +- .../mastodon/features/ui/components/video_modal.js | 22 +- .../mastodon/features/ui/util/async-components.js | 4 + app/javascript/mastodon/features/video/index.js | 304 +++++++++++++++++++++ app/javascript/mastodon/locales/ar.json | 11 + app/javascript/mastodon/locales/bg.json | 11 + app/javascript/mastodon/locales/ca.json | 11 + app/javascript/mastodon/locales/de.json | 11 + .../mastodon/locales/defaultMessages.json | 62 +++++ app/javascript/mastodon/locales/en.json | 13 +- app/javascript/mastodon/locales/eo.json | 11 + app/javascript/mastodon/locales/es.json | 11 + app/javascript/mastodon/locales/fa.json | 13 +- app/javascript/mastodon/locales/fi.json | 11 + app/javascript/mastodon/locales/fr.json | 13 +- app/javascript/mastodon/locales/he.json | 11 + app/javascript/mastodon/locales/hr.json | 12 +- app/javascript/mastodon/locales/hu.json | 11 + app/javascript/mastodon/locales/id.json | 11 + app/javascript/mastodon/locales/io.json | 11 + app/javascript/mastodon/locales/it.json | 11 + app/javascript/mastodon/locales/ja.json | 13 +- app/javascript/mastodon/locales/ko.json | 13 +- app/javascript/mastodon/locales/nl.json | 11 + app/javascript/mastodon/locales/no.json | 11 + app/javascript/mastodon/locales/oc.json | 13 +- app/javascript/mastodon/locales/pl.json | 9 + app/javascript/mastodon/locales/pt-BR.json | 13 +- app/javascript/mastodon/locales/pt.json | 11 + app/javascript/mastodon/locales/ru.json | 11 + app/javascript/mastodon/locales/th.json | 11 + app/javascript/mastodon/locales/tr.json | 11 + app/javascript/mastodon/locales/uk.json | 11 + app/javascript/mastodon/locales/zh-CN.json | 11 + app/javascript/mastodon/locales/zh-HK.json | 11 + app/javascript/mastodon/locales/zh-TW.json | 11 + app/javascript/packs/public.js | 30 +- app/javascript/styles/components.scss | 197 ++++++++++++- app/javascript/styles/stream_entries.scss | 150 +--------- .../stream_entries/_detailed_status.html.haml | 15 +- app/views/stream_entries/_simple_status.html.haml | 17 +- 46 files changed, 1064 insertions(+), 217 deletions(-) create mode 100644 app/javascript/mastodon/containers/card_container.js create mode 100644 app/javascript/mastodon/containers/media_gallery_container.js create mode 100644 app/javascript/mastodon/containers/video_container.js create mode 100644 app/javascript/mastodon/features/video/index.js (limited to 'app/views') diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 30a0c10cb..82359156d 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -9,7 +9,7 @@ import StatusContent from './status_content'; import StatusActionBar from './status_action_bar'; import { FormattedMessage } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; -import { MediaGallery, VideoPlayer } from '../features/ui/util/async-components'; +import { MediaGallery, Video } from '../features/ui/util/async-components'; // We use the component (and not the container) since we do not want // to use the progress bar to show download progress @@ -88,6 +88,10 @@ export default class Status extends ImmutablePureComponent { return
; } + handleOpenVideo = startTime => { + this.props.onOpenVideo(this.props.status.getIn(['media_attachments', 0]), startTime); + } + render () { let media = null; let statusAvatar; @@ -127,9 +131,18 @@ export default class Status extends ImmutablePureComponent { if (status.get('media_attachments').some(item => item.get('type') === 'unknown')) { } else if (status.getIn(['media_attachments', 0, 'type']) === 'video') { + const video = status.getIn(['media_attachments', 0]); + media = ( - - {Component => } + + {Component => } ); } else { diff --git a/app/javascript/mastodon/containers/card_container.js b/app/javascript/mastodon/containers/card_container.js new file mode 100644 index 000000000..11b9f88d4 --- /dev/null +++ b/app/javascript/mastodon/containers/card_container.js @@ -0,0 +1,18 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import Card from '../features/status/components/card'; +import { fromJS } from 'immutable'; + +export default class CardContainer extends React.PureComponent { + + static propTypes = { + locale: PropTypes.string, + card: PropTypes.array.isRequired, + }; + + render () { + const { card, ...props } = this.props; + return ; + } + +} diff --git a/app/javascript/mastodon/containers/media_gallery_container.js b/app/javascript/mastodon/containers/media_gallery_container.js new file mode 100644 index 000000000..812c3d4e5 --- /dev/null +++ b/app/javascript/mastodon/containers/media_gallery_container.js @@ -0,0 +1,34 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { IntlProvider, addLocaleData } from 'react-intl'; +import { getLocale } from '../locales'; +import MediaGallery from '../components/media_gallery'; +import { fromJS } from 'immutable'; + +const { localeData, messages } = getLocale(); +addLocaleData(localeData); + +export default class MediaGalleryContainer extends React.PureComponent { + + static propTypes = { + locale: PropTypes.string.isRequired, + media: PropTypes.array.isRequired, + }; + + handleOpenMedia = () => {} + + render () { + const { locale, media, ...props } = this.props; + + return ( + + + + ); + } + +} diff --git a/app/javascript/mastodon/containers/video_container.js b/app/javascript/mastodon/containers/video_container.js new file mode 100644 index 000000000..2fd353096 --- /dev/null +++ b/app/javascript/mastodon/containers/video_container.js @@ -0,0 +1,26 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { IntlProvider, addLocaleData } from 'react-intl'; +import { getLocale } from '../locales'; +import Video from '../features/video'; + +const { localeData, messages } = getLocale(); +addLocaleData(localeData); + +export default class VideoContainer extends React.PureComponent { + + static propTypes = { + locale: PropTypes.string.isRequired, + }; + + render () { + const { locale, ...props } = this.props; + + return ( + + + ); + } + +} diff --git a/app/javascript/mastodon/features/status/components/card.js b/app/javascript/mastodon/features/status/components/card.js index 6b13e15cc..41c4300d3 100644 --- a/app/javascript/mastodon/features/status/components/card.js +++ b/app/javascript/mastodon/features/status/components/card.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import punycode from 'punycode'; import classnames from 'classnames'; @@ -22,10 +23,15 @@ export default class Card extends React.PureComponent { static propTypes = { card: ImmutablePropTypes.map, + maxDescription: PropTypes.number, + }; + + static defaultProps = { + maxDescription: 50, }; renderLink () { - const { card } = this.props; + const { card, maxDescription } = this.props; let image = ''; let provider = card.get('provider_name'); @@ -52,7 +58,7 @@ export default class Card extends React.PureComponent {
{card.get('title')} -

{(card.get('description') || '').substring(0, 50)}

+

{(card.get('description') || '').substring(0, maxDescription)}

{provider}
diff --git a/app/javascript/mastodon/features/status/components/detailed_status.js b/app/javascript/mastodon/features/status/components/detailed_status.js index 940a2699b..b11b41780 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.js +++ b/app/javascript/mastodon/features/status/components/detailed_status.js @@ -5,12 +5,12 @@ import Avatar from '../../../components/avatar'; import DisplayName from '../../../components/display_name'; import StatusContent from '../../../components/status_content'; import MediaGallery from '../../../components/media_gallery'; -import VideoPlayer from '../../../components/video_player'; import AttachmentList from '../../../components/attachment_list'; import Link from 'react-router-dom/Link'; import { FormattedDate, FormattedNumber } from 'react-intl'; import CardContainer from '../containers/card_container'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import Video from '../../video'; export default class DetailedStatus extends ImmutablePureComponent { @@ -34,6 +34,10 @@ export default class DetailedStatus extends ImmutablePureComponent { e.stopPropagation(); } + handleOpenVideo = startTime => { + this.props.onOpenVideo(this.props.status.getIn(['media_attachments', 0]), startTime); + } + render () { const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status; @@ -44,7 +48,18 @@ export default class DetailedStatus extends ImmutablePureComponent { if (status.get('media_attachments').some(item => item.get('type') === 'unknown')) { media = ; } else if (status.getIn(['media_attachments', 0, 'type']) === 'video') { - media = ; + const video = status.getIn(['media_attachments', 0]); + + media = ( +