Files
pyrom/app/templates/users/settings.html

127 lines
6.9 KiB
HTML

{%- from 'common/macros.html' import babycode_editor_component -%}
{%- from 'common/macros.html' import subheader, avatar, timestamp -%}
{%- extends 'base.html' -%}
{%- block title -%}settings{%- endblock -%}
{%- block content -%}
{%- set sub -%}
{%- if user.is_guest() -%}You are a guest. Your customization options are limited until a moderator confirms your account.{%- endif -%}
{%- endset -%}
{{- subheader('User settings', sub) -}}
{%- if not user.is_guest() -%}
<fieldset class="plank">
<legend>Avatar</legend>
<form method="POST" class="avatar-form" action="{{url_for('users.set_avatar', username=user.username)}}" enctype="multipart/form-data">
{{- avatar(user.get_avatar_url()) -}}
<span class="avatar-form-controls">
<label for="avatar" class="linkbutton alt">Upload&hellip;</label>
<span class="avatar-form-size-label">1MB max. Will be cropped to square.</span>
<input type="file" style="display: none;" id="avatar" name="avatar" accept="image/*" required>
<input type="submit" value="Save">
<input type="submit" class="warn" value="Clear" formaction="{{url_for('users.clear_avatar', username=user.username)}}">
</span>
</form>
</fieldset>
{%- endif -%}
<fieldset class="plank">
<legend>Change password</legend>
<p>After you change your password, you will be logged out of all sessions and will need to log in again.</p>
<form class="full-width" method="POST" action="{{ url_for('users.change_password', username=user.username) }}">
<label for="current-password">Current password</label>
<input type="password" name="current_password" id="current-password" autocomplete="current-password" required>
<label for="new-password">New password</label>
<input type="password" name="new_password" id="new-password" autocomplete="new-password" pattern="(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])(?!.*\s).{10,255}" title="10+ chars with at least: 1 uppercase, 1 lowercase, 1 number, 1 special char, and no spaces" required>
<label for="new-password2">Confirm new password</label>
<input type="password" name="new_password2" id="new-password2" autocomplete="new-password" pattern="(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])(?!.*\s).{10,255}" title="10+ chars with at least: 1 uppercase, 1 lowercase, 1 number, 1 special char, and no spaces" required>
<input type="submit" value="Change password" class="warn">
</form>
</fieldset>
{%- if not user.is_guest() -%}
<fieldset class="plank">
<legend>Personalization</legend>
<form class="full-width" method="POST" action="{{ url_for('users.set_personalization', username=user.username)}}">
<label for="sort-by">Sort threads by:</label>
<select name="sort_by" id="sort-by" autocomplete=off>
<option value="activity" {{ 'selected' if sort_by == 'activity' else '' }}>Activity</option>
<option value="thread" {{ 'selected' if sort_by == 'thread' else '' }}>Newest</option>
</select>
<label for="display-name">Display name</label>
<input type="text" name="display_name" id="display-name" value="{{user.display_name}}" placeholder="Same as username" pattern="(?:[\w!#$%^*\(\)\-_=+\[\]\{\}\|;:,.?\s]{3,50})?" title="Optional. 3-50 characters, no @, no <>, no &." maxlength="50" autocomplete=off>
<label for="status">Status</label>
<input type="text" name="status" id="status" maxlength="100" value="{{user.status}}" placeholder="Will be shown under your username on posts. Max. 100 characters." autocomplete="off">
<div class="inline-group">
<input type="checkbox" id="subscribe-by-default" name="subscribe_by_default" {{'' if session['dont_subscribe_by_default'] else 'checked'}} autocomplete="off">
<label for="subscribe-by-default">Automatically subscribe to thread when responding</label>
</div>
<input type="submit" value="Save">
</form>
</fieldset>
<fieldset class="plank">
<legend>Signature</legend>
<form method="POST" class="full-width" action="{{url_for('users.set_sig', username=user.username)}}">
<p>The signature will appear under each of your posts.</p>
{{babycode_editor_component(id='signature-content', placeholder='Signature content', prefill=user.signature_original_markup, required=false, banned_tags=['@mention'])}}
<input type="submit" value="Save signature">
</form>
</fieldset>
{#<fieldset class="plank">
<legend>About me/Bio</legend>
<form method="POST" class="full-width">
<span>Your bio will appear on your profile.</span>
{{babycode_editor_component(id='bio-content', placeholder='Bio content', prefill=user.signature_original_markup, required=false, banned_tags=['@mention'])}}
<input type="submit" value="Save bio">
</form>
</fieldset>#}
<fieldset class="plank">
<bitty-8 data-connect="/static/js/bits/badge-editor.js"></bitty-8>
<legend>Badges</legend>
<form method="POST" action="{{url_for('users.save_badges', username=get_active_user().username)}}" data-listen="submit" data-r="badgeEditorInit" enctype="multipart/form-data">
<p>Loading badges&hellip;</p>
<p>If badges fail to load, make sure JS is enabled.</p>
</form>
</fieldset>
{%- if user.can_invite() -%}
<fieldset class="plank" id="invite">
<legend>Invite keys</legend>
<p>To manage growth, {{ config.SITE_NAME }} disallows direct sign ups. Instead, users already with an account may invite people they know. You can create invite links here.</p>
<p>Invite links are valid for 48 hours. Once an invite link is used to sign up, it can no longer be used.</p>
<form method="POST" action="{{url_for('users.create_invite_key', username=user.username)}}">
{{ csrf_input() | safe }}
<input type="submit" value="Create new invite">
</form>
{%- if invites -%}
<table>
<thead>
<tr>
<th class="plank even no-shadow contrast-bg" style="--w: 50%;">Link</th>
<th class="plank even no-shadow contrast-bg" style="--w: 30%;">Expires</th>
<th class="plank even no-shadow contrast-bg" style="--w: 20%;">Revoke</th>
</tr>
</thead>
<tbody>
{%- for invite in invites -%}
<tr>
<td class="plank even no-shadow minimal"><a href="{{url_for('users.sign_up', key=invite.key)}}">Copy this</a></td>
<td class="plank even no-shadow minimal">{{timestamp(invite.expires_at)}}</td>
<td class="plank even no-shadow minimal center">
<form method="POST" action="{{url_for('users.revoke_invite_key', username=user.username)}}">
{{ csrf_input() | safe }}
<input type="hidden" name="key" value="{{invite.key}}">
<input type="submit" class="warn" value="Revoke">
</form>
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
{%- else -%}
<p>You do not have any invites pending activation.</p>
{%- endif -%}
</fieldset>
{%- endif -%}
{%- endif -%}
<fieldset class="plank">
<legend>Disown & Delete account</legend>
<a class="linkbutton critical" href="{{url_for('users.delete_confirm', username=user.username)}}">Delete account</a>
</fieldset>
{%- endblock -%}