Skip to content

Commit

Permalink
Show default text "Wpis użytkownika" for microblogs without printable…
Browse files Browse the repository at this point in the history
… text
  • Loading branch information
danon committed Dec 27, 2023
1 parent c9ec290 commit 8817a51
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app/Http/Controllers/Microblog/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Coyote\Http\Resources\MicroblogCollection;
use Coyote\Http\Resources\MicroblogResource;
use Coyote\Http\Resources\UserResource;
use Coyote\Microblog;
use Coyote\Repositories\Eloquent\MicroblogRepository;
use Coyote\Services\Microblogs;
use Coyote\Services\Parser\Extensions\Emoji;
Expand Down Expand Up @@ -63,7 +64,7 @@ public function show(int $id): View
{
$microblog = $this->builder->one($id);
abort_if(!is_null($microblog->parent_id), 404);
$excerpt = excerpt($microblog->html);
$excerpt = $this->title($microblog);
$this->breadcrumb->push($excerpt, route('microblog.view', [$microblog->id]));
MicroblogResource::withoutWrapping();
$resource = new MicroblogResource($microblog);
Expand All @@ -79,6 +80,15 @@ public function show(int $id): View
]);
}

private function title(Microblog $microblog): string
{
$excerpt = excerpt($microblog->html);
if ($excerpt) {
return $excerpt;
}
return 'Wpis użytkownika: ' . $microblog->user->name;
}

private function tags(): array
{
$tags = $this->getCacheFactory()->remember('microblog:tags', 30 * 60, fn() => $this->microblog->getTags());
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endblock %}

{% block head %}
<title>{%- block title -%} :: 4programmers.net{%- endblock -%}</title>
<title>{% block title %} :: 4programmers.net{% endblock %}</title>

<meta name="description" content="{% block description %}{% endblock %}">
<meta name="keywords" content="{% block keywords %}{% endblock %}">
Expand Down
6 changes: 4 additions & 2 deletions resources/views/microblog/view.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% extends 'layout' %}
{% block title %}{{ excerpt }}{{ parent() }}{% endblock %}

{% block title %}{{ excerpt }} {{ parent() }}{% endblock %}
{% block description %}{{ excerpt }}{% endblock %}
{% block keywords %}{{ keywords(microblog.text)|join(',') }}{% endblock %}

{% import 'components.meta' as meta %}

{% block meta_robots %}
{{ meta.robots('index, follow') }}
{{ parent() }}
Expand All @@ -15,7 +17,7 @@
<vue-microblog :microblog="microblog" :wrap="false"></vue-microblog>
</div>
{% include 'microblog.aside' %}
<vue-notifications position="bottom right" />
<vue-notifications position="bottom right"></vue-notifications>
</div>

<script>
Expand Down

0 comments on commit 8817a51

Please sign in to comment.