diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9a81171e5b9f3674e0d413d62d52893cb5cd4304..23d8b4bec9ac7c1e78b14394bf7747d11b99db30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base include WithErrors include WithFeatures include WithLocale + include WithMaintenance before_action :ensure_university, :authenticate_user! diff --git a/app/controllers/application_controller/with_maintenance.rb b/app/controllers/application_controller/with_maintenance.rb new file mode 100644 index 0000000000000000000000000000000000000000..0f28e2325fa2117707a29a36435d63c900a216dd --- /dev/null +++ b/app/controllers/application_controller/with_maintenance.rb @@ -0,0 +1,16 @@ +module ApplicationController::WithMaintenance + extend ActiveSupport::Concern + + included do + before_action :check_maintenance + end + + protected + + def check_maintenance + if ENV['MAINTENANCE'] && + current_user&.role != 'server_admin' + redirect_to '/maintenance' + end + end +end diff --git a/public/maintenance.html b/public/maintenance.html new file mode 100644 index 0000000000000000000000000000000000000000..47c8b4c50039385e9508a0381ddd630dfba6c33b --- /dev/null +++ b/public/maintenance.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html> + +<head> + <title>Maintenance in progress</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width,initial-scale=1"> + <meta http-equiv="refresh" content="30;URL=/"> + <style> + body { + padding: 15px; + } + + * { + font-family: sans-serif; + font-size: 14px; + margin: 0; + text-align: center; + } + + .dialog { + width: 95%; + max-width: 22em; + margin: calc(50vh - 140px) auto 0; + } + + .dialog span { + font-size: 150px; + font-weight: 900; + letter-spacing: -0.04em; + display: block; + width: 100%; + line-height: 0.9; + margin-bottom: 50px + } + + img { + margin-bottom: 30px; + } + + h1 { + font-size: 14px; + line-height: 1.5em; + margin-bottom: 30px; + } + + h1 em { + font-weight: 400; + } + </style> +</head> + +<body> + <div class="dialog"> + <span> + ⌛ + </span> + <div> + <h1>Maintenance in progress</h1> + <a href="/"><img src="/logo.svg" alt="Osuny" width="100"></a> + </div> + </div> +</body> + +</html>