From 1bf90caeecb348546ca25186b1ea6aefb7cc79a0 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Fri, 1 Apr 2022 21:16:05 -0400 Subject: [PATCH] die --- Gemfile | 2 + Gemfile.lock | 5 ++ app/controllers/svelte_controller.rb | 4 ++ app/javascript/app.svelte | 16 +++-- app/javascript/friends.svelte | 0 app/javascript/packs/friends.js | 10 +++ app/javascript/packs/games.js | 0 .../packs/{hello_svelte.js => home.js} | 4 +- app/javascript/packs/portfolio.js | 10 +++ app/javascript/portfolio.svelte | 67 +++++++++++++++++++ app/views/layouts/application.html.erb | 4 +- app/views/svelte/friends.html.erb | 1 + app/views/svelte/index.html.erb | 3 + app/views/svelte/portfolio.html.erb | 1 + config/environments/development.rb | 2 + config/routes.rb | 4 ++ gemset.nix | 21 ++++++ 17 files changed, 147 insertions(+), 7 deletions(-) create mode 100644 app/controllers/svelte_controller.rb create mode 100644 app/javascript/friends.svelte create mode 100644 app/javascript/packs/friends.js create mode 100644 app/javascript/packs/games.js rename app/javascript/packs/{hello_svelte.js => home.js} (77%) create mode 100644 app/javascript/packs/portfolio.js create mode 100644 app/javascript/portfolio.svelte create mode 100644 app/views/svelte/friends.html.erb create mode 100644 app/views/svelte/index.html.erb create mode 100644 app/views/svelte/portfolio.html.erb diff --git a/Gemfile b/Gemfile index 68d679c..ab8f408 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,8 @@ gem 'puma', '~> 5.0' gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 5.0' +# Svelte interop +gem 'svelte-rails' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/Gemfile.lock b/Gemfile.lock index 3c92573..a15c5de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,6 +80,7 @@ GEM concurrent-ruby (1.1.9) crass (1.0.6) erubi (1.10.0) + execjs (2.8.1) ffi (1.15.4) globalid (1.0.0) activesupport (>= 5.0) @@ -174,6 +175,9 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.2) + svelte-rails (0.3.4) + execjs + railties (>= 5.2) thor (1.1.0) tilt (2.0.10) turbolinks (5.2.1) @@ -218,6 +222,7 @@ DEPENDENCIES selenium-webdriver spring sqlite3 (~> 1.4) + svelte-rails turbolinks (~> 5) tzinfo-data web-console (>= 4.1.0) diff --git a/app/controllers/svelte_controller.rb b/app/controllers/svelte_controller.rb new file mode 100644 index 0000000..eb3414f --- /dev/null +++ b/app/controllers/svelte_controller.rb @@ -0,0 +1,4 @@ +class SvelteController < ApplicationController + def index + end +end \ No newline at end of file diff --git a/app/javascript/app.svelte b/app/javascript/app.svelte index ad47e12..8f0fa7f 100644 --- a/app/javascript/app.svelte +++ b/app/javascript/app.svelte @@ -1,11 +1,19 @@ +
+
+

jane {names[Math.floor(Math.random() * names.length)]} petrovna

+

jane#0009

+
+
+ - -

Hello {name}!

\ No newline at end of file diff --git a/app/javascript/friends.svelte b/app/javascript/friends.svelte new file mode 100644 index 0000000..e69de29 diff --git a/app/javascript/packs/friends.js b/app/javascript/packs/friends.js new file mode 100644 index 0000000..9089b44 --- /dev/null +++ b/app/javascript/packs/friends.js @@ -0,0 +1,10 @@ +import App from '../friends.svelte' + +document.addEventListener('DOMContentLoaded', () => { + const app = new App({ + target: document.body, + }); + + window.app = app; +}) + diff --git a/app/javascript/packs/games.js b/app/javascript/packs/games.js new file mode 100644 index 0000000..e69de29 diff --git a/app/javascript/packs/hello_svelte.js b/app/javascript/packs/home.js similarity index 77% rename from app/javascript/packs/hello_svelte.js rename to app/javascript/packs/home.js index a914a9d..3055a1d 100644 --- a/app/javascript/packs/hello_svelte.js +++ b/app/javascript/packs/home.js @@ -11,7 +11,9 @@ document.addEventListener('DOMContentLoaded', () => { const app = new App({ target: document.body, props: { - name: 'Svelte' + names: ['sunset', 'luna', 'bonnibel', 'marceline', 'artemis', + 'diana', 'constanze', 'twilight', 'bianca', 'dawn', 'rosa', 'akemi', + 'glimmer'] } }); diff --git a/app/javascript/packs/portfolio.js b/app/javascript/packs/portfolio.js new file mode 100644 index 0000000..4632ac7 --- /dev/null +++ b/app/javascript/packs/portfolio.js @@ -0,0 +1,10 @@ +import App from '../portfolio.svelte' + +document.addEventListener('DOMContentLoaded', () => { + const app = new App({ + target: document.body, + }); + + window.app = app; +}) + diff --git a/app/javascript/portfolio.svelte b/app/javascript/portfolio.svelte new file mode 100644 index 0000000..4ccf038 --- /dev/null +++ b/app/javascript/portfolio.svelte @@ -0,0 +1,67 @@ + +
+
+ + +
+
+ + + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 05d8fbb..992b115 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - + - J4pm + j4.pm <%= csrf_meta_tags %> <%= csp_meta_tag %> diff --git a/app/views/svelte/friends.html.erb b/app/views/svelte/friends.html.erb new file mode 100644 index 0000000..5b53aea --- /dev/null +++ b/app/views/svelte/friends.html.erb @@ -0,0 +1 @@ +<%= javascript_pack_tag 'friends' %> \ No newline at end of file diff --git a/app/views/svelte/index.html.erb b/app/views/svelte/index.html.erb new file mode 100644 index 0000000..2efd0df --- /dev/null +++ b/app/views/svelte/index.html.erb @@ -0,0 +1,3 @@ +<%= javascript_pack_tag 'home' %> + + \ No newline at end of file diff --git a/app/views/svelte/portfolio.html.erb b/app/views/svelte/portfolio.html.erb new file mode 100644 index 0000000..ec10047 --- /dev/null +++ b/app/views/svelte/portfolio.html.erb @@ -0,0 +1 @@ +<%= javascript_pack_tag 'portfolio' %> \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 7a9f6c3..b144c41 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,6 +3,8 @@ require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + config.hosts << "dev.j4.pm" + # 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. diff --git a/config/routes.rb b/config/routes.rb index c06383a..ac2b1d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,7 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html + + get '/portfolio', to: 'svelte#portfolio' + get '/friends', to: 'svelte#friends' + root 'svelte#index' end diff --git a/gemset.nix b/gemset.nix index b9b5cdc..fb02b83 100644 --- a/gemset.nix +++ b/gemset.nix @@ -231,6 +231,16 @@ }; version = "1.10.0"; }; + execjs = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "121h6af4i6wr3wxvv84y53jcyw2sk71j5wsncm6wq6yqrwcrk4vd"; + type = "gem"; + }; + version = "2.8.1"; + }; ffi = { groups = ["default" "development"]; platforms = []; @@ -673,6 +683,17 @@ }; version = "1.4.2"; }; + svelte-rails = { + dependencies = ["execjs" "railties"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0lcvvx0nd0ya7l6xxa8j40bl6x13qrzwisclckr0i2a6vcf4r1c1"; + type = "gem"; + }; + version = "0.3.4"; + }; thor = { groups = ["default" "development"]; platforms = [];