app/views/user/settings.volt: cleaning up social links with array and loop.
This commit is contained in:
parent
99e86fedd3
commit
bfa772c486
1 changed files with 14 additions and 23 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Reference in a new issue