move template page files into a better structure
This commit is contained in:
@@ -266,7 +266,7 @@ class EdgeDB:
|
||||
value
|
||||
},
|
||||
at
|
||||
}
|
||||
} order by .at desc
|
||||
"""
|
||||
)
|
||||
return [{
|
||||
|
||||
+11
-5
@@ -13,26 +13,32 @@ side_main_bp = Blueprint('side_main', __name__)
|
||||
@LIMITER.limit("10 per minute;50 per hour")
|
||||
async def index():
|
||||
if session.get("user") is not None:
|
||||
return await render_template("views/webpage/upload.htm")
|
||||
return await render_template("views/webpage/files/upload.htm")
|
||||
return await render_template("views/webpage/index.htm")
|
||||
|
||||
@side_main_bp.route('/access')
|
||||
@login_required
|
||||
async def access_list(user):
|
||||
access_data = await current_app.edgedb.get_all_file_access()
|
||||
return await render_template("views/webpage/access/list.htm", access_logs=access_data)
|
||||
|
||||
@side_main_bp.route('/files')
|
||||
@login_required
|
||||
async def files(user):
|
||||
async def files_list(user):
|
||||
files_data = await current_app.edgedb.get_files(current_datetime=datetime.now(timezone.utc), user_id=user['sub'])
|
||||
return await render_template("views/webpage/files_list.htm", files=files_data)
|
||||
return await render_template("views/webpage/files/list.htm", files=files_data)
|
||||
|
||||
@side_main_bp.route('/files/<path:file_id>/info')
|
||||
@login_required
|
||||
async def file_info(file_id, user):
|
||||
files_data = await current_app.edgedb.get_files(user_id=user['sub'])
|
||||
return await render_template("views/webpage/file_info.htm", files=files_data)
|
||||
return await render_template("views/webpage/files/info.htm", files=files_data)
|
||||
|
||||
@side_main_bp.route('/files/<path:file_id>/edit')
|
||||
@login_required
|
||||
async def file_edit(file_id, user):
|
||||
files_data = await current_app.edgedb.get_files(user_id=user['sub'])
|
||||
return await render_template("views/webpage/file_edit.htm", files=files_data)
|
||||
return await render_template("views/webpage/files/edit.htm", files=files_data)
|
||||
|
||||
@side_main_bp.route("/-<file_id>")
|
||||
@LIMITER.limit("10 per minute;500 per hour;")
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
{% extends "base.htm" %}
|
||||
|
||||
{% block title %}NanoShare - Accesslog{% endblock %}
|
||||
|
||||
{% block meta %}
|
||||
<meta name="description" content="NanoShare is a lightweight self-hosted file sharing service built on Python Quart.">
|
||||
<meta name="keywords" content="NanoShare, file sharing, self-hosted, Python Quart, open source">
|
||||
<meta name="robots" content="index, follow" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<main class="file-list">
|
||||
<section class="card" style="padding: clamp(18px, 2.6vw, 28px);">
|
||||
<h2 class="page-title">Accesslog</h2>
|
||||
<p class="subtle">Your uploaded files at a glance. Click a filename to open, or use the actions on the right.</p>
|
||||
|
||||
<div class="table-wrap" role="region" aria-label="Files table" tabindex="0">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Accessed At</th>
|
||||
<th scope="col">Status</th>
|
||||
<th scope="col">IP Address</th>
|
||||
<th scope="col">User Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for access in access_logs %}
|
||||
<tr>
|
||||
<td><time datetime="{{ access.accessed_at }}" class="local-time"></time></td>
|
||||
<td><span class="badge">{{ access.status }}</span></td>
|
||||
<td>{{ access.ip }}</td>
|
||||
<td>{{ access.user_agent }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
document.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('button[data-action="copy"]');
|
||||
if(!btn) return;
|
||||
const row = btn.closest('tr');
|
||||
const link = row?.querySelector('.cell--name a')?.href;
|
||||
if(!link) return;
|
||||
navigator.clipboard.writeText(link).then(() => {
|
||||
const original = btn.innerHTML;
|
||||
btn.innerHTML = '✅';
|
||||
setTimeout(() => btn.innerHTML = original, 1200);
|
||||
}).catch(() => {
|
||||
alert('Could not copy link.');
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll("time.local-time").forEach(timeEl => {
|
||||
const datetime = timeEl.getAttribute("datetime");
|
||||
if (!datetime) return;
|
||||
|
||||
const date = new Date(datetime);
|
||||
|
||||
timeEl.title = date.toISOString();
|
||||
timeEl.textContent = date.toLocaleString(undefined, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: undefined,
|
||||
hour12: false,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user