fix the sending logic

This commit is contained in:
Torsten 2023-02-08 22:49:47 +02:00
parent 9080e458c4
commit 654b989e90
8 changed files with 58 additions and 33 deletions

View File

@ -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"

View File

@ -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

View File

@ -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")

View File

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@ -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

View File

@ -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.

View File

@ -29,6 +29,7 @@ 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"

View File

@ -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