Browse Source

Merge branch 'yaml'

master
parent
commit
022da026a9
  1. 1
      README.md
  2. 12
      src/RepositoryDir.php
  3. 12
      src/RepositoryGit.php

1
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

12
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}");
}

12
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]));
}

Loading…
Cancel
Save