diff --git a/dummy/Gemfile b/dummy/Gemfile
index 7f716c7..62c7e40 100644
--- a/dummy/Gemfile
+++ b/dummy/Gemfile
@@ -13,3 +13,5 @@ gem "sqlite3"
gem "active_hash"
gem "opal-rails"
+gem 'opal-optimizer', git: "https://github.com/hmdne/opal-optimizer" , require: false
+gem "terser"
diff --git a/dummy/Gemfile.lock b/dummy/Gemfile.lock
index 6333b73..9037983 100644
--- a/dummy/Gemfile.lock
+++ b/dummy/Gemfile.lock
@@ -1,3 +1,11 @@
+GIT
+ remote: https://github.com/hmdne/opal-optimizer
+ revision: d958b7f68bfcec7e4d28707b382138c9436db8be
+ specs:
+ opal-optimizer (0.1.7)
+ opal (>= 1.0.0)
+ rkelly-turbo
+
PATH
remote: ..
specs:
@@ -81,6 +89,7 @@ GEM
crass (1.0.6)
date (3.3.3)
erubi (1.12.0)
+ execjs (2.8.1)
globalid (1.1.0)
activesupport (>= 5.0)
haml (6.1.1)
@@ -169,6 +178,7 @@ GEM
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
+ rkelly-turbo (0.1.1)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
@@ -178,6 +188,8 @@ GEM
sprockets (>= 3.0.0)
sqlite3 (1.6.0-x86_64-linux)
temple (0.10.0)
+ terser (1.1.13)
+ execjs (>= 0.3.0, < 3)
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.1)
@@ -194,10 +206,12 @@ PLATFORMS
DEPENDENCIES
active_hash
haml-rails
+ opal-optimizer!
opal-rails
puma (= 5.6.5)
rails
sqlite3
+ terser
vue_r!
BUNDLED WITH
diff --git a/dummy/app/views/images/show.html.haml b/dummy/app/views/images/show.html.haml
index be3c93d..3db9acb 100644
--- a/dummy/app/views/images/show.html.haml
+++ b/dummy/app/views/images/show.html.haml
@@ -1,21 +1,29 @@
-#app
+#app.mt-40
.flex.justify-center
= #@image.attributes
.flex.justify-center
- %a.underline{ e_click: "bg_change" , r_class: 'back(50)'}
+ .p-20
{{ back }}
+ %a.p-20.underline{ e_click: "bg_change(200)" , r_class: 'back'}
+ {{ text1 }}
+ %a.p-20.underline{ e_click: "bg_change(100)" , r_class: 'back'}
+ {{ text2 }}
:opal
class Clicker < VueR::Application
- def bg_change
- self.state = !self.state
+ def bg_change(num)
+ self.state = num
end
- def back(arg)
- puts "Arg:#{arg}:#{arg.class}"
- str = self.state ? "bg-cyan-50" : "bg-cyan-200"
- str + " " + arg.to_s
+ def back
+ 'bg-cyan-' + self.state.to_s
+ end
+ def text1
+ "click for dark"
+ end
+ def text2
+ "click for light"
end
end
- click = Clicker.new(bg: 'bg-cyan-200' , state: true)
+ click = Clicker.new( state: 200)
click.mount("#app")
diff --git a/dummy/app/views/layouts/application.html.erb b/dummy/app/views/layouts/application.html.erb
deleted file mode 100644
index 274a398..0000000
--- a/dummy/app/views/layouts/application.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- Dummy
-
- <%= csrf_meta_tags %>
- <%= csp_meta_tag %>
-
- <%= stylesheet_link_tag "application" %>
- <%= javascript_include_tag "application" %>
-
-
-
- <%= yield %>
-
-
diff --git a/dummy/app/views/layouts/application.html.haml b/dummy/app/views/layouts/application.html.haml
new file mode 100644
index 0000000..34b9a51
--- /dev/null
+++ b/dummy/app/views/layouts/application.html.haml
@@ -0,0 +1,13 @@
+!!!
+%html
+ %head
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
+ %title Dummy
+ %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/
+ = csrf_meta_tags
+ = csp_meta_tag
+ = stylesheet_link_tag "application"
+ = javascript_include_tag "application"
+ %script{:src => "https://cdn.tailwindcss.com"}
+ %body
+ = yield
diff --git a/dummy/config/application.rb b/dummy/config/application.rb
index 82cac35..7b53a78 100644
--- a/dummy/config/application.rb
+++ b/dummy/config/application.rb
@@ -2,6 +2,7 @@ require_relative "boot"
require "rails/all"
require 'sprockets/railtie'
+#require "opal/optimizer/sprockets"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
diff --git a/dummy/config/environments/production.rb b/dummy/config/environments/production.rb
index b8e74f1..1244c89 100644
--- a/dummy/config/environments/production.rb
+++ b/dummy/config/environments/production.rb
@@ -29,7 +29,8 @@ Rails.application.configure do
# config.assets.js_compressor = :terser
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
-
+ config.assets.js_compressor = :terser
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"
diff --git a/opal/vue_r/application.rb b/opal/vue_r/application.rb
index e657184..aa1b8be 100644
--- a/opal/vue_r/application.rb
+++ b/opal/vue_r/application.rb
@@ -75,23 +75,25 @@ module VueR
end
def decompose(expression)
- matches = expression.match(/\b[^()]+\((.*)\)$/)
- return expression if matches.nil?
- method = expression.split("(").first
+ parts = expression.split("(")
+ method = parts.shift
+ raise "No nested brackets" if parts.length > 1
puts "METHOD:#{method}"
- return [method , [] ] if matches[1].empty?
- args = matches[1].split(",").collect{| arg | transform_arg(arg) }
+ return [method , [] ] if parts.empty?
+ args = parts.first.split(")").first.split(",")
+ args = args.collect{| arg | transform_arg(arg) }
return [method , args]
end
def transform_arg(argument)
arg = argument.strip
- #puts "Arg:#{arg}:"
+ puts "Arg:#{arg}:"
return true if arg == "true"
return false if arg == "false"
return nil if arg == "nil"
return arg.to_i if arg == arg.to_i.to_s
- return arg
+ arg.gsub('"' ,"").gsub("'" , "")
+
end
end
end