Update web/templates/entry_view.html

This commit is contained in:
Joshua Laymon 2025-08-15 22:59:30 +00:00
parent 6b257012f3
commit b3e9b222c9

View File

@ -25,8 +25,23 @@
<button class="btn btn-lg btn-primary" {% if position >= count %}disabled{% endif %}>Next </button> <button class="btn btn-lg btn-primary" {% if position >= count %}disabled{% endif %}>Next </button>
</form> </form>
<!-- Share button (copies Illustration + two spaces + Application) -->
<button id="share-btn" class="btn btn-lg btn-primary" type="button" title="Copy to clipboard" style="margin-left:6px;">
<span style="display:flex;align-items:center;gap:6px;">
<!-- iOS-like share icon (SVG) -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
viewBox="0 0 16 16" aria-hidden="true" focusable="false" fill="currentColor">
<path d="M8 1a.5.5 0 0 1 .5.5V9a.5.5 0 0 1-1 0V1.5A.5.5 0 0 1 8 1z"/>
<path d="M5.646 3.646a.5.5 0 0 1 .708 0L8 5.293l1.646-1.647a.5.5 0 0 1 .708.708L8.354 6.354a.5.5 0 0 1-.708 0L5.646 4.354a.5.5 0 0 1 0-.708z"/>
<path d="M4.5 6A1.5 1.5 0 0 0 3 7.5v5A1.5 1.5 0 0 0 4.5 14h7A1.5 1.5 0 0 0 13 12.5v-5A1.5 1.5 0 0 0 11.5 6H10a.5.5 0 0 0 0 1h1.5a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-.5.5h-7a.5.5 0 0 1-.5-.5v-5a.5.5 0 0 1 .5-.5H6a.5.5 0 0 0 0-1H4.5z"/>
</svg>
Share
</span>
</button>
{% if user.is_authenticated and user.is_staff %} {% if user.is_authenticated and user.is_staff %}
<a class="btn btn-outline" href="{% url 'entry_edit' entry.id %}">Unlock / Edit</a> <!-- Just the label changed to 'Edit'; link unchanged -->
<a class="btn btn-outline" href="{% url 'entry_edit' entry.id %}">Edit</a>
<a class="btn btn-danger" href="{% url 'entry_delete' entry.id %}">Delete</a> <a class="btn btn-danger" href="{% url 'entry_delete' entry.id %}">Delete</a>
{% endif %} {% endif %}
</div> </div>
@ -53,7 +68,7 @@
<!-- ILLUSTRATION --> <!-- ILLUSTRATION -->
<div class="section"> <div class="section">
<div class="section-label">Illustration</div> <div class="section-label">Illustration</div>
<div class="section-body lead-text"> <div class="section-body lead-text" id="illustration-text">
{{ entry.illustration|linebreaksbr|default:"—" }} {{ entry.illustration|linebreaksbr|default:"—" }}
</div> </div>
</div> </div>
@ -61,7 +76,7 @@
<!-- APPLICATION --> <!-- APPLICATION -->
<div class="section"> <div class="section">
<div class="section-label">Application</div> <div class="section-label">Application</div>
<div class="section-body lead-text"> <div class="section-body lead-text" id="application-text">
{{ entry.application|linebreaksbr|default:"—" }} {{ entry.application|linebreaksbr|default:"—" }}
</div> </div>
</div> </div>
@ -127,6 +142,14 @@
</div> </div>
<!-- Toast for copy confirmation -->
<div id="copy-toast"
style="position:fixed;bottom:20px;left:50%;transform:translateX(-50%);
background:#333;color:#fff;padding:10px 16px;border-radius:6px;
font-size:14px;display:none;z-index:9999;">
The Illustration was copied to the clipboard
</div>
<style> <style>
.subject-pills{ .subject-pills{
display:flex; display:flex;
@ -150,4 +173,54 @@
border-color:#c9def5; border-color:#c9def5;
} }
</style> </style>
<script>
// Robust copy to clipboard that works on HTTP and HTTPS
(function () {
function copyText(text) {
// Try modern API first
if (navigator.clipboard && window.isSecureContext) {
return navigator.clipboard.writeText(text);
}
// Fallback: temporary textarea
return new Promise(function (resolve, reject) {
try {
var ta = document.createElement('textarea');
ta.value = text;
// Avoid scrolling to bottom
ta.style.position = 'fixed';
ta.style.top = '-1000px';
ta.style.left = '-1000px';
document.body.appendChild(ta);
ta.focus();
ta.select();
var ok = document.execCommand('copy');
document.body.removeChild(ta);
ok ? resolve() : reject(new Error('execCommand failed'));
} catch (e) {
reject(e);
}
});
}
function showToast() {
var toast = document.getElementById('copy-toast');
if (!toast) return;
toast.style.display = 'block';
clearTimeout(showToast._t);
showToast._t = setTimeout(function(){ toast.style.display = 'none'; }, 5000);
}
var btn = document.getElementById('share-btn');
if (!btn) return;
btn.addEventListener('click', function () {
var ill = (document.getElementById('illustration-text')?.innerText || '').trim();
var app = (document.getElementById('application-text')?.innerText || '').trim();
var text = ill + ' ' + app; // two spaces
copyText(text).then(showToast).catch(function (err) {
alert('Failed to copy: ' + err);
});
});
})();
</script>
{% endblock %} {% endblock %}