Skip to content

Commit

Permalink
Feature/icon update (#19)
Browse files Browse the repository at this point in the history
* Changed logo/favicon from PNG to ICO format

Now the icon will be displayed correctly when WEB page bookmark is put
on desktop. Chrome OS has been confirmed working.

* Fixed ico file type in html file

* Stored original .svg
  • Loading branch information
midstar committed Dec 13, 2019
1 parent 33e43bf commit 34407ac
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<title>MediaWEB</title>
<link rel="icon" type="image/png" href="/logo.png">
<link rel="icon" type="image/x-icon" href="/logo.ico">
<style>

/******************************************************************************
Expand Down
Binary file added templates/logo.ico
Binary file not shown.
26 changes: 18 additions & 8 deletions testmedia/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions webapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (wa *WebAPI) serveHTTPStatic(w http.ResponseWriter, r *http.Request) {
} else {
if filepath.Ext(fileName) == ".html" {
w.Header().Set("Content-Type", "text/html")
} else if filepath.Ext(fileName) == ".ico" {
w.Header().Set("Content-Type", "image/x-icon")
} else {
w.Header().Set("Content-Type", "image/png")
}
Expand Down
4 changes: 4 additions & 0 deletions webapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func TestStatic(t *testing.T) {
image := getBinary(t, "icon_folder.png", "image/png")
assertTrue(t, "", len(image) > 100)

// Get an icong
image = getBinary(t, "logo.ico", "image/x-icon")
assertTrue(t, "", len(image) > 100)

// Get a non-existing png
resp, err := http.Get(fmt.Sprintf("%s/invalid.html", baseURL))
assertExpectNoErr(t, "", err)
Expand Down

0 comments on commit 34407ac

Please sign in to comment.