Permalink
Browse files

move config to seperate file, allow local override of github/cache

  • Loading branch information...
1 parent 1dfcb33 commit e99e7796bb2a7932bcd17e33f709bef876337da0 @benbalter benbalter committed Aug 13, 2012
Showing with 29 additions and 8 deletions.
  1. +2 −1 .gitignore
  2. +19 −0 config/config.sample.php
  3. +8 −7 load.php
View
@@ -2,4 +2,5 @@ data/*.json
data/*.xml
data/*.ttl
.DS_Store
-import.php
+import.php
+config/config.php
View
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Main config file for digital strategy report generator
+ * Copy this file to config.php and edit as needed for your installation
+ */
+
+//base dir for includes, leave at default for same directory as this file`
+define( 'DGS_BASE_DIR', dirname( __FILE__ ) );
+
+//directory where reports will reside afer generation, FALSE to delete after sending to user
+define( 'DGS_REPORT_DIR', FALSE );
+
+//base url for schema, change to false to use local information only
+define( 'DGS_SCHEMA_BASE', 'https://raw.github.com/GSA/digital-strategy/1/' );
+
+//TTL of disk / in-memory cache ( default is 1 hour )
+define( 'DGS_TTL', 3600 );
+
+//that's it!
View
@@ -4,10 +4,11 @@
* Will auto-propegate local copies of data files if they don't exist
*/
-define( 'DGS_BASE_DIR', dirname( __FILE__ ) ); //base dir for includes
-define( 'DGS_REPORT_DIR', ''); //directory where reports will reside
-define( 'DGS_SCHEMA_BASE', 'https://raw.github.com/GSA/digital-strategy/1/' ); //base url for schema
-define( 'DGS_TTL', 3600 ); //TTL of disk / in-memory cache ( 60*60 = 3600 )
+if ( !file_exists( dirname( __FILE__ ) . '/config/config.php' ) )
+ die( 'Please copy `config-sample.php` to `config.php` in the project\'s `config` directory' );
+
+//grab config file
+require_once( dirname( __FILE__ ) . '/config/config.php' );
//get core functions
require_once DGS_BASE_DIR . '/includes/functions.php';
@@ -39,19 +40,19 @@
continue;
//check APC Cache, if it's installed
- if ( function_exists( 'apc_fetch' ) && $cache = apc_fetch ( $global_var ) ) {
+ if ( DGS_REPORT_DIR && function_exists( 'apc_fetch' ) && $cache = apc_fetch ( $global_var ) ) {
$$global_var = $cache->$plural;
continue;
}
//look for /data/ files and parse (disk cache)
- if ( $file = dgs_get_disk_cache( $plural ) ) {
+ if ( DGS_REPORT_DIR && $file = dgs_get_disk_cache( $plural ) ) {
$$global_var = $file->$plural;
continue;
}
//try GitHub (mmm... dogfood)
- if ( $file = dgs_get_live( $plural ) ) {
+ if ( DGS_REPORT_DIR && $file = dgs_get_live( $plural ) ) {
$$global_var = $file->$plural;
continue;
}

0 comments on commit e99e779

Please sign in to comment.