diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..9fa0dd5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,5 @@ +FROM mcr.microsoft.com/devcontainers/base:ubuntu + +ENV BUNDLER_VERSION 2.5.7 + +RUN apt -y update && apt -y upgrade && apt -y install libpq-dev diff --git a/.devcontainer/create-db-user.sql b/.devcontainer/create-db-user.sql new file mode 100644 index 0000000..291dfc4 --- /dev/null +++ b/.devcontainer/create-db-user.sql @@ -0,0 +1,2 @@ +CREATE USER vscode CREATEDB; +CREATE DATABASE vscode WITH OWNER vscode; diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..e3ab3d6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,69 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres +{ + "name": "Ruby on Rails & Postgres", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + "features": { + "ghcr.io/devcontainers/features/ruby:1": { + "version": "3.3.1" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "16.20.2" + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // This can be used to network with other containers or the host. + // "forwardPorts": [3000, 5432], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "bundle install && rake db:setup", + "postCreateCommand": "gem install bundler --version 2.5.7", + + // Configure tool-specific properties. + // "customizations": {}, + + "customizations": { + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.defaultProfile.linux": "bash", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "/bin/bash", + "args": ["-l"] + } + }, + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "eslint.workingDirectories": [{ "mode": "auto" }], + "rubyLsp.erbSupport": false, + "rubyLsp.rubyVersionManager": "none", + "[ruby]": { + "editor.defaultFormatter": "Shopify.ruby-lsp", + "editor.semanticHighlighting.enabled": true + } + }, + "extensions": [ + // Add the IDs of extensions you want installed when the container is created. + "cschleiden.vscode-github-actions", + "editorconfig.editorconfig", + "vscode-icons-team.vscode-icons", + "Shopify.ruby-lsp", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "stylelint.vscode-stylelint", + "mikestead.dotenv", + "mhutchie.git-graph" + ] + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..7a50d33 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,48 @@ +version: '3' + +services: + app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + network_mode: service:db + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + image: postgres:16.3 + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + - ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql + environment: + POSTGRES_USER: postgres + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + # Your config/database.yml should use the user and password you set here, + # and host "db" (as that's the name of this service). You can use whatever + # database name you want. Use `bin/rails db:prepare` to create the database. + # + # Example: + # + # development: + # <<: *default + # host: db + # username: postgres + # password: postgres + # database: myapp_development + + # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + +volumes: + postgres-data: diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..040fe32 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig is awesome: https://EditorConfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fe3fb80 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,40 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly + + - package-ecosystem: "bundler" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 + versioning-strategy: lockfile-only + labels: + - "dependencies" + - "gem" + - "ruby" + allow: + - dependency-type: "all" + # ignore: + # - dependency-name: "example" + # versions: + # - "> 1.0.0" + + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 + versioning-strategy: lockfile-only + labels: + - "dependencies" + - "npm" + - "javascript" diff --git a/.github/workflows/build-and-push-to-ghcr.yml b/.github/workflows/build-and-push-to-ghcr.yml new file mode 100644 index 0000000..d878690 --- /dev/null +++ b/.github/workflows/build-and-push-to-ghcr.yml @@ -0,0 +1,37 @@ +name: Build and Publish Docker + +on: + push: + branches: + - master + +jobs: + build_and_push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + IMAGE_NAME: rebacklogs + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.sha }} diff --git a/.ruby-version b/.ruby-version index aedc15b..bea438e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.3 +3.3.1 diff --git a/Dockerfile b/Dockerfile index f856860..9cfd79f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ # refs: https://github.com/tootsuite/mastodon # refs: https://qiita.com/baban/items/99877f9b3065c4cf3d50 -FROM node:8.9.4-alpine as node +FROM node:16.20.2-alpine as node -FROM ruby:2.5.3-alpine as builder +FROM ruby:3.3.1-alpine as builder + +ENV BUNDLER_VERSION 2.5.7 RUN apk --update --no-cache add bash bash-completion @@ -24,7 +26,7 @@ COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules RUN ln -s /usr/local/bin/node /usr/local/bin/nodejs && \ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm -RUN gem install bundler --version 1.17.3 && \ +RUN gem install bundler --version ${BUNDLER_VERSION} && \ bundle install --without development test --path vendor/bundle && \ find vendor/bundle/ruby -path '*/gems/*/ext/*/Makefile' -exec dirname {} \; | xargs -n1 -P$(nproc) -I{} make -C {} clean @@ -46,7 +48,7 @@ ENV NODE_ENV="production" RUN cd /opt/rebacklogs && \ SECRET_KEY_BASE=precompile_placeholder bin/rails assets:precompile -FROM ruby:2.5.3-alpine +FROM ruby:3.3.1-alpine # install rails require minimum package RUN apk --update --no-cache add \ diff --git a/Gemfile b/Gemfile index df61004..227f9d8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,23 +1,23 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.5.3' +# ruby '~> 3.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Full-stack web application framework. (https://rubyonrails.org) -gem 'rails', '~> 6.0.0' +gem 'rails', '~> 7.1.3', '>= 7.1.3.2' # Use Puma as the app server # Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications (http://puma.io) -gem 'puma', '~> 3.12' +gem 'puma', '>= 5.0' # Use SCSS for stylesheets # Sass adapter for the Rails asset pipeline. (https://github.com/rails/sass-rails) gem 'sass-rails', '~> 5' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker # Use webpack to manage app-like JavaScript modules in Rails (https://github.com/rails/webpacker) -gem 'webpacker', '~> 4.0' +gem 'webpacker', '~> 5.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Create JSON structures via a Builder-style DSL (https://github.com/rails/jbuilder) -gem 'jbuilder', '~> 2.7' +gem 'jbuilder' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password @@ -28,7 +28,7 @@ gem 'jbuilder', '~> 2.7' # Reduces boot times through caching; required in config/boot.rb # Boot large ruby/rails apps faster (https://github.com/Shopify/bootsnap) -gem 'bootsnap', '>= 1.4.2', require: false +# gem 'bootsnap', '>= 1.4.2', require: false group :development, :test do # Use sqlite3 as the database for Active Record @@ -37,7 +37,7 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console # Ruby fast debugger - base + CLI (https://github.com/deivid-rodriguez/byebug) - gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + gem 'byebug', platforms: %i[mri mingw x64_mingw] end group :development do @@ -51,8 +51,6 @@ group :development do gem 'spring' # Makes spring watch files using the listen gem. (https://github.com/jonleighton/spring-watcher-listen) gem 'spring-watcher-listen', '~> 2.0.0' - # Solargraph for Ruby (http://solargraph.org) - gem 'solargraph' # Automatic Ruby code style checking tool. (https://github.com/rubocop-hq/rubocop) gem 'rubocop' # An IRB alternative and runtime developer console (http://pryrepl.org) @@ -85,7 +83,7 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Timezone Data for TZInfo (http://tzinfo.github.io) -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] # Flexible authentication solution for Rails with Warden (https://github.com/plataformatec/devise) gem 'devise' @@ -102,7 +100,7 @@ gem 'ranked-model', '~> 0.4' # Track changes to your models. (https://github.com/paper-trail-gem/paper_trail) gem 'paper_trail', '~> 10.3.0' # Common locale data and translations for Rails i18n. (http://github.com/svenfuchs/rails-i18n) -gem 'rails-i18n', '~> 6.0.0' # For 6.0.0 or higher +gem 'rails-i18n', '~> 7.0.9' # For 6.0.0 or higher # Forms made easy! (https://github.com/plataformatec/simple_form) gem 'simple_form' @@ -115,11 +113,10 @@ gem 'cancancan' gem 'rails-settings-cached', '~> 2.0' gem 'omniauth', '~> 1.9' -gem 'omniauth-twitter', '~> 1.4' gem 'omniauth-github', '~> 1.3' gem 'omniauth-google-oauth2', '~> 0.8' gem 'config' +gem 'gravatar_image_tag' gem 'kaminari', '~> 1.2' -gem 'gravatar_image_tag' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index bf634af..fa2163f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,298 +1,326 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.0.0) - actionpack (= 6.0.0) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) - actionmailer (6.0.0) - actionpack (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) + net-imap + net-pop + net-smtp + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - 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) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.0.0) - activesupport (= 6.0.0) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.0) - activesupport (= 6.0.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - 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 (6.0.0) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) + marcel (~> 1.0) + activesupport (7.1.3.4) + base64 + bigdecimal 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.7.0) - public_suffix (>= 2.0.2, < 5.0) - annotate (3.0.2) - activerecord (>= 3.2, < 7.0) - rake (>= 10.4, < 13.0) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + annotate (3.2.0) + activerecord (>= 3.2, < 8.0) + rake (>= 10.4, < 14.0) annotate_gem (0.0.14) bundler (>= 1.1) - ast (2.4.0) - backport (0.3.0) - bcrypt (3.1.13) + ast (2.4.2) + base64 (0.2.0) + bcrypt (3.1.20) + bigdecimal (3.1.8) bindex (0.8.1) - bootsnap (1.4.5) - msgpack (~> 1.0) - builder (3.2.4) - byebug (11.0.1) - cancancan (3.0.1) - capybara (3.29.0) + builder (3.3.0) + byebug (11.1.3) + cancancan (3.6.1) + capybara (3.40.0) addressable + matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - childprocess (2.0.0) - rake (< 13.0) - chunky_png (1.3.11) - coderay (1.1.2) - concurrent-ruby (1.1.6) - config (2.0.0) - activesupport (>= 4.2) + childprocess (5.0.0) + chunky_png (1.4.0) + coderay (1.1.3) + concurrent-ruby (1.3.3) + config (5.5.1) deep_merge (~> 1.2, >= 1.2.1) - dry-schema (~> 1.0) + connection_pool (2.4.1) crass (1.0.6) - deep_merge (1.2.1) - devise (4.7.1) + date (3.3.4) + deep_merge (1.2.2) + devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.8.2) - devise (>= 4.6) - dry-configurable (0.9.0) - concurrent-ruby (~> 1.0) - dry-core (~> 0.4, >= 0.4.7) - dry-container (0.7.2) - concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1, >= 0.1.3) - dry-core (0.4.9) - concurrent-ruby (~> 1.0) - dry-equalizer (0.3.0) - dry-inflector (0.2.0) - dry-initializer (3.0.2) - dry-logic (1.0.5) - concurrent-ruby (~> 1.0) - dry-core (~> 0.2) - dry-equalizer (~> 0.2) - dry-schema (1.4.1) - concurrent-ruby (~> 1.0) - dry-configurable (~> 0.8, >= 0.8.3) - dry-core (~> 0.4) - dry-equalizer (~> 0.2) - dry-initializer (~> 3.0) - dry-logic (~> 1.0) - dry-types (~> 1.2) - dry-types (1.2.1) - concurrent-ruby (~> 1.0) - dry-container (~> 0.3) - dry-core (~> 0.4, >= 0.4.4) - dry-equalizer (~> 0.2, >= 0.2.2) - dry-inflector (~> 0.1, >= 0.1.2) - dry-logic (~> 1.0, >= 1.0.2) - erubi (1.9.0) - faraday (0.17.1) - multipart-post (>= 1.2, < 3) - ffi (1.11.1) - globalid (0.4.2) - activesupport (>= 4.2.0) + devise-i18n (1.12.1) + devise (>= 4.9.0) + drb (2.2.1) + erubi (1.13.0) + faraday (2.10.0) + faraday-net_http (>= 2.0, < 3.2) + logger + faraday-net_http (3.1.0) + net-http + ffi (1.17.0) + globalid (1.2.1) + activesupport (>= 6.1) gravatar_image_tag (1.2.0) - hashie (3.6.0) - htmlentities (4.3.4) - i18n (1.8.2) + hashie (5.0.0) + i18n (1.14.5) concurrent-ruby (~> 1.0) identicon (0.0.5) chunky_png - initial_avatar (0.2.0) - jaro_winkler (1.5.3) - jbuilder (2.9.1) - activesupport (>= 4.2.0) - jwt (2.2.1) - kaminari (1.2.1) + initial_avatar (0.2.2) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + json (2.7.2) + jwt (2.8.2) + base64 + kaminari (1.2.2) activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.1) - kaminari-activerecord (= 1.2.1) - kaminari-core (= 1.2.1) - kaminari-actionview (1.2.1) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) actionview - kaminari-core (= 1.2.1) - kaminari-activerecord (1.2.1) + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) activerecord - kaminari-core (= 1.2.1) - kaminari-core (1.2.1) - kramdown (1.17.0) - launchy (2.4.3) - addressable (~> 2.3) - letter_opener (1.7.0) - launchy (~> 2.2) - letter_opener_web (1.3.4) - actionmailer (>= 3.2) - letter_opener (~> 1.0) - railties (>= 3.2) - listen (3.1.5) + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) + language_server-protocol (3.17.0.3) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + letter_opener (1.10.0) + launchy (>= 2.2, < 4) + letter_opener_web (3.0.0) + actionmailer (>= 6.1) + letter_opener (~> 1.9) + railties (>= 6.1) + rexml + listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.5.0) + logger (1.6.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.3) - mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.1) - msgpack (1.3.1) - multi_json (1.14.1) - multi_xml (0.6.0) - multipart-post (2.1.1) - nio4r (2.5.1) - nokogiri (1.10.9) - mini_portile2 (~> 2.4.0) - oauth (0.5.4) - oauth2 (1.4.2) - faraday (>= 0.8, < 2.0) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.1.0) + mini_mime (1.1.5) + mini_portile2 (2.8.7) + minitest (5.24.1) + multi_xml (0.7.1) + bigdecimal (~> 3.1) + mutex_m (0.2.0) + net-http (0.4.1) + uri + net-imap (0.4.14) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.6) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + oauth2 (2.0.9) + faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) - multi_json (~> 1.3) multi_xml (~> 0.5) - rack (>= 1.2, < 3) - omniauth (1.9.0) - hashie (>= 3.4.6, < 3.7.0) + rack (>= 1.2, < 4) + snaky_hash (~> 2.0) + version_gem (~> 1.1) + omniauth (1.9.2) + hashie (>= 3.4.6) rack (>= 1.6.2, < 3) - omniauth-github (1.3.0) + omniauth-github (1.4.0) omniauth (~> 1.5) omniauth-oauth2 (>= 1.4.0, < 2.0) omniauth-google-oauth2 (0.8.0) jwt (>= 2.0) omniauth (>= 1.1.1) omniauth-oauth2 (>= 1.6) - omniauth-oauth (1.1.0) - oauth - omniauth (~> 1.0) - omniauth-oauth2 (1.6.0) - oauth2 (~> 1.1) - omniauth (~> 1.9) - omniauth-twitter (1.4.0) - omniauth-oauth (~> 1.1) - rack + omniauth-oauth2 (1.7.3) + oauth2 (>= 1.4, < 3) + omniauth (>= 1.9, < 3) orm_adapter (0.5.0) paper_trail (10.3.1) activerecord (>= 4.2) request_store (~> 1.1) - parallel (1.17.0) - parser (2.6.4.0) - ast (~> 2.4.0) - pg (1.1.4) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - public_suffix (4.0.1) - puma (3.12.6) - rack (2.2.3) - rack-proxy (0.6.5) + parallel (1.25.1) + parser (3.3.4.0) + ast (~> 2.4.1) + racc + pg (1.5.6) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + psych (5.1.2) + stringio + public_suffix (6.0.1) + puma (6.4.2) + nio4r (~> 2.0) + racc (1.8.0) + rack (2.2.9) + rack-proxy (0.7.7) rack - rack-test (1.1.0) - rack (>= 1.0, < 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 (= 6.0.0) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rack-session (1.0.2) + rack (< 3) + rack-test (2.1.0) + rack (>= 1.3) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + bundler (>= 1.15.0) + railties (= 7.1.3.4) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) - rails-i18n (6.0.0) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + rails-i18n (7.0.9) i18n (>= 0.7, < 2) - railties (>= 6.0.0, < 7) - rails-settings-cached (2.1.1) - rails (>= 4.2.0) - request_store - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) - method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) - rainbow (3.0.0) - rake (12.3.3) - ranked-model (0.4.4) - activerecord (>= 4.1.16) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + railties (>= 6.0.0, < 8) + rails-settings-cached (2.9.4) + activerecord (>= 5.0.0) + railties (>= 5.0.0) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + ranked-model (0.4.9) + activerecord (>= 5.2) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - regexp_parser (1.6.0) - request_store (1.4.1) + rdoc (6.7.0) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.9) + io-console (~> 0.5) + request_store (1.7.0) rack (>= 1.4) - responders (3.0.0) - actionpack (>= 5.0) - railties (>= 5.0) - reverse_markdown (1.2.0) - nokogiri - rolify (5.2.0) - rubocop (0.74.0) - jaro_winkler (~> 1.5.1) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) + rexml (3.3.2) + strscan + rolify (6.0.1) + rubocop (1.65.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 2.6) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - ruby-progressbar (1.10.1) - ruby_dep (1.5.0) - rubyzip (1.3.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) + rubyzip (2.3.2) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -304,66 +332,68 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - selenium-webdriver (3.142.4) - childprocess (>= 0.5, < 3.0) - rubyzip (~> 1.2, >= 1.2.2) - sequenced (3.1.1) + selenium-webdriver (4.10.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + semantic_range (3.0.0) + sequenced (4.0.0) activerecord (>= 3.0) activesupport (>= 3.0) - simple_form (5.0.1) - actionpack (>= 5.0) - activemodel (>= 5.0) - solargraph (0.31.3) - backport (~> 0.3) - htmlentities (~> 4.3, >= 4.3.4) - jaro_winkler (~> 1.5) - kramdown (~> 1.16) - parser (~> 2.3) - reverse_markdown (~> 1.0, >= 1.0.5) - rubocop (~> 0.52) - thor (~> 0.19, >= 0.19.4) - tilt (~> 2.0) - yard (~> 0.9) - spring (2.1.0) + simple_form (5.3.1) + actionpack (>= 5.2) + activemodel (>= 5.2) + snaky_hash (2.0.1) + hashie + version_gem (~> 1.1, >= 1.1.1) + spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (3.7.2) + sprockets (3.7.3) + base64 concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - sqlite3 (1.4.1) - thor (0.20.3) - thread_safe (0.3.6) - tilt (2.0.9) - tzinfo (1.2.7) - thread_safe (~> 0.1) - unicode-display_width (1.6.0) - warden (1.2.8) - rack (>= 2.0.6) - web-console (4.0.1) + sqlite3 (1.7.3) + mini_portile2 (~> 2.8.0) + stringio (3.1.1) + strscan (3.1.0) + thor (1.3.1) + tilt (2.4.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) + uri (0.13.0) + version_gem (1.1.4) + warden (1.2.9) + rack (>= 2.0.9) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (4.1.2) + webdrivers (5.3.1) nokogiri (~> 1.6) - rubyzip (~> 1.0) - selenium-webdriver (>= 3.0, < 4.0) - webpacker (4.0.7) - activesupport (>= 4.2) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0, < 4.11) + webpacker (5.4.4) + activesupport (>= 5.2) rack-proxy (>= 0.6.1) - railties (>= 4.2) - websocket-driver (0.7.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) + webrick (1.8.1) + websocket (1.2.11) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.20) - zeitwerk (2.3.0) + zeitwerk (2.6.16) PLATFORMS ruby @@ -371,7 +401,6 @@ PLATFORMS DEPENDENCIES annotate annotate_gem - bootsnap (>= 1.4.2) byebug cancancan capybara (>= 2.15) @@ -381,20 +410,19 @@ DEPENDENCIES gravatar_image_tag identicon initial_avatar - jbuilder (~> 2.7) + jbuilder kaminari (~> 1.2) letter_opener_web listen (>= 3.0.5, < 3.2) omniauth (~> 1.9) omniauth-github (~> 1.3) omniauth-google-oauth2 (~> 0.8) - omniauth-twitter (~> 1.4) paper_trail (~> 10.3.0) pg (~> 1.1) pry - puma (~> 3.12) - rails (~> 6.0.0) - rails-i18n (~> 6.0.0) + puma (>= 5.0) + rails (~> 7.1.3, >= 7.1.3.2) + rails-i18n (~> 7.0.9) rails-settings-cached (~> 2.0) ranked-model (~> 0.4) rolify @@ -403,17 +431,13 @@ DEPENDENCIES selenium-webdriver sequenced simple_form - solargraph spring spring-watcher-listen (~> 2.0.0) sqlite3 (~> 1.4) tzinfo-data web-console (>= 3.3.0) webdrivers - webpacker (~> 4.0) - -RUBY VERSION - ruby 2.5.3p105 + webpacker (~> 5.0) BUNDLED WITH - 1.17.3 + 2.5.7 diff --git a/app/controllers/application_settings/dashboard_controller.rb b/app/controllers/application_settings/dashboard_controller.rb index 31f29bd..66d35d1 100644 --- a/app/controllers/application_settings/dashboard_controller.rb +++ b/app/controllers/application_settings/dashboard_controller.rb @@ -13,7 +13,8 @@ def update end private + def settings_params - params.require(:settings).permit(:site_title) + params.require(:settings).permit(:site_title, :head_custom_script, :body_custom_script) end end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index cb6ef12..32a888f 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -19,7 +19,6 @@ def callback_for_all_providers end end - alias twitter callback_for_all_providers alias github callback_for_all_providers alias google_oauth2 callback_for_all_providers end diff --git a/app/controllers/omniauth_finished_controller.rb b/app/controllers/omniauth_finished_controller.rb index 756fe54..3ac03d5 100644 --- a/app/controllers/omniauth_finished_controller.rb +++ b/app/controllers/omniauth_finished_controller.rb @@ -7,22 +7,22 @@ def finish_signup @user = User.find(params[:id]) @provider = params[:provider] - if (request.post? || request.patch?) && @user.update(user_params) - # OAuth の場合には希望アカウントが入力された後にグループを作る - @user.create_default_group - @user.use_gravatar_icon(false) - # @user.send_confirmation_instructions unless @user.confirmed? - sign_in(@user, bypass: true) - redirect_to root_url, notice: t('devise.omniauth_callbacks.success', kind: @provider.capitalize) - end + return unless (request.post? || request.patch?) && @user.update(user_params) + + # OAuth の場合には希望アカウントが入力された後にグループを作る + @user.create_default_group + # @user.use_gravatar_icon(false) + # @user.send_confirmation_instructions unless @user.confirmed? + sign_in(@user, bypass: true) + redirect_to root_url, notice: t('devise.omniauth_callbacks.success', kind: @provider.capitalize) end private # user_paramsにアクセスするため。 def user_params - accessible = [ :username, :email ] - accessible << [ :password, :password_confirmation ] unless params[:user][:password].blank? + accessible = %i[username email] + accessible << %i[password password_confirmation] unless params[:user][:password].blank? params.require(:user).permit(accessible) end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index c716922..0f35ae1 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -26,13 +26,13 @@ def update_password end end - def use_gravatar - current_user.use_gravatar_icon + # def use_gravatar + # current_user.use_gravatar_icon - respond_to do |format| - format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' } - end - end + # respond_to do |format| + # format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' } + # end + # end def destroy_image current_user.image.purge @@ -41,6 +41,7 @@ def destroy_image end private + def user_params params.fetch( :user, {} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1122990..4fab235 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -16,7 +16,7 @@ def nav_link(*args, &block) def changes_from_version_helper(version) return [] if version.object_changes.blank? - changes = YAML.load(version.object_changes) + changes = YAML.unsafe_load(version.object_changes) change_keys = changes.keys.reject { |key| key == :updated_at.to_s } change_keys.map do |key| diff --git a/app/helpers/o_auth/o_auth_policy.rb b/app/helpers/o_auth/o_auth_policy.rb index 6a2f16d..2d9a97e 100644 --- a/app/helpers/o_auth/o_auth_policy.rb +++ b/app/helpers/o_auth/o_auth_policy.rb @@ -1,55 +1,41 @@ # refs: https://qiita.com/mnishiguchi/items/e15bbef61287f84b546e -module OAuthPolicy - class Base - attr_reader :provider, :uid, :name, :nickname, :email, :url, :image_url, - :description, :other, :credentials, :raw_info - end - - class Twitter < OAuthPolicy::Base - def initialize(auth) - @provider = auth['provider'] - @uid = auth['uid'] - @name = auth['info']['name'] - @nickname = auth['info']['nickname'] - @email = '' - @url = auth['info']['urls']['Twitter'] - @image_url = auth['info']['image'] - @description = auth['info']['description'].try(:truncate, 255) - @credentials = auth['credentials'].to_json - @raw_info = auth['extra']['raw_info'].to_json - freeze +module OAuth + module OAuthPolicy + class Base + attr_reader :provider, :uid, :name, :nickname, :email, :url, :image_url, + :description, :other, :credentials, :raw_info end - end - class Github < OAuthPolicy::Base - def initialize(auth) - @provider = auth['provider'] - @uid = auth['uid'] - @name = auth['info']['name'] - @nickname = '' - @email = '' - @url = 'https://github.com/' - @image_url = auth['info']['image'] - @description = '' - @credentials = auth['credentials'].to_json - @raw_info = auth['extra']['raw_info'].to_json - freeze + class Github < OAuthPolicy::Base + def initialize(auth) + @provider = auth['provider'] + @uid = auth['uid'] + @name = auth['info']['name'] + @nickname = '' + @email = '' + @url = 'https://github.com/' + @image_url = auth['info']['image'] + @description = '' + @credentials = auth['credentials'].to_json + @raw_info = auth['extra']['raw_info'].to_json + freeze + end end - end - class GoogleOauth2 < OAuthPolicy::Base - def initialize(auth) - @provider = auth['provider'] - @uid = auth['uid'] - @name = auth['info']['name'] - @nickname = '' - @email = '' - @url = 'https://google.com/' - @image_url = auth['info']['image'] - @description = '' - @credentials = auth['credentials'].to_json - @raw_info = auth['extra']['raw_info'].to_json - freeze + class GoogleOauth2 < OAuthPolicy::Base + def initialize(auth) + @provider = auth['provider'] + @uid = auth['uid'] + @name = auth['info']['name'] + @nickname = '' + @email = '' + @url = 'https://google.com/' + @image_url = auth['info']['image'] + @description = '' + @credentials = auth['credentials'].to_json + @raw_info = auth['extra']['raw_info'].to_json + freeze + end end end -end +end \ No newline at end of file diff --git a/app/javascript/components/MarkdownText.vue b/app/javascript/components/MarkdownText.vue index 57ccf01..7a89417 100644 --- a/app/javascript/components/MarkdownText.vue +++ b/app/javascript/components/MarkdownText.vue @@ -54,7 +54,7 @@ export default { @import '~bootstrap/scss/mixins'; @import '~bootstrap/scss/type'; -.markdown-body /deep/ { +.markdown-body ::v-deep { h1 { @include font-size($h4-font-size); } diff --git a/app/javascript/components/commons/SelectAssignee.vue b/app/javascript/components/commons/SelectAssignee.vue index 94ebdd0..a37f282 100644 --- a/app/javascript/components/commons/SelectAssignee.vue +++ b/app/javascript/components/commons/SelectAssignee.vue @@ -98,9 +98,7 @@ export default { \ No newline at end of file diff --git a/app/javascript/components/commons/SelectAssigneeForTask.vue b/app/javascript/components/commons/SelectAssigneeForTask.vue index aa24c9c..95e09b3 100644 --- a/app/javascript/components/commons/SelectAssigneeForTask.vue +++ b/app/javascript/components/commons/SelectAssigneeForTask.vue @@ -100,7 +100,7 @@ export default { \ No newline at end of file diff --git a/app/javascript/components/commons/SelectStatus.vue b/app/javascript/components/commons/SelectStatus.vue index ff4cdf4..04b958c 100644 --- a/app/javascript/components/commons/SelectStatus.vue +++ b/app/javascript/components/commons/SelectStatus.vue @@ -86,7 +86,7 @@ export default { \ No newline at end of file diff --git a/app/javascript/components/commons/TagInput.vue b/app/javascript/components/commons/TagInput.vue index e3bd4ac..347b5e6 100644 --- a/app/javascript/components/commons/TagInput.vue +++ b/app/javascript/components/commons/TagInput.vue @@ -81,7 +81,7 @@ export default { $vs-selected-bg: #eaecf4; $vs-selected-border-color: #b7b9cc; -/deep/ { +::v-deep { @import "~vue-select/src/scss/vue-select.scss"; .vs__search::placeholder { diff --git a/app/javascript/stylesheets/application.scss b/app/javascript/stylesheets/application.scss index 2ba4383..73924d7 100644 --- a/app/javascript/stylesheets/application.scss +++ b/app/javascript/stylesheets/application.scss @@ -90,4 +90,6 @@ $font-size-xm: 0.8em !default; border: 1px solid $gray-500; font-size: 80%; -} \ No newline at end of file +} + +$vs-border-width: 0px !default; diff --git a/app/javascript/stylesheets/sb-admin/_login.scss b/app/javascript/stylesheets/sb-admin/_login.scss index b071b3c..1bbeb96 100755 --- a/app/javascript/stylesheets/sb-admin/_login.scss +++ b/app/javascript/stylesheets/sb-admin/_login.scss @@ -2,25 +2,24 @@ // Toshi the dog from https://unsplash.com/@charlesdeluvio - what a funny dog... .bg-login-image { - background: url('https://source.unsplash.com/K4mSJ7kc0As/600x800'); + background: url("https://source.unsplash.com/K4mSJ7kc0As/600x800"); background-position: center; background-size: cover; } .bg-register-image { - background: url('https://source.unsplash.com/Mv9hjnEUHR4/600x800'); + background: url("https://source.unsplash.com/Mv9hjnEUHR4/600x800"); background-position: center; background-size: cover; } .bg-password-image { - background: url('https://source.unsplash.com/oWTW-jNGl9I/600x800'); + background: url("https://source.unsplash.com/oWTW-jNGl9I/600x800"); background-position: center; background-size: cover; } form.user { - .custom-checkbox.small { label { line-height: 1.5rem; @@ -38,7 +37,6 @@ form.user { border-radius: 10rem; padding: 0.75rem 1rem; } - } .omniauth { @@ -49,10 +47,6 @@ form.user { } } -.btn-twitter { - @include button-variant($brand-twitter, $white); -} - .btn-github { @include button-variant($brand-github, $white); } diff --git a/app/javascript/stylesheets/sb-admin/_variables.scss b/app/javascript/stylesheets/sb-admin/_variables.scss index f2ec6fe..3395be6 100755 --- a/app/javascript/stylesheets/sb-admin/_variables.scss +++ b/app/javascript/stylesheets/sb-admin/_variables.scss @@ -31,7 +31,6 @@ $cyan: #36b9cc !default; $brand-google: #ea4335; $brand-facebook: #3b5998; $brand-github: #24292e; -$brand-twitter: rgba(29,161,242,1.00); // Set Contrast Threshold $yiq-contrasted-threshold: 195 !default; @@ -41,15 +40,17 @@ $yiq-contrasted-threshold: 195 !default; // kaishuu0123 CUSTOM $body-color: $gray-700 !default; -$font-family-sans-serif: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", 'Noto Color Emoji' !default; +$font-family-sans-serif: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", + Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", + "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default; $font-weight-light: 300 !default; // $font-weight-base: 400; $headings-font-weight: 400 !default; // Shadows -$box-shadow-sm: 0 0.125rem 0.25rem 0 rgba($gray-900, .2) !default; -$box-shadow: 0 0.15rem 1.75rem 0 rgba($gray-900, .15) !default; +$box-shadow-sm: 0 0.125rem 0.25rem 0 rgba($gray-900, 0.2) !default; +$box-shadow: 0 0.15rem 1.75rem 0 rgba($gray-900, 0.15) !default; // $box-shadow-lg: 0 1rem 3rem rgba($black, .175) !default; // Borders Radius @@ -73,7 +74,7 @@ $spacer: 1rem; $grid-gutter-width: $spacer * 1.5; // Transitions -$transition-collapse: height .15s ease !default; +$transition-collapse: height 0.15s ease !default; // Dropdowns $dropdown-font-size: 0.85rem; diff --git a/app/models/setting.rb b/app/models/setting.rb index 460f225..0ab2542 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -11,7 +11,7 @@ # RailsSettings Model class Setting < RailsSettings::Base - cache_prefix { "v1" } + cache_prefix { 'v2' } # Define your fields # field :host, type: :string, default: "http://localhost:3000" @@ -24,4 +24,7 @@ class Setting < RailsSettings::Base field :installed, type: :boolean, default: false field :site_title, type: :string, default: '' + + field :head_custom_script, type: :string, default: '' + field :body_custom_script, type: :string, default: '' end diff --git a/app/models/social_profile.rb b/app/models/social_profile.rb index 78de49b..0b36bef 100644 --- a/app/models/social_profile.rb +++ b/app/models/social_profile.rb @@ -27,7 +27,7 @@ class SocialProfile < ApplicationRecord validates_uniqueness_of :uid, scope: :provider def self.find_for_oauth(auth) - profile = find_or_create_by(uid: auth.uid, provider: auth.provider) + profile = find_or_initialize_by(uid: auth.uid, provider: auth.provider) profile.save_oauth_data!(auth) profile end @@ -35,28 +35,36 @@ def self.find_for_oauth(auth) def save_oauth_data!(auth) return unless valid_oauth?(auth) - provider = auth["provider"] + provider = auth['provider'] policy = policy(provider, auth) - self.update_attributes( uid: policy.uid, - name: policy.name, - nickname: policy.nickname, - email: policy.email, - url: policy.url, - image_url: policy.image_url, - description: policy.description, - credentials: policy.credentials, - raw_info: policy.raw_info ) + update_params = { + uid: policy.uid, + name: policy.name, + nickname: policy.nickname, + email: policy.email, + url: policy.url, + image_url: policy.image_url, + description: policy.description, + credentials: policy.credentials, + raw_info: policy.raw_info + } + + if persisted? + update!(update_params) + else + assign_attributes(update_params) + end end private def policy(provider, auth) class_name = "#{provider}".classify - "OAuthPolicy::#{class_name}".constantize.new(auth) + "OAuth::OAuthPolicy::#{class_name}".constantize.new(auth) end def valid_oauth?(auth) - (self.provider.to_s == auth['provider'].to_s) && (self.uid == auth['uid']) + (provider.to_s == auth['provider'].to_s) && (uid == auth['uid']) end -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index 5dc398f..91ab303 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,15 +15,15 @@ class User < ApplicationRecord # GRAVATAR のデフォルトアイコン (電源ボタンっぽいやつ) - GRAVATAR_DEFAULT_ICON_BASE64 = '/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gOTAK/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAUABQAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A8hooor+iD+YQo/CiigAo9a+h/wBmn9ku4+OOmXOvapqkmjeH4pjbxGCMPNcyAAttzwqjIGSDk5GODXs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XZYngmeKVGilQlXjcbWUjqCD0NLBDJczRwwo8ssjBUjjBZmJ6AAdTX7A+Ivhf4M8YSebrnhnSNXmxgTXlnHJIB/vEZ/WneG/hv4N8ES+dofhrR9HmxjzrOzjjkx/vAZ/Wvqf9bafJ/BfN66fl+h8f/qXV57e2XL6a/df9T5P/ZH/AGSNR0/WrLxx44smsvsrCbTdIuFxL5n8M0q/w7eqqec4Jxjn638Za4mmac67hvYdM1JrXiy102Ftrhnx618PftO/tNLqAu/DXhq7E91JmK8v4WysC9CiEdXPQkfd+vT5WUsXn+LWmv4RX9fefYxjguHME9dPxk/6+48W/aD8fp8QviZe3FvL5unWA+x27g8PtJLuPqxOD3AFecfjSKoRQAMAUtfr+Fw8cLRjRhtFWPxDF4meMrzr1N5O4UUUV1HIIRkc16/8NP2pvHnwzt4rKG/XWtJjAVLLUwZPLX0RwQyj0GSB6V5DRXNXw1HFR5K0VJeZ14bFV8JP2lCbi/I+y9L/AOCgdq8A/tLwte28uOfsl0kqk/8AAguKqa5+3xBLCw03w1ezSEcfarlIgP8AvkNXx/RXhf6uZdzX5H97/wAz6L/WjNOXl9ovWy/yPTfiJ+0X40+IyS21xerpWmycNaaflN49HcksfcZAPpXmKqFGAMD2paK93D4ajhYclGKivI+dxOLr4uftK83J+YUUUV0nKf/Z' rolify attribute :skip_create_default_group, :boolean, default: false # XXX: set_gravatar_icon を create_default_group より後の行に書くと処理が継続されない問題を調べる必要がある - after_create_commit :set_gravatar_icon, if: Proc.new { - skip_create_default_group == false - } - after_create_commit :create_default_group, if: Proc.new { + # after_create_commit :set_gravatar_icon, if: Proc.new { + # skip_create_default_group == false + # } + after_create_commit :create_default_group, if: proc { skip_create_default_group == false } after_create_commit :assign_default_role @@ -31,7 +31,7 @@ class User < ApplicationRecord attr_writer :login TEMP_EMAIL_PREFIX = 'change@me'.freeze - TEMP_EMAIL_REGEX = /\Achange@me/.freeze + TEMP_EMAIL_REGEX = /\Achange@me/ # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable @@ -39,7 +39,7 @@ class User < ApplicationRecord :recoverable, :rememberable, :validatable, :omniauthable validates :username, presence: true, uniqueness: { case_sensitive: false } - validates_format_of :username, with: /^[a-zA-Z0-9_-]*$/, :multiline => true + validates_format_of :username, with: /^[a-zA-Z0-9_-]*$/, multiline: true validate :validate_username has_many :group_users, dependent: :destroy @@ -52,19 +52,20 @@ class User < ApplicationRecord validates :email, presence: true, email: true def validate_username - if User.where(email: username).exists? - errors.add(:username, :invalid) - end + return unless User.where(email: username).exists? + + errors.add(:username, :invalid) end def login - @login || self.username || self.email + @login || username || email end def self.find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) - where(conditions.to_h).where(['lower(username) = :value OR lower(email) = :value', { :value => login.downcase }]).first + where(conditions.to_h).where(['lower(username) = :value OR lower(email) = :value', + { value: login.downcase }]).first elsif conditions.has_key?(:username) || conditions.has_key?(:email) where(conditions.to_h).first end @@ -75,9 +76,9 @@ def create_default_group end # ユーザ作成時に呼び出される Gravatar アイコンを設定するフック - def set_gravatar_icon - use_gravatar_icon(false) - end + # def set_gravatar_icon + # use_gravatar_icon(false) + # end def user_image_url if image.present? @@ -92,42 +93,42 @@ def user_image_url end def assign_default_role - self.add_role(:developer) if self.roles.blank? + add_role(:developer) if roles.blank? end # 現在のアイコンを Gravatar アイコンにセットする # use_default_icon を false にすると、 gravatar 公式のデフォルトアイコンと合致した場合には何もしないようになっている - def use_gravatar_icon(use_default_icon = true) - require 'open-uri' - - # Gravatar の デフォルトアイコンを使わない場合 - unless use_default_icon - image_url = ApplicationController.helpers.gravatar_image_url( - email - ) - image_data = nil - URI.open(image_url) do |file| - image_data = file.read - end - - return if GRAVATAR_DEFAULT_ICON_BASE64 == Base64.strict_encode64(image_data) - end - - image_url = ApplicationController.helpers.gravatar_image_url( - email, - size: 180, - secure: true - ) - - URI.open(image_url) do |file| - image.purge - image.attach( - io: file, - filename: "#{username}-gravatar.#{File.basename(file.meta['content-type'])}", - content_type: file.meta['content-type'] - ) - end - end + # def use_gravatar_icon(use_default_icon = true) + # require 'open-uri' + + # # Gravatar の デフォルトアイコンを使わない場合 + # unless use_default_icon + # image_url = ApplicationController.helpers.gravatar_image_url( + # email + # ) + # image_data = nil + # URI.open(image_url) do |file| + # image_data = file.read + # end + + # return if GRAVATAR_DEFAULT_ICON_BASE64 == Base64.strict_encode64(image_data) + # end + + # image_url = ApplicationController.helpers.gravatar_image_url( + # email, + # size: 180, + # secure: true + # ) + + # URI.open(image_url) do |file| + # image.purge + # image.attach( + # io: file, + # filename: "#{username}-gravatar.#{File.basename(file.meta['content-type'])}", + # content_type: file.meta['content-type'] + # ) + # end + # end ### # refs: https://qiita.com/mnishiguchi/items/e15bbef61287f84b546e @@ -138,7 +139,7 @@ def social_profile(provider) # 本物の email がセットされているか確認。 def email_verified? - self.email && self.email !~ TEMP_EMAIL_REGEX + email && email !~ TEMP_EMAIL_REGEX end # email 確認がされていない状態にする。 diff --git a/app/services/o_auth_service.rb b/app/services/o_auth_service.rb index e7a7941..3610aab 100644 --- a/app/services/o_auth_service.rb +++ b/app/services/o_auth_service.rb @@ -10,10 +10,16 @@ def self.call(auth) user = current_or_profile_user(profile) unless user # 第3候補:認証データにemailが含まれていればそれを元にユーザーを探す。 - user = User.where(email: email).first if verified_email_from_oauth(auth) + user = User.where(email:).first if verified_email_from_oauth(auth) # 見つからなければ、ユーザーを新規作成。 user ||= find_or_create_new_user(auth) end + + unless profile.persisted? + profile.user = user + profile.save! + end + associate_user_with_profile!(user, profile) user end @@ -31,21 +37,21 @@ def current_or_profile_user(profile) def find_or_create_new_user(auth) # Query for user if verified email is provided email = verified_email_from_oauth(auth) - user = User.where(email: email).first if email - if user.nil? - temp_email = "#{User::TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com" - user = User.new( - username: auth.extra.raw_info.name, - email: email ? email : temp_email, - password: Devise.friendly_token[0, 20] - ) - user.skip_create_default_group = true - # email確認メール送信を延期するために一時的にemail確認済みの状態にする。 - # user.skip_confirmation! - # email仮をデータベースに保存するため、validationを一時的に無効化。 - user.save(validate: false) - user - end + user = User.where(email:).first if email + return unless user.nil? + + temp_email = "#{User::TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com" + user = User.new( + username: auth.extra.raw_info.name, + email: email || temp_email, + password: Devise.friendly_token[0, 20] + ) + user.skip_create_default_group = true + # email確認メール送信を延期するために一時的にemail確認済みの状態にする。 + # user.skip_confirmation! + # email仮をデータベースに保存するため、validationを一時的に無効化。 + user.save(validate: false) + user end def verified_email_from_oauth(auth) @@ -58,4 +64,4 @@ def associate_user_with_profile!(user, profile) end end end -end \ No newline at end of file +end diff --git a/app/views/application_settings/dashboard/index.html.erb b/app/views/application_settings/dashboard/index.html.erb index d6c38f2..e506c64 100644 --- a/app/views/application_settings/dashboard/index.html.erb +++ b/app/views/application_settings/dashboard/index.html.erb @@ -13,6 +13,8 @@