feat: add darktable web API interface with gallery, image detail, and settings screens
- Implemented main entry point for React application in `main.jsx`. - Created `Gallery` component for displaying images with infinite scroll and pull-to-refresh functionality. - Developed `ImageDetail` component for showing detailed information and actions for selected images. - Added `Settings` component for configuring API connection settings. - Integrated Vite for build and development with PWA support. - Implemented caching strategies for API responses and image previews using Workbox.
This commit is contained in:
@@ -92,17 +92,58 @@ local function drain_queue()
|
||||
return ids
|
||||
end
|
||||
|
||||
-- ── Mipmap directory ─────────────────────────────────────────────────────────
|
||||
|
||||
-- Darktable's mipmap_cache->cachedir is not directly accessible from Lua, so
|
||||
-- we replicate the naming: SHA1 hex of realpath(library.db) + ".d".
|
||||
-- We compute it once and cache it here.
|
||||
local _mipmap_cachedir
|
||||
|
||||
|
||||
local function mipmap_cachedir()
|
||||
if _mipmap_cachedir then return _mipmap_cachedir end
|
||||
local cache_dir = os.getenv("DT_CACHE_DIR")
|
||||
if not cache_dir then
|
||||
local home = os.getenv("HOME") or "~"
|
||||
cache_dir = home .. "/.cache/darktable"
|
||||
end
|
||||
-- There is exactly one mipmaps-<sha1>.d directory per library.
|
||||
-- Find it by globbing rather than recomputing the SHA1.
|
||||
local h = io.popen(string.format("ls -d %q/mipmaps-*.d 2>/dev/null | head -1", cache_dir))
|
||||
local found = h and h:read("*l"); if h then h:close() end
|
||||
if found and #found > 0 then
|
||||
-- Strip trailing ".d" to get the base prefix used in file paths.
|
||||
_mipmap_cachedir = found:match("^(.+)%.d$") or found
|
||||
log("mipmap cachedir: " .. _mipmap_cachedir .. ".d")
|
||||
return _mipmap_cachedir
|
||||
end
|
||||
log("WARNING: could not find mipmap cache directory under " .. cache_dir)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Delete all mipmap disk files for an image so generate_cache regenerates them.
|
||||
local function delete_mipmap_files(imgid)
|
||||
local base = mipmap_cachedir()
|
||||
if not base then return end
|
||||
for level = 0, 8 do
|
||||
local path = string.format("%s.d/%d/%d.jpg", base, level, imgid)
|
||||
os.remove(path)
|
||||
end
|
||||
end
|
||||
|
||||
-- ── Cache regeneration ────────────────────────────────────────────────────────
|
||||
|
||||
local function refresh_image(img)
|
||||
local label = string.format("id=%d %s/%s", img.id, img.path, img.filename)
|
||||
log("refreshing " .. label)
|
||||
|
||||
-- Remove disk mipmap files first so generate_cache doesn't skip any level.
|
||||
-- drop_cache() only clears the in-memory entry; existing disk files would
|
||||
-- cause generate_cache to skip those levels (it guards with dt_util_test_image_file).
|
||||
delete_mipmap_files(img.id)
|
||||
img:drop_cache()
|
||||
|
||||
-- full=true forces darktable to re-process through its complete rendering
|
||||
-- pipeline (tone curves, exposure, colour grading, etc.) instead of using
|
||||
-- the stale embedded EXIF thumbnail from the source file.
|
||||
-- create_dirs=true ensures the per-level directories exist.
|
||||
img:generate_cache(true, MIP_MIN, MIP_MAX)
|
||||
|
||||
log("done " .. label)
|
||||
|
||||
Reference in New Issue
Block a user