Skip to content

Commit

Permalink
Merge pull request #675 from hydephp/refactor-publications
Browse files Browse the repository at this point in the history
Refactor publications to integrate better with Hyde
  • Loading branch information
caendesilva authored Nov 20, 2022
2 parents 1b49058 + a7c862b commit 8d0eb88
Show file tree
Hide file tree
Showing 33 changed files with 539 additions and 316 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ ij_php_phpdoc_keep_blank_lines = true
ij_php_phpdoc_param_spaces_between_name_and_description = 1
ij_php_phpdoc_param_spaces_between_tag_and_type = 1
ij_php_phpdoc_param_spaces_between_type_and_name = 1
ij_php_phpdoc_use_fqcn = false
ij_php_phpdoc_use_fqcn = true
ij_php_phpdoc_wrap_long_lines = false
ij_php_place_assignment_sign_on_next_line = false
ij_php_place_parens_for_constructor = 0
Expand Down
8 changes: 0 additions & 8 deletions blah/123.md

This file was deleted.

8 changes: 0 additions & 8 deletions blah/aaa.md

This file was deleted.

8 changes: 0 additions & 8 deletions blah/abc.md

This file was deleted.

30 changes: 0 additions & 30 deletions blah/schema.json

This file was deleted.

1 change: 1 addition & 0 deletions config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
Features::bladePages(),
Features::markdownPages(),
Features::documentationPages(),
Features::publicationPages(),
// Features::dataCollections(),

// Frontend Features
Expand Down
1 change: 1 addition & 0 deletions packages/framework/config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
Features::bladePages(),
Features::markdownPages(),
Features::documentationPages(),
Features::publicationPages(),
// Features::dataCollections(),

// Frontend Features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{-- The Post Page Layout --}}
{{-- The Publication Page Layout --}}
@extends('hyde::layouts.app')
@section('content')

<main id="content" class="mx-auto max-w-7xl py-16 px-8">
@include($component, ['publication' => $publication])
{{ $publication }}
</main>

@endsection
205 changes: 0 additions & 205 deletions packages/framework/src/Console/Commands/BuildPublicationsCommand.php

This file was deleted.

3 changes: 3 additions & 0 deletions packages/framework/src/Console/Commands/BuildSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Hyde\Hyde;
use Illuminate\Support\Facades\Config;
use LaravelZero\Framework\Commands\Command;
use function memory_get_peak_usage;

/**
* Hyde Command to run the Build Process.
Expand Down Expand Up @@ -55,6 +56,8 @@ public function handle(): int

$this->printFinishMessage($time_start);

$this->output->writeln('Max memory used: '.memory_get_peak_usage() / 1024 / 1024 .' MB');

return Command::SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Hyde\Console\Commands\Interfaces\CommandHandleInterface;
use Hyde\Framework\Actions\CreatesNewPublicationFile;
use Hyde\HydeHelper;
use Hyde\Framework\Features\Publications\PublicationHelper;
use Illuminate\Support\Str;
use LaravelZero\Framework\Commands\Command;
use Rgasch\Collection\Collection;
Expand All @@ -29,7 +29,7 @@ public function handle(): int
{
$this->title('Creating a new Publication Item!');

$pubTypes = HydeHelper::getPublicationTypes();
$pubTypes = PublicationHelper::getPublicationTypes();
if ($pubTypes->isEmpty()) {
$this->output->error('Unable to locate any publication-types ... did you create any?');

Expand All @@ -44,11 +44,11 @@ public function handle(): int
$offset++;
$this->line(" $offset: $pubType->name");
}
$selected = (int) HydeHelper::askWithValidation($this, 'selected', "Publication type (1-$offset)", ['required', 'integer', "between:1,$offset"]);
$selected = (int) PublicationHelper::askWithValidation($this, 'selected', "Publication type (1-$offset)", ['required', 'integer', "between:1,$offset"]);
$pubType = $pubTypes->{$pubTypes->keys()[$selected - 1]};
}

$mediaFiles = HydeHelper::getMediaForPubType($pubType);
$mediaFiles = PublicationHelper::getMediaForPubType($pubType);
$fieldData = Collection::create();
$this->output->writeln('<bg=magenta;fg=white>Now please enter the field data:</>');
foreach ($pubType->fields as $field) {
Expand All @@ -63,7 +63,7 @@ public function handle(): int
// Useful for debugging
//$this->output->writeln("xxx " . $e->getTraceAsString());
$this->output->writeln("<bg=red;fg=white>$msg</>");
$overwrite = HydeHelper::askWithValidation(
$overwrite = PublicationHelper::askWithValidation(
$this,
'overwrite',
'Do you wish to overwrite the existing file (y/n)',
Expand Down Expand Up @@ -123,7 +123,7 @@ private function captureFieldInput(Collection $field, Collection $mediaFiles): s
$offset = $k + 1;
$this->output->writeln(" $offset: $file");
}
$selected = HydeHelper::askWithValidation($this, $field->name, $field->name, ['required', 'integer', "between:1,$offset"]);
$selected = PublicationHelper::askWithValidation($this, $field->name, $field->name, ['required', 'integer', "between:1,$offset"]);
$file = $mediaFiles->{$selected - 1};

return '_media/'.Str::of($file)->after('media/')->toString();
Expand All @@ -148,7 +148,7 @@ private function captureFieldInput(Collection $field, Collection $mediaFiles): s
}
}

return HydeHelper::askWithValidation($this, $field->name, $field->name, $fieldRules);
return PublicationHelper::askWithValidation($this, $field->name, $field->name, $fieldRules);
}

private function getValidationRulesPerType(): Collection
Expand Down
Loading

0 comments on commit 8d0eb88

Please sign in to comment.