-
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #453 from hydephp/update-build-hooks
Refactor auxiliary build services and tasks
- Loading branch information
Showing
16 changed files
with
164 additions
and
270 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
28 changes: 28 additions & 0 deletions
28
packages/framework/src/Actions/PostBuildTasks/GenerateRssFeed.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Actions\PostBuildTasks; | ||
|
||
use Hyde\Framework\Contracts\AbstractBuildTask; | ||
use Hyde\Framework\Hyde; | ||
use Hyde\Framework\Services\RssFeedService; | ||
|
||
class GenerateRssFeed extends AbstractBuildTask | ||
{ | ||
public static string $description = 'Generating RSS feed'; | ||
|
||
public function run(): void | ||
{ | ||
file_put_contents( | ||
Hyde::getSiteOutputPath(RssFeedService::getDefaultOutputFilename()), | ||
RssFeedService::generateFeed() | ||
); | ||
} | ||
|
||
public function then(): void | ||
{ | ||
$this->writeln(sprintf("\n > Created <info>%s</info> in %s", | ||
RssFeedService::getDefaultOutputFilename(), | ||
$this->getExecutionTime() | ||
)); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/framework/src/Actions/PostBuildTasks/GenerateSearch.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Actions\PostBuildTasks; | ||
|
||
use Hyde\Framework\Actions\GeneratesDocumentationSearchIndexFile; | ||
use Hyde\Framework\Concerns\InteractsWithDirectories; | ||
use Hyde\Framework\Contracts\AbstractBuildTask; | ||
use Hyde\Framework\Hyde; | ||
use Hyde\Framework\Models\Pages\DocumentationPage; | ||
use Hyde\Framework\Services\DiscoveryService; | ||
|
||
class GenerateSearch extends AbstractBuildTask | ||
{ | ||
use InteractsWithDirectories; | ||
|
||
public static string $description = 'Generating search index'; | ||
|
||
public function run(): void | ||
{ | ||
$expected = $this->guesstimateGenerationTime(); | ||
if ($expected > 1) { | ||
$this->line("<fg=gray> > This will take an estimated $expected seconds. Terminal may seem non-responsive.</>"); | ||
} | ||
|
||
GeneratesDocumentationSearchIndexFile::run(); | ||
|
||
if (config('docs.create_search_page', true)) { | ||
$outputDirectory = Hyde::pathToRelative(Hyde::getSiteOutputPath(DocumentationPage::getOutputDirectory())); | ||
$this->needsDirectory(Hyde::path($outputDirectory)); | ||
file_put_contents( | ||
Hyde::path($outputDirectory.'/search.html'), | ||
view('hyde::pages.documentation-search')->render() | ||
); | ||
$this->write(sprintf( | ||
"\n > Created <info>_site/%s/search.html</info>", | ||
config('docs.output_directory', 'docs') | ||
)); | ||
} | ||
} | ||
|
||
public function then(): void | ||
{ | ||
$this->writeln(sprintf("\n > Created <info>%s</info> in %s", | ||
GeneratesDocumentationSearchIndexFile::$filePath, | ||
$this->getExecutionTime() | ||
)); | ||
} | ||
|
||
/** @internal Estimated processing time per file in ms */ | ||
public static float $guesstimationFactor = 52.5; | ||
|
||
protected function guesstimateGenerationTime(): int|float | ||
{ | ||
return (int) round(count(DiscoveryService::getDocumentationPageFiles()) * static::$guesstimationFactor) / 1000; | ||
} | ||
} |
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
Oops, something went wrong.