diff --git a/app/assets/javascripts/application_public.js b/app/assets/javascripts/application_public.js index 31a96fd2dc5682d60e9348b66c849463fde56f81..f131a267ab71ef3c5dd5494fa18d6b30c38a296b 100644 --- a/app/assets/javascripts/application_public.js +++ b/app/assets/javascripts/application_public.js @@ -1,2 +1,3 @@ //= require jquery //= require jquery_ujs +//= require extras diff --git a/app/assets/javascripts/extras.jsx b/app/assets/javascripts/extras.jsx new file mode 100644 index 0000000000000000000000000000000000000000..93f827044b94426d473c0b14762cbe711ee76529 --- /dev/null +++ b/app/assets/javascripts/extras.jsx @@ -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())); + }); +}); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 609b3072649243e7dbc8bbf947b0e73fd56361ae..6dd89c0ea70aaca6168a6520d615e3f68b9e4c01 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -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; } diff --git a/app/assets/stylesheets/stream_entries.scss b/app/assets/stylesheets/stream_entries.scss index 1e29ee7185c0df7a1306a5a0c7331eb9c85c8460..4df03b794be81f22e8118904a95484224c5a7c72 100644 --- a/app/assets/stylesheets/stream_entries.scss +++ b/app/assets/stylesheets/stream_entries.scss @@ -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; + } + } + } + } +} diff --git a/app/controllers/api/oembed_controller.rb b/app/controllers/api/oembed_controller.rb index 4a591dc2222c7045f6c846298748894ecc98a5e4..d30ae815219ee144e15b837682f3d122e0b59f66 100644 --- a/app/controllers/api/oembed_controller.rb +++ b/app/controllers/api/oembed_controller.rb @@ -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 diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb index 98d029030521787efd7680ee34d1842cfad772d9..933bdf737b4561a8b8fb335cbbeaeb41594f1874 100644 --- a/app/controllers/stream_entries_controller.rb +++ b/app/controllers/stream_entries_controller.rb @@ -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 diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index a97fe89a596b72f8fdd6e5e98cb5ff85a1f05557..2a5d23739ae9dd707d57ed357fd63b47ee36c00a 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -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', diff --git a/app/views/api/oembed/show.json.rabl b/app/views/api/oembed/show.json.rabl index e035bc13c5d329cc4d9282ccba945efff4176bdf..2bec9165e5e5c058ab8bfa277459116515f74e74 100644 --- a/app/views/api/oembed/show.json.rabl +++ b/app/views/api/oembed/show.json.rabl @@ -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 } diff --git a/app/views/layouts/embedded.html.haml b/app/views/layouts/embedded.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..adbf0a28707e7019f839f8be48ec691698ee538a --- /dev/null +++ b/app/views/layouts/embedded.html.haml @@ -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 diff --git a/app/views/stream_entries/embed.html.haml b/app/views/stream_entries/embed.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..4a733d42847d5c69b1b8bdb607655323725cc450 --- /dev/null +++ b/app/views/stream_entries/embed.html.haml @@ -0,0 +1,2 @@ +.activity-stream.activity-stream-headless + = render partial: @type, locals: { @type.to_sym => @stream_entry.activity } diff --git a/config/routes.rb b/config/routes.rb index 2d70bdcea6ed15526e9b444e6e0c244996df106b..fd187dc42275036393095bd5b8ce0e39d88362a3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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