Merge pull request #7 from github/joshaber/add-live-reload

Add live reload
This commit is contained in:
Josh Abernathy 2022-11-03 11:53:59 -04:00 committed by GitHub
commit deb18f698f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 94 additions and 7 deletions

View file

@ -10,7 +10,7 @@
},
"customizations": {
"codespaces": {
"openFiles": ["config/routes.rb", "README.md"]
"openFiles": ["app/views/hello/index.html.erb", "README.md"]
},
"vscode": {
"extensions": [

2
.gitignore vendored
View file

@ -33,3 +33,5 @@
# Ignore master key for decrypting credentials and more.
/config/master.key
dump.rdb

View file

@ -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

View file

@ -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)

View file

@ -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;
}

View file

@ -0,0 +1,4 @@
class HelloController < ApplicationController
def index
end
end

View file

@ -0,0 +1,2 @@
module HelloCodespacesHelper
end

View file

@ -0,0 +1,11 @@
<div class="App">
<header class="App-header">
<img src="Octocat.png" class="App-logo" alt="logo" />
<p>
GitHub Codespaces <span class="heart">♥️</span> Rails
</p>
<p class="small">
Edit <code>app/views/hello/index.html.erb</code> and see changes live!
</p>
</header>
</div>

View file

@ -8,6 +8,7 @@
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<%= hotwire_livereload_tags if Rails.env.development? %>
</head>
<body>

View file

@ -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

View file

@ -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

BIN
public/Octocat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 MiB

View file

@ -0,0 +1,8 @@
require "test_helper"
class HelloCodespacesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get "/"
assert_response :success
end
end

BIN
vendor/cache/ffi-1.15.5.gem vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
vendor/cache/listen-3.7.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rb-fsevent-0.11.2.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rb-inotify-0.10.1.gem vendored Normal file

Binary file not shown.