mirror of
https://github.com/sudoxnym/brands.git
synced 2026-07-13 17:51:53 +00:00
Change placeholder fallback logic (#61)
* Remove placeholder fallback * Iteration * Update documentation with new fallback behavior
This commit is contained in:
parent
32983c2b92
commit
b51a4013f0
3 changed files with 38 additions and 15 deletions
31
README.md
31
README.md
|
|
@ -25,14 +25,35 @@ Those images are served in the following format:
|
||||||
- `https://brands.home-assistant.io/[domain]/logo.png`
|
- `https://brands.home-assistant.io/[domain]/logo.png`
|
||||||
- `https://brands.home-assistant.io/[domain]/icon@2x.png`
|
- `https://brands.home-assistant.io/[domain]/icon@2x.png`
|
||||||
- `https://brands.home-assistant.io/[domain]/logo@2x.png`
|
- `https://brands.home-assistant.io/[domain]/logo@2x.png`
|
||||||
|
- `https://brands.home-assistant.io/_/[domain]/icon.png`
|
||||||
|
- `https://brands.home-assistant.io/_/[domain]/logo.png`
|
||||||
|
- `https://brands.home-assistant.io/_/[domain]/icon@2x.png`
|
||||||
|
- `https://brands.home-assistant.io/_/[domain]/logo@2x.png`
|
||||||
|
|
||||||
### Missing image handling
|
### Missing image handling
|
||||||
|
|
||||||
- If a domain is missing, the images from the `_placeholder` domain is served instead.
|
The website can service images with and without a fallback to an placeholder
|
||||||
- If a domain is missing the `icon.png` file, the placeholder will be will be served instead.
|
image.
|
||||||
- If a domain is missing the `logo.png` file, the `icon.png` is served instead.
|
|
||||||
- If a domain is missing the `icon@2.png` file, the `icon.png` is served instead.
|
### Without placeholder fallback
|
||||||
- If a domain is missing the `logo@2.png` file, the `logo.png` is served instead.
|
|
||||||
|
This method uses the plain URLs, **WITHOUT** the `/_/` in the URL path.
|
||||||
|
A missing image, will result in a 404 being served.
|
||||||
|
|
||||||
|
For example: <`https://brands.home-assistant.io/[domain]/icon.png`>
|
||||||
|
|
||||||
|
- If a domain is missing the `icon.png` file, 404 will be served
|
||||||
|
- If a domain is missing the `logo.png` file, the `icon.png` is served instead (if available).
|
||||||
|
- If a domain is missing the `icon@2.png` file, the `icon.png` is served instead (if available).
|
||||||
|
- If a domain is missing the `logo@2.png` file, the `logo.png` is served instead (if available).
|
||||||
|
|
||||||
|
### With placeholder fallback
|
||||||
|
|
||||||
|
This method uses the plain URLs, **WITH** the `/_/` in the URL path.
|
||||||
|
A missing image, will result in placeholder image being served telling the logo/icon is missing.
|
||||||
|
This also applies to domains, in case the integration domain is missing.
|
||||||
|
|
||||||
|
For example: <`https://brands.home-assistant.io/_/[domain]/icon.png`>
|
||||||
|
|
||||||
### Caching
|
### Caching
|
||||||
|
|
||||||
|
|
|
||||||
18
netlify.toml
18
netlify.toml
|
|
@ -3,7 +3,7 @@
|
||||||
command = "bash ./scripts/build.sh"
|
command = "bash ./scripts/build.sh"
|
||||||
|
|
||||||
[[headers]]
|
[[headers]]
|
||||||
for = "/_placeholder/*.png"
|
for = "/_/_placeholder/*.png"
|
||||||
[headers.values]
|
[headers.values]
|
||||||
Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"
|
Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"
|
||||||
|
|
||||||
|
|
@ -20,29 +20,29 @@
|
||||||
headers = {Cache-Control = "public, max-age: 900, s-maxage=604800, must-revalidate"}
|
headers = {Cache-Control = "public, max-age: 900, s-maxage=604800, must-revalidate"}
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/*/icon.png"
|
from = "/_/*/icon.png"
|
||||||
to = "/_placeholder/icon.png"
|
to = "/_/_placeholder/icon.png"
|
||||||
force = false
|
force = false
|
||||||
status = 302
|
status = 302
|
||||||
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/*/logo.png"
|
from = "/_/*/logo.png"
|
||||||
to = "/_placeholder/logo.png"
|
to = "/_/_placeholder/logo.png"
|
||||||
force = false
|
force = false
|
||||||
status = 302
|
status = 302
|
||||||
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/*/icon@2x.png"
|
from = "/_/*/icon@2x.png"
|
||||||
to = "/_placeholder/icon@2x.png"
|
to = "/_/_placeholder/icon@2x.png"
|
||||||
force = false
|
force = false
|
||||||
status = 302
|
status = 302
|
||||||
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/*/logo@2x.png"
|
from = "/_/*/logo@2x.png"
|
||||||
to = "/_placeholder/logo@2x.png"
|
to = "/_/_placeholder/logo@2x.png"
|
||||||
force = false
|
force = false
|
||||||
status = 302
|
status = 302
|
||||||
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
headers = {Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copy folder, without symlinks, but use actual files instead
|
# Copy folder, without symlinks, but use actual files instead
|
||||||
rsync -aL --exclude '_homeassistant' src/ build
|
mkdir -p build/_
|
||||||
|
rsync -aL --exclude '_homeassistant' src/ build/_
|
||||||
|
rsync -aL --exclude '_homeassistant' --exclude '_placeholder' src/ build
|
||||||
|
|
||||||
# Use icon as logo in case of a missing logo
|
# Use icon as logo in case of a missing logo
|
||||||
find ./build -type f -name "icon.png" | while read icon; do
|
find ./build -type f -name "icon.png" | while read icon; do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue