Merge branch 'kb_development' into kb_migration

This commit is contained in:
KMY 2023-03-27 14:06:48 +09:00
commit 21330f8c60
4 changed files with 45 additions and 8 deletions

View file

@ -56,7 +56,7 @@ class CustomEmoji < ApplicationRecord
after_commit :remove_entity_cache
after_post_process :set_size
after_post_process :set_post_size
def local?
domain.nil?
@ -76,6 +76,10 @@ class CustomEmoji < ApplicationRecord
shortcode
end
def update_size
set_size(Rails.configuration.x.use_s3 ? image.url : image.path)
end
class << self
def from_text(text, domain = nil)
return [] if text.blank?
@ -102,14 +106,17 @@ class CustomEmoji < ApplicationRecord
self.domain = domain.downcase unless domain.nil?
end
def set_size
def set_post_size
image.queued_for_write.each do |style, file|
if style == :original
image_size = FastImage.size(file.path)
self.image_width = image_size[0]
self.image_height = image_size[1]
return
set_size(file.path)
end
end
end
def set_size(path)
image_size = FastImage.size(path)
self.image_width = image_size[0]
self.image_height = image_size[1]
end
end

View file

@ -9,6 +9,15 @@
= render_initial_state
= javascript_pack_tag 'application', crossorigin: 'anonymous'
%script(src="https://www.googletagmanager.com/gtag/js?id=AW-11130587137" async)
:javascript
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-11130587137');
.notranslate.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
%noscript
= image_pack_tag 'logo.svg', alt: 'Mastodon'

View file

@ -16,6 +16,11 @@ media_host ||= host_to_url(ENV['S3_CLOUDFRONT_HOST'])
media_host ||= host_to_url(ENV['S3_HOSTNAME']) if ENV['S3_ENABLED'] == 'true'
media_host ||= assets_host
google_host = 'https://www.googletagmanager.com'
google_host2 = 'https://googleads.g.doubleclick.net'
google_host3 = 'https://www.googleadservices.com'
google_tag_script_hash = "'sha256-CS1WvLDd3zJOdxpEk+N+VigcWMa6V345p2HS0WYiFWE='"
Rails.application.config.content_security_policy do |p|
p.base_uri :none
p.default_src :none
@ -32,12 +37,12 @@ Rails.application.config.content_security_policy do |p|
webpacker_urls = %w(ws http).map { |protocol| "#{protocol}#{Webpacker.dev_server.https? ? 's' : ''}://#{Webpacker.dev_server.host_with_port}" }
p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url, *webpacker_urls
p.script_src :self, :unsafe_inline, :unsafe_eval, assets_host
p.script_src :self, :unsafe_inline, :unsafe_eval, assets_host, google_host, google_host2, google_host3
p.child_src :self, :blob, assets_host
p.worker_src :self, :blob, assets_host
else
p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url
p.script_src :self, assets_host, "'wasm-unsafe-eval'"
p.script_src :self, assets_host, "'wasm-unsafe-eval'", google_host, google_host2, google_host3, google_tag_script_hash
p.child_src :self, :blob, assets_host
p.worker_src :self, :blob, assets_host
end

View file

@ -132,6 +132,22 @@ module Mastodon
say('OK', :green)
end
desc 'size', 'Set custom emojis width/height'
long_desc <<-LONG_DESC
Set custom emojis width/height if width/height is nil or zero.
LONG_DESC
def size
scope = CustomEmoji.where(image_width: nil).or(CustomEmoji.where(image_height: [0, nil]))
size = scope.size
count = 0
scope.find_each do |emoji|
emoji.update_size
emoji.save!
count += 1
say("(#{count}/#{size}) proceed #{emoji.shortcode}@#{emoji.domain}")
end
end
private
def color(green, _yellow, red)