-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration keyword and support for attachments
- Loading branch information
Showing
21 changed files
with
1,156 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#!/usr/bin/env zsh | ||
|
||
set -e | ||
|
||
# URL of icon generator | ||
api="http://icons.deanishe.net/icon" | ||
here="$( cd "$( dirname "$0" )"; pwd )" | ||
root="$( cd "$here/../"; pwd )" | ||
# where workflow icons belong | ||
icondir="${root}/src/icons" | ||
# icon config file | ||
iconfile="${icondir}/icons.txt" | ||
|
||
prog="$( basename "$0" )" | ||
|
||
force=false | ||
verbose=false | ||
vopt= | ||
icons=() | ||
|
||
# log <arg>... | Echo arguments to STDERR | ||
log() { | ||
echo "$@" >&2 | ||
} | ||
|
||
# info <arg>.. | Write args to STDERR if VERBOSE is true | ||
info() { | ||
$verbose && log $(print -P "%F{blue}..%f") "$@" | ||
return 0 | ||
} | ||
|
||
# success <arg>.. | Write green "ok" and args to STDERR if VERBOSE is true | ||
success() { | ||
$verbose && log $(print -P "%F{green}ok%f") "$@" | ||
return 0 | ||
} | ||
|
||
# error <arg>.. | Write red "error" and args to STDERR | ||
error() { | ||
log $(print -P '%F{red}error%f') "$@" | ||
} | ||
|
||
# fail <arg>.. | Write red "error" and args to STDERR, then exit with status 1 | ||
fail() { | ||
error "$@" | ||
exit 1 | ||
} | ||
|
||
# load | Read configuration file from STDIN | ||
load() { | ||
typeset -g icons | ||
while read line; do | ||
|
||
# ignore lines that start with # or are empty | ||
[[ $line =~ "#" ]] || test -z "$line" && continue | ||
|
||
read fname font colour name <<< "$line" | ||
icons+=($fname $font $colour $name) | ||
|
||
done | ||
} | ||
|
||
usage() { | ||
cat <<EOF | ||
$prog [options] | ||
Download icons from server. | ||
Usage: | ||
$prog [-v] [-f] | ||
$prog -h | ||
Options: | ||
-f Force re-download | ||
-h Show this help message and exit | ||
-v Be verbose | ||
EOF | ||
} | ||
|
||
while getopts ":fhv" opt; do | ||
case $opt in | ||
f) | ||
force=true;; | ||
h) | ||
usage | ||
exit 0;; | ||
v) | ||
verbose=true | ||
vopt='-v' | ||
;; | ||
\?) | ||
fail "invalid option: -$OPTARG";; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
|
||
cat "$iconfile" | load | ||
|
||
success "loaded config from $iconfile" | ||
|
||
total=$(( ${#icons} / 4 )) | ||
fetched=0 | ||
j=0 | ||
for (( i=1; i<${#icons}; i=i+4 )); do | ||
j=$(( j + 1 )) | ||
|
||
fname=$icons[$i] | ||
font=$icons[$i+1] | ||
colour=$icons[$i+2] | ||
name=$icons[$i+3] | ||
|
||
# info "j=$j, name=$name, font=$font, fname=$fname" | ||
|
||
url="${api}/${font}/${colour}/${name}" | ||
n="${fname}.png" | ||
p="$icondir/$n" | ||
pc="[$j/$total]" | ||
|
||
# download source icon | ||
copts=(-L) | ||
$verbose && copts+=(-#) || copts+=(-sS) | ||
$force || ! test -s "$p" && { | ||
curl $copts -o "$p" "$url" | ||
[[ $? -ne 0 ]] && fail "couldn't download $n" | ||
success "downloaded $n" | ||
fetched=$(( fetched + 1 )) | ||
} || { | ||
info "skipped existing $n" | ||
} | ||
|
||
done | ||
|
||
verbose=true | ||
success "downloaded $fetched icon(s)" | ||
|
||
exit 0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Icons from webfonts via http://icons.deanishe.net | ||
# | ||
# Script ../bin/icons reads this file and downloads the | ||
# specified icons to this directory. | ||
# | ||
# Colours | ||
# blue: 5485F3 | ||
# yellow: F8AC30 | ||
# red: B00000 | ||
# green: 03AE03 | ||
# | ||
|
||
# filename font name colour icon name | ||
|
||
on fontawesome 03AE03 dot-circle-o | ||
off fontawesome B00000 circle-o | ||
reload fontawesome F8AC30 refresh | ||
update-available material F8AC30 cloud-download | ||
update-ok material 03AE03 cloud-done | ||
help material 03AE03 help | ||
docs material 5485F3 help | ||
issue fontawesome F8AC30 bug |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes.
File renamed without changes
Oops, something went wrong.