mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-23 13:05:12 +01:00
Add attachment list fallback to public pages (#9780)
* Add attachment list fallback to public pages Fixes #6714 * Refactor attachments lists
This commit is contained in:
parent
9ee9cb549b
commit
4fb94c758e
@ -69,8 +69,12 @@ module ApplicationHelper
|
|||||||
tag(:meta, content: content, property: property)
|
tag(:meta, content: content, property: property)
|
||||||
end
|
end
|
||||||
|
|
||||||
def react_component(name, props = {})
|
def react_component(name, props = {}, &block)
|
||||||
|
if block.nil?
|
||||||
content_tag(:div, nil, data: { component: name.to_s.camelcase, props: Oj.dump(props) })
|
content_tag(:div, nil, data: { component: name.to_s.camelcase, props: Oj.dump(props) })
|
||||||
|
else
|
||||||
|
content_tag(:div, data: { component: name.to_s.camelcase, props: Oj.dump(props) }, &block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def body_classes
|
def body_classes
|
||||||
|
@ -83,6 +83,12 @@ function main() {
|
|||||||
if (reactComponents.length > 0) {
|
if (reactComponents.length > 0) {
|
||||||
import(/* webpackChunkName: "containers/media_container" */ '../mastodon/containers/media_container')
|
import(/* webpackChunkName: "containers/media_container" */ '../mastodon/containers/media_container')
|
||||||
.then(({ default: MediaContainer }) => {
|
.then(({ default: MediaContainer }) => {
|
||||||
|
[].forEach.call(reactComponents, (component) => {
|
||||||
|
[].forEach.call(component.children, (child) => {
|
||||||
|
component.removeChild(child);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const content = document.createElement('div');
|
const content = document.createElement('div');
|
||||||
|
|
||||||
ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
|
ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
|
||||||
|
8
app/views/stream_entries/_attachment_list.html.haml
Normal file
8
app/views/stream_entries/_attachment_list.html.haml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.attachment-list
|
||||||
|
.attachment-list__icon
|
||||||
|
= fa_icon 'link'
|
||||||
|
%ul.attachment-list__list
|
||||||
|
- attachments.each do |media|
|
||||||
|
%li
|
||||||
|
- url = media.remote_url.presence || media.file.url
|
||||||
|
= link_to File.basename(url), url, title: media.description
|
@ -25,9 +25,11 @@
|
|||||||
- if !status.media_attachments.empty?
|
- if !status.media_attachments.empty?
|
||||||
- if status.media_attachments.first.video?
|
- if status.media_attachments.first.video?
|
||||||
- video = status.media_attachments.first
|
- video = status.media_attachments.first
|
||||||
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 670, height: 380, detailed: true, inline: true, alt: video.description
|
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 670, height: 380, detailed: true, inline: true, alt: video.description do
|
||||||
|
= render partial: 'stream_entries/attachment_list', locals: { attachments: status.media_attachments }
|
||||||
- else
|
- else
|
||||||
= react_component :media_gallery, height: 380, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, standalone: true, 'autoPlayGif': current_account&.user&.setting_auto_play_gif || autoplay, 'reduceMotion': current_account&.user&.setting_reduce_motion, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }
|
= react_component :media_gallery, height: 380, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, standalone: true, 'autoPlayGif': current_account&.user&.setting_auto_play_gif || autoplay, 'reduceMotion': current_account&.user&.setting_reduce_motion, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } do
|
||||||
|
= render partial: 'stream_entries/attachment_list', locals: { attachments: status.media_attachments }
|
||||||
- elsif status.preview_card
|
- elsif status.preview_card
|
||||||
= react_component :card, 'maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_card, serializer: REST::PreviewCardSerializer).as_json
|
= react_component :card, 'maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_card, serializer: REST::PreviewCardSerializer).as_json
|
||||||
|
|
||||||
|
@ -29,9 +29,11 @@
|
|||||||
- if !status.media_attachments.empty?
|
- if !status.media_attachments.empty?
|
||||||
- if status.media_attachments.first.video?
|
- if status.media_attachments.first.video?
|
||||||
- video = status.media_attachments.first
|
- video = status.media_attachments.first
|
||||||
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 610, height: 343, inline: true, alt: video.description
|
= react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 610, height: 343, inline: true, alt: video.description do
|
||||||
|
= render partial: 'stream_entries/attachment_list', locals: { attachments: status.media_attachments }
|
||||||
- else
|
- else
|
||||||
= react_component :media_gallery, height: 343, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, 'autoPlayGif': current_account&.user&.setting_auto_play_gif || autoplay, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json }
|
= react_component :media_gallery, height: 343, sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, 'autoPlayGif': current_account&.user&.setting_auto_play_gif || autoplay, media: status.media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json } do
|
||||||
|
= render partial: 'stream_entries/attachment_list', locals: { attachments: status.media_attachments }
|
||||||
- elsif status.preview_card
|
- elsif status.preview_card
|
||||||
= react_component :card, 'maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_card, serializer: REST::PreviewCardSerializer).as_json
|
= react_component :card, 'maxDescription': 160, card: ActiveModelSerializers::SerializableResource.new(status.preview_card, serializer: REST::PreviewCardSerializer).as_json
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user