Skip to content
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

feat: WP-197 conditional PORTAL_STYLES #880

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion taccsite_cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,15 @@ def gettext(s): return s
PORTAL_STYLES = []
# PORTAL_STYLES = [{
# "is_remote": True,
# "path": "https://cdn.jsdelivr.net/gh/TACC/Core-CMS-Custom@2cdc59f/example_cms/src/apps/example_app/static/example_app/css/example_app.css",
# "path": "https://cdn.jsdelivr.net/gh/TACC/Core-CMS-Custom@design/example_assets/css/site.css",
# }, {
# "is_remote": True,
# "page_id": "home",
# "path": "https://cdn.jsdelivr.net/gh/TACC/Core-CMS-Custom@design/example_assets/css/page.home.css",
# }, {
# "is_remote": True,
# "template_name": "standard.html",
# "path": "https://cdn.jsdelivr.net/gh/TACC/Core-CMS-Custom@design/example_assets/css/template.standard.css",
# }]

# Only use integer numbers (not "v1", not "0.11.0"),
Expand Down
30 changes: 27 additions & 3 deletions taccsite_cms/templates/assets_custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,33 @@

<!-- Custom Site Assets: Styles. -->
{% with settings.PORTAL_STYLES as styles %}
{% for style in styles %}
<link rel="stylesheet" href="{% if style.is_remote %}{{ style.path }}{% else %}{% static style.path %}{% endif %}" />
{% endfor %}
{% for style in styles %}
{% with current_page.reverse_id as page_id %}
{% with CMS_TEMPLATE as page_template %}
{% with style.page_id as style_id %}
{% with style.template_name as style_template %}
{% if style_id == page_id and not style_template or style_template == page_template and not style_id or style_id == page_id and style_template == page_template or not style_id and not style_template %}
<link rel="stylesheet"

{% if style.is_remote %}
href="{{ style.path }}"
{% else %}
href="{% static style.path %}"
{% endif %}

{% if style_template and style_template == page_template %}
data-for-template="{{ style.template_name }}"
{% endif %}
{% if style_id and style_id == page_id %}
data-for-page="{{ style.page_id }}"
{% endif %}
/>
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endfor %}
{% endwith %}


Expand Down