Skip to content

Commit e99e386

Browse files
committed
include a default favicon in sqlpage
this fixes the Unable to read file "favicon.ico" error that was displayed by default in the console when opening a page in a browser
1 parent fd3394f commit e99e386

File tree

7 files changed

+20
-3
lines changed

7 files changed

+20
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- New `max_pending_rows` [configuration option](https://sql.ophir.dev/configuration.md) to limit the number of messages that can be sent to the client before they are read. Usefule when sending large amounts of data to slow clients.
3636
- Update sqlite to v3.46: https://www.sqlite.org/releaselog/3_46_0.html
3737
- Faster initial page load. SQLPage used to wait for the first component to be rendered before sending the shell to the client. We now send the shell immediately, and the first component as soon as it is ready. This can make the initial page load faster, especially when the first component requires a long computation on the database side.
38+
- Include a default favicon when none is specified in the shell component. This fixes the `Unable to read file "favicon.ico"` error message that would appear in the logs by default.
3839
3940
## 0.23.0 (2024-06-09)
4041

build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async fn main() {
2020
spawn(download_deps(c.clone(), "tabler-icons.svg")),
2121
spawn(download_deps(c.clone(), "apexcharts.js")),
2222
spawn(download_deps(c.clone(), "tomselect.js")),
23+
spawn(download_deps(c.clone(), "favicon.svg")),
2324
] {
2425
h.await.unwrap();
2526
}

sqlpage/favicon.svg

+11
Loading

sqlpage/templates/shell.handlebars

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<head>
44
<meta charset="utf-8"/>
55
<title>{{default title "SQLPage"}}</title>
6-
{{#if favicon}}
7-
<link rel="icon" href="{{favicon}}">
8-
{{/if}}
6+
<link rel="icon" href="{{#if favicon}}{{favicon}}{{else}}{{static_path 'favicon.svg'}}{{/if}}">
97
{{#if manifest}}
108
<link rel="manifest" href="{{manifest}}">
119
{{/if}}

src/template_helpers.rs

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ impl CanHelp for StaticPathHelper {
151151
"sqlpage.css" => static_filename!("sqlpage.css"),
152152
"apexcharts.js" => static_filename!("apexcharts.js"),
153153
"tomselect.js" => static_filename!("tomselect.js"),
154+
"favicon.svg" => static_filename!("favicon.svg"),
154155
other => return Err(format!("unknown static file: {other:?}")),
155156
};
156157
Ok(format!("{}{}", self.0, path).into())

src/webserver/http.rs

+1
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ pub fn create_app(
525525
.service(static_content::tomselect_js())
526526
.service(static_content::css())
527527
.service(static_content::icons())
528+
.service(static_content::favicon())
528529
.default_service(fn_service(main_handler)),
529530
)
530531
// when receiving a request outside of the prefix, redirect to the prefix

src/webserver/static_content.rs

+4
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ pub fn css() -> Resource {
4949
pub fn icons() -> Resource {
5050
static_file_endpoint!("tabler-icons", "svg", "image/svg+xml")
5151
}
52+
53+
pub fn favicon() -> Resource {
54+
static_file_endpoint!("favicon", "svg", "image/svg+xml")
55+
}

0 commit comments

Comments
 (0)