Skip to content

Commit

Permalink
support for assets_config
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Jan 23, 2023
1 parent c6df4a5 commit f701913
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GenieAutoReload"
uuid = "c6228e60-a24f-11e9-1776-c313472ebacc"
authors = ["Adrian Salceanu <e@essenciary.com>"]
version = "2.0.1"
version = "2.1.0"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
10 changes: 6 additions & 4 deletions src/GenieAutoReload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export autoreload
Genie.config.websockets_server = true

const WEBCHANNEL_NAME = "autoreload"
const SCRIPT_URI = "$(Genie.Assets.external_assets(Genie.config.base_path) ? "" : "/")js/plugins/autoreload.js"
const WATCH_KEY = "autoreload"
const assets_config = Genie.Assets.AssetsConfig(package = "GenieAutoReload.jl")

function watch(files::Vector{String}, extensions::Vector{String} = Genie.config.watch_extensions) :: Nothing
@info "Watching $files"
Expand Down Expand Up @@ -58,15 +58,17 @@ end

function assets(; devonly = true) :: String
if (devonly && Genie.Configuration.isdev()) || !devonly
"""<script src="$SCRIPT_URI"></script>"""
Genie.Renderer.Html.script(src = Genie.Assets.asset_path(assets_config, :js, file="autoreload"))
else
""
end
end

function routing() :: Nothing
route(SCRIPT_URI) do
assets_js() |> Genie.Renderer.Js.js
if ! Genie.Assets.external_assets(assets_config)
Genie.Router.route(Genie.Assets.asset_route(GenieAutoReload.assets_config, :js, file="autoreload")) do
assets_js() |> Genie.Renderer.Js.js
end
end

channel("/$(WEBCHANNEL_NAME)/subscribe") do
Expand Down

0 comments on commit f701913

Please sign in to comment.