From a9ff7333a83eeab08ba12680b2babd77fbdc39bd Mon Sep 17 00:00:00 2001 From: Rami Maalouf Date: Mon, 31 Jul 2023 15:56:40 -0400 Subject: [PATCH] Initial commit --- .browserslistrc | 1 + .env.development.example | 1 + .erb-lint.yml | 36 ++ .gitattributes | 7 + .github/actions/erblint/action.yml | 63 +++ .github/actions/erblint/script.sh | 97 +++++ .github/workflows/appscan-legacy.yml | 18 + .github/workflows/lint.yml | 22 + .github/workflows/mirror-github-ibm.yml | 22 + .github/workflows/release.yml | 22 + .github/workflows/rspec-tests.yml | 42 ++ .github/workflows/static-analysis.yml | 26 ++ .gitignore | 57 +++ .rubocop.yml | 38 ++ .ruby-version | 1 + CODEOWNERS | 1 + Dockerfile | 93 ++++ Gemfile | 82 ++++ Gemfile.lock | 405 ++++++++++++++++++ LICENSE | 202 +++++++++ Procfile.dev | 3 + README.md | 57 +++ Rakefile | 6 + app/assets/builds/.keep | 0 app/assets/config/manifest.js | 5 + app/assets/images/.keep | 0 app/assets/stylesheets/application.css | 15 + .../stylesheets/application.tailwind.css | 36 ++ app/channels/application_cable/channel.rb | 4 + app/channels/application_cable/connection.rb | 4 + app/components/alert_component.html.erb | 34 ++ app/components/alert_component.rb | 51 +++ app/components/base_component.rb | 24 ++ .../nav_menu_badge_component.html.erb | 5 + app/components/nav_menu_badge_component.rb | 21 + .../nav_menu_item_component.html.erb | 14 + app/components/nav_menu_item_component.rb | 15 + .../nav_menu_subitem_component.html.erb | 4 + app/components/nav_menu_subitem_component.rb | 13 + .../page_heading_component.html.erb | 22 + app/components/page_heading_component.rb | 12 + app/controllers/application_controller.rb | 2 + app/controllers/concerns/.keep | 0 app/controllers/home_controller.rb | 5 + app/helpers/application_helper.rb | 3 + app/helpers/class_name_helper.rb | 19 + app/helpers/fetch_or_fallback_helper.rb | 45 ++ app/helpers/heroicon_helper.rb | 5 + app/inputs/custom_inputs/base_input.rb | 7 + app/javascript/application.js | 11 + app/jobs/application_job.rb | 7 + app/mailers/application_mailer.rb | 4 + app/models/application_record.rb | 3 + app/models/concerns/.keep | 0 app/views/home/index.html.erb | 7 + app/views/layouts/_flash.html.erb | 12 + app/views/layouts/application.html.erb | 19 + app/views/layouts/mailer.html.erb | 13 + app/views/layouts/mailer.text.erb | 1 + app/views/layouts/shell.html.erb | 86 ++++ bin/bundle | 116 +++++ bin/dev | 8 + bin/importmap | 4 + bin/rails | 4 + bin/rake | 4 + bin/setup | 33 ++ config.ru | 6 + config/application.rb | 22 + config/boot.rb | 4 + config/cable.yml | 10 + config/credentials.yml.enc | 1 + config/database.yml | 86 ++++ config/environment.rb | 5 + config/environments/development.rb | 75 ++++ config/environments/production.rb | 93 ++++ config/environments/test.rb | 60 +++ config/importmap.rb | 14 + config/initializers/assets.rb | 12 + config/initializers/config.rb | 54 +++ .../initializers/content_security_policy.rb | 25 ++ .../initializers/filter_parameter_logging.rb | 8 + config/initializers/heroicon.rb | 5 + config/initializers/inflections.rb | 16 + config/initializers/permissions_policy.rb | 11 + config/initializers/sidekiq.rb | 30 ++ config/initializers/simple_form.rb | 241 +++++++++++ config/locales/en.yml | 33 ++ config/locales/views/home.en.yml | 6 + config/puma.rb | 43 ++ config/routes.rb | 6 + config/storage.yml | 34 ++ config/tailwind.config.js | 41 ++ db/schema.rb | 17 + db/seeds.rb | 7 + docker-compose.yml | 15 + lib/assets/.keep | 0 lib/tasks/.keep | 0 log/.keep | 0 public/404.html | 67 +++ public/422.html | 67 +++ public/500.html | 66 +++ public/SN_lightMode_railsTemplate.svg | 167 ++++++++ public/apple-touch-icon-precomposed.png | 0 public/apple-touch-icon.png | 0 public/favicon.ico | Bin 0 -> 15406 bytes public/robots.txt | 1 + spec/rails_helper.rb | 68 +++ spec/requests/home_spec.rb | 10 + spec/spec_helper.rb | 112 +++++ storage/.keep | 0 test/application_system_test_case.rb | 5 + .../application_cable/connection_test.rb | 13 + test/controllers/.keep | 0 test/fixtures/files/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/system/.keep | 0 test/test_helper.rb | 15 + tmp/.keep | 0 tmp/pids/.keep | 0 tmp/storage/.keep | 0 vendor/.keep | 0 vendor/javascript/.keep | 0 125 files changed, 3570 insertions(+) create mode 100644 .browserslistrc create mode 100644 .env.development.example create mode 100644 .erb-lint.yml create mode 100644 .gitattributes create mode 100644 .github/actions/erblint/action.yml create mode 100755 .github/actions/erblint/script.sh create mode 100644 .github/workflows/appscan-legacy.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/mirror-github-ibm.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/rspec-tests.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 .gitignore create mode 100644 .rubocop.yml create mode 100644 .ruby-version create mode 100644 CODEOWNERS create mode 100644 Dockerfile create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 LICENSE create mode 100644 Procfile.dev create mode 100644 README.md create mode 100644 Rakefile create mode 100644 app/assets/builds/.keep create mode 100644 app/assets/config/manifest.js create mode 100644 app/assets/images/.keep create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/application.tailwind.css create mode 100644 app/channels/application_cable/channel.rb create mode 100644 app/channels/application_cable/connection.rb create mode 100644 app/components/alert_component.html.erb create mode 100644 app/components/alert_component.rb create mode 100644 app/components/base_component.rb create mode 100644 app/components/nav_menu_badge_component.html.erb create mode 100644 app/components/nav_menu_badge_component.rb create mode 100644 app/components/nav_menu_item_component.html.erb create mode 100644 app/components/nav_menu_item_component.rb create mode 100644 app/components/nav_menu_subitem_component.html.erb create mode 100644 app/components/nav_menu_subitem_component.rb create mode 100644 app/components/page_heading_component.html.erb create mode 100644 app/components/page_heading_component.rb create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/controllers/home_controller.rb create mode 100644 app/helpers/application_helper.rb create mode 100644 app/helpers/class_name_helper.rb create mode 100644 app/helpers/fetch_or_fallback_helper.rb create mode 100644 app/helpers/heroicon_helper.rb create mode 100644 app/inputs/custom_inputs/base_input.rb create mode 100644 app/javascript/application.js create mode 100644 app/jobs/application_job.rb create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/models/application_record.rb create mode 100644 app/models/concerns/.keep create mode 100644 app/views/home/index.html.erb create mode 100644 app/views/layouts/_flash.html.erb create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.text.erb create mode 100644 app/views/layouts/shell.html.erb create mode 100755 bin/bundle create mode 100755 bin/dev create mode 100755 bin/importmap create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/setup create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/cable.yml create mode 100644 config/credentials.yml.enc create mode 100644 config/database.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/importmap.rb create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/config.rb create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/heroicon.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/permissions_policy.rb create mode 100644 config/initializers/sidekiq.rb create mode 100644 config/initializers/simple_form.rb create mode 100644 config/locales/en.yml create mode 100644 config/locales/views/home.en.yml create mode 100644 config/puma.rb create mode 100644 config/routes.rb create mode 100644 config/storage.yml create mode 100644 config/tailwind.config.js create mode 100644 db/schema.rb create mode 100644 db/seeds.rb create mode 100644 docker-compose.yml create mode 100644 lib/assets/.keep create mode 100644 lib/tasks/.keep create mode 100644 log/.keep create mode 100644 public/404.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/SN_lightMode_railsTemplate.svg create mode 100644 public/apple-touch-icon-precomposed.png create mode 100644 public/apple-touch-icon.png create mode 100644 public/favicon.ico create mode 100644 public/robots.txt create mode 100644 spec/rails_helper.rb create mode 100644 spec/requests/home_spec.rb create mode 100644 spec/spec_helper.rb create mode 100644 storage/.keep create mode 100644 test/application_system_test_case.rb create mode 100644 test/channels/application_cable/connection_test.rb create mode 100644 test/controllers/.keep create mode 100644 test/fixtures/files/.keep create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/system/.keep create mode 100644 test/test_helper.rb create mode 100644 tmp/.keep create mode 100644 tmp/pids/.keep create mode 100644 tmp/storage/.keep create mode 100644 vendor/.keep create mode 100644 vendor/javascript/.keep diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..e94f814 --- /dev/null +++ b/.browserslistrc @@ -0,0 +1 @@ +defaults diff --git a/.env.development.example b/.env.development.example new file mode 100644 index 0000000..fc3fd26 --- /dev/null +++ b/.env.development.example @@ -0,0 +1 @@ +export DATABASE_URL="postgresql://postgres:password@localhost:5432/template_development?schema=public&connection_limit=5" diff --git a/.erb-lint.yml b/.erb-lint.yml new file mode 100644 index 0000000..92db2fe --- /dev/null +++ b/.erb-lint.yml @@ -0,0 +1,36 @@ +--- +EnableDefaultLinters: true +linters: + ErbSafety: + enabled: true + Rubocop: + enabled: true + rubocop_config: + inherit_from: + - .rubocop.yml + Layout/InitialIndentation: + Enabled: false + Layout/LineLength: + Enabled: false + Layout/TrailingEmptyLines: + Enabled: false + Layout/TrailingWhitespace: + Enabled: false + Naming/FileName: + Enabled: false + Style/FrozenStringLiteralComment: + Enabled: false + Lint/UselessAssignment: + Enabled: false + Rails/OutputSafety: + Enabled: false + GitHub/RailsViewRenderPathsExist: + Enabled: false + Layout/FirstArgumentIndentation: + Enabled: false + SpaceInHtmlTag: + enabled: false + PartialInstanceVariable: + enabled: true + RequireScriptNonce: + enabled: true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..31eeee0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored diff --git a/.github/actions/erblint/action.yml b/.github/actions/erblint/action.yml new file mode 100644 index 0000000..680a1fe --- /dev/null +++ b/.github/actions/erblint/action.yml @@ -0,0 +1,63 @@ +name: 'Run erb-lint with reviewdog' +description: '🐶 Run erb-lint with reviewdog on pull requests to improve code review experience.' +inputs: + github_token: + description: 'GITHUB_TOKEN' + default: ${{ github.token }} + erblint_version: + description: 'erb-lint version' + rubocop_extensions: + description: 'Rubocop extensions' + default: 'rubocop-rails rubocop-performance rubocop-rspec rubocop-i18n rubocop-rake' + use_bundler: + description: "Run erb-lint with bundle exec. Default: `false`" + default: 'false' + tool_name: + description: 'Tool name to use for reviewdog reporter' + default: 'erb-lint' + level: + description: 'Report level for reviewdog [info,warning,error]' + default: 'error' + reporter: + description: | + Reporter of reviewdog command [github-pr-check,github-check,github-pr-review]. + Default is github-pr-check. + default: 'github-pr-check' + filter_mode: + description: | + Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. + Default is added. + default: 'added' + reviewdog_flags: + description: 'Additional reviewdog flags' + default: '' + workdir: + description: "The directory from which to look for and run erb-lint. Default '.'" + default: '.' +runs: + using: 'composite' + steps: + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v23.1 + with: + files: | + **/*.erb + - run: .github/actions/erblint/script.sh + shell: sh + env: + REVIEWDOG_VERSION: v0.14.1 + INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} + INPUT_RUBOCOP_EXTENSIONS: ${{ inputs.rubocop_extensions }} + INPUT_ERBLINT_VERSION: ${{ inputs.erblint_version }} + INPUT_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + INPUT_TOOL_NAME: ${{ inputs.tool_name }} + INPUT_LEVEL: ${{ inputs.level }} + INPUT_REPORTER: ${{ inputs.reporter }} + INPUT_FILTER_MODE: ${{ inputs.filter_mode }} + INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} + INPUT_WORKDIR: ${{ inputs.workdir }} + INPUT_USE_BUNDLER: ${{ inputs.use_bundler }} +branding: + icon: 'check-circle' + color: 'blue' diff --git a/.github/actions/erblint/script.sh b/.github/actions/erblint/script.sh new file mode 100755 index 0000000..a1346d5 --- /dev/null +++ b/.github/actions/erblint/script.sh @@ -0,0 +1,97 @@ +#!/bin/sh -e +version() { + if [ -n "$1" ]; then + echo "-v $1" + fi +} + +cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit +export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" + +TEMP_PATH="$(mktemp -d)" +PATH="${TEMP_PATH}:$PATH" + +echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog' +curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1 +echo '::endgroup::' + +echo '::group:: Installing erb-lint ... https://github.com/Shopify/erb-lint' +# grep for erb-lint version +ERBLINT_GEMFILE_VERSION=$(ruby -ne 'print $& if /^\s{4}erb_lint\s\(\K.*(?=\))/' Gemfile.lock) + +# if erb-lint version found, then pass it to the gem install +# left it empty otherwise, so no version will be passed +if [ -n "$ERBLINT_GEMFILE_VERSION" ]; then + ERBLINT_VERSION=$ERBLINT_GEMFILE_VERSION + else + printf "Cannot get the erb-lint's version from Gemfile.lock. The latest version will be installed." +fi +echo '::endgroup::' + +gem install -N erb_lint --version "${ERBLINT_VERSION}" + +echo '::group:: Installing rubocop extensions' +# Traverse over list of rubocop extensions +for extension in $INPUT_RUBOCOP_EXTENSIONS; do + # grep for name and version + INPUT_RUBOCOP_EXTENSION_NAME=$(echo "$extension" |awk 'BEGIN { FS = ":" } ; { print $1 }') + INPUT_RUBOCOP_EXTENSION_VERSION=$(echo "$extension" |awk 'BEGIN { FS = ":" } ; { print $2 }') + + + # if version is 'gemfile' + if [ "${INPUT_RUBOCOP_EXTENSION_VERSION}" = "gemfile" ]; then + # if Gemfile.lock is here + if [ -f 'Gemfile.lock' ]; then + # grep for rubocop extension version + RUBOCOP_EXTENSION_GEMFILE_VERSION=$(ruby -ne "print $& if /^\s{4}$INPUT_RUBOCOP_EXTENSION_NAME\s\(\K.*(?=\))/" Gemfile.lock) + + + # if rubocop extension version found, then pass it to the gem install + # left it empty otherwise, so no version will be passed + if [ -n "$RUBOCOP_EXTENSION_GEMFILE_VERSION" ]; then + RUBOCOP_EXTENSION_VERSION=$RUBOCOP_EXTENSION_GEMFILE_VERSION + else + printf "Cannot get the rubocop extension version from Gemfile.lock. The latest version will be installed." + fi + else + printf 'Gemfile.lock not found. The latest version will be installed.' + fi + else + # set desired rubocop extension version + RUBOCOP_EXTENSION_VERSION=$INPUT_RUBOCOP_EXTENSION_VERSION + fi + + # Handle extensions with no version qualifier + if [ -z "${RUBOCOP_EXTENSION_VERSION}" ]; then + unset RUBOCOP_EXTENSION_VERSION_FLAG + else + RUBOCOP_EXTENSION_VERSION_FLAG="--version ${RUBOCOP_EXTENSION_VERSION}" + fi + + # shellcheck disable=SC2086 + gem install -N "${INPUT_RUBOCOP_EXTENSION_NAME}" ${RUBOCOP_EXTENSION_VERSION_FLAG} +done +echo '::endgroup::' + +export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" + +if [ "${INPUT_USE_BUNDLER}" = "false" ]; then + BUNDLE_EXEC="" +else + BUNDLE_EXEC="bundle exec " +fi + +echo '::group:: Running erb-lint with reviewdog 🐶 ...' +# shellcheck disable=SC2086 +${BUNDLE_EXEC}erblint --format compact ${INPUT_FILES} \ + | reviewdog \ + -efm="%f:%l:%c: %m" \ + -name="${INPUT_TOOL_NAME}" \ + -reporter="${INPUT_REPORTER}" \ + -filter-mode="${INPUT_FILTER_MODE}" \ + -level="${INPUT_LEVEL}" \ + ${INPUT_REVIEWDOG_FLAGS} + +reviewdog_rc=$? +echo '::endgroup::' +exit $reviewdog_rc diff --git a/.github/workflows/appscan-legacy.yml b/.github/workflows/appscan-legacy.yml new file mode 100644 index 0000000..28cc44c --- /dev/null +++ b/.github/workflows/appscan-legacy.yml @@ -0,0 +1,18 @@ +name: static analysis (legacy) + +on: + push: + branches: + - master + - main + workflow_dispatch: + repository_dispatch: + +jobs: + scan: + uses: ibm-skills-network/.github/.github/workflows/appscan-legacy.yml@main + secrets: + skills-network-bot-app-id: ${{ secrets.SKILLS_NETWORK_BOT_APP_ID }} + skills-network-bot-private-key: ${{ secrets.SKILLS_NETWORK_BOT_PRIVATE_KEY }} + asoc-key: ${{ secrets.ASOC_KEY }} + asoc-secret: ${{ secrets.ASOC_SECRET }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..36b14b5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint +on: [pull_request] +jobs: + lint: + name: Rubocop + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + - name: rubocop + uses: reviewdog/action-rubocop@v2 + with: + rubocop_version: gemfile + rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-github:gemfile rubocop-rspec:gemfile +# erb-lint has issues with Alpine (of which is used extensively throughout our products), follow the following issues before re-enabling: +# https://github.com/Shopify/erb-lint/issues/221 +# https://github.com/Shopify/better-html/issues/69 +# - name: erb-lint +# uses: ./.github/actions/erblint +# with: +# rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-github:gemfile diff --git a/.github/workflows/mirror-github-ibm.yml b/.github/workflows/mirror-github-ibm.yml new file mode 100644 index 0000000..67d287b --- /dev/null +++ b/.github/workflows/mirror-github-ibm.yml @@ -0,0 +1,22 @@ +name: mirror github ibm + +on: + push: + branches: + - master + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + # Allows you to use the GitHub API to trigger a webhook event + repository_dispatch: + +jobs: + mirror: + uses: ibm-skills-network/.github/.github/workflows/mirror-github-ibm.yml@main + with: + repo_name: rails-app-template + secrets: + ssh_private_key: + ${{ secrets.MIRROR_GITHUB_IBM_SSH_PRIVATE_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2d61f3c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Build and Release Image +on: + push: + branches: + - master + - main + tags: + - '**' + schedule: + - cron: 0 5 * * * + workflow_dispatch: + inputs: + suffix: + description: Custom suffix for tag + required: false + repository_dispatch: +jobs: + build: + uses: ibm-skills-network/.github/.github/workflows/release.yml@main + with: + image: icr.io/skills-network-faculty/rails-app-template + secrets: inherit diff --git a/.github/workflows/rspec-tests.yml b/.github/workflows/rspec-tests.yml new file mode 100644 index 0000000..881ec38 --- /dev/null +++ b/.github/workflows/rspec-tests.yml @@ -0,0 +1,42 @@ +name: Tests + +on: [push] + +jobs: + build: + name: RSpec + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:14-alpine + ports: ["5432:5432"] + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: rails_app_template_test + redis: + image: redis:7-alpine + ports: ["6379:6379"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Setup Database + env: + RAILS_ENV: test + run: bin/rails db:create db:schema:load + - name: Test with rspec + env: + RAILS_ENV: test + run: bundle exec rspec spec + - name: Archive RSpec screenshots + if: always() + uses: actions/upload-artifact@v3 + with: + name: rspec-screenshots + path: tmp/screenshots diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..5103efb --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,26 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: static analysis + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + scan: + uses: ibm-skills-network/.github/.github/workflows/static-analysis.yml@main + secrets: + skills-network-bot-app-id: ${{ secrets.SKILLS_NETWORK_BOT_APP_ID }} + skills-network-bot-private-key: ${{ secrets.SKILLS_NETWORK_BOT_PRIVATE_KEY }} + asoc-key: ${{ secrets.ASOC_KEY }} + asoc-secret: ${{ secrets.ASOC_SECRET }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a28b624 --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore uploaded files in development. +/storage/* +!/storage/.keep + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key + +/public/packs +/public/packs-test +/node_modules +/yarn-error.log +yarn-debug.log* +.yarn-integrity +test/* + +config/settings.local.yml +config/settings/*.local.yml +config/environments/*.local.yml +*.dec +*.dec + +# Ignore dotenv files +.env.* +!.env.*.example +.env + +# IDE dirs +.vscode +.idea + +/app/assets/builds/* +!/app/assets/builds/.keep +.DS_Store +coverage diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3e7eff9 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,38 @@ +require: + - rubocop-rspec + - rubocop-rails + +inherit_gem: + rubocop-github: + - config/default_edge.yml + - config/rails_edge.yml + +AllCops: + NewCops: disable + Exclude: + - 'db/schema.rb' + - 'db/migrate/**/*' + - 'app/models/setting.rb' + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Rails/EnumHash: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false + +GitHub/RailsControllerRenderPathsExist: + Enabled: false + +Style/TernaryParentheses: + EnforcedStyle: require_parentheses_when_complex + +Lint/MissingSuper: + Exclude: + - 'app/components/**/*' + - 'app/services/**/*' diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..944880f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.0 diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..fc2adbe --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @ibm-skills-network/full-time-developers \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8832e0a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,93 @@ +FROM icr.io/skills-network/ruby:3.2.0 as builder + +ENV APP_HOME /app +ENV RAILS_ENV production + +WORKDIR /app + +USER root + +# Install Gem +COPY Gemfile Gemfile.lock ./ +RUN apk add --no-cache --virtual build_deps \ + git && \ + apk add bind-tools \ + gcompat \ + build-base && \ + apk add --no-cache \ + postgresql-dev && \ + bundle install --jobs="$(nproc --all)" \ + --frozen \ + --retry 3 \ + -j4 \ + --without development test && \ + rm -rf /usr/local/bundle/bundler/gems/*/.git \ + /usr/local/bundle/cache/ && \ + rm -rf /var/cache/apk/* && \ + apk del build_deps + +COPY bin ./bin +COPY config ./config +COPY db ./db +COPY lib ./lib +COPY public ./public +COPY vendor ./vendor +COPY app/components ./app/components +COPY app/inputs ./app/inputs +COPY app/views ./app/views +COPY app/assets ./app/assets +COPY app/javascript ./app/javascript +COPY app/models ./app/models + +# Config files +COPY Rakefile config.ru ./ +COPY .browserslistrc *.config.js ./ + +# Compile/transpile static assets +# Added SECRET_KEY_BASE=dummysecret as it fixes an error in the assets:precompile job +RUN SECRET_KEY_BASE=dummysecret \ + bundle exec bin/rake assets:precompile + +COPY app ./app + +USER 1001 + +# Production image build +FROM icr.io/skills-network/ruby:3.2.0 as release +USER root +ENV APP_HOME /app + +RUN apk add --no-cache \ + tzdata \ + file \ + libpq \ + bind-tools && \ + rm -rf /var/cache/apk/* +COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ +COPY --from=builder $APP_HOME $APP_HOME + +WORKDIR $APP_HOME +USER 1001 +ENTRYPOINT ["bin/rails"] +CMD ["server", "-b", "0.0.0.0"] + +# Default to `release` +FROM release as monkey-patched +USER root + +ENV APP_HOME /app +ENV RAILS_ENV production + +ENV USER=skillsnetwork +ENV UID=1001 +RUN adduser --disabled-password --gecos --ingroup $USER --no-create-home --uid $UID $USER +RUN chown -R $USER:$USER $APP_HOME + +RUN apk upgrade --update-cache \ + libpq \ + expat \ + bind-libs\ + bind-tools\ + && rm -rf /var/cache/apk/* + +USER 1001 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e15835f --- /dev/null +++ b/Gemfile @@ -0,0 +1,82 @@ +source "https://rubygems.org" +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby "3.2.0" + +# Core +gem "pg", "~> 1" +gem "rails", "~> 7" + +# Views, JavaScript and assets +gem "heroicon", "~> 1" +gem "jbuilder", "~> 2" +gem "simple_form", "~> 5" +gem "sprockets-rails", "~> 3" +gem "tailwindcss-rails", "~> 2" +gem "turbo-rails", "~> 1" +gem "view_component", "~> 2" + +# Use Redis adapter to run Action Cable in production +gem "redis", "~> 4" +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +gem "bcrypt", "~> 3" + +# Authentication and authorization +# Implement Outside of Template + +# Jobs +gem "sidekiq", "~> 7" +gem "sidekiq-scheduler", "~> 5" + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +# gem "image_processing", "~> 1.2" + +# Other +gem "bootsnap", ">= 1", require: false +gem "config", "~> 2" +gem "puma", "~> 5" +gem "tzinfo-data", "~> 1" + +# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "importmap-rails", "~> 1" + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "byebug", "~> 11" + # RSpec for testing + gem "rspec-rails", "~> 5" + # FactoryBot for creating model instances for tests + gem "factory_bot_rails", "~> 6" + # Faker for generating fake data for tests + gem "faker", "~> 2" + # Capybara for integration tests + gem "capybara", "~> 3" +end + +group :development do + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console", "~> 4.2.0" + + # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] + gem "rack-mini-profiler", "~> 3.0.0" + + # Speed up commands on slow machines / big apps [https://github.com/rails/spring] + gem "spring", "~> 4.1.0" + + # Rubocop github flavour + gem "rubocop-github", "~> 0.17.0" + gem "rubocop-performance", require: false + gem "rubocop-rails", require: false + gem "rubocop-rspec", require: false + + # ERB linting + gem "erb_lint", "~> 0.3.1" +end + +group :test do + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + gem "webdrivers" + + # WithModel for temporarily creating ActiveRecord models during tests + gem "with_model", "~> 2.1" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..fdc5483 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,405 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.3) + actionpack (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activesupport (= 7.0.4.3) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.4.3) + actionview (= 7.0.4.3) + activesupport (= 7.0.4.3) + rack (~> 2.0, >= 2.2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.4.3) + actionpack (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.4.3) + activesupport (= 7.0.4.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.3.6) + activemodel (7.0.4.3) + activesupport (= 7.0.4.3) + activerecord (7.0.4.3) + activemodel (= 7.0.4.3) + activesupport (= 7.0.4.3) + activestorage (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activesupport (= 7.0.4.3) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.4.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) + bcrypt (3.1.18) + better_html (2.0.1) + actionview (>= 6.0) + activesupport (>= 6.0) + ast (~> 2.0) + erubi (~> 1.4) + parser (>= 2.4) + smart_properties + bindex (0.8.1) + bootsnap (1.16.0) + msgpack (~> 1.2) + builder (3.2.4) + byebug (11.1.3) + capybara (3.38.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + concurrent-ruby (1.2.2) + config (2.2.3) + deep_merge (~> 1.2, >= 1.2.1) + dry-validation (~> 1.0, >= 1.0.0) + connection_pool (2.4.0) + crass (1.0.6) + date (3.3.3) + deep_merge (1.2.2) + diff-lcs (1.5.0) + dry-configurable (1.0.1) + dry-core (~> 1.0, < 2) + zeitwerk (~> 2.6) + dry-core (1.0.0) + concurrent-ruby (~> 1.0) + zeitwerk (~> 2.6) + dry-inflector (1.0.0) + dry-initializer (3.1.1) + dry-logic (1.5.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0, < 2) + zeitwerk (~> 2.6) + dry-schema (1.13.0) + concurrent-ruby (~> 1.0) + dry-configurable (~> 1.0, >= 1.0.1) + dry-core (~> 1.0, < 2) + dry-initializer (~> 3.0) + dry-logic (>= 1.5, < 2) + dry-types (>= 1.7, < 2) + zeitwerk (~> 2.6) + dry-types (1.7.1) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0) + dry-inflector (~> 1.0) + dry-logic (~> 1.4) + zeitwerk (~> 2.6) + dry-validation (1.10.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0, < 2) + dry-initializer (~> 3.0) + dry-schema (>= 1.12, < 2) + zeitwerk (~> 2.6) + erb_lint (0.3.1) + activesupport + better_html (>= 2.0.1) + parser (>= 2.7.1.4) + rainbow + rubocop + smart_properties + erubi (1.12.0) + et-orbi (1.2.7) + tzinfo + factory_bot (6.2.1) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) + faker (2.23.0) + i18n (>= 1.8.11, < 2) + fugit (1.8.1) + et-orbi (~> 1, >= 1.2.7) + raabro (~> 1.4) + globalid (1.1.0) + activesupport (>= 5.0) + heroicon (1.0.0) + rails (>= 5.2) + i18n (1.12.0) + concurrent-ruby (~> 1.0) + importmap-rails (1.1.5) + actionpack (>= 6.0.0) + railties (>= 6.0.0) + jbuilder (2.11.5) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + json (2.6.3) + loofah (2.19.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + matrix (0.4.2) + method_source (1.0.0) + mini_mime (1.1.2) + minitest (5.18.0) + msgpack (1.6.1) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.8) + nokogiri (1.14.3-arm64-darwin) + racc (~> 1.4) + nokogiri (1.14.3-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.14.3-x86_64-linux) + racc (~> 1.4) + parallel (1.22.1) + parser (3.2.1.1) + ast (~> 2.4.1) + pg (1.4.6) + public_suffix (5.0.1) + puma (5.6.5) + nio4r (~> 2.0) + raabro (1.4.0) + racc (1.6.2) + rack (2.2.6.4) + rack-mini-profiler (3.0.0) + rack (>= 1.2.0) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.4.3) + actioncable (= 7.0.4.3) + actionmailbox (= 7.0.4.3) + actionmailer (= 7.0.4.3) + actionpack (= 7.0.4.3) + actiontext (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activemodel (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + bundler (>= 1.15.0) + railties (= 7.0.4.3) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rainbow (3.1.1) + rake (13.0.6) + redis (4.8.1) + redis-client (0.14.1) + connection_pool + regexp_parser (2.7.0) + rexml (3.2.5) + rspec-core (3.12.1) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-rails (5.1.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.12.0) + rubocop (1.48.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.26.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.27.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.17.1) + rubocop (~> 1.41) + rubocop-github (0.17.0) + rubocop + rubocop-performance + rubocop-rails + rubocop-performance (1.16.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.18.0) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + rubocop-rspec (2.19.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + ruby-progressbar (1.13.0) + rubyzip (2.3.2) + rufus-scheduler (3.8.2) + fugit (~> 1.1, >= 1.1.6) + selenium-webdriver (4.8.1) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + sidekiq (7.1.0) + concurrent-ruby (< 2) + connection_pool (>= 2.3.0) + rack (>= 2.2.4) + redis-client (>= 0.14.0) + sidekiq-scheduler (5.0.2) + rufus-scheduler (~> 3.2) + sidekiq (>= 6, < 8) + tilt (>= 1.4.0) + simple_form (5.2.0) + actionpack (>= 5.2) + activemodel (>= 5.2) + smart_properties (1.17.0) + spring (4.1.1) + sprockets (4.2.0) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + tailwindcss-rails (2.0.25-arm64-darwin) + railties (>= 6.0.0) + tailwindcss-rails (2.0.25-x86_64-darwin) + railties (>= 6.0.0) + tailwindcss-rails (2.0.25-x86_64-linux) + railties (>= 6.0.0) + thor (1.2.1) + tilt (2.1.0) + timeout (0.3.2) + turbo-rails (1.4.0) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + tzinfo-data (1.2022.7) + tzinfo (>= 1.0.0) + unicode-display_width (2.4.2) + view_component (2.82.0) + activesupport (>= 5.2.0, < 8.0) + concurrent-ruby (~> 1.0) + method_source (~> 1.0) + web-console (4.2.0) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + webdrivers (5.2.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0) + websocket (1.2.9) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + with_model (2.1.6) + activerecord (>= 5.2) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.6.7) + +PLATFORMS + arm64-darwin-22 + x86_64-darwin-21 + x86_64-darwin-22 + x86_64-linux + +DEPENDENCIES + bcrypt (~> 3) + bootsnap (>= 1) + byebug (~> 11) + capybara (~> 3) + config (~> 2) + erb_lint (~> 0.3.1) + factory_bot_rails (~> 6) + faker (~> 2) + heroicon (~> 1) + importmap-rails (~> 1) + jbuilder (~> 2) + pg (~> 1) + puma (~> 5) + rack-mini-profiler (~> 3.0.0) + rails (~> 7) + redis (~> 4) + rspec-rails (~> 5) + rubocop-github (~> 0.17.0) + rubocop-performance + rubocop-rails + rubocop-rspec + sidekiq (~> 7) + sidekiq-scheduler (~> 5) + simple_form (~> 5) + spring (~> 4.1.0) + sprockets-rails (~> 3) + tailwindcss-rails (~> 2) + turbo-rails (~> 1) + tzinfo-data (~> 1) + view_component (~> 2) + web-console (~> 4.2.0) + webdrivers + with_model (~> 2.1) + +RUBY VERSION + ruby 3.2.0p0 + +BUNDLED WITH + 2.3.7 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 0000000..dd34f85 --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,3 @@ +web: bin/rails server -p 3000 +css: bin/rails tailwindcss:watch +job: bundle exec sidekiq -q low -q default -q high -q critical diff --git a/README.md b/README.md new file mode 100644 index 0000000..b0456ef --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Rails Template + +## Development + +Following the [prereq of portals](https://github.ibm.com/skills-network/portals/blob/master/docs/developing-native.md#prerequisites). + +### Install dependencies + +Install Ruby dependencies + +```bash +bundle install +``` + +### Setup environment + +```bash +cp .env.development.example .env.development +source .env.development +``` + +## Database + +### Start database + +```bash +docker compose up -d +``` + +This will create appropriate Docker volumes, container(s), and create the template PostgreSQL database. + +### Migration + +This should only be used for a fresh database + +```bash +bin/rails db:schema:load +``` + +Otherwise run the command below instead + +```bash +bin/rails db:migrate +``` + +## Run the dev server + +```bash +rbenv shell 3.1.2 +bin/dev +``` + +Then open http://localhost:3000 + +## Merging + +Prior to merging your branch ensure that it runs `bundle exec rubocop` clean \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..9a5ea73 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative "config/application" + +Rails.application.load_tasks diff --git a/app/assets/builds/.keep b/app/assets/builds/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..b06fc42 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,5 @@ +//= link_tree ../images +//= link_directory ../stylesheets .css +//= link_tree ../../javascript .js +//= link_tree ../../../vendor/javascript .js +//= link_tree ../builds diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..288b9ab --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css new file mode 100644 index 0000000..4a2301a --- /dev/null +++ b/app/assets/stylesheets/application.tailwind.css @@ -0,0 +1,36 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +.tooltip{ + visibility: hidden; + position: absolute; + right: 0%; +} + +.has-tooltip:hover .tooltip { + visibility: visible; + z-index: 100; +} + +.has-tooltip { + position: relative; + border-bottom:1px dashed #000; +} + +.tippy-box[data-theme~='app'] { + @apply bg-purple-600; + color: #FFFFFF; +} +.tippy-box[data-theme~='app'][data-placement^='top'] > .tippy-arrow::before { + @apply border-t-purple-600; +} +.tippy-box[data-theme~='app'][data-placement^='bottom'] > .tippy-arrow::before { + @apply border-b-purple-600; +} +.tippy-box[data-theme~='app'][data-placement^='left'] > .tippy-arrow::before { + @apply border-l-purple-600; +} +.tippy-box[data-theme~='app'][data-placement^='right'] > .tippy-arrow::before { + @apply border-r-purple-600; +} diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/components/alert_component.html.erb b/app/components/alert_component.html.erb new file mode 100644 index 0000000..bd0bfbc --- /dev/null +++ b/app/components/alert_component.html.erb @@ -0,0 +1,34 @@ +
+
+
+
+
+ <%= heroicon @icon[:name], options: { class: "h-5 w-5 text-#{@color}-400", **@icon } %> +
+
+
+

<%= @message %>

+ <%= content %> +
+ <% if action.present? %> +
+
+ <%= action %> +
+
+ <% end %> +
+
+
+ +
+
+
+
+
diff --git a/app/components/alert_component.rb b/app/components/alert_component.rb new file mode 100644 index 0000000..f502994 --- /dev/null +++ b/app/components/alert_component.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +class AlertComponent < BaseComponent + include ViewComponent::SlotableV2 + include HeroiconHelper + + DEFAULT_VARIANT = :notice + VARIANT_MAPPINGS = { + DEFAULT_VARIANT => "purple", + :info => "purple", + :warning => "yellow", + :alert => "red", + :danger => "red", + :success => "green" + }.freeze + VARIANT_OPTIONS = VARIANT_MAPPINGS.keys + + ICON_VARIANT_MAPPINGS = { + DEFAULT_VARIANT => { name: :"information-circle", variant: :solid }, + :info => { name: :"information-circle", variant: :solid }, + :warning => { name: :exclamation, variant: :solid }, + :alert => { name: :"x-circle", variant: :solid }, + :danger => { name: :"x-circle", variant: :solid }, + :success => { name: :"check-circle", variant: :solid } + }.freeze + + renders_one :action, "ActionComponent" + + def initialize(message: "", variant: DEFAULT_VARIANT) + @message = message + @color = VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)] + @icon = ICON_VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)] + end + + class ActionComponent < BaseComponent + DEFAULT_TAG = :a + TAG_OPTIONS = [DEFAULT_TAG, :a, :summary].freeze + + def initialize(variant: AlertComponent::DEFAULT_VARIANT, tag: DEFAULT_TAG, **system_arguments) + @system_arguments = system_arguments + @system_arguments[:tag] = tag || DEFAULT_TAG + + color = VARIANT_MAPPINGS[fetch_or_fallback(AlertComponent::VARIANT_OPTIONS, variant, AlertComponent::DEFAULT_VARIANT)] + @system_arguments[:classes] = "bg-#{color}-50 px-2 py-1.5 rounded-md text-sm font-semibold text-#{color}-800 hover:bg-#{color}-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-#{color}-50 focus:ring-#{color}-600" + end + + def call + render(BaseComponent.new(**@system_arguments)) { content } + end + end +end diff --git a/app/components/base_component.rb b/app/components/base_component.rb new file mode 100644 index 0000000..e94fb58 --- /dev/null +++ b/app/components/base_component.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class BaseComponent < ViewComponent::Base + include ClassNameHelper + include FetchOrFallbackHelper + + def initialize(tag:, classes: nil, **system_arguments) + @tag = tag + @system_arguments = system_arguments + + # TODO + # Implement a more native way of adding custom CSS class instead of stupid string concat + # Similar to the Claasifier Primer build + # https://github.com/primer/view_components/blob/41b277aa047ba7d1a669a48dc392115bf4948435/app/components/primer/base_component.rb + @system_arguments[:class] = class_names( + system_arguments[:class], + classes + ) + end + + def call + content_tag(@tag, content, **@system_arguments) + end +end diff --git a/app/components/nav_menu_badge_component.html.erb b/app/components/nav_menu_badge_component.html.erb new file mode 100644 index 0000000..8c5c198 --- /dev/null +++ b/app/components/nav_menu_badge_component.html.erb @@ -0,0 +1,5 @@ +<% if @type == TYPE_DOT %> +
+<% elsif @type == TYPE_NUMBER %> +
<%= @rendered_count %>
+<% end %> diff --git a/app/components/nav_menu_badge_component.rb b/app/components/nav_menu_badge_component.rb new file mode 100644 index 0000000..717ed03 --- /dev/null +++ b/app/components/nav_menu_badge_component.rb @@ -0,0 +1,21 @@ +# Badge component for the navigation menu +class NavMenuBadgeComponent < ViewComponent::Base + TYPE_NO_RENDER = 0 + TYPE_DOT = 1 + TYPE_NUMBER = 2 + + # @param count [Boolean,Integer] Defines how the badge is rendered, when `true` will render a dot, `false` will not render, integers render the count (where count > max becomes "9+") + # @param max [Integer] The maximum badge count + def initialize(count: false, max: 9) + @type = case count + when false, 0 + TYPE_NO_RENDER + when true + TYPE_DOT + else + TYPE_NUMBER + end + + @rendered_count = ((count > max) ? "#{max}+" : count) if @type == TYPE_NUMBER + end +end diff --git a/app/components/nav_menu_item_component.html.erb b/app/components/nav_menu_item_component.html.erb new file mode 100644 index 0000000..0a24a75 --- /dev/null +++ b/app/components/nav_menu_item_component.html.erb @@ -0,0 +1,14 @@ + +
+ <%= link_to @link, class: "#{@active ? "bg-purple-50 border-purple-600 text-purple-600" : "border-transparent text-gray-600 hover:text-gray-900 hover:bg-gray-50"} group border-l-4 py-2 px-3 flex items-center text-sm font-medium" do %> + + <%= heroicon @icon, options: { class: "mr-3 h-6 w-6 #{@active ? "text-purple-500" : "text-gray-400 group-hover:text-gray-500"}" } %> + <%= @title %> + <%= render NavMenuBadgeComponent.new(count: @badge) %> + <% end %> + <% if @active %> + <% children.each do |child| %> + <%= child %> + <% end %> + <% end %> +
diff --git a/app/components/nav_menu_item_component.rb b/app/components/nav_menu_item_component.rb new file mode 100644 index 0000000..ea8a602 --- /dev/null +++ b/app/components/nav_menu_item_component.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class NavMenuItemComponent < ViewComponent::Base + include HeroiconHelper + + renders_many :children, NavMenuSubitemComponent + + def initialize(title:, link:, icon:, active:, badge: false) + @title = title + @link = link + @icon = icon + @active = active + @badge = badge + end +end diff --git a/app/components/nav_menu_subitem_component.html.erb b/app/components/nav_menu_subitem_component.html.erb new file mode 100644 index 0000000..64f6303 --- /dev/null +++ b/app/components/nav_menu_subitem_component.html.erb @@ -0,0 +1,4 @@ +<%= link_to @link, class: "#{@active ? "bg-purple-50 text-purple-600" : "text-gray-600 hover:text-gray-900 hover:bg-gray-50"} border-purple-600 group border-l-4 py-2 px-3 pl-7 flex items-center text-sm font-medium" do %> + <%= @title %> + <%= render NavMenuBadgeComponent.new(count: @badge) %> +<% end %> diff --git a/app/components/nav_menu_subitem_component.rb b/app/components/nav_menu_subitem_component.rb new file mode 100644 index 0000000..88c785c --- /dev/null +++ b/app/components/nav_menu_subitem_component.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class NavMenuSubitemComponent < ViewComponent::Base + include HeroiconHelper + + def initialize(title:, link:, icon:, active:, badge: false) + @title = title + @link = link + @icon = icon + @active = active + @badge = badge + end +end diff --git a/app/components/page_heading_component.html.erb b/app/components/page_heading_component.html.erb new file mode 100644 index 0000000..cf8b210 --- /dev/null +++ b/app/components/page_heading_component.html.erb @@ -0,0 +1,22 @@ +
+
+
+ <% if @title.present? %> +

+ <%= @title %> +

+ <%= title_extra %> + <% elsif title_alternative %> + <%= title_alternative %> + <% end %> +
+ <% if description %> +

+ <%= description %> +

+ <% end %> +
+
+ <%= extra %> +
+
diff --git a/app/components/page_heading_component.rb b/app/components/page_heading_component.rb new file mode 100644 index 0000000..eb8aee9 --- /dev/null +++ b/app/components/page_heading_component.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class PageHeadingComponent < ViewComponent::Base + renders_one :extra + renders_one :title_extra + renders_one :title_alternative + renders_one :description + + def initialize(title: nil) + @title = title + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..e7bebf8 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,5 @@ +class HomeController < ApplicationController + layout "shell" + + def index; end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..e9ed4c8 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,3 @@ +module ApplicationHelper + def comment; end +end diff --git a/app/helpers/class_name_helper.rb b/app/helpers/class_name_helper.rb new file mode 100644 index 0000000..5ea9aac --- /dev/null +++ b/app/helpers/class_name_helper.rb @@ -0,0 +1,19 @@ +# https://github.com/primer/view_components/blob/main/lib/primer/class_name_helper.rb +module ClassNameHelper + def class_names(*args) + classes = [] + + args.each do |class_name| + case class_name + when String + classes << class_name if class_name.present? + when Hash + class_name.each { |key, val| classes << key if val } + when Array + classes << class_names(*class_name).presence + end + end + + classes.compact.uniq.join(" ") + end +end diff --git a/app/helpers/fetch_or_fallback_helper.rb b/app/helpers/fetch_or_fallback_helper.rb new file mode 100644 index 0000000..1cddf93 --- /dev/null +++ b/app/helpers/fetch_or_fallback_helper.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +# https://github.com/primer/view_components/blob/main/lib/primer/fetch_or_fallback_helper.rb +# A little helper to enable graceful fallbacks +# +# Use this helper to quietly ensure a value is +# one that you expect: +# +# allowed_values - allowed options for *value* +# given_value - input being coerced +# fallback - returned if *given_value* is not included in *allowed_values* +# +# fetch_or_fallback([1,2,3], 5, 2) => 2 +# fetch_or_fallback([1,2,3], 1, 2) => 1 +# fetch_or_fallback([1,2,3], nil, 2) => 2 + +module FetchOrFallbackHelper + mattr_accessor :fallback_raises, default: true + + InvalidValueError = Class.new(StandardError) + + def fetch_or_fallback(allowed_values, given_value, fallback = nil) + if allowed_values.include?(given_value) + given_value + else + if fallback_raises && ENV["RAILS_ENV"] != "production" && + ENV["STORYBOOK"] != "true" + raise InvalidValueError, <<~MSG + fetch_or_fallback was called with an invalid value. + + Expected one of: #{allowed_values.inspect} + Got: #{given_value.inspect} + + This will not raise in production, but will instead fallback to: #{fallback.inspect} + MSG + end + + fallback + end + end + + def fetch_or_fallback_boolean(given_value, fallback: false) + [true, false].include?(given_value) ? given_value : fallback + end +end diff --git a/app/helpers/heroicon_helper.rb b/app/helpers/heroicon_helper.rb new file mode 100644 index 0000000..d224271 --- /dev/null +++ b/app/helpers/heroicon_helper.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module HeroiconHelper + include Heroicon::Engine.helpers +end diff --git a/app/inputs/custom_inputs/base_input.rb b/app/inputs/custom_inputs/base_input.rb new file mode 100644 index 0000000..62fad39 --- /dev/null +++ b/app/inputs/custom_inputs/base_input.rb @@ -0,0 +1,7 @@ +module CustomInputs + class BaseInput < SimpleForm::Inputs::StringInput + def hint(wrapper_options = nil) + super unless has_errors? + end + end +end diff --git a/app/javascript/application.js b/app/javascript/application.js new file mode 100644 index 0000000..3976c03 --- /dev/null +++ b/app/javascript/application.js @@ -0,0 +1,11 @@ +// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails +import "@hotwired/turbo" +import "@hotwired/turbo-rails" +import "alpine-turbo-drive-adapter" +import "alpinejs" +import "@alpinejs/persist" +import "@alpinejs/collapse" +import "@rails/actioncable/src" +import "@rails/actioncable" +import "@rails/actiontext" +import "stimulus" diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000..d394c3d --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +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 +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000..3c34c81 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout "mailer" +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000..b63caeb --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..5b92b4f --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,7 @@ +<%= content_for :page_title do %> + <%= t(".page_title") %> +<% end %> + +<%= content_for :title do %> + <%= render PageHeadingComponent.new(title: t(".title")) %> +<% end %> diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 0000000..757891d --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,12 @@ +<% flash.each do |type, message| %> + <% case message %> +<% when String %> + <%= render(AlertComponent.new(message: sanitize(message), variant: type.to_sym)) %> + <% when Hash %> + <%= render(AlertComponent.new(message: message["message"], variant: type.to_sym)) do |component| %> + <%= component.action(variant: type.to_sym, **message["action"]["options"].symbolize_keys) do %> + <%= message["action"]["text"] %> + <% end %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..fff9b81 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,19 @@ + + + + <%= content_for?(:page_title) ? yield(:page_title) : "Rails Template" %> + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> + + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> + + + +
+ <%= yield %> +
+ + diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/layouts/shell.html.erb b/app/views/layouts/shell.html.erb new file mode 100644 index 0000000..df1342e --- /dev/null +++ b/app/views/layouts/shell.html.erb @@ -0,0 +1,86 @@ + + + + <%= content_for?(:page_title) ? yield(:page_title) : "Rails Template" %> + + + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> + + + +
+ +
+
+ +
+
+ + +
+
+
+
+ +
+
+ +
+ <%= turbo_frame_tag :flash do %> + <%= render "layouts/flash" %> + <% end %> + +
+ <%= yield :title %> + +
+ <%= yield %> +
+
+
+
+ + diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..5d58263 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,116 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "rubygems" + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) + end + + def env_var_version + ENV["BUNDLER_VERSION"] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + + bundler_version = Regexp.last_match(1) + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile.present? + + File.expand_path("../Gemfile", __dir__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + + Regexp.last_match(1) + end + + def bundler_requirement + @bundler_requirement ||= + env_var_version || cli_arg_version || + bundler_requirement_for(lockfile_version) + end + + def bundler_requirement_for(version) + return "#{Gem::Requirement.default}.a" unless version + + bundler_gem_version = Gem::Version.new(version) + + requirement = bundler_gem_version.approximate_recommendation + + return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0") + + requirement += ".a" if bundler_gem_version.prerelease? + + requirement + end + + def load_bundler! + ENV["BUNDLE_GEMFILE"] ||= gemfile + + activate_bundler + end + + def activate_bundler + gem_error = activation_error_handling do + gem "bundler", bundler_requirement + end + return if gem_error.nil? + + require_error = activation_error_handling do + require "bundler/version" + end + return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +load Gem.bin_path("bundler", "bundle") if m.invoked_as_script? diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..74ade16 --- /dev/null +++ b/bin/dev @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +if ! gem list foreman -i --silent; then + echo "Installing foreman..." + gem install foreman +fi + +exec foreman start -f Procfile.dev "$@" diff --git a/bin/importmap b/bin/importmap new file mode 100755 index 0000000..36502ab --- /dev/null +++ b/bin/importmap @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require_relative "../config/application" +require "importmap/commands" diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..efc0377 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..4fbf10b --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..ec47b79 --- /dev/null +++ b/bin/setup @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require "fileutils" + +# path to your application root. +APP_ROOT = File.expand_path("..", __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. + # Add necessary setup steps to this file. + + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # end + + puts "\n== Preparing database ==" + system! "bin/rails db:prepare" + + puts "\n== Removing old logs and tempfiles ==" + system! "bin/rails log:clear tmp:clear" + + puts "\n== Restarting application server ==" + system! "bin/rails restart" +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..4a3c09a --- /dev/null +++ b/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..5293a4d --- /dev/null +++ b/config/application.rb @@ -0,0 +1,22 @@ +require_relative "boot" + +require "rails/all" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module RailsAppTemplate + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.0 + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000..988a5dd --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,4 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000..85ad8b7 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: rails_app_template_production diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000..7f7d3e0 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +AwnbHlhU9IEGxSlfqdtMcqGVZiVZZqpa99jrFVz3ALv5db0ImaqFK0ebdKZngmTwbdCSVSVNPxYJQstWX9pGlMmxZvQFH+7jduD/mYFSM4ZfvXF4KFuw3x6VLRackqa541yzj1cBp2wBixQkS9nDLXlM2RUxgFT3q20kMAhP0QiIuCbFMAc3h11NjblByNnJmZ+aqCoFLadO38VIOf3x9UO/LYZAq9Hvk8dJWQfadJzMdCccEMlJDfdiZ5T5WZNpsVQVDLEyQ54Ho/pBncQ5y5ynnUP5n1Gx0VYR4urlGFiOlhTv5X9eH6d1RxemLkmziqFQOZZDF23G1BIOR62uL2mVslphxX0aTQLVoDirQzhSkb0CxBFPbRec0LpriSd4G9gyvuCuLuoKZX7XmqoLynPHsOjypbdh37Vu--HB1C9gUy6Yojoa2Q--I45AxyP+LNttSMteNPZLZA== \ No newline at end of file diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000..4d31d02 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,86 @@ +# PostgreSQL. Versions 9.3 and up are supported. +# +# Install the pg driver: +# gem install pg +# On macOS with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On macOS with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem "pg" +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # https://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + url: <%= ENV["DATABASE_URL"] || "postgresql://postgres:password@localhost:5432/template_development?schema=public&connection_limit=5" %> + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user running Rails. + #username: rails_app_template + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + url: <%= ENV["DATABASE_URL"] || "postgresql://postgres:password@localhost:5432/rails_app_template_test?schema=public&connection_limit=5" %> + +# As with config/credentials.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password or a full connection URL as an environment +# variable when you boot the app. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# If the connection URL is provided in the special DATABASE_URL environment +# variable, Rails will automatically merge its configuration values on top of +# the values provided in this file. Alternatively, you can specify a connection +# URL environment variable explicitly: +# +# production: +# url: <%= ENV["MY_APP_DATABASE_URL"] %> +# +# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full overview on how database connection configuration can be specified. +# +production: + <<: *default + database: rails_app_template_production + username: rails_app_template + password: <%= ENV["RAILS_APP_TEMPLATE_DATABASE_PASSWORD"] %> diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..cac5315 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000..93a3cef --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,75 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing + config.server_timing = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000..6210f4e --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,93 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info + + # Prepend all log lines with the following tags. + config.log_tags = [:request_id] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "rails_app_template_production" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new($stdout) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000..6ea4d1e --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,60 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Turn false under Spring and add config.action_view.cache_template_loading = true. + config.cache_classes = true + + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + "Cache-Control" => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true +end diff --git a/config/importmap.rb b/config/importmap.rb new file mode 100644 index 0000000..af3995a --- /dev/null +++ b/config/importmap.rb @@ -0,0 +1,14 @@ +# Pin npm packages by running ./bin/importmap + +pin "application", preload: true +pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true +pin_all_from "app/javascript/controllers", under: "controllers" +pin "alpinejs", to: "https://unpkg.com/alpinejs@3.10.5/dist/cdn.min.js" +pin "@alpinejs/persist", to: "https://unpkg.com/@alpinejs/persist@3.10.5/dist/cdn.min.js" +pin "@alpinejs/collapse", to: "https://unpkg.com/@alpinejs/collapse@3.10.5/dist/cdn.min.js" +pin "alpine-turbo-drive-adapter", to: "https://cdn.jsdelivr.net/npm/alpine-turbo-drive-adapter@2.0.x/dist/alpine-turbo-drive-adapter.min.js" +pin "@hotwired/turbo", to: "https://ga.jspm.io/npm:@hotwired/turbo@7.2.4/dist/turbo.es2017-esm.js" +pin "@rails/actioncable/src", to: "https://ga.jspm.io/npm:@rails/actioncable@7.0.4/src/index.js" +pin "@rails/actioncable", to: "https://ga.jspm.io/npm:@rails/actioncable@7.0.4/app/assets/javascripts/actioncable.esm.js" +pin "@rails/actiontext", to: "https://ga.jspm.io/npm:@rails/actiontext@7.0.4/app/assets/javascripts/actiontext.js" +pin "stimulus", to: "https://ga.jspm.io/npm:stimulus@3.1.1/dist/stimulus.js" diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..2eeef96 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,12 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = "1.0" + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/config.rb b/config/initializers/config.rb new file mode 100644 index 0000000..74341d0 --- /dev/null +++ b/config/initializers/config.rb @@ -0,0 +1,54 @@ +Config.setup do |config| + # Name of the constant exposing loaded settings + config.const_name = "Settings" + + # Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'. + # + # config.knockout_prefix = nil + + # Overwrite an existing value when merging a `nil` value. + # When set to `false`, the existing value is retained after merge. + # + # config.merge_nil_values = true + + # Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged. + # + # config.overwrite_arrays = true + + # Load environment variables from the `ENV` object and override any settings defined in files. + # + config.use_env = true + + # Define ENV variable prefix deciding which variables to load into config. + # + # Reading variables from ENV is case-sensitive. If you define lowercase value below, ensure your ENV variables are + # prefixed in the same way. + # + # When not set it defaults to `config.const_name`. + # + config.env_prefix = "SETTINGS" + + # What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well + # with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where + # using dots in variable names might not be allowed (eg. Bash). + # + config.env_separator = "_" + + # Ability to process variables names: + # * nil - no change + # * :downcase - convert to lower case + # + config.env_converter = :downcase + + # Parse numeric values as integers instead of strings. + # + # config.env_parse_values = true + + # Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details. + # + # config.schema do + # required(:name).filled + # required(:age).maybe(:int?) + # required(:email).filled(format?: EMAIL_REGEX) + # end +end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..54f47cf --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..166997c --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. +Rails.application.config.filter_parameters += %i[ + passw secret token _key crypt salt certificate otp ssn +] diff --git a/config/initializers/heroicon.rb b/config/initializers/heroicon.rb new file mode 100644 index 0000000..8901e85 --- /dev/null +++ b/config/initializers/heroicon.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Heroicon.configure do |config| + config.variant = :solid # Options are :solid and :outline +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000..3860f65 --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb new file mode 100644 index 0000000..00f64d7 --- /dev/null +++ b/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 0000000..fb770ba --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +redis_url = ENV.fetch("REDIS_URL", "redis://localhost:6379").strip +redis_network_timeout = ENV.fetch("REDIS_NETWORK_TIMEOUT", "15").strip.to_i + +Sidekiq.configure_server do |config| + config.redis = { url: redis_url, network_timeout: redis_network_timeout } + config.average_scheduled_poll_interval = 5 + config.logger.level = Logger::INFO +end + +Sidekiq.configure_client do |config| + config.redis = { url: redis_url, network_timeout: redis_network_timeout } +end + +# Perform Sidekiq jobs immediately in development, +# so you don't have to run a separate process. +# You'll also benefit from code reloading. +if Rails.env.development? && Rails.root.join("config/sidekiq.yml").exist? + # Add https://github.com/ibm-skills-network/portals/blob/master/glados/config/sidekiq.yml to repo for scheduling sidekiq jobs + require "sidekiq/testing" + Sidekiq::Testing.inline! + # Start sidekiq scheduler + if defined?(Rails::Server) + schedule_yaml = ERB.new(File.read(Rails.root.join("config/sidekiq.yml"))).result + Sidekiq.schedule = YAML.safe_load(schedule_yaml, permitted_classes: [Symbol])[:schedule] + SidekiqScheduler::Scheduler.enabled = true + SidekiqScheduler::Scheduler.instance.reload_schedule! + end +end diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 0000000..9b97358 --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true + +# +# Uncomment this and change the path if necessary to include your own +# components. +# See https://github.com/heartcombo/simple_form#custom-components to know +# more about custom components. +Dir[Rails.root.join("lib/components/**/*.rb")].each { |f| require f } +# +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, class: :input, + hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input placeholder: "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => true` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + # and/or database column lengths + b.optional :maxlength + + # Calculate minlength from length validations for string inputs + b.optional :minlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + # b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid' + b.use :label_input + b.use :hint, wrap_with: { tag: :span, class: :hint } + b.use :error, wrap_with: { tag: :span, class: :error } + + ## full_messages_for + # If you want to display the full error message for the attribute, you can + # use the component :full_error, like: + # + # b.use :full_error, wrap_with: { tag: :span, class: :error } + end + + config.wrappers :stacked_form, tag: :div, class: "" do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :minlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + + b.use :label, class: "block text-sm font-medium text-gray-700" + b.use :input, + class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md disabled:opacity-50 disabled:cursor-not-allowed", + valid_class: "", + error_class: "border-red-300 text-red-900 placeholder-red-300 focus:outline-none focus:ring-red-500 focus:border-red-500", + wrap_with: { tag: "div", class: "mt-1" } + b.use :hint, wrap_with: { tag: :p, class: "mt-2 text-sm text-gray-500" } + b.use :error, wrap_with: { tag: :p, class: "mt-2 text-sm text-red-600" } + end + + config.wrappers :stacked_boolean, tag: :div, class: "flex items-center" do |b| + b.use :html5 + b.optional :readonly + b.use :input, class: "focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded", type: "radio" + b.use :label, class: "ml-3 block text-sm font-medium text-gray-700" + end + + config.wrappers :stacked_boolean_with_hint, tag: :div, class: "relative flex items-center" do |b| + b.use :html5 + b.optional :readonly + b.wrapper tag: :div, class: "flex items-center h-5" do |c| + c.use :input, class: "focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" + end + b.wrapper tag: :div, class: "ml-3 text-sm" do |c| + c.use :label, class: "font-medium text-gray-700" + c.use :hint, wrap_with: { tag: :p, class: "text-gray-500" } + end + end + + config.wrappers :stacked_textarea, tag: :div, class: "" do |b| + b.use :html5 + b.use :label, class: "block text-sm font-medium text-gray-700" + b.wrapper tag: :div, class: "mt-1" do |bb| + bb.use :input, class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" + end + b.use :hint, wrap_with: { tag: :p, class: "mt-2 text-sm text-gray-500" } + end + + config.wrappers :stacked_rich_text_area, tag: :div, class: "" do |b| + b.use :html5 + b.use :label, class: "block text-sm font-medium text-gray-700" + b.wrapper tag: :div, class: "mt-1" do |bb| + bb.use :input, class: "prose prose-sm max-w-none shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block border-gray-300 rounded-md h-96 overflow-y-auto" + end + b.use :hint, wrap_with: { tag: :p, class: "mt-2 text-sm text-gray-500" } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :stacked_form # :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # inline: input + label + # nested: label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = "btn" + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = "error_notification" + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + config.label_text = ->(label, required, _explicit_label) { "#{required} #{label}" } + # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } + # NOTE: + # Using `*` to indicate whether a field is required or not is bad practice + # config.label_text = ->(label, _required, _explicit_label) { label.to_s } + + # You can define the class to use on all labels. Default is nil. + # config.label_class = nil + + # You can define the default class to be used on forms. Can be overriden + # with `html: { :class }`. Defaulting to none. + # config.default_form_class = nil + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use the native HTML5 validations (novalidate form option). + # These validations are enabled in SimpleForm's internal config but disabled by default + # in this configuration, which is recommended due to some quirks from different browsers. + # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, + # change this configuration to true. + config.browser_validations = true + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + config.wrapper_mappings = { + boolean: :stacked_boolean, + text: :stacked_textarea, + rich_text_area: :stacked_rich_text_area + } + + # Namespaces where SimpleForm should look for custom input classes that + # override default inputs. + config.custom_inputs_namespaces << "CustomInputs" + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = true + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? + + # Default class for inputs + # config.input_class = nil + + # Define the default class of the input wrapper of the boolean input. + config.boolean_label_class = "checkbox" + + # Defines if the default input wrapper class should be included in radio + # collection wrappers. + # config.include_default_input_wrapper_class = true + + # Defines which i18n scope will be used in Simple Form. + # config.i18n_scope = 'simple_form' + + # Defines validation classes to the input_field. By default it's nil. + # config.input_field_valid_class = 'border-green-400' + # config.input_field_error_class = 'border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500' +end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..8ca56fc --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t "hello" +# +# In views, this is aliased to just `t`: +# +# <%= t("hello") %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# "true": "foo" +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/locales/views/home.en.yml b/config/locales/views/home.en.yml new file mode 100644 index 0000000..61a3965 --- /dev/null +++ b/config/locales/views/home.en.yml @@ -0,0 +1,6 @@ +en: + home: + index: + page_title: "Home Page" + title: "Home Page" + diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..ce4878f --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,43 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT", 3000) + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..a512f40 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,6 @@ +Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Defines the root path route ("/") + root "home#index" +end diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000..4942ab6 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket-<%= Rails.env %> + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket-<%= Rails.env %> + +# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/config/tailwind.config.js b/config/tailwind.config.js new file mode 100644 index 0000000..563e7bb --- /dev/null +++ b/config/tailwind.config.js @@ -0,0 +1,41 @@ +const defaultTheme = require("tailwindcss/defaultTheme"); + +module.exports = { + content: [ + "./app/views/**/*.erb", + "./app/components/**/*.erb", + "./app/inputs/custom_inputs/**/*.rb", + ], + safelist: [ + { pattern: /^bg-(.*)-(50|400)$/ }, + { pattern: /^text-(.*)-(400|500|600|700|800)$/ }, + { pattern: /^ring-offset-(.*)-50$/, variants: ["focus"] }, + { pattern: /^ring-(.*)-600$/, variants: ["focus"] }, + { pattern: /^bg-(.*)-100$/, variants: ["hover"] }, + { pattern: /^col-span-(.*)$/, variants: ["sm"] }, + { pattern: /^row-span-(.*)$/, variants: ["sm"] }, + { pattern: /^line-clamp-(.*)$/ }, + { pattern: /^border-(.*)-600$/, variants: ["focus", "focus-within"] }, + { pattern: /^text-(.*)-600$/, variants: ["hover"] }, + { pattern: /^ring-offset-(.*)-50$/ }, + { pattern: /^ring-offset-(.*)-100$/, variants: ["focus"] }, + { pattern: /^ring-(.*)-500$/, variants: ["focus"] }, + { pattern: /^border-(indigo|red)-(500|600)$/ }, + "shadow-red-500", + "hover:border-red-600", + "shadow-input-glow" + ], + darkMode: "media", + variants: { + extend: { + opacity: ["disabled"], + cursor: ["disabled"] + }, + }, + plugins: [ + require("@tailwindcss/aspect-ratio"), + require("@tailwindcss/forms"), + require("@tailwindcss/typography"), + require("@tailwindcss/line-clamp"), + ], +}; diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..b783f98 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,17 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.0].define(version: 0) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..bc25fce --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) +# Character.create(name: "Luke", movie: movies.first) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..31bfafa --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" +services: + redis: + image: library/redis:7-alpine + ports: + - 6379:6379 + + postgres: + image: postgres:14-alpine + ports: + - 5432:5432 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: template_development diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/public/SN_lightMode_railsTemplate.svg b/public/SN_lightMode_railsTemplate.svg new file mode 100644 index 0000000..6091624 --- /dev/null +++ b/public/SN_lightMode_railsTemplate.svg @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..47a116de1b14104eb8a5aaad8456d0f33f5e4bb6 GIT binary patch literal 15406 zcmeI3d7MYwU>K)v{hV4 z6pVn0;+BtQk!%VwfErOCEYm%}z;yQv!#*oJxFqI%-uvA5{Z)5OF5>_rN&ZWJJ~dUh z>QvRKQ|FvIbxuuQ-Vu36=ACp>9{Iq$aeedhF3Zcy8#plg{gspR@}8&el1p;!=jG)s zJtZ&iE5Oi&9@%=bUj4k4&F6c`%>7X8ZQ}ZdWHg&(3 zOpWt4Z91lNXyvIbf#`QyhekhBe{JP)UUM_;4L@eQ2fc-xj`5GMFjsbpg^=&J33tNItiI?Xc zp|_LXs0(V?%(7DZ9-h3wWO)~Y%8(42@oaSvSjFqU){`~!IU28CUXIp`L zC3B8uJ(tk;esAg0V})NlFWx5-iCh~Fhp!X-jFO7NrzTX~uCnmx2s%Ry9>M6;?3z=P zMB9!)^c2P|7hE(Ny(tn3O=>E3hPdI%sZO}!3DS`HcZ4Rj6~t~94EfzV1McVSzO)xa zzui`tU8maTjgDTiHRw)#Wn5)`G*o&^EL=7v7O5PpHvQW3-9cM`H+#z-Z_N)6vi+;8 z%1654iU%8S4)u3K6(jT=3XSgXhRg1+j+BqK{RMA%Lwns?;FPJ&sVedSmL(+v_U1n@Yk$aiO%|c}V#=@m{SBJ{(@z=Elojc&I ztC)8reDrm-W$Dmxc1xi%yfqlR%i?h#c*G;618slxZ3{+6c`F;wfY%?k^;zDACzB0l zi${fDTQFAAQ4ky4Q5gMBTY+r=sKw!DA2feac%=e~umJljeqxHCJtVH*-GWCDweQ zw__Mxm`G0spWTKp;Gy336`Z$p_2-y(8Ebj7`@9^+T|tJnsclp-?^GIZ$tBtl255!KkSApNmpgR{_%J5sK}(nqodRRQIjpT z6h!~Kg)_$1dx5}_@X(s}!ssoksRCZY`R6Z*fE`KQ&DgBrFLSm{hmJ#SJ^Wb2*zeeHcx|4yB2`5GIJCc4 z_02=#C$LxVZ@Q&aCaU>i_uS09kAlNPBx4JyfqCzWMatu`NLhswsf=c!^YWIA4vlFq zbe?DrI<9OwTfb>!{1|ZCyFCy;U3KhvDd}0}f1BL!IQw}WcrUSiY|i|Jp-|{{Cmenw zGdwzNU9t0|8w$S#4W0&%XTfW}8!4Yg`AKZ5h0R6L5v_&p?Xvsq7|NM{Zfl{FudzLgMkJ zm(`GFLxX2}>Z>~0?dfYvg=n4(s!81xqNR zRvsrFkC&Bw8u(X9uSa|~s>b7uvanr-BZrmzYY()hRpw-d)3Fz27e#! zCne0k%-(;Y_kGOwqJ`1@1RmJ!txOwv=_rVB-;Ql-%a3*Gbqi~A^xco(?<(=Wc)-?o z&szi0E0}vndoX5noOBIy?X)sy;o*fiG^xQ3Izn}=g|TbYPkU-%{CR*gjrE7&^H@9{ z_?T^E#>mdSt*szx?#HTQuU}#QC;VfXdgE)zBxvtCOAJ2+v0s92L^f6TJ_q{Nev2Q4 z|Ne8Q$3y$Hx1j#Gp8DqYq1CHx9A(?L42yh$GvjT>O6xpp|3SQ;ZR?(U*bJS>H*&TL zJ-(Fl-sm;Kan=T)Z>P69b6)p;{%=oykJ@xAdNFMIMeW$WH!<#;@WnoC!};Lz)3$s! z1aDPQKN%X$g=hCteiuK&kF2euzKq4XnY%9Y4SgT#Cq4we4m{@Q4&jHFe8Ee@Bp*8G z!Q*G#z3=5r3fQyV!ej5B#@w%vQo2{z`rhQmE|VWZ=VK!MsP06)=_eSke*LLAe&&45 zU|SykeN^`*#`py|=$`u~a$5m?26^@Ps*=fmy7Qa+TC(9P+GW$!koLjHFL;T@FZUMb zL&14Vmh@-L{2VSTyxPn*=J`A6f52%wdzFOFGbtB&$qgqSYP|onXDJ{7y@WK9^sn%f zFwDn((y88(#{NdXtjt{Dt!OA`FJEHMbjM#$>dYo=(L|cPP5*{Gf&DZ2dg=tb zksKX>y-}OGfHC*8$^TvG8^4fzFiAt-56PRs_aXG_Rq{!jb5L}Z{V@waxBPf2FJFFw zw{qnvSsmDP8FF?neN(LGucXbS>B#+ne+S;u+1{#ECqbv-%-hOYwTJoMp*+m*SO27Q zL-V7!Z(q+I%x6D#k#>^qGXAsNdH+er>IIKRwV!=fCV-ow?>d$-SO( zBj@0}mO$CDnp5_>?ARTnC-?6O2kB?%A0**7#V^Kw_XO9QI`+1&;g=-#V+ieimiS4=pA>Xw=4^xyv5z{iuQq^tit>l7rP10pn**_PsNV?e2lRVcc35}cqQ>`X zo4&~!lFYl0JsGdqiGSYSl(~Bq!z(SUVV<{i%|-q`!lwlv2DJSnX&3mc1+N+S@JF>4 z5=-G8x@mCy80?W+KmMKY6YxRoHrXe2q}{TQ6o=YD{KP+pd|pP6W%vDVzun}A>#6J| znuf6c-3IrZ?QY@rKy&bYT62SQYkRPIYd z7k|ZbJ?*`J%md-?hiM4JkH>bM!nnIgsn#Or5-%|8NDE`^tlD&fv!flm>08}-*up6{ z@{`E?8oueouD-^$33vJLpm_snQ)|9^dr$PX@HX!a{(@xZ!@U)pE?wBmJ5O)%7ap_Fx4H{5Pnv$n zzhh!;7DuDA6Y2L@L#eIv=icHiCmVT9ayLk&y5bGucinjyce8N!_c>Jgli+X1+8hko zHDvtv4r43HR!OAycx%_5W#N^J)|`QlpsP4n8-8SIFTKs(?ib*(SAN6Z(%p`IIQWZK zi60I{N9=^3UQt}fj>o;}`{2I=JZEy|b=`aAGl%xFs}}k1G|1Brp}pkl`QGrmoyX>f zgTMNEW1l{%y|DTb_Wb>vuh*PAxfuGZtby~b`D+GNv`?h&Bw>rC0(Nfsyf|Zi4-MM% zCc)M#$H#cI<2VE4cT?HlX3O!xgZnlYISEoz%>n#oNqkA-5&6FSetnIR-Fwb&-K`7b zT{4Rt4@}|N#dkgipVe&q*R#p*l)`H9`<@P8+|8Rc z>qySEgt3wEb9rmmpG7$X{*!G##?e`>-CNSU(^D{=KU}`@E1d$Ijx0}YxEXCzKbnIkuUgR6uad7Tc-8->%p~*#Cf1I z8e81lJ=T23!sO(3H~jna?lf^-_w(RC2mZN)bTPQU#hUiJkH@O2z9^g>r}DyRwER5$ zcyC6d73bUWmDi7mowK<}ei!#rd>`i%OPjlWc>G*H46@u8+#f}kezfss=QP{KS#}XP zf9S1Pdn4r%?2fU0Yz`mv1AiC1=POapkRE&LuE@#sIqPM3o$m*n zaOFDuaPvrWh{H5f_p>tjpv%k8V!izztSqmdJ2sp`uf2(`sew-((HjywkIkWffN}SA zp#N;0i6192YvB8bk=y5u-odwG+o8!r^y!psY3uyCe6-+mt`fLhc3)Mbe(eY+1r8h2 z#csm`m6235TJ>#w*?*`GSNuURkw|zYzWo&I*~s2B(AN0V(#pY#5Y(aZ28UIou{Ty`X-koWLmndiN zQ#wD8UHpu0x+O5h+&d06$HpS(m&`E}U3fhHcx*A}H|pcZUvHA|Ex#O(k3XKc#>0}2 zLyfC;*_80X3hbgLyGN{pn0o4Q^yohDZvp@5iaQBj=M=bSNUOCL)gA1I419G;S!5k+ z*a`onkeMwV0rxWX@#CMBV*AI;w9tZzE;4L5I z{~7%2GShmCzwwV(m0gQ}oVZ-YLMIZcM-FDJ9}z!Q?;|z^s!rEF$Er%CgWe@Aj#gBh zkKFf>{Kl%vZ-|HPIfFfTKypCb<88)zQ*kh0x@-cAyK?xU2mFl>75vjp?8Sck108ex zlfAe4$5Px6nN&QH_(JJe=(s!7PsGj^gO~;IWnT zf^GBGU^gfRkVwBll5cynd}p>j=Lh*v_iQ{1~|0 z%bFyk)vRF!DM2~PTGQ{2i9X2tfyeNnlK~1koPs1|jLc>yUU9WXO-=o3#MJ3Vwjj`d- zmZDe-x=^w9#chSrN9=qD%5~qsu9(F6{69Oeg)AKWaslZ>Y|xu?v8i=>|7+WoGsknJ z`u4#7wwWKsmf`QY;8_KpeZc)Eq!-oZ*PqZ4JYp~9&X?Peu{zuTK>4;p=QOicd|-YU z?zttCG#9w#&b7wyk?!9jO=(&#ZuV9P-uTb;0=Ym#>OF zUCTOL*6|MG#=DQx{Ttff!aDbK=HBtDJ*)fm9*j7(-WclsQj3qPR({~r5A7IxM(W<{ zzRG-C{C7Cp?$6Qd$C|h;w09~?Zxrv4jzNB3g`eigUXnjSwlerkCcZXYdc{9R_p*FM z*lhKzd0{7Ki*1KbE(iC&ai5QBEvi>M3jB#N@aD$%R#kCv=(d;iRQLOl9j~W69v|C} zeVB?&tRbyNE@nz^^#t2fo$fZs-hI&T1MR=`mEh2uM`16|A`y#iFmIDhJ$%cWi03I* zj!fj>bN;>;7zbaQQy`ymPxE!J(_IB#s)>arep&B{S;GSI{mzK)eeAc9j{@gL6Q^hY zxqo!&RL-fv;I8=GFSQoiN4eM3^jTyYncy8>?)`!4-@7gP8TNb?_&4+3`GD{F1#5rO zsmSyKy@iRI_c3J)W%t|mgXP<>r=izs(#BoG;$1P`+&%XN_yiwN&u?B8A7^d&_?t%9 zJYeM@omMTgploE{p6ZLvx`CKAd%eEgV*SRd4?Lh6eUi^-X z-H4vAXZ)=#iqoU}ZM*#6$R=?r;>^B#mTkAW(M2m7FEuu4ZECfbsQ~ zv)T{etpB~>9DYlBb19R6vuRXjitmUkEtSwkwApbXhkdwvF zc1$lX-bZJMWJfv~TFbZg7xF#W_PjxHMyrp7S8o1iCX4%aXkTGkewDt6%a<@m=iwoLYaA)1+Y8@P{?kI)ZuIOVL5D^UQ!o#K^FtlIeO_z=ATh{+q3Jq$Z1-6*pb!A@g-=Pi%x8C;2;$(b~@}vHNwAHL7kxoO) zd3 e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = Rails.root.join("spec/fixtures").to_s + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + config.include ApplicationHelper + config.include FactoryBot::Syntax::Methods + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/requests/home_spec.rb b/spec/requests/home_spec.rb new file mode 100644 index 0000000..6bdecae --- /dev/null +++ b/spec/requests/home_spec.rb @@ -0,0 +1,10 @@ +require "rails_helper" + +RSpec.describe "Homes", type: :request do + describe "GET /index" do + it "responds with 200" do + get root_path + expect(response).to have_http_status(:ok) + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..029cc1c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,112 @@ +require "with_model" +require "capybara/rspec" +require "webdrivers/chromedriver" + +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed + + config.extend WithModel + + config.before(:suite) do + Rails.application.load_tasks + Rails.application.load_seed + Rake::Task["assets:precompile"].invoke + end + + config.before(:each, type: :system) do + driven_by :rack_test + end + + config.before(:each, type: :system, js: true) do + driven_by :selenium_chrome_headless + end +end diff --git a/storage/.keep b/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb new file mode 100644 index 0000000..6340bf9 --- /dev/null +++ b/test/channels/application_cable/connection_test.rb @@ -0,0 +1,13 @@ +require "test_helper" + +module ApplicationCable + class ConnectionTest < ActionCable::Connection::TestCase + # test "connects with cookies" do + # cookies.signed[:user_id] = 42 + # + # connect + # + # assert_equal connection.user_id, "42" + # end + end +end diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/system/.keep b/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..0c22470 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,15 @@ +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" + +module ActiveSupport + class TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... + end +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 0000000..e69de29 diff --git a/tmp/pids/.keep b/tmp/pids/.keep new file mode 100644 index 0000000..e69de29 diff --git a/tmp/storage/.keep b/tmp/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/javascript/.keep b/vendor/javascript/.keep new file mode 100644 index 0000000..e69de29