From 606c9839614339643d2299f7647bba36f721d08c Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Feb 2026 19:01:20 +0100 Subject: [PATCH 01/10] enh(catalog): update forum's list of app tags --- list_builder.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/list_builder.py b/list_builder.py index 27751154..5b43918e 100755 --- a/list_builder.py +++ b/list_builder.py @@ -30,6 +30,8 @@ now = time.time() +FORUM_TOKEN = (TOOLS_DIR / ".forum_token").open("r", encoding="utf-8").read().strip() +FORUM_URL = "https://forum.yunohost.org" @cache def categories_list(): @@ -235,6 +237,48 @@ def build_app_dict(app, infos, cache_path: Path): ), } +@cache +def get_forum_all_tags(): + url = f"{FORUM_URL}/tags.json" + try: + with requests.Session() as s: + s.headers.update("Api-Key": FORUM_TOKEN, "Api-Username": "system") + return s.get(url).json() + except Exception as e: + logging.error(f"[List builder] Failed to GET the forum's full tags list: {e}") + return {} + +@cache +def get_forum_app_tags(): + url = f"{FORUM_URL}/tag_groups/8.json" + try: + with requests.Session() as s: + s.headers.update("Api-Key": FORUM_TOKEN, "Api-Username": "system") + return s.get(url).json() + except Exception as e: + logging.error(f"[List builder] Failed to GET the forum's apps tags: {e}") + return {} + +def put_forum_app_tags(forum_app_tags): + url = f"{FORUM_URL}/tag_groups/8.json" + try: + with requests.Session() as s: + s.headers.update("Api-Key": FORUM_TOKEN, "Api-Username": "system") + return s.put(url, json=forum_app_tags) + except Exception as e: + logging.error(f"[List builder] Failed to PUT the forum's apps tags: {e}") + return {} + +def create_new_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog): + apps_in_tags = [ tag["name" for tag in forum_app_tags["tag_group"]["tags"] ] + apps_in_catalog = base_catalog.keys() + missing_app_tags = list(set(apps_in_catalog)-set(apps_in_tags)) + logging.info(f"[List builder] Here is the list of new forum app tags: {missing_app_tags}") + new_id = max(tag["id"] for tag in forum_all_tags["tags"]) + for tag in missing_app_tags: + new_id = new_id + 1 + forum_app_tags["tag_group"]["tags"].append({'id': new_id, 'name': tag, 'slug': tag}) + return forum_app_tags def main() -> None: parser = argparse.ArgumentParser() @@ -269,6 +313,16 @@ def main() -> None: print(f"Writing the catalogs to {target_dir}...") write_catalog_v3(base_catalog, apps_dir, target_dir / "v3") + + print("PUT the forum's apps tags list") + forum_all_tags = get_forum_all_tags() + forum_app_tags = get_forum_app_tags() + if len(forum_all_tags) = 0 or len(forum_app_tags) != 0 + logging.error(f"[List builder] The forum returned empty tags list(s), I will not proceed with tags update.") + else: + new_forum_app_tags = create_new_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) + put_forum_app_tags(new_forum_app_tags) + print("Done!") From 4cc065c42089d91cbf34b350047b0d989ae52338 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Feb 2026 19:13:58 +0100 Subject: [PATCH 02/10] add(gitignore): .forum_token --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca4e2c2a..1e42254d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,9 @@ venv/ __pycache__/ .mypy_cache/ -# Github authentication files +# Authentication files .github_* +.forum_token # yunohost specific cache/output dirs .apps_cache From 2b32605bae6c000cb05fe2ed69da5c83794e846b Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Feb 2026 19:16:23 +0100 Subject: [PATCH 03/10] fix(catalog): fix authentication for tags API --- list_builder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/list_builder.py b/list_builder.py index 5b43918e..f04bde59 100755 --- a/list_builder.py +++ b/list_builder.py @@ -242,7 +242,7 @@ def get_forum_all_tags(): url = f"{FORUM_URL}/tags.json" try: with requests.Session() as s: - s.headers.update("Api-Key": FORUM_TOKEN, "Api-Username": "system") + s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) return s.get(url).json() except Exception as e: logging.error(f"[List builder] Failed to GET the forum's full tags list: {e}") @@ -253,7 +253,7 @@ def get_forum_app_tags(): url = f"{FORUM_URL}/tag_groups/8.json" try: with requests.Session() as s: - s.headers.update("Api-Key": FORUM_TOKEN, "Api-Username": "system") + s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) return s.get(url).json() except Exception as e: logging.error(f"[List builder] Failed to GET the forum's apps tags: {e}") @@ -263,7 +263,7 @@ def put_forum_app_tags(forum_app_tags): url = f"{FORUM_URL}/tag_groups/8.json" try: with requests.Session() as s: - s.headers.update("Api-Key": FORUM_TOKEN, "Api-Username": "system") + s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) return s.put(url, json=forum_app_tags) except Exception as e: logging.error(f"[List builder] Failed to PUT the forum's apps tags: {e}") From f48bb8141fe1754632d674d935e2ee123221b959 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Feb 2026 19:18:11 +0100 Subject: [PATCH 04/10] fix(typo) --- list_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_builder.py b/list_builder.py index f04bde59..ee55007a 100755 --- a/list_builder.py +++ b/list_builder.py @@ -270,7 +270,7 @@ def put_forum_app_tags(forum_app_tags): return {} def create_new_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog): - apps_in_tags = [ tag["name" for tag in forum_app_tags["tag_group"]["tags"] ] + apps_in_tags = [ tag["name"] for tag in forum_app_tags["tag_group"]["tags"] ] apps_in_catalog = base_catalog.keys() missing_app_tags = list(set(apps_in_catalog)-set(apps_in_tags)) logging.info(f"[List builder] Here is the list of new forum app tags: {missing_app_tags}") From e254cf6d72fbcc0e9ae586e47d71ec0bdc5b993f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Feb 2026 19:19:16 +0100 Subject: [PATCH 05/10] fix(typo) --- list_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_builder.py b/list_builder.py index ee55007a..67999d03 100755 --- a/list_builder.py +++ b/list_builder.py @@ -317,7 +317,7 @@ def main() -> None: print("PUT the forum's apps tags list") forum_all_tags = get_forum_all_tags() forum_app_tags = get_forum_app_tags() - if len(forum_all_tags) = 0 or len(forum_app_tags) != 0 + if len(forum_all_tags) == 0 or len(forum_app_tags) == 0: logging.error(f"[List builder] The forum returned empty tags list(s), I will not proceed with tags update.") else: new_forum_app_tags = create_new_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) From db928a466e72b56377f9b28e438b214b1b644e5f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 21 Feb 2026 19:20:50 +0100 Subject: [PATCH 06/10] fix(typo) --- list_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_builder.py b/list_builder.py index 67999d03..69e6b7bb 100755 --- a/list_builder.py +++ b/list_builder.py @@ -30,7 +30,7 @@ now = time.time() -FORUM_TOKEN = (TOOLS_DIR / ".forum_token").open("r", encoding="utf-8").read().strip() +FORUM_TOKEN = Path(".forum_token").open("r", encoding="utf-8").read().strip() FORUM_URL = "https://forum.yunohost.org" @cache From 6fcafcfa9e44dd6a1f65c1dc2af0b9f31ae0959a Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 22 Feb 2026 10:11:46 +0100 Subject: [PATCH 07/10] fix(tags): properly use the API --- list_builder.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/list_builder.py b/list_builder.py index 69e6b7bb..7fe174db 100755 --- a/list_builder.py +++ b/list_builder.py @@ -259,26 +259,22 @@ def get_forum_app_tags(): logging.error(f"[List builder] Failed to GET the forum's apps tags: {e}") return {} -def put_forum_app_tags(forum_app_tags): +def put_forum_app_tags(missing_forum_app_tags): url = f"{FORUM_URL}/tag_groups/8.json" try: with requests.Session() as s: s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) - return s.put(url, json=forum_app_tags) + return s.put(url, json={"tag_names": missing_forum_app_tags}) except Exception as e: logging.error(f"[List builder] Failed to PUT the forum's apps tags: {e}") return {} -def create_new_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog): +def get_missing_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog): apps_in_tags = [ tag["name"] for tag in forum_app_tags["tag_group"]["tags"] ] apps_in_catalog = base_catalog.keys() missing_app_tags = list(set(apps_in_catalog)-set(apps_in_tags)) logging.info(f"[List builder] Here is the list of new forum app tags: {missing_app_tags}") - new_id = max(tag["id"] for tag in forum_all_tags["tags"]) - for tag in missing_app_tags: - new_id = new_id + 1 - forum_app_tags["tag_group"]["tags"].append({'id': new_id, 'name': tag, 'slug': tag}) - return forum_app_tags + return missing_app_tags def main() -> None: parser = argparse.ArgumentParser() @@ -320,8 +316,8 @@ def main() -> None: if len(forum_all_tags) == 0 or len(forum_app_tags) == 0: logging.error(f"[List builder] The forum returned empty tags list(s), I will not proceed with tags update.") else: - new_forum_app_tags = create_new_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) - put_forum_app_tags(new_forum_app_tags) + missing_forum_app_tags = create_missing_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) + put_forum_app_tags(missing_forum_app_tags) print("Done!") From 7f4f29e5fe76a120ebfa9d076f944d8a30add3c9 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 22 Feb 2026 10:12:42 +0100 Subject: [PATCH 08/10] fix(typo) --- list_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_builder.py b/list_builder.py index 7fe174db..5bcf56a9 100755 --- a/list_builder.py +++ b/list_builder.py @@ -316,7 +316,7 @@ def main() -> None: if len(forum_all_tags) == 0 or len(forum_app_tags) == 0: logging.error(f"[List builder] The forum returned empty tags list(s), I will not proceed with tags update.") else: - missing_forum_app_tags = create_missing_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) + missing_forum_app_tags = get_missing_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) put_forum_app_tags(missing_forum_app_tags) print("Done!") From 1e3386d14a8aea66dd9f03082f99a505272cd14e Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 22 Feb 2026 11:17:04 +0100 Subject: [PATCH 09/10] fix(tags): huge simplification of the whole thing --- list_builder.py | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/list_builder.py b/list_builder.py index 5bcf56a9..a4193caf 100755 --- a/list_builder.py +++ b/list_builder.py @@ -237,45 +237,18 @@ def build_app_dict(app, infos, cache_path: Path): ), } -@cache -def get_forum_all_tags(): - url = f"{FORUM_URL}/tags.json" - try: - with requests.Session() as s: - s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) - return s.get(url).json() - except Exception as e: - logging.error(f"[List builder] Failed to GET the forum's full tags list: {e}") - return {} - -@cache -def get_forum_app_tags(): +def put_forum_app_tags(forum_app_tags): + # 8 is the ID of the Applications tags list + # We send the whole list, Discourse can manage pre-existing tags url = f"{FORUM_URL}/tag_groups/8.json" try: with requests.Session() as s: s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) - return s.get(url).json() - except Exception as e: - logging.error(f"[List builder] Failed to GET the forum's apps tags: {e}") - return {} - -def put_forum_app_tags(missing_forum_app_tags): - url = f"{FORUM_URL}/tag_groups/8.json" - try: - with requests.Session() as s: - s.headers.update({"Api-Key": FORUM_TOKEN, "Api-Username": "system"}) - return s.put(url, json={"tag_names": missing_forum_app_tags}) + return s.put(url, json={"tag_names": forum_app_tags}) except Exception as e: logging.error(f"[List builder] Failed to PUT the forum's apps tags: {e}") return {} -def get_missing_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog): - apps_in_tags = [ tag["name"] for tag in forum_app_tags["tag_group"]["tags"] ] - apps_in_catalog = base_catalog.keys() - missing_app_tags = list(set(apps_in_catalog)-set(apps_in_tags)) - logging.info(f"[List builder] Here is the list of new forum app tags: {missing_app_tags}") - return missing_app_tags - def main() -> None: parser = argparse.ArgumentParser() get_apps_repo.add_args(parser) @@ -310,14 +283,8 @@ def main() -> None: print(f"Writing the catalogs to {target_dir}...") write_catalog_v3(base_catalog, apps_dir, target_dir / "v3") - print("PUT the forum's apps tags list") - forum_all_tags = get_forum_all_tags() - forum_app_tags = get_forum_app_tags() - if len(forum_all_tags) == 0 or len(forum_app_tags) == 0: - logging.error(f"[List builder] The forum returned empty tags list(s), I will not proceed with tags update.") - else: - missing_forum_app_tags = get_missing_forum_app_tags(forum_all_tags, forum_app_tags, base_catalog) - put_forum_app_tags(missing_forum_app_tags) + print("PUTting the forum's apps tags list") + put_forum_app_tags(list(base_catalog.keys())) print("Done!") From 04f319b010984fb8105b2b3bb4d6d1f5fdb90491 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 22 Feb 2026 11:31:33 +0100 Subject: [PATCH 10/10] fix(tags): path to .forum_token --- list_builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/list_builder.py b/list_builder.py index a4193caf..58d24474 100755 --- a/list_builder.py +++ b/list_builder.py @@ -30,7 +30,8 @@ now = time.time() -FORUM_TOKEN = Path(".forum_token").open("r", encoding="utf-8").read().strip() +TOOLS_DIR = Path(__file__).resolve().parent +FORUM_TOKEN = (TOOLS_DIR / ".forum_token").open("r", encoding="utf-8").read().strip() FORUM_URL = "https://forum.yunohost.org" @cache