ICS filename hardcoded to 'addtocal.ics', should use Title.

Created on 24 July 2023, over 1 year ago
Updated 3 May 2024, 8 months ago

Problem/Motivation

On 8.x-1.x the .ics files were provided with the sanitised title as the filename. Since 8.x-2.x this has changed to be hardcoded to 'addtocal'.
Even if this was done for a specific reason, the option of being able to override that title might be nice!

Steps to reproduce

Create an Add To Cal widget and click on the 'iCal' option and you will see the file that is downloaded is called 'addtocal.ics'

Proposed resolution

Provide a data attribute for the JS to be able to use as a filename

Remaining tasks

Test

User interface changes

File name of ics download changes

✨ Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom ChrisDarke London

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ChrisDarke
  • @chrisdarke opened merge request.
  • Status changed to Needs review over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom ChrisDarke London

    Adding Fork and merge request.
    Updated Remaining tasks and status.

  • πŸ‡¬πŸ‡§United Kingdom ChrisDarke London

    @Maintainers, is there a timeline for getting some of these 3.0.0-beta1 issues resolved? I am at the point where multiple composer patches are conflicting. If no one is able to commit time to this project feel free to put out an issue looking for co-maintainers so we can get some of these issues past the finish line, cheers!

  • πŸ‡¬πŸ‡§United Kingdom danielzigo

    @ChrisDarke, I've tested this on 3.0.0-beta1, and I saw the file name change from 'addtocal.ics' to 'Test basic.ics' on the creation of the file. If what I described hasn't been before, it may be the browser (tested on Arc browser). This was when I added the date field to a basic page named 'Test basic page'.

    I tested on another basic page named 'Hello world', and noticed that the file name of the ICS file was 'Hello world addtolocal.ics'. I thought that was weird, so I renamed the page to 'Hello world page' and tried again, and this time the file was named 'Hello world.ics'.

    If this isn't desired, then maybe a bit of work is necessary.

    Setup: D9.5.11, PHP 8.1

  • πŸ‡ΊπŸ‡ΈUnited States aarontocenter

    @chrisdarke @danielzigo

    Thank you both for your testing, and "bump" of priority, I too now have a D10 site that was upgraded from D9, and D7 before that, it is using the add to calendar module and finding the generic "event.ics" that is downloaded with clicking iCal from Firefox is lost in random downloads.

    We continue to get requests for this title to be returned as it was in the previous versions.

    @Maintainers With the new year on us, can we circle back to another commit? Thanks!

  • πŸ‡©πŸ‡ͺGermany quotientix

    To fix this, I changed the code in addtocal-download.js to this:

    Drupal.behaviors.addtocalDownload = {
        attach: function (context, settings) {
          // Trigger file download for any data links generated by addtocal.
          console.log("vor allem");
          $(once('addtocal', '.addtocal-container', context)).each(function () {
            $('.addtocal-link a', context).click(function (event) {
              var href = $(this).attr('href');
              if (/^data:/.test(href)) {
                var title = $('h1').text(); // My node-title
                // var filename = 'addtocal';
                if (/^data:text\/calendar/.test(href)) {
                  title += '.ics';
                }
                download(href, title);
                event.preventDefault();
              }
            });
          });
        },
    
        download: download
      };

    Maybe that helps for now.

Production build 0.71.5 2024