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..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; @@ -41,6 +42,17 @@ 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}")); + $d1['format'] = 'yaml'; + + 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..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; @@ -79,6 +80,17 @@ 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))); + $d1['format'] = 'yaml'; + + 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])); }