Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
matrix-stickers
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Anthony "Phoko" Barbier
matrix-stickers
Validations
7c4d7d26
Valider
7c4d7d26
rédigé
2 years ago
par
Elliu
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Bugfix
parent
267b8cf5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
stpkg
+19
-17
19 ajouts, 17 suppressions
stpkg
avec
19 ajouts
et
17 suppressions
stpkg
+
19
−
17
Voir le fichier @
7c4d7d26
...
...
@@ -5,7 +5,7 @@ shopt -s nocasematch # Case insensitive
STPKG_CONF_FILE
=
~/.config/stpkg.sh
BASE_DIR
=
"
$PWD
"
animatedFiletype
=(
gif apng
)
declare
-A
animatedFiletype
=(
gif apng
)
# Detect install
if
[
"x
$1
"
=
"x-install"
]
;
then
...
...
@@ -56,7 +56,7 @@ require() {
}
require
\
md5sum mktemp
column uuidgen convert montage identify python3 curl
\
sed tr
git sponge
ls
find jq
chmod cat expr
iconv
sed tr
git sponge
ls
find jq
chmod cat expr
iconv
bc
__grep
=
`
which egrep
`
if
[
-z
$__grep
]
;
then
__grep
=
`
which
grep
`
...
...
@@ -175,7 +175,7 @@ __upload_file() {
local
NAME
=
$3
# The pretty name for the sticker
# TODO: Use jq here
curl
-s
-X
POST
-H
\
"Content-Type:
image/
$TYPE
"
--data-binary
"@
$
DEST
"
"https://
$STPKG_HOMESERV
/_matrix/media/r0/upload?access_token=
$STPKG_TOKEN
"
|
\
"Content-Type:
$TYPE
"
--data-binary
"@
$
FILE
"
"https://
$STPKG_HOMESERV
/_matrix/media/r0/upload?access_token=
$STPKG_TOKEN
"
|
\
tee
/tmp/toto | python
-c
"import sys, json; print(json.load(sys.stdin)['content_uri'])"
[
$?
-ne
0
]
&&
die
"Failed to upload sticker
$NAME
for pack
$PACK_NAME
to
$STPKG_HOMESERV
"
}
...
...
@@ -274,6 +274,9 @@ STPKG_MAX_WIDTH=256
STPKG_GENERATE_PREVIEW="no"
STPKG_IMAGE_TARGET_FILETYPE="png"
STPKG_ANIMATED_TARGET_FILETYPE="gif"
__do_mount() { :; }
EOF
chmod
00600
$STPKG_CONF_FILE
...
...
@@ -578,8 +581,8 @@ process_sticker_file() {
local
INIT_WIDTH
=
$(
file_get_width
"
$FILE
"
)
local
INIT_HEIGHT
=
$(
file_get_height
"
$FILE
"
)
local
WIDTH_RATIO
=
"
$(
echo
"scale=10;
$INIT_WIDTH
/
$STPKG_MAX_WIDTH
"
)
"
local
HEIGHT_RATIO
=
"
$(
echo
"scale=10;
$INIT_HEIGHT
/
$STPKG_MAX_HEIGHT
"
)
"
local
WIDTH_RATIO
=
"
$(
echo
"scale=10;
$INIT_WIDTH
/
$STPKG_MAX_WIDTH
"
| bc
)
"
local
HEIGHT_RATIO
=
"
$(
echo
"scale=10;
$INIT_HEIGHT
/
$STPKG_MAX_HEIGHT
"
| bc
)
"
if
[
$(
echo
"
$HEIGHT_RATIO
>=
$WIDTH_RATIO
"
| bc
)
=
"1"
]
;
then
if
[
$(
echo
"
$HEIGHT_RATIO
> 1"
| bc
)
=
"1"
]
;
then
...
...
@@ -589,18 +592,17 @@ process_sticker_file() {
local
DEST_HEIGHT
=
$INIT_HEIGHT
local
DEST_WIDTH
=
$INIT_WIDTH
fi
elif
[
$(
echo
"
$WIDTH_RATIO
> 1"
| bc
)
=
"1"
]
;
then
local
DEST_HEIGHT
=
""
local
DEST_WIDTH
=
$STPKG_MAX_WIDTH
else
if
[
$(
echo
"
$WIDTH_RATIO
> 1"
| bc
)
=
"1"
]
;
then
local
DEST_HEIGHT
=
""
local
DEST_WIDTH
=
$STPKG_MAX_WIDTH
else
local
DEST_HEIGHT
=
$INIT_HEIGHT
local
DEST_WIDTH
=
$INIT_WIDTH
fi
local
DEST_HEIGHT
=
$INIT_HEIGHT
local
DEST_WIDTH
=
$INIT_WIDTH
fi
# Get the names and extensions
local
INIT_TYPE
=
$(
file_get_type
"
$FILE
"
)
local
INIT_EXT
=
$(
file_get_ext_from_type
"
$INIT_TYPE
"
)
local
NAME
=
$(
file_get_name
"
$FILE
"
)
local
TEMP
=
`
mktemp
--suffix
=
.stpkg
`
...
...
@@ -625,7 +627,7 @@ process_sticker_file() {
progress_dot
else
if
[[
${
animatedFiletype
[
$INIT_
TYPE
]
}
]]
;
then
if
[[
${
animatedFiletype
[
$INIT_
EXT
]
}
]]
;
then
#
# Convert animated image
#
...
...
@@ -637,11 +639,11 @@ process_sticker_file() {
# Convert fixed image
#
local
DEST_TYPE
=
$STPKG_IMAGE_TARGET_FILETYPE
local
BONUS_OPT
=
"+repage"
local
BONUS_OPT
=
"
-trim
+repage"
fi
local
DEST_EXT
=
$(
file_get_ext_from_type
"
$DEST_TYPE
"
)
convert
"
$FILE
"
-bordercolor
none
-border
1
-background
none
-gravity
center
-resize
${
DEST_WIDTH
}
x
${
DEST_HEIGHT
}
${
BONUS_OPT
}
"
${
DEST_EXT
}
:
${
TEMP
}
"
1>&2
\
convert
"
$FILE
"
-bordercolor
none
-border
1
${
BONUS_OPT
}
-background
none
-gravity
center
-resize
${
DEST_WIDTH
}
x
${
DEST_HEIGHT
}
"
${
DEST_EXT
}
:
${
TEMP
}
"
1>&2
\
&&
progress_dot
\
||
die
"
$NAME
failed converting the sticker"
...
...
@@ -781,7 +783,7 @@ __pack() {
# For the report
[
"x
$FIRST_IN_ARRAY
"
=
"x"
]
&&
echo
-e
"StickerName MXC Type Width Height"
local
FIRST_IN_ARRAY
=
","
echo
-e
"
$ST_JSON
"
| jq
'[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
echo
-e
"
$ST_JSON
"
| jq
-r
'[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
progress_reset
done
| column
-t
...
...
@@ -900,7 +902,7 @@ __do_command() {
*
)
;;
esac
$*
__
$*
}
######################
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter