humanacollabora/tools/gen_forge_table.sh

152 lines
5.9 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Syntax: gen_forge_table.sh [text]
#
# Add "text" option to write the tables in simple text.
# Without the text option, all output will be markdown.
typeset -r db_file=$(mktemp --dry-run --suffix=.db)
typeset -A sym=([red_circle]=$'\xF0\x9F\x94\xB4'
[green_circle]=$'\xf0\x9f\x9f\xa2'
[test_tube]=$'\xf0\x9f\xa7\xaa'
[cloud_lightening]=$'\xf0\x9f\x8c\xa9'
[detective]=$'\xf0\x9f\x95\xb5'
[okhand]=$'\xF0\x9F\x91\x8C'
[eye]=$'\xf0\x9f\x91\x81'
[onion]=$'\xF0\x9F\xA7\x85'
[skull]=$'\xF0\x9F\x92\x80'
[vomit]=$'\xF0\x9F\xA4\xAE'
[noentry]=$'\xE2\x9B\x94'
[warning]=$'\xE2\x9A\xA0'
[biohaz]=$'\xE2\x98\xA3'
[hammerpick]=$'\xE2\x9A\x92')
#local red_circle='🔴'
#local green_circle='🟢'
#local test_tube='🧪'
#local cloud_lightening='🌩'
#local detective='🕵'
#local okhand='👌'
#local eye='👁'
#local onion=''
#local skull='💀'
#local noentry='⛔'
intro()
{
local lst=$1
case "$lst" in
white)
printf %s\\n 'The following forges have no significant ethical issues:'
;;
gray)
printf %s\\n 'These forges are not as seriously flawed as the blacklisted ones, but they should still be avoided if possible. Non-Cloudflare sites that use a Cloudflare NS server pose a risk for disruptions because they can trivially and spontaneously flip a switch and route all your traffic through Cloudflare, potentially cutting access to some of your contributors. Dead sites are also graylisted because if they come back online, they are known to be unreliable. Codeberg is graylisted for falsely accusing a repository of illegal conduct and deleting the content of all forks from that project without evidence or redress.'
;;
black)
printf %s\\n 'These forges have severe ethical or trust issues and should be boycotted:'
;;
esac
};#intro
table_populate()
{
sqlite3 "${db_file}" < input_data/forges.sql
};#table_populate
table_text()
{
# .ft B (bold font)
# .ft I (italics font)
# .ft P (previous font)
# .ll 6i (6 inch width)
for lst in white gray black
do
if [[ "$lst" == black ]]
then
url_clause="''"
else
url_clause="case when url_clrnet like '_%' then char(10)||'('||replace(url_clrnet,'https://','')||')||||||' else '' end"
fi
printf %s "# ${lst^}"'list
```
.TS
box tab(|);
c|c|c|c|c|c.
.ft BI
forge | Tor- | sensitive info | forced | forced execution | notes
| hostile | exposed to | re/hCAPTCHA | of non-free |
| | CloudFlare | | software |
.ft P
.T&
l|l|l|l|l|lp40.
'
sqlite3 "${db_file}" "select case when url_clrnet is null then '' else replace(url_clrnet,'https://','[')||']('||url_clrnet||')' end||'(placeholder)',
case when antitor then 'y' else 'n' end,
case when cflogin then 'y' else 'n' end,
case when hrecaptcha then 'y' else 'n' end,
case when forced_nfsw then 'y' else 'n' end,
case when notes is null then '' else 'T{
.ll 6i
'|| replace(replace(notes,'[',''),']',' ') ||'
T}' end||
$url_clause
from forgesTbl where lst_kind = '$lst'
order by url_clrnet collate nocase;"
printf %s '.TE
```
'
done
}; #table_text
table_md()
{
printf %s\\n "# Directory of forges"
for lst in white gray black
do
if [[ "$lst" == black ]]
then
name_clause="case when url_clrnet is null then '' else replace(url_clrnet,'https://','') end"
else
name_clause="case when url_clrnet is null then '' else replace(url_clrnet,'https://','[')||']('||url_clrnet||')' end"
fi
printf %s "## ${lst^}list
$(intro $lst)"'
| *forge* | *registration publicly open* | *software* | *Tor-hostile* | *Cloudflare MitM* | *forced re/hCAPTCHA* | *forced execution of non-free software* | *notes* |
|---|---|---|---|---|---|---|---|
'
sqlite3 "${db_file}" "select $name_clause||case when url_onion is null then '' else '([${sym[onion]}]('||url_onion||'))' end,
case when dead then '${sym[skull]}' when (cflogin and hrecaptcha = 'unavoidable') or antitor or nation_discrimination then '${sym[noentry]} (exclusive walled garden)' when not openpubreg then '${sym[red_circle]}' else '${sym[green_circle]}' end,
case software when 'gitlab_ce' then 'Gitlab (CE)' when 'gitlab_ee' then 'Gitlab (EE)' when 'other' then 'other/unknown' else software end,
case when antitor then '${sym[eye]}' else 'n' end,
case when cflogin then '${sym[cloud_lightening]}' else 'n' end,
case when hrecaptcha = 'unavoidable' then '${sym[hammerpick]}' else 'n' end,
case when forced_nfsw then '${sym[biohaz]}' else 'n' end,
case when notes is null then '|' else notes||'|' end
from forgesTbl where lst_kind = '$lst'
order by software,url_clrnet collate nocase;"
printf $'\n'
done
};#table_md
table_populate
case "$1" in
txt|text)
table_text | tbl | nroff -Tascii | uniq
;;
*)
printf '%s\n\n' '[//]: # (** DO NOT EDIT this file directly! ** It is auto-generated. Changes should be made to financial_institutions.sql or '"${0##*/}"' instead.)'
table_md
;;
esac