Sfoglia il codice sorgente

added ant build file; added ini based config

Andi Dittrich 8 anni fa
parent
commit
b887e8eb45

File diff suppressed because it is too large
+ 0 - 0
assets/Layout.css


+ 38 - 38
assets/Layout.less

@@ -2,60 +2,60 @@
 
 
 /*! Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages */
 /*! Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages */
 html,body {
 html,body {
-	width: 100%;
-	height: 100%;
-	background-color: #21232a;
+    width: 100%;
+    height: 100%;
+    background-color: #21232a;
 }
 }
 
 
 body {
 body {
-	color: #fff;
-	text-align: center;
-	text-shadow: 0 2px 4px rgba(0, 0, 0, .5);
-	padding: 0px;
-	min-height: 100%;
-	-webkit-box-shadow: inset 0 0 100px rgba(0, 0, 0, .8);
-	box-shadow: inset 0 0 100px rgba(0, 0, 0, .8);
-	display: table;
-	font-family: "Open Sans", Arial, sans-serif;
+    color: #fff;
+    text-align: center;
+    text-shadow: 0 2px 4px rgba(0, 0, 0, .5);
+    padding: 0px;
+    min-height: 100%;
+    -webkit-box-shadow: inset 0 0 100px rgba(0, 0, 0, .8);
+    box-shadow: inset 0 0 100px rgba(0, 0, 0, .8);
+    display: table;
+    font-family: "Open Sans", Arial, sans-serif;
 }
 }
 
 
 h1{
 h1{
-	font-family: inherit;
-	font-weight: 500;
-	line-height: 1.1;
-	color: inherit;
-	font-size: 36px;
+    font-family: inherit;
+    font-weight: 500;
+    line-height: 1.1;
+    color: inherit;
+    font-size: 36px;
 }
 }
 
 
 h1 small{
 h1 small{
-	font-size: 68%;
-	font-weight: 400;
-	line-height: 1;
-	color: #777777;
+    font-size: 68%;
+    font-weight: 400;
+    line-height: 1;
+    color: #777777;
 }
 }
 a{
 a{
-	text-decoration: none;
-	color: #ffffff;
-	font-size: inherit;
-	border-bottom: dotted 1px #707070;
+    text-decoration: none;
+    color: #ffffff;
+    font-size: inherit;
+    border-bottom: dotted 1px #707070;
 }
 }
 .lead {
 .lead {
-	color: #c0c0c0;
-	font-size: 21px;
-	line-height: 1.4;
+    color: #c0c0c0;
+    font-size: 21px;
+    line-height: 1.4;
 }
 }
 .cover {
 .cover {
-	display: table-cell;
-	vertical-align: middle;
-	padding: 0 20px;
+    display: table-cell;
+    vertical-align: middle;
+    padding: 0 20px;
 }
 }
 
 
 footer{
 footer{
-	position: fixed;
-	width: 100%;
-	height: 40px;
-	left: 0px;
-	bottom: 0px;
-	color: #a0a0a0;			
-	font-size: 14px;
+    position: fixed;
+    width: 100%;
+    height: 40px;
+    left: 0px;
+    bottom: 0px;
+    color: #a0a0a0;
+    font-size: 14px;
 }
 }

+ 39 - 0
build.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="HttpErrorPages" default="pages" basedir=".">
+    <!-- AN-contrib !-->
+    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
+
+    <target name="css">
+        <!-- Less CSS build (WEB CSS) !-->
+        <echo message="Building LESS Files.." />
+        <exec executable="lessc">
+            <arg line="assets/Layout.less" />
+            <arg line="assets/Layout.css" />
+            <arg line="--clean-css" />
+        </exec>
+    </target>
+
+    <!-- Generate Pages using default config !-->
+    <target name="pages" depends="css">
+        <!-- Generate Pages !-->
+        <exec executable="php">
+            <arg value="generator.php" />
+        </exec>
+    </target>
+
+    <!-- Generate Docs Pages !-->
+    <target name="docs" depends="css">
+        <!-- Generate Pages !-->
+        <exec executable="php">
+            <arg value="generator.php" />
+            <arg value="docs/config.ini" />
+        </exec>
+    </target>
+
+    <!-- Full Rebuild !-->
+    <target name="full" depends="css,docs,pages">
+    </target>
+
+</project>
+

+ 7 - 0
config.ini

@@ -0,0 +1,7 @@
+[global]
+
+; Output dir path
+output_dir="dist/"
+
+; Footer content (HTML Allowed)
+footer=""

File diff suppressed because it is too large
+ 3 - 3
dist/HTTP400.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP401.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP403.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP404.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP500.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP501.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP502.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP503.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP520.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP521.html


File diff suppressed because it is too large
+ 3 - 3
dist/HTTP533.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP400.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP401.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP403.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP404.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP500.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP501.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP502.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP503.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP520.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP521.html


File diff suppressed because it is too large
+ 3 - 3
docs/HTTP533.html


+ 7 - 0
docs/config.ini

@@ -0,0 +1,7 @@
+[global]
+
+; Output dir path
+output_dir="docs/"
+
+; Footer content (HTML Allowed)
+footer = "Technical Contact: <a href="mailto:x@example.com">x@example.com</a>"

+ 25 - 4
generator.php

@@ -3,9 +3,23 @@
  * HttpErrorPages HTML Generator
  * HttpErrorPages HTML Generator
  */
  */
 
 
-$config = array(
-    'footer' => 'Technical Contact: <a href="mailto:x@example.com">x@example.com</a>'
-);
+// default config file
+$configFilename = 'config.ini';
+
+// config file specified ?
+if (isset($argv[1])){
+    if (is_file($argv[1])){
+        echo 'Using Config File "', $argv[1], '"', PHP_EOL;
+        $configFilename = $argv[1];
+    }else{
+        echo 'Error: Config File "', $argv[1], '" not found - Using default one', PHP_EOL;
+    }
+}else{
+    echo 'Using Default Config File "', $configFilename, '"', PHP_EOL;
+}
+
+// load config
+$config = parse_ini_file($configFilename, false);
 
 
 // load pages
 // load pages
 $pages = require('pages.php');
 $pages = require('pages.php');
@@ -15,10 +29,13 @@ $css = trim(file_get_contents('assets/Layout.css'));
 
 
 // generate each error page
 // generate each error page
 foreach ($pages as $code => $page){
 foreach ($pages as $code => $page){
+    echo 'Generating Page ', $page['title'], ' (', $code, ')..', PHP_EOL;
+
     // assign variables
     // assign variables
     $v_code = intval($code);
     $v_code = intval($code);
     $v_title = nl2br(htmlspecialchars($page['title']));
     $v_title = nl2br(htmlspecialchars($page['title']));
     $v_message = nl2br(htmlspecialchars($page['message']));
     $v_message = nl2br(htmlspecialchars($page['message']));
+    $v_footer = (isset($config['footer']) ? $config['footer'] : '');
 
 
     // render template
     // render template
     ob_start();
     ob_start();
@@ -26,5 +43,9 @@ foreach ($pages as $code => $page){
     $errorpage = ob_get_clean();
     $errorpage = ob_get_clean();
 
 
     // store template
     // store template
-    file_put_contents('dist/HTTP'.$v_code.'.html', $errorpage);
+    if (is_dir($config['output_dir'])){
+        file_put_contents($config['output_dir'] . 'HTTP'.$v_code.'.html', $errorpage);
+    }else{
+        echo 'Error: Output dir "', $config['output_dir'], '" not found', PHP_EOL;
+    }    
 }
 }

+ 6 - 8
template.phtml

@@ -3,9 +3,9 @@
 <head>
 <head>
     <!-- Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages -->
     <!-- Simple HttpErrorPages | MIT X11 License | https://github.com/AndiDittrich/HttpErrorPages -->
 
 
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta charset="utf-8" />
+    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
     
     
     <title>We've got some trouble | <?php echo $v_code; ?> - <?php echo $v_title; ?></title>
     <title>We've got some trouble | <?php echo $v_code; ?> - <?php echo $v_title; ?></title>
 
 
@@ -13,17 +13,15 @@
 </head>
 </head>
 
 
 <body>
 <body>
-
     <div class="cover">
     <div class="cover">
         <h1><?php echo $v_title; ?> <small>Error <?php echo $v_code; ?></small></h1>
         <h1><?php echo $v_title; ?> <small>Error <?php echo $v_code; ?></small></h1>
         <p class="lead"><?php echo $v_message; ?></p>
         <p class="lead"><?php echo $v_message; ?></p>
     </div>
     </div>
     
     
-    <?php if ($config['footer'] != null){ ?>
+    <?php if (!empty($v_footer)){ ?>
     <footer>
     <footer>
-        <p><?php echo $config['footer']; ?></p>
+        <p><?php echo $v_footer; ?></p>
     </footer>
     </footer>
-    <?php } ?>
-    
+    <?php } ?>    
 </body>
 </body>
 </html>
 </html>

Some files were not shown because too many files changed in this diff