Add OEmbed iframe HTML, convert emojis on public pages, increase size of attachment thumbnails
This commit is contained in:
parent
6de079a5af
commit
aed25932b5
|
@ -1,2 +1,3 @@
|
|||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require extras
|
||||
|
|
8
app/assets/javascripts/extras.jsx
Normal file
8
app/assets/javascripts/extras.jsx
Normal file
|
@ -0,0 +1,8 @@
|
|||
import emojify from './components/emoji'
|
||||
|
||||
$(() => {
|
||||
$.each($('.entry .content, .name, .account__header__content'), (_, content) => {
|
||||
const $content = $(content);
|
||||
$content.html(emojify($content.html()));
|
||||
});
|
||||
});
|
|
@ -114,6 +114,18 @@ body {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
&.embed {
|
||||
background: transparent;
|
||||
margin: 0;
|
||||
|
||||
.container {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 360px) {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
|
|
@ -232,3 +232,24 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.embed {
|
||||
.activity-stream {
|
||||
border-radius: 4px;
|
||||
box-shadow: none;
|
||||
|
||||
.entry {
|
||||
&:last-child {
|
||||
border-radius: 0 0 4px 4px;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border-radius: 4px 4px 0 0;
|
||||
|
||||
&:last-child {
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ class Api::OembedController < ApiController
|
|||
|
||||
def show
|
||||
@stream_entry = stream_entry_from_url(params[:url])
|
||||
@width = [300, params[:maxwidth].to_i].min
|
||||
@height = [200, params[:maxheight].to_i].min
|
||||
@width = [300, params[:maxwidth].to_i].max
|
||||
@height = [200, params[:maxheight].to_i].max
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -25,6 +25,15 @@ class StreamEntriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def embed
|
||||
response.headers['X-Frame-Options'] = 'ALLOWALL'
|
||||
@type = @stream_entry.activity_type.downcase
|
||||
|
||||
return gone if @stream_entry.activity.nil?
|
||||
|
||||
render layout: 'embedded'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
|
|
|
@ -45,14 +45,14 @@ class MediaAttachment < ApplicationRecord
|
|||
if f.instance.image?
|
||||
{
|
||||
original: '1280x1280>',
|
||||
small: '250x250>',
|
||||
small: '400x400>',
|
||||
}
|
||||
else
|
||||
{
|
||||
small: {
|
||||
convert_options: {
|
||||
output: {
|
||||
vf: 'scale=\'min(250\, iw):min(250\, ih)\':force_original_aspect_ratio=decrease',
|
||||
vf: 'scale=\'min(400\, iw):min(400\, ih)\':force_original_aspect_ratio=decrease',
|
||||
},
|
||||
},
|
||||
format: 'png',
|
||||
|
|
|
@ -9,6 +9,6 @@ node(:author_url) { |entry| account_url(entry.account) }
|
|||
node(:provider_name) { Rails.configuration.x.local_domain }
|
||||
node(:provider_url) { root_url }
|
||||
node(:cache_age) { 86_400 }
|
||||
node(:html, &:content)
|
||||
node(:html) { |entry| "<div style=\"position: relative; height: 0; overflow: hidden; padding-top: 30px; padding-bottom: 56.25%\"><iframe src=\"#{embed_account_stream_entry_url(entry.account, entry)}\" style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden\" frameborder=\"0\" width=\"#{@width}\" scrolling=\"no\"></iframe></div>" }
|
||||
node(:width) { @width }
|
||||
node(:height) { @height }
|
||||
node(:height) { nil }
|
||||
|
|
8
app/views/layouts/embedded.html.haml
Normal file
8
app/views/layouts/embedded.html.haml
Normal file
|
@ -0,0 +1,8 @@
|
|||
!!! 5
|
||||
%html{:lang => 'en'}
|
||||
%head
|
||||
%meta{:charset => 'utf-8'}/
|
||||
= stylesheet_link_tag 'application', media: 'all'
|
||||
= javascript_include_tag 'application_public'
|
||||
%body.embed
|
||||
= yield
|
2
app/views/stream_entries/embed.html.haml
Normal file
2
app/views/stream_entries/embed.html.haml
Normal file
|
@ -0,0 +1,2 @@
|
|||
.activity-stream.activity-stream-headless
|
||||
= render partial: @type, locals: { @type.to_sym => @stream_entry.activity }
|
|
@ -25,7 +25,11 @@ Rails.application.routes.draw do
|
|||
}
|
||||
|
||||
resources :accounts, path: 'users', only: [:show], param: :username do
|
||||
resources :stream_entries, path: 'updates', only: [:show]
|
||||
resources :stream_entries, path: 'updates', only: [:show] do
|
||||
member do
|
||||
get :embed
|
||||
end
|
||||
end
|
||||
|
||||
member do
|
||||
get :followers
|
||||
|
|
Loading…
Reference in a new issue