Commit 1c54abcc2e

1c54abcc2e024ab96f1202b9f84a9f792a7370c2

parent: 6f83b8f2ff

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-01 22:05 UTC

Updates readme generation script, to nest stat badges

Layout: unified · split

lib/awesome-privacy-readme-gen.py +34 −3
@@ -33,12 +33,35 @@ def repoElement(repoUrl):
3333 if not repoUrl:
3434 return ""
3535 return (
36 f"\t- [![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}"
36 f"[![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}"
3737 f"?style=flat&logo=github&label={repoUrl.split('/')[1]}"
3838 "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]"
39 f"(https://github.com/{repoUrl})\n"
39 f"(https://github.com/{repoUrl})"
4040 )
4141
42def tosElement(tosdrId):
43 if not tosdrId:
44 return ""
45 return f"[![Privacy Policy](https://shields.tosdr.org/en_{tosdrId}.svg)](https://tosdr.org/en/service/{tosdrId})"
46
47def awesomePrivacyReport(categoryName, sectionName, serviceName):
48 if not serviceName:
49 return ""
50 def slugify(name):
51 return (name or '').lower().replace(' ', '-')
52 return (
53 f"[![{serviceName} on Awesome Privacy]"
54 f"(https://img.shields.io/badge/{serviceName.replace(' ', '_')}-FC60A8?style=flat&logo=awesomelists&label=Awesome%20Privacy)]"
55 f"(https://awesome-privacy.xyz/{slugify(categoryName)}/{slugify(sectionName)}/{slugify(serviceName)})"
56 )
57
58def makeStatsCard():
59 return (
60 f"\t- <details><summary>Stats</summary>\n\n"
61 f""
62 f"\n\n</details>"
63 )
64
4265def makeHref(text):
4366 if not text: return "#"
4467 return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-")
@@ -79,7 +102,15 @@ def makeAwesomePrivacy():
79102 markdown += (
80103 f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]"
81104 f"({app.get('url')})** - {app.get('description')} "
82 f"{repoElement(app.get('github'))}"
105
106 + ((
107 f"\t- <details>\n\t\t<summary>Stats</summary>\n\n\t\t"
108 f"{repoElement(app.get('github'))} "
109 f"{tosElement(app.get('tosdrId'))} "
110 f"{awesomePrivacyReport(category.get('name'), section.get('name'), app.get('name'))} \n"
111 f"\n\t\t</details>\n"
112 )
113 if app.get('github') or app.get('tosdrId') else '')
83114 )
84115 markdown += "\n"
85116 # If word of warning exists, append it