This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pibiDAV is a Frappe App that integrates WebDAV functionality with NextCloud Server, enabling automatic file synchronization between Frappe and NextCloud. When files are uploaded to Frappe, they are simultaneously uploaded to NextCloud with automatic tagging and folder organization.
# Build JavaScript and CSS assets for the pibidav app
bench build --app pibidav
# Build in production mode (minified)
bench build --app pibidav --production
# Force rebuild instead of downloading available assets
bench build --app pibidav --force# Run all tests for pibidav app
bench run-tests --app pibidav
# Run tests for specific doctype
bench run-tests --app pibidav --doctype "NextCloud Settings"
# Run tests with coverage
bench run-tests --app pibidav --coverage
# Run UI tests
bench run-ui-tests# Run patches and sync schema after code changes
bench migrate
# Clear cache after making changes
bench clear-cache# Install the app to a site
bench --site site_name install-app pibidav
# Get the app from repository
bench get-app pibidav --branch version-15 https://github.com/pibico/pibidav.git-
Frappe Integration via hooks.py
- Dynamically injects JavaScript into configured doctypes (Customer, Sales Invoice, etc.)
- Hooks into File doctype's after_insert event for automatic NextCloud upload
- Scheduled tasks for daily/weekly backups to NextCloud
- Defines app-level JavaScript bundles and icons
-
Core Module Structure
pibidav/nextcloud.py: Main NextCloud API integration using embedded pyocclientpibidav/custom.py: Custom functions for file operations and folder management- DocTypes for configuration and data storage:
NextCloud Settings: Global configuration and credentialsPibiDAV Addon: Extension data for integrated doctypesFolder Set: Template-based folder structure creation
-
Integration Pattern
- Each integrated doctype gets a parallel "addon" document (prefixed with 'pbc_')
- Addons store NextCloud-specific data (folder paths, references, attachments)
- File uploads trigger automatic NextCloud synchronization with tagging
-
JavaScript Module System
nc_pibidav.js: Main form integration that adds NextCloud buttons to doctypesnc_browser.bundle.js: Vue 3 application for folder browsing and selection- Lazy-loaded components for optimal performance
-
Vue.js Components
NcBrowser.vue: Main file browser with tree navigationTreeNode.vue: Recursive component for folder tree rendering- Uses Vue 3 composition API with TypeScript support
-
API Integration
- Server calls via
frappe.call()for NextCloud operations - Real-time folder browsing and file listing
- Folder creation with template support
- Server calls via
-
Authentication Flow
- SuperUser credentials stored in NextCloud Settings
- Per-user credentials stored in User doctype with "NextCloud User" role
- Automatic credential validation and connection testing
-
File Upload Pipeline
- File uploaded to Frappe → triggers
after_inserthook - Checks if parent doctype is NC-enabled
- Uploads to selected NextCloud folder with automatic tagging
- Creates public share links automatically
- File uploaded to Frappe → triggers
-
Folder Structure Management
- Template-based folder creation using Folder Set doctype
- Recursive folder structure replication in NextCloud
- Automatic folder naming with abbreviations and descriptions
-
SSL Requirements: Both Frappe and NextCloud must have valid SSL certificates (wildcard certificates not supported)
-
Developer Mode: Requires
developer_mode = 1in site_config.json -
Tagging System: Files are automatically tagged based on configured doctype fields (e.g., customer name, tax_id)
-
Backup Integration: Automatic daily/weekly backups to NextCloud with version control
-
Error Handling: Graceful fallback if NextCloud is unreachable - files still save to Frappe
-
Performance: Uses lazy loading and caching for optimal performance with large folder structures