glimmer-dsl-web 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +636 -0
- data/VERSION +1 -0
- data/app/assets/stylesheets/glimmer/glimmer.css +15 -0
- data/glimmer-dsl-web.gemspec +67 -0
- data/lib/glimmer/config/opal_logger.rb +16 -0
- data/lib/glimmer/data_binding/element_binding.rb +36 -0
- data/lib/glimmer/data_binding/observable_element.rb +14 -0
- data/lib/glimmer/dsl/web/dsl.rb +24 -0
- data/lib/glimmer/dsl/web/element_expression.rb +37 -0
- data/lib/glimmer/util/proc_tracker.rb +50 -0
- data/lib/glimmer/web/element_proxy.rb +1058 -0
- data/lib/glimmer/web/property_owner.rb +24 -0
- data/lib/glimmer/web.rb +25 -0
- data/lib/glimmer-dsl-web/ext/class.rb +10 -0
- data/lib/glimmer-dsl-web/ext/date.rb +60 -0
- data/lib/glimmer-dsl-web/ext/exception.rb +6 -0
- data/lib/glimmer-dsl-web/samples/hello/hello_world.rb +29 -0
- data/lib/glimmer-dsl-web/vendor/jquery.js +10881 -0
- data/lib/glimmer-dsl-web.rb +99 -0
- metadata +295 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8f25d5b94aa413809d21b46a16bbbe525b3166ff6dc62789942410465795858c
|
4
|
+
data.tar.gz: 611add41ae0b8db1e9e964be7dbcecc6b046dafac023e109ab9c6e4f51943c24
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8cde325767663eaf70334758888a1c65708b77b41a626f3ad1d990135ebbf8aa424457cf79026d4893a62968b7737661ec5f89cede81f98632a7f69be53e1e59
|
7
|
+
data.tar.gz: f9d3a94e629ca6eae4663df1e1eb89f5b4f013c225aa1948e7c8acc8420061f9740559dc8a591388720f214646d0a62ab9e5f77265ed34faeb0437c1ea18fb6c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.0.1
|
4
|
+
|
5
|
+
- Render top-level HTML element + attributes under a root parent element by specifying `root: 'css_selector'` option (e.g. `div(root: 'css_selector')`)
|
6
|
+
- Render nested HTML element + attributes by nesting under another HTML element (`div(root: 'css_selector') { span }`)
|
7
|
+
- Render `String` text content as the return value of the block of an HTML element (`div(root: 'css_selector') { "Hello, World!" }`)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2023 Andy Maleh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,636 @@
|
|
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.0.1
|
2
|
+
## Ruby in the Browser Web GUI Library
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-web.svg)](http://badge.fury.io/rb/glimmer-dsl-web)
|
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)
|
5
|
+
|
6
|
+
This project is inspired-by [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) and is similar in enabling frontend GUI development with Ruby, but it mainly differs from Glimmer DSL for Opal by adopting a DSL that follows web-like HTML syntax in Ruby (enabling transfer of HTML/CSS/JS skills) instead of adopting a desktop GUI DSL that is webified. Also, it will begin by supporting [Opal Ruby](https://opalrb.com/), but it might grow to support [Ruby WASM](https://github.com/ruby/ruby.wasm) as an alternative to [Opal Ruby](https://opalrb.com/) that could be switched to with a simple configuration change.
|
7
|
+
|
8
|
+
### You can finally live in pure Rubyland on the web!
|
9
|
+
|
10
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for Web is an upcoming **pre-alpha** [gem](https://rubygems.org/gems/glimmer-dsl-web) that enables building web GUI in pure Ruby via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/) (and potentially [Ruby WASM](https://github.com/ruby/ruby.wasm) in the future).
|
11
|
+
|
12
|
+
**Hello, World! Sample**
|
13
|
+
|
14
|
+
Initial HTML Markup:
|
15
|
+
|
16
|
+
```html
|
17
|
+
<div id="app-container">
|
18
|
+
</div>
|
19
|
+
```
|
20
|
+
|
21
|
+
Glimmer GUI code:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'glimmer-dsl-web'
|
25
|
+
|
26
|
+
include Glimmer
|
27
|
+
|
28
|
+
# This will hook into element #application and then build HTML inside it using Ruby DSL code
|
29
|
+
div(root: '#app-container') {
|
30
|
+
label(class: 'greeting') {
|
31
|
+
'Hello, World!'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
```
|
35
|
+
|
36
|
+
That produces:
|
37
|
+
|
38
|
+
```html
|
39
|
+
<div id="app-container">
|
40
|
+
<div root="#app-container" id="element-1" class="element">
|
41
|
+
<label class="greeting element" id="element-2">
|
42
|
+
Hello, World!
|
43
|
+
</label>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
```
|
47
|
+
|
48
|
+
**Hello, Button! Sample**
|
49
|
+
|
50
|
+
**UPCOMING (NOT RELEASED OR SUPPORTED YET)**
|
51
|
+
|
52
|
+
Glimmer GUI code demonstrating MVC + Glimmer Web Components (Views) + Data-Binding:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
require 'glimmer-dsl-web'
|
56
|
+
|
57
|
+
class Counter
|
58
|
+
attr_accessor :count
|
59
|
+
|
60
|
+
def initialize
|
61
|
+
self.count = 0
|
62
|
+
end
|
63
|
+
|
64
|
+
def increment!
|
65
|
+
self.count += 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class HelloButton
|
70
|
+
include Glimmer::Web::Component
|
71
|
+
|
72
|
+
before_render do
|
73
|
+
@counter = Counter.new
|
74
|
+
end
|
75
|
+
|
76
|
+
markup {
|
77
|
+
# This will hook into element #application and then build HTML inside it using Ruby DSL code
|
78
|
+
div(root_css_selector) {
|
79
|
+
text 'Hello, Button!'
|
80
|
+
|
81
|
+
button {
|
82
|
+
# Unidirectional Data-Binding indicating that on every change to @counter.count, the value
|
83
|
+
# is read and converted to "Click To Increment: #{value} ", and then automatically
|
84
|
+
# copied to button innerText (content) to display to the user
|
85
|
+
inner_text <= [@counter, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
|
86
|
+
|
87
|
+
on_click {
|
88
|
+
@counter.increment!
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
HelloButton.render('#application')
|
96
|
+
```
|
97
|
+
|
98
|
+
That produces:
|
99
|
+
|
100
|
+
```html
|
101
|
+
<div id="application">
|
102
|
+
<button>
|
103
|
+
Click To Increment: 0
|
104
|
+
</button>
|
105
|
+
</div>
|
106
|
+
```
|
107
|
+
|
108
|
+
When clicked:
|
109
|
+
|
110
|
+
```html
|
111
|
+
<div id="application">
|
112
|
+
<button>
|
113
|
+
Click To Increment: 1
|
114
|
+
</button>
|
115
|
+
</div>
|
116
|
+
```
|
117
|
+
|
118
|
+
When clicked 7 times:
|
119
|
+
|
120
|
+
```html
|
121
|
+
<div id="application">
|
122
|
+
<button>
|
123
|
+
Click To Increment: 7
|
124
|
+
</button>
|
125
|
+
</div>
|
126
|
+
```
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
NOTE: Glimmer DSL for Web is a pre-alpha project. If you want it developed faster, please [open an issue report](https://github.com/AndyObtiva/glimmer-dsl-web/issues/new). I have completed some GitHub project features much faster before due to [issue reports](https://github.com/AndyObtiva/glimmer-dsl-web/issues) and [pull requests](https://github.com/AndyObtiva/glimmer-dsl-web/pulls). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
131
|
+
|
132
|
+
Learn more about the differences between various [Glimmer](https://github.com/AndyObtiva/glimmer) DSLs by looking at:
|
133
|
+
|
134
|
+
**[Glimmer DSL Comparison Table](https://github.com/AndyObtiva/glimmer#glimmer-dsl-comparison-table)**.
|
135
|
+
|
136
|
+
## Table of Contents
|
137
|
+
|
138
|
+
- [Glimmer DSL for Web](#-glimmer-dsl-for-opal-alpha-pure-ruby-web-gui)
|
139
|
+
- [Principles](#principles)
|
140
|
+
- [Background](#background)
|
141
|
+
- [Prerequisites](#prerequisites)
|
142
|
+
- [Setup](#setup)
|
143
|
+
- [Supported Glimmer DSL Keywords](#supported-glimmer-dsl-keywords)
|
144
|
+
- [Samples](#samples)
|
145
|
+
- [Hello Samples](#hello-samples)
|
146
|
+
- [Hello, World!](#hello-world)
|
147
|
+
- [Hello, Button!](#hello-button)
|
148
|
+
- [Glimmer Process](#glimmer-process)
|
149
|
+
- [Help](#help)
|
150
|
+
- [Issues](#issues)
|
151
|
+
- [Chat](#chat)
|
152
|
+
- [Feature Suggestions](#feature-suggestions)
|
153
|
+
- [Change Log](#change-log)
|
154
|
+
- [Contributing](#contributing)
|
155
|
+
- [Contributors](#contributors)
|
156
|
+
- [License](#license)
|
157
|
+
|
158
|
+
## Prerequisites
|
159
|
+
|
160
|
+
- Rails 6-7: [https://github.com/rails/rails](https://github.com/rails/rails)
|
161
|
+
- Opal 1.4.1 for Rails 6-7 or Opal 1.0.5 for Rails 5: [https://github.com/opal/opal](https://github.com/opal/opal)
|
162
|
+
- Opal-Rails 2.0.2 for Rails 6-7 or Opal-Rails 1.1.2 for Rails 5: [https://github.com/opal/opal-rails](https://github.com/opal/opal-rails)
|
163
|
+
- jQuery 3 (included): [https://code.jquery.com/](https://code.jquery.com/) (jQuery 3.6.0 is included in the [glimmer-dsl-web](https://rubygems.org/gems/glimmer-dsl-web) gem)
|
164
|
+
|
165
|
+
## Setup
|
166
|
+
|
167
|
+
(NOTE: Keep in mind this is a very early experimental and incomplete **alpha**. If you run into issues, try to go back to a [previous revision](https://rubygems.org/gems/glimmer-dsl-web/versions). Also, there is a slight chance any issues you encounter are fixed in master or some other branch that you could check out instead)
|
168
|
+
|
169
|
+
The [glimmer-dsl-web](https://rubygems.org/gems/glimmer-dsl-web) gem is a [Rails Engine](https://guides.rubyonrails.org/engines.html) gem that includes assets.
|
170
|
+
|
171
|
+
### Rails 7
|
172
|
+
|
173
|
+
Please follow the following steps to setup.
|
174
|
+
|
175
|
+
Install a Rails 7 gem:
|
176
|
+
|
177
|
+
```
|
178
|
+
gem install rails -v7.0.1
|
179
|
+
```
|
180
|
+
|
181
|
+
Start a new Rails 7 app:
|
182
|
+
|
183
|
+
```
|
184
|
+
rails new glimmer_app_server
|
185
|
+
```
|
186
|
+
|
187
|
+
Add the following to `Gemfile`:
|
188
|
+
|
189
|
+
```
|
190
|
+
gem 'opal', '1.4.1'
|
191
|
+
gem 'opal-rails', '2.0.2'
|
192
|
+
gem 'opal-async', '~> 1.4.0'
|
193
|
+
gem 'opal-jquery', '~> 0.4.6'
|
194
|
+
gem 'glimmer-dsl-web', '~> 0.0.1'
|
195
|
+
gem 'glimmer-dsl-xml', '~> 1.3.1', require: false
|
196
|
+
gem 'glimmer-dsl-css', '~> 1.2.1', require: false
|
197
|
+
```
|
198
|
+
|
199
|
+
Run:
|
200
|
+
|
201
|
+
```
|
202
|
+
bundle
|
203
|
+
```
|
204
|
+
|
205
|
+
Follow [opal-rails](https://github.com/opal/opal-rails) instructions, basically running:
|
206
|
+
|
207
|
+
```
|
208
|
+
bin/rails g opal:install
|
209
|
+
```
|
210
|
+
|
211
|
+
Edit `config/initializers/assets.rb` and add the following at the bottom:
|
212
|
+
```
|
213
|
+
Opal.use_gem 'glimmer-dsl-web'
|
214
|
+
```
|
215
|
+
|
216
|
+
Run:
|
217
|
+
|
218
|
+
```
|
219
|
+
rails g scaffold welcome
|
220
|
+
```
|
221
|
+
|
222
|
+
Run:
|
223
|
+
|
224
|
+
```
|
225
|
+
rails db:migrate
|
226
|
+
```
|
227
|
+
|
228
|
+
Add the following to `config/routes.rb` inside the `Rails.application.routes.draw` block:
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
mount Glimmer::Engine => "/glimmer" # add on top
|
232
|
+
root to: 'welcomes#index'
|
233
|
+
```
|
234
|
+
|
235
|
+
Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
|
236
|
+
|
237
|
+
```erb
|
238
|
+
<%= stylesheet_link_tag 'glimmer/glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
|
239
|
+
```
|
240
|
+
|
241
|
+
Clear the file `app/views/welcomes/index.html.erb` completely from all content.
|
242
|
+
|
243
|
+
Delete `app/javascript/application.js`
|
244
|
+
|
245
|
+
Edit and replace `app/assets/javascript/application.js.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below):
|
246
|
+
|
247
|
+
```ruby
|
248
|
+
require 'glimmer-dsl-web' # brings opal and other dependencies automatically
|
249
|
+
|
250
|
+
# Add more require-statements or Glimmer GUI DSL code
|
251
|
+
```
|
252
|
+
|
253
|
+
Example to confirm setup is working:
|
254
|
+
|
255
|
+
Initial HTML Markup:
|
256
|
+
|
257
|
+
```html
|
258
|
+
<div id="app-container">
|
259
|
+
</div>
|
260
|
+
```
|
261
|
+
|
262
|
+
Glimmer GUI code:
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
require 'glimmer-dsl-web'
|
266
|
+
|
267
|
+
include Glimmer
|
268
|
+
|
269
|
+
# This will hook into element #application and then build HTML inside it using Ruby DSL code
|
270
|
+
div(root: '#app-container') {
|
271
|
+
label(class: 'greeting') {
|
272
|
+
'Hello, World!'
|
273
|
+
}
|
274
|
+
}
|
275
|
+
```
|
276
|
+
|
277
|
+
That produces:
|
278
|
+
|
279
|
+
```html
|
280
|
+
<div id="app-container">
|
281
|
+
<div root="#app-container" id="element-1" class="element">
|
282
|
+
<label class="greeting element" id="element-2">
|
283
|
+
Hello, World!
|
284
|
+
</label>
|
285
|
+
</div>
|
286
|
+
</div>
|
287
|
+
```
|
288
|
+
|
289
|
+
Start the Rails server:
|
290
|
+
```
|
291
|
+
rails s
|
292
|
+
```
|
293
|
+
|
294
|
+
Visit `http://localhost:3000`
|
295
|
+
|
296
|
+
You should see:
|
297
|
+
|
298
|
+
![setup is working](/images/glimmer-dsl-web-setup-example-working.png)
|
299
|
+
|
300
|
+
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).
|
301
|
+
|
302
|
+
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).
|
303
|
+
|
304
|
+
### Rails 6
|
305
|
+
|
306
|
+
Please follow the following steps to setup.
|
307
|
+
|
308
|
+
Install a Rails 6 gem:
|
309
|
+
|
310
|
+
```
|
311
|
+
gem install rails -v6.1.4.6
|
312
|
+
```
|
313
|
+
|
314
|
+
Start a new Rails 6 app (skipping webpack):
|
315
|
+
|
316
|
+
```
|
317
|
+
rails new glimmer_app_server --skip-webpack-install
|
318
|
+
```
|
319
|
+
|
320
|
+
Disable the `webpacker` gem line in `Gemfile`:
|
321
|
+
|
322
|
+
```ruby
|
323
|
+
# gem 'webpacker', '~> 5.0'
|
324
|
+
```
|
325
|
+
|
326
|
+
Add the following to `Gemfile`:
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
gem 'opal', '1.4.1'
|
330
|
+
gem 'opal-rails', '2.0.2'
|
331
|
+
gem 'opal-async', '~> 1.4.0'
|
332
|
+
gem 'opal-jquery', '~> 0.4.6'
|
333
|
+
gem 'glimmer-dsl-web', '~> 0.0.1'
|
334
|
+
gem 'glimmer-dsl-xml', '~> 1.3.1', require: false
|
335
|
+
gem 'glimmer-dsl-css', '~> 1.2.1', require: false
|
336
|
+
```
|
337
|
+
|
338
|
+
Run:
|
339
|
+
|
340
|
+
```
|
341
|
+
bundle
|
342
|
+
```
|
343
|
+
|
344
|
+
Follow [opal-rails](https://github.com/opal/opal-rails) instructions, basically running:
|
345
|
+
|
346
|
+
```
|
347
|
+
bin/rails g opal:install
|
348
|
+
```
|
349
|
+
|
350
|
+
Edit `config/initializers/assets.rb` and add the following at the bottom:
|
351
|
+
```
|
352
|
+
Opal.use_gem 'glimmer-dsl-web'
|
353
|
+
```
|
354
|
+
|
355
|
+
Run:
|
356
|
+
|
357
|
+
```
|
358
|
+
rails g scaffold welcome
|
359
|
+
```
|
360
|
+
|
361
|
+
Run:
|
362
|
+
|
363
|
+
```
|
364
|
+
rails db:migrate
|
365
|
+
```
|
366
|
+
|
367
|
+
Add the following to `config/routes.rb` inside the `Rails.application.routes.draw` block:
|
368
|
+
|
369
|
+
```ruby
|
370
|
+
mount Glimmer::Engine => "/glimmer" # add on top
|
371
|
+
root to: 'welcomes#index'
|
372
|
+
```
|
373
|
+
|
374
|
+
Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
|
375
|
+
|
376
|
+
```erb
|
377
|
+
<%= stylesheet_link_tag 'glimmer/glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
|
378
|
+
```
|
379
|
+
|
380
|
+
Also, delete the following line:
|
381
|
+
|
382
|
+
```erb
|
383
|
+
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
384
|
+
```
|
385
|
+
|
386
|
+
Clear the file `app/views/welcomes/index.html.erb` completely from all content.
|
387
|
+
|
388
|
+
Edit and replace `app/assets/javascript/application.js.rb` content with code below (optionally including a require statement for one of the [samples](#samples) below):
|
389
|
+
|
390
|
+
```ruby
|
391
|
+
require 'glimmer-dsl-web' # brings opal and other dependencies automatically
|
392
|
+
|
393
|
+
# Add more require-statements or Glimmer GUI DSL code
|
394
|
+
```
|
395
|
+
|
396
|
+
Example to confirm setup is working:
|
397
|
+
|
398
|
+
Initial HTML Markup:
|
399
|
+
|
400
|
+
```html
|
401
|
+
<div id="app-container">
|
402
|
+
</div>
|
403
|
+
```
|
404
|
+
|
405
|
+
Glimmer GUI code:
|
406
|
+
|
407
|
+
```ruby
|
408
|
+
require 'glimmer-dsl-web'
|
409
|
+
|
410
|
+
include Glimmer
|
411
|
+
|
412
|
+
# This will hook into element #application and then build HTML inside it using Ruby DSL code
|
413
|
+
div(root: '#app-container') {
|
414
|
+
label(class: 'greeting') {
|
415
|
+
'Hello, World!'
|
416
|
+
}
|
417
|
+
}
|
418
|
+
```
|
419
|
+
|
420
|
+
That produces:
|
421
|
+
|
422
|
+
```html
|
423
|
+
<div id="app-container">
|
424
|
+
<div root="#app-container" id="element-1" class="element">
|
425
|
+
<label class="greeting element" id="element-2">
|
426
|
+
Hello, World!
|
427
|
+
</label>
|
428
|
+
</div>
|
429
|
+
</div>
|
430
|
+
```
|
431
|
+
|
432
|
+
Start the Rails server:
|
433
|
+
```
|
434
|
+
rails s
|
435
|
+
```
|
436
|
+
|
437
|
+
Visit `http://localhost:3000`
|
438
|
+
|
439
|
+
You should see:
|
440
|
+
|
441
|
+
![setup is working](/images/glimmer-dsl-web-setup-example-working.png)
|
442
|
+
|
443
|
+
**NOT RELEASED OR SUPPORTED YET**
|
444
|
+
|
445
|
+
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).
|
446
|
+
|
447
|
+
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).
|
448
|
+
|
449
|
+
## Supported Glimmer DSL Keywords
|
450
|
+
|
451
|
+
All HTML elements.
|
452
|
+
|
453
|
+
All HTML attributes.
|
454
|
+
|
455
|
+
## Samples
|
456
|
+
|
457
|
+
This external sample app contains all the samples mentioned below configured inside a Rails [Opal](https://opalrb.com/) app with all the prerequisites ready to go for convenience:
|
458
|
+
|
459
|
+
https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails7-app
|
460
|
+
|
461
|
+
**[NOT RELEASED OR SUPPORTED YET]** https://github.com/AndyObtiva/sample-glimmer-dsl-web-rails-app
|
462
|
+
|
463
|
+
### Hello Samples
|
464
|
+
|
465
|
+
#### Hello, World!
|
466
|
+
|
467
|
+
Initial HTML Markup:
|
468
|
+
|
469
|
+
```html
|
470
|
+
<div id="app-container">
|
471
|
+
</div>
|
472
|
+
```
|
473
|
+
|
474
|
+
Glimmer GUI code:
|
475
|
+
|
476
|
+
```ruby
|
477
|
+
require 'glimmer-dsl-web'
|
478
|
+
|
479
|
+
include Glimmer
|
480
|
+
|
481
|
+
# This will hook into element #application and then build HTML inside it using Ruby DSL code
|
482
|
+
div(root: '#application') {
|
483
|
+
label(class: 'greeting') {
|
484
|
+
'Hello, World!'
|
485
|
+
}
|
486
|
+
}
|
487
|
+
```
|
488
|
+
|
489
|
+
That produces:
|
490
|
+
|
491
|
+
```html
|
492
|
+
<div id="app-container">
|
493
|
+
<div root="#app-container" id="element-1" class="element">
|
494
|
+
<label class="greeting element" id="element-2">
|
495
|
+
Hello, World!
|
496
|
+
</label>
|
497
|
+
</div>
|
498
|
+
</div>
|
499
|
+
```
|
500
|
+
|
501
|
+
#### Hello, Button!
|
502
|
+
|
503
|
+
**UPCOMING (NOT RELEASED OR SUPPORTED YET)**
|
504
|
+
|
505
|
+
Glimmer GUI code demonstrating MVC + Glimmer Web Components (Views) + Data-Binding:
|
506
|
+
|
507
|
+
```ruby
|
508
|
+
require 'glimmer-dsl-web'
|
509
|
+
|
510
|
+
class Counter
|
511
|
+
attr_accessor :count
|
512
|
+
|
513
|
+
def initialize
|
514
|
+
self.count = 0
|
515
|
+
end
|
516
|
+
|
517
|
+
def increment!
|
518
|
+
self.count += 1
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
class HelloButton
|
523
|
+
include Glimmer::Web::Component
|
524
|
+
|
525
|
+
before_render do
|
526
|
+
@counter = Counter.new
|
527
|
+
end
|
528
|
+
|
529
|
+
markup {
|
530
|
+
# This will hook into element #application and then build HTML inside it using Ruby DSL code
|
531
|
+
div(root_css_selector) {
|
532
|
+
text 'Hello, Button!'
|
533
|
+
|
534
|
+
button {
|
535
|
+
# Unidirectional Data-Binding indicating that on every change to @counter.count, the value
|
536
|
+
# is read and converted to "Click To Increment: #{value} ", and then automatically
|
537
|
+
# copied to button innerText (content) to display to the user
|
538
|
+
inner_text <= [@counter, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
|
539
|
+
|
540
|
+
on_click {
|
541
|
+
@counter.increment!
|
542
|
+
}
|
543
|
+
}
|
544
|
+
}
|
545
|
+
}
|
546
|
+
end
|
547
|
+
|
548
|
+
HelloButton.render('#application')
|
549
|
+
```
|
550
|
+
|
551
|
+
That produces:
|
552
|
+
|
553
|
+
```html
|
554
|
+
<div id="application">
|
555
|
+
<button>
|
556
|
+
Click To Increment: 0
|
557
|
+
</button>
|
558
|
+
</div>
|
559
|
+
```
|
560
|
+
|
561
|
+
When clicked:
|
562
|
+
|
563
|
+
```html
|
564
|
+
<div id="application">
|
565
|
+
<button>
|
566
|
+
Click To Increment: 1
|
567
|
+
</button>
|
568
|
+
</div>
|
569
|
+
```
|
570
|
+
|
571
|
+
When clicked 7 times:
|
572
|
+
|
573
|
+
```html
|
574
|
+
<div id="application">
|
575
|
+
<button>
|
576
|
+
Click To Increment: 7
|
577
|
+
</button>
|
578
|
+
</div>
|
579
|
+
```
|
580
|
+
|
581
|
+
## Glimmer Supporting Libraries
|
582
|
+
|
583
|
+
Here is a list of notable 3rd party gems used by Glimmer DSL for Web:
|
584
|
+
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML & HTML in pure Ruby.
|
585
|
+
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) in pure Ruby.
|
586
|
+
- [opal-async](https://github.com/AndyObtiva/opal-async): Non-blocking tasks and enumerators for Web.
|
587
|
+
- [to_collection](https://github.com/AndyObtiva/to_collection): Treat an array of objects and a singular object uniformly as a collection of objects.
|
588
|
+
|
589
|
+
## Glimmer Process
|
590
|
+
|
591
|
+
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) is the lightweight software development process used for building Glimmer libraries and Glimmer apps, which goes beyond Agile, rendering all Agile processes obsolete. [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) is simply made up of 7 guidelines to pick and choose as necessary until software development needs are satisfied.
|
592
|
+
|
593
|
+
Learn more by reading the [GPG](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) (Glimmer Process Guidelines)
|
594
|
+
|
595
|
+
## Help
|
596
|
+
|
597
|
+
### Issues
|
598
|
+
|
599
|
+
You may submit [issues](https://github.com/AndyObtiva/glimmer-dsl-web /issues) on [GitHub](https://github.com/AndyObtiva/glimmer-dsl-web /issues).
|
600
|
+
|
601
|
+
[Click here to submit an issue.](https://github.com/AndyObtiva/glimmer-dsl-web /issues)
|
602
|
+
|
603
|
+
### Chat
|
604
|
+
|
605
|
+
If you need live help, try to [![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)
|
606
|
+
|
607
|
+
## Feature Suggestions
|
608
|
+
|
609
|
+
These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
|
610
|
+
|
611
|
+
[TODO.md](TODO.md)
|
612
|
+
|
613
|
+
## Change Log
|
614
|
+
|
615
|
+
[CHANGELOG.md](CHANGELOG.md)
|
616
|
+
|
617
|
+
## Contributing
|
618
|
+
|
619
|
+
[CONTRIBUTING.md](CONTRIBUTING.md)
|
620
|
+
|
621
|
+
## Contributors
|
622
|
+
|
623
|
+
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|
624
|
+
|
625
|
+
[Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-web /graphs/contributors)
|
626
|
+
|
627
|
+
## License
|
628
|
+
|
629
|
+
[MIT](https://opensource.org/licenses/MIT)
|
630
|
+
|
631
|
+
Copyright (c) 2023 - Andy Maleh.
|
632
|
+
See [LICENSE.txt](LICENSE.txt) for further details.
|
633
|
+
|
634
|
+
--
|
635
|
+
|
636
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built for [Glimmer](https://github.com/AndyObtiva/glimmer) (DSL Framework).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|