You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2012/05/28 19:57:32 UTC
svn commit: r1343341 - in /logging/site/branches/cms/trunk: build.php
build_cms.sh
Author: rgoers
Date: Mon May 28 17:57:32 2012
New Revision: 1343341
URL: http://svn.apache.org/viewvc?rev=1343341&view=rev
Log:
Create CMS compliant script
Added:
logging/site/branches/cms/trunk/build_cms.sh
Modified:
logging/site/branches/cms/trunk/build.php
Modified: logging/site/branches/cms/trunk/build.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/build.php?rev=1343341&r1=1343340&r2=1343341&view=diff
==============================================================================
--- logging/site/branches/cms/trunk/build.php (original)
+++ logging/site/branches/cms/trunk/build.php Mon May 28 17:57:32 2012
@@ -19,26 +19,32 @@
// -- Config ------------------------------------
-$options = getopt("o:,outputDir:");
+$options = getopt("i:o:,intputDir:outputDir:");
-$target = $options["o"];
+$base = $options["i"];
+$dest = $options["o"];
-if (is_null($target))
+if (is_null($base))
{
- print("No target directory provided\n");
- exit(-1);
+ printUsage();
+ exit(-1);
+}
+if (is_null($dest))
+{
+ printUsage();
+ exit(-1);
}
-$base = dirname(__FILE__);
+// $base = dirname(__FILE__);
define('PAGES_DIR', "$base/content/pages/");
define('RESOURCES_DIR', "$base/content/resources/");
define('TEMPLATES_DIR', "$base/templates/");
-define('TARGET_DIR', "$target"); // "$base/target/site/");
+define('TARGET_DIR', "$dest/"); // "$base/target/site/");
define('POM_PATH', "$base/pom.xml");
// -- Init --------------------------------------
-
+
require "$base/libs/Twig/lib/Twig/Autoloader.php";
require "$base/libs/textile/classTextile.php";
@@ -64,14 +70,14 @@ if (!file_exists(TARGET_DIR)) {
// Render pages
$files = scandir(PAGES_DIR);
-foreach($files as $file)
+foreach($files as $file)
{
- if (preg_match('/.twig$/', $file))
+ if (preg_match('/.twig$/', $file))
{
$filename = str_replace('.twig', '.html', $file);
$target = TARGET_DIR . $filename;
echo "Rendering template: $filename\n";
-
+
$template = $twig->loadTemplate($file);
$page = $template->render($params);
file_put_contents($target, $page);
@@ -86,6 +92,11 @@ echo "Done.\n";
// -- Helpers -----------------------------------
+function printUsage()
+{
+ print("Usage: php build.php -i sourceDirectory -o targetDirectory\n");
+}
+
/** Extracts information from pom.xml required for rendering the site. */
function parsePOM()
{
@@ -104,18 +115,18 @@ function copyDir($source, $target)
{
$source = rtrim($source, '/');
$target = rtrim($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("$source/$file"))
{
- if (!is_dir("$target/$file"))
+ if (!is_dir("$target/$file"))
{
mkdir("$target/$file");
}
@@ -133,5 +144,5 @@ function copyDir($source, $target)
function renderTextile($data)
{
$textile = new Textile();
- return $textile->TextileThis(trim($data));
+ return $textile->TextileThis(trim($data));
}
Added: logging/site/branches/cms/trunk/build_cms.sh
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/build_cms.sh?rev=1343341&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/build_cms.sh (added)
+++ logging/site/branches/cms/trunk/build_cms.sh Mon May 28 17:57:32 2012
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+if test $# -lt 2
+then
+ echo "Usage: build.cms.sh sourceDirectory targetDirectory"
+fi
+
+php build.php -i $1 -o $2
\ No newline at end of file