aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/index.html
blob: e67f5826241a923b99b7f775e0ea146fab14fae2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!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">
            <option value="a4paper">A4</option>
            <option value="letterpaper">US Letter</option>
            <option value="legalpaper">US Legal</option>
          </select>

          <label for="margin">Margins</label>
          <select id="margin" name="margin">
            <option value="0.75in">Narrow (0.75in)</option>
            <option value="1in" selected>Normal (1in)</option>
            <option value="1.25in">Comfort (1.25in)</option>
            <option value="1.5in">Wide (1.5in)</option>
          </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="/static/main.js"></script>
  </body>
</html>