humanacollabora/tools/gen_forge_table.sh

170 lines
6.7 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'
[red_crossmark]=$'\xe2\x9d\x8c'
[green_checkmark]=$'\xe2\x9c\x85'
[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')
# temporary hack. git.sdf.org upgraded to 1.14.1 and it broke the icons.
sym+=([red_circle]=n
[green_circle]=y
[cloud_lightening]=y
[eye]=y
[onion]=onion
[skull]=${sym[red_crossmark]}
[noentry]=${sym[red_crossmark]})
#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()
{
# table_text not used yet, so we don't have it in working order #
# .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_crossmark]}' else '${sym[green_checkmark]}' end,
case software when 'gitlab_ce' then 'Gitlab (CE)' when 'gitlab_ee' then 'Gitlab (EE)' when 'other' then 'other/unknown' else replace(replace(software,'1.05','1.5'),'1.09','1.9') 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;"
# for the future => order by naturalsort(software),url_clrnet...
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
printf '\n%s\n' '⚠ Gitea versions note: Gitea 1.14.0 [breaks][gitea-bug] emoji in some browsers. So the best version ATM is 1.13.7 which opendev.org runs.
[gitea-bug]: https://codeberg.org/Codeberg/Community/issues/444'
;;
esac