Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
exclude dir in source like .git from http://stackoverflow.com/a/20501…
Browse files Browse the repository at this point in the history
  • Loading branch information
klml committed Jul 2, 2014
1 parent ce79da9 commit 84115e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions _drf/config.global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ tplextension: .html
namespaceseparator: ":"
metaseparator: "\n#meta#"
defaulttemplate: plain
sourceexclude: '.git'
directory:
template: ../template/
source: ../source/
Expand Down
26 changes: 20 additions & 6 deletions _drf/make.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,28 @@ protected function httpandcliRouting() {
}

}
protected function allPages( $sourcedirrecursive ) {
$sourcedirrecursive = new RecursiveDirectoryIterator( $sourcedirrecursive );
foreach (new RecursiveIteratorIterator($sourcedirrecursive) as $sourcepath => $file) { // TODO differece $file vs $sourcepath
protected function allPages( $sourcedir ) {

// dont parse directories
if ( !is_dir( $sourcepath ) ) {
$this->createPage($sourcepath);
$exclude = array();
array_push($exclude, $this->makeconfig['sourceexclude'] );

$filter = function ($file, $key, $iterator) use ($exclude) {
if ($iterator->hasChildren() && !in_array($file->getFilename(), $exclude)) {
return true;
}
return $file->isFile();
};

$innerIterator = new RecursiveDirectoryIterator(
$sourcedir,
RecursiveDirectoryIterator::SKIP_DOTS
);
$iterator = new RecursiveIteratorIterator(
new RecursiveCallbackFilterIterator($innerIterator, $filter)
);

foreach ($iterator as $pathname => $fileInfo) {
$this->createPage($fileInfo);
}
}

Expand Down

0 comments on commit 84115e4

Please sign in to comment.