Initial upload
This commit is contained in:
25
info.php
Normal file
25
info.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$recipesDir = __DIR__ . '/recipes';
|
||||
|
||||
if (!is_dir($recipesDir)) {
|
||||
echo json_encode(["recipes" => new stdClass()], JSON_PRETTY_PRINT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$categories = array_filter(glob($recipesDir . '/*'), 'is_dir');
|
||||
$output = ["recipes" => []];
|
||||
|
||||
foreach ($categories as $categoryPath) {
|
||||
$categoryName = basename($categoryPath);
|
||||
$items = array_filter(glob($categoryPath . '/*'), 'is_dir');
|
||||
$itemNames = array_map('basename', $items);
|
||||
|
||||
if (!empty($itemNames)) {
|
||||
$output["recipes"][$categoryName] = array_values($itemNames);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
?>
|
||||
Reference in New Issue
Block a user