diff options
author | ThibG <thib@sitedethib.com> | 2018-10-11 21:28:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 21:28:03 +0200 |
commit | 00759642446c41c9e9c428010ed0d3d3b79703bb (patch) | |
tree | f8cc02c4034d2436ea849a4f313c42eabc51a808 | |
parent | bb1103d9742f088252f8156968a474ca8a58b087 (diff) | |
parent | 8f720be9f3ad314f0c0b0c7c0cc81616ba20e8fd (diff) |
Merge pull request #775 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
-rw-r--r-- | Gemfile | 8 | ||||
-rw-r--r-- | Gemfile.lock | 30 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 16 | ||||
-rw-r--r-- | app/javascript/core/settings.js | 2 | ||||
-rw-r--r-- | app/views/accounts/_og.html.haml | 6 | ||||
-rwxr-xr-x | app/views/layouts/application.html.haml | 7 | ||||
-rw-r--r-- | app/views/shared/_og.html.haml | 6 | ||||
-rw-r--r-- | app/views/stream_entries/_og_description.html.haml | 5 | ||||
-rw-r--r-- | app/workers/scheduler/pghero_scheduler.rb | 11 | ||||
-rw-r--r-- | config/sidekiq.yml | 3 | ||||
-rw-r--r-- | db/migrate/20181007025445_create_pghero_space_stats.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 11 |
12 files changed, 94 insertions, 24 deletions
diff --git a/Gemfile b/Gemfile index d77a29b79..b417a8d2e 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'hamlit-rails', '~> 0.2' gem 'pg', '~> 1.1' gem 'makara', '~> 0.4' 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 'fog-core', '~> 2.1' @@ -109,7 +109,7 @@ end group :test do gem 'capybara', '~> 3.9' gem 'climate_control', '~> 0.2' - gem 'faker', '~> 1.8' + gem 'faker', '~> 1.9' gem 'microformats', '~> 4.0' gem 'rails-controller-testing', '~> 1.0' gem 'rspec-sidekiq', '~> 3.0' @@ -121,7 +121,7 @@ end group :development do gem 'active_record_query_trace', '~> 1.5' gem 'annotate', '~> 2.7' - gem 'better_errors', '~> 2.4' + gem 'better_errors', '~> 2.5' gem 'binding_of_caller', '~> 0.7' gem 'bullet', '~> 5.7' gem 'letter_opener', '~> 1.4' @@ -133,7 +133,7 @@ group :development do gem 'scss_lint', '~> 0.57', require: false gem 'capistrano', '~> 3.11' - gem 'capistrano-rails', '~> 1.3' + gem 'capistrano-rails', '~> 1.4' gem 'capistrano-rbenv', '~> 2.1' gem 'capistrano-yarn', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 3583bc396..13c1127b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -92,7 +92,7 @@ GEM aws-sigv4 (1.0.3) bcrypt (3.1.12) benchmark-ips (2.7.2) - better_errors (2.4.0) + better_errors (2.5.0) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) @@ -103,7 +103,7 @@ GEM brakeman (4.3.1) browser (2.5.3) builder (3.2.3) - bullet (5.7.5) + bullet (5.7.6) activesupport (>= 3.0.0) uniform_notifier (~> 1.11.0) bundler-audit (0.6.0) @@ -118,7 +118,7 @@ GEM capistrano-bundler (1.3.0) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.3.1) + capistrano-rails (1.4.0) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rbenv (2.1.4) @@ -184,9 +184,9 @@ GEM unf (>= 0.0.5, < 1.0.0) doorkeeper (5.0.0) railties (>= 4.2) - dotenv (2.2.2) - dotenv-rails (2.2.2) - dotenv (= 2.2.2) + dotenv (2.5.0) + dotenv-rails (2.5.0) + dotenv (= 2.5.0) railties (>= 3.2, < 6.0) elasticsearch (6.0.2) elasticsearch-api (= 6.0.2) @@ -204,7 +204,7 @@ GEM tzinfo excon (0.62.0) fabrication (2.20.1) - faker (1.8.7) + faker (1.9.1) i18n (>= 0.7) faraday (0.15.0) multipart-post (>= 1.2, < 3) @@ -330,7 +330,7 @@ GEM mimemagic (~> 0.3.2) mario-redis-lock (1.2.1) redis (>= 3.0.5) - memory_profiler (0.9.11) + memory_profiler (0.9.12) method_source (0.9.0) microformats (4.0.7) json @@ -539,14 +539,14 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.4.4) nokogumbo (~> 1.4) - sass (3.5.6) + sass (3.6.0) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - scss_lint (0.57.0) + scss_lint (0.57.1) rake (>= 0.9, < 13) - sass (~> 3.5.5) + sass (~> 3.5, >= 3.5.5) sidekiq (5.2.2) connection_pool (~> 2.2, >= 2.2.2) rack-protection (>= 1.5.0) @@ -654,7 +654,7 @@ DEPENDENCIES addressable (~> 2.5) annotate (~> 2.7) aws-sdk-s3 (~> 1.21) - better_errors (~> 2.4) + better_errors (~> 2.5) binding_of_caller (~> 0.7) bootsnap (~> 1.3) brakeman (~> 4.3) @@ -662,7 +662,7 @@ DEPENDENCIES bullet (~> 5.7) bundler-audit (~> 0.6) capistrano (~> 3.11) - capistrano-rails (~> 1.3) + capistrano-rails (~> 1.4) capistrano-rbenv (~> 2.1) capistrano-yarn (~> 2.0) capybara (~> 3.9) @@ -675,9 +675,9 @@ DEPENDENCIES devise-two-factor (~> 3.0) devise_pam_authenticatable2 (~> 9.2) doorkeeper (~> 5.0) - dotenv-rails (~> 2.2, < 2.3) + dotenv-rails (~> 2.5) fabrication (~> 2.20) - faker (~> 1.8) + faker (~> 1.9) fast_blank (~> 1.0) fastimage fog-core (~> 2.1) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c002017ef..e9b48fa98 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -82,4 +82,20 @@ module ApplicationHelper output << 'rtl' if locale_direction == 'rtl' output.reject(&:blank?).join(' ') 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 diff --git a/app/javascript/core/settings.js b/app/javascript/core/settings.js index 377c899dc..af97c84f9 100644 --- a/app/javascript/core/settings.js +++ b/app/javascript/core/settings.js @@ -56,7 +56,7 @@ delegate(document, '.input-copy input', '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.select(); diff --git a/app/views/accounts/_og.html.haml b/app/views/accounts/_og.html.haml index a583b39c2..de948ec6a 100644 --- a/app/views/accounts/_og.html.haml +++ b/app/views/accounts/_og.html.haml @@ -1,7 +1,11 @@ +- description = account_description(account) + +%meta{ name: 'description', content: description }/ + = opengraph 'og:url', url = opengraph 'og:site_name', site_title = 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:width', '120' = opengraph 'og:image:height', '120' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 36b4e9cae..7d3daf6c9 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,6 +3,13 @@ %head %meta{ charset: 'utf-8' }/ %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: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }/ %link{ rel: 'mask-icon', href: '/mask-icon.svg', color: '#2B90D9' }/ diff --git a/app/views/shared/_og.html.haml b/app/views/shared/_og.html.haml index 76db511cd..802d8c41d 100644 --- a/app/views/shared/_og.html.haml +++ b/app/views/shared/_og.html.haml @@ -1,9 +1,13 @@ - 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:url', url_for(only_path: false) = opengraph 'og:type', 'website' = 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:width', thumbnail ? thumbnail.meta['width'] : '1200' = opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630' diff --git a/app/views/stream_entries/_og_description.html.haml b/app/views/stream_entries/_og_description.html.haml index 3d122b94e..a7b18424d 100644 --- a/app/views/stream_entries/_og_description.html.haml +++ b/app/views/stream_entries/_og_description.html.haml @@ -1 +1,4 @@ -= opengraph 'og:description', status_description(activity) +- description = status_description(activity) + +%meta{ name: 'description', content: description }/ += opengraph 'og:description', description diff --git a/app/workers/scheduler/pghero_scheduler.rb b/app/workers/scheduler/pghero_scheduler.rb new file mode 100644 index 000000000..4453bf2cd --- /dev/null +++ b/app/workers/scheduler/pghero_scheduler.rb @@ -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 diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 6a09bb6e9..c44af5b6c 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -33,3 +33,6 @@ backup_cleanup_scheduler: cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *' class: Scheduler::BackupCleanupScheduler + pghero_scheduler: + cron: '0 0 * * *' + class: Scheduler::PgheroScheduler diff --git a/db/migrate/20181007025445_create_pghero_space_stats.rb b/db/migrate/20181007025445_create_pghero_space_stats.rb new file mode 100644 index 000000000..6198a6f84 --- /dev/null +++ b/db/migrate/20181007025445_create_pghero_space_stats.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 8ab3ea3c0..f9019e8cf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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 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 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| t.string "url", default: "", null: false t.string "title", default: "", null: false |