gitzip Documentation

repository·master·Indexed 20 days ago

https://github.com/kinolien/gitzip

A tool and web-based API that allows users to download specific sub-folders, sub-directories, or single files of a GitHub repository as a ZIP file. Includes functionality for triggering downloads via GitZip.zipRepo() and monitoring progress through GitZip.registerCallback().

Tokens
527
Snippets
2
Records
3
Agent score
20%

What's inside gitzip

  1. Integrate GitZip into your website

    master
    To use the GitZip API in your own project, clone the repository to obtain the necessary library files and include them in your web application. Once the files are available, you can call the GitZip methods directly in your client-side code.
  2. Register a progress callback for GitZip

    master

    You can monitor the zipping process (fetching files, zipping, errors, etc.) by registering a callback function using GitZip.registerCallback(inputFn).

    The callback function receives three arguments:

    • status (string): The current state. Possible values include 'error', 'prepare', 'processing', and 'done'.
    • message (string): A descriptive message corresponding to the current status.
    • percent (number): A value from 0 to 100 representing the progress percentage (primarily for debugging).
    GitZip.registerCallback(function(status, message, percent) {
      console.log(`[${status}] ${message} - ${percent}%`);
    });
  3. Download a GitHub repository or sub-directory as a ZIP

    master

    Use GitZip.zipRepo() to trigger the zipping and downloading process for a GitHub repository, a specific sub-directory, or a single file. You can provide a callbackScope to control the this context of the progress callback if one is registered.

    Supported URL patterns include:

    • Repository root: https://github.com/user/repo
    • Sub-directory: https://github.com/user/repo/tree/branch/folder
    • Single file: https://github.com/user/repo/blob/branch/file.ext
    // Zip the entire repository
    GitZip.zipRepo("https://github.com/KinoLien/gitzip");
    
    // Zip a specific sub-directory
    GitZip.zipRepo("https://github.com/KinoLien/gitzip/tree/master/js");
    
    // Zip a single file
    GitZip.zipRepo("https://github.com/KinoLien/gitzip/blob/master/example.html");