TACC / Core-CMS

The Core CMS codebase used by TACC Portals.
https://cep.tacc.utexas.edu
2 stars 1 forks source link

TUP-703 TACC Home Banner Links Open in New Window #805

Closed R-Tomas-Gonzalez closed 4 months ago

R-Tomas-Gonzalez commented 4 months ago

Overview

Prevent banner links from opening in new windows.

Related

Changes

Changes what is considered an external link. Looks for the host name with or without www., then opens in new window if it isn't matching to the document's host.

Testing

A) If you'd like to troubleshoot in TUP-UI Repo:

  1. Comment out code on Core CMS
  2. Follow https://github.com/TACC/Core-CMS/wiki/Locally-Develop-CMS-and-TUP-CMS
  3. Make snippet with code in TUP -> look at attachment for example
  4. Add snippet to Django and import it in the footer

B) If you'd like to just test these changes in TUP-UI using Core_CMS

  1. Follow https://github.com/TACC/Core-CMS/wiki/Locally-Develop-CMS-and-TUP-CMS

UI

Notes

The shouldForceSetTarget function below:

      const shouldForceSetTarget = pathsToForceSetTarget.some(path => {
        let shouldForce;
        if (path instanceof RegExp) {
          shouldForce = path.test(link.pathname);
        }
        if (typeof path === 'string') {
          shouldForce = _doPathsMatch(path, link.pathname);
        }
        if (SHOULD_DEBUG && shouldForce) {
          console.debug(`Path "${link.pathname}" matches "${path}"`);
        }
        return shouldForce;
      });

does not allow external links to open in a new window.

For instance. If you're in localhost, and have a tacc.utexas.edu link - it should open in a new window because it doesn't match the host.

This might be something you test in tup-ui repo using the A) testing steps above