linkfree-generator
linkfree-generator copied to clipboard
Deploy: Make user download index.html as .zip folder
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
pages.
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 can you assign the task to me
@chriskthomas can you assign the task to me
Sure! I think you'll want to:
- Refactor the code in
api.phpso that it always writes to an output buffer - Add a checkbox to the interface in
index.phpfor zipping the file - When
api.phpsees that the checkbox is false: print the output buffer and exit - When
api.phpsees 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
@Adedoyin-Emmanuel are you still interested in doing this? Let me know if you need any help.