From 04fd48cf20eda92e9685e298f6856c6786a7ce01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Mon, 20 Jun 2022 17:13:08 +0200 Subject: [PATCH] Categories: accept yaml format --- README.md | 1 + src/RepositoryDir.php | 10 ++++++++++ src/RepositoryGit.php | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 256ae41f..67fe8be8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ## INSTALL ```sh +sudo apt install php-yaml git clone https://github.com/plepe/openstreetbrowser.git cd openstreetbrowser npm install diff --git a/src/RepositoryDir.php b/src/RepositoryDir.php index ff273cd8..fc2db585 100644 --- a/src/RepositoryDir.php +++ b/src/RepositoryDir.php @@ -41,6 +41,16 @@ class RepositoryDir extends RepositoryBase { $data['categories'][$m[1]] = jsonMultilineStringsJoin($d1, array('exclude' => array(array('const'), array('filter')))); } + if (preg_match("/^([0-9a-zA-Z_\-]+)\.yaml$/", $f, $m)) { + $d1 = yaml_parse(file_get_contents("{$this->path}/{$f}")); + + if (!$this->isCategory($d1)) { + continue; + } + + $data['categories'][$m[1]] = $d1; + } + if (preg_match("/^(detailsBody|popupBody).html$/", $f, $m)) { $data['templates'][$m[1]] = file_get_contents("{$this->path}/{$f}"); } diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index 23865108..e343c7ca 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -79,6 +79,16 @@ class RepositoryGit extends RepositoryBase { $data['categories'][$id] = jsonMultilineStringsJoin($d1, array('exclude' => array(array('const'), array('filter')))); } + if (preg_match("/^([0-9a-zA-Z_\-]+)\.yaml$/", $r, $m)) { + $d1 = yaml_parse(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:" . escapeShellArg($f))); + + if (!$this->isCategory($d1)) { + continue; + } + + $data['categories'][$m[1]] = $d1; + } + if (preg_match("/^[0-9]{6} blob [0-9a-f]{40}\t((detailsBody|popupBody)\.html)$/", $r, $m)) { $data['templates'][$m[2]] = shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:" . escapeShellArg($m[1])); }