ily.li/views/url-shrinker.njk

76 lines
2.8 KiB
Plaintext

{% extends 'layouts/base.njk' %}
{% set title = app.name + ' - Shrink URL' %}
{% block scripts %}
<script src="/js/url-shrinker.js"></script>
{% endblock %}
{% block body %}
<h1>Shrink URLs</h1>
<p>For security reasons, shrinked URLs cannot be deleted.</p>
<div class="container">
<section class="panel">
<h2><i data-feather="crosshair"></i> Shrink a URL</h2>
<form action="{{ route('shrink-url') }}" method="POST" id="url-shrink-form">
{{ macros.field(_locals, 'text', 'target_url', '', 'Target URL', 'Only valid URLs starting with http:// or https://', validation_attributes='required') }}
{{ macros.field(_locals, 'checkbox', 'autogen_url', '', 'Generate url automatically', null, validation_attributes='checked') }}
{{ macros.field(_locals, 'text', 'slug', '', 'Custom url slug', 'Example: bear sets url to https://'+default_domain+'/bear', validation_attributes='disabled') }}
{{ macros.csrf(getCsrfToken) }}
<button type="submit"><i data-feather="link"></i> Shrink URL</button>
</form>
{% set url = flash('url') %}
{% if url | length %}
<div class="copyable-text">
<div class="title">URL</div>
<div class="content">{{ url }}</div>
<button class="copy-button"><i data-feather="copy"></i></button>
</div>
{% endif %}
</section>
<section class="panel">
<h2><i data-feather="link"></i> URL list</h2>
{{ macros.paginate(urls.pagination, 'url-shrinker', 3) }}
<table class="data-table">
<thead>
<tr>
<th>#</th>
<th class="table-col-grow">Target</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for url in urls %}
<tr>
<td>{{ url.id }}</td>
<td class="table-col-grow-cell"><a href="{{ url.getURL() }}"><pre>{{ url.target_url }}</pre></a></td>
<td class="actions">
<div>
<button class="copy-button" data-content="{{ url.getURL() }}"><i data-feather="copy"></i> <span class="tip">Copy URL</span></button>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="3" class="center">You haven't shrunk any url yet.</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ macros.paginate(urls.pagination, 'url-shrinker', 3) }}
</section>
</div>
{% endblock %}