PWA: Add alternative prism app icon

This commit is contained in:
Michael Mayer 2021-11-22 11:26:10 +01:00
parent 9ddd853234
commit 6ce109153b
50 changed files with 73 additions and 67 deletions

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View file

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View file

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View file

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View file

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View file

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View file

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View file

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -4,77 +4,77 @@
"description": "{{ .config.SiteDescription }}",
"icons": [
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-16.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-16.png",
"sizes": "16x16",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-32.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-32.png",
"sizes": "32x32",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-72.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-114.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-114.png",
"sizes": "114x114",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-128.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-144.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-152.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-160.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-160.png",
"sizes": "160x160",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-167.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-167.png",
"sizes": "167x167",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-180.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-180.png",
"sizes": "180x180",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-192.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-196.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-196.png",
"sizes": "196x196",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-256.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-400.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-400.png",
"sizes": "400x400",
"type": "image/png"
},
{
"src": "{{ .config.StaticUri }}/img/{{ .config.AppIcon }}-512.png",
"src": "{{ .config.StaticUri }}/img/icons/{{ .config.AppIcon }}-512.png",
"sizes": "512x512",
"type": "image/png"
}
@ -82,8 +82,8 @@
"scope": "{{ .config.BaseUri }}/",
"start_url": "{{ .config.BaseUri }}/",
"display": "{{ .config.AppMode }}",
"theme_color": "#0d0d0d",
"background_color": "#0d0d0d",
"theme_color": "#000000",
"background_color": "#000000",
"permissions": [
"geolocation",
"downloads",

53
internal/config/app.go Normal file
View file

@ -0,0 +1,53 @@
package config
import (
"github.com/photoprism/photoprism/pkg/fs"
"github.com/photoprism/photoprism/pkg/txt"
"path/filepath"
"strings"
)
// AppName returns the app name when installed on a device.
func (c *Config) AppName() string {
name := strings.TrimSpace(c.options.AppName)
if name == "" {
name = c.SiteTitle()
}
clean := func(r rune) rune {
switch r {
case '\'', '"':
return -1
}
return r
}
name = strings.Map(clean, name)
return txt.Clip(name, 32)
}
// AppMode returns the app mode when installed on a device.
func (c *Config) AppMode() string {
switch c.options.AppMode {
case "fullscreen", "standalone", "minimal-ui", "browser":
return c.options.AppMode
default:
return "standalone"
}
}
// AppIcon returns the app icon when installed on a device.
func (c *Config) AppIcon() string {
defaultIcon := "logo"
if c.options.AppIcon == "" || c.options.AppIcon == defaultIcon {
// Default.
} else if fs.FileExists(filepath.Join(c.ImgPath(), "icons", c.options.AppIcon+"-192.png")) {
return c.options.AppIcon
}
return defaultIcon
}

View file

@ -42,7 +42,7 @@ var TotalMem uint64
const MsgFreeBeer = "Help us make a difference and become a sponsor today!"
const MsgFundingInfo = "Visit https://docs.photoprism.org/funding/ to learn more."
const MsgSponsorCommand = "Since running this command puts additional load on our infrastructure," +
" we unfortunately can't offer it for free."
" we unfortunately can only offer it to sponsors."
const ApiUri = "/api/v1" // REST API
const StaticUri = "/static" // Static Content
@ -350,10 +350,6 @@ func (c *Config) SiteCaption() string {
// SiteDescription returns a long site description.
func (c *Config) SiteDescription() string {
if !c.Sponsor() {
return MsgFreeBeer
}
return c.options.SiteDescription
}
@ -370,49 +366,6 @@ func (c *Config) SitePreview() string {
return c.options.SitePreview
}
// AppName returns the app name when installed on a device.
func (c *Config) AppName() string {
name := strings.TrimSpace(c.options.AppName)
if name == "" {
name = c.SiteTitle()
}
clean := func(r rune) rune {
switch r {
case '\'', '"':
return -1
}
return r
}
name = strings.Map(clean, name)
return txt.Clip(name, 32)
}
// AppMode returns the app mode when installed on a device.
func (c *Config) AppMode() string {
switch c.options.AppMode {
case "fullscreen", "standalone", "minimal-ui", "browser":
return c.options.AppMode
default:
return "standalone"
}
}
// AppIcon returns the app icon when installed on a device.
func (c *Config) AppIcon() string {
if c.options.AppIcon == "" || c.options.AppIcon == "favicon" {
// Default.
} else if fs.FileExists(filepath.Join(c.ImgPath(), c.options.AppIcon+"-192.png")) {
return c.options.AppIcon
}
return "favicon"
}
// Debug tests if debug mode is enabled.
func (c *Config) Debug() bool {
return c.options.Debug

View file

@ -281,8 +281,8 @@ var GlobalFlags = []cli.Flag{
},
cli.StringFlag{
Name: "app-icon",
Usage: "application `ICON` (favicon, lens)",
Value: "favicon",
Usage: "application `ICON` (logo, prism, lens)",
Value: "logo",
EnvVar: "PHOTOPRISM_APP_ICON",
},
cli.IntFlag{