aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-categories
diff options
context:
space:
mode:
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"