glimmer-dsl-web 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c9bd6a7f085751de551a8eada611f25b6462c32f31019ebc31e296a98a7dbe7
4
- data.tar.gz: cde631c346fddf15d48c52b85643f4f436761b059ccca0a8909cca56fdc7676e
3
+ metadata.gz: 84438bf8ca94283ebca35c684038f1ba326c9301782508bdf07b7c4e23ecb391
4
+ data.tar.gz: f7246af497c04e9c509457444ac9c17c8617aa881fca82adb4561473f1d18044
5
5
  SHA512:
6
- metadata.gz: 036cbe077a6378e6fb18cf10060074b4a071b20f4293960ded842458069c4dfb5bc041eb909f0b7b3cfbb809f73a41605f2b97f101b338f1ee616e52f00445c3
7
- data.tar.gz: 4441339edfaf2724324e4aa30c19b2afc7e0e9d673add6130882e1c3220e278a1be1d21be126bf9b8aaa7568c62a0c59ecbce9ca2d1103183263ae17deb2d15e
6
+ metadata.gz: b47263b248b7952d58d9fe8fb03f0614f8c917e025310839f7ab311f33fc31e292fe257ffec8f1c487843eab7814253829c00579ea2132385b4064b75e801890
7
+ data.tar.gz: 6be5e5bab5900605d78977e703d27ac95dac303fa3855d52bd4f7dd4a1e8c8f090d49b95c57a5abe3155dde9adece9a028cfa7afc3872b9fcead2ce1a417676d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.1.1
4
+
5
+ - Upgrade to opal-jquery 0.5.1 (adds `# backtick_javascript: true` where needed to satisfy new Opal requirement)
6
+ - Upgrade to opal-async 1.4.1 (adds `# backtick_javascript: true` where needed to satisfy new Opal requirement)
7
+ - Update setup instructions to NOT disable Hotwire files, to allow running Hotwire/Turbo side by side with Glimmer DSL for Web (but not in the same pages)
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  - Update rendering system to render HTML elements immediately instead of waiting for complete components to be rendered all at once.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.1.0 (Beta)
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Web 0.1.1 (Beta)
2
2
  ## Ruby in the Browser Web GUI Frontend Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-web.svg)](http://badge.fury.io/rb/glimmer-dsl-web)
4
4
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -1146,7 +1146,7 @@ rails new glimmer_app_server
1146
1146
  Add the following to `Gemfile`:
1147
1147
 
1148
1148
  ```
1149
- gem 'glimmer-dsl-web', '~> 0.1.0'
1149
+ gem 'glimmer-dsl-web', '~> 0.1.1'
1150
1150
  ```
1151
1151
 
1152
1152
  Run:
@@ -1191,26 +1191,28 @@ rails db:migrate
1191
1191
  Add the following to `config/routes.rb` inside the `Rails.application.routes.draw` block:
1192
1192
 
1193
1193
  ```ruby
1194
- mount Glimmer::Engine => "/glimmer" # add on top
1195
1194
  root to: 'welcomes#index'
1196
1195
  ```
1197
1196
 
1198
1197
  Clear the file `app/views/welcomes/index.html.erb` completely from all content.
1199
1198
 
1200
- Delete `app/javascript` directory
1199
+ Rename `app/assets/javascript/application.js.rb` file to `app/assets/javascript/opal_application.rb`.
1201
1200
 
1202
1201
  Rename `app/assets/javascript` directory to `app/assets/opal`.
1203
1202
 
1204
- Add the following lines to `app/assets/config/manifest.js` (and delete their `javascript` equivalents):
1203
+ Edit `app/assets/config/manifest.js` and update `//= link_directory ../javascript .js` to `//= link_directory ../opal .js`:
1205
1204
 
1206
1205
  ```js
1207
- //= link_tree ../../opal .js
1208
1206
  //= link_directory ../opal .js
1209
1207
  ```
1210
1208
 
1211
- Rename `app/assets/opal/application.js.rb` to `app/assets/opal/application.rb`.
1209
+ Edit `app/views/layouts/application.html.erb` and update `<%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>` to `<%= javascript_include_tag "opal_application", "data-turbolinks-track": "reload" %>`:
1212
1210
 
1213
- Edit and replace `app/assets/opal/application.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below):
1211
+ ```erb
1212
+ <%= javascript_include_tag "opal_application", "data-turbolinks-track": "reload" %>
1213
+ ```
1214
+
1215
+ Edit and replace `app/assets/opal/opal_application.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below):
1214
1216
 
1215
1217
  ```ruby
1216
1218
  require 'glimmer-dsl-web' # brings opal and other dependencies automatically
@@ -1317,6 +1319,7 @@ That produces:
1317
1319
  </div>
1318
1320
  ...
1319
1321
  ```
1322
+
1320
1323
  You may insert a Glimmer component anywhere into a Rails View using `glimmer_component(component_path, *args)` Rails helper. Add `include GlimmerHelper` to `ApplicationHelper` or another Rails helper, and use `<%= glimmer_component("path/to/component", *args) %>` in Views.
1321
1324
 
1322
1325
  To use `glimmer_component`, edit `app/helpers/application_helper.rb` in your Rails application, add `require 'glimmer/helpers/glimmer_helper'` on top and `include GlimmerHelper` inside `module`.
@@ -1333,6 +1336,8 @@ module ApplicationHelper
1333
1336
  end
1334
1337
  ```
1335
1338
 
1339
+ Note that Turbo is disabled on Glimmer elements/components. You can still use Turbo/Hotwire side by side with Glimmer DSL for Web by using one of the two technologies in every page. But, mixing them in the same pages is not recommended at the moment, so any pages loaded with Glimmer DSL for Web must be loaded without Turbo (e.g. by putting "data-turbo"="false" on anchor "a" tag links to Glimmer pages).
1340
+
1336
1341
  If you run into any issues in setup, refer to the [Sample Glimmer DSL for Web Rails 7 App](https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails7-app) project (in case I forgot to include some setup steps by mistake).
1337
1342
 
1338
1343
  Otherwise, if you still cannot setup successfully (even with the help of the sample project, or if the sample project stops working), please do not hesitate to report an [Issue request](https://github.com/AndyObtiva/glimmer-dsl-web/issues) or fix and submit a [Pull Request](https://github.com/AndyObtiva/glimmer-dsl-web/pulls).
@@ -1362,7 +1367,7 @@ Disable the `webpacker` gem line in `Gemfile`:
1362
1367
  Add the following to `Gemfile`:
1363
1368
 
1364
1369
  ```ruby
1365
- gem 'glimmer-dsl-web', '~> 0.1.0'
1370
+ gem 'glimmer-dsl-web', '~> 0.1.1'
1366
1371
  ```
1367
1372
 
1368
1373
  Run:
@@ -1407,10 +1412,8 @@ rails db:migrate
1407
1412
  Add the following to `config/routes.rb` inside the `Rails.application.routes.draw` block:
1408
1413
 
1409
1414
  ```ruby
1410
- mount Glimmer::Engine => "/glimmer" # add on top
1411
1415
  root to: 'welcomes#index'
1412
1416
  ```
1413
- ```
1414
1417
 
1415
1418
  Also, delete the following line:
1416
1419
 
@@ -1420,18 +1423,23 @@ Also, delete the following line:
1420
1423
 
1421
1424
  Clear the file `app/views/welcomes/index.html.erb` completely from all content.
1422
1425
 
1426
+ Rename `app/assets/javascript/application.js.rb` file to `app/assets/javascript/opal_application.rb`.
1427
+
1423
1428
  Rename `app/assets/javascript` directory to `app/assets/opal`.
1424
1429
 
1425
- Add the following lines to `app/assets/config/manifest.js` (and delete their `javascript` equivalents):
1430
+ Edit `app/assets/config/manifest.js` and update `//= link_directory ../javascript .js` to `//= link_directory ../opal .js`:
1426
1431
 
1427
1432
  ```js
1428
- //= link_tree ../../opal .js
1429
1433
  //= link_directory ../opal .js
1430
1434
  ```
1431
1435
 
1432
- Rename `app/assets/opal/application.js.rb` to `app/assets/opal/application.rb`.
1436
+ Edit `app/views/layouts/application.html.erb` and update `<%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>` to `<%= javascript_include_tag "opal_application", "data-turbolinks-track": "reload" %>`:
1433
1437
 
1434
- Edit and replace `app/assets/opal/application.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below inside a `Document.ready? do; end` block):
1438
+ ```erb
1439
+ <%= javascript_include_tag "opal_application", "data-turbolinks-track": "reload" %>
1440
+ ```
1441
+
1442
+ Edit and replace `app/assets/opal/opal_application.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below):
1435
1443
 
1436
1444
  ```ruby
1437
1445
  require 'glimmer-dsl-web' # brings opal and other dependencies automatically
@@ -1508,6 +1516,8 @@ module ApplicationHelper
1508
1516
  end
1509
1517
  ```
1510
1518
 
1519
+ Note that Turbo is disabled on Glimmer elements/components. You can still use Turbo/Hotwire side by side with Glimmer DSL for Web by using one of the two technologies in every page. But, mixing them in the same pages is not recommended at the moment, so any pages loaded with Glimmer DSL for Web must be loaded without Turbo (e.g. by putting "data-turbo"="false" on anchor "a" tag links to Glimmer pages).
1520
+
1511
1521
  **NOT RELEASED OR SUPPORTED YET**
1512
1522
 
1513
1523
  If you run into any issues in setup, refer to the [Sample Glimmer DSL for Web Rails 6 App](https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails6-app) project (in case I forgot to include some setup steps by mistake).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-web 0.1.0 ruby lib
5
+ # stub: glimmer-dsl-web 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-web".freeze
9
- s.version = "0.1.0".freeze
9
+ s.version = "0.1.1".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -79,8 +79,8 @@ Gem::Specification.new do |s|
79
79
  s.add_runtime_dependency(%q<glimmer-dsl-css>.freeze, ["~> 1.2.2".freeze])
80
80
  s.add_runtime_dependency(%q<opal>.freeze, ["= 1.8.2".freeze])
81
81
  s.add_runtime_dependency(%q<opal-rails>.freeze, ["= 2.0.3".freeze])
82
- s.add_runtime_dependency(%q<opal-async>.freeze, ["~> 1.4.0".freeze])
83
- s.add_runtime_dependency(%q<opal-jquery>.freeze, ["~> 0.5.0".freeze])
82
+ s.add_runtime_dependency(%q<opal-async>.freeze, ["~> 1.4.1".freeze])
83
+ s.add_runtime_dependency(%q<opal-jquery>.freeze, ["~> 0.5.1".freeze])
84
84
  s.add_runtime_dependency(%q<to_collection>.freeze, [">= 2.0.1".freeze, "< 3.0.0".freeze])
85
85
  s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0".freeze])
86
86
  s.add_development_dependency(%q<rake>.freeze, [">= 10.1.0".freeze, "< 14.0.0".freeze])
@@ -7,24 +7,27 @@ module GlimmerHelper
7
7
  end
8
8
 
9
9
  def glimmer_component(component_asset_path, *component_args)
10
- component_file = component_asset_path.split('/').last
11
- component_class_name = component_file.classify
10
+ component_file = component_asset_path.split('/').last # TODO support namespaced components
11
+ component_class_name = component_file.classify # TODO support namespaced components
12
12
  next_id_number = GlimmerHelper.next_id_number
13
13
  component_id = "glimmer_component_#{next_id_number}"
14
14
  component_script_container_id = "glimmer_component_script_container_#{next_id_number}"
15
15
  component_args_json = JSON.dump(component_args)
16
- opal_script = <<~Opal
16
+ opal_script = <<~OPAL
17
17
  require 'glimmer-dsl-web'
18
18
  component_args_json = '#{component_args_json}'
19
19
  component_args = JSON.parse(component_args_json)
20
20
  component_args << {} if !component_args.last.is_a?(Hash)
21
21
  component_args.last[:parent] = "##{component_id}"
22
22
  #{component_class_name}.render(*component_args)
23
- Opal
24
- content_tag(:div, id: component_script_container_id, class: ['glimmer_component_script_container', "#{component_file}_script_container"]) do
23
+ OPAL
24
+ js_script = <<~JAVASCRIPT
25
+ Opal.eval(`#{opal_script}`)
26
+ JAVASCRIPT
27
+ content_tag(:div, id: component_script_container_id, class: ['glimmer_component_script_container', "#{component_file}_script_container"], 'data-turbo': 'false') do
25
28
  content_tag(:div, '', id: component_id, class: ['glimmer_component', component_file]) +
26
29
  javascript_include_tag(component_asset_path, "data-turbolinks-track": "reload") +
27
- content_tag(:script, raw(opal_script), type: 'text/ruby')
30
+ content_tag(:script, raw(js_script), type: 'application/javascript', "data-turbo-eval": "false")
28
31
  end
29
32
  end
30
33
  end
@@ -253,7 +253,6 @@ module Glimmer
253
253
  brand_new = @dom.nil? || old_element.empty? || !options[:parent].to_s.empty? || brand_new
254
254
  build_dom(layout: !custom_parent_dom_element) # TODO handle custom parent layout by passing parent instead of parent dom element
255
255
  if brand_new
256
- # TODO make a method attach to allow subclasses to override if needed
257
256
  attach(the_parent_dom_element)
258
257
  else
259
258
  reattach(old_element)
@@ -336,6 +335,7 @@ module Glimmer
336
335
  end
337
336
  html_options[:class] ||= ''
338
337
  html_options[:class] = "#{html_options[:class]} #{body_class}".strip
338
+ html_options['data-turbo'] = 'false' if parent.nil?
339
339
  html_options
340
340
  end
341
341
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.4.0
89
+ version: 1.4.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.4.0
96
+ version: 1.4.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: opal-jquery
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.5.0
103
+ version: 0.5.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.5.0
110
+ version: 0.5.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: to_collection
113
113
  requirement: !ruby/object:Gem::Requirement