mirror of
https://github.com/mustbeperfect/definitive-opensource.git
synced 2026-04-18 02:54:13 +02:00
Commented on contents_generator
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
# Utils
|
||||||
def slugify(name):
|
def slugify(name):
|
||||||
return name.lower().replace(" ", "-").replace("(", "").replace(")", "")
|
return name.lower().replace(" ", "-").replace("(", "").replace(")", "")
|
||||||
|
|
||||||
@@ -23,25 +24,7 @@ def format_stars(n):
|
|||||||
return str(n)
|
return str(n)
|
||||||
|
|
||||||
|
|
||||||
"""
|
# Generates actual list contents in markdown (categories and projects within)
|
||||||
def format_stars(n):
|
|
||||||
if n >= 1_000_000:
|
|
||||||
value = n / 1_000_000
|
|
||||||
suffix = "M"
|
|
||||||
elif n >= 1_000:
|
|
||||||
value = n / 1_000
|
|
||||||
suffix = "k"
|
|
||||||
else:
|
|
||||||
return str(n)
|
|
||||||
|
|
||||||
# If it's a whole number, don't show decimal point
|
|
||||||
if value == int(value):
|
|
||||||
return f"{int(value)}{suffix}"
|
|
||||||
else:
|
|
||||||
return f"{value:.1f}{suffix}"
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def generate_contents(platform="all"):
|
def generate_contents(platform="all"):
|
||||||
with open("core/data/static/categories.json", "r", encoding="utf-8") as f:
|
with open("core/data/static/categories.json", "r", encoding="utf-8") as f:
|
||||||
cat_data = json.load(f)
|
cat_data = json.load(f)
|
||||||
@@ -56,6 +39,7 @@ def generate_contents(platform="all"):
|
|||||||
subcategories = cat_data.get("subcategories", [])
|
subcategories = cat_data.get("subcategories", [])
|
||||||
applications = app_data.get("applications", [])
|
applications = app_data.get("applications", [])
|
||||||
|
|
||||||
|
# Map id's to corresponding names
|
||||||
parent_map = {cat["id"]: cat["name"] for cat in categories}
|
parent_map = {cat["id"]: cat["name"] for cat in categories}
|
||||||
attribute_map = {
|
attribute_map = {
|
||||||
attribute["id"]: attribute["emoji"] for attribute in tags_data["attributes"]
|
attribute["id"]: attribute["emoji"] for attribute in tags_data["attributes"]
|
||||||
@@ -75,6 +59,7 @@ def generate_contents(platform="all"):
|
|||||||
for key in subcat_by_parent:
|
for key in subcat_by_parent:
|
||||||
subcat_by_parent[key].sort(key=lambda x: x["Name"].lower())
|
subcat_by_parent[key].sort(key=lambda x: x["Name"].lower())
|
||||||
|
|
||||||
|
# Include projects relative to type of list being gneerated (all or platform specific)
|
||||||
apps_by_subcat = {}
|
apps_by_subcat = {}
|
||||||
for app in applications:
|
for app in applications:
|
||||||
include = False
|
include = False
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
# Architecture
|
# Architecture
|
||||||
Here's a look at how the "backend" of the list works.
|
Here's a look at how this list works.
|
||||||
|
|
||||||
|
# The List Itself
|
||||||
|
The core of this list is powered by Python using UV and Ruff for linting and formatting.
|
||||||
|
|
||||||
## README Generation
|
## README Generation
|
||||||
All applications are stored inside [`applications.json`](core/data/dynamic/applications.json). Categories are declared inside [`categories.json`](core/data/static/categories.json). Instead of a nested format with subcategories as on object of it's parent, we've given subcategories a `parent` attribute. There's also a [`tags.json`](core/data/static/tags.json). Instead of putting the emoji inside of the ```tags``` attribute in `applications.json`, the id is used, for example, `commercial` or `disruptive`.. These id's are mapped to their corresponding emoji for when the READMEs are generated and makes``applications.json``` more readable.
|
All applications are stored inside [`applications.json`](core/data/dynamic/applications.json). Categories are declared inside [`categories.json`](core/data/static/categories.json). Instead of a nested format with subcategories as on object of it's parent, we've given subcategories a `parent` attribute. There's also a [`tags.json`](core/data/static/tags.json). Instead of putting the emoji inside of the ```tags``` attribute in `applications.json`, the id is used, for example, `commercial` or `disruptive`.. These id's are mapped to their corresponding emoji for when the READMEs are generated and makes``applications.json``` more readable.
|
||||||
|
|||||||
Reference in New Issue
Block a user