Skip to content

Commit f4cceac

Browse files
committed
fixes to PR
1 parent c3bdc1a commit f4cceac

File tree

4 files changed

+27
-68
lines changed

4 files changed

+27
-68
lines changed

src/Dash.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
module Dash
2-
components = [1,2,3,4,5]
32
import HTTP, JSON2
43
using MacroTools
54
include("ComponentPackages.jl")
@@ -23,10 +22,6 @@ include("index_page.jl")
2322
include("handlers.jl")
2423

2524

26-
macro test()
27-
28-
end
29-
3025
@doc """
3126
module Dash
3227

src/app.jl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ end
7878
"""
7979
struct DashApp <: Any
8080
81-
Representation of Dash application
81+
Representation of Dash application.
82+
83+
Not meant to be constructed directly, use `dash` function instead.
8284
"""
8385
struct DashApp
8486
name ::String
@@ -111,13 +113,28 @@ end
111113

112114

113115
"""
114-
dash(name::String; external_stylesheets ::Vector{String} = Vector{String}(), url_base_pathname::String="/")
115-
dash(layout_maker::Function, name::String; external_stylesheets ::Vector{String} = Vector{String}(), url_base_pathname::String="/")
116+
dash(name::String;
117+
external_stylesheets,
118+
external_scripts,
119+
url_base_pathname,
120+
requests_pathname_prefix,
121+
routes_pathname_prefix,
122+
assets_folder,
123+
assets_url_path,
124+
assets_ignore,
125+
serve_locally,
126+
suppress_callback_exceptions,
127+
eager_loading ,
128+
meta_tags,
129+
index_string,
130+
assets_external_path,
131+
include_assets_files,
132+
show_undo_redo
133+
)
116134
117135
Construct a dash app
118136
119137
# Arguments
120-
- `layout_maker::Function` - function for layout creation. Must has signature ()::Component
121138
- `name::String` - The name of your application
122139
- `assets_folder::String` - a path, relative to the current working directory,
123140
for extra files to be used in the browser. Default ``'assets'``.
@@ -148,7 +165,7 @@ Construct a dash app
148165
149166
150167
- `url_base_pathname::String`: A local URL prefix to use app-wide.
151-
Default ``'/'``. Both `requests_pathname_prefix` and
168+
Default ``nothing``. Both `requests_pathname_prefix` and
152169
`routes_pathname_prefix` default to `url_base_pathname`.
153170
154171

src/index_page.jl

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function metas_html(app::DashApp)
1515
!has_ie_compat && push!(result, "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">")
1616
!has_charset && push!(result, "<meta charset=\"UTF-8\">")
1717

18-
append!(result, formattag.("meta", meta_tags, opened = true))
18+
append!(result, format_tag.("meta", meta_tags, opened = true))
1919
return join(result, "\n ")
2020

2121
end
@@ -49,66 +49,13 @@ function scripts_html(app::DashApp; debug = false)
4949
append!(scripts,
5050
ComponentPackages.components_js_sources(app.config.requests_pathname_prefix, debug = debug)
5151
)
52-
return join(map(make_scipt_tag, scripts), "\n ")
52+
return join(map(make_script_tag, scripts), "\n ")
5353
end
5454

5555
renderer_html() = """<script id="_dash-renderer" type="application/javascript">var renderer = new DashRenderer();</script>"""
5656

5757
favicon_html(app::DashApp) = ""
5858

59-
#=
60-
def _walk_assets_directory(self):
61-
walk_dir = self.config.assets_folder
62-
slash_splitter = re.compile(r"[\\/]+")
63-
ignore_str = self.config.assets_ignore
64-
ignore_filter = re.compile(ignore_str) if ignore_str else None
65-
66-
for current, _, files in os.walk(walk_dir):
67-
if current == walk_dir:
68-
base = ""
69-
else:
70-
s = current.replace(walk_dir, "").lstrip("\\").lstrip("/")
71-
splitted = slash_splitter.split(s)
72-
if len(splitted) > 1:
73-
base = "/".join(slash_splitter.split(s))
74-
else:
75-
base = splitted[0]
76-
77-
if ignore_filter:
78-
files_gen = (x for x in files if not ignore_filter.search(x))
79-
else:
80-
files_gen = files
81-
82-
for f in sorted(files_gen):
83-
path = "/".join([base, f]) if base else f
84-
85-
full = os.path.join(current, f)
86-
87-
if f.endswith("js"):
88-
self.scripts.append_script(self._add_assets_resource(path, full))
89-
elif f.endswith("css"):
90-
self.css.append_css(self._add_assets_resource(path, full))
91-
elif f == "favicon.ico":
92-
self._favicon = path
93-
=#
94-
95-
function find_assets_files(app::DashApp)
96-
result = (css = String[], js = String[], favicon = nothing)
97-
98-
if app.config.include_assets_files
99-
for (base, dirs, files) in walkdir(app.config.assets_folder)
100-
if !isempty(files)
101-
relative = (base == app.config.assets_folder) ? "" : relpath(base, app.config.assets_folder)
102-
relative_uri = join(splitpath(relative), "/") * "/"
103-
104-
105-
end
106-
107-
108-
end
109-
end
110-
return result
111-
end
11259

11360
function index_page(app::DashApp; debug = false)
11461

test/config_functional.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ end
146146

147147
@test !isnothing(
148148
findfirst(
149-
Dash.formattag("meta", Dict("type" => "tst", "rel" => "r"), opened = true),
149+
Dash.format_tag("meta", Dict("type" => "tst", "rel" => "r"), opened = true),
150150
index_page)
151151
)
152152

@@ -166,7 +166,7 @@ end
166166

167167
@test !isnothing(
168168
findfirst(
169-
Dash.formattag("meta", Dict("type" => "tst", "rel" => "r"), opened = true),
169+
Dash.format_tag("meta", Dict("type" => "tst", "rel" => "r"), opened = true),
170170
index_page)
171171
)
172172

@@ -179,7 +179,7 @@ end
179179
)
180180
@test !isnothing(
181181
findfirst(
182-
Dash.formattag("meta", Dict("http-equiv" => "X-UA-Compatible", "content" => "IE"), opened = true),
182+
Dash.format_tag("meta", Dict("http-equiv" => "X-UA-Compatible", "content" => "IE"), opened = true),
183183
index_page)
184184
)
185185

0 commit comments

Comments
 (0)