loadTemplate($file); $page = $template->render($params); file_put_contents($target, $page); } } // Copy resources copyDir(RESOURCES_DIR, TARGET_DIR); echo "Done.\n"; // -- Helpers ----------------------------------- /** Extracts information from pom.xml required for rendering the site. */ function parsePOM() { $project = simplexml_load_file(POM_PATH); return array( 'project' => array( 'name' => (string) $project->name, 'url' => (string) $project->url, 'inceptionYear' => (string) $project->inceptionYear, ) ); } /** Recursively copies directory contents. */ function copyDir($source, $target) { $source = trim($source, '/'); $target = trim($target, '/'); $files = scandir($source); foreach($files as $file) { if ($file == '.' || $file == '..') continue; // Skip hidden files such as .svn if ($file[0] == '.') continue; if (is_dir("$source/$file")) { if (!is_dir("$target/$file")) { mkdir("$target/$file"); } copyDir("$source/$file", "$target/$file"); } else { echo "Copying resource: $target/$file\n"; copy("$source/$file", "$target/$file"); } } }