From c76ea393777897e0c367e186d1a3b243193d8377 Mon Sep 17 00:00:00 2001 From: Ken D'Ambrosio Date: Thu, 14 May 2026 22:59:59 +0000 Subject: Hide transcoded originals from non-admins; mark them visually for admins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update.rb records transcoded_to in album.json (even on re-runs where the MP4 already exists) so the marker survives across scans. app.rb filters files with transcoded_to from non-admin views. album.erb renders them greyed-out with an amber "⚠ original" badge in admin mode. admin/album.erb marks the edit-table row and shows the target filename under the original. Co-Authored-By: Claude Sonnet 4.6 --- app.rb | 28 +++++++++++++++------------- public/css/style.css | 8 ++++++++ scripts/update.rb | 13 +++++++++---- views/admin/album.erb | 7 +++++-- views/album.erb | 3 ++- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/app.rb b/app.rb index af18d44..ff7740c 100644 --- a/app.rb +++ b/app.rb @@ -90,20 +90,22 @@ helpers do entries = files.filter_map do |name| meta = (data['files'] || {})[name] || {} next if meta['visible'] == false && !admin? + next if meta['transcoded_to'] && !admin? { - name: name, - title: meta['title'] || name, - caption: meta['caption'], - visible: meta.fetch('visible', true), - type: media_type_for(name), - taken_at: meta['taken_at'], - width: meta['width'], - height: meta['height'], - duration: meta['duration'], - camera: meta['camera'], - aperture: meta['aperture'], - shutter: meta['shutter'], - iso: meta['iso'], + name: name, + title: meta['title'] || name, + caption: meta['caption'], + visible: meta.fetch('visible', true), + type: media_type_for(name), + taken_at: meta['taken_at'], + width: meta['width'], + height: meta['height'], + duration: meta['duration'], + camera: meta['camera'], + aperture: meta['aperture'], + shutter: meta['shutter'], + iso: meta['iso'], + transcoded_to: meta['transcoded_to'], } end diff --git a/public/css/style.css b/public/css/style.css index 41dfd0a..062b187 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -379,6 +379,14 @@ legend { padding: 0 8px; color: var(--text-dim); font-size: .85rem; } .files-table { font-size: .78rem; } } +/* ── Unplayable originals (admin-only) ─────────────────────────────────── */ +.unplayable-original { opacity: .45; } +.unplayable-badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.7); + color: #f0a500; font-size: .68rem; padding: 2px 5px; + border-radius: 3px; pointer-events: none; } +tr.original-file td { opacity: .5; } +.transcoded-label { display: block; font-size: .72rem; color: #c07000; font-style: italic; margin-top: 2px; } + /* ── Admin delete ──────────────────────────────────────────────────────── */ .delete-cell { text-align: center; } .delete-check { accent-color: #c0392b; width: 16px; height: 16px; cursor: pointer; } diff --git a/scripts/update.rb b/scripts/update.rb index a4969d3..9953505 100644 --- a/scripts/update.rb +++ b/scripts/update.rb @@ -64,16 +64,21 @@ def process_dir(dir) .each do |name| base = File.basename(name, '.*') target = "#{base}.mp4" - next if current.include?(target) # already transcoded on a previous run + if current.include?(target) + # MP4 already exists — just ensure the marker is recorded + data['files'][name] ||= {} + data['files'][name]['transcoded_to'] = target + next + end full = File.join(dir, name) dest = File.join(dir, target) puts " Transcoding: #{name} → #{target}" transcode_to_mp4(full, dest) if File.exist?(dest) data['files'][name] ||= {} - data['files'][name]['visible'] ||= false # hide original; admin can override - current << target # include in processing pass below - puts " → done (original hidden)" + data['files'][name]['transcoded_to'] = target + current << target + puts " → done" else warn " Transcode failed: #{name}" end diff --git a/views/admin/album.erb b/views/admin/album.erb index f28d515..15a043f 100644 --- a/views/admin/album.erb +++ b/views/admin/album.erb @@ -70,9 +70,12 @@ <% @files.each do |name| %> <% meta = (@data['files'] || {})[name] || {} %> <% file_rel = @rel.empty? ? name : "#{@rel}/#{name}" %> - + > - <%= name %> + + <%= name %> + <% if meta['transcoded_to'] %>→ <%= meta['transcoded_to'] %><% end %> + diff --git a/views/album.erb b/views/album.erb index 8577bdb..64bf763 100644 --- a/views/album.erb +++ b/views/album.erb @@ -54,7 +54,7 @@
<% @entries.each_with_index do |e, i| %> <% file_rel = @rel.empty? ? e[:name] : "#{@rel}/#{e[:name]}" %> -
<% end %> <% if e[:type] == :video && e[:duration] %><%= format_duration(e[:duration]) %><% end %> <% if e[:type] == :audio %><% end %> + <% if e[:transcoded_to] %>⚠ original<% end %>
<% if e[:caption] %>

<%= e[:caption] %>

-- cgit v1.2.3