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 1/2] 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])); } From 79053f304a12efd72fbb1e4fad75219c6a114254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Wed, 22 Jun 2022 19:56:27 +0200 Subject: [PATCH 2/2] RepositoryGit/Dir: include format of category (json/yaml) --- src/RepositoryDir.php | 2 ++ src/RepositoryGit.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/RepositoryDir.php b/src/RepositoryDir.php index fc2db585..07e33667 100644 --- a/src/RepositoryDir.php +++ b/src/RepositoryDir.php @@ -33,6 +33,7 @@ class RepositoryDir extends RepositoryBase { while ($f = readdir($d)) { if (preg_match("/^([0-9a-zA-Z_\-]+)\.json$/", $f, $m) && $f !== 'package.json') { $d1 = json_decode(file_get_contents("{$this->path}/{$f}"), true); + $d1['format'] = 'json'; if (!$this->isCategory($d1)) { continue; @@ -43,6 +44,7 @@ class RepositoryDir extends RepositoryBase { if (preg_match("/^([0-9a-zA-Z_\-]+)\.yaml$/", $f, $m)) { $d1 = yaml_parse(file_get_contents("{$this->path}/{$f}")); + $d1['format'] = 'yaml'; if (!$this->isCategory($d1)) { continue; diff --git a/src/RepositoryGit.php b/src/RepositoryGit.php index e343c7ca..eafdfb2d 100644 --- a/src/RepositoryGit.php +++ b/src/RepositoryGit.php @@ -71,6 +71,7 @@ class RepositoryGit extends RepositoryBase { } $d1 = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show {$this->branchEsc}:" . escapeShellArg($f)), true); + $d1['format'] = 'json'; if (!$this->isCategory($d1)) { continue; @@ -81,6 +82,7 @@ class RepositoryGit extends RepositoryBase { 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))); + $d1['format'] = 'yaml'; if (!$this->isCategory($d1)) { continue;