Skip to content

Commit

Permalink
Improvement: Fix several edge-cases where the 'Mark external links' s…
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Dec 31, 2023
1 parent d86c27c commit 192a894
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2023-12-31 - Improvement: Fix several edge-cases where the "Mark external links" should not add its icons, solves #525 & #526 & #528.
* 2023-12-28 - Feature: Add slider which can be displayed on site home, solves #162.
* 2023-12-27 - Improvement: Add content style setting to the advertisement tiles, solves #519.
* 2023-12-27 - Test: Always reactivate debugging during Behat tests, solves #521.
Expand Down
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Upstream changes

* This theme is built on top of theme_boost from Moodle core. It inherits the codebase from theme_boost and overwrites and extends several behaviours and functions. Doing this, code duplication couldn't be avoided. If there are any upstream changes in theme_boost, you should check if they should be adopted to this theme as well.
* In addition to that, you should check any upstream changes which happen in /lib/templates and /lib/outputrenderers.php as some of these templates and renderers are overwritten in this theme as well.
* In addition to that, you should check if any additions to theme_boost_union_get_scss_to_mark_external_links() should be made. This might be particularly necessary if any new links have been added to the footer questionmark icon in Moodle core (have a look at footer.mustache) or if any links have been added which have a hardcoded external-link icon (check for new occurrences of "i/externallink" in the Moodle codebase).


Automated tests
Expand Down
26 changes: 24 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1421,20 +1421,42 @@ function theme_boost_union_get_scss_to_mark_external_links($theme) {
padding-right: 0.25rem;
}';

// While adding the external link icon to text links is perfectly fine and intended, the SCSS code also
// matches on image links. And this should be avoided for optical reasons.
// Unfortunately, we can't select _all_ images which are surrounded by links with pure CSS.
// But we can at least revert the external link icon in images and other assets which we know that should not
// get it:
// * Everything inside the frontpage slider.
$scss .= '#themeboostunionslider a::before, #themeboostunionslider a::after {
display: none;
}';

// Moodle adds a hardcoded external-link icon to several links:
// * The "services and support" link in the questionmark menu (which should point to moodle.com/help, but may also point to
// the URL in the $CFG->servicespage setting).
// * The "contact site support" link in the questionmark menu (as soon as the URL in the $CFG->supportpage setting is set).
// * The links to the Moodle docs (which are created with the get_docs_url() helper function).
// * The "Chat to course participants" link in the questionmark menu (as soon as the communication setting is set within
// a course).
// * The "Give feedback about this software" link in the questionmark menu (if the $CFG->enableuserfeedback setting
// is enabled).
// * Anything else which is shown in the call-to-action notification banners on the Dashboard
// (Currently just the "Give feedback about this software" link as well).
// These icons become obsolete now. We remove them with the sledgehammer.
$scss .= '.footer-support-link a[href^="https://moodle.com/help/"] .fa-external-link';
$scss .= '.footer-support-link a[href^="https://moodle.com/help/"] .fa-external-link,
.footer-support-link a[target="_blank"] .fa-external-link';
if (!empty($CFG->servicespage)) {
$scss .= ', .footer-support-link a[href="'.$CFG->servicespage.'"] .fa-external-link';
}
if (!empty($CFG->supportpage)) {
$scss .= ', a[href="'.$CFG->supportpage.'"] .fa-external-link';
}
$scss .= ', a[href^="'.get_docs_url().'"] .fa-external-link {
if (!empty($CFG->enableuserfeedback)) {
$scss .= ', a[href^="https://feedback.moodle.org"] .fa-external-link,
a[href^="https://feedback.moodle.org"] .ml-1';
}
$scss .= ', a[href^="'.get_docs_url().'"] .fa-external-link,
div.cta a .fa-external-link {
display: none;
}';
}
Expand Down

0 comments on commit 192a894

Please sign in to comment.