-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(submod): texascale, load annual stylesheets
For: https://jira.tacc.utexas.edu/browse/FP-1439 Mirrors: #490
- Loading branch information
1 parent
07a7df2
commit bcd1bfa
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import re | ||
|
||
from django import template | ||
from urllib.parse import urlparse | ||
|
||
register = template.Library() | ||
|
||
@register.filter | ||
def get_url_match(path, pattern): | ||
""" | ||
Custom Template Filter `get_url_match` | ||
Use: Render string that matches given pattern from current page URL. | ||
Load custom filter into template: | ||
{% load get_url_match %} | ||
Template inline usage: | ||
{# given path '.../2019/...', does nothing #} | ||
{% if path|get_url_match:"/20\d\d/" %} | ||
{# condition evaluates to False #} | ||
{% endif %} | ||
{# given path '.../2020/...', does something #} | ||
{% if path|get_url_match:"/20\d\d/" %} | ||
{# condition evaluates to True #} | ||
{% endif %} | ||
{# given path '.../2021/...', prints complete match #} | ||
{% with year_path=path|get_url_match:"/20\d\d/" %} | ||
<pre>{{ year_path }}</pre> {# prints complete match #} | ||
{% endwith %} | ||
{# given path '.../2022/...', prints matched content #} | ||
{% with year_slug=path|get_url_match:"/(20\d\d)/" %} | ||
<pre>{{ year_slug }}</pre> {# prints match within the (…) #} | ||
{% endwith %} | ||
""" | ||
result = re.search(pattern, path) | ||
|
||
if result: | ||
try: | ||
match = result.group(1) | ||
except IndexError: | ||
match = result[0] | ||
else: | ||
match = False | ||
|
||
return match |
Submodule taccsite_custom
updated
2 files
+18 −0 | texascale-org/templates/base.html | |
+1 −1 | texascale-org/templates/fullwidth.html |