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

Issue #190: Fix long links displaying correctly in invite.ics #191

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

djarran
Copy link
Contributor

@djarran djarran commented Dec 16, 2024

Description: The issue described in #190 has been resolved by switching to a combination of rtrim and chunk_split.


Problem

When we create the .ics file, we need to conform to the RFC (outlined here).

To do this, we use the wordwrap function. This function wraps at word boundaries (in this case, since we set the argument $cut_long_words to true , it only does this for words less than the limit) and removes any trailing and/or leading whitespace. For example:

//                            ⌄ 20 characters reached here
$string = 'verylongwording ashorter word here';
echo wordwrap($damn, 20, "\n", true);

//Output:
//verylongwording
//ashorter word here

Note

See that the wordwrap function doesn't wrap at exactly 20 characters, and that trailing/leading spaces at the boundary are removed.

This is problematic when we view this text in a calendar client.

This causes issues when we render this text. Even though the RFC requires each line in the description to be no more than 75 octets/characters, the container holding such text is not limited by this - i.e it is responsive. In Google Calendar, the container is ~500 pixels, displaying ~55 characters.

This meant that the above output when rendered could look like so:

//verylongwordingashorter word here

This is the same problem as described in Issue #183. That was resolved in #184 by adding a space prior to the new line. But this breaks long links/words, for example:

Prior to PR #184: https://giithub.com/catalyst/moodle-mod_facetoface/pull/191
After PR #184: https://giithub.com/cat alyst/moodle-mod_facet oface/pull/191

Solution

Use a combination of rtrim and chunk_split instead of wordwrap. This is adapted from this Stackoverflow answer about the same issue.

The chunk_split function wraps at the exact length specified and keeps whitespace.

This still follows the RFC outlined here.

Testing Instructions

  1. Add plugin to a Moodle 4.3 site
  2. Create XS test course
  3. Add activity module
  4. In the form, add a title and click 'Save and display'
  5. Click 'Add a new session'
  6. Set 'Session date/time known' to Yes, add a start and finish time in the current week
  7. Add the following to the details section
Moodle is a free, online Learning Management system enabling educators to create their own private website filled with dynamic courses that extend learning, any time, anywhere. Whether you're a teacher, student or administrator, Moodle can meet your needs.

https://github.com/moodle/moodle/blob/321e04d630324c44929c931acfcce344b06e4a98/tag/classes/reportbuilder/local/entities/tag.php
  1. Save changes
  2. Sign up for session (no need to change notification type)
  3. Check Mailhog, find first email
    image
  4. Go to MIME tab and download invite.ics file
    image
  5. Import into email client
  6. Note that email is broken
    image
  7. Checkout working branch
git checkout origin/190-MOODLE_403_STABLE-ics-output 
  1. Cancel booking
  2. Repeat steps 9 - 12
  3. Description should be formatted correctly
    image

@djarran djarran self-assigned this Dec 16, 2024
@djarran djarran force-pushed the 190-MOODLE_403_STABLE-ics-output branch from 4d76356 to 26e74b2 Compare December 16, 2024 06:40
@djarran djarran force-pushed the 190-MOODLE_403_STABLE-ics-output branch from 26e74b2 to 85fe70e Compare December 17, 2024 00:16
@djarran djarran changed the title Draft: Issue #190: Fix long links displaying correctly in invite.ics Issue #190: Fix long links displaying correctly in invite.ics Dec 17, 2024
@djarran djarran requested a review from gbarat87 December 17, 2024 01:12
@gbarat87
Copy link
Contributor

Hi @djarran
Thank you.
I have tested on my side and it works as expected.

Regards,
Guillaume

@gbarat87 gbarat87 merged commit 464a772 into MOODLE_403_STABLE Dec 17, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants