aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates
diff options
context:
space:
mode:
authorkj_sh6042026-02-16 01:42:50 -0500
committerkj_sh6042026-02-16 01:42:50 -0500
commitafd82dc38510c6a47cfa227f40f1dae76e1a526c (patch)
tree6182294363a0599e2b07e5d0675fc1a8ccf5fc01 /src/templates
parent94c6fdd12c8352f26df112f1c21592b020bb7c06 (diff)
refactor: move to src/
Diffstat (limited to 'src/templates')
-rw-r--r--src/templates/index.html96
-rw-r--r--src/templates/partials/error.html4
-rw-r--r--src/templates/partials/result.html5
-rw-r--r--src/templates/partials/upload_error.html4
-rw-r--r--src/templates/partials/upload_result.html12
5 files changed, 121 insertions, 0 deletions
diff --git a/src/templates/index.html b/src/templates/index.html
new file mode 100644
index 0000000..42f5f5c
--- /dev/null
+++ b/src/templates/index.html
@@ -0,0 +1,96 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <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>
+ .htmx-indicator {
+ display: none;
+ }
+
+ .htmx-request .htmx-indicator,
+ .htmx-request.htmx-indicator {
+ display: inline;
+ }
+ </style>
+ </head>
+ <body>
+ <main>
+ <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"><strong>textarea</strong></label>
+ <textarea
+ id="markdown"
+ name="markdown"
+ rows="16"
+ placeholder="markdown goes here..."
+ required
+ ></textarea>
+
+ <section>
+ <h3>pdf options</h3>
+
+ <label for="paper_size">Paper size</label>
+ <select id="paper_size" name="paper_size">
+ {% for key, label in paper_sizes.items() %}
+ <option value="{{ key }}">{{ label }}</option>
+ {% endfor %}
+ </select>
+
+ <label for="margin">Margins</label>
+ <select id="margin" name="margin">
+ {% for key, label in margins.items() %}
+ <option value="{{ key }}" {% if key == "1in" %}selected{% endif %}>{{ label }}</option>
+ {% endfor %}
+ </select>
+
+ <fieldset>
+ <legend>main font</legend>
+ <label>
+ <input type="radio" name="main_font" value="serif" checked /> serif
+ </label>
+ <label>
+ <input type="radio" name="main_font" value="sans" /> sans-serif
+ </label>
+ </fieldset>
+ </section>
+
+ <button id="convert-button" type="submit">generate pdf</button>
+ <small id="loading" class="htmx-indicator">converting…</small>
+ </form>
+
+ <section id="result" aria-live="polite"></section>
+ </main>
+
+ <script src="{{ url_for('static', filename='main.js') }}"></script>
+ </body>
+</html>
diff --git a/src/templates/partials/error.html b/src/templates/partials/error.html
new file mode 100644
index 0000000..83825f1
--- /dev/null
+++ b/src/templates/partials/error.html
@@ -0,0 +1,4 @@
+<article>
+ <h3>Conversion failed</h3>
+ <pre>{{ message }}</pre>
+</article>
diff --git a/src/templates/partials/result.html b/src/templates/partials/result.html
new file mode 100644
index 0000000..427382d
--- /dev/null
+++ b/src/templates/partials/result.html
@@ -0,0 +1,5 @@
+<article>
+ <h3>pdf ready</h3>
+ <p><strong>{{ filename }}</strong></p>
+ <a href="{{ download_url }}">download pdf</a>
+</article>
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>