[TWIG][Cards][Profile] Card templates! Profile now has a card template to be used everywhere you need to show quick actor information.

This commit is contained in:
Eliseu Amaro 2021-09-22 14:10:36 +01:00
parent c6082bab10
commit 3f618c2674
8 changed files with 14 additions and 73 deletions

View File

@ -9,7 +9,7 @@
<div class="section-widget-padded">
{% if actors is defined and actors is not empty %}
{% for actor in actors %}
{% include 'directory/actor.html.twig' %}
{% block profile_view %}{% include 'cards/profile/view.html.twig' %}{% endblock profile_view %}
{% endfor %}
{% else %}
<h1>{% trans %}No actors here.{% endtrans %}</h1>

View File

@ -1,43 +1,9 @@
{% extends 'stdgrid.html.twig' %}
{% set id = actor.getId() %}
{% set nickname = actor.getNickname() %}
{% set actor_bio = actor.getBio() %}
{% set actor_tags = actor.getSelfTags() %}
{% set avatar = actor.getAvatarUrl() %}
{% block title %}{{ nickname }}'s profile{% endblock %}
{% block title %}{{ actor.getNickname() }}'s profile{% endblock %}
{% block body %}
<section title="{{ nickname }}'s {{ 'profile information.' | trans }}">
<a class='profile' href="{{ path('actor_view_nickname', {'nickname' : nickname}) }}">
<img src="{{ avatar }}" class="profile-avatar" alt="{{ nickname }}{{ '\'s avatar.' | trans }}">
<div class="profile-info">
<strong id="profile-info-nickname" title="{{ nickname }}{{ '\'s nickname.' | trans }}">{{ nickname }}</strong>
<nav class="profile-info-tags">
{% if actor_tags %}
{% for tag in actor_tags %}
<a href='#'><i> #{{ tag }} </i></a>
{% endfor %}
{% else %}
{{ '(no tags)' | trans }}
{% endif %}
</nav>
<section class="profile-info-stats">
{% if actor_bio %}
<p>{{ actor_bio }}</p>
{% else %}
<p>{{ '(no bio)' | trans }}</p>
{% endif %}
</section>
</div>
</a>
</section>
<hr>
{% block profile_view %}{% include 'cards/profile/view.html.twig' %}{% endblock profile_view %}
<main class="timeline" tabindex="0" role="feed">
<div class="h-feed hfeed notes">

View File

@ -3,12 +3,12 @@
{% set actor_tags = actor.getSelfTags() %}
{% set actor_bio = actor.getBio() %}
{% block body %}
<section title="{{ actor_nickname }}'s {{ 'profile information.' | trans }}">
{% block profile_view %}
<section title="{{ actor_nickname }}'s {{ 'profile information.' | trans }}">
<a class='profile' href="{{ path('actor_view_nickname', {'nickname' : actor_nickname}) }}">
<img src='{{ actor_avatar }}' class="profile-avatar" alt="{{ 'Your account\'s avatar.' | trans }}">
<img src='{{ actor_avatar }}' class="profile-avatar" alt="{{ actor_nickname }}{{ '\'s avatar.' | trans }}">
<div class="profile-info">
<strong id="profile-info-nickname" title="{{ 'Your account\' nickname.' | trans }}">{{ actor_nickname }}</strong>
<strong id="profile-info-nickname" title="{{ actor_nickname }}{{ '\'s nickname.' | trans }}">{{ actor_nickname }}</strong>
<nav class="profile-info-tags">
{% if actor_tags %}
@ -21,6 +21,9 @@
</nav>
<section class="profile-info-stats">
<div><strong>{{ 'Subscriptions' | trans }}</strong>{{ actor.getSubscriptionsCount() }}</div>
<div><strong>{{ 'Subscribers' | trans }}</strong>{{ actor.getSubscribersCount() }}</div>
{% if actor_bio %}
<p>{{ actor_bio }}</p>
{% else %}
@ -29,7 +32,7 @@
</section>
</div>
</a>
</section>
</section>
<hr>
{% endblock body %}
<hr>
{% endblock profile_view %}

View File

@ -6,36 +6,8 @@
<aside class="panel-content accessibility-target">
{% if app.user %}
<section class='section-widget section-widget-padded' title="{{ 'Your profile information.' | trans }}">
<a class="profile" href="{{ path('actor_view_nickname', {'nickname' : current_actor.getNickname()}) }}">
<img class="profile-avatar" src='{{ current_actor.getAvatarUrl() }}' class="icon icon-avatar" alt="{{ 'Your account\'s avatar.' | trans }}">
<div class="profile-info">
<strong class="profile-info-nickname" title="{{ 'Your account\' nickname.' | trans }}">{{ current_actor.getNickname() }}</strong>
<nav class="profile-info-tags">
{% set user_tags = current_actor.getSelfTags() %}
<ul>
{% if user_tags %}
{% for tag in user_tags %}
<li><a href='#'> #{{ tag }}</a></li>
{% endfor %}
{% else %}
{{ '(no tags)' | trans }}
{% endif %}
</ul>
</nav>
<section class="profile-info-stats">
<div><strong>{{ 'Subscriptions' | trans }}</strong>{{ current_actor.getSubscriptionsCount() }}</div>
<div><strong>{{ 'Subscribers' | trans }}</strong>{{ current_actor.getSubscribersCount() }}</div>
</section>
</div>
</a>
<hr>
{% block profile_view %}{% include 'cards/profile/view.html.twig' with { actor: current_actor } %}{% endblock profile_view %}
<nav tabindex="0" class="profile-navigation" title="{{ 'Navigate through account related pages.' | trans }}">
<a title='{{ 'Your messages.' | trans }}' href='{{ path('settings') }}' class='{{ active("replies") }}'>