From adb1de5074de16998ec9acb78c4573aa486a28cf Mon Sep 17 00:00:00 2001 From: Raghu Betina Date: Sat, 29 Jul 2023 13:21:53 -0500 Subject: [PATCH] Initial commit --- .devcontainer/devcontainer.json | 43 ++ .erdconfig | 22 + .gitattributes | 7 + .gitignore | 42 ++ .gitpod.yml | 31 ++ .pryrc | 8 + .rspec | 4 + .ruby-version | 1 + .vscode/settings.json | 72 +++ Gemfile | 109 +++++ Gemfile.lock | 450 ++++++++++++++++++ README.md | 54 +++ Rakefile | 6 + app/assets/config/manifest.js | 4 + app/assets/images/.keep | 0 app/assets/stylesheets/application.css | 15 + app/channels/application_cable/channel.rb | 4 + app/channels/application_cable/connection.rb | 4 + app/controllers/application_controller.rb | 3 + app/controllers/concerns/.keep | 0 app/helpers/application_helper.rb | 2 + app/javascript/application.js | 3 + app/javascript/controllers/application.js | 9 + .../controllers/hello_controller.js | 7 + app/javascript/controllers/index.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/layouts/application.html.erb | 16 + app/views/layouts/mailer.html.erb | 13 + app/views/layouts/mailer.text.erb | 1 + appdev.Dockerfile | 207 ++++++++ bin/bundle | 109 +++++ bin/dev | 10 + bin/importmap | 4 + bin/rails | 4 + bin/rake | 4 + bin/setup | 45 ++ config.ru | 15 + config/application.rb | 33 ++ config/boot.rb | 4 + config/cable.yml | 11 + config/credentials.yml.enc | 1 + config/database.yml | 90 ++++ config/environment.rb | 5 + config/environments/development.rb | 79 +++ config/environments/production.rb | 93 ++++ config/environments/test.rb | 60 +++ config/importmap.rb | 7 + config/initializers/appdev_support.rb | 7 + config/initializers/assets.rb | 12 + config/initializers/backtrace_silencers.rb | 9 + .../initializers/content_security_policy.rb | 25 + config/initializers/cookies_serializer.rb | 5 + .../initializers/filter_parameter_logging.rb | 8 + config/initializers/inflections.rb | 16 + config/initializers/nicer_errors.rb | 47 ++ config/initializers/permissions_policy.rb | 11 + config/initializers/rails_db.rb | 30 ++ config/initializers/wrap_parameters.rb | 14 + config/locales/en.yml | 55 +++ config/puma.rb | 43 ++ config/routes.rb | 6 + config/storage.yml | 34 ++ db/schema.rb | 17 + db/seeds.rb | 7 + lib/assets/.keep | 0 lib/tasks/.keep | 0 lib/tasks/auto_annotate_models.rake | 59 +++ lib/tasks/dev.rake | 3 + log/.keep | 0 public/404.html | 67 +++ public/422.html | 67 +++ public/500.html | 66 +++ public/apple-touch-icon-precomposed.png | 0 public/apple-touch-icon.png | 0 public/favicon.ico | 0 public/robots.txt | 1 + spec/features/sample_spec.rb | 7 + spec/rails_helper.rb | 67 +++ spec/spec_helper.rb | 107 +++++ spec/support/headless_chrome.rb | 19 + spec/support/hint_formatter.rb | 11 + spec/support/json_output_formatter.rb | 67 +++ spec/support/webmock.rb | 4 + storage/.keep | 0 test/application_system_test_case.rb | 5 + .../application_cable/connection_test.rb | 11 + 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 | 13 + tmp/.keep | 0 tmp/pids/.keep | 0 tmp/storage/.keep | 0 vendor/.keep | 0 vendor/javascript/.keep | 0 102 files changed, 2656 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .erdconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .gitpod.yml create mode 100644 .pryrc create mode 100644 .rspec create mode 100644 .ruby-version create mode 100644 .vscode/settings.json create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 README.md create mode 100644 Rakefile 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/channels/application_cable/channel.rb create mode 100644 app/channels/application_cable/connection.rb create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/helpers/application_helper.rb create mode 100644 app/javascript/application.js create mode 100644 app/javascript/controllers/application.js create mode 100644 app/javascript/controllers/hello_controller.js create mode 100644 app/javascript/controllers/index.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/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 appdev.Dockerfile 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/appdev_support.rb create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/cookies_serializer.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/nicer_errors.rb create mode 100644 config/initializers/permissions_policy.rb create mode 100644 config/initializers/rails_db.rb create mode 100644 config/initializers/wrap_parameters.rb create mode 100644 config/locales/en.yml create mode 100644 config/puma.rb create mode 100644 config/routes.rb create mode 100644 config/storage.yml create mode 100644 db/schema.rb create mode 100644 db/seeds.rb create mode 100644 lib/assets/.keep create mode 100644 lib/tasks/.keep create mode 100644 lib/tasks/auto_annotate_models.rake create mode 100644 lib/tasks/dev.rake 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/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/features/sample_spec.rb create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb create mode 100644 spec/support/headless_chrome.rb create mode 100644 spec/support/hint_formatter.rb create mode 100644 spec/support/json_output_formatter.rb create mode 100644 spec/support/webmock.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/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..dbbe26d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,43 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/universal +{ + "name": "Container", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "jelaniwoods/appdev2023-rails-template", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 4567, 9292], + + "portsAttributes": { + "3000": { + "onAutoForward": "silent" + }, + "4567": { + "onAutoForward": "silent" + }, + "9292": { + "onAutoForward": "silent" + } + }, + + "otherPortsAttributes": {"onAutoForward": "ignore"}, + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "bin/setup", + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": ["vortizhe.simple-ruby-erb", + "mbessey.vscode-rufo", + "aliariff.vscode-erb-beautify", + "eamodio.gitlens"] + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.erdconfig b/.erdconfig new file mode 100644 index 0000000..70ea51f --- /dev/null +++ b/.erdconfig @@ -0,0 +1,22 @@ +attributes: + - content + - foreign_key + - inheritance +disconnected: true +filename: erd +filetype: png +indirect: true +inheritance: false +markup: true +notation: bachman +orientation: vertical +polymorphism: false +sort: true +warn: false +title: false +exclude: ActiveRecord::InternalMetadata,ActiveRecord::SchemaMigration,ActiveStorage::Attachment,ActiveStorage::Blob,AdminUser,ActiveAdmin::Comment,primary::SchemaMigration +only: null +only_recursion_depth: null +prepend_primary: false +cluster: false +splines: spline 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/.gitignore b/.gitignore new file mode 100644 index 0000000..561daca --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# 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 +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +/public/assets + +# Ignore master key for decrypting credentials and more. +/config/master.key +# AppDev files +core.chrome* +examples.txt +.vscode/.ltici_apitoken.yml + +# Ignore dotenv files +/.env* + +# Un-ignore SQLite3 db +!/db/*.sqlite3 +!/db/*.sqlite3-journal diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..a726284 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,31 @@ +image: jelaniwoods/appdev2023-rails-template + +tasks: + - env: + DATABASE_URL: "postgresql://gitpod@localhost" + before: | + sudo echo 'export DATABASE_URL="postgresql://gitpod@localhost"' | sudo tee -a ~/.bashrc + sudo cp -r /home/student /home/gitpod && sudo chmod 777 /home/gitpod && chown -R gitpod /home/gitpod + export GEM_HOME=/workspace/.rvm + export GEM_PATH=$GEM_HOME:$GEM_PATH + export PATH=/workspace/.rvm/bin:$PATH + bin/setup +ports: + - port: 3000 + onOpen: open-preview + visibility: public + - port: 4567 + onOpen: open-preview + visibility: public + - port: 9292 + onOpen: open-preview + visibility: public + - port: 5432 + onOpen: ignore + +vscode: + extensions: + - vortizhe.simple-ruby-erb + - mbessey.vscode-rufo + - aliariff.vscode-erb-beautify + - eamodio.gitlens diff --git a/.pryrc b/.pryrc new file mode 100644 index 0000000..bb814e0 --- /dev/null +++ b/.pryrc @@ -0,0 +1,8 @@ +Pry.config.print = proc do |output, value, _pry_| + case value + when ActiveRecord::Relation + output.puts "=> #{value.to_s}" + else + Pry::ColorPrinter.default(output, value, _pry_) + end +end diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..064157a --- /dev/null +++ b/.rspec @@ -0,0 +1,4 @@ +--color +--format documentation +--order default +--require spec_helper diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..72b3400 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-3.2.1 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..444f764 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,72 @@ +{ + "editor.tabSize": 2, + "editor.acceptSuggestionOnEnter": "off", + "editor.bracketPairColorization.enabled": false, + "editor.cursorSurroundingLines": 4, + "editor.dragAndDrop": false, + "editor.guides.bracketPairs": true, + "editor.linkedEditing": true, + "editor.minimap.enabled": false, + "editor.smoothScrolling": false, + "editor.wordBasedSuggestionsMode": "allDocuments", + "editor.wordWrap": "on", + "editor.wrappingIndent": "deepIndent", + "workbench.editor.closeOnFileDelete": true, + "workbench.fontAliasing": "auto", + "workbench.startupEditor": "none", + "workbench.tree.renderIndentGuides": "always", + "files.autoSaveDelay": 500, + "files.exclude": { + "**/.git": true, + ".vscode": true, + ".bundle": true, + ".gitignore": false, + ".gitpod.yml": false, + ".rspec": false, + ".devcontainer/": false, + "config.ru": false, + "Dockerfile": false, + "Gemfile": false, + "Gemfile.lock": false, + "tmp/": false, + "install-packages": false, + "main.rb": false, + "README.md": false, + "app.rb": false, + "environment.rb": false, + "bin/": false, + "spec/": false, + "examples.txt": false, + "config/": false + }, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "screencastMode.onlyKeyboardShortcuts": true, + "screencastMode.verticalOffset": 10, + "explorer.compactFolders": false, + "explorer.incrementalNaming": "smart", + "html.format.endWithNewline": true, + "html.format.preserveNewLines": true, + "html.format.templating": true, + "terminal.integrated.altClickMovesCursor": true, + "vscode-erb-beautify.keepBlankLines": 1, + "ruby.intellisense": false, + "gitpod.openInStable.neverPrompt": true, + "gitlens.showWelcomeOnInstall": false, + "gitlens.currentLine.enabled": false, + "redhat.telemetry.enabled": false, + "emmet.includeLanguages": { + "erb": "html" + }, + "[ruby]": { + "editor.defaultFormatter": "mbessey.vscode-rufo", + "editor.formatOnSave": false + }, + "[erb]": { + "editor.defaultFormatter": "aliariff.vscode-erb-beautify", + "editor.formatOnSave": false + }, + "files.associations": { + "*.html.erb": "erb" + } +} diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..6ccc546 --- /dev/null +++ b/Gemfile @@ -0,0 +1,109 @@ +source "https://rubygems.org" +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby "3.2.1" + +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 7.0.4", ">= 7.0.4.3" + +# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] +gem "sprockets-rails" + +# Use postgresql as the database for Active Record +gem "pg", "~> 1.1" + +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", "~> 5.0" + +# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "importmap-rails" + +# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] +gem "turbo-rails" + +# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] +gem "stimulus-rails" + +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +gem "jbuilder" + +# Use Redis adapter to run Action Cable in production +gem "redis", "~> 4.0" + +# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] +# gem "kredis" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +# gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] + +# Reduces boot times through caching; required in config/boot.rb +gem "bootsnap", require: false + +# Use Sass to process CSS +# gem "sassc-rails" + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +# gem "image_processing", "~> 1.2" + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri mingw x64_mingw ] +end + +group :development do + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console" + + # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] + # gem "rack-mini-profiler" + + # Speed up commands on slow machines / big apps [https://github.com/rails/spring] + # gem "spring" +end + +group :test do + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + gem "capybara" + gem "selenium-webdriver" + gem "webdrivers" +end + +# AppDev Gems +# =========== +gem "appdev_support" +gem "awesome_print" +gem "devise" # to be removed +gem "dotenv-rails" +gem "faker" +gem "htmlbeautifier" +gem "http" +gem "sqlite3", "~> 1.4" +gem "table_print" + +group :development do + gem "annotate" + gem "better_errors" + gem "binding_of_caller" + gem "draft_generators" + gem "grade_runner" + gem "pry-rails" + gem "rails_db" + gem "rails-erd" + gem "rufo" + gem "specs_to_readme" + gem "web_git" +end + +group :development, :test do + gem "rspec-rails", "~> 6.0.0" +end + +group :test do + gem "draft_matchers"#, "0.0.2"#path: "../../my_stuff/draft_matchers" + # gem "draft_matchers" + gem "rspec-html-matchers" + gem "webmock" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..c464aa8 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,450 @@ +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.4) + public_suffix (>= 2.0.2, < 6.0) + annotate (3.2.0) + activerecord (>= 3.2, < 8.0) + rake (>= 10.4, < 14.0) + ansispan (0.0.1) + appdev_support (0.2.1) + tabulo + awesome_print (1.9.2) + bcrypt (3.1.18) + better_errors (2.9.1) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) + bindex (0.8.1) + binding_of_caller (1.0.0) + debug_inspector (>= 0.0.1) + bootsnap (1.16.0) + msgpack (~> 1.2) + builder (3.2.4) + capybara (3.39.1) + 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) + choice (0.2.0) + coderay (1.1.3) + color (1.8) + color_namer (0.1.0) + color (>= 1.4.1) + concurrent-ruby (1.2.2) + crack (0.4.5) + rexml + crass (1.0.6) + date (3.3.3) + debug (1.7.2) + irb (>= 1.5.0) + reline (>= 0.3.1) + debug_inspector (1.1.0) + devise (4.9.2) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) + diff-lcs (1.5.0) + diffy (3.4.2) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.8.1) + dotenv-rails (2.8.1) + dotenv (= 2.8.1) + railties (>= 3.2) + draft_generators (0.0.4) + devise + indefinite_article + draft_matchers (0.0.2) + capybara + color_namer + rspec + erubi (1.12.0) + faker (3.1.1) + i18n (>= 1.8.11, < 2) + faraday (2.7.9) + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) + faraday-net_http (3.0.2) + faraday-retry (1.0.3) + ffi (1.15.5) + ffi-compiler (1.0.1) + ffi (>= 1.0.0) + rake + git (1.18.0) + addressable (~> 2.8) + rchardet (~> 1.8) + globalid (1.1.0) + activesupport (>= 5.0) + grade_runner (0.0.8) + activesupport (>= 2.3.5) + faraday-retry (~> 1.0.3) + octokit (~> 5.0) + oj (~> 3.13.12) + rake (~> 13) + hashdiff (1.0.1) + htmlbeautifier (1.4.2) + http (5.1.1) + addressable (~> 2.8) + http-cookie (~> 1.0) + http-form_data (~> 2.2) + llhttp-ffi (~> 0.4.0) + http-cookie (1.0.5) + domain_name (~> 0.5) + http-form_data (2.3.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + importmap-rails (1.1.5) + actionpack (>= 6.0.0) + railties (>= 6.0.0) + indefinite_article (0.2.5) + activesupport + io-console (0.6.0) + irb (1.6.4) + reline (>= 0.3.0) + jbuilder (2.11.5) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + kaminari (1.2.2) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) + actionview + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) + activerecord + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) + llhttp-ffi (0.4.0) + ffi-compiler (~> 1.0) + rake (~> 13.0) + loofah (2.20.0) + 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.1) + msgpack (1.7.0) + mustermann (3.0.0) + ruby2_keywords (~> 0.0.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.9) + nokogiri (1.15.2-x86_64-linux) + racc (~> 1.4) + octokit (5.6.1) + faraday (>= 1, < 3) + sawyer (~> 0.9) + oj (3.13.23) + orm_adapter (0.5.0) + pg (1.4.6) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (5.0.1) + puma (5.6.5) + nio4r (~> 2.0) + racc (1.6.2) + rack (2.2.7) + rack-protection (3.0.6) + rack + 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-erd (1.7.2) + activerecord (>= 4.2) + activesupport (>= 4.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + rails_db (2.4.2) + activerecord + kaminari + rails (>= 5.0.0) + ransack (>= 2.3.2) + simple_form (>= 5.0.1) + terminal-table + 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) + rake (13.0.6) + ransack (4.0.0) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) + i18n + rchardet (1.8.0) + redis (4.8.1) + regexp_parser (2.8.0) + reline (0.3.3) + io-console (~> 0.5) + responders (3.1.0) + actionpack (>= 5.2) + railties (>= 5.2) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-html-matchers (0.10.0) + nokogiri (~> 1) + rspec (>= 3.0.0.a) + rspec-mocks (3.12.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-rails (6.0.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.11) + rspec-expectations (~> 3.11) + rspec-mocks (~> 3.11) + rspec-support (~> 3.11) + rspec-support (3.12.0) + ruby-graphviz (1.2.5) + rexml + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + rufo (0.16.0) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) + selenium-webdriver (4.8.6) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + simple_form (5.2.0) + actionpack (>= 5.2) + activemodel (>= 5.2) + sinatra (3.0.6) + mustermann (~> 3.0) + rack (~> 2.2, >= 2.2.4) + rack-protection (= 3.0.6) + tilt (~> 2.0) + specs_to_readme (0.1.0) + 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) + sqlite3 (1.6.2-x86_64-linux) + stimulus-rails (1.2.1) + railties (>= 6.0.0) + table_print (1.5.7) + tabulo (2.8.2) + tty-screen (= 0.8.1) + unicode-display_width (~> 2.2) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + thor (1.2.1) + tilt (2.1.0) + timeout (0.3.2) + tty-screen (0.8.1) + 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.2023.3) + tzinfo (>= 1.0.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.2) + unicode-display_width (2.4.2) + warden (1.2.9) + rack (>= 2.0.9) + web-console (4.2.0) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + web_git (0.1.0) + actionview + ansispan + diffy + git + sinatra + tzinfo-data + webdrivers (5.2.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0) + webmock (3.18.1) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + websocket (1.2.9) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.6.7) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + annotate + appdev_support + awesome_print + better_errors + binding_of_caller + bootsnap + capybara + debug + devise + dotenv-rails + draft_generators + draft_matchers + faker + grade_runner + htmlbeautifier + http + importmap-rails + jbuilder + pg (~> 1.1) + pry-rails + puma (~> 5.0) + rails (~> 7.0.4, >= 7.0.4.3) + rails-erd + rails_db + redis (~> 4.0) + rspec-html-matchers + rspec-rails (~> 6.0.0) + rufo + selenium-webdriver + specs_to_readme + sprockets-rails + sqlite3 (~> 1.4) + stimulus-rails + table_print + turbo-rails + tzinfo-data + web-console + web_git + webdrivers + webmock + +RUBY VERSION + ruby 3.2.1p31 + +BUNDLED WITH + 2.4.6 diff --git a/README.md b/README.md new file mode 100644 index 0000000..528bf07 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Rails Template + +This is a base Ruby on Rails repository configured for learning with Codespaces (and Gitpod). + +- Ruby version: `3.2.1` +- Rails version: `7.0.4.3` + + +We've added additional Ruby gems and other software that aren't automatically available in a new Rails app. + +### Additional gems: + +- [`appdev_support`](https://github.com/firstdraft/appdev_support) +- [`annotate`](https://github.com/ctran/annotate_models) +- [`awesome_print`](https://github.com/awesome-print/awesome_print) +- [`better_errors`](https://github.com/BetterErrors/better_errors) +- [`binding_of_caller`](https://github.com/banister/binding_of_caller) +- [`dotenv-rails`](https://github.com/bkeepers/dotenv) +- [`draft_generators`](https://github.com/firstdraft/draft_generators/) +- [`draft_matchers`](https://github.com/jelaniwoods/draft_matchers/) +- [`devise`](https://github.com/heartcombo/devise) +- [`faker`](https://github.com/faker-ruby/faker) +- [`grade_runner`](https://github.com/firstdraft/grade_runner/) +- [`htmlbeautifier`](https://github.com/threedaymonk/htmlbeautifier/) +- [`http`](https://github.com/httprb/http) +- [`pry_rails`](https://github.com/pry/pry-rails) +- [`rails_db`](https://github.com/igorkasyanchuk/rails_db) +- [`rails-erd`](https://github.com/voormedia/rails-erd) +- [`rspec-html-matchers`](https://github.com/kucaahbe/rspec-html-matchers) +- [`rspec-rails`](https://github.com/rspec/rspec-rails) +- [`rufo`](https://github.com/ruby-formatter/rufo) +- [`specs_to_readme`](https://github.com/firstdraft/specs_to_readme) +- [`table_print`](https://github.com/arches/table_print) +- [`web_git`](https://github.com/firstdraft/web_git) +- [`webmock`](https://github.com/bblimke/webmock) + +### Additional software: +- OS Ubuntu 20.04.5 LTS +- Chromedriver +- Fly.io's `flyctl` +- Google Chrome (headless browser) +- Graphviz +- Heroku +- Node JS 18 +- NPM 8.19.3 +- Parity +- Postgresql 12 +- Redis +- Yarn + +### VS Code extensions: +- aliariff.vscode-erb-beautify +- mbessey.vscode-rufo +- vortizhe.simple-ruby-erb 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/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..ddd546a --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,4 @@ +//= link_tree ../images +//= link_directory ../stylesheets .css +//= link_tree ../../javascript .js +//= link_tree ../../../vendor/javascript .js 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/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/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..8c14a6c --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + skip_forgery_protection +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/javascript/application.js b/app/javascript/application.js new file mode 100644 index 0000000..0d7b494 --- /dev/null +++ b/app/javascript/application.js @@ -0,0 +1,3 @@ +// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails +import "@hotwired/turbo-rails" +import "controllers" diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 0000000..1213e85 --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,9 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js new file mode 100644 index 0000000..5975c07 --- /dev/null +++ b/app/javascript/controllers/hello_controller.js @@ -0,0 +1,7 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + connect() { + this.element.textContent = "Hello World!" + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 0000000..54ad4ca --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,11 @@ +// Import and register all your controllers from the importmap under controllers/* + +import { application } from "controllers/application" + +// Eager load all controllers defined in the import map under controllers/**/*_controller +import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" +eagerLoadControllersFrom("controllers", application) + +// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) +// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" +// lazyLoadControllersFrom("controllers", application) 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/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..0cc6f4e --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,16 @@ + + + + Rails Template + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= 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/appdev.Dockerfile b/appdev.Dockerfile new file mode 100644 index 0000000..1b82ae6 --- /dev/null +++ b/appdev.Dockerfile @@ -0,0 +1,207 @@ +FROM buildpack-deps:focal + +### base ### +RUN yes | unminimize \ + && apt-get install -yq \ + acl \ + zip \ + unzip \ + bash-completion \ + build-essential \ + htop \ + jq \ + less \ + locales \ + man-db \ + nano \ + software-properties-common \ + sudo \ + time \ + vim \ + multitail \ + lsof \ + && locale-gen en_US.UTF-8 \ + && mkdir /var/lib/apt/dazzle-marks \ + && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* + +ENV LANG=en_US.UTF-8 + +### Git ### +RUN add-apt-repository -y ppa:git-core/ppa \ + && apt-get install -yq git \ + && rm -rf /var/lib/apt/lists/* + +### Container user ### +# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user +RUN useradd -l -u 33334 -G sudo -md /home/student -s /bin/bash -p student student \ + # passwordless sudo for users in the 'sudo' group + && sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers +ENV HOME=/home/student +WORKDIR $HOME +# custom Bash prompt +RUN { echo && echo "PS1='\[\e]0;\u \w\a\]\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \\\$ '" ; } >> .bashrc + +### Student user (2) ### +USER student +# use sudo so that user does not get sudo usage info on (the first) login +RUN sudo echo "Running 'sudo' for container: success" && \ + # create .bashrc.d folder and source it in the bashrc + mkdir /home/student/.bashrc.d && \ + (echo; echo "for i in \$(ls \$HOME/.bashrc.d/*); do source \$i; done"; echo) >> /home/student/.bashrc + +### Ruby ### +LABEL dazzle/layer=lang-ruby +LABEL dazzle/test=tests/lang-ruby.yaml +USER student +RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \ + && curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - \ + && curl -fsSL https://get.rvm.io | bash -s stable \ + && bash -lc " \ + rvm requirements \ + && rvm install 3.2.1 \ + && rvm use 3.2.1 --default \ + && rvm rubygems current \ + && gem install bundler:2.4.6 --no-document" \ + && echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> /home/student/.bashrc.d/70-ruby +RUN echo "rvm_gems_path=/home/student/.rvm" > ~/.rvmrc + +ENV GEM_HOME=/workspaces/.rvm +ENV GEM_PATH=$GEM_HOME:$GEM_PATH +ENV PATH=/workspaces/.rvm/bin:$PATH + +USER student + +# AppDev stuff +RUN sudo wget -qO /usr/bin/install-packages "https://gist.githubusercontent.com/jelaniwoods/d5cc8157a0de0f449de748f75e2e182e/raw/c45b0f2947975ff7bb53cbddb8a2fe2e6241db8e/install-packages" \ + && sudo chmod 775 /usr/bin/install-packages +RUN /bin/bash -l -c "gem install htmlbeautifier rufo -N" + +WORKDIR /rails-template + +# Pre-install gems into /rails-template/gems/ +COPY Gemfile /rails-template/Gemfile +COPY --chown=student:student Gemfile.lock /rails-template/Gemfile.lock +RUN /bin/bash -l -c "bundle install" + +# Install Google Chrome +RUN sudo apt-get update && sudo apt-get install -y libxss1 +RUN wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_114.0.5735.198-1_amd64.deb && \ + sudo apt-get install -y ./google-chrome-stable_114.0.5735.198-1_amd64.deb + +# Install Chromedriver (compatable with Google Chrome version) +# See https://gerg.dev/2021/06/making-chromedriver-and-chrome-versions-match-in-a-docker-image/ +RUN BROWSER_MAJOR=$(google-chrome --version | sed 's/Google Chrome \([0-9]*\).*/\1/g') && \ + wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${BROWSER_MAJOR} -O chrome_version && \ + wget https://chromedriver.storage.googleapis.com/`cat chrome_version`/chromedriver_linux64.zip && \ + unzip chromedriver_linux64.zip && \ + sudo mv chromedriver /usr/local/bin/ && \ + DRIVER_MAJOR=$(chromedriver --version | sed 's/ChromeDriver \([0-9]*\).*/\1/g') && \ + echo "chrome version: $BROWSER_MAJOR" && \ + echo "chromedriver version: $DRIVER_MAJOR" && \ + if [ $BROWSER_MAJOR != $DRIVER_MAJOR ]; then echo "VERSION MISMATCH"; exit 1; fi + + +# Install PostgreSQL +RUN sudo install-packages postgresql-12 postgresql-contrib-12 + +# Setup PostgreSQL server for user student +ENV PATH="$PATH:/usr/lib/postgresql/12/bin" +ENV PGDATA="/workspaces/.pgsql/data" +RUN sudo mkdir -p $PGDATA +RUN mkdir -p $PGDATA ~/.pg_ctl/bin ~/.pg_ctl/sockets \ + && printf '#!/bin/bash\n[ ! -d $PGDATA ] && mkdir -p $PGDATA && initdb -D $PGDATA\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" start\n' > ~/.pg_ctl/bin/pg_start \ + && printf '#!/bin/bash\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" stop\n' > ~/.pg_ctl/bin/pg_stop \ + && chmod +x ~/.pg_ctl/bin/* \ + && sudo addgroup dev \ + && sudo adduser student dev \ + && sudo chgrp -R dev $PGDATA \ + && sudo chmod -R 775 $PGDATA \ + && sudo setfacl -dR -m g:staff:rwx $PGDATA \ + && sudo chmod 777 /var/run/postgresql +ENV PATH="$PATH:$HOME/.pg_ctl/bin" +# ENV DATABASE_URL="postgresql://student@localhost" +ENV PGHOSTADDR="127.0.0.1" +ENV PGDATABASE="postgres" + +# This is a bit of a hack. At the moment we have no means of starting background +# tasks from a Dockerfile. This workaround checks, on each bashrc eval, if the +# PostgreSQL server is running, and if not starts it. +RUN printf "\n# Auto-start PostgreSQL server.\n[[ \$(pg_ctl status | grep PID) ]] || pg_start > /dev/null\n" >> ~/.bashrc + +WORKDIR /rails-template +USER student +# Install graphviz (Rails ERD) +RUN /bin/bash -l -c "sudo apt update && sudo apt install -y graphviz=2.42.2-3build2" + +# Install fuser (bin/server) and expect (web_git) +RUN sudo apt install -y libpq-dev psmisc lsof expect + +# Install parity +RUN wget -qO - https://apt.thoughtbot.com/thoughtbot.gpg.key | sudo apt-key add - \ + && echo "deb http://apt.thoughtbot.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/thoughtbot.list \ + && sudo apt-get update \ + && sudo apt-get -y install parity=3.5.0-2 + +# Install Node and npm +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - \ + && sudo apt-get install -y nodejs + +# Install Yarn +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - \ + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \ + && sudo apt-get update \ + && sudo apt-get install -y yarn \ + && sudo npm install -g n \ + && sudo n 18 \ + && hash -r + +# Install Redis. +RUN sudo apt-get update \ + && sudo apt-get install -y \ + redis-server=5:5.0.7-2ubuntu0.1 \ + && sudo rm -rf /var/lib/apt/lists/* + +# Install heroku-cli +RUN /bin/bash -l -c "curl https://cli-assets.heroku.com/install.sh | sh" + +# Install flyyctl +RUN /bin/bash -l -c "curl -L https://fly.io/install.sh | sh" +RUN echo "export PATH=\"/home/student/.fly/bin:\$PATH\"" >> ~/.bashrc + +# Thoughtbot style bash prompt +RUN sudo wget -qO ./prompt "https://gist.githubusercontent.com/jelaniwoods/7e5db8d72b3dfac257b7eb562cfebf11/raw/af43083d91c0eb1489059a2ad9c39474a34ddbda/thoughtbot-style-prompt" +RUN /bin/bash -l -c "cat ./prompt >> ~/.bashrc" + +# Git global configuration +RUN git config --global push.default upstream \ + && git config --global merge.ff only \ + && git config --global alias.aa '!git add -A' \ + && git config --global alias.cm '!f(){ git commit -m "${*}"; };f' \ + && git config --global alias.acm '!f(){ git add -A && git commit -am "${*}"; };f' \ + && git config --global alias.as '!git add -A && git stash' \ + && git config --global alias.p 'push' \ + && git config --global alias.sla 'log --oneline --decorate --graph --all' \ + && git config --global alias.co 'checkout' \ + && git config --global alias.cob 'checkout -b' \ + && git config --global --add --bool push.autoSetupRemote true + +# Alias 'git' to 'g' +# RUN echo 'export PATH="$PATH:$GITPOD_REPO_ROOT/bin"' >> ~/.bashrc +RUN echo "# No arguments: 'git status'\n\ +# With arguments: acts like 'git'\n\ +g() {\n\ + if [[ \$# > 0 ]]; then\n\ + git \$@\n\ + else\n\ + git status\n\ + fi\n\ +}\n# Complete g like git\n\ +source /usr/share/bash-completion/completions/git\n\ +__git_complete g __git_main" >> ~/.bash_aliases + +# Alias bundle exec to be +RUN echo "alias be='bundle exec'" >> ~/.bash_aliases +# RUN sudo cp -r /home/student /home/gitpod && sudo chmod 777 /home/gitpod + +# Add bin/rake to path for non-Rails projects +RUN echo 'export PATH="$PWD/bin:$PATH"' >> ~/.bashrc diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..ee73929 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,109 @@ +#!/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($0) == 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| + if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile && !gemfile.empty? + + 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) + + bundler_gem_version.approximate_recommendation + 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! + +if m.invoked_as_script? + load Gem.bin_path("bundler", "bundle") +end diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..6668021 --- /dev/null +++ b/bin/dev @@ -0,0 +1,10 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +parentdir="$(dirname "$DIR")" +pid="$parentdir/tmp/pids/server.pid" +if [ -f $pid ]; then + rm $pid +fi +fuser -k -n tcp 3000 +rails server -b 0.0.0.0 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..3c99990 --- /dev/null +++ b/bin/setup @@ -0,0 +1,45 @@ +#!/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. + if `cat /etc/passwd`.include?("gitpod") + puts "updating db permissions" + system! "sudo adduser gitpod dev" + system! "sudo chown gitpod $PGDATA" + system! "initdb -D $PGDATA" + system! "pg_ctl start" + end + + puts "== Installing dependencies ==" + 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:create" + system! "bin/rails db:migrate" + system! "bin/rails db:seed" + + puts "\n== Removing old logs and tempfiles ==" + system! "bin/rails log:clear tmp:clear" + + puts "\n== Restarting application server ==" + system! "bin/rails restart" + + puts "\n== Creating test database ==" + system! "bundle exec rake db:create RAILS_ENV=test" + puts "\n== Initial setup complete ==" +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..b2017fe --- /dev/null +++ b/config.ru @@ -0,0 +1,15 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +if Rails.env.development? + map '/git' do + run WebGit::Server + end +end + +map '/' do + run Rails.application +end + +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..816e38a --- /dev/null +++ b/config/application.rb @@ -0,0 +1,33 @@ +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 RailsTemplate + 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") + config.generators do |g| + g.test_framework nil + g.factory_bot false + g.scaffold_stylesheet false + g.stylesheets false + g.javascripts false + g.helper false + end + + config.action_controller.default_protect_from_forgery = false + config.generators.system_tests = nil + 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..d946db7 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,11 @@ +development: + adapter: redis + url: redis://localhost:6379/1 + +test: + adapter: test + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: rails_template_production diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000..64429ee --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ ++Nrzc0yp4pH3MFYI9YM2GyIjptoLE/MlAyqycvuh5PWQJUT7E3bSYmi2+DWXCac8dl/vC55sOYH4EB+Socmgmxkl2MhQD2FLPOdao2NyigB1B1FluPpnQsI/uYEJhsLDgiCisRgkEc9qNQrcWH+Un6kxY5AaJ2UapuMBb6RTX/cGF98WQRa9+LltiLpYwiLnNPNyE+rh3WZDgPTrLg5NwO+XKMz13QvKqMGdg7Km/kyFXRR/pRLTlsS7MXDEPMg2Wwon+zopDKngX/+tR3Zd6PhVa+e2yN5yMVZ7/F1LamiJJJxLe54JQyb/4GKpQIkKUm9PFtFp6EC5HlTK7TVHAwUpMinp7Y9/5kFAJGVDT52Xwrhu4SQI0fNCI/yeoyt2mKMY34u65znB+feyl/4GK83p7br6qXPAsWyZ--X41Jo6YDcBgMCt8i--JM5pu8Z4sduuGlfTXLSa3A== \ No newline at end of file diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000..cfefc5e --- /dev/null +++ b/config/database.yml @@ -0,0 +1,90 @@ +# 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: + adapter: sqlite3 + database: db/development.sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + + # 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_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: + adapter: sqlite3 + database: db/test.sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + +# 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_template_production + username: rails_template + password: <%= ENV["RAILS_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..47a5d16 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,79 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Allow server to be hosted on any URL + config.hosts.clear + # Allow better_errors to work in online IDE + config.web_console.whitelisted_ips = "0.0.0.0/0.0.0.0" + BetterErrors::Middleware.allow_ip! "0.0.0.0/0.0.0.0" + # Auto-connect to database when rails console opens + console do + ActiveRecord::Base.connection + end + # 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 + + # 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..1ce7042 --- /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_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..8dce42d --- /dev/null +++ b/config/importmap.rb @@ -0,0 +1,7 @@ +# Pin npm packages by running ./bin/importmap + +pin "application", preload: true +pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true +pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true +pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true +pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/config/initializers/appdev_support.rb b/config/initializers/appdev_support.rb new file mode 100644 index 0000000..e2773f9 --- /dev/null +++ b/config/initializers/appdev_support.rb @@ -0,0 +1,7 @@ +AppdevSupport.config do |config| + config.action_dispatch = true + config.active_record = true + config.pryrc = :minimal +end + +AppdevSupport.init 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/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..8b03bbb --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,9 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! + +Rails.backtrace_cleaner.add_silencer { |line| line =~ /lib|gems/ } 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/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..adc6568 --- /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 += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] 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/nicer_errors.rb b/config/initializers/nicer_errors.rb new file mode 100644 index 0000000..30e4af0 --- /dev/null +++ b/config/initializers/nicer_errors.rb @@ -0,0 +1,47 @@ + +module ActionDispatch + class ExceptionWrapper + def framework_trace + [] + end + end +end + +module ActionDispatch + module Routing + class RouteSet + def draw(&block) + clear! unless @disable_clear_and_finalize + eval_block(block) + finalize! unless @disable_clear_and_finalize + nil + rescue => e + nicer_message = e.message + nicer_message = nicer_message.sub(/for .+/,'.') + nicer_message = nicer_message.sub('ApplicationController::','') + nicer_message = nicer_message.sub('uninitialized constant','undefined class') + nicer_message = nicer_message.sub('undefined local variable or method','unrecognized') + nicer_message = nicer_message.sub(/ \(/,'') + nicer_message = nicer_message.sub(/did you mean/, 'Did you mean') + + route_line = e.backtrace.detect { |line| line !~ /\/gems/ }.sub(/^[^\/]+/,'') + route_line.sub!(/:in .+/,'') + route_line =~ /(.+):(.+)/ + + puts + puts "ERROR: routes.rb" + puts nicer_message + puts route_line + puts + + rescue_route = proc do + html = "

There's a problem with your routes.rb file.

#{nicer_message}

#{route_line}

" + get '/' => proc {|env| [200, { "Content-Type" => 'text/html'}, [html]]} + get '*path' => proc {|env| [200, { "Content-Type" => 'text/html'}, [html]]} + end + + eval_block(rescue_route) + end + end + end +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/rails_db.rb b/config/initializers/rails_db.rb new file mode 100644 index 0000000..83daca3 --- /dev/null +++ b/config/initializers/rails_db.rb @@ -0,0 +1,30 @@ +if Object.const_defined?('RailsDb') + RailsDb.setup do |config| + # # enabled or not + # config.enabled = Rails.env.development? + + # # automatic engine routes mounting + # config.automatic_routes_mount = true + + # set tables which you want to hide ONLY + config.black_list_tables = ["ar_internal_metadata"] + + # set tables which you want to show ONLY + # config.white_list_tables = ['posts', 'comments'] + + # # Enable http basic authentication + # config.http_basic_authentication_enabled = false + + # # Enable http basic authentication + # config.http_basic_authentication_user_name = 'rails_db' + + # # Enable http basic authentication + # config.http_basic_authentication_password = 'password' + + # # Enable http basic authentication + # config.verify_access_proc = proc { |controller| true } + + # # Sandbox mode (only read-only operations) + # config.sandbox = false + end +end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..de656cc --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,55 @@ +# 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: + hints: + randomness: This test deals with randomness. If you think your code is correct but the test failed anyway, you might have just gotten unlucky; try running the test a couple more times. + copy_must_match: Make sure that the text exactly matches the target, including capitalization. + button_type: If you're not being sent anywhere when you click submit and you have an attribute `type="button"` on your `