Commit 1c54abcc2e
Unsigned
Layout: unified · split
lib/awesome-privacy-readme-gen.py +34 −3
| @@ -33,12 +33,35 @@ def repoElement(repoUrl): | ||
| 33 | 33 | if not repoUrl: |
| 34 | 34 | return "" |
| 35 | 35 | return ( |
| 36 | f"\t- [[1]}" |
| 38 | 38 | "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]" |
| 39 | f"(https://github.com/{repoUrl})\n" | |
| 39 | f"(https://github.com/{repoUrl})" | |
| 40 | 40 | ) |
| 41 | 41 | |
| 42 | def tosElement(tosdrId): | |
| 43 | if not tosdrId: | |
| 44 | return "" | |
| 45 | return f"[](https://tosdr.org/en/service/{tosdrId})" | |
| 46 | ||
| 47 | def 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 | ||
| 58 | def makeStatsCard(): | |
| 59 | return ( | |
| 60 | f"\t- <details><summary>Stats</summary>\n\n" | |
| 61 | f"" | |
| 62 | f"\n\n</details>" | |
| 63 | ) | |
| 64 | ||
| 42 | 65 | def makeHref(text): |
| 43 | 66 | if not text: return "#" |
| 44 | 67 | return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-") |
| @@ -79,7 +102,15 @@ def makeAwesomePrivacy(): | ||
| 79 | 102 | markdown += ( |
| 80 | 103 | f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]" |
| 81 | 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 | 115 | markdown += "\n" |
| 85 | 116 | # If word of warning exists, append it |