marky

Lightweight bookmarking + plaintext archive
Log | Files | Refs | README | LICENSE

commit a3cb080d904d745f1b71c2e0bc250756358e960f
parent 757d7929b147e6e403ff5412f999d34364d6383e
Author: David Eisinger <[email protected]>
Date:   Wed,  7 Jan 2026 10:17:27 -0500

Add button to paste referrer from clipboard

Diffstat:
Minternal/api.go | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/internal/api.go b/internal/api.go @@ -174,9 +174,12 @@ func NewHandlerWithConfig(db *DB, cfg HandlerConfig) (http.Handler, error) { label{display:block;margin:8px 0} input[type=text], textarea{width:100%%;box-sizing:border-box;padding:8px;border:1px solid #ccc;border-radius:6px} textarea{min-height:100px;resize:vertical} + .inline-row{display:flex;gap:8px;align-items:center} + .inline-row input{flex:1} .actions{margin-top:12px;display:flex;gap:8px} button{background:#222;color:#fff;border:0;border-radius:6px;padding:8px 12px;cursor:pointer} button.secondary{background:#eee;color:#222} + button.inline{padding:8px 12px} .small{color:#666;font-size:12px;margin-top:6px} .success{color:green} .error{color:#b00020} @@ -193,7 +196,10 @@ func NewHandlerWithConfig(db *DB, cfg HandlerConfig) (http.Handler, error) { <textarea id="desc">%[3]s</textarea> </label> <label>Referrer - <input id="ref" type="text" value="%[8]s" placeholder="https://site-that-linked-here.example"> + <span class="inline-row"> + <input id="ref" type="text" value="%[8]s" placeholder="https://site-that-linked-here.example"> + <button id="refPaste" class="secondary inline" type="button">Paste</button> + </span> </label> <label><input id="pub" type="checkbox" %[4]s> Public</label> <div class="actions"> @@ -209,6 +215,17 @@ func NewHandlerWithConfig(db *DB, cfg HandlerConfig) (http.Handler, error) { const uname = %[7]s; const form = document.getElementById('f'); const msg = document.getElementById('msg'); + const refInput = document.getElementById('ref'); + const refPaste = document.getElementById('refPaste'); + refPaste.addEventListener('click', async function(){ + try { + const text = await navigator.clipboard.readText(); + refInput.value = (text || '').trim(); + refInput.focus(); + } catch (err) { + alert('Paste failed'); + } + }); form.addEventListener('submit', async function(e){ e.preventDefault(); msg.textContent = '';