diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e50ee5c..2720462 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,7 @@ }, "customizations": { "codespaces": { - "openFiles": ["config/routes.rb", "README.md"] + "openFiles": ["app/views/hello/index.html.erb", "README.md"] }, "vscode": { "extensions": [ diff --git a/.gitignore b/.gitignore index 886f714..eddbb4f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ # Ignore master key for decrypting credentials and more. /config/master.key + +dump.rdb diff --git a/Gemfile b/Gemfile index 8c563a9..ff4c62c 100644 --- a/Gemfile +++ b/Gemfile @@ -66,6 +66,8 @@ group :development do # Speed up commands on slow machines / big apps [https://github.com/rails/spring] # gem "spring" + + gem "hotwire-livereload", "~> 1.2" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e8fec78..6ef09e9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,8 +108,12 @@ GEM rubocop smart_properties erubi (1.11.0) + ffi (1.15.5) globalid (1.0.0) activesupport (>= 5.0) + hotwire-livereload (1.2.2) + listen (>= 3.0.0) + rails (>= 6.0.0) i18n (1.12.0) concurrent-ruby (~> 1.0) importmap-rails (1.1.5) @@ -127,6 +131,9 @@ GEM rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) loofah (2.18.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -193,6 +200,9 @@ GEM zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) + ffi (~> 1.0) regexp_parser (2.5.0) reline (0.3.1) io-console (~> 0.5) @@ -283,6 +293,7 @@ DEPENDENCIES capybara debug erb_lint + hotwire-livereload (~> 1.2) importmap-rails jbuilder puma (~> 5.0) diff --git a/app/assets/stylesheets/hello.css b/app/assets/stylesheets/hello.css new file mode 100644 index 0000000..fa4c720 --- /dev/null +++ b/app/assets/stylesheets/hello.css @@ -0,0 +1,45 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +.App-header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.App-link { + color: #61dafb; +} + +.heart { + color: #ff0000; +} + +.small { + font-size: 0.75rem; +} diff --git a/app/controllers/hello_controller.rb b/app/controllers/hello_controller.rb new file mode 100644 index 0000000..5203753 --- /dev/null +++ b/app/controllers/hello_controller.rb @@ -0,0 +1,4 @@ +class HelloController < ApplicationController + def index + end +end diff --git a/app/helpers/hello_codespaces_helper.rb b/app/helpers/hello_codespaces_helper.rb new file mode 100644 index 0000000..874a2ca --- /dev/null +++ b/app/helpers/hello_codespaces_helper.rb @@ -0,0 +1,2 @@ +module HelloCodespacesHelper +end diff --git a/app/views/hello/index.html.erb b/app/views/hello/index.html.erb new file mode 100644 index 0000000..e705171 --- /dev/null +++ b/app/views/hello/index.html.erb @@ -0,0 +1,11 @@ +
+
+ +

+ GitHub Codespaces ♥️ Rails +

+

+ Edit app/views/hello/index.html.erb and see changes live! +

+
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0d23b0e..fa5e3a0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,6 +8,7 @@ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_importmap_tags %> + <%= hotwire_livereload_tags if Rails.env.development? %> diff --git a/config/environments/development.rb b/config/environments/development.rb index bac3264..224bf90 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -59,8 +59,9 @@ Rails.application.configure do # Suppress logger output for asset requests. config.assets.quiet = true + pf_domain = ENV['GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN'] config.action_dispatch.default_headers = { - 'X-Frame-Options' => 'ALLOW-FROM preview.app.github.dev' + 'X-Frame-Options' => "ALLOW-FROM #{pf_domain}" } # Raises error for missing translations. @@ -73,5 +74,8 @@ Rails.application.configure do # config.action_cable.disable_request_forgery_protection = true # Allow requests from our preview domain. - config.hosts << "#{ENV['CODESPACE_NAME']}-3000.preview.app.github.dev" + pf_host = "#{ENV['CODESPACE_NAME']}-3000.#{pf_domain}" + config.hosts << pf_host + + config.action_cable.allowed_request_origins = ["https://#{pf_host}"] end diff --git a/config/routes.rb b/config/routes.rb index 262ffd5..f28ca9f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,3 @@ 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 "articles#index" + root "hello#index" end diff --git a/public/Octocat.png b/public/Octocat.png new file mode 100644 index 0000000..91057da Binary files /dev/null and b/public/Octocat.png differ diff --git a/test/controllers/hello_codespaces_controller_test.rb b/test/controllers/hello_codespaces_controller_test.rb new file mode 100644 index 0000000..d17cd16 --- /dev/null +++ b/test/controllers/hello_codespaces_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class HelloCodespacesControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get "/" + assert_response :success + end +end diff --git a/vendor/cache/ffi-1.15.5.gem b/vendor/cache/ffi-1.15.5.gem new file mode 100644 index 0000000..a632047 Binary files /dev/null and b/vendor/cache/ffi-1.15.5.gem differ diff --git a/vendor/cache/hotwire-livereload-1.2.2.gem b/vendor/cache/hotwire-livereload-1.2.2.gem new file mode 100644 index 0000000..bfd2f2c Binary files /dev/null and b/vendor/cache/hotwire-livereload-1.2.2.gem differ diff --git a/vendor/cache/listen-3.7.1.gem b/vendor/cache/listen-3.7.1.gem new file mode 100644 index 0000000..5e1eed5 Binary files /dev/null and b/vendor/cache/listen-3.7.1.gem differ diff --git a/vendor/cache/rb-fsevent-0.11.2.gem b/vendor/cache/rb-fsevent-0.11.2.gem new file mode 100644 index 0000000..e645266 Binary files /dev/null and b/vendor/cache/rb-fsevent-0.11.2.gem differ diff --git a/vendor/cache/rb-inotify-0.10.1.gem b/vendor/cache/rb-inotify-0.10.1.gem new file mode 100644 index 0000000..276590b Binary files /dev/null and b/vendor/cache/rb-inotify-0.10.1.gem differ