-
-
Notifications
You must be signed in to change notification settings - Fork 138
Implement front-end spec for Smarter Resources #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9a5fd18
667a13e
07ba4f0
577dd08
0d0ab20
f0676fe
5b18052
cec38ec
2d232fc
4d4411a
4adf44b
a09b0b1
d2543b6
a960b3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| description: This tutorial, written by Python Discord staff member vcokltfre, | ||
| will walk you through all the aspects of creating your own Discord bot, | ||
| starting from from creating the bot user itself. | ||
| name: vcokltfre's Discord Bot Tutorial | ||
| title_url: https://vcokltfre.dev/ | ||
| tags: | ||
| topics: | ||
| - discord bots | ||
| payment_tiers: | ||
| - free | ||
| complexity: | ||
| - intermediate | ||
| type: | ||
| - tutorial |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from django import template | ||
|
|
||
| register = template.Library() | ||
|
|
||
|
|
||
| @register.filter | ||
| def get_category_icon(name: str) -> str: | ||
| """Get icon of a specific resource category.""" | ||
| icons = { | ||
| "Algorithms And Data Structures": "fa-cogs", | ||
| "Data Science": "fa-flask", | ||
| "Databases": "fa-server", | ||
| "Game Development": "fa-joystick", | ||
| "General": "fa-book", | ||
| "Microcontrollers": "fa-microchip", | ||
| "Other": "fa-question-circle", | ||
| "Software Design": "fa-paint-brush", | ||
| "Testing": "fa-vial", | ||
| "Tooling": "fa-toolbox", | ||
| "User Interface": "fa-desktop", | ||
| "Web Development": "fa-wifi", | ||
| "Discord Bots": "fa-robot", | ||
| "Book": "fa-book", | ||
| "Community": "fa-users", | ||
| "Course": "fa-chalkboard-teacher", | ||
| "Interactive": "fa-mouse-pointer", | ||
| "Podcast": "fa-microphone-alt", | ||
| "Tool": "fa-tools", | ||
| "Tutorial": "fa-clipboard-list", | ||
| "Video": "fa-video", | ||
| "Free": "fa-first-aid", | ||
| "Paid": "fa-sack", | ||
| "Subscription": "fa-credit-card", | ||
| "Beginner": "fa-play-circle", | ||
| "Intermediate": "fa-align-center" | ||
| } | ||
| icon_name = icons[name] | ||
| return f'fa {icon_name}' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,12 +23,15 @@ def resource_view(request: HttpRequest) -> HttpResponse: | |
| ) | ||
| } | ||
|
|
||
| topics = sorted(RESOURCE_META_TAGS.get("topics")) | ||
|
|
||
| return render( | ||
| request, | ||
| template_name="resources/resources.html", | ||
| context={ | ||
| "checkboxOptions": checkbox_options, | ||
| "topics": sorted(RESOURCE_META_TAGS.get("topics")), | ||
| "topics_1": topics[:len(topics) // 2], | ||
| "topics_2": topics[len(topics) // 2:], | ||
|
Comment on lines
+33
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to double check that this doesn't affect the back end logic in any way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't |
||
| "tag_types": sorted(RESOURCE_META_TAGS.get("type")), | ||
| "payment_tiers": sorted(RESOURCE_META_TAGS.get("payment_tiers")), | ||
| "complexities": sorted(RESOURCE_META_TAGS.get("complexity")), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,4 +61,3 @@ i.has-icon-padding { | |
| #tab-content p.is-active { | ||
| display: block; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dictionary should be a global so that it's not being re-created each time. Try naming it
_ICONS.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure Python handles this and uses LOAD CONST, that said using an all-caps variable at the top of the file is cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I wish we had function composition so that this function could just be
get_category_icon = register.filter @ 'fa {icon_name}'.format @ icons.get, but no 😞