From 7f6325fe213ed46ff5479ffd34b0e212426d48f2 Mon Sep 17 00:00:00 2001 From: Ken D'Ambrosio Date: Mon, 8 Jun 2026 21:09:47 +0000 Subject: Add people cluster detail page with face move/merge and hover preview Each cluster in /admin/people now links to a detail page showing all faces in a grid. From there you can rename the cluster, move individual faces to another named person (or spin off a new cluster), or merge the entire cluster into another. Hovering any face crop shows the original full photo for context. Co-Authored-By: Claude Sonnet 4.6 --- app.rb | 77 ++++++++++++++++++++++++++++++ public/css/style.css | 32 +++++++++++++ views/admin/people.erb | 31 +++++++++++- views/admin/person_detail.erb | 107 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 views/admin/person_detail.erb diff --git a/app.rb b/app.rb index 3978c54..7ce9d22 100644 --- a/app.rb +++ b/app.rb @@ -895,6 +895,83 @@ post '/admin/people/:uuid' do redirect '/admin/people' end +get '/admin/people/:uuid' do + require_admin! + data = load_people_data + people = data['people'] || {} + halt 404 unless people.key?(params[:uuid]) + + pd = people[params[:uuid]] + @title = pd['name'] || 'Unnamed cluster' + @uuid = params[:uuid] + @name = pd['name'] + @members = pd['members'] || [] + @count = @members.length + + @named_others = people + .reject { |k, _| k == params[:uuid] } + .select { |_, v| v['name'] } + .map { |k, v| { uuid: k, name: v['name'] } } + .sort_by { |x| x[:name].downcase } + + @all_others = people + .reject { |k, _| k == params[:uuid] } + .map { |k, v| { uuid: k, name: v['name'] || "(unnamed · #{(v['members'] || []).length})" } } + .sort_by { |x| x[:name].downcase } + + erb :'admin/person_detail' +end + +post '/admin/people/:uuid/move' do + require_admin! + src = params[:uuid] + rel = params['rel'] + box = JSON.parse(params['box']).map(&:to_i) + to = params['to'].to_s.strip + + return redirect "/admin/people/#{src}" if to.empty? + + data = load_people_data + people = data['people'] || {} + halt 404 unless people.key?(src) + + member = people[src]['members'].find { |m| m['rel'] == rel && m['box'].map(&:to_i) == box } + halt 404 unless member + people[src]['members'].delete(member) + + if to == 'new' + new_uid = SecureRandom.uuid + people[new_uid] = { 'name' => nil, 'slug' => nil, 'members' => [member] } + else + halt 404 unless people.key?(to) + people[to]['members'] << member + end + + data['people'] = people + atomic_write(PEOPLE_PATH, JSON.pretty_generate(data)) + + people[src] ? redirect("/admin/people/#{src}") : redirect('/admin/people') +end + +post '/admin/people/:uuid/merge' do + require_admin! + src = params[:uuid] + into = params['into'].to_s.strip + + return redirect '/admin/people' if into.empty? + + data = load_people_data + people = data['people'] || {} + halt 404 unless people.key?(src) && people.key?(into) + + people[into]['members'].concat(people[src]['members']) + people.delete(src) + data['people'] = people + + atomic_write(PEOPLE_PATH, JSON.pretty_generate(data)) + redirect "/admin/people/#{into}" +end + get '/people' do data = load_people_data people = (data['people'] || {}).select { |_, p| p['name'] && p['slug'] } diff --git a/public/css/style.css b/public/css/style.css index 47147f4..7b0ce1a 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -477,6 +477,38 @@ tr.delete-marked td { background: rgba(192,57,43,.08); } } .name-input:focus { border-color: var(--accent); outline: none; } +/* ── People — detail page ──────────────────────────────────────────────── */ +.face-detail-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); + gap: 10px; + margin-top: 16px; +} +.face-detail-card { + background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); + padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; +} +.face-detail-thumb img { border-radius: 50%; object-fit: cover; display: block; } +.face-detail-thumb a { display: block; line-height: 0; cursor: zoom-in; } +.face-move-form { display: flex; flex-direction: column; gap: 4px; width: 100%; } +.face-move-select { + width: 100%; + background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); + color: var(--text); padding: 3px 6px; font-size: .75rem; cursor: pointer; +} +.face-move-select:focus { border-color: var(--accent); outline: none; } + +/* Shared hover preview (face crops) */ +#face-hover-preview { + display: none; position: fixed; z-index: 9999; pointer-events: none; + padding: 4px; border: 2px solid var(--border); border-radius: var(--radius); + background: var(--bg2); box-shadow: 0 8px 24px rgba(0,0,0,.6); +} +#face-hover-preview img { + display: block; width: 300px; height: 300px; object-fit: cover; + border-radius: calc(var(--radius) - 2px); +} + /* ── People — public ───────────────────────────────────────────────────── */ .people-grid { margin-top: 8px; } diff --git a/views/admin/people.erb b/views/admin/people.erb index 6b7a4d0..c17e847 100644 --- a/views/admin/people.erb +++ b/views/admin/people.erb @@ -37,10 +37,14 @@
<% c[:samples].each do |s| %> + width="72" height="72" loading="lazy" + class="face-list-thumb" + data-thumb="/thumb/<%= ERB::Util.html_escape(s[:rel]) %>"> <% end %> <% if c[:count] > c[:samples].length %> - +<%= c[:count] - c[:samples].length %> + + +<%= c[:count] - c[:samples].length %> more + <% end %>
@@ -54,6 +58,7 @@ <% end %> + View all
<% end %> @@ -66,7 +71,29 @@ <% end %> +
+ -- cgit v1.2.3