# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is a Drupal 10.5 website for MÁL (Magyar Állattenyésztők Lapja - Hungarian Animal Breeders Journal) built using the macroweb-drupal-skeleton template. The site uses Hungarian locale (hu) as the primary language and includes e-commerce functionality via Drupal Commerce with Barion payment integration.

## Development Commands

### Composer Operations
```bash
# Install dependencies
composer install --no-progress --no-interaction --prefer-dist

# Update dependencies
composer update

# Apply patches (automatically applied during composer install)
composer install
```

### Drush Commands
Drush is located at `vendor/bin/drush`. Run commands from the project root:

```bash
# Clear cache
vendor/bin/drush --root=web cache:rebuild

# Import configuration
vendor/bin/drush --root=web config:import -y

# Export configuration
vendor/bin/drush --root=web config:export -y

# Update database after code changes
vendor/bin/drush --root=web updatedb -y --cache-clear

# Import translations
vendor/bin/drush --root=web locale:import:all translations --override=all --type=customized --yes

# Check for translation updates
vendor/bin/drush --root=web locale:check
vendor/bin/drush --root=web locale:update

# Enable maintenance mode
vendor/bin/drush --root=web state:set system.maintenance_mode TRUE

# Disable maintenance mode
vendor/bin/drush --root=web state:set system.maintenance_mode FALSE

# Import environment-specific config split
vendor/bin/drush --root=web config-split:import config_[env] -y

# Custom colorbox command
vendor/bin/drush --root=web colorbox-dompurify

# Create database backup (using backup_migrate module)
vendor/bin/drush --root=web eval 'backup_migrate_perform_backup("default_db", "private_files", []);'
```

## Directory Structure

- **web/** - Drupal webroot
  - **modules/custom/** - Custom modules for this project
    - `mal_custom_hooks/` - Custom hook implementations
    - `mal_purchase_prices_block/` - Purchase prices block functionality
    - `mal_premium/` - Premium content features
    - `exchange_rate/` - Currency exchange rate functionality
    - `tab_panels/` - Tab panel components
    - `login_register_block/` - Login/registration block
  - **themes/custom/mal/** - Custom theme based on stable9
    - `templates/` - Twig templates
    - `scss/` - SASS stylesheets
    - `js/` - JavaScript files
- **config/** - Configuration management
  - **sync/** - Shared configuration exported via config:export
  - **deploy/** - Deployment-specific configurations
- **patches/** - Local patches applied via composer-patches
- **translations/** - Custom translation (.po) files
- **drush/** - Drush configuration and custom commands
  - **Commands/** - Custom Drush commands
  - **sites/** - Site-specific drush configuration
- **lib/capistrano/tasks/** - Capistrano deployment tasks
- **private_files/** - Private file storage (outside webroot)
- **vendor/** - Composer dependencies

## Configuration Management

This project uses **config_split** for environment-specific configurations:
- Base config in `config/sync/`
- Environment-specific splits named `config_[env]` where env is first 4 chars of stage (demo, stag, prod)
- Import config splits during deployment: `drush config-split:import config_demo -y`

System UUID and language UUIDs must match between environments - these are set during deployment from `config/sync/system.site.yml` and `config/sync/language.entity.*.yml`.

## Deployment

Deployments use **Capistrano** (Ruby-based deployment tool).

### Deployment Stages
- **demo** - Demo environment at https://demo.xn--ml-mia.hu/ (auto-deploys from master branch)
- **production** - Production at https://xn--ml-mia.hu/ (manual deployment from live branch)

### Deploy Commands
```bash
# Deploy to demo (auto-triggered by CI on master push)
bundle exec cap demo deploy

# Deploy to production (manual)
bundle exec cap production deploy

# Set up a new Drupal instance
bundle exec cap [stage] drupal:site:setup
```

### Deployment Process (Automatic)
1. Site put into maintenance mode
2. Code updated via Git
3. Dependencies installed via `composer install`
4. Database updates run via `drush updatedb`
5. Configuration imported via `drush config:import`
6. Environment-specific config split imported
7. Translations imported from `translations/` directory
8. Custom colorbox-dompurify command executed
9. Cache cleared
10. Site taken out of maintenance mode

Linked files (shared across releases):
- `web/sites/default/settings.php`
- `web/sites/default/settings.local.php`
- `web/.htaccess`

## Custom Patches

The project maintains several **custom patches** in the `patches/` directory that must not be replaced with upstream versions:

### Critical Custom Patches (DO NOT REPLACE)
- `colorbox-remote-video-support-3021913-49-CUSTOMIZED.pach` - Custom modifications to colorbox remote video integration (see Atrium case #37815)
- `simpleads-atrium_case_37239_191597-and-atrium_case_39029_195130-and-atrium_case_39029_195214.patch` - Custom SimpleAds fixes for specific issues
- `exif_orientation-prevent-double-rotation.patch` - Custom fix to prevent double rotation and correct GD rotation direction
- `commerce_barion_payment-custom_patches.patch` - Custom patches for Barion payment integration

### Standard Patches
Other patches can be updated when newer versions are available from drupal.org.

## Key Drupal Modules

### Commerce
- `commerce_shipping` - Shipping functionality
- `commerce_recurring` - Recurring payments/subscriptions (1.x-dev)
- `commerce_barion_payment` - Barion payment gateway (v2.0.0, custom patched)
- `commerce_cart_redirection` - Cart redirection behavior
- `commerce_combine_carts` - Merge carts on login
- `commerce_license` - Digital license management

### Content & Media
- `entity_embed` - Embed entities in WYSIWYG
- `entity_browser` - Entity browsing interface
- `inline_entity_form` - Inline entity forms
- `media_entity_download` - Download button for media
- `dropzonejs` - Drag & drop file uploads
- `colorbox` - Lightbox functionality

### Development
- `devel` - Development tools (dev dependency only)
- `admin_toolbar` - Enhanced admin toolbar
- `masquerade` - Switch users
- `drd_agent` - Remote site management

### Site Building
- `views_add_button` - Add buttons to Views
- `draggableviews` - Drag and drop in Views
- `views_infinite_scroll` - Infinite scrolling
- `search_api` + `search_api_solr` - Search functionality
- `pathauto` - Automatic URL aliases

## Theme Architecture

The custom theme **mal** extends stable9 base theme and uses:
- SASS for styling (compile `scss/` to `css/`)
- Custom Twig templates in `templates/`
- Multiple custom regions including:
  - `hero` - Hero section
  - `simpleadsfirst`, `simpleadssecond` - Advertisement regions
  - `articlesfirst`, `frontarticlessecond` - Article listings
  - `frontcurrentissue` - Current issue display
  - `mobile_menu` - Mobile navigation

## Important Notes

### Drush Path Detection
The project includes a custom patch for Drush (`drush-site-local-path-detection-v6.patch`) to fix site-local path detection issues in certain environments. This is critical for proper Drush operation.

### File References
When referencing code locations, use the format `file_path:line_number` (e.g., `web/modules/custom/mal_custom_hooks/mal_custom_hooks.module:45`).

### Hungarian Locale
- Site is configured for Hungarian (hu) language
- Translation files in `translations/*.po` are imported during deployment
- Account names use Hungarian conventions (e.g., default admin: "csopadmin")

### Private Files
Private files are stored in `private_files/` directory outside the webroot for security.

### Database Backups
A demo database snapshot exists at `mal_demo.sql` in the repository root (29MB).

## Git Workflow

- **master** branch - Development branch, auto-deploys to demo environment
- **live** branch - Production branch, manual deployment to production
- GitLab CI/CD configured in `.gitlab-ci.yml`
- Capistrano deployments triggered from CI or manually

## External Dependencies

- **Barion Payment Gateway** - Hungarian payment processor integration
- **Solr** - Search API backend (search_api_solr module)
- **Sendy** - Email newsletter integration (custom patched module)
- **Google Charts** - Chart visualization library
- **Colorbox/Slick** - Frontend libraries for galleries and carousels
