diff --git a/web/templates/search.html b/web/templates/search.html index fa80d63..cadeda9 100644 --- a/web/templates/search.html +++ b/web/templates/search.html @@ -4,8 +4,6 @@ {% block content %}
- -

Illustration Search

@@ -51,8 +49,6 @@ {% endfor %}
- -
{% if ran_search and result_count == 0 %} @@ -62,25 +58,33 @@
{% endif %} - -
-

Search History

-
+ +
+ - -
-
Your Recent Searches
-
    - -
    +
    @@ -95,7 +99,6 @@ const csrftoken = getCookie('csrftoken'); // Helper: build entry view URL from a known-good template - // We grab a real URL like /entry/1/ and swap the trailing number with the actual id. const ENTRY_URL_TEMPLATE = "{% url 'entry_view' 1 %}"; function entryUrlFor(id){ return ENTRY_URL_TEMPLATE.replace(/\/\d+\/?$/, '/' + id + '/'); @@ -134,7 +137,20 @@ }); }); - // --- Search history: fetch + render (unchanged) --- + // --- Collapsible History toggle --- + const toggle = document.getElementById('historyToggle'); + const body = document.getElementById('historyBody'); + if (toggle && body){ + toggle.addEventListener('click', ()=>{ + const isOpen = !body.hidden; + body.hidden = isOpen; + toggle.setAttribute('aria-expanded', String(!isOpen)); + const chev = toggle.querySelector('.chev'); + if (chev) chev.textContent = isOpen ? '▸' : '▾'; + }); + } + + // --- Search history: fetch + render --- const histList = document.getElementById('searchHistoryList'); const histEmpty = document.getElementById('searchHistoryEmpty'); function renderHistory(items){ @@ -156,7 +172,7 @@ if (j.ok) renderHistory(j.items); }).catch(()=>{}); - // --- Recently viewed: fetch + render (FIXED link + 20-word snippet) --- + // --- Recently viewed: fetch + render (keeps snippet + fixed link) --- const rvList = document.getElementById('recentViewsList'); const rvEmpty = document.getElementById('recentViewsEmpty'); function renderRecent(items){ @@ -166,8 +182,8 @@ items.forEach(it=>{ const url = entryUrlFor(it.entry_id); const snippet = (it.snippet && it.snippet.trim()) - || firstWords(it.illustration || '', 20) - || `Entry #${it.entry_id}`; + || firstWords(it.illustration || '', 20) + || `Entry #${it.entry_id}`; const when = new Date(it.viewed_at); const li = document.createElement('li'); li.innerHTML = `${snippet} @@ -179,7 +195,7 @@ if (j.ok) renderRecent(j.items); }).catch(()=>{}); - // --- Log searches reliably using Beacon on submit (unchanged) --- + // --- Log searches reliably using Beacon on submit --- const searchForm = document.querySelector('form.search-form'); if (searchForm){ searchForm.addEventListener('submit', ()=>{ @@ -187,7 +203,6 @@ const fd = new FormData(searchForm); const data = new URLSearchParams(); data.append('q', (fd.get('q') || '').trim()); - // selected checkboxes (match your field names) ['subject','illustration','application','scripture_raw','source','talk_title','talk_number','entry_code'] .forEach(k=>{ if (fd.get(k)) data.append(`sel[${k}]`, 'on'); @@ -200,7 +215,7 @@ })(); - + - +