Add links to profile.

This commit is contained in:
flash 2018-03-23 01:27:46 +01:00
parent 8a6a36d6bf
commit 391d8e9cc7
3 changed files with 109 additions and 11 deletions

View file

@ -12,6 +12,15 @@
}
}
&__account-link {
color: inherit;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
&__icon {
vertical-align: middle;
}
@ -70,6 +79,10 @@
@media (max-width: @mio-profile-mobile) {
background-color: #fbeeff;
}
&--links:empty {
display: none;
}
}
&__row {

View file

@ -115,7 +115,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['profile']['youtube'])) {
$youtube_regex = preg_match(
'#^(?:https?://(?:www.)?youtube.com/(?:(?:user|c|channel)/)?)?'
. '(UC[a-zA-Z0-9-_]{1,50}|[a-zA-Z0-9-_%]{1,100})/?$#u',
. '(UC[a-zA-Z0-9-_]{1,22}|[a-zA-Z0-9-_%]{1,100})/?$#u',
$_POST['profile']['youtube'],
$youtube_matches
);
@ -259,7 +259,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
}
if (!empty($_POST['current_password']) && (isset($_POST['password']) || isset($_OST['email']))) {
if (!empty($_POST['current_password'])
|| (
(isset($_POST['password']) || isset($_OST['email']))
&& (!empty($_POST['password']['new']) || !empty($_POST['email']['new']))
)
) {
if (!$settings_user->verifyPassword($_POST['current_password'])) {
$settings_errors[] = "Your current password was incorrect.";
break;

View file

@ -1,8 +1,64 @@
{% extends '@mio/user/master.twig' %}
{% from '@mio/macros.twig' import navigation %}
{% from '@mio/macros.twig' import navigation, link %}
{% set title = 'Profile of ' ~ profile.username %}
{% set youtube_is_channel_id = profile.user_youtube|slice(0, 2) == 'UC' and profile.youtube|length == 24 %}
{% set profile_fields = {
"twitter": {
"title": "Twitter",
"value": profile.user_twitter,
"link": "https://twitter.com/%s",
"format": "@%s",
},
"osu": {
"title": "osu!",
"value": profile.user_osu,
"link": "https://osu.ppy.sh/users/%s",
},
"website": {
"title": "Website",
"value": profile.user_website,
"link": "%s",
},
"youtube": {
"title": "Youtube",
"value": profile.user_youtube,
"link": "https://youtube.com/" ~ (youtube_is_channel_id ? "channel/" : '') ~ "%s",
"format": youtube_is_channel_id ? "Channel of " ~ profile.username : "%s",
},
"steam": {
"title": "Steam",
"value": profile.user_steam,
"link": "https://steamcommunity.com/id/%s",
},
"twitchtv": {
"title": "Twitch.tv",
"value": profile.user_twitchtv,
"link": "https://twitch.tv/%s",
},
"lastfm": {
"title": "Last.fm",
"value": profile.user_lastfm,
"link": "http://last.fm/user/%s",
},
"github": {
"title": "Github",
"value": profile.user_github,
"link": "https://github.com/%s",
},
"skype": {
"title": "Skype",
"value": profile.user_skype,
"link": "skype:%s?userinfo",
},
"discord": {
"title": "Discord",
"value": profile.user_discord,
},
} %}
{% block content %}
{{ navigation(mio_navigation, false, true) }}
@ -12,16 +68,16 @@
<div class="mio__container__content mio__profile__header__content">
<div class="mio__profile__info">
<div class="mio__profile__info__section">
<div class="mio__profile__info__block">
<div class="mio__profile__info__row">
<div class="mio__profile__info__column mio__profile__info__column--icons">
<img class="mio__profile__icon" src="https://static.flash.moe/flags/fff/{{ profile.user_country|lower }}.png" alt="{{ profile.user_country }}">
</div>
<div class="mio__profile__info__column mio__profile__info__column--country">
{{ profile.user_country|country_name }}
<div class="mio__profile__info__block">
<div class="mio__profile__info__row">
<div class="mio__profile__info__column mio__profile__info__column--icons">
<img class="mio__profile__icon" src="https://static.flash.moe/flags/fff/{{ profile.user_country|lower }}.png" alt="{{ profile.user_country }}">
</div>
<div class="mio__profile__info__column mio__profile__info__column--country">
{{ profile.user_country|country_name }}
</div>
</div>
</div>
</div>
<div class="mio__profile__info__block">
<div class="mio__profile__info__row" title="{{ profile.created_at.format('r') }}">
@ -34,6 +90,30 @@
</div>
</div>
</div>
{% spaceless %}
<div class="mio__profile__info__section">
<div class="mio__profile__info__block mio__profile__info__block--links">
{% for name, data in profile_fields %}
{% if (data.display is defined ? data.display : data.value|length > 0) %}
<div class="mio__profile__info__row mio__profile__info__row--field-{{ name }}">
<div class="mio__profile__info__column mio__profile__info__column--heading">
{{ data.title }}
</div>
<div class="mio__profile__info__column">
{% set profile_field_value = (data.format is defined ? data.format : '%s')|format(data.value) %}
{% if data.link is defined %}
{{ link(data.link|format(data.value), profile_field_value, 'mio__profile__account-link') }}
{% else %}
{{ profile_field_value }}
{% endif %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endspaceless %}
</div>
<div class="mio__avatar mio__profile__avatar" style="background-image:url('https://secret.flashii.net/avatar-serve.php?id={{ profile.user_id }}');"></div>
</div>