diff options
-rw-r--r-- | scripts/feedicon.sh | 32 | ||||
-rw-r--r-- | scripts/url.inc | 12 |
2 files changed, 36 insertions, 8 deletions
diff --git a/scripts/feedicon.sh b/scripts/feedicon.sh index 3253b42..5d2e537 100644 --- a/scripts/feedicon.sh +++ b/scripts/feedicon.sh @@ -183,12 +183,18 @@ get_feedicon() { return; fi - is_furl=$(echo $ICONURL | grep -i '^http') + is_furl=$(echo $ICONURL | grep -i '^http'); DATAURI=''; for u in $ICONURL; do # handle sites with multiple favicons if [ "$is_furl" ]; then fetch_feedicon $u else - fetch_feedicon "$BURL/$u" + if is_datauri $u; then #is a datauri + DATAURI=$u; + echo -e ${cGREEN}'msg: shortcut datauri-icon download success'${cNORMAL}; + return; + else + fetch_feedicon "$BURL/$u" + fi fi if is_file_ico $localIco; then echo -e ${cGREEN}'msg: shortcut icon download success'${cNORMAL}; @@ -200,6 +206,21 @@ get_feedicon() { } +_make_datauri_file() { + local _i="${localIco%%.ico}.ico.txt" + if [ $DATAURI != "" ]; then + echo $DATAURI > "$_i" + else + if [ ! -s "$localIco" ]; then return; fi + echo 'image/'${iconType}';base64,' > "$_i" + base64 "$localIco" >> "$_i" + fi + + chmod 0644 "$_i" + mv -f "$_i" "$ICONTXTDIR/$a/$b/$URLSUM.ico.txt" + echo -e ${cGREEN}'feedicon::update-feedicon -> creating datauri file done'${cNORMAL}; +} + update_feedicon() { local URLSUM=$1 a=$(echo $URLSUM | cut -b 1 -) @@ -227,12 +248,7 @@ update_feedicon() { fi get_feedicon $rssurl - if [ ! -s "$localIco" ]; then return; fi - local _i="${localIco%%.ico}.ico.txt" - echo 'image/'${iconType}';base64,' > "$_i" - base64 "$localIco" >> "$_i" - chmod 0644 "$_i" - mv -f "$_i" "$ICONTXTDIR/$a/$b/$URLSUM.ico.txt" + _make_datauri_file update_icon_status "$URLSUM" '1' "$dbname" echo -e ${cGREEN}'feedicon::update-feedicon -> icon update done'${cNORMAL}; diff --git a/scripts/url.inc b/scripts/url.inc index d9e7797..7fdb55c 100644 --- a/scripts/url.inc +++ b/scripts/url.inc @@ -23,3 +23,15 @@ parse_url () { path="$(echo $url | grep / | cut -d/ -f2-)" } +is_datauri () { + # http://en.wikipedia.org/wiki/Data_URI_scheme + # eg. href=data:image/gif;base64 + # src=data:image/png;base64 + + if [ ! -n "$1" ]; then return; fi + isHeader=0 + # check header + local header=$(echo $1 | grep -o -E '(^data:image/)(x-icon|png|gif|jpeg)(\;base64)') + if [ $header != "" ]; then isHeader=1; fi +} + |