make static homepage going into calendar.json archiving history.json

This commit is contained in:
fred 2022-04-11 00:50:10 +02:00
parent 915c7614a3
commit 538e65c5a9
2 changed files with 39 additions and 3 deletions

View File

@ -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": "<a href='"'_INDEX_'"'>_HIER_</a>"}]' > ~/.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

View File

@ -26,8 +26,8 @@
<!-- #$-:Please do not edit lines starting with "#$" -->
<!-- #$VERSION:2.3 -->
<!-- #$AUTHOR:fred -->
<area shape="rect" coords="0,0,330,62" href="http://crowdbunker.com" />
<area shape="rect" coords="421,3,876,57" href="http://crowdbunker.com/search?q=Astroport" />
<area shape="rect" coords="0,0,330,62" target="crowdbunker" href="http://crowdbunker.com" />
<area shape="rect" coords="421,3,876,57" target="crowdbunker" href="http://crowdbunker.com/search?q=Astroport" />
<area shape="rect" coords="1002,0,1264,61" target="code" href="https://qo-op.com" />
<area shape="rect" coords="3,64,1260,205" target="code" href="http://opencollective.com/monnaie-libre/projects/bunker-box" />
</map>
@ -54,6 +54,8 @@
</div>
</article>
<div id="calendarList"><div class="wrapper"></div></div>
<center>
<h6>
<a href="_IPNSL_"> _\/_ </a> powered by <a href="https://astroport.com"><span>"</span>Astroport<span>"</span></a>
@ -68,7 +70,7 @@
<link rel="stylesheet" href="styles/pagination.css" />
<script>
$.getJSON('_IPNSL_/history.json', function (json) {
$.getJSON('./history.json', function (json) {
$('#videosList').pagination({
dataSource: json.Videos,
pageSize: 1,
@ -80,6 +82,20 @@ $.getJSON('_IPNSL_/history.json', function (json) {
}
});
});
$.getJSON('./calendar.json', function (json) {
$('#calendarList').pagination({
dataSource: json.History,
pageSize: 1,
callback: function(data, pagination) {
var wrapper = $('#calendarList .wrapper').empty();
$.each(data, function (i, f) {
$('#calendarList .wrapper').append('<ul><li>' + f.link + '</li></ul>');
});
}
});
});
var arrTimes = [];
var i = 0; // start
var timesToTest = 5;