x

Programs, configuration and documentation that don't fit anywhere else
Log | Files | Refs | README | LICENSE

commit 2f11327c092f6d29cf4651b0d75082fe9bb413ba
parent 110506e3789b28df9fd2777e87b202018139fde5
Author: Oliver Lowe <o@olowe.co>
Date:   Sat,  8 Jul 2023 20:58:26 +1000

add lemmyverse(1)

Diffstat:
MREADME | 1+
Abin/lemmyverse | 31+++++++++++++++++++++++++++++++
Aman/lemmyverse.1 | 34++++++++++++++++++++++++++++++++++
Mmkfile | 3+++
4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -8,4 +8,5 @@ hits - count web traffic hlsget - download the contents of a HLS playlist jsfmt - format javascript source code knocknocauth - create and close knocknoc sessions +lemmyverse - search lemmy communities webpaste - create a web paste on webpaste.olowe.co diff --git a/bin/lemmyverse b/bin/lemmyverse @@ -0,0 +1,31 @@ +#!/bin/sh + +usage='usage: lemmyverse pattern' +if test $# -ne 1 +then + echo $usage + exit 2 +fi + +cachedir=$HOME/.cache/lemmyverse +mkdir -p $cachedir +cd $cachedir +if ! test -f community.full.json +then + curl --compressed https://lemmyverse.net/data/community.full.json > community.full.json +fi + +if test -f communities +then + grep $@ $cachedir/communities + exit $? +fi + +< community.full.json tr ',' ' +' | tr -d '"{}' | grep '(^baseurl)|(^name)|(^desc)' | awk -F : ' +$1 == "baseurl" { instance=$2 } +$1 == "desc"{ desc = $2 } +$1 == "name" { name = $2 } +NR % 3 == 0 { printf "%s@%s\t%s\n", name, instance, desc }' | grep -v 'enoweiooe' | sort > communities + +grep $@ $cachedir/communities diff --git a/man/lemmyverse.1 b/man/lemmyverse.1 @@ -0,0 +1,34 @@ +.Dd +.Dt LEMMYVERSE 1 +.Sh Name +.Nm lemmyverse +.Nd search lemmy communities +.Sh SYNOPSIS +.Nm +.Ar pattern +.Sh DESCRIPTION +.Nm +searches Lemmy communities indexed by +.Pa lemmyverse.net +using the given regular expression. +Both the names and descriptions of the communities are searched. +.Pp +On first run, a search index file of communities must be generated. +The full community database is downloaded from +.Pa https://lemmyverse.net +and stored in the user cache directory. +.Nm +then generates the index. +To fetch a new database or generate a new index, +remove each file respectively. +.Sh EXAMPLE +Find communities for the Plan 9 operating system: +.Dl lemmyverse '(plan9)|(Plan 9)' +.Pp +List all communities from the instance lemmy.sdf.org: +.Dl lemmyverse '.*@lemmy.sdf.org' +.Sh EXIT STATUS +.Ex +.Sh SEE ALSO +.Xr curl 1 , +.Lk https://lemmyverse.net diff --git a/mkfile b/mkfile @@ -1,3 +1,6 @@ README: readme.proto summary.sh cp readme.proto README ./summary.sh >> README + +clean: + rm -f README