diff options
author | 2022-12-09 22:27:08 -0800 | |
---|---|---|
committer | 2022-12-09 22:27:08 -0800 | |
commit | aeeec9d11307b75ed117dabf7c04698bd9186d77 (patch) | |
tree | a23267fa619b5f98187ec5e027d3701c6e34f231 /pydis_site/apps/content/urls.py | |
parent | Appeased the requests from reviews. (diff) | |
parent | Merge pull request #811 from python-discord/dependabot/pip/flake8-bugbear-22.... (diff) |
Merge branch 'main' into 695-setting-different-statuses-on-your-bot
Diffstat (limited to 'pydis_site/apps/content/urls.py')
-rw-r--r-- | pydis_site/apps/content/urls.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/pydis_site/apps/content/urls.py b/pydis_site/apps/content/urls.py index f8496095..a7695a27 100644 --- a/pydis_site/apps/content/urls.py +++ b/pydis_site/apps/content/urls.py @@ -3,7 +3,7 @@ from pathlib import Path from django_distill import distill_path -from . import views +from . import utils, views app_name = "content" @@ -29,15 +29,38 @@ def __get_all_files(root: Path, folder: typing.Optional[Path] = None) -> list[st return results -def get_all_pages() -> typing.Iterator[dict[str, str]]: +DISTILL_RETURN = typing.Iterator[dict[str, str]] + + +def get_all_pages() -> DISTILL_RETURN: """Yield a dict of all page categories.""" for location in __get_all_files(Path("pydis_site", "apps", "content", "resources")): yield {"location": location} +def get_all_tags() -> DISTILL_RETURN: + """Return all tag names and groups in static builds.""" + # We instantiate the set with None here to make filtering it out later easier + # whether it was added in the loop or not + groups = {None} + for tag in utils.get_tags_static(): + groups.add(tag.group) + yield {"location": (f"{tag.group}/" if tag.group else "") + tag.name} + + groups.remove(None) + for group in groups: + yield {"location": group} + + urlpatterns = [ distill_path("", views.PageOrCategoryView.as_view(), name='pages'), distill_path( + "tags/<path:location>/", + views.TagView.as_view(), + name="tag", + distill_func=get_all_tags + ), + distill_path( "<path:location>/", views.PageOrCategoryView.as_view(), name='page_category', |