Skip to content

Conversation

@wesleyboar
Copy link
Member

@wesleyboar wesleyboar commented Sep 10, 2024

Overview

Allow CMS News to be loaded on other websites.

Related

Changes

  • added new app remote_content
  • added temporary middleware
  • renamed template raw.html to plain.html

Testing

Follow https://github.com/wesleyboar/Core-CMS-Plugin-Remote-Content/blob/main/TESTING.md.

UI

  1. News can be loaded from Site 1 (https://localhost) with or without styles.

    Site 1 News Site 1 News
    No Styles
    site 1 news site 1 news - no styles
  2. Site 2 (http://127.0.0.1) can use a plugin to load content from Site 1 (http://localhost).
    Site 1 host is defined in setting PORTAL_PLUGIN_CONTENT_NETLOC, which defaults to https://tacc.utexas.edu, but is set to http://localhost for this demo.

    Choose Plugin Enter Content Path Save Plugin
    plugin choice plugin form plugin instance
  3. Site 1 (http://localhost) news can be loaded on Site 2 (http://127.0.0.1).

    Image Load Error
    Expected Issue
    Caused by CORS
    Proof that Cause is CORS
    site news via site 2 - image load error site news via site 2 - show CORS error
  4. Image load error is because Site 1 (http://localhost) does not permit its content to be hijacked on Site 2 (http://127.0.0.1). Cumbersome to fix on a local test website, but can be fixed on a properly-served website.

    If CORS Were Fixed
    We Can Fix It on Real Site
    site news via site 2 - bypass CORS error
  5. External articles open in new window.

    external.article.links.mov

    External articles are tagged external and have external link hidden within their abstract. Details.

  6. P.S. Site 2 (http://127.0.0.1) could still have its own news. I do not suggest this; it is merely proof that the content of each site is still independent.

    Independent Site 2 Content
    site 2 news
Before Plugin Solution
Site 1 News on Site 1 RAW Site 1 News via Site 2 RAW
site 1 news via site 2 RAW site 1 news on site 1 RAW

[!TIP]
We only want the markup, so load the article with ?template=raw.html.

Site 1 News on Site 1 Site 1 News via Site 2
site 1 news on site 1 site 1 news via site 2

Notes

Warning

Resources via CSS @import and JS import in HTML will not load.

Status

Completed Tasks
  • make it work
  • extract independent changes
  • divorce naming from blog feature
  • use setting and query param for URL
  • refactor after discussion
  • make template optional and configurable
  • support external articles
    e.g. on news page 4 (or later page), the link "NSF, TACC Announce Groundbreaking Leadership-Class Computing Facility" redirects to an external site's article instead of our internal article
    • This can be handled on client via JavaScript just like tup-ui does it. No need to integrate this into the new code.
  • update/remove settings accordingly
  • remove middleware
  • improve https://github.com/wesleyboar/Core-CMS-Plugin-Remote-Content
    • improve form UI
    • change setting to PORTAL_CONTENT_…
    • add test cases
    • release version
  • update "UI" section of PR
  • get review from WMA team
  • ask whether all plugins may be installed on core
    Answer: Yes. Note, we could choose to activate1 per site, but because CMS user permissions can manage plugin access, it is okay to also activate1 TACC plugins on every site.
  • fix article links; open article on source site
    Change links to absolute URLs by default.
  • fix pagination links; open next page in client site
    Allow user to retain relative URLs for some links specified via new setting.
  • add plain.html to TACC's CMS_TEMPLATES
    V3.4.0/fp 1439 yearly site theme for texascale #508
    Task/ecepweb-205-logos #509
  • migrate repo to TACC
  • create test on https://dev.cep.tacc.utexas.edu
  • get review from CMS admin user H.P.
  • support external article links
Abandoned Tasks

Footnotes

  1. By "activate" I mean add to INSTALLED_APPS. All apps used by Core-CMS are actually "installed" on every client as dependencies by Poetry. 2

wesleyboar and others added 20 commits July 19, 2024 15:54
NOT WORKING! Fails with:

> NoReverseMatch at /feed/
> '' is not a registered namespace
Fails, because it renders nothing.
Load `/blog/remote`.

BREAKING CHANGE: Changed `/blog` to `/blog/local`
⚠️ Does NOT render feed items.
This reverts commit 6bece39.

This did not fix anything. `SESSION_COOKIE_SECURE=False` is still required locally.
@wesleyboar wesleyboar added feature A new feature or replacement of present feature effort XL Extra large effort task (~4 weeks) — does not include review time labels Sep 10, 2024
@wesleyboar wesleyboar force-pushed the feat/tup-706-news-on-other-sites branch from bd3397d to 104fe71 Compare September 10, 2024 22:37
@wesleyboar wesleyboar marked this pull request as ready for review May 20, 2025 19:57
@taoteg
Copy link
Contributor

taoteg commented May 21, 2025

Dropping this here for later - configuring Nginx CORS for multiple origins: https://stackoverflow.com/questions/79588791/how-to-properly-allow-multiple-origins-for-a-cross-origin-cors-request

TL;DR:

`Before outputting your Access-Control-Allow-Origin header, check to see if the Origin request header is an allowed origin. This is most easily done by having an array of allowed origins and using in_array. You could also do more complex approaches (e.g. using a regular expression) but be careful not to be more permissive that you need to be.

If it is not, issue your "denied" response.

If it is, then use that value in the response.

If the request is a (preflight) OPTIONS request, then don't do any further processing. Just respond that it is OK to send the actual request.`

@wesleyboar
Copy link
Member Author

After much self-review, before and after peer reviews, this PR is ready to be merged! All features are working on https://dev.cep.tacc.utexas.edu/news-from-tacc/. Image load is responsibility of CORS headers on source, so images not loading does not block this PR.

@wesleyboar wesleyboar merged commit 5562561 into main May 28, 2025
@wesleyboar wesleyboar deleted the feat/tup-706-news-on-other-sites branch May 28, 2025 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort XL Extra large effort task (~4 weeks) — does not include review time feature A new feature or replacement of present feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to Load Blog Articles Across Sites

3 participants