Commit ccdadeac98

ccdadeac98ebec347f20d62f2d5b6a207f502547

parent: e1cdcb9518

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-09 15:26 UTC

Updates Python script to colourize badges

Layout: unified · split

lib/awesome-privacy-readme-gen.py +16 −6
@@ -35,7 +35,7 @@ def repoElement(repoUrl):
3535 return (
3636 f"[![GitHub: {repoUrl}](https://img.shields.io/github/stars/{repoUrl}"
3737 f"?style=flat&logo=github&label={repoUrl.split('/')[1]}"
38 "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]"
38 "&color=%235f53f4&cacheSeconds=3600)]"
3939 f"(https://github.com/{repoUrl})"
4040 )
4141
@@ -44,6 +44,16 @@ def tosElement(tosdrId):
4444 return ""
4545 return f"[![Privacy Policy](https://shields.tosdr.org/en_{tosdrId}.svg)](https://tosdr.org/en/service/{tosdrId})"
4646
47def statsElement(isOpenSource, isSecurityAudited, isAcceptsCrypto):
48 statsStr = ""
49 if isOpenSource == True:
50 statsStr += "📦 Open Source "
51 if isSecurityAudited == True:
52 statsStr += "🛡️ Security Audited "
53 if isAcceptsCrypto == True:
54 statsStr += "💰 Accepts Anonymous Payment "
55 return statsStr
56
4757def awesomePrivacyReport(categoryName, sectionName, serviceName):
4858 if not serviceName:
4959 return ""
@@ -51,7 +61,7 @@ def awesomePrivacyReport(categoryName, sectionName, serviceName):
5161 return (name or '').lower().replace(' ', '-')
5262 return (
5363 f"[![{serviceName} on Awesome Privacy]"
54 f"(https://img.shields.io/badge/{serviceName.replace(' ', '_')}-FC60A8?style=flat&logo=awesomelists&label=Awesome%20Privacy)]"
64 f"(https://img.shields.io/badge/View%20Report-FC60A8?style=flat&logo=awesomelists&label={serviceName.replace(' ', '_')})]"
5565 f"(https://awesome-privacy.xyz/{slugify(categoryName)}/{slugify(sectionName)}/{slugify(serviceName)})"
5666 )
5767
@@ -67,8 +77,8 @@ def makeHref(text):
6777 return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-")
6878
6979def makeContents():
70 contents = "<details>\n"
71 contents += "<summary><h2>Contents</h2></summary>\n"
80 contents = "<blockquote><details>\n"
81 contents += "<summary>📋 <b>Contents</b></summary>\n"
7282
7383 for category in data.get('categories'):
7484 contents += f"\n- **{category.get('name')}**"
@@ -77,7 +87,7 @@ def makeContents():
7787 f"\n\t- [{section.get('name')}](#{makeHref(section.get('name'))}) "
7888 f"({len(section.get('services') or [])})"
7989 )
80 contents += "\n</details>\n\n"
90 contents += "\n</details></blockquote>\n\n"
8191 return contents
8292
8393def makeAwesomePrivacy():
@@ -102,12 +112,12 @@ def makeAwesomePrivacy():
102112 markdown += (
103113 f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]"
104114 f"({app.get('url')})** - {app.get('description')} "
105
106115 + ((
107116 f"\t- <details>\n\t\t<summary>Stats</summary>\n\n\t\t"
108117 f"{repoElement(app.get('github'))} "
109118 f"{tosElement(app.get('tosdrId'))} "
110119 f"{awesomePrivacyReport(category.get('name'), section.get('name'), app.get('name'))} \n"
120 f"{statsElement(app.get('openSource'), app.get('securityAudited'), app.get('acceptsCrypto'))} \n"
111121 f"\n\t\t</details>\n"
112122 )
113123 if app.get('github') or app.get('tosdrId') else '')