# CLAUDE.md

**IMPORTANT**: This file contains project-specific instructions. Always read the global environment instructions first: `/var/www/html/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.4 website (biztonsagosinternet.hu) built with Composer and deployed using Capistrano. The project uses a customized Bootstrap Barrio theme and includes several custom modules for site-specific functionality.

## Development Commands

### Composer & Dependencies

```bash
# Install/update dependencies
composer install
composer update

# The composer.phar is included in the repository
php composer.phar install
```

### Drush Commands

Drush is located in `vendor/bin/drush` and must be run from the project root with `--root` parameter pointing to the `web/` directory:

```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

# Database updates
./vendor/bin/drush --root=web updatedb -y

# Import environment-specific config (dev/staging/prod)
./vendor/bin/drush --root=web config-split:import config_dev -y

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

# Run colorbox cleanup (custom command)
./vendor/bin/drush --root=web colorbox-dompurify
```

### Theme Development

The custom theme is located at `web/themes/custom/gyermekmento/` and uses Gulp for building assets:

```bash
cd web/themes/custom/gyermekmento/
npm install
gulp  # or specific gulp tasks
```

The theme is based on Bootstrap Barrio 5.x and includes:
- SASS/SCSS compilation with Compass
- Bootstrap 5.3.2 integration
- Custom JavaScript and CSS assets

## Architecture

### Drupal Structure

- **Web root**: `web/` (Drupal core and contributed modules)
- **Custom modules**: `web/modules/custom/`
  - `biztonsagosinter_custom_hooks` - Site-specific hook implementations
  - `media_image_detailed_description` - Extended media functionality
- **Custom theme**: `web/themes/custom/gyermekmento/` (Bootstrap Barrio subtheme)
- **Configuration**: `config/sync/` (main config directory for all environments)
- **Private files**: `private_files/`
- **Translations**: `translations/` (Hungarian .po files)

### Configuration Management

This project uses **Config Split** for environment-specific configurations:

- `config/sync/` - Base configuration (version controlled)
- `config_dev/` - Development-only configuration
- `config_stag/` - Staging-only configuration
- `config_prod/` - Production-only configuration (includes backup schedules)

When importing config, always import the environment-specific split after the base config.

### Patches

The project applies several patches to contrib modules (see `composer.json` "extra" > "patches" section). Notable patches:

- Colorbox remote video support (custom patch - do not replace with upstream)
- Drush site-local path detection
- Various Drupal core and contrib fixes

## Deployment

### Capistrano Deployment

Deployment is managed via Capistrano (Ruby). Configuration files:

- `Capfile` - Main Capistrano entry point
- `config/deploy.rb` - Global deployment settings
- `config/deploy/*.rb` - Environment-specific settings (dev, staging, production)
- `lib/capistrano/tasks/drupal_deploy.rake` - Custom Drupal deployment tasks

### Environments

1. **Development** (master branch)
   - URL: https://d10.biztonsagosinternet.node8.macroweb.hu/
   - Deploy: `bundle exec cap dev deploy`
   - Auto-deploys from master branch

2. **Staging** (live branch)
   - URL: https://stag.biztonsagosinternet.hu/
   - Deploy: `bundle exec cap staging deploy`
   - Manual deployment

3. **Production** (live branch)
   - URL: https://www.biztonsagosinternet.hu/
   - Server: new.biztonsagosinternet.hu
   - PHP: 8.1 (configured in production.rb)
   - Deploy: `bundle exec cap production deploy`
   - Manual deployment
   - Includes automatic database backup before deployment

### Deployment Process

The automated deployment flow (defined in `lib/capistrano/tasks/drupal_deploy.rake`):

1. Site goes into maintenance mode
2. Code is deployed to a new release directory
3. Composer dependencies are installed
4. Database updates run (`drush updatedb`)
5. Configuration is imported (`drush config:import`)
6. Environment-specific config split is imported
7. Translations are imported from `translations/` directory
8. Caches are cleared
9. Site exits maintenance mode
10. Symlinks are updated to point to new release
11. Old releases are cleaned up (keeps 4 releases)

### GitLab CI/CD

The `.gitlab-ci.yml` file defines the CI/CD pipeline:

- Automatic deployment to dev from master branch
- Manual deployment to staging/production from live branch
- Uses Ruby Bundler for Capistrano dependencies

## Key Drupal Modules

The site uses numerous contributed modules. Key modules include:

- **Content**: webform, entity_browser, entity_embed, inline_entity_form
- **Media**: dropzonejs, colorbox, media_entity_download
- **Admin**: admin_toolbar, masquerade, config_split, drd_agent
- **Performance**: backup_migrate (production backups configured)
- **Security**: antibot, captcha, recaptcha, seckit
- **SEO**: metatag, pathauto, redirect, xmlsitemap

## Working with Configuration

When making configuration changes:

1. Make changes in the Drupal UI or via Drush
2. Export config: `./vendor/bin/drush --root=web config:export -y`
3. Commit the changes in `config/sync/`
4. For environment-specific config, use Config Split UI or place files in appropriate `config_*` directories
5. On other environments, import with: `./vendor/bin/drush --root=web config:import -y`

## Translations

Hungarian translations are managed via .po files in the `translations/` directory. After modifying translations:

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

# Update translations
./vendor/bin/drush --root=web locale:update
```
