Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ vendor/*
.sass-cache

# Grav Specific
backup/*
!backup/.*
cache/*
!cache/.*
assets/*
!assets/.*
logs/*
!logs/.*
images/*
!images/.*
user/accounts/*
!user/accounts/.*
user/data/*
!user/data/.*
run/backup/*
!run/backup/.*
run/cache/*
!run/cache/.*
run/assets/*
!run/assets/.*
run/logs/*
!run/logs/.*
run/images/*
!run/images/.*
run/accounts/*
!run/accounts/.*
run/data/*
!run/data/.*
user/plugins/*
!user/plugins/.*
user/themes/*
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 9 additions & 4 deletions system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
$path = rtrim(getenv('GRAV_USER_PATH') ?: 'user', DS);
define('GRAV_USER_PATH', $path);
}
// Absolute or relative path to cache folder. Defaults to GRAV_ROOT/cache
if (!defined('GRAV_RUN_PATH')) {
$path = rtrim(getenv('GRAV_CACHE_PATH') ?: 'run', DS);
define('GRAV_RUN_PATH', $path);
}
// Absolute or relative path to system folder. Defaults to GRAV_ROOT/system
// If system folder is outside of webroot, see https://github.com/getgrav/grav/issues/3297#issuecomment-810294972
if (!defined('GRAV_SYSTEM_PATH')) {
Expand All @@ -46,22 +51,22 @@
}
// Absolute or relative path to cache folder. Defaults to GRAV_ROOT/cache
if (!defined('GRAV_CACHE_PATH')) {
$path = rtrim(getenv('GRAV_CACHE_PATH') ?: 'cache', DS);
$path = rtrim(getenv('GRAV_CACHE_PATH') ?: GRAV_RUN_PATH . '/cache', DS);
define('GRAV_CACHE_PATH', $path);
}
// Absolute or relative path to logs folder. Defaults to GRAV_ROOT/logs
if (!defined('GRAV_LOG_PATH')) {
$path = rtrim(getenv('GRAV_LOG_PATH') ?: 'logs', DS);
$path = rtrim(getenv('GRAV_LOG_PATH') ?: GRAV_RUN_PATH . '/logs', DS);
define('GRAV_LOG_PATH', $path);
}
// Absolute or relative path to tmp folder. Defaults to GRAV_ROOT/tmp
if (!defined('GRAV_TMP_PATH')) {
$path = rtrim(getenv('GRAV_TMP_PATH') ?: 'tmp', DS);
$path = rtrim(getenv('GRAV_TMP_PATH') ?: GRAV_RUN_PATH . '/tmp', DS);
define('GRAV_TMP_PATH', $path);
}
// Absolute or relative path to backup folder. Defaults to GRAV_ROOT/backup
if (!defined('GRAV_BACKUP_PATH')) {
$path = rtrim(getenv('GRAV_BACKUP_PATH') ?: 'backup', DS);
$path = rtrim(getenv('GRAV_BACKUP_PATH') ?: GRAV_RUN_PATH . '/backup', DS);
define('GRAV_BACKUP_PATH', $path);
}
unset($path);
Expand Down
28 changes: 17 additions & 11 deletions system/src/Grav/Common/Config/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class Setup extends Data

/** @var array */
protected $streams = [
'run' => [
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => [], // Set in constructor
]
],
'user' => [
'type' => 'ReadOnlyStream',
'force' => true,
Expand All @@ -57,29 +64,29 @@ class Setup extends Data
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => [], // Set in constructor
'images' => ['images']
'' => ['run://cache'], // Set in constructor
'images' => ['run://images']
]
],
'log' => [
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => [] // Set in constructor
'' => ['run://logs']
]
],
'tmp' => [
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => [] // Set in constructor
'' => ['run://tmp'] // Set in constructor
]
],
'backup' => [
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => [] // Set in constructor
'' => ['run://backup']
]
],
'environment' => [
Expand All @@ -94,8 +101,9 @@ class Setup extends Data
],
'asset' => [
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => ['assets'],
'' => ['run://assets'],
]
],
'blueprints' => [
Expand Down Expand Up @@ -150,13 +158,13 @@ class Setup extends Data
'type' => 'Stream',
'force' => true,
'prefixes' => [
'' => ['user://data']
'' => ['run://data']
]
],
'account' => [
'type' => 'ReadOnlyStream',
'prefixes' => [
'' => ['user://accounts']
'' => ['run://accounts']
]
],
];
Expand All @@ -170,10 +178,8 @@ public function __construct($container)
$abs = str_starts_with(GRAV_SYSTEM_PATH, '/');
$this->streams['system']['prefixes'][''] = $abs ? ['system', GRAV_SYSTEM_PATH] : ['system'];
$this->streams['user']['prefixes'][''] = [GRAV_USER_PATH];
$this->streams['cache']['prefixes'][''] = [GRAV_CACHE_PATH];
$this->streams['log']['prefixes'][''] = [GRAV_LOG_PATH];
$this->streams['run']['prefixes'][''] = [GRAV_RUN_PATH];
$this->streams['tmp']['prefixes'][''] = [GRAV_TMP_PATH];
$this->streams['backup']['prefixes'][''] = [GRAV_BACKUP_PATH];

// If environment is not set, look for the environment variable and then the constant.
$environment = static::$environment ??
Expand Down
1 change: 1 addition & 0 deletions system/src/Grav/Console/Cli/SandboxCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SandboxCommand extends GravCommand
{
/** @var array */
protected $directories = [
'/run',
'/assets',
'/backup',
'/cache',
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Grav/Common/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,12 @@ public function testPipeline(): void
$this->assets->add('test.css', null, true);
$this->assets->setCssPipeline(true);
$css = $this->assets->css();
self::assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
self::assertRegExp('#<link href=\"\/run\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);

//Add a core Grav CSS file, which is found. Pipeline will now return a file
$this->assets->add('/system/assets/debugger/phpdebugbar', null, true);
$css = $this->assets->css();
self::assertRegExp('#<link href=\"\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
self::assertRegExp('#<link href=\"\/run\/assets\/(.*).css\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
}

public function testPipelineWithTimestamp(): void
Expand All @@ -582,7 +582,7 @@ public function testPipelineWithTimestamp(): void
//Add a core Grav CSS file, which is found. Pipeline will now return a file
$this->assets->add('/system/assets/debugger.css', null, true);
$css = $this->assets->css();
self::assertRegExp('#<link href=\"\/assets\/(.*).css\?foo\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
self::assertRegExp('#<link href=\"\/run\/assets\/(.*).css\?foo\" type=\"text\/css\" rel=\"stylesheet\">#', $css);
}

public function testInline(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Grav/Common/Helpers/ExcerptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ protected function _after(): void
public function testProcessImageHtml(): void
{
self::assertRegexp(
'|<img alt="Sample Image" src="\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?cropZoom=300,300" \/>|',
'|<img alt="Sample Image" src="\/run\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?cropZoom=300,300" \/>|',
Excerpts::processImageHtml('<img src="sample-image.jpg?cropZoom=300,300" alt="Sample Image" />', $this->page)
);
self::assertRegexp(
'|<img alt="Sample Image" class="foo" src="\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?classes=foo" \/>|',
'|<img alt="Sample Image" class="foo" src="\/run\/images\/.*-sample-image.jpe?g\" data-src="sample-image\.jpg\?classes=foo" \/>|',
Excerpts::processImageHtml('<img src="sample-image.jpg?classes=foo" alt="Sample Image" />', $this->page)
);
}
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/Grav/Common/Markdown/ParsedownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testImages(): void
$this->parsedown->text('![](sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
'|<p><img alt="" src="\/run\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
$this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')
);

Expand All @@ -100,11 +100,11 @@ public function testImages(): void
$this->parsedown->text('![](sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
'|<p><img alt="" src="\/run\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
$this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')
);
self::assertRegexp(
'|<p><img alt="" src="\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="\/run\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](/home-cache-image.jpg?cache)')
);
self::assertSame(
Expand All @@ -131,15 +131,15 @@ public function testImagesSubDir(): void
$this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();

self::assertRegexp(
'|<p><img alt="" src="\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="\/subdir\/run\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](/home-cache-image.jpg?cache)')
);
self::assertSame(
'<p><img alt="" src="/subdir/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
$this->parsedown->text('![](sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="\/subdir\/run\/images\/.*-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](cache-image.jpg?cache)')
);
self::assertSame(
Expand All @@ -162,11 +162,11 @@ public function testImagesAbsoluteUrls(): void
$this->parsedown->text('![](sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="http:\/\/testing.dev\/images\/.*-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="http:\/\/testing.dev\/run\/images\/.*-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](cache-image.jpg?cache)')
);
self::assertRegexp(
'|<p><img alt="" src="http:\/\/testing.dev\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="http:\/\/testing.dev\/run\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](/home-cache-image.jpg?cache)')
);
self::assertSame(
Expand All @@ -189,11 +189,11 @@ public function testImagesSubDirAbsoluteUrls(): void
$this->parsedown->text('![](sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/run\/images\/.*-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](cache-image.jpg?cache)')
);
self::assertRegexp(
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/run\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')
);
self::assertSame(
Expand Down Expand Up @@ -384,11 +384,11 @@ public function testRootImages(): void
$this->parsedown->text('![](home-sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="\/run\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](home-cache-image.jpg?cache)')
);
self::assertRegexp(
'|<p><img alt="" src="\/images\/.*-home-cache-image.jpe?g\?foo=1" \/><\/p>|',
'|<p><img alt="" src="\/run\/images\/.*-home-cache-image.jpe?g\?foo=1" \/><\/p>|',
$this->parsedown->text('![](home-cache-image.jpg?cropResize=200,200&foo)')
);
self::assertSame(
Expand Down Expand Up @@ -417,11 +417,11 @@ public function testRootImagesSubDirAbsoluteUrls(): void
$this->parsedown->text('![](sample-image.jpg)')
);
self::assertRegexp(
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/run\/images\/.*-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](cache-image.jpg?cache)')
);
self::assertRegexp(
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
'|<p><img alt="" src="http:\/\/testing.dev\/subdir\/run\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
$this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')
);
self::assertSame(
Expand Down
1 change: 0 additions & 1 deletion user/data/.gitkeep

This file was deleted.