Skip to content

Commit

Permalink
fixed title for page show Chapter, Exercise, Solution v.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolalexx committed Apr 2, 2024
1 parent 81d44a8 commit 903af7d
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 41 deletions.
6 changes: 2 additions & 4 deletions app/Helpers/TemplateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

class TemplateHelper
{
public static function getTitleContent(object $model): string
public static function getTitleContent(string $header, string $title): string
{
$header = $model->getFullTitle();
$nameModel = $model->getNameModel();
$nameProject = __('layout.title.name_SICP');
return "{$nameModel} {$header} - {$nameProject}";
return "{$title} {$header} - {$nameProject}";
}

public static function getBookLink(string $locale): string
Expand Down
4 changes: 2 additions & 2 deletions app/Helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Illuminate\Support\Collection;

if (!function_exists('getTitleContent')) {
function getTitleContent(object $model): string
function getTitleContent(string $header, string $title = ''): string
{
return TemplateHelper::getTitleContent($model);
return TemplateHelper::getTitleContent($header, $title);
}
}

Expand Down
5 changes: 0 additions & 5 deletions app/Models/Chapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@ public function getFullTitle(): string
{
return $this->present()->fullTitle;
}

public function getNameModel(): string
{
return $this->present()->nameModel;
}
}
5 changes: 0 additions & 5 deletions app/Models/Exercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,4 @@ public function getExerciseTeacherSolution(): string

return trim($fileContent);
}

public function getNameModel(): string
{
return $this->present()->nameModel;
}
}
10 changes: 0 additions & 10 deletions app/Models/Solution.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,4 @@ public function scopeVersioned(Builder $builder): Builder
->from(self::getTable());
}, $this->getTable());
}

public function getFullTitle(): string
{
return $this->exercise->getFullTitle();
}

public function getNameModel(): string
{
return __('solution.solution_for_title');
}
}
6 changes: 0 additions & 6 deletions app/Presenters/ChapterPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@
/**
* @mixin Chapter
* @property-read string $fullTitle
* @property-read string $nameModel
*/
class ChapterPresenter extends Presenter
{
public function getNameModelAttribute(): string
{
return __('chapter.chapter');
}

public function getFullTitleAttribute(): string
{
$path = $this->path;
Expand Down
6 changes: 0 additions & 6 deletions app/Presenters/ExercisePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @property-read string $underscorePath
* @property-read string $title
* @property-read string $fullTitle
* @property-read string $nameModel
*/
class ExercisePresenter extends Presenter
{
Expand All @@ -35,9 +34,4 @@ public function getFullTitleAttribute(): string

return "$path $exerciseTitle";
}

public function getNameModelAttribute(): string
{
return __('exercise.exercise');
}
}
2 changes: 1 addition & 1 deletion resources/views/chapter/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
@endphp
@section('title')
{{ getTitleContent($chapter) }}
{{ getTitleContent($chapter->getFullTitle(), __('chapter.chapter')) }}
@endsection
@section('description')
@foreach (Breadcrumbs::generate('chapter', $chapter) as $breadcrumb)
Expand Down
2 changes: 1 addition & 1 deletion resources/views/exercise/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
@endphp
@section('title')
{{ getTitleContent($exercise) }}
{{ getTitleContent($exercise->getFullTitle(), __('exercise.exercise')) }}
@endsection
@section('description')
{{ __('exercise.exercise') }} {{ $exercise->path }} {{ $exercise->getTitle() }} {{ __('exercise.show.description') }}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/solution/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@section('meta-robots', 'nofollow, noindex')
@section('title')
{{ getTitleContent($solution) }}
{{ getTitleContent($currentExercise->getFullTitle(), __('solution.solution_for_title')) }}
@endsection
@section('description'){{ $user->id }} - {{ __('solution.code_review') }} - {{ $user->name }} -
{{ __('solution.exercise') }} {{ $currentExercise->getFullTitle() }}@endsection
Expand Down

0 comments on commit 903af7d

Please sign in to comment.