浏览代码

added scheme option to set the output filename

Andi Dittrich 8 年之前
父节点
当前提交
ed75894a9a
共有 5 个文件被更改,包括 41 次插入10 次删除
  1. 2 0
      CHANGES.md
  2. 28 8
      README.md
  3. 3 0
      config.ini
  4. 3 0
      docs/config.ini
  5. 5 2
      generator.php

+ 2 - 0
CHANGES.md

@@ -1,4 +1,6 @@
 ## 0.4 ##
+* Added: **ANT** based build file
+* Added: Configuration file `config.ini`
 * Changed the directory structure
 * Demo Pages are hosted via GitHub Pages (located within the `docs/` dir)
 

+ 28 - 8
README.md

@@ -73,27 +73,47 @@ Error-Codes used by CloudFlare
 ```php
 // webserver origin error
 '520' => array(
-	'title' => 'Origin Error - Unknown Host',
-	'message' => 'The requested hostname is not routed. Use only hostnames to access resources.'
+    'title' => 'Origin Error - Unknown Host',
+    'message' => 'The requested hostname is not routed. Use only hostnames to access resources.'
 ),
-		
+
 // webserver down error
 '521' => array (
-		'title' => 'Webservice currently unavailable',
-		'message' => "We've got some trouble with our backend upstream cluster.\nOur service team has been dispatched to bring it back online."
-)	
+    'title' => 'Webservice currently unavailable',
+    'message' => "We've got some trouble with our backend upstream cluster.\nOur service team has been dispatched to bring it back online."
+)
 ```
 
 ### Build/Generator ###
-Used Naming-Scheme: **HTTP**__CODE__**.html** (customizable by editing the generator script)
+Used Naming-Scheme: **HTTP**__CODE__**.html** (customizable by editing the `config.ini`)
 To generate the static html pages, run the `generator.php` script:
 
 ```shell
 php generator.php
 ```
 
-All generated html files are located into the `Build/` directory.
+All generated html files are located into the `dist/` directory.
+
+### Configuration ###
+
+It's possible to change the basic configuration without modifying the generator script. Just change the following variables within the `config.ini`.
+
+You can also specify a custom configuration file by passing it as first argument to the generator script `php generator.php path/myconfig.ini`
+
+**config.ini**
 
+```ini
+[global]
+
+; Output Filename Scheme - eg. HTTP500.html
+scheme='HTTP%d.html'
+
+; Output dir path
+output_dir="docs/"
+
+; Footer content (HTML Allowed)
+footer = "Technical Contact: <a href="mailto:x@example.com">x@example.com</a>"
+```
 
 ## License ##
 HttpErrorsPages is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute

+ 3 - 0
config.ini

@@ -1,5 +1,8 @@
 [global]
 
+; Output Filename Scheme - eg. HTTP500.html
+scheme='HTTP%d.html'
+
 ; Output dir path
 output_dir="dist/"
 

+ 3 - 0
docs/config.ini

@@ -1,5 +1,8 @@
 [global]
 
+; Output Filename Scheme - eg. HTTP500.html
+scheme='HTTP%d.html'
+
 ; Output dir path
 output_dir="docs/"
 

+ 5 - 2
generator.php

@@ -42,10 +42,13 @@ foreach ($pages as $code => $page){
     require('template.phtml');
     $errorpage = ob_get_clean();
 
+    // generate output filename
+    $filename = sprintf($config['scheme'], $v_code);
+
     // store template
     if (is_dir($config['output_dir'])){
-        file_put_contents($config['output_dir'] . 'HTTP'.$v_code.'.html', $errorpage);
+        file_put_contents($config['output_dir'] . $filename, $errorpage);
     }else{
         echo 'Error: Output dir "', $config['output_dir'], '" not found', PHP_EOL;
-    }    
+    }
 }