diff --git a/.babelrc b/.babelrc deleted file mode 100644 index ded31c0..0000000 --- a/.babelrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "presets": [ - ["env", { - "modules": false, - "targets": { - "browsers": "> 1%", - "uglify": true - }, - "useBuiltIns": true - }] - ], - - "plugins": [ - "syntax-dynamic-import", - "transform-object-rest-spread", - ["transform-class-properties", { "spec": true }] - ] -} diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..e94f814 --- /dev/null +++ b/.browserslistrc @@ -0,0 +1 @@ +defaults diff --git a/.gitignore b/.gitignore index 0bfdc6a..cf90d16 100644 --- a/.gitignore +++ b/.gitignore @@ -19,9 +19,6 @@ # Ignore uploaded files in development /storage/* -/node_modules -/yarn-error.log - /public/assets .byebug_history @@ -44,3 +41,10 @@ yarn-debug.log* # OS file .DS_Store + +/public/packs +/public/packs-test +/node_modules +/yarn-error.log +yarn-debug.log* +.yarn-integrity diff --git a/.postcssrc.yml b/.postcssrc.yml deleted file mode 100644 index 150dac3..0000000 --- a/.postcssrc.yml +++ /dev/null @@ -1,3 +0,0 @@ -plugins: - postcss-import: {} - postcss-cssnext: {} diff --git a/.travis.yml b/.travis.yml index f35806b..2ffb940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ language: - ruby rvm: - - 2.3 - - 2.4 + ### Zeitwerk is not fully compatible with < 2.5.4 + ### cf. https://github.com/Evolix/chexpire/pull/104 - 2.5 - 2.6 @@ -23,8 +23,6 @@ services: - mysql before_install: - - gem update --system - - gem install bundler - mysql -e 'CREATE DATABASE chexpire_test;' - cp config/database.travis.yml config/database.yml - cp config/secrets.example.yml config/secrets.yml @@ -37,6 +35,7 @@ install: - bundle install - yarn install - rails db:create db:migrate + - rails webpacker:compile script: - bundle exec rubocop diff --git a/Gemfile b/Gemfile index 53ec5bd..02ca23f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,45 +1,44 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '>= 2.3.3' +ruby '>= 2.5.4' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.2.0' -gem 'rails-i18n', '~> 5.1' +gem 'rails', '6.0.0' +gem 'rails-i18n', '~> 6.0.0' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4', '< 0.6.0' # Use Puma as the app server -gem 'puma', '~> 3.11' - -gem 'devise', '~> 4.4' -gem 'devise-i18n', '~> 1.6' - -# responders 3 depends on Ruy >= 2.4.0, let's keep a 2.x for now -gem 'responders', '~> 2.4.1' +gem 'puma', '~> 4.0' +gem 'devise', '~> 4.7' +gem 'devise-i18n', '~> 1.8' gem 'simple_form', '~> 4.0' gem 'pundit', '~> 1.1' # Use SCSS for stylesheets -# sass-rails 5.1 depends on Ruy >= 2.4.0, let's keep 5.0.7 for now -gem 'sass-rails', '5.0.7' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -gem 'webpacker', '~> 3.5' +gem 'sass-rails', '~> 5' +# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker +gem 'webpacker', '~> 4.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby -# Use CoffeeScript for .coffee assets and views -# gem 'coffee-rails', '~> 4.2' +gem 'bootstrap', '~> 4.3.1' + # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.5' -# Use ActiveModel has_secure_password +gem 'jbuilder', '~> 2.7' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use Active Model has_secure_password gem 'bcrypt', '~> 3.1.7' -# Use ActiveStorage variant -# gem 'mini_magick', '~> 4.8' +# Use Active Storage variant +# gem 'image_processing', '~> 1.2' + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.4.2', require: false gem 'rack-contrib' @@ -55,12 +54,10 @@ gem 'has_scope' gem 'logging' -# Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.1.0', require: false - group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'binding_of_caller' + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + # gem 'binding_of_caller' gem 'pry-byebug' gem 'pry-rails' @@ -69,7 +66,7 @@ end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem 'web-console', '>= 3.3.0' + gem 'web-console', '~> 4.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' @@ -95,7 +92,7 @@ end group :test do # Adds support for Capybara system testing and selenium driver - gem 'capybara', '>= 2.15', '< 4.0' + gem 'capybara', '>= 2.15' gem 'selenium-webdriver' gem 'webdrivers' gem 'launchy' diff --git a/Gemfile.lock b/Gemfile.lock index a754c6a..23ea50a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,47 +1,61 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (6.0.0) + actionpack (= 6.0.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) + actionmailbox (6.0.0) + actionpack (= 6.0.0) + activejob (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + mail (>= 2.7.1) + actionmailer (6.0.0) + actionpack (= 6.0.0) + actionview (= 6.0.0) + activejob (= 6.0.0) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) + actionpack (6.0.0) + actionview (= 6.0.0) + activesupport (= 6.0.0) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.3) - activesupport (= 5.2.3) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.0) + actionpack (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + nokogiri (>= 1.8.5) + actionview (6.0.0) + activesupport (= 6.0.0) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.3) - activesupport (= 5.2.3) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.0.0) + activesupport (= 6.0.0) globalid (>= 0.3.6) - activemodel (5.2.3) - activesupport (= 5.2.3) - activerecord (5.2.3) - activemodel (= 5.2.3) - activesupport (= 5.2.3) - arel (>= 9.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) + activemodel (6.0.0) + activesupport (= 6.0.0) + activerecord (6.0.0) + activemodel (= 6.0.0) + activesupport (= 6.0.0) + activestorage (6.0.0) + actionpack (= 6.0.0) + activejob (= 6.0.0) + activerecord (= 6.0.0) marcel (~> 0.3.1) - activesupport (5.2.3) + activesupport (6.0.0) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + zeitwerk (~> 2.1, >= 2.1.8) addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) airbrussh (1.3.3) @@ -49,15 +63,18 @@ GEM annotate (2.7.5) activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 13.0) - arel (9.0.0) ast (2.4.0) + autoprefixer-rails (9.6.1.1) + execjs bcrypt (3.1.13) bcrypt_pbkdf (1.0.1) bindex (0.8.1) - binding_of_caller (0.8.0) - debug_inspector (>= 0.0.1) bootsnap (1.4.4) msgpack (~> 1.0) + bootstrap (4.3.1) + autoprefixer-rails (>= 9.1.0) + popper_js (>= 1.14.3, < 2) + sassc-rails (>= 2.0.0) builder (3.2.3) byebug (11.0.1) capistrano (3.11.0) @@ -73,10 +90,10 @@ GEM capistrano-rbenv (2.1.4) capistrano (~> 3.1) sshkit (~> 1.3) - capistrano3-puma (3.1.1) + capistrano3-puma (4.0.0) capistrano (~> 3.7) capistrano-bundler - puma (~> 3.4) + puma (~> 4.0) capybara (3.28.0) addressable mini_mime (>= 0.1.3) @@ -92,11 +109,10 @@ GEM concurrent-ruby (1.1.5) crass (1.0.4) database_cleaner (1.7.0) - debug_inspector (0.0.3) - devise (4.6.2) + devise (4.7.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) devise-i18n (1.8.1) @@ -198,6 +214,7 @@ GEM parallel (1.17.0) parser (2.6.3.0) ast (~> 2.4.0) + popper_js (1.14.5) powerpack (0.1.2) pry (0.12.2) coderay (~> 1.1.0) @@ -208,7 +225,8 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (3.1.1) - puma (3.12.1) + puma (4.1.0) + nio4r (~> 2.0) pundit (1.1.0) activesupport (>= 3.0.0) rack (2.0.7) @@ -218,33 +236,35 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.3) - actioncable (= 5.2.3) - actionmailer (= 5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) - activemodel (= 5.2.3) - activerecord (= 5.2.3) - activestorage (= 5.2.3) - activesupport (= 5.2.3) + rails (6.0.0) + actioncable (= 6.0.0) + actionmailbox (= 6.0.0) + actionmailer (= 6.0.0) + actionpack (= 6.0.0) + actiontext (= 6.0.0) + actionview (= 6.0.0) + activejob (= 6.0.0) + activemodel (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) bundler (>= 1.3.0) - railties (= 5.2.3) + railties (= 6.0.0) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) - rails-i18n (5.1.3) + rails-i18n (6.0.0) i18n (>= 0.7, < 2) - railties (>= 5.0, < 6) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + railties (>= 6.0.0, < 7) + railties (6.0.0) + actionpack (= 6.0.0) + activesupport (= 6.0.0) method_source rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) + thor (>= 0.20.3, < 2.0) rainbow (3.0.0) rake (12.3.3) rb-fsevent (0.10.3) @@ -253,9 +273,9 @@ GEM rbnacl (4.0.2) ffi regexp_parser (1.6.0) - responders (2.4.1) - actionpack (>= 4.2.0, < 6.0) - railties (>= 4.2.0, < 6.0) + responders (3.0.0) + actionpack (>= 5.0) + railties (>= 5.0) rubocop (0.56.0) parallel (~> 1.10) parser (>= 2.5) @@ -271,12 +291,20 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) + sass-rails (5.1.0) + railties (>= 5.2.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + sassc (2.1.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt selenium-webdriver (3.142.3) childprocess (>= 0.5, < 2.0) rubyzip (~> 1.2, >= 1.2.2) @@ -311,21 +339,19 @@ GEM turbolinks-source (5.2.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.20) - execjs (>= 0.3.0, < 3) unicode-display_width (1.6.0) warden (1.2.8) rack (>= 2.0.6) - web-console (3.7.0) - actionview (>= 5.0) - activemodel (>= 5.0) + web-console (4.0.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) bindex (>= 0.4.0) - railties (>= 5.0) + railties (>= 6.0.0) webdrivers (4.1.2) nokogiri (~> 1.6) rubyzip (~> 1.0) selenium-webdriver (>= 3.0, < 4.0) - webpacker (3.6.0) + webpacker (4.0.7) activesupport (>= 4.2) rack-proxy (>= 0.6.1) railties (>= 4.2) @@ -336,6 +362,7 @@ GEM chronic (>= 0.6.3) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.1.9) PLATFORMS ruby @@ -344,23 +371,24 @@ DEPENDENCIES annotate bcrypt (~> 3.1.7) bcrypt_pbkdf (>= 1.0, < 2.0) - binding_of_caller - bootsnap (>= 1.1.0) + bootsnap (>= 1.4.2) + bootstrap (~> 4.3.1) + byebug capistrano (~> 3.10) capistrano-rails (~> 1.4) capistrano-rbenv capistrano3-puma - capybara (>= 2.15, < 4.0) + capybara (>= 2.15) database_cleaner - devise (~> 4.4) - devise-i18n (~> 1.6) + devise (~> 4.7) + devise-i18n (~> 1.8) ed25519 (>= 1.2, < 2.0) factory_bot_rails (~> 5.0) guard guard-minitest has_scope hashie - jbuilder (~> 2.5) + jbuilder (~> 2.7) kaminari launchy letter_opener_web @@ -372,15 +400,14 @@ DEPENDENCIES open4 pry-byebug pry-rails - puma (~> 3.11) + puma (~> 4.0) pundit (~> 1.1) rack-contrib - rails (~> 5.2.0) - rails-i18n (~> 5.1) + rails (= 6.0.0) + rails-i18n (~> 6.0.0) rbnacl (>= 3.2, < 5.0) - responders (~> 2.4.1) rubocop (~> 0.56.0) - sass-rails (= 5.0.7) + sass-rails (~> 5) selenium-webdriver simple_form (~> 4.0) simplecov @@ -388,14 +415,13 @@ DEPENDENCIES spring-watcher-listen (~> 2.0.0) turbolinks (~> 5) tzinfo-data - uglifier (>= 1.3.0) - web-console (>= 3.3.0) + web-console (~> 4.0) webdrivers - webpacker (~> 3.5) + webpacker (~> 4.0) whenever RUBY VERSION - ruby 2.3.3p222 + ruby 2.6.3p62 BUNDLED WITH 1.17.2 diff --git a/INSTALL.md b/INSTALL.md index cfb3fa7..37e5093 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -3,15 +3,15 @@ ## Requirements Chexpire requires : -* Ruby > 2.3.3 and Bundler +* Ruby > 2.5.4 and Bundler * NodeJS and Yarn * MySQL or MariaDB We are usually running Chexpire on typical POSIX servers like : -- Linux Debian 9, Ruby 2.5.1, NodeJS 8.11 and MariaDB 10.1 -- macOS High Sierra, Ruby 2.5.1, NodeJS 10.2.1 and MariaDB 10.2 +- Linux Debian 9, Ruby 2.5.4, NodeJS 8.11 and MariaDB 10.1 +- macOS High Sierra, Ruby 2.5.4, NodeJS 10.2.1 and MariaDB 10.2 -It probably works on any system that supports Ruby >2.3, NodeJS >6 and MySQL >5.5. Feel free to report any unexpected incompatibilities. +It probably works on any system that supports Ruby >= 2.5.4, NodeJS >= 6 and MySQL >= 5.5. Feel free to report any unexpected incompatibilities. If you use rbenv, chruby or RVM, you can set your prefered Ruby version in the `.ruby-version` file at the root of the project. @@ -21,7 +21,7 @@ If you are familiar with Ansible, you can use our [Ansible roles](http://forge.e […] roles: - mysql - - { role: rbenv, username: "{{ ansible_user }}", rbenv_ruby_version: "2.5.1" } + - { role: rbenv, username: "{{ ansible_user }}", rbenv_ruby_version: "2.5.4" } - { role: nodejs, nodejs_install_yarn: yes } […] ``` @@ -34,7 +34,7 @@ If you want to do manual installations, you can use our Wiki documentations for Execute `# bundle install` to install Ruby gems (including Rails itself). -Execute `# yarn install` to install Javascript/NodeJS packages. +Execute `# yarn install --check-files` to install Javascript/NodeJS packages. Depending on what is already installed on your OS or not, you might need to install a few system packages to be able to have everything working. @@ -45,15 +45,21 @@ To use elliptic curve SSH keys, we need to have `libsodium` and its headers. * on macOS with Homebrew : `# brew install libsodium`. -## Rails configuration +## Application configuration After cloning this repository, you have to create and edit a few files for your local development/test configuration. Theses files will be ignored by git. +### Environment variables + +A handful of settings can be set by environment variables. If you use Heroku-like platforms they offer a simple way to set them. + +If you use Rbenv, there is the `rbenv-vars` plugin. That is what we recommend on POSIX servers. You have to put an `.rbenv-vars` file at the root of the project. If you use Capistrano, put it in the shared directory and have it linked in the `current` directory at deploy time. + ### Database configuration Create the file if missing : `cp config/database.example.yml config/database.yml`. If you change the settings in the `defaults` section it applies to the `development` and `test` sections. More information is available at "guides.rubyonrails.org":https://guides.rubyonrails.org/configuring.html#configuring-a-database -Note that on Debian 9 with MariaDB, the database socket is at `/var/run/mysqld/mysqld.sock`, which is not the default in the configuration file. +Note that on Debian 9+ with MariaDB, the database socket is at `/var/run/mysqld/mysqld.sock`, which is not the default in the configuration file. ### Rails secrets @@ -63,7 +69,7 @@ Create the file if missing : `cp config/secrets.example.yml config/secrets.yml`. Create the file if missing : `cp config/chexpire.example.yml config/chexpire.yml`. Set at least the `mailer_default_from` and `host` variables. See other configuration overridable in `config/chexpire.defaults.yml`. -## Database +## Database You need databases for development and tests. You can create them like this (once connected to you MySQL server) : @@ -75,8 +81,8 @@ MariaDB [none]> CREATE DATABASE `chexpire_test`; If you don't want to use the default `root` MySQL user with no password, you can create users : ``` -MariaDB [none]> GRANT ALL PRIVILEGES ON `chexpire_development`.* TO `chexpire_development`@localhost IDENTIFIED BY 'MY_PASSWORD_FOR_DEV'; -MariaDB [none]> GRANT ALL PRIVILEGES ON `chexpire_test`.* TO `chexpire_test`@localhost IDENTIFIED BY 'MY_PASSWORD_FOR_TEST'; +MariaDB [none]> GRANT ALL PRIVILEGES ON `chexpire_development%`.* TO `chexpire_development`@localhost IDENTIFIED BY 'MY_PASSWORD_FOR_DEV'; +MariaDB [none]> GRANT ALL PRIVILEGES ON `chexpire_test%`.* TO `chexpire_test`@localhost IDENTIFIED BY 'MY_PASSWORD_FOR_TEST'; MariaDB [none]> FLUSH PRIVILEGES; ``` @@ -113,3 +119,17 @@ You can use the `script/to_staging` and/or `script/to_production` scripts. * with `to_production` you deploy the `master` branch to production. On the remote servers – where the application will be deployed – you have to copy the configuration files just as you've just did for your development setup. The files has to go in the `shared/config/` directory, relative to your `deploy_to` path. They will be symlinked to the proper destination by Capistrano. +If an `.rbenv-vars` file is found in the shared directory, it will be linked to help loading environment files (by Ruby via Rbenv, systemd…). + +### systemd + +If you want to use systemd to manage your Puma process, there are [a few different ways](https://github.com/puma/puma/blob/master/docs/systemd.md). We've prepared a systemd unit file (`config/deploy/puma-chexpire@.service`) but you can adjust to better suit your needs. + +If you deploy your application to `/home/chexpire_`, the systemd unit can be used as a template, for example : `puma-chexpire@production.service`. This template is compatible with systemd actions like `systemctl stop puma-chexpire@production.service` and also with Capistrano tasks like `cap production puma:stop`. + +To install the systemd unit : + +``` +$ cp config/deploy/puma-chexpire@.service /etc/systemd/system/puma-chexpire@.service +$ systemctl enable puma-chexpire@.service +``` diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index ac907b3..5918193 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1 +1,2 @@ //= link_tree ../images +//= link_directory ../stylesheets .css diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1d70ea6..a4d430f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,6 +45,6 @@ class ApplicationController < ActionController::Base end def render_404 - render file: "#{Rails.root}/public/404", status: :not_found + render file: "#{Rails.root}/public/404.html", status: :not_found end end diff --git a/app/frontend/scss/_variables.scss b/app/frontend/scss/_variables.scss deleted file mode 100644 index 954eccf..0000000 --- a/app/frontend/scss/_variables.scss +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018 Colin Darie , 2018 Evolix -// License: GNU AGPL-3+ (see full text in LICENSE file) - -$input-placeholder-color: #b9bbbb; -$enable-rounded: false; -$theme-colors: ( - "primary": #118b83, //light-green - "secondary": #013d3a, //dark-green - "tertiary": #be0c04, //red - "quaternary": #d6b20e, // yellow - "success": #118b83, //light-green - "warning": #F6AE2D, - "danger": #be0c04, //red - "info": #2E86AB, -); diff --git a/app/frontend/scss/index.js b/app/frontend/scss/index.js deleted file mode 100644 index 15c6e9b..0000000 --- a/app/frontend/scss/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2018 Colin Darie , 2018 Evolix -// License: GNU AGPL-3+ (see full text in LICENSE file) - -import './index.scss'; diff --git a/app/frontend/components/check_validation.js b/app/javascript/components/check_validation.js similarity index 100% rename from app/frontend/components/check_validation.js rename to app/javascript/components/check_validation.js diff --git a/app/frontend/packs/application.js b/app/javascript/packs/application.js similarity index 56% rename from app/frontend/packs/application.js rename to app/javascript/packs/application.js index f232272..2430c3f 100644 --- a/app/frontend/packs/application.js +++ b/app/javascript/packs/application.js @@ -6,27 +6,25 @@ // present in this directory. You're encouraged to place your actual application logic in // a relevant structure within app/javascript and only use these pack files to reference // that code so it'll be compiled. -// -// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate -// layout file, like app/views/layouts/application.html.erb -import Rails from 'rails-ujs'; -import Turbolinks from 'turbolinks'; +require("@rails/ujs").start() +require("turbolinks").start() +// require("@rails/activestorage").start() +// require("channels") -import 'bootstrap/js/dist/collapse'; -import 'bootstrap/js/dist/dropdown'; -import 'bootstrap/js/dist/button'; -import 'bootstrap/js/dist/tooltip'; - -import '../scss'; +import 'bootstrap' +import '../stylesheets/application' import checkValidationInitialize from '../components/check_validation'; -Rails.start() -Turbolinks.start() - document.addEventListener("turbolinks:load", () => { $('[data-toggle="tooltip"]').tooltip(); checkValidationInitialize(); }); +// Uncomment to copy all static images under ../images to the output folder and reference +// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) +// or the `imagePath` JavaScript helper below. +// +// const images = require.context('../images', true) +// const imagePath = (name) => images(name, true) diff --git a/app/javascript/stylesheets/_custom.scss b/app/javascript/stylesheets/_custom.scss new file mode 100644 index 0000000..bf60bbb --- /dev/null +++ b/app/javascript/stylesheets/_custom.scss @@ -0,0 +1,15 @@ +// Copyright (C) 2018 Colin Darie , 2018 Evolix +// License: GNU AGPL-3+ (see full text in LICENSE file) + +$input-placeholder-color: #b9bbbb; +$enable-rounded: false; +$theme-colors: ( + "primary": #118b83, //light-green + "secondary": #013d3a, //dark-green + "tertiary": #be0c04, //red + "quaternary": #d6b20e, //yellow + "success": #118b83, //light-green + "warning": #F6AE2D, //orange + "danger": #be0c04, //red + "info": #2E86AB, //light-blue +); diff --git a/app/frontend/scss/index.scss b/app/javascript/stylesheets/application.scss similarity index 55% rename from app/frontend/scss/index.scss rename to app/javascript/stylesheets/application.scss index 20ea0ae..9f5913a 100644 --- a/app/frontend/scss/index.scss +++ b/app/javascript/stylesheets/application.scss @@ -1,10 +1,9 @@ -// Copyright (C) 2018 Colin Darie , 2018 Evolix -// License: GNU AGPL-3+ (see full text in LICENSE file) - -@import '_variables'; +@import '_custom'; @import '~bootstrap/scss/bootstrap'; + @import 'layout'; @import 'icons'; + @import 'components/callouts'; @import 'components/users'; @import 'components/checks'; diff --git a/app/frontend/scss/components/callouts.scss b/app/javascript/stylesheets/components/callouts.scss similarity index 100% rename from app/frontend/scss/components/callouts.scss rename to app/javascript/stylesheets/components/callouts.scss diff --git a/app/frontend/scss/components/checks.scss b/app/javascript/stylesheets/components/checks.scss similarity index 100% rename from app/frontend/scss/components/checks.scss rename to app/javascript/stylesheets/components/checks.scss diff --git a/app/frontend/scss/components/notifications.scss b/app/javascript/stylesheets/components/notifications.scss similarity index 100% rename from app/frontend/scss/components/notifications.scss rename to app/javascript/stylesheets/components/notifications.scss diff --git a/app/frontend/scss/components/users.scss b/app/javascript/stylesheets/components/users.scss similarity index 100% rename from app/frontend/scss/components/users.scss rename to app/javascript/stylesheets/components/users.scss diff --git a/app/frontend/scss/icons.scss b/app/javascript/stylesheets/icons.scss similarity index 100% rename from app/frontend/scss/icons.scss rename to app/javascript/stylesheets/icons.scss diff --git a/app/frontend/scss/layout.scss b/app/javascript/stylesheets/layout.scss similarity index 99% rename from app/frontend/scss/layout.scss rename to app/javascript/stylesheets/layout.scss index e532b05..8c22423 100644 --- a/app/frontend/scss/layout.scss +++ b/app/javascript/stylesheets/layout.scss @@ -146,7 +146,7 @@ a.navbar-item.navbar-link { .row { height: 100%; } - + .homepage-img { border: 1px solid map-get($theme-colors, secondary); } diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index ce4acc2..5a34298 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,4 +1,10 @@ class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError + # from http://api.rubyonrails.org/classes/ActiveJob/Core.html attr_writer :attempt_number diff --git a/app/jobs/ssl_sync_job.rb b/app/jobs/ssl_sync_job.rb index 6c47679..47c3696 100644 --- a/app/jobs/ssl_sync_job.rb +++ b/app/jobs/ssl_sync_job.rb @@ -1,3 +1,6 @@ +# Copyright (C) 2018 Colin Darie , 2018 Evolix +# License: GNU AGPL-3+ (see full text in LICENSE file) + class SSLSyncJob < ApplicationJob queue_as :default diff --git a/app/jobs/whois_sync_job.rb b/app/jobs/whois_sync_job.rb index 1532245..9388e54 100644 --- a/app/jobs/whois_sync_job.rb +++ b/app/jobs/whois_sync_job.rb @@ -1,3 +1,6 @@ +# Copyright (C) 2018 Colin Darie , 2018 Evolix +# License: GNU AGPL-3+ (see full text in LICENSE file) + class WhoisSyncJob < ApplicationJob queue_as :default diff --git a/app/mailers/notifications_mailer.rb b/app/mailers/notifications_mailer.rb index b57de6c..b20e4a7 100644 --- a/app/mailers/notifications_mailer.rb +++ b/app/mailers/notifications_mailer.rb @@ -11,19 +11,15 @@ class NotificationsMailer < ApplicationMailer end def domain_expires_soon - @expire_in_days = Integer(@check.domain_expires_at.to_date - Date.today) - I18n.with_locale params&.fetch(:locale) { @check.user.locale } do - subject = t(".subject", domain: @check.domain, count: @expire_in_days) + subject = t(".subject", domain: @check.domain, count: @check.domain_expires_in_days) mail subject: subject, to: @notification.recipient end end def ssl_expires_soon - @expire_in_days = Integer(@check.domain_expires_at.to_date - Date.today) - I18n.with_locale params&.fetch(:locale) { @check.user.locale } do - subject = t(".subject", domain: @check.domain, count: @expire_in_days) + subject = t(".subject", domain: @check.domain, count: @check.domain_expires_in_days) mail subject: subject, to: @notification.recipient end end diff --git a/app/models/check.rb b/app/models/check.rb index 87fbe5c..492e754 100644 --- a/app/models/check.rb +++ b/app/models/check.rb @@ -44,6 +44,8 @@ class Check < ApplicationRecord enum kind: [:domain, :ssl] enum mode: [:auto, :manual] + # Those dates are written as UTC, + # but not converted back when read from the database self.skip_time_zone_conversion_for_attributes = [ :domain_created_at, :domain_updated_at, @@ -82,7 +84,8 @@ class Check < ApplicationRecord def days_from_last_success return unless last_success_at.present? - (Date.today - last_success_at.to_date).to_i + # return the number of whole days + ((Time.now - last_success_at) / (24 * 3600)).to_i end def increment_consecutive_failures! @@ -104,6 +107,10 @@ class Check < ApplicationRecord end end + def domain_expires_in_days + Integer(domain_expires_at.to_date - Time.now.utc.to_date) + end + private def domain_created_at_past diff --git a/app/services/notifier.rb b/app/services/notifier.rb index 4a59233..92f68f7 100644 --- a/app/services/notifier.rb +++ b/app/services/notifier.rb @@ -1,8 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "notifier/processor" - module Notifier class << self def process_all(configuration = nil) diff --git a/lib/null_logger.rb b/app/services/null_logger.rb similarity index 90% rename from lib/null_logger.rb rename to app/services/null_logger.rb index 03352cf..fc4b09b 100644 --- a/lib/null_logger.rb +++ b/app/services/null_logger.rb @@ -1,6 +1,4 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "naught" - NullLogger = Naught.build diff --git a/app/services/ssl.rb b/app/services/ssl.rb index e566352..75eb0e3 100644 --- a/app/services/ssl.rb +++ b/app/services/ssl.rb @@ -1,13 +1,17 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "null_logger" -require "system_command" -require_relative "ssl/parser" -require_relative "ssl/response" -require_relative "ssl/errors" - module SSL + class Error < StandardError; end + + class CommandError < Error; end + class ConfigurationError < Error; end + + class ParserError < Error; end + class DomainNotMatchError < ParserError; end + class InvalidResponseError < ParserError; end + class InvalidDateError < ParserError; end + class << self def ask(domain, system_klass: SystemCommand, logger: NullLogger.new) Service.new(domain, system_klass: system_klass, logger: logger).call @@ -41,7 +45,7 @@ module SSL result = command.execute unless result.exit_status.zero? - fail SSLCommandError, "SSL command failed with status #{result.exit_status}" + fail SSL::CommandError, "SSL command failed with status #{result.exit_status}" end result @@ -69,7 +73,7 @@ module SSL def custom_check_http_args return nil unless configuration.check_http_args.present? - fail SSLConfigurationError, "check_http_args option must be an array of argument." \ + fail SSL::ConfigurationError, "check_http_args option must be an array of argument." \ unless configuration.check_http_args.is_a?(Array) configuration.check_http_args diff --git a/app/services/ssl/errors.rb b/app/services/ssl/errors.rb deleted file mode 100644 index aa15760..0000000 --- a/app/services/ssl/errors.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (C) 2018 Colin Darie , 2018 Evolix -# License: GNU AGPL-3+ (see full text in LICENSE file) - -module SSL - class Error < StandardError; end - - class SSLCommandError < Error; end - class SSLConfigurationError < Error; end - - class ParserError < Error; end - class DomainNotMatchError < ParserError; end - class InvalidResponseError < ParserError; end - class InvalidDateError < ParserError; end -end diff --git a/app/services/ssl/parser.rb b/app/services/ssl/parser.rb index 81caf76..a224d43 100644 --- a/app/services/ssl/parser.rb +++ b/app/services/ssl/parser.rb @@ -1,9 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "null_logger" -require "ssl/errors" - module SSL class Parser DATE_REGEX = /will expire on (.+)\./ diff --git a/app/services/system_command.rb b/app/services/system_command.rb index 52dfdc9..c216be9 100644 --- a/app/services/system_command.rb +++ b/app/services/system_command.rb @@ -1,12 +1,10 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "open4" -require "null_logger" - -SystemCommandResult = Struct.new(:command, :exit_status, :stdout, :stderr) - class SystemCommand + Result = Struct.new(:command, :exit_status, :stdout, :stderr) + class NotAllowedError < StandardError; end + attr_reader :program attr_reader :args attr_reader :logger @@ -42,7 +40,7 @@ class SystemCommand pid, _, stdout, stderr = Open4.popen4 cmd _, status = Process.waitpid2 pid - SystemCommandResult.new( + Result.new( syscmd, status.exitstatus || 255, stdout.read.strip, diff --git a/app/services/whois.rb b/app/services/whois.rb index f6c0765..9fd0400 100644 --- a/app/services/whois.rb +++ b/app/services/whois.rb @@ -1,14 +1,17 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "null_logger" -require "domain_helper" -require "system_command" -require_relative "whois/parser" -require_relative "whois/response" -require_relative "whois/errors" - module Whois + class Error < StandardError; end + + class CommandError < Error; end + class UnsupportedDomainError < Error; end + class DomainNotFoundError < Error; end + class ParserError < Error; end + + class FieldNotFoundError < ParserError; end + class InvalidDateError < ParserError; end + class << self def ask(domain, system_klass: SystemCommand, logger: NullLogger.new) Service.new(domain, system_klass: system_klass, logger: logger).call @@ -39,7 +42,7 @@ module Whois result = command.execute unless result.exit_status.zero? - fail WhoisCommandError, "Whois command failed with status #{result.exit_status}" + fail Whois::CommandError, "Whois command failed with status #{result.exit_status}" end result diff --git a/app/services/whois/errors.rb b/app/services/whois/errors.rb deleted file mode 100644 index 6348a98..0000000 --- a/app/services/whois/errors.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (C) 2018 Colin Darie , 2018 Evolix -# License: GNU AGPL-3+ (see full text in LICENSE file) - -module Whois - class Error < StandardError; end - - class WhoisCommandError < Error; end - class UnsupportedDomainError < Error; end - class DomainNotFoundError < Error; end - class ParserError < Error; end - - class FieldNotFoundError < ParserError; end - class InvalidDateError < ParserError; end -end diff --git a/app/services/whois/parser.rb b/app/services/whois/parser.rb index 9eec072..d44631a 100644 --- a/app/services/whois/parser.rb +++ b/app/services/whois/parser.rb @@ -1,16 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "null_logger" -require "whois/errors" -require "whois/parser/afilias" -require "whois/parser/afnic" -require "whois/parser/cira" -require "whois/parser/io" -require "whois/parser/neustar" -require "whois/parser/sonic" -require "whois/parser/verisign" - module Whois module Parser PARSERS = [ diff --git a/app/services/whois/parser/afilias.rb b/app/services/whois/parser/afilias.rb index d858083..56daed7 100644 --- a/app/services/whois/parser/afilias.rb +++ b/app/services/whois/parser/afilias.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class Afilias < Base diff --git a/app/services/whois/parser/afnic.rb b/app/services/whois/parser/afnic.rb index 342fd2a..459e073 100644 --- a/app/services/whois/parser/afnic.rb +++ b/app/services/whois/parser/afnic.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class AFNIC < Base diff --git a/app/services/whois/parser/base.rb b/app/services/whois/parser/base.rb index e327c11..98e3410 100644 --- a/app/services/whois/parser/base.rb +++ b/app/services/whois/parser/base.rb @@ -1,10 +1,7 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "null_logger" require_relative "../response" -require_relative "../errors" -require_relative "entry_builder" module Whois module Parser diff --git a/app/services/whois/parser/cira.rb b/app/services/whois/parser/cira.rb index cb248f2..4d13185 100644 --- a/app/services/whois/parser/cira.rb +++ b/app/services/whois/parser/cira.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class CIRA < Base diff --git a/app/services/whois/parser/entry/blank.rb b/app/services/whois/parser/entry/blank.rb index 4c34f8b..2043ae7 100644 --- a/app/services/whois/parser/entry/blank.rb +++ b/app/services/whois/parser/entry/blank.rb @@ -1,8 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require_relative "base" - module Whois module Parser module Entry diff --git a/app/services/whois/parser/entry/field.rb b/app/services/whois/parser/entry/field.rb index 53ed379..d7751ec 100644 --- a/app/services/whois/parser/entry/field.rb +++ b/app/services/whois/parser/entry/field.rb @@ -1,8 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require_relative "base" - module Whois module Parser module Entry diff --git a/app/services/whois/parser/entry/text.rb b/app/services/whois/parser/entry/text.rb index dc8c79c..f7acfa6 100644 --- a/app/services/whois/parser/entry/text.rb +++ b/app/services/whois/parser/entry/text.rb @@ -1,8 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require_relative "base" - module Whois module Parser module Entry diff --git a/app/services/whois/parser/entry_builder.rb b/app/services/whois/parser/entry_builder.rb index 7b488d4..37e6b37 100644 --- a/app/services/whois/parser/entry_builder.rb +++ b/app/services/whois/parser/entry_builder.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require_relative "entry/blank" -require_relative "entry/field" -require_relative "entry/text" - module Whois module Parser class EntryBuilder diff --git a/app/services/whois/parser/io.rb b/app/services/whois/parser/io.rb index c1f7648..fe08fa4 100644 --- a/app/services/whois/parser/io.rb +++ b/app/services/whois/parser/io.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class IO < Base diff --git a/app/services/whois/parser/neustar.rb b/app/services/whois/parser/neustar.rb index 1406a55..303de75 100644 --- a/app/services/whois/parser/neustar.rb +++ b/app/services/whois/parser/neustar.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class Neustar < Base diff --git a/app/services/whois/parser/sonic.rb b/app/services/whois/parser/sonic.rb index ac5c683..406d7a4 100644 --- a/app/services/whois/parser/sonic.rb +++ b/app/services/whois/parser/sonic.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class Sonic < Base diff --git a/app/services/whois/parser/verisign.rb b/app/services/whois/parser/verisign.rb index a6ec93a..7943ece 100644 --- a/app/services/whois/parser/verisign.rb +++ b/app/services/whois/parser/verisign.rb @@ -1,10 +1,6 @@ # Copyright (C) 2018 Colin Darie , 2018 Evolix # License: GNU AGPL-3+ (see full text in LICENSE file) -require "domain_helper" -require "whois/errors" -require_relative "base" - module Whois module Parser class Verisign < Base diff --git a/app/views/checks/_filters.html.erb b/app/views/checks/_filters.html.erb index 39a537a..46a7b0a 100644 --- a/app/views/checks/_filters.html.erb +++ b/app/views/checks/_filters.html.erb @@ -33,7 +33,7 @@
- <%= link_to Octicons::Octicon.new("x").to_svg.html_safe, checks_path, class: "btn btn-danger btn-sm btn-outline-danger" %> + <%= link_to Octicons::Octicon.new("x").to_svg.html_safe, checks_path, class: "btn btn-sm btn-outline-danger" %>
diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index e3cbbf3..16020c7 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -1,63 +1,62 @@ <% # Copyright (C) 2018 Colin Darie , 2018 Evolix %> - <% # License: GNU AGPL-3+ (see full text in LICENSE file) %> -