Browse Source

Repository: exclude json files which are not categories

master
Stephan Bösch-Plepelits 7 years ago
parent
commit
746e1093d9
  1. 8
      src/RepositoryBase.php
  2. 5
      src/RepositoryDir.php
  3. 5
      src/RepositoryGit.php

8
src/RepositoryBase.php

@ -29,4 +29,12 @@ class RepositoryBase {
'timestamp' => Date(DATE_ISO8601, $this->timestamp()), 'timestamp' => Date(DATE_ISO8601, $this->timestamp()),
); );
} }
function isCategory ($data) {
if (!array_key_exists('type', $data)) {
return false;
}
return in_array($data['type'], array('index', 'overpass'));
}
} }

5
src/RepositoryDir.php

@ -21,6 +21,11 @@ class RepositoryDir extends RepositoryBase {
while ($f = readdir($d)) { while ($f = readdir($d)) {
if (preg_match("/^([0-9a-zA-Z_\-]+)\.json$/", $f, $m) && $f !== 'package.json') { if (preg_match("/^([0-9a-zA-Z_\-]+)\.json$/", $f, $m) && $f !== 'package.json') {
$d1 = json_decode(file_get_contents("{$this->path}/{$f}"), true); $d1 = json_decode(file_get_contents("{$this->path}/{$f}"), true);
if (!$this->isCategory($d1)) {
continue;
}
$data['categories'][$m[1]] = jsonMultilineStringsJoin($d1, array('exclude' => array(array('const')))); $data['categories'][$m[1]] = jsonMultilineStringsJoin($d1, array('exclude' => array(array('const'))));
} }
} }

5
src/RepositoryGit.php

@ -20,6 +20,11 @@ class RepositoryGit extends RepositoryBase {
} }
$d1 = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show HEAD:" . escapeShellArg($f)), true); $d1 = json_decode(shell_exec("cd " . escapeShellArg($this->path) . "; git show HEAD:" . escapeShellArg($f)), true);
if (!$this->isCategory($d1)) {
continue;
}
$data['categories'][$id] = jsonMultilineStringsJoin($d1, array('exclude' => array(array('const')))); $data['categories'][$id] = jsonMultilineStringsJoin($d1, array('exclude' => array(array('const'))));
} }
} }

Loading…
Cancel
Save