|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Generate Horde icons from Tabler Icons (MIT license) |
| 4 | +# https://github.com/tabler/tabler-icons |
| 5 | +# |
| 6 | +# Requires: ImageMagick (convert), curl |
| 7 | +# |
| 8 | +# Usage: |
| 9 | +# ./generate-admin-icons.sh [size] [category] |
| 10 | +# |
| 11 | +# Categories: |
| 12 | +# admin - Admin dashboard icons (output: themes/default/graphics/admin/) |
| 13 | +# actions - Common action icons (output: themes/default/graphics/actions/) |
| 14 | +# apps - Application identity icons (output: themes/default/graphics/apps/) |
| 15 | +# status - Status/notification icons (output: themes/default/graphics/status/) |
| 16 | +# nav - Navigation icons (output: themes/default/graphics/nav/) |
| 17 | +# all - Generate all categories (default) |
| 18 | +# |
| 19 | +# Default size: 48px |
| 20 | +# |
| 21 | + |
| 22 | +set -euo pipefail |
| 23 | + |
| 24 | +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 25 | +BASE_URL="https://raw.githubusercontent.com/tabler/tabler-icons/main/icons/outline" |
| 26 | +THEMES_DIR="${SCRIPT_DIR}/../themes/default/graphics" |
| 27 | +SIZE="${1:-48}" |
| 28 | +CATEGORY="${2:-all}" |
| 29 | +TMPDIR="$(mktemp -d)" |
| 30 | +STROKE_COLOR="#333333" |
| 31 | + |
| 32 | +trap 'rm -rf "$TMPDIR"' EXIT |
| 33 | + |
| 34 | +generate_icons() { |
| 35 | + local dest="$1" |
| 36 | + shift |
| 37 | + local -n icons_ref=$1 |
| 38 | + |
| 39 | + mkdir -p "$dest" |
| 40 | + |
| 41 | + local failed=0 |
| 42 | + for key in "${!icons_ref[@]}"; do |
| 43 | + local icon="${icons_ref[$key]}" |
| 44 | + local url="${BASE_URL}/${icon}.svg" |
| 45 | + local svgfile="${TMPDIR}/${key}.svg" |
| 46 | + local pngfile="${dest}/${key}.png" |
| 47 | + |
| 48 | + printf " %-20s <- tabler/%s.svg ... " "$key" "$icon" |
| 49 | + |
| 50 | + if ! curl -sfL "$url" -o "$svgfile"; then |
| 51 | + echo "DOWNLOAD FAILED" |
| 52 | + failed=$((failed + 1)) |
| 53 | + continue |
| 54 | + fi |
| 55 | + |
| 56 | + if [ ! -s "$svgfile" ]; then |
| 57 | + echo "EMPTY FILE" |
| 58 | + failed=$((failed + 1)) |
| 59 | + continue |
| 60 | + fi |
| 61 | + |
| 62 | + # Replace currentColor with our stroke color for consistent rendering |
| 63 | + sed -i "s/currentColor/${STROKE_COLOR}/g" "$svgfile" |
| 64 | + |
| 65 | + if convert -background none -density 192 "$svgfile" -resize "${SIZE}x${SIZE}" "$pngfile" 2>/dev/null; then |
| 66 | + echo "OK" |
| 67 | + else |
| 68 | + echo "CONVERT FAILED" |
| 69 | + failed=$((failed + 1)) |
| 70 | + fi |
| 71 | + done |
| 72 | + |
| 73 | + return $failed |
| 74 | +} |
| 75 | + |
| 76 | +# ============================================================================= |
| 77 | +# ADMIN DASHBOARD ICONS |
| 78 | +# Used by: AdminDashboardController, lib/Api.php admin_list() |
| 79 | +# Output: themes/default/graphics/admin/ |
| 80 | +# ============================================================================= |
| 81 | +declare -A ADMIN_ICONS=( |
| 82 | + [config]="settings" |
| 83 | + [user]="user" |
| 84 | + [group]="users-group" |
| 85 | + [perms]="shield-lock" |
| 86 | + [locked]="lock" |
| 87 | + [alarm]="bell" |
| 88 | + [data]="database" |
| 89 | + [cache]="server-bolt" |
| 90 | + [hashtable]="hash" |
| 91 | + [sessions]="users" |
| 92 | + [api-registry]="plug-connected" |
| 93 | + [php]="code" |
| 94 | + [sql]="sql" |
| 95 | + [shell]="terminal-2" |
| 96 | + [mobile]="device-mobile" |
| 97 | + [oauth]="key" |
| 98 | + [auth-status]="shield-check" |
| 99 | +) |
| 100 | + |
| 101 | +# ============================================================================= |
| 102 | +# COMMON ACTION ICONS |
| 103 | +# Used by: toolbars, buttons, context menus across all apps |
| 104 | +# Output: themes/default/graphics/actions/ |
| 105 | +# ============================================================================= |
| 106 | +declare -A ACTION_ICONS=( |
| 107 | + [add]="plus" |
| 108 | + [edit]="pencil" |
| 109 | + [delete]="trash" |
| 110 | + [search]="search" |
| 111 | + [download]="download" |
| 112 | + [upload]="upload" |
| 113 | + [import]="file-import" |
| 114 | + [export]="file-export" |
| 115 | + [refresh]="refresh" |
| 116 | + [close]="x" |
| 117 | + [copy]="copy" |
| 118 | + [cut]="cut" |
| 119 | + [print]="printer" |
| 120 | + [help]="help-circle" |
| 121 | + [info]="info-circle" |
| 122 | + [login]="login" |
| 123 | + [logout]="logout" |
| 124 | + [compose]="edit" |
| 125 | + [reply]="arrow-back-up" |
| 126 | + [replyall]="arrows-left" |
| 127 | + [forward]="arrow-forward-up" |
| 128 | + [attachment]="paperclip" |
| 129 | + [bookmark]="bookmark" |
| 130 | + [share]="share" |
| 131 | + [link]="link" |
| 132 | + [settings]="settings" |
| 133 | + [filter]="filter" |
| 134 | + [sort-asc]="sort-ascending" |
| 135 | + [sort-desc]="sort-descending" |
| 136 | + [expand]="chevron-down" |
| 137 | + [collapse]="chevron-up" |
| 138 | + [undo]="arrow-back" |
| 139 | + [redo]="arrow-forward" |
| 140 | + [move]="arrows-move" |
| 141 | + [tag]="tag" |
| 142 | +) |
| 143 | + |
| 144 | +# ============================================================================= |
| 145 | +# APPLICATION IDENTITY ICONS |
| 146 | +# Used by: app switcher, portal tiles, responsive portal grid |
| 147 | +# Output: themes/default/graphics/apps/ |
| 148 | +# ============================================================================= |
| 149 | +declare -A APP_ICONS=( |
| 150 | + [mail]="mail" |
| 151 | + [calendar]="calendar" |
| 152 | + [contacts]="address-book" |
| 153 | + [tasks]="list-check" |
| 154 | + [notes]="note" |
| 155 | + [files]="folder" |
| 156 | + [wiki]="notebook" |
| 157 | + [bookmarks]="bookmarks" |
| 158 | + [news]="news" |
| 159 | + [password]="lock-access" |
| 160 | + [passwd]="key" |
| 161 | + [content]="tags" |
| 162 | + [skeleton]="puzzle" |
| 163 | + [filters]="filter" |
| 164 | + [administration]="shield-cog" |
| 165 | + [webmail]="inbox" |
| 166 | + [timetracker]="clock" |
| 167 | +) |
| 168 | + |
| 169 | +# ============================================================================= |
| 170 | +# STATUS/NOTIFICATION ICONS |
| 171 | +# Used by: alerts, notifications, indicators |
| 172 | +# Output: themes/default/graphics/status/ |
| 173 | +# ============================================================================= |
| 174 | +declare -A STATUS_ICONS=( |
| 175 | + [error]="alert-circle" |
| 176 | + [warning]="alert-triangle" |
| 177 | + [success]="circle-check" |
| 178 | + [info]="info-circle" |
| 179 | + [message]="message" |
| 180 | + [alarm]="bell-ringing" |
| 181 | + [flagged]="flag" |
| 182 | + [spam]="flame" |
| 183 | + [read]="mail-opened" |
| 184 | + [unread]="mail" |
| 185 | + [private]="lock" |
| 186 | + [recurring]="repeat" |
| 187 | + [loading]="loader" |
| 188 | +) |
| 189 | + |
| 190 | +# ============================================================================= |
| 191 | +# NAVIGATION ICONS |
| 192 | +# Used by: pagination, tree controls, breadcrumbs |
| 193 | +# Output: themes/default/graphics/nav/ |
| 194 | +# ============================================================================= |
| 195 | +declare -A NAV_ICONS=( |
| 196 | + [first]="chevrons-left" |
| 197 | + [last]="chevrons-right" |
| 198 | + [prev]="chevron-left" |
| 199 | + [next]="chevron-right" |
| 200 | + [up]="chevron-up" |
| 201 | + [down]="chevron-down" |
| 202 | + [home]="home" |
| 203 | + [back]="arrow-left" |
| 204 | + [folder]="folder" |
| 205 | + [folder-open]="folder-open" |
| 206 | + [file]="file" |
| 207 | + [tree-plus]="square-plus" |
| 208 | + [tree-minus]="square-minus" |
| 209 | +) |
| 210 | + |
| 211 | +# ============================================================================= |
| 212 | +# MAIN |
| 213 | +# ============================================================================= |
| 214 | + |
| 215 | +TOTAL_FAILED=0 |
| 216 | + |
| 217 | +run_category() { |
| 218 | + local name="$1" |
| 219 | + local dest="$2" |
| 220 | + local -n ref=$3 |
| 221 | + |
| 222 | + echo "" |
| 223 | + echo "=== ${name} (${SIZE}px) ===" |
| 224 | + echo "Output: ${dest}" |
| 225 | + echo "" |
| 226 | + |
| 227 | + if generate_icons "$dest" "$3"; then |
| 228 | + : |
| 229 | + else |
| 230 | + TOTAL_FAILED=$((TOTAL_FAILED + $?)) |
| 231 | + fi |
| 232 | +} |
| 233 | + |
| 234 | +case "$CATEGORY" in |
| 235 | + admin) |
| 236 | + run_category "Admin Dashboard" "${THEMES_DIR}/admin" ADMIN_ICONS |
| 237 | + ;; |
| 238 | + actions) |
| 239 | + run_category "Common Actions" "${THEMES_DIR}/actions" ACTION_ICONS |
| 240 | + ;; |
| 241 | + apps) |
| 242 | + run_category "Application Identity" "${THEMES_DIR}/apps" APP_ICONS |
| 243 | + ;; |
| 244 | + status) |
| 245 | + run_category "Status/Notifications" "${THEMES_DIR}/status" STATUS_ICONS |
| 246 | + ;; |
| 247 | + nav) |
| 248 | + run_category "Navigation" "${THEMES_DIR}/nav" NAV_ICONS |
| 249 | + ;; |
| 250 | + all) |
| 251 | + run_category "Admin Dashboard" "${THEMES_DIR}/admin" ADMIN_ICONS |
| 252 | + run_category "Common Actions" "${THEMES_DIR}/actions" ACTION_ICONS |
| 253 | + run_category "Application Identity" "${THEMES_DIR}/apps" APP_ICONS |
| 254 | + run_category "Status/Notifications" "${THEMES_DIR}/status" STATUS_ICONS |
| 255 | + run_category "Navigation" "${THEMES_DIR}/nav" NAV_ICONS |
| 256 | + ;; |
| 257 | + *) |
| 258 | + echo "Unknown category: $CATEGORY" |
| 259 | + echo "Valid: admin, actions, apps, status, nav, all" |
| 260 | + exit 1 |
| 261 | + ;; |
| 262 | +esac |
| 263 | + |
| 264 | +echo "" |
| 265 | +echo "==========================================" |
| 266 | +echo "Done." |
| 267 | +if [ $TOTAL_FAILED -gt 0 ]; then |
| 268 | + echo "WARNING: ${TOTAL_FAILED} icon(s) failed." |
| 269 | + exit 1 |
| 270 | +fi |
0 commit comments