Improve search result page
This commit is contained in:
+20
-1
@@ -121,7 +121,9 @@
|
||||
// diary photo grids wrap each thumbnail in a .photo-grid anchor.
|
||||
// The left tree rail's file anchors (a.tree-file) join in too;
|
||||
// folder anchors there end in "/" and fall through to navigation.
|
||||
var anchor = e.target.closest('.list-item a, a.thumb-tile, .photo-grid a, aside.tree-sidebar a.tree-file');
|
||||
// Search file-result anchors join in too: page results end in "/"
|
||||
// and fall through to navigation, file results don't and open locally.
|
||||
var anchor = e.target.closest('.list-item a, a.thumb-tile, .photo-grid a, aside.tree-sidebar a.tree-file, .search-card a');
|
||||
if (!anchor) return;
|
||||
var item = anchor.closest('.list-item');
|
||||
// Only intercept the primary file link, and only for files (not folders).
|
||||
@@ -153,6 +155,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
function wireFileRevealButtons() {
|
||||
// Per-result "open location" buttons on the search page. Unlike the
|
||||
// page reveal button (which reveals window.location), each carries its
|
||||
// own file path so it reveals that specific file in its folder.
|
||||
if (!state.available) return;
|
||||
var btns = document.querySelectorAll('[data-companion-file-reveal]');
|
||||
btns.forEach(function (btn) {
|
||||
btn.hidden = false;
|
||||
btn.addEventListener('click', function () {
|
||||
var rel = btn.getAttribute('data-companion-file-reveal');
|
||||
if (!rel) return;
|
||||
companionGET('/open-folder', { path: rel }).catch(function () { });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function probeStatus() {
|
||||
return companionGET('/status').then(function (r) {
|
||||
if (!r.ok) throw new Error('status ' + r.status);
|
||||
@@ -171,6 +189,7 @@
|
||||
updateFooterIcon();
|
||||
wireFileLinks();
|
||||
wireRevealButton();
|
||||
wireFileRevealButtons();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+18
-4
@@ -4,15 +4,29 @@
|
||||
|
||||
{{define "content"}}
|
||||
{{if .Query}}
|
||||
{{if .Results}}
|
||||
<p class="muted">{{len .Results}} match{{if ne (len .Results) 1}}es{{end}} for “{{.Query}}”</p>
|
||||
<hr/>
|
||||
{{range .Results}}
|
||||
{{if or .Pages .Files}}
|
||||
{{if .Pages}}
|
||||
<h2 class="search-section">Matching Pages <span class="muted">{{.PageTotal}}</span></h2>
|
||||
{{range .Pages}}
|
||||
<article class="search-card">
|
||||
<a href="{{.URL}}">{{.Name}}</a>
|
||||
<div class="muted">/{{.Path}}</div>
|
||||
</article>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if .Files}}
|
||||
<h2 class="search-section">Matching Files <span class="muted">{{.FileTotal}}</span></h2>
|
||||
{{range .Files}}
|
||||
<article class="search-card">
|
||||
<div class="row">
|
||||
{{fileIcon .Name}}
|
||||
<a href="{{.URL}}">{{.Name}}</a>
|
||||
<button class="btn btn-small" data-companion-file-reveal="{{.Path}}" hidden title="Open location in file manager">open</button>
|
||||
</div>
|
||||
<div class="muted">/{{.Path}} · {{.Meta}}</div>
|
||||
</article>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
<p class="empty">No matches for “{{.Query}}”.</p>
|
||||
{{end}}
|
||||
|
||||
+4
-3
@@ -448,14 +448,15 @@ body.edit-mode footer { max-width: none; }
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
padding-bottom: var(--space-4);
|
||||
margin-bottom: var(--space-4);
|
||||
border-bottom: var(--border-dashed);
|
||||
word-break: break-word;
|
||||
}
|
||||
.search-card:last-child { border-bottom: none; }
|
||||
.search-card a { color: var(--link); font-size: 1.1rem; }
|
||||
.search-card a:hover { color: var(--link-hover); }
|
||||
.search-section {
|
||||
padding-bottom: var(--space-2);
|
||||
border-bottom: var(--border-dashed);
|
||||
}
|
||||
|
||||
/* === Floating action button ===
|
||||
Standalone FAB buttons (the tree rail, the right rail) are mobile-only and
|
||||
|
||||
Reference in New Issue
Block a user