Skip to content

⏸️ feat: WP-197 conditional PORTAL_STYLES#880

Closed
wesleyboar wants to merge 5 commits into
mainfrom
feat/WP-197-conditional-portal-styles
Closed

⏸️ feat: WP-197 conditional PORTAL_STYLES#880
wesleyboar wants to merge 5 commits into
mainfrom
feat/WP-197-conditional-portal-styles

Conversation

@wesleyboar

@wesleyboar wesleyboar commented Oct 1, 2024

Copy link
Copy Markdown
Member

Status

Important

Replaced by:

Overview

Update PORTAL_STYLES setting to:

  • Make entry with page_id only load on Django CMS page with matching "Id".
  • Make entry with template_name only load on Django CMS page with matching "Template".
Why?

Allows a custom CMS on taccwma/core-cms Docker image to have page-specific stylesheets (without using a CMS Snippet to load the stylesheet).

What's wrong with a Snippet?
  1. Snippet developers recommend using them only during development. I agree, and always try to find ways to not use a snippet long-term (and if I must do so, then version control it).
  2. The Snippet is rendered after the header, so any styles to change the header — e.g. color swap, hide element — have a delayed effect.
  3. Using a snippet is not explicit, like a "hidden" trick.
Don't complicate the CMS. Just load the Snippet earlier.

Good idea. Less CMS code. All snippets now use "Content" or "Footer" placeholder. I would just add a custom placeholder e.g. "Head". My concerns:

  1. A "Head" placeholder would rarely be used.
    • So, only show it for admins…
      • I can do this, but then how stylesheet is loaded would be more "hidden".
  2. A "Head" would appear above "Content", quite in the way.
    • So, make it show below "Content" (and "Footer")…
      • If I can do this, then how stylesheet is loaded would be more "hidden".

Status

  • Is this worth the complexity? How many sites benefit?
    • Maybe not. Two or so:
      • Frontera (some)
      • Texascale (much)
      • UTRC (minor)
      • maybe TUP (see TACC/tup-ui#507 "Notes")
    • If worth the complexity, should it use a new templatetag?
      • Probably.
  • How about adding data-page-template on html
    Then use [data-page-template] and [data-page-id] to scope styles in global stylesheet.
    feat: data-page-template #946

Related

Changes

  • added logic for rendering PORTAL_STYLES

Testing

  1. Edit settings_local.py or settings_custom.py:

    PORTAL_STYLES = [{
        "is_remote": True,
        "path": "https://test-1.css",
    }, {
        "is_remote": True,
        "page_id": "home",
        "path": "https://test-2.css",
    }, {
        "is_remote": True,
        "template_name": "standard.html",
        "path": "https://test-3.css",
    }, {
        "is_remote": True,
        "page_id": "fruit",
        "template_name": "standard.html",
        "path": "https://test-4.css",
    }]
  2. Create/Edit pages to test these stylesheets.

    • Edit page's "Advanced settings".
    • To set page_id, set "Id".
    • To set template_name, set "Template".
    • (bonus) Test on a Blog page.
  3. Verify <!-- Custom Site Assets: Styles. --> of every page.

UI

1 1 page
2 2 page
3 3 page
3 3 app
4 4 page

@wesleyboar wesleyboar changed the title feat: conditional PORTAL_STYLES feat: WP-197 conditional PORTAL_STYLES Oct 2, 2024
@wesleyboar
wesleyboar marked this pull request as ready for review October 2, 2024 00:14
@wesleyboar wesleyboar added the proposal Proposal or request for new task label Feb 3, 2025
@wesleyboar wesleyboar added the paused Started but not actively in progress label Mar 7, 2025
@wesleyboar wesleyboar changed the title feat: WP-197 conditional PORTAL_STYLES ⏸️ feat: WP-197 conditional PORTAL_STYLES Mar 7, 2025
wesleyboar added a commit to TACC/Core-CMS-Custom that referenced this pull request Apr 16, 2025
@wesleyboar

Copy link
Copy Markdown
Member Author

Replaced by #946.

@wesleyboar wesleyboar closed this May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

paused Started but not actively in progress proposal Proposal or request for new task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant