From fcca3cfad1008459b30a09ad245458f83d213806 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 12 Jan 2024 06:43:34 +0200 Subject: local-index subcommand enhancment Figures if files are published already in your zchain --- bin/ak-news | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/ak-news b/bin/ak-news index c020d1a..1b6ff9b 100755 --- a/bin/ak-news +++ b/bin/ak-news @@ -43,14 +43,23 @@ create(){ index(){ FILES="$(ls -1 $ZNEWSDIR)" i=0 + ak-get-ipfs-hashes-from-my-zchain | sort | uniq > temp for FILE in $FILES do - DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') - TITLE=$(head -n 1 $ZNEWSDIR/$FILE) - IPFS_HASH=$(ak-ipfs-addn $ZNEWSDIR/$FILE) - echo $i \| $IPFS_HASH \| $DATE \| $TITLE + DATE="$(echo $FILE | cut -d - -f 1 | awk '{print $1}')" + TITLE="$(head -n 1 $ZNEWSDIR/$FILE)" + IPFS_HASH="$(ipfs add -nQ $ZNEWSDIR/$FILE)" + ONLINE="Not in zchain" + grep "$IPFS_HASH" temp > /dev/null 2>&1 + if [ $? -eq 0 ] + then + ONLINE="On zchain" + fi + printf "%3d | %5s | %52s | %10s | %56s \n"\ + "$i" "$ONLINE" "$IPFS_HASH" "$DATE" "$TITLE" let i+=1 done + rm temp } title(){ echo $PROGRAM -- cgit v1.2.3