Browse Source

Categories: accept yaml format

master
parent
commit
04fd48cf20
  1. 1
      README.md
  2. 10
      src/RepositoryDir.php
  3. 10
      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

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

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

Loading…
Cancel
Save