Skip to content

Commit 082c079

Browse files
committed
better versioning of generator and APIs
1 parent edbf300 commit 082c079

7 files changed

Lines changed: 65 additions & 7 deletions

File tree

config/config.sample.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Main config file for digital strategy report generator
4+
* Copy this file to config.php and edit as needed for your installation
5+
*/
6+
7+
//base directory of project, leave at default for parent directory of this file
8+
define( 'DGS_BASE_DIR', dirname( dirname( __FILE__ ) ) );
9+
10+
//directory where reports will reside afer generation, FALSE to delete after sending to user as a zip file
11+
define( 'DGS_REPORT_DIR', FALSE );
12+
13+
//base url for schema, change to FALSE to use local information only (e.g., to generate agency and items data files)
14+
define( 'DGS_SCHEMA_BASE', 'https://raw.github.com/GSA/digital-strategy/1/' );
15+
16+
//TTL of disk / in-memory cache ( default is 1 hour )
17+
define( 'DGS_TTL', 3600 );
18+
19+
//that's it!

includes/build-agencies.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
require_once 'config/agencies.php';
88
require_once 'load.php';
99

10+
//store generator version
11+
$dgs_agencies = dgs_prepend_generator_version( $dgs_agencies );
12+
1013
//sort agencies by name alpha ascending
11-
dgs_sort( $dgs_agencies, 'name' );
14+
dgs_sort( $dgs_agencies->agencies, 'name' );
1215

1316
//output JSON
1417
file_put_contents( DGS_BASE_DIR . '/data/agencies.json', json_encode( $dgs_agencies ) );

includes/build-items.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
require_once 'config/items.php';
88
require_once 'load.php';
99

10+
//store generator version
11+
$dgs_items = dgs_prepend_generator_version( $dgs_items );
12+
1013
//sort action items by ID ascending
11-
dgs_sort( $dgs_items );
14+
dgs_sort( $dgs_items->items );
1215

1316
//JSON encode the action items array into the json file
1417
file_put_contents( DGS_BASE_DIR .'/data/items.json', json_encode( $dgs_items ) );

includes/footer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
?>
66
<footer>
7-
Version 1.0
7+
Generator Version <?php echo DGS_VERSION; ?>
88
</footer>
99
</div> <!-- /container -->
1010

includes/functions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,9 @@ function dgs_sort( &$items, $field = 'id' , $dir = SORT_ASC ) {
359359
array_multisort( $order, $dir, $items );
360360

361361
}
362+
363+
function dgs_prepend_generator_version( $array ) {
364+
365+
return array_merge( array( 'generator_version' => DGS_VERSION ), $array );
366+
367+
}

load.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
//bootrstrap form generator
1717
require_once DGS_BASE_DIR . '/includes/forms/load.php';
1818

19+
//generator version, bump with each release
20+
define( 'DGS_VERSION', '1.1' );
21+
1922
//bootstrap DSG Generator Core
2023
foreach ( array( 'items', 'agencies' ) as $plural ) {
2124

readme.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ Requirements
1616
------------
1717

1818
* PHP (e.g., LAMP, XAMPP, MAMP, etc.)
19-
* The /tmp/ must be writable by PHP (`chmod 0777 /tmp/` works well)
2019

21-
Usage
22-
-----
20+
Usage and installation
21+
----------------------
2322

24-
Load index.php in your favorite HTML5 web browser
23+
1. Clone or extract the project into your web server's `htdocs` or `public_html` folder
24+
2. Copy `config/config.sample.php` to `config/config.php`
25+
2. Navigate to the project's folder in your favorite HTML5 web browser (e.g., `http://localhost/dgs/`)
26+
27+
Usage as a service
28+
------------------
29+
30+
1. Complete step 1 above
31+
2. POST data directly to the `index.php` file using any language or script of your choice
32+
3. Recieve a zip file containing the generated content
2533

2634
How it Works
2735
------------
@@ -37,6 +45,22 @@ Contributing
3745

3846
Federal employees and members of the public are encouraged to contribue to the project by forking and submitting a pull request. All code must be licensed to the public under GPLv2 or later.
3947

48+
Changelog
49+
---------
50+
51+
### 1.0 ###
52+
* Initial Release
53+
54+
### 1.1 ###
55+
* Better PHP 5.4 compatability (removed calltime pass by reference)
56+
* Added option to write generated file to web server for easier programatic access (props [Bill Severe](https://github.com/bsevere))
57+
* Uses PHP's default temporary directory, rather than the `tmp/` folder within the project to generate files, simplifying installation and improving portability (props [Bill Severe](https://github.com/bsevere))
58+
* Moved configuration to separate file to simplifying customization
59+
* Better sorting of agencies and action items in datafiles and in the generator (props [Bill Severe](https://github.com/bsevere))
60+
* Abilitity to bypass GitHub service and local cache to force generation of fresh datafiles
61+
* Clarified requirements, installation instructions, and usage as a service
62+
* Corrected typos in readme (props [Bill Severe](https://github.com/bsevere))
63+
4064
License
4165
-------
4266

0 commit comments

Comments
 (0)