#!/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 would normally be blacklisted, but due to the short whitelist they are set aside as a less evil compromise to those blacklisted. They should still be avoided if possible.' ;; 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 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* | *sensitive info exposed to CloudFlare* | *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 or antitor 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)' else 'gitea' 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 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