From e4f18be94261b39544ef3bc50321f6aedeb45bd6 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 31 Mar 2024 12:00:59 +0300 Subject: huge refactor, might breaking things --- bin/ak-news | 78 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 27 deletions(-) (limited to 'bin/ak-news') diff --git a/bin/ak-news b/bin/ak-news index 3f8b94a..875b888 100755 --- a/bin/ak-news +++ b/bin/ak-news @@ -1,14 +1,37 @@ #!/bin/bash +## +## -h, --help Prints this help message +## +## -l, --local-index Prints an indexed table of your news files +## +## -i, --import TODO +## +## -a, --add Creates a data file from the news file you +## point to +## +## -r, --read Reads a zblock as a news data +## +## -c, --create Vim is going to pop up, you will write and +## save your newsletter and it's going to bei +## saved +## +## -s, --specs Print specs of data block +## +## -x, --html Returns an appropriate html element from a +## NEWS zblock +## +fullprogrampath="$(realpath $0)" PROGRAM=$(basename $0) descriptionString="Module to read, create and add zblocks" ZNEWSDIR="$AK_WORKDIR/news" TEMP="/tmp/aktmp" -source $AK_LIBDIR/_ak_logit -source $AK_LIBDIR/_ak_script_description +source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_script source $AK_LIBDIR/_ak_ipfs source $AK_LIBDIR/_ak_gpg +source $AK_LIBDIR/_ak_zblock if [ ! -d $ZNEWSDIR ]; then mkdir $ZNEWSDIR @@ -63,10 +86,6 @@ _ak_modules_news_index(){ rm temp } -_ak_modules_news_title(){ - description -} - _ak_modules_news_import(){ echo "#TODO" if [ ! -z $1 ] @@ -120,7 +139,7 @@ EOF logit "ERROR" "File $FILE doesn't exist"; exit 2 fi - ak-zblock-pack "news/add" $(pwd)/data + _ak_zblock_pack "news/add" $(pwd)/data if [ $? == 0 ] then logit "INFO" "News added successfully" @@ -156,7 +175,7 @@ EOF logit "ERROR" "File $1 doesn't exist"; exit 2 fi - ak-zblock-pack "news/add" $(pwd)/data + _ak_zblock_pack "news/add" $(pwd)/data if [ $? == 0 ] then logit "INFO" "News added successfully" @@ -166,20 +185,6 @@ EOF fi } -_ak_modules_news_usage(){ - _ak_modules_news_title - echo " -h, --help Prints this help message" - echo " -l, --local-index Prints an indexed table of your news files" - echo " -i, --import #TODO" - echo " -a, --add Creates a data file from the news file you point to" - echo " -r, --read Reads a zblock as a news data" - echo " -c, --create Vim is going to pop up, you will write and save your" - echo " newsletter and it's going to be saved" - echo " -s, --specs Print specs of data block" - echo " -x, --html Returns an appropriate html element from a NEWS zblock" - exit 0 -} - _ak_modules_news_read(){ ak-enter -l 1 $1 > temp if [ $? -ne 0 ] @@ -232,7 +237,7 @@ _ak_modules_news_html(){ echo " " echo " " echo " " - echo "
 ✍️  Title
" + echo "
✍️ Title
" echo " " echo " " echo "
$ztitle
" @@ -251,7 +256,26 @@ _ak_modules_news_html(){ echo "
📄 Content
" echo " " echo " " - echo "
$(_ak_ipfs_cat $linkToText)
" + echo " " + _ak_ipfs_cat $linkToText | txt2tags -t html -H --infile=- --outfile=- echo " " echo " " echo '' @@ -278,7 +302,7 @@ _ak_modules_news_specs(){ if [ ! -z $1 ]; then case $1 in - -h | --help) _ak_modules_news_usage; exit;; + -h | --help) _ak_usage; exit;; -l | --local-index) _ak_modules_news_index; exit;; -i | --import) _ak_modules_news_import $2; exit;; -a | --add) _ak_modules_news_add_from_file $2; exit;; @@ -286,7 +310,7 @@ if [ ! -z $1 ]; then -r | --read) _ak_modules_news_read $2; exit;; -s | --specs) _ak_modules_news_specs $2; exit;; -x | --html) _ak_modules_news_html $2; exit;; - * ) _ak_modules_news_usage;; + * ) _ak_usage;; esac -else _ak_modules_news_usage +else _ak_usage fi -- cgit v1.2.3