Pick a DB file and store its name in session

This commit is contained in:
2024-07-29 14:44:06 -06:00
parent 52ca219659
commit b80242b74b
10 changed files with 121 additions and 6 deletions

View File

@ -0,0 +1,23 @@
{% if #directories ~= 0 then %}
<ul class="directories">
{% for _, dir in ipairs(directories) do %}
<details
hx-trigger="toggle once"
hx-get="/dirlist?dirpath={%& dir.path %}"
hx-target="find .details-children">
<summary>{%& dir.name %}</summary>
<div class="details-children"></div>
</details>
{% end %}
</ul>
{% end %}
{% if #files ~= 0 then %}
<ul class="files">
{% for _, file in ipairs(files) do %}
<li><label>
<input type="radio" name="filename-option" value="{%& file.path %}">
{%& file.name %}
</label></li>
{% end %}
</ul>
{% end %}

4
assets/tmpl/home.tmpl Normal file
View File

@ -0,0 +1,4 @@
{% function block.pagebody() %}
<a href="/open">Open…</a>
{% end %}
{% render('layout') %}

View File

@ -1,9 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<script src="/static/js/htmx.min.js"></script>
<script src="/static/js/_hyperscript.min.js"></script>
<title>Everything is Peachy</title>
<link rel="stylesheet" href="/static/css/site.css">
{% if block.styles then for _, style in ipairs(block.styles) do %}
<link rel="stylesheet" href="{%& style %}">
{% end end %}
</head>
<body>
<h1>Peachy</h1>
{% function block.pagebody() %}
<h1>It works!</h1>
<p>But something seems to be missing…</p>

View File

@ -1,4 +1,15 @@
{% block.styles = { "/static/css/filepicker.css" } %}
{% function block.pagebody() %}
<p>Please select a database file to load.</p>
<form action="/open" method=POST>
<input id="filename-input" name="filename" value="{%& filename %}">
<input type="submit">
</form>
<div
class="filepicker"
hx-get="/dirlist?dirpath=/"
hx-trigger="load"
_="on change(target)[target.type=='radio'] set #filename-input.value to target.value">
</div>
{% end %}
{% render('layout') %}