Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Oct 11, 2024
2 parents 446ddab + d1291f4 commit 60ac830
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 22 deletions.
53 changes: 42 additions & 11 deletions src/Layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ using Genie, Stipple
export layout, add_css, remove_css
export page, app, row, column, cell, container, flexgrid_kwargs, htmldiv, @gutter

export theme
export theme, googlefonts_css, stipplecore_css, genie_footer

const THEMES = Ref(Function[])

const FLEXGRID_KWARGS = [:col, :xs, :sm, :md, :lg, :xl, :gutter, :xgutter, :ygutter]
Expand Down Expand Up @@ -122,6 +123,31 @@ function iscontainer(class)
false
end

function genie_footer()
ParsedHTMLString("""
<style>
._genie_logo {
background:url('https://genieframework.com/logos/genie/logo-simple-with-padding.svg') no-repeat;
background-size:40px;
padding-top:22px;
padding-right:10px;
color:transparent !important;
font-size:9pt;
}
._genie .row .col-12 { width:50%; margin:auto; }
</style>
<footer class='_genie container'>
<div class='row'>
<div class='col-12'>
<p class='text-muted credit' style='text-align:center;color:#8d99ae;'>Built with
<a href='https://genieframework.com' target='_blank' class='_genie_logo' ref='nofollow'>Genie</a>
</p>
</div>
</div>
</footer>
""")
end

function flexgrid_class(tag::Symbol, value::Union{String,Int,Nothing,Symbol} = -1, container = false)
gutter = container ? "q-col-gutter" : "q-gutter"
(value == -1 || value === nothing) && return ""
Expand Down Expand Up @@ -507,6 +533,19 @@ function htmldiv(args...;
Genie.Renderer.Html.div(args...; kwargs...)
end

function googlefonts_css()
(stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"),)
end

function stipplecore_css()
(stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore")),)
end

function coretheme()
stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"),
stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore"))
end

"""
function theme() :: String
Expand All @@ -528,20 +567,12 @@ julia> push!(Stipple.Layout.THEMES[], StippleUI.theme)
function theme(; core_theme::Bool = true) :: Vector{String}
output = String[]

if core_theme
push!(THEMES[], () -> begin
stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"),
stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore"))
end
)
end

unique!(THEMES[])
core_theme && coretheme THEMES[] && push!(output, coretheme()...)

for f in THEMES[]
push!(output, f()...)
end

output
end

Expand Down
6 changes: 4 additions & 2 deletions src/ReactiveTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}()
const HANDLERS_FUNCTIONS = LittleDict{Type{<:ReactiveModel},Function}()

function DEFAULT_LAYOUT(; title::String = "Genie App",
meta::D = Dict(), head_content::Union{AbstractString, Vector} = "") where {D <:AbstractDict}
meta::D = Dict(),
head_content::Union{AbstractString, Vector} = "",
core_theme::Bool = true) where {D <:AbstractDict}
tags = Genie.Renderers.Html.for_each(x -> """<meta name="$(string(x.first))" content="$(string(x.second))">\n""", meta)
"""
<!DOCTYPE html>
Expand Down Expand Up @@ -73,7 +75,7 @@ function DEFAULT_LAYOUT(; title::String = "Genie App",
<div class='container'>
<div class='row'>
<div class='col-12'>
<% Stipple.page(model, partial = true, v__cloak = true, [Stipple.Genie.Renderer.Html.@yield], Stipple.@if(:isready)) %>
<% Stipple.page(model, partial = true, v__cloak = true, [Stipple.Genie.Renderer.Html.@yield], Stipple.@if(:isready); core_theme = $core_theme) %>
</div>
</div>
</div>
Expand Down
26 changes: 17 additions & 9 deletions src/Stipple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,9 @@ using Stipple.ReactiveTools
@compile_workload begin
# all calls in this block will be precompiled, regardless of whether
# they belong to your package or not (on Julia 1.8 and higher)
# set secret in order to avoid automatic generation of a new one,
# which would invalidate the precompiled file
Genie.Secrets.secret_token!(repeat("f", 64))
ui() = [cell("hello"), row("world"), htmldiv("Hello World")]

@app PrecompileApp begin
Expand All @@ -1277,15 +1280,20 @@ using Stipple.ReactiveTools
end
port = tryparse(Int, get(ENV, "STIPPLE_PRECOMPILE_PORT", ""))
port === nothing && (port = rand(8081:8999))
up(port)

precompile_get = tryparse(Bool, get(ENV, "STIPPLE_PRECOMPILE_GET", "1"))
precompile_get === true && HTTP.get("http://localhost:$port")
# The following lines (still) produce an error although
# they pass at the repl. Not very important though.
# HTTP.get("http://localhost:$port$(Genie.Assets.asset_path(Genie.assets_config, :js, file = "channels"))")
# HTTP.get("http://localhost:$port$(Genie.Assets.asset_path(assets_config, :js, file = "stipplecore"))")
down()

Logging.with_logger(Logging.SimpleLogger(stdout, Logging.Error)) do
up(port)

precompile_get = tryparse(Bool, get(ENV, "STIPPLE_PRECOMPILE_GET", "1"))
precompile_get === true && HTTP.get("http://localhost:$port")
# The following lines (still) produce an error although
# they pass at the repl. Not very important though.
# HTTP.get("http://localhost:$port$(Genie.Assets.asset_path(Genie.assets_config, :js, file = "channels"))")
# HTTP.get("http://localhost:$port$(Genie.Assets.asset_path(assets_config, :js, file = "stipplecore"))")
down()
end
# reset secret back to empty string
Genie.Secrets.secret_token!("")
end
PRECOMPILE[] = false
end
Expand Down

2 comments on commit 60ac830

@hhaensel
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117115

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.30.8 -m "<description of version>" 60ac8301ebcdd16a6e648d37aac468291dfe4029
git push origin v0.30.8

Please sign in to comment.