aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-categories
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-04-03 05:15:00 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-04-03 05:15:00 +0300
commitfc91066907e4d16a951c8d72d23aa610945f5407 (patch)
tree8d66ab33ae012ba185810b7462cd58687b6be38b /bin/ak-categories
parentad7d6281475c4adb67e0a43017803aeb4a9059ce (diff)
downloadarching-kaos-tools-fc91066907e4d16a951c8d72d23aa610945f5407.tar.gz
arching-kaos-tools-fc91066907e4d16a951c8d72d23aa610945f5407.tar.bz2
arching-kaos-tools-fc91066907e4d16a951c8d72d23aa610945f5407.zip
Clean up, elimination of duplicate tempassins, fixed current directory problems, introduced new tool
Diffstat (limited to 'bin/ak-categories')
-rwxr-xr-xbin/ak-categories45
1 files changed, 18 insertions, 27 deletions
diff --git a/bin/ak-categories b/bin/ak-categories
index 45d11ff..d72453f 100755
--- a/bin/ak-categories
+++ b/bin/ak-categories
@@ -1,18 +1,14 @@
#!/bin/bash
-ZNEWSDIR="$AK_WORKDIR/news"
-TEMP="/tmp/aktmp"
-echo $ZNEWSDIR
-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"
+AK_CATEGORIES="$AK_WORKDIR/categories"
+PROGRAM="$(basename $0)"
+
+echo $AK_CATEGORIES
+if [ ! -d $AK_CATEGORIES ]; then
+ mkdir $AK_CATEGORIES
+ cd $AK_CATEGORIES
+ echo "AK_CATEGORIES created"
else
- echo "znewsdir found"
+ echo "AK_CATEGORIES found"
fi
create(){
@@ -24,31 +20,26 @@ create(){
TITLE="$(head -n 1 $NEWS_FILE)"
TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' )
IPFS_FILE=$(ak-ipfs-add $NEWS_FILE)
- mv $NEWS_FILE $ZNEWSDIR/$TO_FILE
- sed -e 's,Qm.*,'"$IPFS_FILE"',g' $ZNEWSDIR/README
- add $ZNEWSDIR/$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
+ mv $NEWS_FILE $AK_CATEGORIES/$TO_FILE
+ sed -e 's,Qm.*,'"$IPFS_FILE"',g' $AK_CATEGORIES/README
+ add $AK_CATEGORIES/$TO_FILE
+ cd $AK_CATEGORIES
}
index(){
- FILES="$(ls -1 $ZNEWSDIR)"
+ FILES="$(ls -1 $AK_CATEGORIES)"
i=0
for FILE in $FILES
do
DATE=$(echo $FILE | cut -d - -f 1 | awk '{print $1}')
- TITLE=$(head -n 1 $ZNEWSDIR/$FILE)
+ TITLE=$(head -n 1 $AK_CATEGORIES/$FILE)
echo $i \| $DATE \| $TITLE
let i+=1
done
}
title(){
- echo ak-news-cli
- echo "--------------"
+ echo "$PROGRAM"
}
+
import(){
echo "#TODO"
if [ ! -z $1 ]
@@ -96,7 +87,7 @@ EOF
echo "File $FILE doesn't exist";
exit 2
fi
- ak-pack_z_block "news/add" data
+ ak-pack_z_block "news/add" $(pwd)/data
if [ $? == 0 ]
then
echo "News added successfully"