Astroport.ONE/tools/make_image_ipfs_index_carou...

171 lines
5.9 KiB
Bash
Raw Normal View History

2023-01-06 06:23:34 +01:00
#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
. "$MY_PATH/my.sh"
#Set Path to Images
img_dir="$1"
if [[ ! -d $img_dir ]]; then
2023-03-11 14:36:41 +01:00
PLAYERONE=($(ls -t ~/.zen/game/players/ | grep "@" 2>/dev/null))
[[ ! $PLAYERONE ]] && echo "NO PLAYER IN THE GAME HERE" && exit 1
echo "ASTROPORT STATION CAROUSEL MODE"
rm -Rf ~/.zen/tmp/carousel 2>/dev/null
mkdir -p ~/.zen/tmp/carousel
# Make it with latest PLAYERS WALLETS
## RUNING FOR ALL LOCAL PLAYERS
for PLAYER in ${PLAYERONE[@]}; do
pub=$(cat ~/.zen/game/players/$PLAYER/.g1pub)
# Get PLAYER wallet amount :: ~/.zen/game/players/${PLAYER}/ipfs/G1SSB/COINS
2023-03-15 05:06:49 +01:00
echo "$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey balance"
2023-03-15 01:36:20 +01:00
$MY_PATH/COINScheck.sh $pub > ~/.zen/tmp/coins
cat ~/.zen/tmp/coins
COINS=$(cat ~/.zen/tmp/coins | tail -n 1)
echo "+++ ${PLAYER} have $COINS Ğ1 Coins +++"
2023-03-15 05:06:49 +01:00
## USE G1BARRE OR G1WorldMap.png AS 1ST IMAGE
2023-03-15 05:17:09 +01:00
curl -m 3 -so ~/.zen/tmp/carousel/${pub}.one.png \
"https://g1sms.fr/g1barre/image.php?pubkey=${pub}&target=20000&title=${PLAYER}&node=g1.asycn.io&start_date=2020-01-01&display_pubkey=true&display_qrcode=true"
2023-03-15 05:06:49 +01:00
[[ $(file -b ~/.zen/tmp/carousel/${pub}.one.png | cut -d ' ' -f 1) == "PNG" ]] \
&& echo "GOT ~/.zen/tmp/carousel/${pub}.one.png" \
|| cp $MY_PATH/../images/G1WorldMap.png ~/.zen/tmp/carousel/${pub}.one.png
CIMG="$MY_PATH/../images/g1ticket.png"
amzqr ${pub} -l H -p "$CIMG" -c -n QRG1avatar.png -d ~/.zen/game/players/${PLAYER}/
2023-03-15 05:50:05 +01:00
convert ~/.zen/game/players/${PLAYER}/QRG1avatar.png -resize 250 ~/.zen/tmp/QR.png
composite -compose Over -gravity NorthEast -geometry +0+0 ~/.zen/tmp/QR.png ~/.zen/tmp/carousel/${pub}.one.png ~/.zen/tmp/one.png
2023-03-12 22:31:11 +01:00
## WRITE ON IT : ASK FOR REFILL
2023-03-13 04:26:59 +01:00
convert -font 'Liberation-Sans' \
2023-03-15 05:52:08 +01:00
-pointsize 80 -fill purple -draw 'text 50,120 "'"$COINS Ğ1"'"' \
2023-03-15 06:15:18 +01:00
-pointsize 30 -fill purple -draw 'text 40, 180 "'"$PLAYER"'"' \
2023-03-15 20:11:22 +01:00
-pointsize 14 -fill white -draw 'text 40, 200 "'"$(date)"'"' \
2023-03-15 05:06:49 +01:00
"${HOME}/.zen/tmp/one.png" "${HOME}/.zen/tmp/carousel/${pub}.png" \
2023-03-13 05:14:51 +01:00
&& rm ${HOME}/.zen/tmp/carousel/${pub}.one.png
2023-03-12 22:31:11 +01:00
## PREPARE LOOP LINK LINE
ASTRONAUTENS=$(cat ~/.zen/game/players/${PLAYER}/.playerns)
2023-03-12 22:31:11 +01:00
[[ $COINS -gt 0 ]] \
2023-03-13 05:52:49 +01:00
&& echo "<a href=\"javascript:homeAstroportStation('"$myASTROPORT"/?qrcode="$ASTRONAUTENS"', 'tab', '2500')\" title=\"$PLAYER ($COINS G1)\">_REPLACE_</a>" > ~/.zen/tmp/carousel/${pub}.insert \
2023-03-12 22:31:11 +01:00
|| echo "_REPLACE_" > ~/.zen/tmp/carousel/${pub}.insert
2023-03-13 00:50:08 +01:00
done
img_dir="$HOME/.zen/tmp/carousel"
fi
2023-01-06 06:23:34 +01:00
#Set Path to HTML page
html_file="/tmp/index.html"
2023-03-09 19:42:41 +01:00
core_file="/tmp/core.html"
2023-01-06 06:23:34 +01:00
#Create HTML page
echo "<!DOCTYPE html>
<html>
<head>
<title>Astroport ZEN Gallery : $myIP</title>
2023-01-06 06:23:34 +01:00
<meta charset=\"UTF-8\">
2023-03-09 19:42:41 +01:00
</head>
<body>" > $html_file
echo "<link rel=\"stylesheet\" href=\"/ipfs/QmX9QyopkTw9TdeC6yZpFzutfjNFWP36nzfPQTULc4cYVJ/bootstrap.min.css\">
2023-03-13 18:55:13 +01:00
<script src=\"/ipfs/QmUre8yT9cMnkDikXWLbvCAurDB16EiYxBwrX9VCComhC8/astro.js\"></script>
2023-03-13 00:50:08 +01:00
2023-01-06 06:23:34 +01:00
<style>
.carousel-item {
background-color: #0B0C10;
}
.carousel-indicators li {
background-color: #0B0C10;
}
.carousel-indicators .active {
background-color: #FFFFFF;
}
</style>
2023-03-15 20:11:22 +01:00
<h3 id=\"countdown\"> $myHOST :: ${#PLAYERONE[@]}</h3>
2023-03-12 22:31:11 +01:00
2023-01-06 06:23:34 +01:00
<div class=\"container\">
2023-01-06 06:23:34 +01:00
<div id=\"myCarousel\" class=\"carousel slide\" data-ride=\"carousel\">
<!-- Indicators -->
<ul class=\"carousel-indicators\">
2023-03-09 19:42:41 +01:00
<li data-target=\"#myCarousel\" data-slide-to=\"0\" class=\"active\"></li>" > $core_file
2023-01-06 06:23:34 +01:00
#Loop over images
num=1
for i in "$img_dir"/*; do
2023-01-11 20:57:59 +01:00
if [[ $i =~ \.(JPG|jpg|PNG|png|JPEG|jpeg|GIF|gif)$ ]]; then
2023-01-06 06:23:34 +01:00
if [ $num -ne 1 ]; then
2023-03-09 19:42:41 +01:00
echo " <li data-target=\"#myCarousel\" data-slide-to=\"$num\"></li>" >> $core_file
2023-01-06 06:23:34 +01:00
fi
num=$((num+1))
fi
done
echo " </ul>
<!-- The slideshow -->
2023-03-09 19:42:41 +01:00
<div class=\"carousel-inner\">" >> $core_file
2023-01-06 06:23:34 +01:00
#Loop over images
num=1
for i in "$img_dir"/*; do
2023-01-11 20:57:59 +01:00
if [[ $i =~ \.(JPG|jpg|PNG|png|JPEG|jpeg|GIF|gif)$ ]]; then
2023-02-11 21:48:26 +01:00
ilink=$(ipfs add -q "$i")
img_info=$(identify -format '%w %h %[EXIF:*]' "$i")
2023-01-06 06:23:34 +01:00
img_width=$(echo $img_info | cut -d ' ' -f1)
img_height=$(echo $img_info | cut -d ' ' -f2)
img_alt=$(echo $img_info | cut -d ' ' -f3)
MORE="${i%.png}.insert"
echo "$MORE"
LINK="<img src=\"/ipfs/$ilink\" alt=\"$img_alt\" width=\"$img_width\" height=\"$img_height\">"
[[ -s $MORE ]] && ZLINK=$(cat $MORE | sed "s~_REPLACE_~$LINK~g") || ZLINK="$LINK"
echo $ZLINK
2023-01-06 06:23:34 +01:00
if [ $num -eq 1 ]; then
echo " <div class=\"carousel-item active\">
$ZLINK
2023-03-09 19:42:41 +01:00
</div>" >> $core_file
2023-01-06 06:23:34 +01:00
else
echo " <div class=\"carousel-item\">
$ZLINK
2023-03-09 19:42:41 +01:00
</div>" >> $core_file
2023-01-06 06:23:34 +01:00
fi
num=$((num+1))
fi
done
echo " </div>
<!-- Left and right controls -->
<a class=\"carousel-control-prev\" href=\"#myCarousel\" data-slide=\"prev\">
<span class=\"carousel-control-prev-icon\"></span>
</a>
<a class=\"carousel-control-next\" href=\"#myCarousel\" data-slide=\"next\">
<span class=\"carousel-control-next-icon\"></span>
</a>
</div>
</div>
2023-02-23 22:15:58 +01:00
<script src=\"/ipfs/QmX9QyopkTw9TdeC6yZpFzutfjNFWP36nzfPQTULc4cYVJ/jquery-3.2.1.slim.min.js\"></script>
<script src=\"/ipfs/QmX9QyopkTw9TdeC6yZpFzutfjNFWP36nzfPQTULc4cYVJ/popper.min.js\"></script>
2023-03-09 19:42:41 +01:00
<script src=\"/ipfs/QmX9QyopkTw9TdeC6yZpFzutfjNFWP36nzfPQTULc4cYVJ/bootstrap.min.js\"></script>" >> $core_file
2023-01-06 06:23:34 +01:00
2023-03-09 19:42:41 +01:00
cat $core_file >> $html_file
echo "</body></html>" >> $html_file
2023-01-06 06:23:34 +01:00
htmlipfs=$(ipfs add -q $html_file)
[[ $XDG_SESSION_TYPE == 'x11' ]] && xdg-open http://ipfs.localhost:8080/ipfs/$htmlipfs
2023-03-15 05:37:03 +01:00
echo "/ipfs/$htmlipfs"
2023-01-06 06:23:34 +01:00
exit 0