From 8c4aa671f74307289e0805ef3becda239c5db37d Mon Sep 17 00:00:00 2001 From: lemonsaurus Date: Sun, 6 Jun 2021 13:33:56 +0200 Subject: Update templates with new resource urls. --- pydis_site/templates/base/navbar.html | 2 +- pydis_site/templates/resources/resources.html | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/base/navbar.html b/pydis_site/templates/base/navbar.html index 4cc49dc6..9c492f35 100644 --- a/pydis_site/templates/base/navbar.html +++ b/pydis_site/templates/base/navbar.html @@ -67,7 +67,7 @@ Resources - + Tools diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index f1f487cf..04744f90 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -24,7 +24,7 @@
- +

Read

Lovingly curated books to explore

@@ -32,7 +32,7 @@
- +

Try

Interactively discover the possibilities

- +

Learn

Structured courses with clear goals

@@ -61,14 +61,14 @@
- +

Tools

Things we love to use

-- cgit v1.2.3 From c781ed1f80188ffb274eeada974172f4aa07c0b5 Mon Sep 17 00:00:00 2001 From: fisher60 Date: Fri, 23 Jul 2021 20:20:10 -0500 Subject: change resources to prepare for smart resource search --- pydis_site/apps/resources/urls.py | 2 +- pydis_site/apps/resources/views/__init__.py | 4 +- pydis_site/apps/resources/views/resources.py | 10 +- pydis_site/static/css/resources/resources.css | 51 +++++----- pydis_site/templates/resources/resources.html | 131 ++++++++++++++------------ 5 files changed, 105 insertions(+), 93 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/resources/urls.py b/pydis_site/apps/resources/urls.py index cd4f53e7..c8d441df 100644 --- a/pydis_site/apps/resources/urls.py +++ b/pydis_site/apps/resources/urls.py @@ -4,6 +4,6 @@ from pydis_site.apps.resources import views app_name = "resources" urlpatterns = [ - path("", views.ResourcesView.as_view(), name="index"), + path("", views.resources.resource_view, name="index"), path("list/", views.ResourcesListView.as_view(), name="resources") ] diff --git a/pydis_site/apps/resources/views/__init__.py b/pydis_site/apps/resources/views/__init__.py index 8eb383b5..c89071c5 100644 --- a/pydis_site/apps/resources/views/__init__.py +++ b/pydis_site/apps/resources/views/__init__.py @@ -1,4 +1,4 @@ -from .resources import ResourcesView +from .resources import resource_view from .resources_list import ResourcesListView -__all__ = ["ResourcesView", "ResourcesListView"] +__all__ = ["resource_view", "ResourcesListView"] diff --git a/pydis_site/apps/resources/views/resources.py b/pydis_site/apps/resources/views/resources.py index 25ce3e50..dfd21682 100644 --- a/pydis_site/apps/resources/views/resources.py +++ b/pydis_site/apps/resources/views/resources.py @@ -1,7 +1,11 @@ from django.views.generic import TemplateView +from django.shortcuts import render +# class ResourcesView(TemplateView): +# """View for resources index page.""" +# +# template_name = "resources/resources.html" -class ResourcesView(TemplateView): - """View for resources index page.""" - template_name = "resources/resources.html" +def resource_view(request): + return render(request, template_name="resources/resources.html") diff --git a/pydis_site/static/css/resources/resources.css b/pydis_site/static/css/resources/resources.css index cf4cb472..a9226647 100644 --- a/pydis_site/static/css/resources/resources.css +++ b/pydis_site/static/css/resources/resources.css @@ -1,29 +1,30 @@ -.box, .tile.is-parent { - transition: 0.1s ease-out; -} -.box { - min-height: 15vh; -} -.tile.is-parent:hover .box { - box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); -} -.tile.is-parent:hover { - padding: 0.65rem 0.85rem 0.85rem 0.65rem; - filter: saturate(1.1) brightness(1.1); -} +/*.box, .tile.is-parent {*/ +/* transition: 0.1s ease-out;*/ +/*}*/ +/*.box {*/ +/* min-height: 15vh;*/ +/*}*/ +/*.tile.is-parent:hover .box {*/ +/* box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);*/ +/*}*/ +/*.tile.is-parent:hover {*/ +/* padding: 0.65rem 0.85rem 0.85rem 0.65rem;*/ +/* filter: saturate(1.1) brightness(1.1);*/ +/*}*/ -#readingBlock { - background-image: linear-gradient(141deg, #911eb4 0%, #b631de 71%, #cf4bf7 100%); -} +/*#readingBlock {*/ +/* background-image: linear-gradient(141deg, #911eb4 0%, #b631de 71%, #cf4bf7 100%);*/ +/*}*/ -#interactiveBlock { - background-image: linear-gradient(141deg, #d05600 0%, #da722a 71%, #e68846 100%); -} +/*#interactiveBlock {*/ +/* background-image: linear-gradient(141deg, #d05600 0%, #da722a 71%, #e68846 100%);*/ +/*}*/ -#communitiesBlock { - background-image: linear-gradient(141deg, #3b756f 0%, #3a847c 71%, #41948b 100%); -} +/*#communitiesBlock {*/ +/* background-image: linear-gradient(141deg, #3b756f 0%, #3a847c 71%, #41948b 100%);*/ +/*}*/ + +/*#podcastsBlock {*/ +/* background-image: linear-gradient(141deg, #232382 0%, #30309c 71%, #4343ad 100%);*/ +/*}*/ -#podcastsBlock { - background-image: linear-gradient(141deg, #232382 0%, #30309c 71%, #4343ad 100%); -} diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index 04744f90..7eb21432 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -12,79 +12,86 @@
+ {% endblock %} -- cgit v1.2.3 From 156951f12c05146650a84d4ac9d45e7a8a085023 Mon Sep 17 00:00:00 2001 From: fisher60 Date: Sat, 24 Jul 2021 18:22:59 -0500 Subject: add constant for resource tags. Add Functional front end This change adds a fully functional front end menu for testing. This is a very rough outline and will need a bit of UI and UX love to get working fully. Should act as an example of functionality --- pydis_site/apps/resources/views/resources.py | 25 +++++++-- pydis_site/templates/resources/resources.html | 81 +++++++++++++++++---------- 2 files changed, 71 insertions(+), 35 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/resources/views/resources.py b/pydis_site/apps/resources/views/resources.py index dfd21682..f88a23fb 100644 --- a/pydis_site/apps/resources/views/resources.py +++ b/pydis_site/apps/resources/views/resources.py @@ -1,11 +1,24 @@ -from django.views.generic import TemplateView from django.shortcuts import render -# class ResourcesView(TemplateView): -# """View for resources index page.""" -# -# template_name = "resources/resources.html" +from pydis_site.apps.resources.utils import get_resources_meta + +RESOURCE_META_TAGS = get_resources_meta() + + +def format_checkbox_options(options: str) -> list: + """Split up the comma separated parameters into a list.""" + if options: + return options.split(",")[:-1] + return list() def resource_view(request): - return render(request, template_name="resources/resources.html") + """View for resources index page.""" + context = { + "checkboxOptions": format_checkbox_options(request.GET.get("checkboxOptions")), + "topics": RESOURCE_META_TAGS.get("topics"), + "tag_types": RESOURCE_META_TAGS.get("type"), + "payment_tiers": RESOURCE_META_TAGS.get("payment_tiers"), + "complexities": RESOURCE_META_TAGS.get("complexity") + } + return render(request, template_name="resources/resources.html", context=context) diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index 7eb21432..fca3d0da 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -23,55 +23,66 @@
Topic -
- -
- -
-
+ {% endfor %}
Type + + {% for tag_type in tag_types %}
-
+
+ {% endfor %}
Payment + + {% for payment_tier in payment_tiers %}
-
+
+ {% endfor %}
Level + + {% for complexity in complexities %}
-
+
+ {% endfor %}
-
- +
+ + + + + + + + +
@@ -79,9 +90,18 @@ {% endblock %} -- cgit v1.2.3 From 95e7b11df812e09baffe9ef16807e7d02a5e6f1d Mon Sep 17 00:00:00 2001 From: fisher60 Date: Sun, 25 Jul 2021 19:49:01 -0500 Subject: working demo of smart resources search I have incorporated a search that allows users to check boxes to filter resources. This is a working version, but the algo for searching likely needs to be modified. The frontend also needs some style updates. All necessary functionality should be present now though. --- pydis_site/apps/resources/utils.py | 25 ++++++++++++-- pydis_site/apps/resources/views/resources.py | 10 +++--- pydis_site/apps/resources/views/resources_list.py | 4 +-- pydis_site/templates/resources/resources.html | 41 +++++++++++++++++++++-- 4 files changed, 69 insertions(+), 11 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/resources/utils.py b/pydis_site/apps/resources/utils.py index bb812ec0..7f238431 100644 --- a/pydis_site/apps/resources/utils.py +++ b/pydis_site/apps/resources/utils.py @@ -15,7 +15,28 @@ default_categories = [ ] -def get_resources() -> list[dict[str, t.Union[list[str], str]]]: +def yaml_file_matches_search(yaml_data: dict[str, t.Union[list[str], str]], search_terms: list[str]) -> bool: + match_count = 0 + search_len = len(search_terms) + for search in search_terms: + for _, values in yaml_data["tags"].items(): + if search.lower() in values: + match_count += 1 + if match_count >= search_len: + return True + return False + + +def get_resources_from_search(search_categories: list[str]) -> list[dict[str, t.Union[list[str], str]]]: + out = [] + for item in RESOURCES_PATH.rglob("*.yaml"): + this_dict = yaml.safe_load(item.read_text()) + if yaml_file_matches_search(this_dict, search_categories): + out.append(this_dict) + return out + + +def get_all_resources() -> list[dict[str, t.Union[list[str], str]]]: """Loads resource YAMLs from provided path.""" return [yaml.safe_load(item.read_text()) for item in RESOURCES_PATH.rglob("*.yaml")] @@ -24,7 +45,7 @@ def get_resources_meta() -> dict[str, list[str]]: """Combines the tags from each resource into one dictionary of unique tags.""" resource_meta_tags = {x: set() for x in default_categories} - for resource in get_resources(): + for resource in get_all_resources(): for tag_key, tag_values in resource.get("tags").items(): for tag_item in tag_values: resource_meta_tags[tag_key].add(tag_item.title().replace('And', 'and', -1)) diff --git a/pydis_site/apps/resources/views/resources.py b/pydis_site/apps/resources/views/resources.py index 2414e48b..ffb4f4a8 100644 --- a/pydis_site/apps/resources/views/resources.py +++ b/pydis_site/apps/resources/views/resources.py @@ -1,26 +1,28 @@ from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from pydis_site.apps.resources.utils import get_resources_meta +from pydis_site.apps.resources.utils import get_all_resources, get_resources_from_search, get_resources_meta RESOURCE_META_TAGS = get_resources_meta() def format_checkbox_options(options: str) -> list[str]: - """Split up the comma separated parameters into a list.""" + """Split up the comma separated query parameters for checkbox options into a list.""" return options.split(",")[:-1] if options else [] def resource_view(request: HttpRequest) -> HttpResponse: """View for resources index page.""" + checkbox_options = format_checkbox_options(request.GET.get("checkboxOptions")) return render( request, template_name="resources/resources.html", context={ - "checkboxOptions": format_checkbox_options(request.GET.get("checkboxOptions")), + "checkboxOptions": checkbox_options, "topics": RESOURCE_META_TAGS.get("topics"), "tag_types": RESOURCE_META_TAGS.get("type"), "payment_tiers": RESOURCE_META_TAGS.get("payment_tiers"), - "complexities": RESOURCE_META_TAGS.get("complexity") + "complexities": RESOURCE_META_TAGS.get("complexity"), + "resources": get_resources_from_search(checkbox_options) } ) diff --git a/pydis_site/apps/resources/views/resources_list.py b/pydis_site/apps/resources/views/resources_list.py index 0ec74d78..bd43be33 100644 --- a/pydis_site/apps/resources/views/resources_list.py +++ b/pydis_site/apps/resources/views/resources_list.py @@ -2,7 +2,7 @@ from typing import Any, Dict from django.views.generic import TemplateView -from pydis_site.apps.resources.utils import get_resources +from pydis_site.apps.resources.utils import get_all_resources class ResourcesListView(TemplateView): @@ -13,6 +13,6 @@ class ResourcesListView(TemplateView): def get_context_data(self, **kwargs) -> Dict[str, Any]: """Add resources and subcategories data into context.""" context = super().get_context_data(**kwargs) - context["resources"] = get_resources() + context["resources"] = get_all_resources() return context diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index fca3d0da..e2275e89 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -1,9 +1,11 @@ {% extends 'base/base.html' %} +{% load as_icon %} {% load static %} {% block title %}Resources{% endblock %} {% block head %} - + + {% endblock %} {% block content %} @@ -89,16 +91,49 @@ + + {% if resources|length > 0 %} +
+
+
+
+ {% for resource in resources %} + {% include "resources/resource_box.html" %} + {% endfor %} + + {% for subcategory in subcategories %} +

+ + {{ subcategory.category_info.name }} + +

+

{{ subcategory.category_info.description|safe }}

+ + {% for resource in subcategory.resources %} + {% with category_info=subcategory.category_info %} + {% include "resources/resource_box.html" %} + {% endwith %} + {% endfor %} + {% endfor %} +
+
+
+
+ {% else %} +

No resources matching search.

+ {% endif %} + {% endblock %} -- cgit v1.2.3 From 1dbe8046c38d43bc87fe6a78b1bfc61a3599de01 Mon Sep 17 00:00:00 2001 From: dawnofmidnight Date: Tue, 3 Aug 2021 14:53:17 -0400 Subject: styles: filtering resources page --- pydis_site/apps/resources/utils.py | 2 +- pydis_site/static/css/resources/resources_list.css | 9 ++++++ pydis_site/templates/resources/resources.html | 34 ++++++++++------------ 3 files changed, 25 insertions(+), 20 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/resources/utils.py b/pydis_site/apps/resources/utils.py index 623dd7b6..bc444df4 100644 --- a/pydis_site/apps/resources/utils.py +++ b/pydis_site/apps/resources/utils.py @@ -21,7 +21,7 @@ RESOURCES: dict[str, Resource] = {path.stem: yaml.safe_load(path.read_text()) fo RESOURCE_TABLE = {category: defaultdict(set) for category in ( "topics", - "payment_tiers", + "payment_tiers", "complexity", "type" )} diff --git a/pydis_site/static/css/resources/resources_list.css b/pydis_site/static/css/resources/resources_list.css index e6808a99..283a506b 100644 --- a/pydis_site/static/css/resources/resources_list.css +++ b/pydis_site/static/css/resources/resources_list.css @@ -53,3 +53,12 @@ i.resource-icon.is-black { i.has-icon-padding { padding: 0 10px 25px 0; } + +#tab-content p { + display: none; +} + +#tab-content p.is-active { +display: block; +} + \ No newline at end of file diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index f2d5a976..8105a557 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -17,58 +17,58 @@

Resources


-
+

Search Options

-
- Topic +
+
Topic
{% for topic in topics %}
-
{% endfor %}
-
- Type +
+
Type
{% for tag_type in tag_types %}
{% endfor %}
-
- Payment +
+
Payment
{% for payment_tier in payment_tiers %}
{% endfor %}
-
- Level +
+
Level
{% for complexity in complexities %}
{% endfor %} @@ -76,7 +76,6 @@
- @@ -84,12 +83,9 @@ -
-
-
{% if resources|length > 0 %} @@ -120,7 +116,7 @@
{% else %} -

No resources matching search.

+

No resources matching search.

{% endif %} {% endblock %} -- cgit v1.2.3 From 4adf44bb7aa524f06b81f18218376799f3a75319 Mon Sep 17 00:00:00 2001 From: Vivaan Verma Date: Mon, 16 Aug 2021 22:25:48 +0100 Subject: fix: Make select all buttons for each individual column --- pydis_site/templates/resources/resources.html | 42 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index 11f7ceab..0e4302c6 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -22,14 +22,14 @@
-
+
Topic
{% for topic in topics_1 %}
@@ -39,52 +39,64 @@ {% for topic in topics_2 %}
{% endfor %}
+ + +
-
+
Type
{% for tag_type in tag_types %}
{% endfor %} + + +
-
+
Payment
{% for payment_tier in payment_tiers %}
{% endfor %} + + +
-
+
Level
{% for complexity in complexities %}
{% endfor %} + + +
@@ -93,13 +105,9 @@ - + - - - -
@@ -178,10 +186,12 @@ }); } - function selectAllQueryParams(){ + function selectAllQueryParams(column){ checkboxOptions.forEach((option) => { document.querySelectorAll(createQuerySelect(option)).forEach((checkbox) => { - checkbox.checked = true; + if (checkbox.className == column) { + checkbox.checked = true; + } }); }); } -- cgit v1.2.3 From a09b0b10fac6d84166779e72f4ed5fc4fcfcf0fb Mon Sep 17 00:00:00 2001 From: Vivaan Verma Date: Tue, 17 Aug 2021 10:23:58 +0100 Subject: Align select all buttons to center of column --- pydis_site/templates/resources/resources.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index 0e4302c6..2ae28725 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -46,7 +46,7 @@ {% endfor %}
- +

@@ -62,7 +62,7 @@
{% endfor %} - +
@@ -78,7 +78,7 @@
{% endfor %} - + @@ -94,7 +94,7 @@ {% endfor %} - + -- cgit v1.2.3 From 990eebae44ba6f9328d8c15d02319f8c2a07f850 Mon Sep 17 00:00:00 2001 From: swfarnsworth Date: Sat, 4 Sep 2021 17:31:05 -0400 Subject: Drop -Option from {topic,type,etc}Option. Having -Option in the names was making the URL especially verbose. --- pydis_site/apps/resources/views/resources.py | 8 ++++---- pydis_site/templates/resources/resources.html | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/apps/resources/views/resources.py b/pydis_site/apps/resources/views/resources.py index a7c631dc..60ec6d8f 100644 --- a/pydis_site/apps/resources/views/resources.py +++ b/pydis_site/apps/resources/views/resources.py @@ -16,10 +16,10 @@ def resource_view(request: HttpRequest) -> HttpResponse: checkbox_options = { a: set(format_checkbox_options(request.GET.get(b))) for a, b in ( - ('topics', 'topicOption'), - ('type', 'typeOption'), - ('payment_tiers', 'paymentOption'), - ('complexity', 'complexityOption'), + ('topics', 'topic'), + ('type', 'type'), + ('payment_tiers', 'payment'), + ('complexity', 'complexity'), ) } diff --git a/pydis_site/templates/resources/resources.html b/pydis_site/templates/resources/resources.html index 2ae28725..e9695fff 100644 --- a/pydis_site/templates/resources/resources.html +++ b/pydis_site/templates/resources/resources.html @@ -29,7 +29,7 @@ {% for topic in topics_1 %}
@@ -39,7 +39,7 @@ {% for topic in topics_2 %}
@@ -57,7 +57,7 @@ {% for tag_type in tag_types %}
@@ -73,7 +73,7 @@ {% for payment_tier in payment_tiers %}
@@ -89,7 +89,7 @@ {% for complexity in complexities %}
@@ -147,8 +147,7 @@ {% endblock %} -- cgit v1.2.3 From cacbece7686f1d98671eecb4f9e82fb5724d3445 Mon Sep 17 00:00:00 2001 From: kosayoda Date: Sun, 23 Jan 2022 14:48:25 -0500 Subject: Prevent page title from overlapping dropdown button. On clients with a small viewport width, the content title of pages overlap the "Sub-Articles" dropdown button due to having the same z-index, causing the element last positioned in the HTML to show up on top. Fixes #643. --- pydis_site/templates/content/dropdown.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/templates') diff --git a/pydis_site/templates/content/dropdown.html b/pydis_site/templates/content/dropdown.html index d81e29dc..13c89c68 100644 --- a/pydis_site/templates/content/dropdown.html +++ b/pydis_site/templates/content/dropdown.html @@ -1,4 +1,4 @@ -