From 3ab1195a2fd01816287879fa78297b2904462584 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Thu, 18 Jul 2024 04:45:12 +0300 Subject: ak-follow is now a module (ak -m follow) --- MODULES | 35 ++++++++++++++++++ README | 7 +--- bin/ak-follow | 96 -------------------------------------------------- modules/follow/lib.sh | 66 ++++++++++++++++++++++++++++++++++ modules/follow/main.sh | 33 +++++++++++++++++ 5 files changed, 135 insertions(+), 102 deletions(-) delete mode 100755 bin/ak-follow create mode 100755 modules/follow/lib.sh create mode 100755 modules/follow/main.sh diff --git a/MODULES b/MODULES index 3466d6e..c677261 100644 --- a/MODULES +++ b/MODULES @@ -300,6 +300,41 @@ As you have already witnessed, prototype is another way of telling "will do" or "here is an idea". +## follow + +Prototype - Follows something! + +"Something" is completely accurate at this point as it is following nothing in +particular. The purpose of introducing it was to be able to add a "follow/add" +block to your chain, so in some sense to inform others that others exist too +and you "follow" them as in the "social media" terminology. + +The place from which you are doing it though is vague. The first thought was to +have the `ak-config` IPNS key in the list. An update on that key would fetch you +the new latest of the zchain that this key point to, hence, being able to crawl +the latest version of it. That was mostly cause the 'ak-config' output would be +something like this: + +```json +{ + "profile": { + "nickname": "someone", + }, + "genesis": "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH", + "gpg": "42A...", + "zchain": "k51q...", + "zlatest": "Qm..." +} +``` + +Other than publishing that you follow or unfollow someone's ak-config IPNS key, +the module doesn't do anything else. + +Privacy-wise, someone would not like to let others know what their follow list +is. + + + ## Notes - [1] "data_signature" is labeled as "detach" inside the block. - [2] README file mentions that the whole project is in experimental state, btw diff --git a/README b/README index ffaaf37..d3c8955 100644 --- a/README +++ b/README @@ -291,15 +291,10 @@ Modules - transactions # Prototype of transactions in the ZCHAIN - smfiles # Adds a split file's map to the ZCHAIN - todos PROTO Adds todo list to the ZCHAIN + - follow PROTO Follow IPNS keys of ZCHAIN for changes Read more at the `./MODULES` file -Public following (uses ak-profile module) ------------------------------------------ - - ak-follow # Follow something - - ak-following # List your follows - - ak-unfollow # Unfollow something - FS tools -------- - ak-fs diff --git a/bin/ak-follow b/bin/ak-follow deleted file mode 100755 index d8461b8..0000000 --- a/bin/ak-follow +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -## -## You can maintain a list of friendly zchains or ids -## -## Usage: -## -## -h, --help Prints this help message -## -## -f, --follow Adds a ... to your follow list -## -## -l, --list Shows a list of your followings -## -## -u, --unfollow Unfollows a ... -## -fullprogrampath="$(realpath $0)" -PROGRAM=$(basename $0) -descriptionString="Following stuff" - -source $AK_LIBDIR/_ak_log -source $AK_LIBDIR/_ak_script -source $AK_LIBDIR/_ak_ipfs - -FOLLOWING="$HOME/.arching-kaos/following" - -_ak_follow_follow(){ - if [ ! -z $1 ] - then - grep $1 $FOLLOWING - if [ $? == 0 ] - then - _ak_log_error "Already exists" - exit 1 - fi - echo $1 >> $FOLLOWING - IPFS=$(_ak_ipfs_add $FOLLOWING) - if [ $? -ne 0 ] - then - _ak_log_error "Addition failed" - exit 1 - fi - ak-profile set following $IPFS - exit 0 - fi - printf "Usage:\n\t%s \n" $PROGRAM - exit 1 -} - -_ak_follow_list(){ - if [ -f $FOLLOWING ] - then - cat $FOLLOWING - else - _ak_log_info "No following file, creating" - touch $FOLLOWING - echo "None found" - fi -} - -_ak_follow_unfollow(){ - FOLLOWING="$HOME/.arching-kaos/following" - fentries="$(cat $FOLLOWING)" - if [ ! -z $1 ] - then - search="$1" - sed -i -e 's,'"$search"',,g' $FOLLOWING - if [ $? -ne 0 ] - then - _ak_log_error "sed didn't found $search" - exit 1 - fi - IPFS="$(_ak_ipfs_add $FOLLOWING)" - if [ $? -ne 0 ] - then - _ak_log_error "IPFS problem" - exit 1 - fi - ak-profile set repositories "$IPFS" - exit 0 - else - echo "Who to unfollow?" - echo "Type following to see them" - exit 1 - fi -} - -if [ ! -z $1 ] -then - case $1 in - -h | --help) _ak_usage; exit;; - -f | --follow) _ak_follow_follow $2; exit;; - -l | --list) _ak_follow_list $2; exit;; - -u | --unfollow) _ak_follow_unfollow $2; exit;; - * ) _ak_usage;; - esac -else _ak_usage -fi diff --git a/modules/follow/lib.sh b/modules/follow/lib.sh new file mode 100755 index 0000000..17ac384 --- /dev/null +++ b/modules/follow/lib.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +source $AK_LIBDIR/_ak_ipfs + +FOLLOWING="$AK_WORKDIR/following" + +_ak_follow_follow(){ + if [ ! -z $1 ] + then + grep $1 $FOLLOWING + if [ $? == 0 ] + then + _ak_log_error "Already exists" + exit 1 + fi + echo $1 >> $FOLLOWING + IPFS=$(_ak_ipfs_add $FOLLOWING) + if [ $? -ne 0 ] + then + _ak_log_error "Addition failed" + exit 1 + fi + ak-profile set following $IPFS + exit 0 + fi + printf "Usage:\n\t%s \n" $PROGRAM + exit 1 +} + +_ak_follow_list(){ + if [ -f $FOLLOWING ] + then + cat $FOLLOWING + else + _ak_log_info "No following file, creating" + touch $FOLLOWING + echo "None found" + fi +} + +_ak_follow_unfollow(){ + FOLLOWING="$HOME/.arching-kaos/following" + fentries="$(cat $FOLLOWING)" + if [ ! -z $1 ] + then + search="$1" + sed -i -e 's,'"$search"',,g' $FOLLOWING + if [ $? -ne 0 ] + then + _ak_log_error "sed didn't found $search" + exit 1 + fi + IPFS="$(_ak_ipfs_add $FOLLOWING)" + if [ $? -ne 0 ] + then + _ak_log_error "IPFS problem" + exit 1 + fi + ak-profile set repositories "$IPFS" + exit 0 + else + echo "Who to unfollow?" + echo "Type following to see them" + exit 1 + fi +} diff --git a/modules/follow/main.sh b/modules/follow/main.sh new file mode 100755 index 0000000..75be507 --- /dev/null +++ b/modules/follow/main.sh @@ -0,0 +1,33 @@ +#!/bin/bash +## +## You can maintain a list of friendly zchains or ids +## +## Usage: +## +## -h, --help Prints this help message +## +## -f, --follow Adds a ... to your follow list +## +## -l, --list Shows a list of your followings +## +## -u, --unfollow Unfollows a ... +## +fullprogrampath="$(realpath $0)" +PROGRAM="$(realpath $0 | rev |cut -d '/' -f 2 | rev)" +descriptionString="Following stuff" + +source $AK_LIBDIR/_ak_log +source $AK_LIBDIR/_ak_script +source $AK_MODULESDIR/$PROGRAM/lib.sh + +if [ ! -z $1 ] +then + case $1 in + -h | --help) _ak_usage; exit;; + -f | --follow) _ak_follow_follow $2; exit;; + -l | --list) _ak_follow_list $2; exit;; + -u | --unfollow) _ak_follow_unfollow $2; exit;; + * ) _ak_usage;; + esac +else _ak_usage +fi -- cgit v1.2.3