Skip to content

Commit 9198f3c

Browse files
committedJul 14, 2022
Get maps working again
1 parent 34d339a commit 9198f3c

17 files changed

+820
-326
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@
3535
yarn-debug.log*
3636
.yarn-integrity
3737
dump.rdb
38+
39+
/app/assets/builds/*
40+
!/app/assets/builds/.keep

‎Gemfile

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby '2.7.2'
4+
ruby '3.1.2'
55

6-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
7-
gem 'rails', '~> 7.0.0.alpha2'
6+
gem 'rails', github: 'rails/rails', branch: 'main'
7+
8+
gem 'sprockets-rails'
89

910
# Use postgresql as the database for Active Record
1011
gem 'pg', '~> 1.1'
12+
1113
# Use Puma as the app server
1214
gem 'puma', '~> 5.0'
13-
# Use SCSS for stylesheets
14-
gem 'sass-rails', '>= 6'
15-
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
16-
gem 'webpacker', '~> 5.0'
17-
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
18-
gem 'turbolinks', '~> 5'
15+
16+
gem "jsbundling-rails"
17+
18+
gem "turbo-rails"
19+
20+
gem "stimulus-rails"
21+
1922
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
2023
gem 'jbuilder', '~> 2.7'
24+
25+
# Use SCSS for stylesheets
26+
gem 'sass-rails', '>= 6'
27+
28+
29+
2130
# Use Redis adapter to run Action Cable in production
2231
# gem 'redis', '~> 4.0'
2332
# Use Active Model has_secure_password
@@ -27,15 +36,13 @@ gem 'jbuilder', '~> 2.7'
2736
# gem 'image_processing', '~> 1.2'
2837

2938
# Reduces boot times through caching; required in config/boot.rb
30-
gem 'bootsnap', '>= 1.4.4', require: false
31-
39+
gem 'bootsnap', require: false
3240

3341
# Authentication
3442
gem 'devise'
3543
gem 'omniauth-google-oauth2'
3644
gem 'omniauth-rails_csrf_protection'
3745

38-
3946
group :development, :test do
4047
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
4148
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
@@ -59,15 +66,10 @@ end
5966
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
6067
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
6168

62-
gem "stimulus-rails", "~> 0.6.0"
63-
6469
gem "tailwindcss-rails", "~> 0.4.3"
6570
gem 'image_processing', '~> 1.2'
6671
gem 'stripe'
6772
gem 'resque'
68-
6973
gem "validates_overlap", "~> 1.0"
70-
7174
gem "pagy", "~> 5.10"
72-
7375
gem "noticed", "~> 1.5"

‎Gemfile.lock

+167-157
Large diffs are not rendered by default.

‎Procfile.dev

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: bin/rails server -p 3000
2+
js: yarn build --watch

‎app/assets/builds/.keep

Whitespace-only changes.

‎app/assets/config/manifest.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
//= link_tree ../images
22
//= link_directory ../stylesheets .css
3+
//= link_tree ../builds

‎app/javascript/application.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Entry point for the build script in your package.json
2+
// import * as ActiveStorage from "@rails/activestorage"
3+
import "@hotwired/turbo-rails"
4+
import "./channels"
5+
import "./controllers"
6+
7+
// ActiveStorage.start()
8+
console.log("here")
9+
window.initMap = () => {
10+
console.log('initMap was called');
11+
const event = new Event("MapLoaded")
12+
event.initEvent("map-loaded", true, true);
13+
window.dispatchEvent(event)
14+
}

‎app/javascript/channels/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Load all the channels within this directory and all subdirectories.
2-
// Channel files must be named *_channel.js.
1+
import { createConsumer } from "@rails/actioncable"
32

4-
const channels = require.context('.', true, /_channel\.js$/)
5-
channels.keys().forEach(channels)
3+
export default createConsumer()

‎app/javascript/controllers/listing_map_controller.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class extends Controller {
1212
}
1313

1414
initGoogle() {
15+
console.log('init google')
1516
const myLatLng = { lat: -25.363, lng: 131.044 };
1617
const map = new google.maps.Map(this.mapTarget, {
1718
zoom: 4,
@@ -21,6 +22,7 @@ export default class extends Controller {
2122
}
2223

2324
addMarkers(map) {
25+
console.log('adding markers')
2426
Array.from(this.listingsTarget.children).forEach((listing) => {
2527
if(listing.dataset.lat) {
2628
new google.maps.Marker({

‎app/javascript/packs/application.js

-21
This file was deleted.

‎app/views/layouts/application.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<%= stylesheet_link_tag "inter-font", "data-turbo-track": "reload" %>
1010
<%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>
1111
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
12-
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
12+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
1313
<script src="https://maps.googleapis.com/maps/api/js?key=<%= Rails.application.credentials.google[:maps] %>&libraries=places&callback=initMap" async defer data-turbolinks-eval="false"></script>
1414
</head>
1515

‎bin/dev

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
if ! foreman version &> /dev/null
4+
then
5+
echo "Installing foreman..."
6+
gem install foreman
7+
fi
8+
9+
foreman start -f Procfile.dev "$@"

‎config/webpacker.yml

-92
This file was deleted.

‎db/seeds.rb

+5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
state: Faker::Address.state,
1616
country: 'US',
1717
status: [:draft, :published].sample,
18+
nightly_price: 12000,
19+
cleaning_fee: 5000,
1820
)
21+
puts "New listing: #{listing.id}"
1922
end
2023

2124

@@ -36,6 +39,8 @@
3639
state: Faker::Address.state,
3740
country: 'US',
3841
status: [:draft, :published].sample,
42+
nightly_price: 12000,
43+
cleaning_fee: 5000,
3944
)
4045
end
4146
end

‎package-lock.json

+538-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
"name": "clearbnb",
33
"private": true,
44
"dependencies": {
5-
"@hotwired/stimulus": "^3.0.0",
5+
"@hotwired/stimulus": "^3.0.1",
6+
"@hotwired/turbo-rails": "^7.1.3",
67
"@rails/actioncable": "^7.0.0",
78
"@rails/activestorage": "^7.0.0",
8-
"@rails/ujs": "^7.0.0",
9-
"@rails/webpacker": "5.4.3",
109
"el-transition": "^0.0.7",
11-
"turbolinks": "^5.2.0",
12-
"webpack": "^4.46.0",
13-
"webpack-cli": "^3.3.12",
10+
"esbuild": "^0.14.49",
1411
"yarn": "^1.22.17"
1512
},
1613
"version": "0.1.0",
17-
"devDependencies": {
18-
"webpack-dev-server": "^3"
14+
"scripts": {
15+
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets"
1916
}
2017
}

‎yarn.lock

+52-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.