Giter Site home page Giter Site logo

kirby-plugin-zip's Introduction

Kirby ZIP plugin

Creates a ZIP archive from a list of files.

Requirements

You need PHP ZIP module enabled.

Setup a new project

  1. go to the root of your Kirby project :
cd path/to/your-project
  1. clone this repo :
git submodule add https://github.com/julien-gargot/kirby-plugin-zip.git site/plugins/zip

Configure

You can set different defaults parameters in your config.php :

  • the route URL to download the ZIPs : c::set('zip.download.url', "download/archive"),
  • where to save ZIPs (include trailing slash) : c::set('zip.destination.path', "tmp/zip/"),
  • also the ZIP filename : c::set('zip.default.filename', "archive").

If you need individual case by ZIP, just edit the plugin ;).

Use

Plugin needs a JSON object formatted like this:

{
  page-hash : filename.ext,
  page-hash : filename.ext,
  …
}

For now, plugin gets files by doing a $site->index()->findBy('hash', page-hash) then $result_page->file(filename.ext).

Use POST to the send the JSON to the zip.download.url. Default URL is download/archive.

General infos

  • ❗ I’m not a specialist about ZIP and PHP optimisation. If a lot of users start a ZIP generation at the same time, it will probably overload your server. Any advice appreciated.
  • ZIP can be conserved or not. Your call. Edit the plugin. cf. line 44
  • If user close the connection before the ZIP is generated, it continue the process on your server and will save it, not matter your settings.
  • Filenames inside the archive are set line 85.

TODO

  • Write a better description and readme
  • Create a kirby tag. Something like (zip: file-1.ext, file-2.ext, file-3.ext zipname: my-archive).
  • Prevent multiple ZIP generation and server overload.

kirby-plugin-zip's People

Contributors

julien-gargot avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.