Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version ID now automatically added to boilerplate

  • Loading branch information...
commit 3d6939011cb6b6e2f6e6e2116facb9fdc93373e9 1 parent 4489b1c
@peteboere authored
Showing with 17 additions and 6 deletions.
  1. +1 −1  CssCrush.boilerplate
  2. +1 −1  CssCrush.php
  3. +15 −4 lib/Core.php
View
2  CssCrush.boilerplate
@@ -1,2 +1,2 @@
CSS Crush(ed) on {{datetime}}
-http://github.com/peteboere/css-crush
+http://github.com/peteboere/css-crush ({{version}})
View
2  CssCrush.php
@@ -22,7 +22,7 @@
require_once 'lib/Regex.php';
require_once 'lib/Hook.php';
-csscrush::init( dirname( __FILE__ ) );
+csscrush::init( __FILE__ );
View
19 lib/Core.php
@@ -21,12 +21,17 @@ class csscrush {
// Init called once manually post class definition
- public static function init ( $current_dir ) {
+ public static function init ( $seed_file ) {
self::$config = new stdclass();
// Path to this installation
- self::$config->location = $current_dir;
+ self::$config->location = dirname( $seed_file );
+
+ // Get version ID from seed file
+ $seed_file_contents = file_get_contents( $seed_file );
+ $match_count = preg_match( '!@version\s+([\d\.]+)!', $seed_file_contents, $version_match );
+ self::$config->version = $match_count ? $version_match[1] : null;
// Set the docRoot reference
self::setDocRoot();
@@ -468,19 +473,25 @@ protected static function getBoilerplate () {
// Load the file
$boilerplate = file_get_contents( $file );
- // Process any tags, currently only '{{datetime}}' is supported
+ // Substitute any tags
if ( preg_match_all( '!\{\{([^}]+)\}\}!', $boilerplate, $boilerplate_matches ) ) {
+
$replacements = array();
foreach ( $boilerplate_matches[0] as $index => $tag ) {
- if ( $boilerplate_matches[1][$index] === 'datetime' ) {
+ $tag_name = $boilerplate_matches[1][$index];
+ if ( $tag_name === 'datetime' ) {
$replacements[] = @date( 'Y-m-d H:i:s O' );
}
+ elseif ( $tag_name === 'version' ) {
+ $replacements[] = 'v' . csscrush::$config->version;
+ }
else {
$replacements[] = '?';
}
}
$boilerplate = str_replace( $boilerplate_matches[0], $replacements, $boilerplate );
}
+
// Pretty print
$boilerplate = explode( PHP_EOL, $boilerplate );
$boilerplate = array_map( 'trim', $boilerplate );
Please sign in to comment.
Something went wrong with that request. Please try again.