Archived
1
0
Fork 0

app/views/user/settings.volt: cleaning up social links with array and loop.

This commit is contained in:
Henrik Hautakoski 2018-08-08 23:16:57 +02:00
parent 99e86fedd3
commit bfa772c486
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -1,3 +1,10 @@
{%
set social_links = [
'github' : [ 'connected': user.getGithubId() > 0 ],
'gitlab' : [ 'connected': user.getGitlabId() > 0, 'class': 'text-gitlab' ],
'google' : [ 'connected': user.getGoogleId() > 0, 'class': 'text-google' ]
]
%}
<div class="section">
@ -44,33 +51,17 @@
<hr />
{% for name,info in social_links %}
<div class="col-sm-2 text-center">
<div>{{ icon('brand/github', [ '3x' ]) }}</div>
{% if user.getGithubId() > 0 %}
<a href="{{ url(['for': 'oauth-disconnect', 'provider': 'github']) }}">Disconnect</a>
{% set class = info['class'] | default(false) %}
<div{{ class ? ' class="%s"'|format(class) : '' }}>{{ icon('brand/' ~ name, [ '3x' ]) }}</div>
{% if info['connected'] %}
<a href="{{ url(['for': 'oauth-disconnect', 'provider': name]) }}">Disconnect</a>
{% else %}
<a href="{{ url(['for': 'oauth', 'strategy': 'github']) }}">Connect</a>
<a href="{{ url(['for': 'oauth', 'strategy': name]) }}">Connect</a>
{% endif %}
</div>
<div class="col-sm-2 text-center">
<div class="text-gitlab">{{ icon('brand/gitlab', [ '3x' ]) }}</div>
{% if user.getGitlabId() > 0 %}
<a href="{{ url(['for': 'oauth-disconnect', 'provider': 'gitlab' ]) }}">Disconnect</a>
{% else %}
<a href="{{ url(['for': 'oauth', 'strategy': 'gitlab']) }}">Connect</a>
{% endif %}
</div>
<div class="col-sm-2 text-center">
<div class="text-google">{{ icon('brand/google', [ '3x' ]) }}</div>
{% if user.getGoogleId() > 0 %}
<a href="{{ url(['for': 'oauth-disconnect', 'provider': 'google']) }}">Disconnect</a>
{% else %}
<a href="{{url(['for': 'oauth', 'strategy': 'google']) }}">Connect</a>
{% endif %}
</div>
{% endfor %}
</div>
</div>