From 1c54abcc2e024ab96f1202b9f84a9f792a7370c2 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Fri, 1 Mar 2024 22:05:06 +0000 Subject: [PATCH] Updates readme generation script, to nest stat badges --- lib/awesome-privacy-readme-gen.py | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/awesome-privacy-readme-gen.py b/lib/awesome-privacy-readme-gen.py index 8fa8c3f..e31dc3f 100644 --- a/lib/awesome-privacy-readme-gen.py +++ b/lib/awesome-privacy-readme-gen.py @@ -33,12 +33,35 @@ def repoElement(repoUrl): if not repoUrl: return "" return ( - f"\t- [![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}" + f"[![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}" f"?style=flat&logo=github&label={repoUrl.split('/')[1]}" "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]" - f"(https://github.com/{repoUrl})\n" + f"(https://github.com/{repoUrl})" ) +def tosElement(tosdrId): + if not tosdrId: + return "" + return f"[![Privacy Policy](https://shields.tosdr.org/en_{tosdrId}.svg)](https://tosdr.org/en/service/{tosdrId})" + +def awesomePrivacyReport(categoryName, sectionName, serviceName): + if not serviceName: + return "" + def slugify(name): + return (name or '').lower().replace(' ', '-') + return ( + f"[![{serviceName} on Awesome Privacy]" + f"(https://img.shields.io/badge/{serviceName.replace(' ', '_')}-FC60A8?style=flat&logo=awesomelists&label=Awesome%20Privacy)]" + f"(https://awesome-privacy.xyz/{slugify(categoryName)}/{slugify(sectionName)}/{slugify(serviceName)})" + ) + +def makeStatsCard(): + return ( + f"\t-
Stats\n\n" + f"" + f"\n\n
" + ) + def makeHref(text): if not text: return "#" return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-") @@ -79,7 +102,15 @@ def makeAwesomePrivacy(): markdown += ( f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]" f"({app.get('url')})** - {app.get('description')} " - f"{repoElement(app.get('github'))}" + + + (( + f"\t-
\n\t\tStats\n\n\t\t" + f"{repoElement(app.get('github'))} " + f"{tosElement(app.get('tosdrId'))} " + f"{awesomePrivacyReport(category.get('name'), section.get('name'), app.get('name'))} \n" + f"\n\t\t
\n" + ) + if app.get('github') or app.get('tosdrId') else '') ) markdown += "\n" # If word of warning exists, append it