Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Public Profile Pages #433

Merged
merged 11 commits into from
Jan 31, 2025
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"overtrue/phplint": "^3.0 || ^4.0",
"overtrue/phplint": "^5.5.0",
"symfony/phpunit-bridge": "^5.4 || ^6.4",
"symfony/webpack-encore-bundle": "^1.13"
},
Expand Down
9 changes: 5 additions & 4 deletions src/Resources/views/layout.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head{% block headAttributes %}{% endblock %}>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -11,6 +11,7 @@
{% if template.application.assets.encore_entrypoint and template_function_exist('encore_entry_link_tags') %}
{{ template_function_call('encore_entry_link_tags', template.application.assets.encore_entrypoint) }}
{% endif %}
{% block metatags %}{% endblock %}
{% block stylesheets %}{% endblock %}
<script src="https://cdn.typo3.com/typo3infrastructure/universe/dist/webcomponents-loader.js"></script>
<script type="module" src="https://cdn.typo3.com/typo3infrastructure/universe/dist/typo3-universe.js"></script>
Expand Down Expand Up @@ -39,8 +40,8 @@
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="mainnavigation">
{{ knp_menu_render('main-default', {'depth': 2}) }}
{{ knp_menu_render('main-profile', {'depth': 2}) }}
{{ knp_menu_render('main-default', {'depth': 2, 'allow_safe_labels': true}) }}
{{ knp_menu_render('main-profile', {'depth': 2, 'allow_safe_labels': true}) }}
</div>
</div>
</nav>
Expand Down Expand Up @@ -119,7 +120,7 @@
<span>© {{ "now"|date("Y") }} <a href="{{ template.application.copyright.url }}" target="_blank">{{ template.application.copyright.author }}</a>.</span>
</div>
<div class="page-footer-menu">
{{ knp_menu_render('main-footer') }}
{{ knp_menu_render('main-footer', {'allow_safe_labels': true}) }}
</div>
</div>
{% endframe %}
Expand Down
6 changes: 6 additions & 0 deletions src/Twig/Extension/AvatarExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function getFunctions(): array
{
return [
new TwigFunction('avatar', [$this, 'render'], ['is_safe' => ['html']]),
new TwigFunction('avatarUrl', [$this, 'renderUrl'], ['is_safe' => ['html']]),
];
}

Expand All @@ -31,6 +32,11 @@ public function render(string $value, int $size = 36): string
return AvatarUtility::getAvatar($value, $size);
}

public function renderUrl(string $value, int $size = 36): string
{
return AvatarUtility::getAvatarUrl($value, $size);
}

public function getName(): string
{
return 'avatar';
Expand Down
68 changes: 68 additions & 0 deletions src/Twig/Extension/LinkTypeExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

/*
* This file is part of the package t3g/symfony-template-bundle.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace T3G\Bundle\TemplateBundle\Twig\Extension;

use Psr\Log\LoggerInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class LinkTypeExtension extends AbstractExtension
{
private $logger;

public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}

public function getFunctions(): array
{
return [
new TwigFunction('linkTypeIdentifier', [$this, 'getLinkTypeIdentifier'], ['is_safe' => ['html']]),
new TwigFunction('linkTypeName', [$this, 'getLinkTypeName'], ['is_safe' => ['html']]),
new TwigFunction('linkTypePrefix', [$this, 'getLinkTypePrefix'], ['is_safe' => ['html']]),
];
}

public function getLinkTypeIdentifier(string $type): string
{
if (class_exists('T3G\DatahubApiLibrary\Enum\LinkTypes')) {
return \T3G\DatahubApiLibrary\Enum\LinkTypes::getIconIdentifier($type);
}

$this->logger->warning('Tried to get link type identifier without t3g/datahub-api-library installed.', ['type' => $type]);

return $type;
}

public function getLinkTypeName(string $type): string
{
if (class_exists('T3G\DatahubApiLibrary\Enum\LinkTypes')) {
return \T3G\DatahubApiLibrary\Enum\LinkTypes::getName($type);
}

$this->logger->warning('Tried to get link type name without t3g/datahub-api-library installed.', ['type' => $type]);

return '';
}

public function getLinkTypePrefix(string $type): string
{
if (class_exists('T3G\DatahubApiLibrary\Enum\LinkTypes')) {
return \T3G\DatahubApiLibrary\Enum\LinkTypes::getUrlPrefix($type);
}

$this->logger->warning('Tried to get link type prefix without t3g/datahub-api-library installed.', ['type' => $type]);

return '';
}
}