summaryrefslogtreecommitdiffstats
path: root/views/admin
diff options
context:
space:
mode:
authorKen <ken@jots.org>2026-05-09 04:41:03 +0000
committerKen <ken@jots.org>2026-05-09 04:41:03 +0000
commitc75beda743dfd6af63f512e928d0889d9ead3973 (patch)
treebed91fd4f9d36a905be0b1ef990457a1e37e567b /views/admin
Initial commit — Albumen photo album
Ruby/Sinatra self-hosted photo album with directory hierarchy, per-photo captions and visibility, lightbox, slideshow, admin UI, and Let's Encrypt HTTPS via Apache reverse proxy on prouter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'views/admin')
-rw-r--r--views/admin/album.erb101
-rw-r--r--views/admin/login.erb14
2 files changed, 115 insertions, 0 deletions
diff --git a/views/admin/album.erb b/views/admin/album.erb
new file mode 100644
index 0000000..f6b80d6
--- /dev/null
+++ b/views/admin/album.erb
@@ -0,0 +1,101 @@
+<div class="admin-album">
+ <div class="admin-nav">
+ <% if @rel.empty? %>
+ <a href="/browse/" class="btn btn-sm">View Root</a>
+ <% else %>
+ <% parent = @rel.include?('/') ? @rel.split('/')[0..-2].join('/') : '' %>
+ <a href="/admin/edit/<%= parent %>" class="btn btn-sm">← Parent</a>
+ <a href="/browse/<%= @rel %>" class="btn btn-sm">View Album</a>
+ <% end %>
+ </div>
+
+ <h1>Edit: <%= @title %></h1>
+
+ <form method="post" action="/admin/edit/<%= @rel %>">
+ <fieldset class="album-settings">
+ <legend>Album</legend>
+ <div class="form-row">
+ <label>Title override
+ <input type="text" name="album_title" value="<%= @data['title'] %>" placeholder="(use directory name)">
+ </label>
+ </div>
+ <div class="form-row">
+ <label>Description
+ <textarea name="album_description" rows="2"><%= @data['description'] %></textarea>
+ </label>
+ </div>
+ <div class="form-row form-row-inline">
+ <label>Cover image
+ <select name="album_cover">
+ <option value="">— auto (first image) —</option>
+ <% @files.each do |name| %>
+ <option value="<%= name %>"<%= ' selected' if @data['cover'] == name %>><%= name %></option>
+ <% end %>
+ </select>
+ </label>
+ <label class="checkbox-label">
+ <input type="checkbox" name="album_cover_dynamic" value="1"<%= ' checked' if @data['cover_dynamic'] %>>
+ Dynamic cover
+ </label>
+ <label class="checkbox-label">
+ <input type="checkbox" name="album_sort_reverse" value="1"<%= ' checked' if @data['sort_reverse'] %>>
+ Reverse sub-album order
+ </label>
+ <label class="checkbox-label">
+ <input type="hidden" name="album_visible" value="0">
+ <input type="checkbox" name="album_visible" value="1"<%= ' checked' if @data['visible'] != false %>>
+ Visible
+ </label>
+ </div>
+ </fieldset>
+
+ <% unless @files.empty? %>
+ <div class="files-section">
+ <h2>Files</h2>
+ <table class="files-table">
+ <thead>
+ <tr>
+ <th>Thumb</th>
+ <th>Filename</th>
+ <th>Title</th>
+ <th>Caption</th>
+ <th>Visible</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @files.each do |name| %>
+ <% meta = (@data['files'] || {})[name] || {} %>
+ <% file_rel = @rel.empty? ? name : "#{@rel}/#{name}" %>
+ <tr>
+ <td><img src="/thumb/<%= file_rel %>" width="60" height="60" loading="lazy" style="object-fit:cover"></td>
+ <td class="filename"><code><%= name %></code></td>
+ <td><input type="text" name="file_title[<%= name %>]" value="<%= ERB::Util.html_escape(meta['title'].to_s) %>" placeholder="<%= ERB::Util.html_escape(name) %>"></td>
+ <td><input type="text" name="file_caption[<%= name %>]" value="<%= ERB::Util.html_escape(meta['caption'].to_s) %>" placeholder="caption…"></td>
+ <td class="visible-cell">
+ <input type="hidden" name="file_visible[<%= name %>]" value="0">
+ <input type="checkbox" name="file_visible[<%= name %>]" value="1"<%= ' checked' if meta['visible'] != false %>>
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+ <% end %>
+
+ <div class="form-actions">
+ <button type="submit" class="btn">Save</button>
+ </div>
+ </form>
+
+ <% unless @sub_dirs.empty? %>
+ <section class="sub-albums-section">
+ <h2>Sub-albums</h2>
+ <ul class="sub-album-list">
+ <% @sub_dirs.each do |name| %>
+ <% sub_rel = @rel.empty? ? name : "#{@rel}/#{name}" %>
+ <li><a href="/admin/edit/<%= sub_rel %>"><%= name %></a></li>
+ <% end %>
+ </ul>
+ </section>
+ <% end %>
+</div>
diff --git a/views/admin/login.erb b/views/admin/login.erb
new file mode 100644
index 0000000..16f12d2
--- /dev/null
+++ b/views/admin/login.erb
@@ -0,0 +1,14 @@
+<div class="admin-login">
+ <h1>Admin Login</h1>
+ <% if defined?(@error) && @error %>
+ <p class="form-error"><%= @error %></p>
+ <% end %>
+ <form method="post" action="/admin/login">
+ <input type="hidden" name="return_to" value="<%= ERB::Util.html_escape(params['return_to'].to_s) %>">
+ <label>
+ Password
+ <input type="password" name="password" autofocus autocomplete="current-password">
+ </label>
+ <button type="submit" class="btn">Login</button>
+ </form>
+</div>