diff --git a/crowdbunker.sh b/crowdbunker.sh index b8002c4..6c9e4c3 100755 --- a/crowdbunker.sh +++ b/crowdbunker.sh @@ -29,6 +29,22 @@ IPFSNGW="http://127.0.0.1:8080" [[ ! $isLAN ]] && IPFSNGW="https://$(hostname)" echo "IPFS GATEWAY $IPFSNGW" +## History Rotation +hier=$(date --date="yesterday" +"%Y-%m-%d") +# New day! 00:00 is passed... +if [[ ! -f ~/.zen/bunkerbox/history_${hier}.json && -f ~/.zen/bunkerbox/homepage/chain ]]; then + NUMBER=$(cat ~/.zen/bunkerbox/history.json | jq '.Videos[].link' | wc -l) && echo ".ROTATION. Hier historique de $NUMBER Videos." + [[ -f ~/.zen/bunkerbox/history.json ]] && mv ~/.zen/bunkerbox/history.json ~/.zen/bunkerbox/history_${hier}.json + ## CREATE/UPDATE calendar.json + [[ ! -f ~/.zen/bunkerbox/calendar.json || $(cat ~/.zen/bunkerbox/calendar.json 2>/dev/null) == "" ]] && cp ${MY_PATH}/templates/data/calendar.json ~/.zen/bunkerbox/calendar.json + cat ~/.zen/bunkerbox/calendar.json | jq '.History += [{"link": "_HIER_"}]' > ~/.zen/tmp/calendar.json + sed -i "s~_INDEX_~/ipfs/$(cat ~/.zen/bunkerbox/homepage/chain)~g" ~/.zen/tmp/calendar.json + sed -i "s~_HIER_~${hier} ($NUMBER)~g" ~/.zen/tmp/calendar.json + + [[ "$(cat ~/.zen/tmp/calendar.json)" == "" ]] && echo "NO calendar.json FATAL ERROR" && exit 1 + cp ~/.zen/tmp/calendar.json ~/.zen/bunkerbox/calendar.json +fi + ## GET LATEST VIDEOS VWALLURL="https://api.crowdbunker.com/post/all" curl -s $VWALLURL -H "Accept: application/json" > ~/.zen/bunkerbox/crowd.json @@ -300,12 +316,14 @@ echo "########################################################################## sed -i "s~_IPNSL_~$IPNSL~g" ~/.zen/bunkerbox/homepage/index.html cp ~/.zen/bunkerbox/history.json ~/.zen/bunkerbox/homepage/history.json + cp ~/.zen/bunkerbox/calendar.json ~/.zen/bunkerbox/homepage/calendar.json cp ~/.zen/bunkerbox/history.${CHANNEL}.json ~/.zen/bunkerbox/homepage/history.${CHANNEL}.json echo "$TS" > ~/.zen/bunkerbox/homepage/ts # TimeStamping echo "Adding ~/.zen/bunkerbox/homepage/* to IPFS " VROOT=$(ipfs add -rwHq ~/.zen/bunkerbox/homepage/* | tail -n 1) echo "'qo-op' update with /ipfs/$VROOT" ipfs name publish --key=qo-op /ipfs/$VROOT + echo "$VROOT" > ~/.zen/bunkerbox/homepage/chain # Memorize chain ipfs reference echo "HOME : $IPFSNGW/ipns/$IPNS/" echo "HISTORY : $IPFSNGW/ipns/$IPNS/history.json" fi @@ -321,3 +339,5 @@ echo "########################################################################## end=`date +%s`; echo ___Duration `expr $end - $start` seconds___ done + + diff --git a/templates/homepage.html b/templates/homepage.html index 530a68d..2bee560 100644 --- a/templates/homepage.html +++ b/templates/homepage.html @@ -26,8 +26,8 @@ - - + + @@ -54,6 +54,8 @@ +
+
_\/_ powered by "Astroport" @@ -68,7 +70,7 @@