linkfree-generator icon indicating copy to clipboard operation
linkfree-generator copied to clipboard

Deploy: Make user download index.html as .zip folder

Open Adedoyin-Emmanuel opened this issue 2 years ago • 3 comments

We can add an option to make the user download the index.html file as a zipped file so they can easily deploy it on Netlify

Screenshot from 2023-07-30 17-57-40 pages.

Adedoyin-Emmanuel avatar Jul 30 '23 16:07 Adedoyin-Emmanuel

Good idea. This is possible with output buffers and the ziparchive library in php:

  • https://www.php.net/manual/en/book.outcontrol.php
  • https://www.php.net/manual/en/ziparchive.addfromstring.php
  • https://www.php.net/manual/en/function.tmpfile.php

As an alternative to ziparchive and tmpfile, I could use ZipStream. However, that would complicate the project somewhat.

This is probably something that I should do, but if someone thinks that they can do it, I'm happy to assign.

chriskthomas avatar Jul 31 '23 17:07 chriskthomas

@chriskthomas can you assign the task to me

Adedoyin-Emmanuel avatar Jul 31 '23 18:07 Adedoyin-Emmanuel

@chriskthomas can you assign the task to me

Sure! I think you'll want to:

  • Refactor the code in api.php so that it always writes to an output buffer
  • Add a checkbox to the interface in index.php for zipping the file
  • When api.php sees that the checkbox is false: print the output buffer and exit
  • When api.php sees that the checkbox is true: (1) create a tempfile zip archive, (2) add the output buffer as a string to the archive, and (3) send the archive as a download

chriskthomas avatar Jul 31 '23 20:07 chriskthomas

@Adedoyin-Emmanuel are you still interested in doing this? Let me know if you need any help.

chriskthomas avatar Jun 21 '24 23:06 chriskthomas