Skip to content
Extraits de code Groupes Projets
Valider c4064db6 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Finished pack command, with working upload

parent 4a65148e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -380,9 +380,6 @@ __pack() { ...@@ -380,9 +380,6 @@ __pack() {
local NAME=`echo "$FILE" | cut -f1 -d'.'` local NAME=`echo "$FILE" | cut -f1 -d'.'`
local DEST="$DEST_FOLDER/$NAME.$TYPE" local DEST="$DEST_FOLDER/$NAME.$TYPE"
# For the report
echo -e "$NAME $TYPE $WIDTH $HEIGHT"
# For the progress # For the progress
progress "($CURRENT_FILE/$TOTAL_FILES) $NAME " progress "($CURRENT_FILE/$TOTAL_FILES) $NAME "
CURRENT_FILE=$[ $CURRENT_FILE + 1 ] CURRENT_FILE=$[ $CURRENT_FILE + 1 ]
...@@ -397,12 +394,18 @@ __pack() { ...@@ -397,12 +394,18 @@ __pack() {
# Add a ',' only if it's not the first in the array # Add a ',' only if it's not the first in the array
echo -n "$FIRST_IN_ARRAY" >> $DEST_INDEX echo -n "$FIRST_IN_ARRAY" >> $DEST_INDEX
FIRST_IN_ARRAY=","
# Upload TODO # Upload
local MXC=1 # TODO: Use jq here
local MXC=`curl -s -X POST -H "Content-Type: image/$TYPE" --data-binary "@$DEST" \
"https://$STPKG_HOMESERV/_matrix/media/r0/upload?access_token=$STPKG_TOKEN" | \
python -c "import sys, json; print(json.load(sys.stdin)['content_uri'])" \
|| die "Failed to upload sticker $NAME for pack $PACK_NAME to $STPKG_HOMESERV"`
progress_dot
# Calculate the 128x128 format # Calculate the 128x128 format
local INIT_WIDTH=$WIDTH
local INIT_HEIGHT=$HEIGHT
convert "$DEST" -resize "128x128" "$DEST" 1>&2 \ convert "$DEST" -resize "128x128" "$DEST" 1>&2 \
&& progress_dot || die "$NAME failed at 128x128 resize" && progress_dot || die "$NAME failed at 128x128 resize"
WIDTH=$( identify -format "%w" "$DEST") >/dev/null WIDTH=$( identify -format "%w" "$DEST") >/dev/null
...@@ -413,13 +416,18 @@ __pack() { ...@@ -413,13 +416,18 @@ __pack() {
"\"w\":$WIDTH,\"thumbnail_url\":\"$MXC\"},\"msgtype\":\"m.sticker\",\"url\":\"$MXC\"" \ "\"w\":$WIDTH,\"thumbnail_url\":\"$MXC\"},\"msgtype\":\"m.sticker\",\"url\":\"$MXC\"" \
",\"id\":\"$PACK_NAME-$NAME\"}" >> $DEST_INDEX ",\"id\":\"$PACK_NAME-$NAME\"}" >> $DEST_INDEX
# For the report
[ "x$FIRST_IN_ARRAY" = "x" ] && echo -e "StickerName MXC Type Width Height"
FIRST_IN_ARRAY=","
echo -e "$NAME ($MXC) $TYPE $INIT_WIDTH $INIT_HEIGHT"
progress_reset progress_reset
done | column -t | sort done | column -t
# Create the preview # Create the preview
montage "$DEST_FOLDER/*.{png,gif}" -background none "$DEST_FOLDER/preview.png" montage "$DEST_FOLDER/*.{png,gif}" -background none "$DEST_FOLDER/preview.png"
echo -ne "# $PACK_NAME\n![Preview of $PACK_NAME](preview.png)" > "$DEST_FOLDER/README.md" echo -ne "# $PACK_NAME\n![Preview of $PACK_NAME](preview.png)" > "$DEST_FOLDER/README.md"
find $DEST_FOLDER -type f \( ! -name "preview.png" \) -exec rm {} \; find $DEST_FOLDER -type f \( ! -name "preview.png" -and ! -name "$PACK_NAME.json" \) -exec rm {} \;
echo -n "]}" >> $DEST_INDEX echo -n "]}" >> $DEST_INDEX
info "Pack created, you can now commit it and create a MR to share it with other users" info "Pack created, you can now commit it and create a MR to share it with other users"
...@@ -431,29 +439,11 @@ __pack() { ...@@ -431,29 +439,11 @@ __pack() {
[ "x$1" = "x" ] && usage [ "x$1" = "x" ] && usage
case "$1" in case "$1" in
update) update) __update ;;
__update list) shift; __list $* ;;
;; add) shift; __add $* ;;
list) del) shift; __del $* ;;
shift default) __default ;;
__list $* pack) shift; __pack $* ;;
;; *) usage ;;
add)
shift
__add $*
;;
del)
shift
__del $*
;;
default)
__default
;;
pack)
shift
__pack $*
;;
*)
usage
;;
esac esac
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter