Browse Source

"todo / done" wordpress publication process

master
qo-op 1 month ago
parent
commit
1509af55f7
2 changed files with 36 additions and 19 deletions
  1. +1
    -1
      zen/new_file_in_astroport.sh
  2. +35
    -18
      zen/wordpress_channel.sh

+ 1
- 1
zen/new_file_in_astroport.sh View File

@ -275,7 +275,7 @@ then
## CREATE astroport call to Astroport/Wordpress stations
if [[ ! -d ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE} ]]; then
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE}
echo "0" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE}/do
echo "1" > ~/.zen/ipfs/.$IPFSNODEID/astroport/wordpress/${INDEXPREFIX}${REFERENCE}/do
fi
fi


+ 35
- 18
zen/wordpress_channel.sh View File

@ -4,7 +4,7 @@
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
[[ ! $(which wp) ]] && exit 0 # MUST RUN WORDPRESS and wp-cli
# Take care about Astroport/Wordpress "do/done" publication process
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
@ -16,30 +16,47 @@ IPFSNODEID=$(ipfs id -f='<id>\n')
[[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title)
## CREATION DE LA ZONE DE DIALOGUE IPFS SWARM
for wpcall in $(ls -d ~/.zen/ipfs_swarm/.12D*/astroport/wordpress/*/);
for wpcall in $(ls -d ~/.zen/ipfs_swarm/.12D*/astroport/wordpress/*);
do
echo "$wpcall"
done=$(cat $wpcall/do) && [[ "$done" != "0" ]] && echo "DONE" && continue # Already DONE
ls $wpcall
[[ -f $wpcall/do ]] && istodo=$(cat $wpcall/do)
[[ -f $wpcall/done ]] && isdone=$(cat $wpcall/done)
[[ ! $isdone && ! $istodo ]] && continue
ipfnodesource=$(echo "$wpcall" | cut -d '/' -f 6 | cut -d '.' -f 2 )
g1pubsource=$($MY_PATH/tools/ipfs_to_g1.py $ipfnodesource)
mediakey=$(echo "$wpcall" | cut -d '/' -f 9 )
echo "$ipfnodesource wants to publish $mediakey"
## GET ipns link + title + xzuid
ipnsid=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/.ipns.link)
title=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/.title)
xzuid=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/_xbian.zuid)
mynodename=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/G1SSB/_nodename)
GENRES="$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/ajouter_video.txt | cut -d ';' -f 6 | sed s/|/,/g)"
# 1=DIY, Habiter=2, Guerir=3, Divertir=4, Déplacer=5, Energie=6, Cultiver=7
wp post create --post_author='$xzuid' --post_content="<p><a href=\"https://$mynodename/ipns/$ipnsid\" target=\"_blank\" rel=\"noreferrer noopener\">$title</a></p>" --post_title="$title" --post_excerpt="Youtube" --post_category="1,7" --tags_input="youtube" --porcelain
if [[ "$ipfsnodeid" != "$IPFSNODEID" ]]; then
[[ ! $(which wp) ]] && continue # MUST RUN WORDPRESS and wp-cli
if [[ $istodo && ! $isdone ]]; then
## I am the destination of that "todo / not done" wpcall
echo "$ipfnodesource wants to publish $mediakey"
## GET ipns link + title + xzuid
ipnsid=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/.ipns.link)
title=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/.title)
xzuid=$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/_xbian.zuid)
mynodename=$(cat ~/.zen/ipfs_swarm/.$IPFSNODEID/G1SSB/_nodename)
genres="$(cat ~/.zen/ipfs_swarm/.$ipfnodesource/KEY/$mediakey/$g1pubsource/ajouter_video.txt | cut -d ';' -f 6 | sed s/|/,/g)"
# 1=DIY, Habiter=2, Guerir=3, Divertir=4, Déplacer=5, Energie=6, Cultiver=7
cd /var/www/wordpress/
isWPuser=$(wp user list | grep "$xzuid")
wp post create --post_author="$xzuid" --post_content="<p><a href=\"https://$mynodename/ipns/$ipnsid\" target=\"_blank\" rel=\"noreferrer noopener\">$title</a></p>" --post_title="$title" --post_excerpt="$g1pubsource" --tags_input="$genres" --porcelain
# REPLY done=1
responsedir="$(echo "$wpcall" | sed 's/ipfs_swarm/ipfs/g')"
mkdir -p $responsedir
echo "1" > $responsedir/done
fi
## I am the destination of that "done / not todo" wpcall
[[ $isdone && ! $istodo ]] && echo rm -Rf ~/.zen/ipfs/.$ipfnodesource/astroport/wordpress/$mediakey/done
# REPLY do=1
response="$(echo "$wpcall" | sed 's/ipfs_swarm/ipfs/g')"
echo "1" > $response
else
## I am the source of that "done" wpcall remove "do"
[[ $isdone ]] && echo rm -f ~/.zen/ipfs/.$ipfnodesource/astroport/wordpress/$mediakey/do
fi
done


Loading…
Cancel
Save