kodbox Documentation

repository·main·Indexed 25 days ago

https://github.com/kalcaddle/kodbox

A web-based file manager and code editor providing a Windows-like experience in the browser. Features include multi-cloud storage fusion (S3, FTP, WebDAV), online document preview/editing, and fine-grained permission control. Documentation covers installation via source or download, Nginx rewrite configuration, system requirements (PHP 5.3+, MySQL, SQLite), WebDAV integration for tools like Zotero and Joplin, and database schema references for users, groups, and file management.

Tokens
8.2K
Snippets
24
Records
42
Agent score
85%

What's inside kodbox

  1. Overview of Kodbox features

    main

    Kodbox (formerly KodExplorer) is a private cloud and online document management system. Key capabilities include:

    • Multi-Cloud Storage: Supports local disk, FTP, WebDAV, Alibaba Cloud OSS, Tencent Cloud COS, Qiniu, MinIO, and S3-compatible protocols.
    • File Management: Windows-style interface with drag-and-drop, keyboard shortcuts (Ctrl+C/X/V, F2, etc.), and various view modes (Icon, List, Split).
    • Online Preview & Editing: Supports hundreds of formats including Office documents, PDFs, images, video, and code (120+ languages).
    • Collaboration: Granular permission control, file versioning, document discussions, and external link sharing with passwords/expiry.
    • Security: Login device control, 2FA, IP filtering, audit logs, and data backup.
  2. Configure Nginx rewrite rules

    main

    Kodbox requires specific Nginx rewrite configurations depending on whether it is installed in the root directory or a subdirectory. This ensures that requests are correctly routed to index.php.

    # Root directory deployment
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    # Subdirectory deployment (e.g., /kodbox/)
    location /kodbox/ {
        try_files $uri $uri/ /kodbox/index.php?$query_string;
    }
  3. Setup KaTeX using a starter template

    main

    To use KaTeX in a web project, include the KaTeX CSS and JavaScript in your HTML <head>. KaTeX requires the HTML5 doctype to render properly. You can also include the auto-render extension to automatically find and render math within text elements.

    <!DOCTYPE html>
    <html>
      <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.43/dist/katex.min.css" integrity="sha384-GN/+TZ6J/TdzuQrKFjIgwzaM0nkbGRiCBnJ9i+CmaynUcJDRE3u6Frp/8oj/lBze" crossorigin="anonymous">
    
        <!-- The loading of KaTeX is deferred to speed up page rendering -->
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.43/dist/katex.min.js" integrity="sha384-I/76u4uGYb2jZizpHGbumq1RzC/CknJIAamvKNrTumsehWnS4xX0FFQvlX0I2s/n" crossorigin="anonymous"></script>
    
        <!-- To automatically render math in text elements, include the auto-render extension: -->
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.43/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous"
            onload="renderMathInElement(document.body);"></script>
      </head>
      ...
    </html>
  4. Customizing ACE Editor for Kodbox

    main

    Kodbox uses a customized version of the ACE editor to improve support for CJK (Chinese, Japanese, Korean) characters, mobile clipboard operations, and specific language modes. If you are maintaining or upgrading the editor within Kodbox, note the following key modifications:

    • CJK Character Support: Custom regex and width calculations are used in $renderToken and isFullWidth to ensure proper cursor positioning and character spacing.
    • Mobile Clipboard: To support copy/paste on non-HTTPS connections (where navigator.clipboard is unavailable), Kodbox implements an internal fallback using ace.mobileCopyText within ace/mouse/touch_handler.
    • PHP File Renaming: To bypass certain server firewalls that block files with .php in their names, Kodbox renames several core files (e.g., mode-php.js becomes mode-phhp.js).
    • Line Highlighting: The MAX_TOKEN_COUNT is increased (from 2000 to 4000 or 5000) to allow for longer single-line highlights, though very large values may cause lag.
  5. Customize PDF.js viewer options

    main

    To customize the PDF.js viewer in Kodbox, you can inject custom options by modifying pdfjs/web/viewer.js. The viewer looks for a window.pdfOptions object. If present, these options will be merged with the default userOptions.

    // In pdfjs/web/viewer.js
    var userOptions = Object.create(null);
    userOptions = window.pdfOptions || userOptions;
  6. Configure WebDAV for manual client mounting

    main

    When manually mounting Kodbox via a WebDAV client, if your username contains Chinese characters, you must encode the username using the format $$ followed by the URL-encoded username to ensure successful login.

    Example: If the username is 张三, use $$%E5%BC%A0%E4%B8%89.

  7. Configure Nginx rewrite rules for kodbox

    main

    Depending on where you install kodbox, you must configure Nginx rewrite rules to ensure correct routing.

    If installed in the Root Directory, use:

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    If installed in a Subdirectory (e.g., /kodbox/), use:

    location /kodbox/ {
        try_files $uri $uri/ /kodbox/index.php?$query_string;
    }
    # Installed in the Root Directory
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    # Installed in a Subdirectory (e.g., /kodbox/)
    location /kodbox/ {
        try_files $uri $uri/ /kodbox/index.php?$query_string;
    }
  8. Install kodbox from source

    main

    To install kodbox by cloning the repository directly, use the following commands. Ensure you set the appropriate permissions for the web server to access the files.

    git clone https://github.com/kalcaddle/kodbox.git
    chmod -Rf 777 ./kodbox/*
  9. Install Kodbox via download package

    main

    To install Kodbox using the pre-packaged ZIP archive, download the main branch archive, unzip it, and set the directory permissions.

    wget https://github.com/kalcaddle/kodbox/archive/refs/heads/main.zip
    unzip main.zip
    chmod -Rf 777 ./*
  10. Use WebDAV for file synchronization and third-party apps

    main

    The WebDAV plugin provides compatibility for several synchronization and note-taking tools. You can use Kodbox as a backend for:

    • File Sync: goodSync (supports direct binding and network drive mounting; supports two-way sync) and FreeFileSync (supports direct binding and network drive mounting; supports two-way sync).
    • Note-taking: joplin (syncing notes).
    • Reference Management: Zotero.
    • Bookmarks: floccus.
    • Other: Noteshelf and super-productivity (via browser-based client compatibility).