-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from hydephp/v0.15.x-dev
Refactor internal codebase by sorting traits into relevant namespaces
- Loading branch information
Showing
29 changed files
with
220 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Models/HasDynamicTitle.php → src/Concerns/HasDynamicTitle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Models; | ||
namespace Hyde\Framework\Concerns; | ||
|
||
use Hyde\Framework\Hyde; | ||
|
||
|
4 changes: 3 additions & 1 deletion
4
src/Models/HasFeaturedImage.php → src/Concerns/HasFeaturedImage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Models/HasTableOfContents.php → src/Concerns/HasTableOfContents.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Concerns\Internal; | ||
|
||
use function config; | ||
|
||
/** | ||
* AssetManager for the Hyde Facade. | ||
*/ | ||
trait AssetManager | ||
{ | ||
/** | ||
* Return the Tailwind CDN if enabled. | ||
*/ | ||
public static function tailwind(): string|false | ||
{ | ||
return config('hyde.loadTailwindFromCDN') | ||
? 'https://cdn.jsdelivr.net/gh/hydephp/[email protected]/dist/app.css' | ||
: false; | ||
} | ||
|
||
/** | ||
* Return the Hyde stylesheet. | ||
*/ | ||
public static function styles(): string | ||
{ | ||
return 'https://cdn.jsdelivr.net/gh/hydephp/[email protected]/dist/hyde.css'; | ||
} | ||
|
||
/** | ||
* Return the Hyde scripts. | ||
*/ | ||
public static function scripts(): string | ||
{ | ||
return 'https://cdn.jsdelivr.net/gh/hydephp/[email protected]/dist/hyde.js'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Concerns\Internal; | ||
|
||
use function config; | ||
|
||
/** | ||
* General file helpers intended to be used through the Hyde Facade. | ||
*/ | ||
trait FileHelpers | ||
{ | ||
/** | ||
* Get the subdirectory compiled documentation files are stored in. | ||
* | ||
* @return string | ||
*/ | ||
public static function docsDirectory(): string | ||
{ | ||
return trim(config('hyde.docsDirectory', 'docs'), '/\\'); | ||
} | ||
|
||
/** | ||
* Get the path to the frontpage for the documentation. | ||
* | ||
* @return string|false returns false if no frontpage is found | ||
*/ | ||
public static function docsIndexPath(): string|false | ||
{ | ||
if (file_exists(static::path('_docs/index.md'))) { | ||
return static::docsDirectory().'/index.html'; | ||
} | ||
|
||
if (file_exists(static::path('_docs/readme.md'))) { | ||
return static::docsDirectory().'/readme.html'; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Get an absolute file path from a supplied relative path. | ||
* | ||
* The function returns the fully qualified path to your site's root directory. | ||
* | ||
* You may also use the function to generate a fully qualified path to a given file | ||
* relative to the project root directory when supplying the path argument. | ||
* | ||
* @param string $path | ||
* @return string | ||
*/ | ||
public static function path(string $path = ''): string | ||
{ | ||
if (empty($path)) { | ||
return getcwd(); | ||
} | ||
|
||
$path = trim($path, '/\\'); | ||
|
||
return getcwd().DIRECTORY_SEPARATOR.$path; | ||
} | ||
|
||
/** | ||
* Works similarly to the path() function, but returns a file in the Framework package. | ||
* | ||
* @param string $path | ||
* @return string | ||
*/ | ||
public static function vendorPath(string $path = ''): string | ||
{ | ||
return static::path('vendor/hyde/framework/'.trim($path, '/\\')); | ||
} | ||
|
||
/** | ||
* Inject the proper number of `../` before the links in Blade templates. | ||
* | ||
* @param string $destination the route to format | ||
* @param string $current the current route | ||
* @return string | ||
*/ | ||
public static function relativePath(string $destination, string $current = ''): string | ||
{ | ||
$nestCount = substr_count($current, '/'); | ||
$route = ''; | ||
if ($nestCount > 0) { | ||
$route .= str_repeat('../', $nestCount); | ||
} | ||
$route .= $destination; | ||
|
||
return $route; | ||
} | ||
|
||
/** | ||
* Return a qualified URI path, if SITE_URL is set in .env, else return false. | ||
* | ||
* @param string|null $path optional relative path suffix. Omit to return base url. | ||
* @return string|false | ||
*/ | ||
public static function uriPath(?string $path = ''): string|false | ||
{ | ||
if (config('hyde.site_url', false)) { | ||
return rtrim(config('hyde.site_url'), '/').'/'.(trim($path, '/') ?? ''); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Wrapper for the copy function, but allows choosing if files may be overwritten. | ||
* | ||
* @param string $from The source file path. | ||
* @param string $to The destination file path. | ||
* @param bool $force If true, existing files will be overwritten. | ||
* @return bool|int Returns true|false on copy() success|failure, or an error code on failure | ||
*/ | ||
public static function copy(string $from, string $to, bool $force = false): bool|int | ||
{ | ||
if (! file_exists($from)) { | ||
return 404; | ||
} | ||
|
||
if (file_exists($to) && ! $force) { | ||
return 409; | ||
} | ||
|
||
return copy($from, $to); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tions/HasConfigurableMarkdownFeatures.php → ...kdown/HasConfigurableMarkdownFeatures.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...ns/ServiceActions/HasMarkdownFeatures.php → ...Concerns/Markdown/HasMarkdownFeatures.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...rviceActions/HasTorchlightIntegration.php → ...rns/Markdown/HasTorchlightIntegration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Actions/ValidatesExistence.php → src/Concerns/ValidatesExistence.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
src/AbstractPageParser.php → src/Contracts/AbstractPageParser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Actions/ActionContract.php → src/Contracts/ActionContract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Actions; | ||
namespace Hyde\Framework\Contracts; | ||
|
||
/** | ||
* Interface ActionContract. | ||
|
4 changes: 1 addition & 3 deletions
4
src/PageParserContract.php → src/Contracts/PageParserContract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.