Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 01ba672

Browse files
committed
support moving public files form source/_data to public/data
1 parent 916fd4c commit 01ba672

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

builder/lib/generator.lib.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ public function generate() {
3737
// render out the index and style guide
3838
$this->generateMainPages();
3939

40+
// iterate over the data files and regenerate the entire site if they've changed
41+
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__."/../../source/_data/"), RecursiveIteratorIterator::SELF_FIRST);
42+
43+
// make sure dots are skipped
44+
$objects->setFlags(FilesystemIterator::SKIP_DOTS);
45+
46+
foreach($objects as $name => $object) {
47+
48+
$fileName = str_replace(__DIR__."/../../source/_data".DIRECTORY_SEPARATOR,"",$name);
49+
if (($fileName[0] != "_") && $object->isFile()) {
50+
$this->moveStaticFile("_data/".$fileName,"","_data","data");
51+
}
52+
53+
}
54+
4055
// iterate over all of the other files in the source directory and move them if their modified time has changed
4156
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__."/../../source/"), RecursiveIteratorIterator::SELF_FIRST);
4257

builder/lib/watcher.lib.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,15 @@ public function watch() {
140140

141141
if (!isset($o->$fileName)) {
142142
$o->$fileName = $mt;
143+
if (($fileName[0] != "_") && $object->isFile()) {
144+
$this->moveStaticFile("_data/".$fileName,"","_data","data");
145+
}
143146
} else if ($o->$fileName != $mt) {
144147
$o->$fileName = $mt;
145148
$this->updateSite($fileName,"changed");
149+
if (($fileName[0] != "_") && $object->isFile()) {
150+
$this->moveStaticFile("_data/".$fileName,"","_data","data");
151+
}
146152
}
147153

148154
}

0 commit comments

Comments
 (0)