glimmer-dsl-opal 0.15.1 → 0.16.0

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: 724c0f462ad5dd94ef3eb8705f6ceb54b350c0f83976a6a7bb3f0506afe67f65
4
- data.tar.gz: 0ba2076cb72f46bbe855c746e80c3747d0d2834f73167266fb42752d873e6290
3
+ metadata.gz: f8072dfb955151aa374817c0f2f175bf9c7adfd115eca1bbd6df6c2c3b0725e4
4
+ data.tar.gz: 94304037d23dfe1719087fc93d3dc9056be7701f6fdac1044bfe2719e61e43b0
5
5
  SHA512:
6
- metadata.gz: c52727efe6e7efc09cffe80991ccddf6fb4ee69835ecb46f21321ab912997980f6dd9ba9fc68117ce5864f61d63809037139d64b741ff509f66dfda09a2ab0a1
7
- data.tar.gz: e00c6998ab192d91340f27567c29b2b6ee63a65680ec316d0a3c74353c0905a04ed2f3771423b527c7441ee6d2dd8870d7c758a09e8151dd0223a4e6053f8a7a
6
+ metadata.gz: 7f85477240562b1eb7c3bfb3e147577bf6ac7f265c54b6d5acad7ae295a65b1226ff41798eb2a8d41804d2c56d999992f6e6e98b64bde1bed5708c52c46862f0
7
+ data.tar.gz: 847b86e900e53586993c74982b37d68ede27f399982188187de524dec31b1d5ffdf0ffc31694da38510060f3e5224c71acc7ca85d75fdef398a8e42c287ca666
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.16.0
4
+
5
+ - Support label widget background_image attribute
6
+ - Have File.expand_path support expanding paths even if they did not base off of __dir__ or __FILE__
7
+ - Custom specification of gems having image paths via server-side configuration in Glimmer::Config.gems_having_image_paths
8
+
3
9
  ## 0.15.1
4
10
 
5
11
  - Auto-expose images of gems that depend on glimmer-dsl-opal as downloadable asset links providing `/glimmer/image_paths` server call to obtain them
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 Opal 0.15.1 (Pure Ruby Web GUI)
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 Opal 0.16.0 (Pure Ruby Web GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
3
3
  [![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)
4
4
 
@@ -14,6 +14,8 @@ Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com
14
14
 
15
15
  #### Hello, Table! Sample
16
16
 
17
+ Code: [lib/glimmer-dsl-opal/samples/hello/hello_table.rb](lib/glimmer-dsl-opal/samples/hello/hello_table.rb)
18
+
17
19
  Glimmer GUI code from [glimmer-dsl-opal/samples/hello/hello_table.rb](lib/glimmer-dsl-opal/samples/hello/hello_table.rb):
18
20
 
19
21
  ```ruby
@@ -141,7 +143,7 @@ Hello, Table! Game Booked
141
143
 
142
144
  NOTE: Glimmer DSL for Opal is an alpha project. 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.
143
145
 
144
- **Alpha Version** 0.15.1 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
146
+ **Alpha Version** 0.16.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
145
147
 
146
148
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
147
149
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -151,7 +153,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
151
153
 
152
154
  ## Table of Contents
153
155
 
154
- - [Glimmer DSL for Opal 0.15.1 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0151-pure-ruby-web-gui)
156
+ - [Glimmer DSL for Opal 0.16.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0160-pure-ruby-web-gui)
155
157
  - [Principles](#principles)
156
158
  - [Background](#background)
157
159
  - [Pre-requisites](#pre-requisites)
@@ -252,7 +254,7 @@ Add the following to `Gemfile`:
252
254
  gem 'opal-rails', '~> 1.1.2'
253
255
  gem 'opal-async', '~> 1.2.0'
254
256
  gem 'opal-jquery', '~> 0.4.4'
255
- gem 'glimmer-dsl-opal', '~> 0.15.1'
257
+ gem 'glimmer-dsl-opal', '~> 0.16.0'
256
258
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
257
259
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
258
260
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.1
1
+ 0.16.0
@@ -3,8 +3,13 @@ require 'fileutils'
3
3
  module Glimmer
4
4
  class ImagePathsController < ApplicationController
5
5
  def index
6
+ # TODO apply caching in the future to avoid recopying files on every request
6
7
  Gem.loaded_specs.map(&:last).select {|s| s.name == 'glimmer-dsl-opal' || s.dependencies.detect {|dep| dep.name == 'glimmer-dsl-opal'} }
7
- full_gem_specs = Gem.loaded_specs.map(&:last).select {|s| s.name == 'glimmer-dsl-opal' || s.dependencies.detect {|dep| dep.name == 'glimmer-dsl-swt'} }
8
+ full_gem_specs = Gem.loaded_specs.map(&:last).select do |s|
9
+ s.name == 'glimmer-dsl-opal' ||
10
+ Glimmer::Config.gems_having_image_paths.to_a.include?(s.name) || # consider turning into a Glimmer::Config server-side option
11
+ s.dependencies.detect {|dep| dep.name == 'glimmer-dsl-swt'}
12
+ end
8
13
  full_gem_paths = full_gem_specs.map {|gem_spec| gem_spec.full_gem_path}
9
14
  full_gem_names = full_gem_paths.map {|path| File.basename(path)}
10
15
  full_gem_image_path_collections = full_gem_paths.map do |gem_path|
@@ -32,7 +37,7 @@ module Glimmer
32
37
  end
33
38
  end
34
39
  download_gem_image_paths = download_gem_image_paths.map {|p| "/assets/#{p}"}
35
-
40
+
36
41
  # TODO apply a security white list
37
42
  render json: download_gem_image_paths
38
43
  end
@@ -102,5 +102,6 @@ if RUBY_ENGINE == 'opal'
102
102
  result ||= method == 'handle'
103
103
  end
104
104
  else
105
+ require_relative 'glimmer/config'
105
106
  require_relative 'glimmer/engine'
106
107
  end
@@ -37,22 +37,16 @@ class File
37
37
  alias expand_path_without_glimmer expand_path
38
38
  def expand_path(path, base=nil)
39
39
  get_image_paths unless image_paths
40
- if base
41
- path = expand_path_without_glimmer(path, base)
42
- end
40
+ path = expand_path_without_glimmer(path, base) if base
43
41
  path_include_dir_or_file = !!path.match(REGEXP_DIR_FILE)
44
- if !path_include_dir_or_file
45
- path
46
- else
47
- essential_path = path.split('(dir)').last.split('(file)').last
48
- image_paths.detect do |image_path|
49
- image_path.include?(essential_path)
50
- end
42
+ essential_path = path.split('(dir)').last.split('(file)').last.split('../').last.split('./').last
43
+ image_paths.detect do |image_path|
44
+ image_path.include?(essential_path)
51
45
  end
52
46
  end
53
47
 
54
48
  def get_image_paths
55
- image_paths_json = Net::HTTP.get(`window.location.origin`, '/glimmer/image_paths.json')
49
+ image_paths_json = Net::HTTP.get(`window.location.origin`, "/glimmer/image_paths.json")
56
50
  self.image_paths = JSON.parse(image_paths_json)
57
51
  end
58
52
 
@@ -0,0 +1,11 @@
1
+ module Glimmer
2
+ # Consumer Rails apps can set these attributes in their assets.rb file
3
+ module Config
4
+ class << self
5
+ # (server-side option) used to collect image paths for copying to assets & matching in Opal to download and use in Glimmer GUI
6
+ def gems_having_image_paths
7
+ @gems_having_image_paths ||= []
8
+ end
9
+ end
10
+ end
11
+ end
@@ -40,12 +40,12 @@ module Glimmer
40
40
  text&.gsub("\n", '<br />')
41
41
  end
42
42
 
43
- def background_image=(*image_options)
43
+ # def background_image=(*image_options)
44
44
  # TODO consider if there is a difference between background_image and image in label and to have one reuse the other
45
45
  # TODO finish implementation
46
46
  # @background_image = Glimmer::SWT::ImageProxy.create(*image_options)
47
47
  # dom_element.css('background-image', @background_image.image_data.dom_element.src)
48
- end
48
+ # end
49
49
 
50
50
  def image=(*image_options)
51
51
  # TODO finish implementation
@@ -53,6 +53,19 @@ module Glimmer
53
53
  # dom_element.css('background-image', @image.image_data.dom_element.src)
54
54
  end
55
55
 
56
+ # background image
57
+ def background_image
58
+ @background_image
59
+ end
60
+
61
+ # background image is stretched by default
62
+ def background_image=(value)
63
+ @background_image = value
64
+ dom_element.css('background-image', "url(#{background_image})")
65
+ dom_element.css('background-repeat', 'no-repeat')
66
+ dom_element.css('background-size', 'cover')
67
+ end
68
+
56
69
  def element
57
70
  'label'
58
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-12 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -324,6 +324,7 @@ files:
324
324
  - lib/glimmer-dsl-opal/vendor/jquery-ui/package.json
325
325
  - lib/glimmer-dsl-opal/vendor/jquery.js
326
326
  - lib/glimmer-dsl-swt.rb
327
+ - lib/glimmer/config.rb
327
328
  - lib/glimmer/config/opal_logger.rb
328
329
  - lib/glimmer/data_binding/element_binding.rb
329
330
  - lib/glimmer/data_binding/list_selection_binding.rb