Commit ccdadeac98
Unsigned
Layout: unified · split
lib/awesome-privacy-readme-gen.py +16 −6
| @@ -35,7 +35,7 @@ def repoElement(repoUrl): | |||
| 35 | return ( | 35 | return ( |
| 36 | f"[[1]}" | 37 | f"?style=flat&logo=github&label={repoUrl.split('/')[1]}" |
| 38 | "&labelColor=%230d1117&color=%23302982&cacheSeconds=3600)]" | 38 | "&color=%235f53f4&cacheSeconds=3600)]" |
| 39 | f"(https://github.com/{repoUrl})" | 39 | f"(https://github.com/{repoUrl})" |
| 40 | ) | 40 | ) |
| 41 | 41 | ||
| @@ -44,6 +44,16 @@ def tosElement(tosdrId): | |||
| 44 | return "" | 44 | return "" |
| 45 | return f"[](https://tosdr.org/en/service/{tosdrId})" | 45 | return f"[](https://tosdr.org/en/service/{tosdrId})" |
| 46 | 46 | ||
| 47 | def 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 | |||
| 47 | def awesomePrivacyReport(categoryName, sectionName, serviceName): | 57 | def awesomePrivacyReport(categoryName, sectionName, serviceName): |
| 48 | if not serviceName: | 58 | if not serviceName: |
| 49 | return "" | 59 | return "" |
| @@ -51,7 +61,7 @@ def awesomePrivacyReport(categoryName, sectionName, serviceName): | |||
| 51 | return (name or '').lower().replace(' ', '-') | 61 | return (name or '').lower().replace(' ', '-') |
| 52 | return ( | 62 | return ( |
| 53 | f"[![{serviceName} on Awesome Privacy]" | 63 | 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(' ', '_')})]" |
| 55 | f"(https://awesome-privacy.xyz/{slugify(categoryName)}/{slugify(sectionName)}/{slugify(serviceName)})" | 65 | f"(https://awesome-privacy.xyz/{slugify(categoryName)}/{slugify(sectionName)}/{slugify(serviceName)})" |
| 56 | ) | 66 | ) |
| 57 | 67 | ||
| @@ -67,8 +77,8 @@ def makeHref(text): | |||
| 67 | return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-") | 77 | return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-") |
| 68 | 78 | ||
| 69 | def makeContents(): | 79 | def makeContents(): |
| 70 | contents = "<details>\n" | 80 | contents = "<blockquote><details>\n" |
| 71 | contents += "<summary><h2>Contents</h2></summary>\n" | 81 | contents += "<summary>📋 <b>Contents</b></summary>\n" |
| 72 | 82 | ||
| 73 | for category in data.get('categories'): | 83 | for category in data.get('categories'): |
| 74 | contents += f"\n- **{category.get('name')}**" | 84 | contents += f"\n- **{category.get('name')}**" |
| @@ -77,7 +87,7 @@ def makeContents(): | |||
| 77 | f"\n\t- [{section.get('name')}](#{makeHref(section.get('name'))}) " | 87 | f"\n\t- [{section.get('name')}](#{makeHref(section.get('name'))}) " |
| 78 | f"({len(section.get('services') or [])})" | 88 | f"({len(section.get('services') or [])})" |
| 79 | ) | 89 | ) |
| 80 | contents += "\n</details>\n\n" | 90 | contents += "\n</details></blockquote>\n\n" |
| 81 | return contents | 91 | return contents |
| 82 | 92 | ||
| 83 | def makeAwesomePrivacy(): | 93 | def makeAwesomePrivacy(): |
| @@ -102,12 +112,12 @@ def makeAwesomePrivacy(): | |||
| 102 | markdown += ( | 112 | markdown += ( |
| 103 | f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]" | 113 | f"- **[{iconElement(app.get('url'), app.get('icon'))} {app.get('name')}]" |
| 104 | f"({app.get('url')})** - {app.get('description')} " | 114 | f"({app.get('url')})** - {app.get('description')} " |
| 105 | |||
| 106 | + (( | 115 | + (( |
| 107 | f"\t- <details>\n\t\t<summary>Stats</summary>\n\n\t\t" | 116 | f"\t- <details>\n\t\t<summary>Stats</summary>\n\n\t\t" |
| 108 | f"{repoElement(app.get('github'))} " | 117 | f"{repoElement(app.get('github'))} " |
| 109 | f"{tosElement(app.get('tosdrId'))} " | 118 | f"{tosElement(app.get('tosdrId'))} " |
| 110 | f"{awesomePrivacyReport(category.get('name'), section.get('name'), app.get('name'))} \n" | 119 | 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" | ||
| 111 | f"\n\t\t</details>\n" | 121 | f"\n\t\t</details>\n" |
| 112 | ) | 122 | ) |
| 113 | if app.get('github') or app.get('tosdrId') else '') | 123 | if app.get('github') or app.get('tosdrId') else '') |