aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/templates/index.html (renamed from templates/index.html)27
-rw-r--r--src/templates/partials/error.html (renamed from templates/partials/error.html)0
-rw-r--r--src/templates/partials/result.html (renamed from templates/partials/result.html)0
-rw-r--r--src/templates/partials/upload_error.html4
-rw-r--r--src/templates/partials/upload_result.html12
5 files changed, 39 insertions, 4 deletions
diff --git a/templates/index.html b/src/templates/index.html
index cd9c316..42f5f5c 100644
--- a/templates/index.html
+++ b/src/templates/index.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
- <title>Markdown to PDF</title>
+ <title>likha-pdf</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kj-sh604/noir.css@latest/out/noir.min.css" />
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
<style>
@@ -19,16 +19,35 @@
</head>
<body>
<main>
- <h1>markdown → pdf</h1>
+ <h1>likha-pdf</h1>
<p>simple markdown export with pandoc + lualatex.</p>
+ <section>
+ <h3>image upload</h3>
+ <form
+ id="upload-form"
+ hx-post="/upload-image"
+ hx-target="#upload-result"
+ hx-swap="innerHTML"
+ hx-encoding="multipart/form-data"
+ hx-indicator="#uploading"
+ >
+ <label for="image">image file</label>
+ <input id="image" name="image" type="file" accept="image/*" required />
+ <button id="upload-button" type="submit">upload image</button>
+ <small id="uploading" class="htmx-indicator">uploading…</small>
+ </form>
+ <div id="upload-result" aria-live="polite"></div>
+ </section>
+
<form
+ id="convert-form"
hx-post="/convert"
hx-target="#result"
hx-swap="innerHTML"
hx-indicator="#loading"
>
- <label for="markdown">Markdown</label>
+ <label for="markdown"><strong>textarea</strong></label>
<textarea
id="markdown"
name="markdown"
@@ -66,7 +85,7 @@
</section>
<button id="convert-button" type="submit">generate pdf</button>
- <small id="loading" class="htmx-indicator">Converting…</small>
+ <small id="loading" class="htmx-indicator">converting…</small>
</form>
<section id="result" aria-live="polite"></section>
diff --git a/templates/partials/error.html b/src/templates/partials/error.html
index 83825f1..83825f1 100644
--- a/templates/partials/error.html
+++ b/src/templates/partials/error.html
diff --git a/templates/partials/result.html b/src/templates/partials/result.html
index 427382d..427382d 100644
--- a/templates/partials/result.html
+++ b/src/templates/partials/result.html
diff --git a/src/templates/partials/upload_error.html b/src/templates/partials/upload_error.html
new file mode 100644
index 0000000..d219783
--- /dev/null
+++ b/src/templates/partials/upload_error.html
@@ -0,0 +1,4 @@
+<article>
+ <h4>upload failed</h4>
+ <pre>{{ message }}</pre>
+</article>
diff --git a/src/templates/partials/upload_result.html b/src/templates/partials/upload_result.html
new file mode 100644
index 0000000..116c74c
--- /dev/null
+++ b/src/templates/partials/upload_result.html
@@ -0,0 +1,12 @@
+<article>
+ <h4>image uploaded</h4>
+ <p><a href="{{ preview_url }}" target="_blank" rel="noreferrer">{{ filename }}</a></p>
+ <p><code id="uploaded-markdown">{{ markdown_snippet }}</code></p>
+ <button
+ type="button"
+ data-insert-markdown="{{ markdown_snippet }}"
+ class="insert-markdown"
+ >
+ insert into markdown
+ </button>
+</article>