Pick a DB file and store its name in session
This commit is contained in:
23
assets/tmpl/fragment/dirlist.tmpl
Normal file
23
assets/tmpl/fragment/dirlist.tmpl
Normal 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
4
assets/tmpl/home.tmpl
Normal file
@ -0,0 +1,4 @@
|
||||
{% function block.pagebody() %}
|
||||
<a href="/open">Open…</a>
|
||||
{% end %}
|
||||
{% render('layout') %}
|
@ -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>
|
||||
|
@ -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') %}
|
Reference in New Issue
Block a user