/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
scripts/render/touch-icon.sh
53 строки
2 KB
Michael Mayer
PWA: Add full-bleed touch icon variants and refresh icon set #5737
21 июл 2026, 11:26
21 июл 2026, 11:26
37e7832
Код
Авторство
О чём код?
#!/usr/bin/env bash # Renders the full-bleed "touch" icon variants used by the apple-touch-icon links. iOS masks the # home-screen icon into a squircle and, during the app-open zoom, composites it over the light # launch background, so a source with transparent rounded corners flashes white around the icon. # Each theme icon therefore provides a "<name>.touch.svg" source whose background fills the whole # square opaquely (no rounded corners); iOS supplies the rounding. if [[ -n $1 ]] && [[ $1 == "-h" || $1 == "--help" ]]; then echo "Usage: (1) ${0##*/} (renders touch icons for all assets/static/icons/*.touch.svg sources)" 1>&2 echo " (2) ${0##*/} [name] (renders touch icons for assets/static/icons/[name].touch.svg only)" 1>&2 exit 1 fi set -e # Sizes must match the apple-touch-icon ladder in assets/templates/favicons.gohtml # (the sizes iOS actually requests for home-screen web clips: iPhone 180, iPad Pro 167, # iPad 152, older iPhone 120). sizes=(120 152 167 180) icons_dir="assets/static/icons" # render_touch_svg renders a "<name>.touch.svg" source into "<name>/touch/<size>.png". render_touch_svg() { local svg="$1" local name name="$(basename "$svg" .touch.svg)" local dest="${icons_dir}/${name}/touch" echo "Creating touch icons from ${svg}..." mkdir -p "$dest" for size in "${sizes[@]}"; do rsvg-convert -a -w "$size" -h "$size" "$svg" > "$dest/$size.png" echo "$dest/$size.png" done } if [[ -n $1 ]]; then if [ -f "${icons_dir}/${1}.touch.svg" ]; then render_touch_svg "${icons_dir}/${1}.touch.svg" else echo "${icons_dir}/${1}.touch.svg not found" 1>&2 exit 1 fi else for svg in "${icons_dir}"/*.touch.svg; do [ -e "$svg" ] || continue render_touch_svg "$svg" done fi echo "Done."