aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-02 05:46:40 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-02 05:46:40 +0200
commita6c00d58d0818fb6495f8407ff2573ff77bf29d6 (patch)
tree4a49bbc5b39bfc94c4d6833195cffb2eaba66c19 /bin
parent82934d0325e61669c877122b721f5fe72a25bea5 (diff)
downloadarching-kaos-tools-a6c00d58d0818fb6495f8407ff2573ff77bf29d6.tar.gz
arching-kaos-tools-a6c00d58d0818fb6495f8407ff2573ff77bf29d6.tar.bz2
arching-kaos-tools-a6c00d58d0818fb6495f8407ff2573ff77bf29d6.zip
Refactored ak-articles to match rest of scripts
- Removed git intergration - Uses logit now instead of printing to stdout - Checks for `EDITOR` variable instead of blindly running vi - Spacings fix - Removes temp dir after 'add' command is done
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ak-articles36
1 files changed, 20 insertions, 16 deletions
diff --git a/bin/ak-articles b/bin/ak-articles
index 9e7c7b4..22222cb 100755
--- a/bin/ak-articles
+++ b/bin/ak-articles
@@ -40,22 +40,26 @@ fi
_ak_modules_articles_create(){
TEMP="$(ak-tempassin)"
cd $TEMP
- pwd
- export ARTICLES_FILE="$(date +%Y%m%d_%H%M%S)"
- vi $ARTICLES_FILE
- echo "Renaming..."
- TITLE="$(head -n 1 $ARTICLES_FILE)"
- TO_FILE=$ARTICLES_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' )
- IPFS_FILE=$(ak-ipfs-add $ARTICLES_FILE)
- mv $ARTICLES_FILE $ZARTICLESDIR/$TO_FILE
- sed -e 's,Qm.*,'"$IPFS_FILE"',g' $ZARTICLESDIR/README
- _ak_modules_articles_add $ZARTICLESDIR/$TO_FILE
- echo "Adding to git repo..."
- cd $ZARTICLESDIR
- git add $TO_FILE README
- git commit -m "Added $TO_FILE with $(head -n 1 $ZARTICLESDIR/$TO_FILE)"
- git clean --force
- # rm -rf $TEMP
+ export ARTICLES_FILE="$(date +%Y%m%d_%H%M%S)"
+ if [ -z $EDITOR ]
+ then
+ logit "ERROR" "No $EDITOR found. Exiting..."
+ exit 1
+ fi
+ $EDITOR $ARTICLES_FILE
+ logit "INFO" "Renaming..."
+ TITLE="$(head -n 1 $ARTICLES_FILE)"
+ TO_FILE=$ARTICLES_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' )
+ IPFS_FILE=$(ak-ipfs-add $ARTICLES_FILE)
+ mv $ARTICLES_FILE $ZARTICLESDIR/$TO_FILE
+ sed -e 's,Qm.*,'"$IPFS_FILE"',g' $ZARTICLESDIR/README
+ _ak_modules_articles_add $ZARTICLESDIR/$TO_FILE
+ logit "INFO" "Adding to git repo..."
+ cd $ZARTICLESDIR
+ # git add $TO_FILE README
+ # git commit -m "Added $TO_FILE with $(head -n 1 $ZARTICLESDIR/$TO_FILE)"
+ # git clean --force
+ rm -rf $TEMP
}
_ak_modules_articles_index(){
FILES="$(ls -1 $ZARTICLESDIR)"