summaryrefslogtreecommitdiffstats
path: root/app.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app.rb')
-rw-r--r--app.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app.rb b/app.rb
index 6b11d5d..a923b4d 100644
--- a/app.rb
+++ b/app.rb
@@ -23,7 +23,8 @@ VIDEO_EXTS = %w[mp4 mov avi mkv webm m4v ogv].freeze
AUDIO_EXTS = %w[mp3 flac ogg wav m4a aac].freeze
MEDIA_EXTS = (IMAGE_EXTS + VIDEO_EXTS + AUDIO_EXTS).freeze
-APP_CONFIG = (File.exist?(CONFIG_PATH) ? YAML.load_file(CONFIG_PATH, symbolize_names: true) : {}).freeze
+APP_CONFIG = (File.exist?(CONFIG_PATH) ? YAML.load_file(CONFIG_PATH, symbolize_names: true) : {}).freeze
+FACES_ENABLED = (APP_CONFIG.dig(:faces, :enabled) == true).freeze
# ── Sinatra config ─────────────────────────────────────────────────────────────
@@ -83,7 +84,17 @@ helpers do
{ 'files' => {}, 'visible' => true }
end
+ def load_faces(dir)
+ path = File.join(dir, 'faces.json')
+ return {} unless File.exist?(path)
+ JSON.parse(File.read(path))
+ rescue JSON::ParserError
+ {}
+ end
+
def album_files(dir, data)
+ face_data = FACES_ENABLED ? load_faces(dir) : {}
+
files = Dir.children(dir)
.sort
.select { |n| MEDIA_EXTS.include?(File.extname(n).downcase.delete_prefix('.')) }
@@ -107,6 +118,7 @@ helpers do
shutter: meta['shutter'],
iso: meta['iso'],
transcoded_to: meta['transcoded_to'],
+ faces: face_data[name],
}
end