diff --git a/index.php b/index.php index 437711e..f7b7778 100644 --- a/index.php +++ b/index.php @@ -47,6 +47,16 @@ function hidden_video_outputs($config){ return $hidden; } +function map_hidden_outputs($config){ + $hidden = []; + foreach (glob($config['uploads_dir'].'/*', GLOB_ONLYDIR) ?: [] as $dir) { + if (!is_file($dir . '/.mvlog-hide-map')) continue; + $state = is_file($dir . '/.movmaker-state.json') ? json_decode((string)file_get_contents($dir . '/.movmaker-state.json'), true) : []; + if (is_array($state) && !empty($state['output'])) $hidden[basename((string)$state['output'])] = true; + } + return $hidden; +} + function video_metadata($path){ $base = pathinfo($path, PATHINFO_FILENAME); $meta = [ @@ -134,6 +144,7 @@ function load_video_cache($videos){ } $hiddenOutputs = hidden_video_outputs($config); +$hiddenMapOutputs = map_hidden_outputs($config); $videos = array_values(array_filter( glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: [], fn($v)=>empty($hiddenOutputs[basename($v)]) && !preg_match('/_preview\.(mp4|webm|mov|m4v)$/i', basename($v)) @@ -289,7 +300,8 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : []; ">" alt="Map"> diff --git a/new.php b/new.php index d367355..495d0a2 100644 --- a/new.php +++ b/new.php @@ -5,6 +5,7 @@ $config = require __DIR__ . "/config.php"; foreach (["videos_dir", "thumbs_dir", "uploads_dir"] as $d) if (!is_dir($config[$d])) mkdir($config[$d], 0775, true); if (!is_dir(__DIR__ . "/cache")) mkdir(__DIR__ . "/cache", 0775, true); const ARTICLE_ID_FILE = '.mvlog-id'; +const MAP_HIDDEN_FILE = '.mvlog-hide-map'; function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, "UTF-8"); } function ajax_json($data){ header('Content-Type: application/json; charset=UTF-8'); echo json_encode($data, JSON_UNESCAPED_UNICODE); exit; } function lower_text($s){ return function_exists('mb_strtolower') ? mb_strtolower((string)$s, 'UTF-8') : strtolower((string)$s); } @@ -442,7 +443,7 @@ entries = [] for dirpath, dirnames, filenames in os.walk(root): dirnames[:] = [d for d in dirnames if d != '.movmaker-lock'] for name in filenames: - if name in {'.movmaker-state.json', '.movmaker-enabled', '.movmaker-preview', '.mvlog-hidden', '.mvlog-id'}: + if name in {'.movmaker-state.json', '.movmaker-enabled', '.movmaker-preview', '.mvlog-hidden', '.mvlog-id', '.mvlog-hide-map'}: continue path = os.path.join(dirpath, name) rel = os.path.relpath(path, root) @@ -554,6 +555,12 @@ function set_input_dir_visible($dir, $visible){ if ($visible) { if (is_file($path)) unlink($path); } else { file_put_contents($path, "hidden\n"); chmod($path, 0664); } } +function input_dir_map_hidden($dir){ return is_file($dir . '/' . MAP_HIDDEN_FILE); } +function set_input_dir_map_hidden($dir, $hidden){ + $path = $dir . '/' . MAP_HIDDEN_FILE; + if ($hidden) { file_put_contents($path, "hide-map\n"); chmod($path, 0664); } + elseif (is_file($path)) unlink($path); +} function ensure_state_article_id($dir){ $articleId = ensure_article_id($dir); $stateFile = $dir . '/.movmaker-state.json'; @@ -801,6 +808,23 @@ try { } header('Location: new.php?tab=edit&msg=' . rawurlencode($message)); exit; + } elseif ($action === 'set_map_hidden') { + $dir = resolve_input_dir_from_request($config['uploads_dir'], $_POST['id'] ?? '', $_POST['dir'] ?? '', $articleIndex); + $articleId = ensure_state_article_id($dir); + $mapHiddenNow = !empty($_POST['map_hidden']); + set_input_dir_map_hidden($dir, $mapHiddenNow); + $message = ($mapHiddenNow ? 'Map hidden on index for: in-dir/' : 'Map visible on index for: in-dir/') . basename($dir); + if (!empty($_POST['ajax'])) { + ajax_json([ + 'ok' => true, + 'map_hidden' => $mapHiddenNow, + 'dir' => basename($dir), + 'id' => $articleId, + 'message' => $message, + ]); + } + header('Location: new.php?tab=edit&msg=' . rawurlencode($message)); + exit; } elseif ($action === 'update') { $dir = resolve_input_dir_from_request($config['uploads_dir'], $_POST['id'] ?? '', $_POST['dir'] ?? '', $articleIndex); $articleId = ensure_state_article_id($dir); @@ -960,7 +984,7 @@ $runningJobs = active_worker_jobs($config);

Videos without input dir

No orphan videos.


MB
-

No input directories yet.

Map
No video yet
+

No input directories yet.

Map
No video yet
@@ -991,6 +1015,16 @@ $runningJobs = active_worker_jobs($config);
+
+ + + + + +
RenderingEdit

No videoPreview video

ยท files

Edit input dir

in-dir/

This input directory is . Editing is disabled until the job completes.
@@ -1350,6 +1384,7 @@ function applySwitchPayload(payload){ } if('preview' in payload) setSwitch('preview', payload.preview); if('enabled' in payload) setSwitch('render', payload.enabled); + if('map_hidden' in payload) setSwitch('hide-map', payload.map_hidden); if('visible' in payload){ setSwitch('show', payload.visible); row.classList.toggle('shown', !!payload.visible);