Skip to content

Commit

Permalink
previews tweaked
Browse files Browse the repository at this point in the history
  • Loading branch information
tybenz committed Jul 10, 2012
1 parent 872f028 commit e3dfb8e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 350 deletions.
74 changes: 34 additions & 40 deletions add_version.php
@@ -1,24 +1,27 @@
<?php
require 'version.php';

$oldest = '1.0.1';
foreach( $VERSION_LIST as $version ) {
if ( !versionCompare( $version, $oldest ) ) {
$oldest = $version;
}
}

if ( isset( $argv ) ) {
$jqm = $argv[ 1 ];
$jq = $argv[ 2 ];
$jqm = isset( $argv[ 1 ] ) ? $argv[ 1 ] : '';
$jq = isset( $argv[ 2 ] ) ? $argv[ 2 ] : '';
$jqm_path ="http://code.jquery.com/mobile/" . $jqm;
$jq_path ="http://code.jquery.com/jquery-" . $jq . ".min.js";

chdir( 'jqm' );
rrmdir( $jqm );

//get most recent version of jqm
$versions = preg_grep('/^([^.])/', scandir( "." ));
$most_recent = '';
foreach( $versions as $version ) {
if ( versionCompare( $version, $most_recent ) ) {
$most_recent = $version;
}
}

mkdir( $jqm );
chdir( $jqm );

//Get jQuery JS
echo "Getting jQuery JS...\n";
getFile( $jq_path, "jquery.min.js" );
Expand All @@ -43,26 +46,22 @@
getFile( $jqm_path . "/jquery.mobile.theme-" . $jqm . ".css", "jqm.default.theme.css" );
//Create TR starter theme
echo "Generating ThemeRoller starter theme CSS...\n";
createStarter( "jqm.default.theme.css", "jqm.starter.theme.css" );
//Copy preview.html from oldest version present
@createStarter( "jqm.default.theme.css", "jqm.starter.theme.css" );
//Copy preview.html from most recent version present
echo "Generating Preview Markup...\n";
$contents = @file_get_contents( '../' . $oldest . '/preview.html' );
$file = fopen( 'preview.html', 'w' );
fwrite( $file, $contents );
fclose( $file );
$contents = @file_get_contents( '../' . $most_recent . '/preview.html' );
writeFile( 'preview.html', $contents );
//Create user_themes directory with README placeholder
echo "Creating user_themes directory...\n";
mkdir( "user_themes" );
$file = fopen( 'user_themes/README.md', 'w' );
fwrite( $file, 'This is where theme files are temporarily stored when a user "shares" a theme.' );
fclose( $file );
writeFile( 'user_themes/README.md', 'This is where theme files are temporarily stored when a user "shares" a theme.' );
//Create empty panel.js file
writeFile( 'panel.js', '' );
//Altering version.php with new key value pair for jQm, and jQuery versions
chdir( '../..' );
$contents = file_get_contents( 'version.php' );
$contents = preg_replace( "/(\\\$ALL_JQUERY_VERSIONS.*)\n.*\);/s", "$1,\n\t\"" . $jqm . "\" => \"" . $jq . "\"\n);", $contents );
$file = fopen( 'version.php', 'w' );
fwrite( $file, $contents );
fclose( $file );
writeFile( 'version.php', $contents );

} else {
echo 'This script must be executed via command line';
Expand All @@ -75,8 +74,7 @@ function check404( $url ) {
function getFile( $url, $filename ) {
if ( check404( $url ) ) {
echo $url . " could not be found. Generating empty file for " . $filename . "\n";
$file = fopen( $filename, 'w' );
fclose( $file );
writeFile( $filename, '' );
return false;
} else {
//get contents
Expand All @@ -86,13 +84,17 @@ function getFile( $url, $filename ) {
curl_close( $handle );

//write them out to local file
$file = fopen( $filename, 'w' );
fwrite( $file, $contents );
fclose( $file );
writeFile( $filename, $contents );
return true;
}
}

function writeFile( $filename, $string ) {
$file = fopen( $filename, 'w' );
fwrite( $file, $string );
fclose( $file );
}

function createStarter( $default, $starter ) {
$contents = file_get_contents( $default );

Expand All @@ -109,28 +111,20 @@ function createStarter( $default, $starter ) {
$temp = preg_replace( "/{c-/", "{a-", $temp );
$a_swatch = preg_replace( "/\/\*\s*C(\s*-*\*\/)/", "/* A$1", $temp );

//Build B swatch
$temp = preg_replace( "/-c\s/", "-b ", $c_swatch );
$temp = preg_replace( "/-c,/", "-b,", $temp );
$temp = preg_replace( "/{c-/", "{b-", $temp );
$b_swatch = preg_replace( "/\/\*\s*C(\s*-*\*\/)/", "/* B$1", $temp );

$contents = preg_replace( "/(\/\*\s*C\s*-*\*\/.*)\/\*\sStructure\s\*\//s",
$a_swatch . $b_swatch . "$1/* Structure */", $contents );
$contents = preg_replace( "/\/\*\s*C\s*-*\*\/.*\/\*\sStructure\s\*\//s",
$a_swatch . "/* Structure */", $contents );

$file = fopen( $starter, 'w' );
fwrite( $file, $contents );
fclose( $file );
writeFile( $starter, $contents );
}

function rrmdir($dir) {
foreach(glob($dir . '/*') as $file) {
if(is_dir($file))
@rrmdir($file);
else
unlink($file);
@unlink($file);
}
rmdir($dir);
@rmdir($dir);
}

?>
4 changes: 4 additions & 0 deletions css/tr.preview.css
Expand Up @@ -46,6 +46,10 @@
border-left-width: 1px;
}

.preview [data-role=fieldcontain] fieldset .ui-controlgroup-controls {
width: 100%;
}

.ui-slider{
width: 62% !important;
}
Expand Down
4 changes: 2 additions & 2 deletions jqm/1.0.1/preview.html
Expand Up @@ -47,8 +47,8 @@ <h1 class="ui-title" tabindex="0" role="heading" aria-level="1">A</h1>
<input type="radio" name="radio-choice-a" id="radio-choice-2-a" value="choice-2" />
<label for="radio-choice-2-a" data-form="ui-btn-up-a">Radio 2</label>

<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" checked="checked" />
<label for="checkbox-1" data-form="ui-btn-up-a">Checkbox</label>
<input type="checkbox" name="checkbox-a" id="checkbox-1" class="custom" checked="checked" />
<label for="checkbox-a" data-form="ui-btn-up-a">Checkbox</label>

</fieldset>
</div>
Expand Down
4 changes: 2 additions & 2 deletions jqm/1.1.0/preview.html
Expand Up @@ -47,8 +47,8 @@ <h1 class="ui-title" tabindex="0" role="heading" aria-level="1">A</h1>
<input type="radio" name="radio-choice-a" id="radio-choice-2-a" value="choice-2" />
<label for="radio-choice-2-a" data-form="ui-btn-up-a">Radio 2</label>

<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" checked="checked" />
<label for="checkbox-1" data-form="ui-btn-up-a">Checkbox</label>
<input type="checkbox" name="checkbox-1" id="checkbox-a" class="custom" checked="checked" />
<label for="checkbox-a" data-form="ui-btn-up-a">Checkbox</label>

</fieldset>
</div>
Expand Down

0 comments on commit e3dfb8e

Please sign in to comment.