Skip to content

Commit

Permalink
move config to seperate file, allow local override of github/cache
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter committed Aug 13, 2012
1 parent 1dfcb33 commit e99e779
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ data/*.json
data/*.xml
data/*.ttl
.DS_Store
import.php
import.php
config/config.php
19 changes: 19 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
@@ -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!
15 changes: 8 additions & 7 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e99e779

Please sign in to comment.