Merge pull request #775 from ThibG/glitch-soc/merge-upstream

Merge upstream changes
This commit is contained in:
ThibG 2018-10-11 21:28:03 +02:00 committed by GitHub
commit 0075964244
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 94 additions and 24 deletions

View file

@ -13,7 +13,7 @@ gem 'hamlit-rails', '~> 0.2'
gem 'pg', '~> 1.1' gem 'pg', '~> 1.1'
gem 'makara', '~> 0.4' gem 'makara', '~> 0.4'
gem 'pghero', '~> 2.2' gem 'pghero', '~> 2.2'
gem 'dotenv-rails', '~> 2.2', '< 2.3' gem 'dotenv-rails', '~> 2.5'
gem 'aws-sdk-s3', '~> 1.21', require: false gem 'aws-sdk-s3', '~> 1.21', require: false
gem 'fog-core', '~> 2.1' gem 'fog-core', '~> 2.1'
@ -109,7 +109,7 @@ end
group :test do group :test do
gem 'capybara', '~> 3.9' gem 'capybara', '~> 3.9'
gem 'climate_control', '~> 0.2' gem 'climate_control', '~> 0.2'
gem 'faker', '~> 1.8' gem 'faker', '~> 1.9'
gem 'microformats', '~> 4.0' gem 'microformats', '~> 4.0'
gem 'rails-controller-testing', '~> 1.0' gem 'rails-controller-testing', '~> 1.0'
gem 'rspec-sidekiq', '~> 3.0' gem 'rspec-sidekiq', '~> 3.0'
@ -121,7 +121,7 @@ end
group :development do group :development do
gem 'active_record_query_trace', '~> 1.5' gem 'active_record_query_trace', '~> 1.5'
gem 'annotate', '~> 2.7' gem 'annotate', '~> 2.7'
gem 'better_errors', '~> 2.4' gem 'better_errors', '~> 2.5'
gem 'binding_of_caller', '~> 0.7' gem 'binding_of_caller', '~> 0.7'
gem 'bullet', '~> 5.7' gem 'bullet', '~> 5.7'
gem 'letter_opener', '~> 1.4' gem 'letter_opener', '~> 1.4'
@ -133,7 +133,7 @@ group :development do
gem 'scss_lint', '~> 0.57', require: false gem 'scss_lint', '~> 0.57', require: false
gem 'capistrano', '~> 3.11' gem 'capistrano', '~> 3.11'
gem 'capistrano-rails', '~> 1.3' gem 'capistrano-rails', '~> 1.4'
gem 'capistrano-rbenv', '~> 2.1' gem 'capistrano-rbenv', '~> 2.1'
gem 'capistrano-yarn', '~> 2.0' gem 'capistrano-yarn', '~> 2.0'

View file

@ -92,7 +92,7 @@ GEM
aws-sigv4 (1.0.3) aws-sigv4 (1.0.3)
bcrypt (3.1.12) bcrypt (3.1.12)
benchmark-ips (2.7.2) benchmark-ips (2.7.2)
better_errors (2.4.0) better_errors (2.5.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubi (>= 1.0.0) erubi (>= 1.0.0)
rack (>= 0.9.0) rack (>= 0.9.0)
@ -103,7 +103,7 @@ GEM
brakeman (4.3.1) brakeman (4.3.1)
browser (2.5.3) browser (2.5.3)
builder (3.2.3) builder (3.2.3)
bullet (5.7.5) bullet (5.7.6)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
uniform_notifier (~> 1.11.0) uniform_notifier (~> 1.11.0)
bundler-audit (0.6.0) bundler-audit (0.6.0)
@ -118,7 +118,7 @@ GEM
capistrano-bundler (1.3.0) capistrano-bundler (1.3.0)
capistrano (~> 3.1) capistrano (~> 3.1)
sshkit (~> 1.2) sshkit (~> 1.2)
capistrano-rails (1.3.1) capistrano-rails (1.4.0)
capistrano (~> 3.1) capistrano (~> 3.1)
capistrano-bundler (~> 1.1) capistrano-bundler (~> 1.1)
capistrano-rbenv (2.1.4) capistrano-rbenv (2.1.4)
@ -184,9 +184,9 @@ GEM
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
doorkeeper (5.0.0) doorkeeper (5.0.0)
railties (>= 4.2) railties (>= 4.2)
dotenv (2.2.2) dotenv (2.5.0)
dotenv-rails (2.2.2) dotenv-rails (2.5.0)
dotenv (= 2.2.2) dotenv (= 2.5.0)
railties (>= 3.2, < 6.0) railties (>= 3.2, < 6.0)
elasticsearch (6.0.2) elasticsearch (6.0.2)
elasticsearch-api (= 6.0.2) elasticsearch-api (= 6.0.2)
@ -204,7 +204,7 @@ GEM
tzinfo tzinfo
excon (0.62.0) excon (0.62.0)
fabrication (2.20.1) fabrication (2.20.1)
faker (1.8.7) faker (1.9.1)
i18n (>= 0.7) i18n (>= 0.7)
faraday (0.15.0) faraday (0.15.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
@ -330,7 +330,7 @@ GEM
mimemagic (~> 0.3.2) mimemagic (~> 0.3.2)
mario-redis-lock (1.2.1) mario-redis-lock (1.2.1)
redis (>= 3.0.5) redis (>= 3.0.5)
memory_profiler (0.9.11) memory_profiler (0.9.12)
method_source (0.9.0) method_source (0.9.0)
microformats (4.0.7) microformats (4.0.7)
json json
@ -539,14 +539,14 @@ GEM
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
nokogumbo (~> 1.4) nokogumbo (~> 1.4)
sass (3.5.6) sass (3.6.0)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
scss_lint (0.57.0) scss_lint (0.57.1)
rake (>= 0.9, < 13) rake (>= 0.9, < 13)
sass (~> 3.5.5) sass (~> 3.5, >= 3.5.5)
sidekiq (5.2.2) sidekiq (5.2.2)
connection_pool (~> 2.2, >= 2.2.2) connection_pool (~> 2.2, >= 2.2.2)
rack-protection (>= 1.5.0) rack-protection (>= 1.5.0)
@ -654,7 +654,7 @@ DEPENDENCIES
addressable (~> 2.5) addressable (~> 2.5)
annotate (~> 2.7) annotate (~> 2.7)
aws-sdk-s3 (~> 1.21) aws-sdk-s3 (~> 1.21)
better_errors (~> 2.4) better_errors (~> 2.5)
binding_of_caller (~> 0.7) binding_of_caller (~> 0.7)
bootsnap (~> 1.3) bootsnap (~> 1.3)
brakeman (~> 4.3) brakeman (~> 4.3)
@ -662,7 +662,7 @@ DEPENDENCIES
bullet (~> 5.7) bullet (~> 5.7)
bundler-audit (~> 0.6) bundler-audit (~> 0.6)
capistrano (~> 3.11) capistrano (~> 3.11)
capistrano-rails (~> 1.3) capistrano-rails (~> 1.4)
capistrano-rbenv (~> 2.1) capistrano-rbenv (~> 2.1)
capistrano-yarn (~> 2.0) capistrano-yarn (~> 2.0)
capybara (~> 3.9) capybara (~> 3.9)
@ -675,9 +675,9 @@ DEPENDENCIES
devise-two-factor (~> 3.0) devise-two-factor (~> 3.0)
devise_pam_authenticatable2 (~> 9.2) devise_pam_authenticatable2 (~> 9.2)
doorkeeper (~> 5.0) doorkeeper (~> 5.0)
dotenv-rails (~> 2.2, < 2.3) dotenv-rails (~> 2.5)
fabrication (~> 2.20) fabrication (~> 2.20)
faker (~> 1.8) faker (~> 1.9)
fast_blank (~> 1.0) fast_blank (~> 1.0)
fastimage fastimage
fog-core (~> 2.1) fog-core (~> 2.1)

View file

@ -82,4 +82,20 @@ module ApplicationHelper
output << 'rtl' if locale_direction == 'rtl' output << 'rtl' if locale_direction == 'rtl'
output.reject(&:blank?).join(' ') output.reject(&:blank?).join(' ')
end end
def cdn_host
ENV['CDN_HOST'].presence
end
def cdn_host?
cdn_host.present?
end
def storage_host
ENV['S3_ALIAS_HOST'].presence || ENV['S3_CLOUDFRONT_HOST'].presence
end
def storage_host?
storage_host.present?
end
end end

View file

@ -56,7 +56,7 @@ delegate(document, '.input-copy input', 'click', ({ target }) => {
}); });
delegate(document, '.input-copy button', 'click', ({ target }) => { delegate(document, '.input-copy button', 'click', ({ target }) => {
const input = target.parentNode.querySelector('input'); const input = target.parentNode.querySelector('.input-copy__wrapper input');
input.focus(); input.focus();
input.select(); input.select();

View file

@ -1,7 +1,11 @@
- description = account_description(account)
%meta{ name: 'description', content: description }/
= opengraph 'og:url', url = opengraph 'og:url', url
= opengraph 'og:site_name', site_title = opengraph 'og:site_name', site_title
= opengraph 'og:title', yield(:page_title).strip = opengraph 'og:title', yield(:page_title).strip
= opengraph 'og:description', account_description(account) = opengraph 'og:description', description
= opengraph 'og:image', full_asset_url(account.avatar.url(:original)) = opengraph 'og:image', full_asset_url(account.avatar.url(:original))
= opengraph 'og:image:width', '120' = opengraph 'og:image:width', '120'
= opengraph 'og:image:height', '120' = opengraph 'og:image:height', '120'

View file

@ -3,6 +3,13 @@
%head %head
%meta{ charset: 'utf-8' }/ %meta{ charset: 'utf-8' }/
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/ %meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/
- if cdn_host?
%link{ rel: 'dns-prefetch', href: cdn_host }/
- if storage_host?
%link{ rel: 'dns-prefetch', href: storage_host }/
%link{ rel: 'icon', href: favicon_path, type: 'image/x-icon' }/ %link{ rel: 'icon', href: favicon_path, type: 'image/x-icon' }/
%link{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }/ %link{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }/
%link{ rel: 'mask-icon', href: '/mask-icon.svg', color: '#2B90D9' }/ %link{ rel: 'mask-icon', href: '/mask-icon.svg', color: '#2B90D9' }/

View file

@ -1,9 +1,13 @@
- thumbnail = @instance_presenter.thumbnail - thumbnail = @instance_presenter.thumbnail
- description = strip_tags(@instance_presenter.site_short_description.presence || @instance_presenter.site_description.presence || t('about.about_mastodon_html'))
%meta{ name: 'description', content: description }/
= opengraph 'og:site_name', t('about.hosted_on', domain: site_hostname) = opengraph 'og:site_name', t('about.hosted_on', domain: site_hostname)
= opengraph 'og:url', url_for(only_path: false) = opengraph 'og:url', url_for(only_path: false)
= opengraph 'og:type', 'website' = opengraph 'og:type', 'website'
= opengraph 'og:title', @instance_presenter.site_title = opengraph 'og:title', @instance_presenter.site_title
= opengraph 'og:description', strip_tags(@instance_presenter.site_short_description.presence || @instance_presenter.site_description.presence || t('about.about_mastodon_html')) = opengraph 'og:description', description
= opengraph 'og:image', full_asset_url(thumbnail&.file&.url || asset_pack_path('preview.jpg', protocol: :request)) = 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:width', thumbnail ? thumbnail.meta['width'] : '1200'
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630' = opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630'

View file

@ -1 +1,4 @@
= opengraph 'og:description', status_description(activity) - description = status_description(activity)
%meta{ name: 'description', content: description }/
= opengraph 'og:description', description

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class Scheduler::PgheroScheduler
include Sidekiq::Worker
sidekiq_options unique: :until_executed, retry: 0
def perform
PgHero.capture_space_stats
end
end

View file

@ -33,3 +33,6 @@
backup_cleanup_scheduler: backup_cleanup_scheduler:
cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *' cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *'
class: Scheduler::BackupCleanupScheduler class: Scheduler::BackupCleanupScheduler
pghero_scheduler:
cron: '0 0 * * *'
class: Scheduler::PgheroScheduler

View file

@ -0,0 +1,13 @@
class CreatePgheroSpaceStats < ActiveRecord::Migration[5.2]
def change
create_table :pghero_space_stats do |t|
t.text :database
t.text :schema
t.text :relation
t.integer :size, limit: 8
t.timestamp :captured_at
end
add_index :pghero_space_stats, [:database, :captured_at]
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_09_29_222014) do ActiveRecord::Schema.define(version: 2018_10_07_025445) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -382,6 +382,15 @@ ActiveRecord::Schema.define(version: 2018_09_29_222014) do
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
end end
create_table "pghero_space_stats", force: :cascade do |t|
t.text "database"
t.text "schema"
t.text "relation"
t.bigint "size"
t.datetime "captured_at"
t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
end
create_table "preview_cards", force: :cascade do |t| create_table "preview_cards", force: :cascade do |t|
t.string "url", default: "", null: false t.string "url", default: "", null: false
t.string "title", default: "", null: false t.string "title", default: "", null: false