Skip to content

Commit

Permalink
include a default favicon in sqlpage
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lovasoa committed Jun 23, 2024
1 parent fd3394f commit e99e386
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- 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.
- Update sqlite to v3.46: https://www.sqlite.org/releaselog/3_46_0.html
- 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.
- 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.
## 0.23.0 (2024-06-09)
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async fn main() {
spawn(download_deps(c.clone(), "tabler-icons.svg")),
spawn(download_deps(c.clone(), "apexcharts.js")),
spawn(download_deps(c.clone(), "tomselect.js")),
spawn(download_deps(c.clone(), "favicon.svg")),
] {
h.await.unwrap();
}
Expand Down
11 changes: 11 additions & 0 deletions sqlpage/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions sqlpage/templates/shell.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
<head>
<meta charset="utf-8"/>
<title>{{default title "SQLPage"}}</title>
{{#if favicon}}
<link rel="icon" href="{{favicon}}">
{{/if}}
<link rel="icon" href="{{#if favicon}}{{favicon}}{{else}}{{static_path 'favicon.svg'}}{{/if}}">
{{#if manifest}}
<link rel="manifest" href="{{manifest}}">
{{/if}}
Expand Down
1 change: 1 addition & 0 deletions src/template_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ impl CanHelp for StaticPathHelper {
"sqlpage.css" => static_filename!("sqlpage.css"),
"apexcharts.js" => static_filename!("apexcharts.js"),
"tomselect.js" => static_filename!("tomselect.js"),
"favicon.svg" => static_filename!("favicon.svg"),
other => return Err(format!("unknown static file: {other:?}")),
};
Ok(format!("{}{}", self.0, path).into())
Expand Down
1 change: 1 addition & 0 deletions src/webserver/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ pub fn create_app(
.service(static_content::tomselect_js())
.service(static_content::css())
.service(static_content::icons())
.service(static_content::favicon())
.default_service(fn_service(main_handler)),
)
// when receiving a request outside of the prefix, redirect to the prefix
Expand Down
4 changes: 4 additions & 0 deletions src/webserver/static_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ pub fn css() -> Resource {
pub fn icons() -> Resource {
static_file_endpoint!("tabler-icons", "svg", "image/svg+xml")
}

pub fn favicon() -> Resource {
static_file_endpoint!("favicon", "svg", "image/svg+xml")
}

0 comments on commit e99e386

Please sign in to comment.