myWebLog/src/admin-theme/upload-list.liquid

76 lines
3.5 KiB
Plaintext

<h2 class=my-3>{{ page_title }}</h2>
<article>
{%- capture base_url %}{{ "" | relative_link }}{% endcapture -%}
{%- capture upload_path %}upload/{{ web_log.slug }}/{% endcapture -%}
{%- capture upload_base %}{{ base_url }}{{ upload_path }}{% endcapture -%}
<a href="{{ "admin/upload/new" | relative_link }}" class="btn btn-primary btn-sm mb-3">Upload a New File</a>
<form method=post class=container hx-target=body>
<input type=hidden name="{{ csrf.form_field_name }}" value="{{ csrf.request_token }}">
<div class=row>
<div class="col text-center"><em class=text-muted>Uploaded files served from</em><br>{{ upload_base }}</div>
</div>
{%- assign file_count = files | size -%}
{%- if file_count > 0 %}
<div class="row mwl-table-heading">
<div class=col-6>File Name</div>
<div class=col-3>Path</div>
<div class=col-3>File Date/Time</div>
</div>
{% for file in files %}
<div class="row mwl-table-detail">
<div class=col-6>
{%- capture badge_class -%}
{%- if file.source == "Disk" %}secondary{% else %}primary{% endif -%}
{%- endcapture -%}
{%- assign path_and_name = file.path | append: file.name -%}
{%- assign blog_rel = upload_path | append: path_and_name -%}
<span class="badge bg-{{ badge_class }} text-uppercase float-end mt-1">{{ file.source }}</span>
{{ file.name }}<br>
<small>
<a href="{{ upload_base | append: path_and_name }}" target="_blank">View File</a>
<span class=text-muted> &bull; Copy </span>
<a href="{{ blog_rel | absolute_link }}" hx-boost=false
onclick="return Admin.copyText('{{ blog_rel | absolute_link }}', this)">
Absolute
</a>
<span class=text-muted> | </span>
<a href="{{ blog_rel | relative_link }}" hx-boost=false
onclick="return Admin.copyText('{{ blog_rel | relative_link }}', this)">
Relative
</a>
{%- unless base_url == "/" %}
<span class=text-muted> | </span>
<a href="{{ blog_rel }}" hx-boost=false onclick="return Admin.copyText('/{{ blog_rel }}', this)">
For Post
</a>
{%- endunless %}
<span class=text-muted> Link</span>
{% if is_web_log_admin %}
<span class=text-muted> &bull; </span>
{%- capture delete_url -%}
{%- if file.source == "Disk" -%}
admin/upload/delete/{{ path_and_name }}
{%- else -%}
admin/upload/{{ file.id }}/delete
{%- endif -%}
{%- endcapture -%}
<a href="{{ delete_url | relative_link }}" hx-post="{{ delete_url | relative_link }}"
hx-confirm="Are you sure you want to delete {{ file.name }}? This action cannot be undone."
class=text-danger>Delete</a>
{% endif %}
</small>
</div>
<div class=col-3>{{ file.path }}</div>
<div class=col-3>
{% if file.updated_on %}{{ file.updated_on.value | date: "yyyy-MM-dd/HH:mm" }}{% else %}--{% endif %}
</div>
</div>
{% endfor %}
{%- else -%}
<div class=row>
<div class="col text-muted fst-italic text-center"><br>This web log has uploaded files</div>
</div>
{%- endif %}
</form>
</article>