Loading .gitlab-ci.yml +3 −3 Original line number Diff line number Diff line Loading @@ -38,9 +38,9 @@ Build Images: - scripts/* variables: BUILD_ARGS: >- wp_version=$WORDPRESS_VERSION php_version=$PHP_VERSION nginx_version=$NGINX_VERSION WORDPRESS_VERSION:wp_version PHP_VERSION:php_version NGINX_VERSION:nginx_version parallel: matrix: - TARGET: [nginx, fastcgi] Loading .pre-commit-config.yaml +1 −3 Original line number Diff line number Diff line Loading @@ -63,7 +63,6 @@ repos: rev: 5.12.0 hooks: - id: isort args: ["--settings=.lint.cfg"] stages: [commit, manual] - repo: https://github.com/asottile/add-trailing-comma Loading @@ -79,7 +78,6 @@ repos: rev: 3.1.0 hooks: - id: flakeheaven args: ["--config=.lint.cfg"] additional_dependencies: - flake8-bugbear - flake8-docstrings Loading @@ -92,7 +90,7 @@ repos: rev: v1.0.1 hooks: - id: mypy args: ["--config-file=.lint.cfg", "--python-version=3.9"] args: ["--python-version=3.9"] additional_dependencies: - types-requests - behave-utils ~=0.3.2 data/composer.json +1 −7 Original line number Diff line number Diff line { "type": "project", "license": "MPL-2.0", "repositories": [ { "type": "gitlab", "url": "https://code.kodo.org.uk/singing-chimes.co.uk/s3-uploads" } ], "require": { "humanmade/s3-uploads": "dev-develop", "humanmade/s3-uploads": "3.0.7", "ayesh/wordpress-password-hash": "2.*" }, "config": { Loading doc/configuration.md +35 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,41 @@ An array of "key=value" strings declaring [PHP directives][]. > arguments preceded by the '-d' flag: > `-d upload_max_filesize=20M -d post_max_size=20M` ### S3_MEDIA_ENDPOINT **Type**: string\ **Required**: if using S3 for uploaded media\ **Format**: URL\ **Example**: "https://s3.example.com/bucket/path"\ A URL to an S3 or S3-like API, including any region and bucket names, and any path in the bucket to append. ### S3_MEDIA_KEY **Type**: string\ **Required**: if using S3 for uploaded media\ An access key allowing write access to the S3 endpoint given by [**S3_MEDIA_ENDPOINT**](#s3_media_endpoint). ### S3_MEDIA_SECRET **Type**: string\ **Required**: if using S3 for uploaded media\ The secret paired with the access key given in [**S3_MEDIA_KEY**](#s3_media_key). ### S3_MEDIA_REWRITE_URL **Type**: string\ **Required**: no\ **Format**: URL\ **Example**: "https://my.domain.example.org/"\ A base URL for viewers to access uploaded media. This allows caching proxies, such as CDNs, to be used for accessing files. ### SANDBOX_MODE **Type**: flag\ Loading plugins/docker-integration.php +33 −23 Original line number Diff line number Diff line <?php /** * Copyright 2019-2021, 2023 Dominik Sekotill <dom.sekotill@kodo.org.uk> * Copyright 2019-2021, 2023-2024 Dominik Sekotill <dom.sekotill@kodo.org.uk> * * Plugin Name: Docker Image Integration * Plugin URI: https://code.kodo.org.uk/singing-chimes.co.uk/wordpress/tree/master/plugins Loading @@ -12,25 +12,6 @@ */ // Media URL Fix add_action( 'plugins_loaded', function() { add_filter( 'upload_dir', function( $paths ) { $baseurl = parse_url( $paths['baseurl'] ); $fullurl = parse_url( $paths['url'] ); $subdir = $paths['subdir']; $baseurl['path'] = '/media'; $fullurl['path'] = '/media' . ($subdir ? "/{$subdir}" : ''); $paths['baseurl'] = unparse_url( $baseurl ); $paths['url'] = unparse_url( $fullurl ); return $paths; }); }); if ( !defined( 'SANDBOX_MODE' ) ): // Block File Modification Loading Loading @@ -77,18 +58,17 @@ endif; // S3-Uploads Integration if ( defined( 'S3_UPLOADS_ENDPOINT_URL' ) || defined( 'WP_CLI' ) ): if ( defined( 'S3_MEDIA_ENDPOINT' ) || defined( 'WP_CLI' ) ): add_filter( 's3_uploads_s3_client_params', function ( $params ) { $params['endpoint'] = S3_UPLOADS_ENDPOINT_URL; $params['endpoint'] = S3_MEDIA_ENDPOINT; $params['bucket_endpoint'] = true; $params['disable_host_prefix_injection'] = true; $params['use_path_style_endpoint'] = true; $params['debug'] = WP_DEBUG && WP_DEBUG_DISPLAY; $params['region'] = ''; return $params; } ); Loading @@ -96,6 +76,36 @@ add_filter( endif; // Media URL Fix add_action( 'plugins_loaded', function() { add_filter( 'upload_dir', function( array $paths ) : array { $baseurl = parse_url( $paths['baseurl'] ); $fullurl = parse_url( $paths['url'] ); $subdir = $paths['subdir'] ?? ''; if ( defined( 'S3_MEDIA_ENDPOINT' ) ) { $s3 = S3_Uploads\Plugin::get_instance(); $basedir = str_replace( $paths['basedir'], $s3->get_s3_path(), $paths['basedir'] ); $paths['basedir'] = $basedir; $paths['path'] = "{$basedir}{$subdir}"; $baseurl = parse_url( $s3->get_s3_url() ); $fullurl = $baseurl; $fullurl['path'] = ($fullurl['path'] ?? '') . $subdir; } else { $baseurl['path'] = '/media'; $fullurl['path'] = '/media' . $subdir; } $paths['baseurl'] = unparse_url( $baseurl ); $paths['url'] = unparse_url( $fullurl ); return $paths; }); }); // Functions function unparse_url( array $parts ) { Loading Loading
.gitlab-ci.yml +3 −3 Original line number Diff line number Diff line Loading @@ -38,9 +38,9 @@ Build Images: - scripts/* variables: BUILD_ARGS: >- wp_version=$WORDPRESS_VERSION php_version=$PHP_VERSION nginx_version=$NGINX_VERSION WORDPRESS_VERSION:wp_version PHP_VERSION:php_version NGINX_VERSION:nginx_version parallel: matrix: - TARGET: [nginx, fastcgi] Loading
.pre-commit-config.yaml +1 −3 Original line number Diff line number Diff line Loading @@ -63,7 +63,6 @@ repos: rev: 5.12.0 hooks: - id: isort args: ["--settings=.lint.cfg"] stages: [commit, manual] - repo: https://github.com/asottile/add-trailing-comma Loading @@ -79,7 +78,6 @@ repos: rev: 3.1.0 hooks: - id: flakeheaven args: ["--config=.lint.cfg"] additional_dependencies: - flake8-bugbear - flake8-docstrings Loading @@ -92,7 +90,7 @@ repos: rev: v1.0.1 hooks: - id: mypy args: ["--config-file=.lint.cfg", "--python-version=3.9"] args: ["--python-version=3.9"] additional_dependencies: - types-requests - behave-utils ~=0.3.2
data/composer.json +1 −7 Original line number Diff line number Diff line { "type": "project", "license": "MPL-2.0", "repositories": [ { "type": "gitlab", "url": "https://code.kodo.org.uk/singing-chimes.co.uk/s3-uploads" } ], "require": { "humanmade/s3-uploads": "dev-develop", "humanmade/s3-uploads": "3.0.7", "ayesh/wordpress-password-hash": "2.*" }, "config": { Loading
doc/configuration.md +35 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,41 @@ An array of "key=value" strings declaring [PHP directives][]. > arguments preceded by the '-d' flag: > `-d upload_max_filesize=20M -d post_max_size=20M` ### S3_MEDIA_ENDPOINT **Type**: string\ **Required**: if using S3 for uploaded media\ **Format**: URL\ **Example**: "https://s3.example.com/bucket/path"\ A URL to an S3 or S3-like API, including any region and bucket names, and any path in the bucket to append. ### S3_MEDIA_KEY **Type**: string\ **Required**: if using S3 for uploaded media\ An access key allowing write access to the S3 endpoint given by [**S3_MEDIA_ENDPOINT**](#s3_media_endpoint). ### S3_MEDIA_SECRET **Type**: string\ **Required**: if using S3 for uploaded media\ The secret paired with the access key given in [**S3_MEDIA_KEY**](#s3_media_key). ### S3_MEDIA_REWRITE_URL **Type**: string\ **Required**: no\ **Format**: URL\ **Example**: "https://my.domain.example.org/"\ A base URL for viewers to access uploaded media. This allows caching proxies, such as CDNs, to be used for accessing files. ### SANDBOX_MODE **Type**: flag\ Loading
plugins/docker-integration.php +33 −23 Original line number Diff line number Diff line <?php /** * Copyright 2019-2021, 2023 Dominik Sekotill <dom.sekotill@kodo.org.uk> * Copyright 2019-2021, 2023-2024 Dominik Sekotill <dom.sekotill@kodo.org.uk> * * Plugin Name: Docker Image Integration * Plugin URI: https://code.kodo.org.uk/singing-chimes.co.uk/wordpress/tree/master/plugins Loading @@ -12,25 +12,6 @@ */ // Media URL Fix add_action( 'plugins_loaded', function() { add_filter( 'upload_dir', function( $paths ) { $baseurl = parse_url( $paths['baseurl'] ); $fullurl = parse_url( $paths['url'] ); $subdir = $paths['subdir']; $baseurl['path'] = '/media'; $fullurl['path'] = '/media' . ($subdir ? "/{$subdir}" : ''); $paths['baseurl'] = unparse_url( $baseurl ); $paths['url'] = unparse_url( $fullurl ); return $paths; }); }); if ( !defined( 'SANDBOX_MODE' ) ): // Block File Modification Loading Loading @@ -77,18 +58,17 @@ endif; // S3-Uploads Integration if ( defined( 'S3_UPLOADS_ENDPOINT_URL' ) || defined( 'WP_CLI' ) ): if ( defined( 'S3_MEDIA_ENDPOINT' ) || defined( 'WP_CLI' ) ): add_filter( 's3_uploads_s3_client_params', function ( $params ) { $params['endpoint'] = S3_UPLOADS_ENDPOINT_URL; $params['endpoint'] = S3_MEDIA_ENDPOINT; $params['bucket_endpoint'] = true; $params['disable_host_prefix_injection'] = true; $params['use_path_style_endpoint'] = true; $params['debug'] = WP_DEBUG && WP_DEBUG_DISPLAY; $params['region'] = ''; return $params; } ); Loading @@ -96,6 +76,36 @@ add_filter( endif; // Media URL Fix add_action( 'plugins_loaded', function() { add_filter( 'upload_dir', function( array $paths ) : array { $baseurl = parse_url( $paths['baseurl'] ); $fullurl = parse_url( $paths['url'] ); $subdir = $paths['subdir'] ?? ''; if ( defined( 'S3_MEDIA_ENDPOINT' ) ) { $s3 = S3_Uploads\Plugin::get_instance(); $basedir = str_replace( $paths['basedir'], $s3->get_s3_path(), $paths['basedir'] ); $paths['basedir'] = $basedir; $paths['path'] = "{$basedir}{$subdir}"; $baseurl = parse_url( $s3->get_s3_url() ); $fullurl = $baseurl; $fullurl['path'] = ($fullurl['path'] ?? '') . $subdir; } else { $baseurl['path'] = '/media'; $fullurl['path'] = '/media' . $subdir; } $paths['baseurl'] = unparse_url( $baseurl ); $paths['url'] = unparse_url( $fullurl ); return $paths; }); }); // Functions function unparse_url( array $parts ) { Loading