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):
33 if not repoUrl: 33 if not repoUrl:
34 return "" 34 return ""
35 return ( 35 return (
36 f"\t- [![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}" 36 f"[![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}"
37 f"?style=flat&logo=github&label={repoUrl.split('/')[1]}" 37 f"?style=flat&logo=github&label={repoUrl.split('/')[1]}"
38 "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]" 38 "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]"
39 f"(https://github.com/{repoUrl})\n" 39 f"(https://github.com/{repoUrl})"
40 ) 40 )
41 41
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
42def makeHref(text): 65def makeHref(text):
43 if not text: return "#" 66 if not text: return "#"
44 return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-") 67 return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-")
@@ -79,7 +102,15 @@ def makeAwesomePrivacy():
79 markdown += ( 102 markdown += (
80 f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]" 103 f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]"
81 f"({app.get('url')})** - {app.get('description')} " 104 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 '')
83 ) 114 )
84 markdown += "\n" 115 markdown += "\n"
85 # If word of warning exists, append it 116 # If word of warning exists, append it