summaryrefslogtreecommitdiffstats
path: root/app.rb
diff options
context:
space:
mode:
authorKen D'Ambrosio <ken@jots.org>2026-06-18 21:58:04 +0000
committerKen D'Ambrosio <ken@jots.org>2026-06-18 21:58:04 +0000
commitc5ec42b2f42e285a95610f1b9b9efba4beef3d7e (patch)
tree549fdff3243113484a840bf0bc631c65eda4fddc /app.rb
parent462e0081cc9062beb29530e84d15edf2003802db (diff)
Rename global search to "Album Search" and group results by album
Photo search was returning every individual matching photo, which was overkill for what's meant to be a quick way to find an album. /search now groups matches by album (cover thumbnail + match count) instead of listing each photo, and is relabeled "Album Search" throughout the UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app.rb')
-rw-r--r--app.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app.rb b/app.rb
index 7d6489a..c5f533b 100644
--- a/app.rb
+++ b/app.rb
@@ -556,15 +556,26 @@ end
get '/search' do
q = params[:q].to_s.strip
- @title = q.empty? ? 'Search' : "Search: #{q}"
+ @title = q.empty? ? 'Album Search' : "Album Search: #{q}"
@search_query = q
unless q.empty?
- ast = search_parse(q)
- index = search_index
- all = index.select { |d| (admin? || d[:visible]) && eval_search(ast, d[:text]) }
- @total = all.length
- @results = all.first(300)
+ ast = search_parse(q)
+ index = search_index
+ matched = index.select { |d| (admin? || d[:visible]) && eval_search(ast, d[:text]) }
+
+ by_dir = matched.each_with_object({}) { |d, h| (h[d[:dir_rel]] ||= []) << d }
+ @results = by_dir.map do |dir_rel, docs|
+ dir = dir_rel.empty? ? MEDIA_ROOT : File.join(MEDIA_ROOT, dir_rel)
+ data = load_album(dir)
+ {
+ dir_rel: dir_rel,
+ title: data['title'] || (dir_rel.empty? ? '(root)' : File.basename(dir_rel)),
+ cover: album_cover(dir, data),
+ count: docs.length,
+ }
+ end
+ @total = @results.length
end
erb :search