{% extends "files/_layout.html" %} {% from "_macros.html" import icon %} {% from "files/_macros.html" import in_place, size %} {% set explorer = true %} {# A file, in the explorer's frame (tree beside it, path above). A text file you may change opens straight in the editor: CodeMirror over a textarea (js/editor.js; without JavaScript the textarea and Save post `/files/save` as a form). Markdown and HTML have a Preview beside Edit, drawn by the server the way the viewer draws them (js/file-page.js fetches it again after a change). Anything else -- an older version, a file you may only read, an image, a binary -- opens in the viewer (files/_viewer_body.html). A `.py` file has Run when Python is switched on here: Pyodide, in a worker in this browser (js/file-page.js and the `python` tool's worker), with what it printed shown under the file. `?run=1` runs it on arrival -- the explorer's Run button. #} {% block title %}{{ path }} - {{ brand.name }}{% endblock %} {% block files_head %} {% if editing %} {% endif %} {% endblock %} {% block files_content %} {% if problem %}
{{ icon("file-text", "empty__mark") }}

{{ t("Not here") }}

{{ problem }}

{{ t("Back to your files") }}

{% else %} {% set previewable = opened.kind in ("markdown", "html") %} {% set runnable = python and opened.name.lower().endswith(".py") %}
{{ icon("file-code" if opened.kind in ("code", "html") else "file-text", "icon--sm") }} {{ opened.name }} {{ size(opened.size) }}{% if opened.version %} · {{ t("an older version") }}{% elif not opened.writable %} · {{ t("read-only") }}{% endif %} {% if editing and previewable %} {% endif %} {% if runnable %} {% endif %} {% if versions|length > 1 %} {#- Every write is a version (services/fs.py); restoring one writes it again, so nothing is lost by trying. -#}
{% endif %} {% if opened.version %} {{ t("Back to the current one") }} {% endif %} {{ icon("download", "icon--sm") }} {% if editing %} {% endif %}
{% if editing %}
{% if previewable %} {% endif %} {% else %}
{% include "files/_viewer_body.html" %}
{% endif %}
{% if runnable %} {% endif %}
{% endif %} {% endblock %}