From 6aeeba96e5d4d2fdaea6dcc699304167b3e064cc Mon Sep 17 00:00:00 2001 From: Adrian Salceanu Date: Tue, 29 Aug 2023 13:36:14 +0200 Subject: [PATCH 1/3] fixes --- src/ReactiveTools.jl | 8 ++++---- src/Stipple.jl | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index 6a8d4d4b..c4444ed3 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -34,7 +34,7 @@ const HANDLERS = LittleDict{Module,Vector{Expr}}() const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}() function DEFAULT_LAYOUT(; title::String = "Genie App", meta::Dict{<:AbstractString,<:AbstractString} = Dict("og:title" => "Genie App")) - tags = Genie.Renderers.Html.for_each(x -> """\n """, meta) + tags = Genie.Renderers.Html.for_each(x -> """\n""", meta) """ @@ -616,7 +616,7 @@ macro handlers(typename, expr, handlers_fn_name = :handlers) i_start = i + 1 end end - + # model_to_storage is only needed when we add variables to an existing type. no_new_vars = findfirst(x -> x isa Expr, initcode.args) === nothing # if we redefine a type newtype is true @@ -963,14 +963,14 @@ for f in (:methods, :watch, :computed) @$($f_str)(App, expr) Defines js functions for the `$($f_str)` section of the vue element. - + `expr` can be - `String` containing javascript code - `Pair` of function name and function code - `Function` returning String of javascript code - `Dict` of function names and function code - `Vector` of the above - + ### Example 1 ```julia diff --git a/src/Stipple.jl b/src/Stipple.jl index 62f5af07..a5e22aa9 100644 --- a/src/Stipple.jl +++ b/src/Stipple.jl @@ -29,10 +29,10 @@ will import all names from Parent.MyModule except `x` and `y`. Currently suports macro using_except(expr) # check validity expr isa Expr && (expr.args[1] == :(:) || (expr.args[1].head == :call && expr.args[1].args[1] == :(:))) || return - + # determine module name and list of excluded symbols m, excluded = expr.args[1] == :(:) ? (expr.args[2], Symbol[expr.args[3]]) : (expr.args[1].args[2], Symbol[s for s in vcat([expr.args[1].args[3]], expr.args[2:end])]) - + # convert m.args to list of Symbols if m isa Expr m.args[2] = m.args[2].value @@ -41,9 +41,9 @@ macro using_except(expr) m.args[2] = m.args[2].args[2].value end end - + m_name = m isa Expr ? m.args[end] : m - + # as a first step use only the module name # by constructing `using Parent.MyModuleName: MyModule` expr = :(using dummy1: dummy2) @@ -61,7 +61,7 @@ macro using_except(expr) # re-use previous expression and insert the names to be imported expr.args[1].args = pushfirst!(args, expr.args[1].args[1]) - + @debug(expr) expr end @@ -459,7 +459,7 @@ function init(::Type{M}; try haskey(payload, "sesstoken") && ! isempty(payload["sesstoken"]) && - Genie.Router.params!(Stipple.ModelStorage.Sessions.GenieSession.PARAMS_SESSION_KEY, + Genie.Router.params!(:session, Stipple.ModelStorage.Sessions.GenieSession.load(payload["sesstoken"] |> Genie.Encryption.decrypt)) catch ex @error ex From 7e8b66880ae82161f144b6dd3d141caa76ce9bd8 Mon Sep 17 00:00:00 2001 From: Adrian Salceanu Date: Tue, 12 Sep 2023 12:15:33 +0300 Subject: [PATCH 2/3] No default "og:title" --- src/ReactiveTools.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index ac53153b..a6b7bee5 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -33,7 +33,8 @@ const REACTIVE_STORAGE = LittleDict{Module,LittleDict{Symbol,Expr}}() const HANDLERS = LittleDict{Module,Vector{Expr}}() const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}() -function DEFAULT_LAYOUT(; title::String = "Genie App", meta::Dict{<:AbstractString,<:AbstractString} = Dict("og:title" => "Genie App")) +function DEFAULT_LAYOUT(; title::String = "Genie App", + meta::Dict{<:AbstractString,<:AbstractString} = Dict()) tags = Genie.Renderers.Html.for_each(x -> """\n""", meta) """ From b7f95de9b8faee96b0c6672382da34457a2c6936 Mon Sep 17 00:00:00 2001 From: Adrian Salceanu Date: Tue, 12 Sep 2023 13:06:45 +0300 Subject: [PATCH 3/3] Fix rendering of fields --- src/Elements.jl | 2 +- src/ReactiveTools.jl | 4 ++-- src/stipple/rendering.jl | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Elements.jl b/src/Elements.jl index 32e9d09c..380772db 100644 --- a/src/Elements.jl +++ b/src/Elements.jl @@ -328,7 +328,7 @@ Sometimes preprocessing of the events is necessary, e.g. to add or skip informat ``` """ macro on(arg, expr, preprocess = nothing) - kw = Symbol("v-on:", arg isa String ? arg : arg isa QuoteNode ? arg.value : arg.head == :vect ? join(lstrip.(string.(arg.args), ':'), '.') : + kw = Symbol("v-on:", arg isa String ? arg : arg isa QuoteNode ? arg.value : arg.head == :vect ? join(lstrip.(string.(arg.args), ':'), '.') : throw("Value '$arg' for `arg` not supported. `arg` should be of type Symbol, String, or Vector{Union{String, Symbol}}")) isevent = expr isa QuoteNode && expr.value isa Symbol diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index ab91a826..76e87f77 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -34,8 +34,8 @@ const HANDLERS = LittleDict{Module,Vector{Expr}}() const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}() function DEFAULT_LAYOUT(; title::String = "Genie App", - meta::Dict{<:AbstractString,<:AbstractString} = Dict()) - tags = Genie.Renderers.Html.for_each(x -> """\n""", meta) + meta::D = Dict()) where {D <:AbstractDict} + tags = Genie.Renderers.Html.for_each(x -> """\n""", meta) """ diff --git a/src/stipple/rendering.jl b/src/stipple/rendering.jl index 4fc0af32..f721a6c3 100644 --- a/src/stipple/rendering.jl +++ b/src/stipple/rendering.jl @@ -1,5 +1,5 @@ """ - join_js(xx, delim = ""; skip_empty = true, pre::Function = identity, + join_js(xx, delim = ""; skip_empty = true, pre::Function = identity, strip_delimiter = true, pre_delim::Union{Function,Nothing} = nothing) Join elements of an iterator similar to [`join`](@ref) with additonal features @@ -86,7 +86,7 @@ function julia_to_vue(field, mapping_keys = mapping_keys()) :: String extraparts = map((x) -> uppercasefirst(string(x)), parts[2:end]) string(parts[1], join(extraparts)) else - parts |> string + join(parts) |> string end else field |> string