1- function resource_url (app:: DashApp , resource:: AppRelativeResource )
1+ function resource_url (app:: DashApp , resource:: AppRelativeResource )
22 prefix = get_setting (app, :requests_pathname_prefix )
33 return string (prefix,
44 " _dash-component-suites/" ,
55 resource. namespace,
66 " /" ,
7- build_fingerprint (resource. relative_path, resource. version, resource. ts)
7+ build_fingerprint (resource. relative_path, resource. version, resource. ts)
88 )
99end
1010
@@ -19,7 +19,7 @@ function asset_path(app::DashApp, path::AbstractString)
1919end
2020
2121resource_url (app:: DashApp , resource:: AppExternalResource ) = resource. url
22- function resource_url (app:: DashApp , resource:: AppAssetResource )
22+ function resource_url (app:: DashApp , resource:: AppAssetResource )
2323 return string (
2424 asset_path (app, resource. path),
2525 " ?m=" , resource. ts
@@ -42,7 +42,7 @@ function metas_html(app::DashApp)
4242 get (tag, " http-equiv" , " " ) == " X-UA-Compatible"
4343 end
4444 has_charset = any (tag -> haskey (tag, " charset" ), meta_tags)
45-
45+
4646 result = String[]
4747 ! has_ie_compat && push! (result, " <meta http-equiv=\" X-UA-Compatible\" content=\" IE=edge\" >" )
4848 ! has_charset && push! (result, " <meta charset=\" UTF-8\" >" )
@@ -52,7 +52,7 @@ function metas_html(app::DashApp)
5252
5353end
5454
55- function css_html (app:: DashApp , resources:: ApplicationResources )
55+ function css_html (app:: DashApp , resources:: ApplicationResources )
5656 join (
5757 make_css_tag .(Ref (app), resources. css), " \n "
5858 )
@@ -77,7 +77,7 @@ app_entry_html() = """
7777</div>
7878"""
7979
80- function config_html (app:: DashApp )
80+ function config_html (app:: DashApp )
8181 config = Dict {Symbol, Any} (
8282 :url_base_pathname => get_setting (app, :url_base_pathname ),
8383 :requests_pathname_prefix => get_setting (app, :requests_pathname_prefix ),
@@ -94,20 +94,35 @@ function config_html(app::DashApp)
9494 )
9595 end
9696 return """ <script id="_dash-config" type="application/json">$(JSON2. write (config)) </script>"""
97- end
97+ end
9898
9999
100100renderer_html () = """ <script id="_dash-renderer" type="application/javascript">var renderer = new DashRenderer();</script>"""
101101
102- favicon_html (app:: DashApp ) = " "
102+ function favicon_html (app:: DashApp , resources:: ApplicationResources )
103+ favicon_url = if ! isnothing (resources. favicon)
104+ asset_path (app, resources. favicon. path)
105+ else
106+ " $(get_setting (app, :requests_pathname_prefix )) _favicon.ico?v=$(build_info (). dash_version) "
107+ end
108+ return format_tag (
109+ " link" ,
110+ Dict (
111+ " rel" => " icon" ,
112+ " type" => " image/x-icon" ,
113+ " href" => favicon_url
114+ ),
115+ opened = true
116+ )
117+ end
118+
103119
120+ function index_page (app:: DashApp , resources:: ApplicationResources )
104121
105- function index_page (app:: DashApp , resources:: ApplicationResources )
106-
107122 result = interpolate_string (app. index_string,
108123 metas = metas_html (app),
109124 title = app. title,
110- favicon = favicon_html (app),
125+ favicon = favicon_html (app, resources ),
111126 css = css_html (app, resources),
112127 app_entry = app_entry_html (),
113128 config = config_html (app),
@@ -121,7 +136,7 @@ function index_page(app::DashApp, resources::ApplicationResources)
121136 " #_dash_config" => r" id=\" _dash-config\" " ,
122137 " dash-renderer" => r" src=\" [^\" ]*dash[-_]renderer[^\" ]*\" " ,
123138 " new DashRenderer" => r" id=\" _dash-renderer" ,
124- ]
139+ ]
125140 )
126141 return result
127142end
0 commit comments