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

Closes #7069: 3.18 - Exclusions part #7167

Open
wants to merge 17 commits into
base: feature/host-google-fonts
Choose a base branch
from

Conversation

Miraeld
Copy link
Contributor

@Miraeld Miraeld commented Dec 4, 2024

Description

Fixes #7069
It allows the user to use a new filter rocket_exclude_locally_host_fonts to exclude some fonts from the feature.

Type of change

  • New feature (non-breaking change which adds functionality).

Detailed scenario

Just add some fonts to exclusiosn through the new filter (rocket_exclude_locally_host_fonts), and it won't be downloaded.

Technical description

Documentation

This pull request introduces a new feature to exclude specific fonts from being rewritten in the media fonts optimization process. The changes involve adding methods to handle font exclusions and updating relevant tests to ensure the new functionality works as expected.

New Feature: Font Exclusions

Tests and Fixtures Updates

New dependencies

None

Risks

None

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

@Miraeld Miraeld added this to the 3.18 milestone Dec 4, 2024
@Miraeld Miraeld requested a review from a team December 4, 2024 01:33
@Miraeld Miraeld self-assigned this Dec 4, 2024
Copy link

codacy-production bot commented Dec 4, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.06% (target: -0.10%) 91.80% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (eb81681) 38473 16896 43.92%
Head commit (1fbb5af) 38491 (+18) 16928 (+32) 43.98% (+0.06%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7167) 61 56 91.80%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@Miraeld Miraeld linked an issue Dec 4, 2024 that may be closed by this pull request
inc/Engine/Media/Fonts/Frontend/Controller.php Outdated Show resolved Hide resolved
inc/Engine/Media/Fonts/Frontend/Controller.php Outdated Show resolved Hide resolved
inc/Engine/Media/Fonts/Frontend/Controller.php Outdated Show resolved Hide resolved
@remyperona remyperona added the type: sub-task Indicates the issue is a sub-task linked to an epics card label Dec 4, 2024
@jeawhanlee
Copy link
Contributor

I might be mistaken but I'm not sure this PR considers this thread here and the proposals following because as it is we might not be correctly excluding combined fonts or not?

@Miraeld
Copy link
Contributor Author

Miraeld commented Dec 5, 2024

@remyperona @jeawhanlee
Hello hello,

I've made modifications to comply with feedbacks.
Added, also, the exclusion to the Google Font combine feature so we won't combine excluded fonts.


Summary of changes by this PR:

This pull request introduces several enhancements to the font optimization process, specifically focusing on excluding certain fonts from being optimized based on user-defined patterns. These changes include updates to the core functionality, new methods for exclusion handling, and corresponding test cases.

Core Functionality Enhancements:

  • inc/Engine/Media/Fonts/Frontend/Controller.php: Added methods get_exclusions and is_excluded to retrieve exclusion patterns and check if a font URL matches any exclusion pattern. Updated rewrite_fonts method to skip excluded fonts during font replacement. [1] [2]

Integration with Dynamic Lists:

Google Fonts Optimization:

Test Cases:

  • Added new test fixtures and updated existing ones to validate the exclusion functionality. [1] [2] [3] [4] [5] [6] [7]
  • Updated integration tests to include the new exclusion filters and ensure they are applied correctly. [1] [2] [3] [4] [5] [6]

@Miraeld Miraeld force-pushed the feature/7069-exclusion-part branch from 22258dd to ef79267 Compare December 5, 2024 18:58
@Miraeld Miraeld requested a review from remyperona December 5, 2024 19:05
@hanna-meda
Copy link

@Miraeld, thank you for this PR.
I could only make the filter work using font family name, i.e. $exclusions[] = 'Roboto';
Based on this AC The exclusion should be regex compatible, we should also cover expressions such as:
$exclusions[] = 'https://fonts.googleapis.com/css?family=.*';
$exclusions[] = 'fonts.googleapis.com/.*';
$exclusions[] = 'https://fonts.googleapis.com/css?family=Noto%20Sans%3A400%2C700%7CMontserrat%3A700&display=swap';
$exclusions[] = 'https://fonts.googleapis.com/css?family=Rob.*';

Returning this back to In Progress based on this comment. cc @piotrbak

@jeawhanlee jeawhanlee self-assigned this Dec 11, 2024
@piotrbak
Copy link
Contributor

@hanna-meda after discussion on the daily, since the URL doesn't matter for the exclusions, we'll match the regex after it:

  • family(.*)Montserrat%3A700&display=swap
    -family=Rob(.*)o

cc @jeawhanlee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: sub-task Indicates the issue is a sub-task linked to an epics card
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.18 - Exclusions part
6 participants