From 9606644a0beb4f2883e1e0f4c6c81b42ab40b3a1 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 3 Apr 2023 00:24:49 +0300 Subject: Renaming to prefix convention, introduced ipfs wrappers so it can be easier to maintain, changes in filesplitter and filejoiner as they move sm submodule namespace... like there are namespaces in bash or something --- bin/ak-news | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'bin/ak-news') diff --git a/bin/ak-news b/bin/ak-news index 84f5ff8..1658065 100755 --- a/bin/ak-news +++ b/bin/ak-news @@ -1,19 +1,27 @@ #!/bin/bash +PROGRAM=$(basename $0) + ZNEWSDIR="$AK_WORKDIR/news" TEMP="/tmp/aktmp" -echo $ZNEWSDIR + +logit(){ + ak-logthis "<$PROGRAM>" "$1" "$2" +} + if [ ! -d $ZNEWSDIR ]; then mkdir $ZNEWSDIR - cd $ZNEWSDIR - git init - echo "News repository" > README - echo "Qmetc" >> README - git add README - git commit -m "Initiated news repository" - echo "znewsdir created along with git repo" + if [ "$?" == 0 ]; then + logit "[INFO]" "$ZNEWSDIR created" + else + logit "[ERROR]" "$ZNEWSDIR couldn't be created" + exit 1 + fi else - echo "znewsdir found" + logit "[INFO]" "$ZNEWSDIR found" fi + +cd $ZNEWSDIR + tempassin(){ if [ ! -z $1 ] then @@ -27,6 +35,7 @@ tempassin(){ fi cd $TEMPASSIN } + create(){ tempassin $TEMP curpath="$(pwd)" @@ -35,15 +44,12 @@ create(){ echo "Renaming..." TITLE="$(head -n 1 $NEWS_FILE)" TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) - IPFS_FILE=$(ipfs add -q $NEWS_FILE) + IPFS_FILE=$(ak-ipfs-add $NEWS_FILE) mv $NEWS_FILE $ZNEWSDIR/$TO_FILE sed -e 's,Qm.*,'"$IPFS_FILE"',g' $ZNEWSDIR/README add $TO_FILE echo "Adding to git repo..." cd $ZNEWSDIR - git add $TO_FILE README - git commit -m "Added $TO_FILE with $(head -n 1 $ZNEWSDIR/$TO_FILE)" - git clean --force # rm -rf $TEMP } index(){ @@ -53,13 +59,13 @@ index(){ do DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') TITLE=$(head -n 1 $ZNEWSDIR/$FILE) - echo $i \| $DATE \| $TITLE + IPFS_HASH=$(ak-ipfs-addn $ZNEWSDIR/$FILE) + echo $i \| $IPFS_HASH \| $DATE \| $TITLE let i+=1 done } title(){ - echo ak-news-cli - echo "--------------" + echo $PROGRAM } import(){ echo "#TODO" @@ -93,10 +99,10 @@ add2(){ echo "Adding news from " $FILE DATETIME=$(echo $FILE | cut -d - -f 1 | awk '{print $1}') TITLE=$(head -n 1 $FILE) - FILE_IPFS_HASH=$(ipfs add -q $FILE) + FILE_IPFS_HASH=$(ak-ipfs-add $FILE) FILE_SIGN_FILE=$FILE".asc" gpg --detach-sign --sign-with $FINGERPRINT --armor --output $FILE_SIGN_FILE $FILE - FILE_SIGNATURE=$(ipfs add -q $FILE_SIGN_FILE) + FILE_SIGNATURE=$(ak-ipfs-add $FILE_SIGN_FILE) cat > data < data < #TODO" echo "add Creates a data file from the news file you point to" echo "create Vim is going to pop up, you will write and save your" @@ -167,7 +173,7 @@ title if [ ! -z $1 ]; then case $1 in help) usage; exit;; - index) index; exit;; + local-index) index; exit;; import) import $2; exit;; add) add2 $2; exit;; create) create; exit;; -- cgit v1.2.3