commit 2f11327c092f6d29cf4651b0d75082fe9bb413ba from: Oliver Lowe date: Sat Jul 8 10:59:45 2023 UTC add lemmyverse(1) commit - 110506e3789b28df9fd2777e87b202018139fde5 commit + 2f11327c092f6d29cf4651b0d75082fe9bb413ba blob - fedaedf415cc682f4288218f6def7b238a6ee098 blob + 1945fa52b1a01a932e2733c56d12ca0e71801080 --- README +++ 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 blob - /dev/null blob + ee89a78a7adbd229a6fe2e3ab8e48128803542fc (mode 755) --- /dev/null +++ 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 blob - /dev/null blob + 488076dcd84b76f22d358dc9c29c0e03f48bcfc2 (mode 644) --- /dev/null +++ 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 blob - e2469fc987953add2b777570bfe4a4f1b5cdd765 blob + 5d6ed7e965556a9e717a7bc52edc127b5da26324 --- mkfile +++ mkfile @@ -1,3 +1,6 @@ README: readme.proto summary.sh cp readme.proto README ./summary.sh >> README + +clean: + rm -f README