filesafe/views/album.njk
Bobby Wibowo 8ab77a6464
Updated
Removed version strings from _globals.njk,
in favor of src/versions.json.
That versions in that file can be bumped with "yarn bump-versions".
v1 is automatically bumped when doing "yarn build" as well.

Added README file in src directory, explaining versions.json file.

Added README file in scripts directory, detailing usage of each scripts.

Version strings will no longer be appended when cacheControl is disabled
in config file.
After all, version strings are only needed when the static assets are
cached indefinitely in users' browsers.

Initial Cloudflare's cache purging will no longer be executed when
cloudflare -> purgeCache is disabled, even if cacheControl is enabled.
Just in case someone wants to use version strings for other use cases.

Actually use custom metaDesc variable on meta description tag.
2019-09-19 19:10:37 +07:00

131 lines
4.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% set metaTitle %}
{{- album.name | truncate(60, true, '…') + ' ' + files.length + ' file' + ('s' if files.length !== 1) -}}
{% endset %}
{% set metaDesc = album.description | striptags | truncate(200, true, '…') %}
{% set metaUrl = '/' + album.url %}
{% set fileRoot = config.domain %}
{% set metaImage = fileRoot + '/' + album.thumb %}
{% extends "_layout.njk" %}
{% set generateZips = config.uploads.generateZips %}
{% set usingCdn = config.cloudflare and config.cloudflare.purgeCache %}
{% block stylesheets %}
<!-- Stylesheets -->
<link rel="stylesheet" href="../libs/bulma/bulma.min.css{{ versions[3] }}">
<link rel="stylesheet" href="../css/style.css{{ versions[1] }}">
<link rel="stylesheet" href="../css/thumbs.css{{ versions[1] }}">
<link rel="stylesheet" href="../css/album.css{{ versions[1] }}">
{% endblock %}
{% block scripts %}
{% if not nojs -%}
<!-- Scripts -->
<script src="../libs/lazyload/lazyload.min.js{{ versions[3] }}"></script>
<script src="../js/album.js{{ versions[1] }}"></script>
<script src="../js/misc/utils.js{{ versions[1] }}"></script>
{% endif %}
{% endblock %}
{% block content %}
{{ super() }}
<section class="section">
<div class="container">
<nav class="level">
<div class="level-left">
<div class="level-item">
<h1 id="title" class="title">
{{ album.name | truncate(70, true, '…') }}
</h1>
</div>
<div class="level-item">
<h1 id="count" class="subtitle">
{{ files.length }} file{{ 's' if files.length !== 1 }} (<span class="file-size">{{ album.totalSize }} B</span>)
</h1>
</div>
</div>
{% if generateZips -%}
<div class="level-right">
<p class="level-item">
{% if not files.length -%}
<a class="button is-primary is-outlined" title="There are no files in the album" disabled>Download album</a>
{%- elif album.downloadLink -%}
{%- if usingCDN -%}
<a class="button is-primary is-outlined" title="Be aware that album archive may be cached by CDN" href="../{{ album.downloadLink }}">Download album</a>
{%- else -%}
<a class="button is-primary is-outlined" href="../{{ album.downloadLink }}">Download album</a>
{%- endif -%}
{%- else -%}
<a class="button is-primary is-outlined" title="The album's owner has chosen to disable download" disabled>Download disabled</a>
{%- endif %}
</p>
</div>
{%- endif %}
</nav>
{% if album.description -%}
<div class="subtitle description">
{{ album.description | nl2br | safe }}
</div>
{%- endif %}
<hr>
{% if nojs -%}
<article class="message">
<div class="message-body">
<p>You are viewing No-JS version of this album, so file size will be displayed in bytes.</p>
<p>Please <a href="../{{ album.url }}">click here</a> if you want to view its regular version.</p>
</div>
</article>
{%- endif %}
{% if files.length -%}
<div id="table" class="columns is-multiline is-mobile is-centered has-text-centered">
{% for file in files %}
<div class="image-container column">
<a class="image" href="{{ fileRoot }}/{{ file.name }}" target="_blank" rel="noopener">
{% if file.thumb -%}
{% if nojs -%}
<img alt="{{ file.name }}" src="{{ fileRoot }}/{{ file.thumb }}" width="200" height="200" loading="lazy">
{%- else -%}
<img alt="{{ file.name }}" data-src="{{ fileRoot }}/{{ file.thumb }}">
{%- endif %}
{%- else -%}
<h1 class="title">{{ file.extname | default('N/A') }}</h1>
{%- endif %}
</a>
<div class="details">
<p><span class="name">{{ file.name }}</span></p>
<p class="file-size">{{ file.size }} B</p>
</div>
</div>
{% endfor %}
</div>
{%- else -%}
<article class="message">
<div class="message-body">
There are no files in the album.
</div>
</article>
{%- endif %}
</div>
</section>
{% if not nojs -%}
<noscript>
<style>body > section:not(#noscript) { display: none !important; }</style>
<section id="noscript" class="hero is-fullheight">
<div class="hero-body">
<div class="container has-text-centered">
<p>You have JavaScript disabled, but this page requires JavaScript to function.</p>
<p>Please <a href="../{{ album.url }}?nojs">click here</a> if you want to view its No-JS version.</p>
</div>
</div>
</section>
</noscript>
{%- endif %}
{% endblock %}