2018-08-15 01:12:58 +00:00
{% extends 'user/master.twig' %}
2018-10-22 19:53:21 +00:00
{% from 'macros.twig' import container_title %}
2018-10-25 01:35:53 +00:00
{% from '_layout/input.twig' import input_hidden , input_csrf , input_text %}
2018-03-22 02:56:41 +00:00
2018-04-14 02:58:53 +00:00
{% set image = '/profile.php?u=' ~ profile .user_id ~ '&m=avatar' %}
{% set canonical_url = '/profile.php?u=' ~ profile .user_id %}
2018-03-22 02:56:41 +00:00
{% set title = 'Profile of ' ~ profile .username %}
2018-04-23 03:00:55 +00:00
{% set manage_link = '/manage/users.php?v=view&u=' ~ profile .user_id %}
2018-03-22 02:56:41 +00:00
2018-09-16 01:37:32 +00:00
{% if has_background %}
{% set site_background_url = '/profile.php?m=background&u=' ~ profile .user_id %}
{% endif %}
2018-09-23 14:04:48 +00:00
{% set stats = [
{
'title': 'Joined',
'is_date': true,
'value': profile.created_at,
},
{
'title': 'Last seen',
'is_date': true,
'value': profile.last_seen,
},
{
'title': 'Topics',
'value': profile.forum_topic_count,
},
{
'title': 'Posts',
'value': profile.forum_post_count,
},
{
'title': 'Comments',
'value': profile.comments_count,
},
{
'title': 'Changes',
'value': profile.changelog_count,
},
] %}
2018-03-22 02:56:41 +00:00
{% block content %}
2018-09-23 19:12:40 +00:00
{% if is_editing %}
2018-09-26 09:23:36 +00:00
<form class="profile" method="post" action="/settings.php" enctype="multipart/form-data">
2018-10-25 01:35:53 +00:00
{{ input_hidden ( 'user' , profile .user_id ) }}
{{ input_csrf ( 'settings' ) }}
2018-09-26 09:23:36 +00:00
{% if perms .edit_avatar %}
<input class="settings__avatar__input"
accept="image/png,image/jpeg,image/gif"
type="file"
name="avatar[file]"
id="avatar-selection">
<script>
function updateAvatarPreview(name, url, preview) {
url = url || "/profile.php?u= {{ profile .user_id }} &m=avatar";
preview = preview || document.getElementById('avatar-preview');
preview.style.backgroundImage = 'url(\' { 0}\')'.replace(' { 0}', url);
preview.title = name;
}
document.getElementById('avatar-selection').addEventListener('change', function (ev) {
updateAvatarPreview(ev.target.files[0].name, URL.createObjectURL(ev.target.files[0]));
});
</script>
{% endif %}
2018-09-23 19:12:40 +00:00
{% else %}
<div class="profile">
{% endif %}
2018-08-12 13:35:50 +00:00
2018-09-23 19:12:40 +00:00
{% include 'user/_layout/header.twig' %}
2018-09-27 06:39:49 +00:00
{% if is_editing %}
2018-10-22 17:26:59 +00:00
<div class="container profile__guidelines">
2018-09-27 20:02:24 +00:00
<ul class="profile__guidelines__section">
<li class="profile__guidelines__line profile__guidelines__line--header">General</li>
<li class="profile__guidelines__line">Keep things sane and generally suitable for all ages.</li>
<li class="profile__guidelines__line">Make sure to adhere to the <a href="/info.php/rules" class="profile__guidelines__link">rules</a>.</li>
</ul>
2018-09-27 06:39:49 +00:00
2018-09-27 20:02:24 +00:00
{% if perms .edit_avatar %}
2018-09-27 06:39:49 +00:00
<ul class="profile__guidelines__section">
2018-09-27 20:02:24 +00:00
<li class="profile__guidelines__line profile__guidelines__line--header">Avatar</li>
<li class="profile__guidelines__line">May not exceed the <span class="profile__guidelines__emphasis"> {{ guidelines .avatar .max_size | byte_symbol ( true ) }} </span> file size limit.</li>
<li class="profile__guidelines__line">May not be larger than <span class="profile__guidelines__emphasis"> {{ guidelines .avatar .max_width }} x {{ guidelines .avatar .max_height }} </span>.</li>
<li class="profile__guidelines__line">Will be centre cropped and scaled to <span class="profile__guidelines__emphasis">200x200</span>.</li>
<li class="profile__guidelines__line">Animated gif images are allowed.</li>
2018-09-27 06:39:49 +00:00
</ul>
2018-09-27 20:02:24 +00:00
{% endif %}
2018-09-27 06:39:49 +00:00
2018-09-27 20:02:24 +00:00
{% if perms .edit_background %}
<ul class="profile__guidelines__section">
<li class="profile__guidelines__line profile__guidelines__line--header">Background</li>
<li class="profile__guidelines__line">May not exceed the <span class="profile__guidelines__emphasis"> {{ guidelines .background .max_size | byte_symbol ( true ) }} </span> file size limit.</li>
<li class="profile__guidelines__line">May not be larger than <span class="profile__guidelines__emphasis"> {{ guidelines .background .max_width }} x {{ guidelines .background .max_height }} </span>.</li>
<li class="profile__guidelines__line">Gif images, in general, are only allowed when tiling.</li>
</ul>
{% endif %}
2018-09-23 19:12:40 +00:00
</div>
2018-09-27 22:03:43 +00:00
{% endif %}
{% if profile_notices is defined %}
2018-09-27 06:39:49 +00:00
<div class="warning">
<div class="warning__content">
2018-09-27 22:03:43 +00:00
{% for notice in profile_notices %}
{{ notice }}
{% endfor %}
2018-09-27 06:39:49 +00:00
</div>
</div>
{% endif %}
2018-09-16 22:36:46 +00:00
2018-09-23 19:12:40 +00:00
<div class="profile__container">
<div class="profile__container__side">
{% if current_user is not defined %}
2018-10-22 17:26:59 +00:00
<div class="container">
2018-09-23 19:12:40 +00:00
<div class="profile__accounts__notice">
You must <a href="/auth.php?m=login" class="profile__accounts__link">log in</a> to view full profiles!
</div>
2018-09-19 18:58:13 +00:00
</div>
2018-09-23 19:12:40 +00:00
{% elseif is_editing ? perms .edit_profile : profile_fields | default ( [ ] ) | length > 0 %}
2018-10-22 17:26:59 +00:00
<div class="container">
2018-10-22 19:53:21 +00:00
{{ container_title ( 'Elsewhere' ) }}
2018-09-23 19:12:40 +00:00
<div class="profile__accounts">
{% for name , data in profile_fields %}
<label class="profile__accounts__item">
<div class="profile__accounts__title">
{{ data .name }}
</div>
{% if is_editing %}
2018-10-25 01:35:53 +00:00
{{ input_text ( 'profile[' ~ name ~ ']' , 'profile__accounts__input' , profile [ 'user_' ~ name ] , data .type | default ( 'text' ) ) }}
2018-09-19 18:58:13 +00:00
{% else %}
2018-09-23 19:12:40 +00:00
<div class="profile__accounts__value"
{% if data .tooltip is defined %} title=" {{ data .tooltip | format ( data .value ) | raw }} " {% endif %} >
{% set profile_field_value = ( data .format is defined ? data .format : '%s' ) | format ( data .value ) %}
{% if data .link is defined %}
{{ data .link | format ( data .value ) | html_link ( profile_field_value , 'profile__accounts__link' ) | raw }}
{% else %}
{{ profile_field_value }}
{% endif %}
</div>
2018-09-19 18:58:13 +00:00
{% endif %}
2018-09-23 19:12:40 +00:00
</label>
{% endfor %}
</div>
2018-09-19 18:58:13 +00:00
</div>
2018-09-23 19:12:40 +00:00
{% endif %}
</div>
2018-09-17 18:39:46 +00:00
2018-09-23 19:12:40 +00:00
<div class="profile__container__main">
2018-09-28 07:58:26 +00:00
{% if ( is_editing and perms .edit_about ) or profile .user_about_content | length > 0 %}
2018-10-22 17:26:59 +00:00
<div class="container profile__about" id="about">
2018-10-22 19:53:21 +00:00
{{ container_title ( 'About ' ~ profile .username ) }}
2018-09-23 19:12:40 +00:00
<div class="profile__about__content {% if is_editing %} profile__about__content--edit {% endif %} ">
{% if is_editing %}
2018-10-22 17:26:59 +00:00
<select name="about[parser]" class="input__select profile__about__select">
2018-09-23 19:12:40 +00:00
{% for parser , name in constant ( 'MSZ_PARSERS_NAMES' ) %}
<option value=" {{ parser }} " {% if parser == profile .user_about_parser %} selected {% endif %} > {{ name }} </option>
{% endfor %}
</select>
2018-10-22 17:26:59 +00:00
<textarea name="about[text]" class="input__textarea profile__about__editor" id="about-textarea"> {{ profile .user_about_content | escape }} </textarea>
2018-09-23 19:12:40 +00:00
{% else %}
{{ profile .user_about_content | escape | parse_text ( profile .user_about_parser ) | raw }}
{% endif %}
</div>
2018-09-19 18:58:13 +00:00
</div>
2018-09-23 19:12:40 +00:00
{% endif %}
2018-09-19 18:58:13 +00:00
2018-09-23 19:12:40 +00:00
</div>
2018-09-17 18:39:46 +00:00
</div>
2018-09-23 19:12:40 +00:00
{% if is_editing %}
</form>
{% else %}
2018-09-17 18:39:46 +00:00
</div>
2018-09-23 19:12:40 +00:00
{% endif %}
2018-03-22 02:56:41 +00:00
{% endblock %}