Skip to content
Browse files

Added Install file & test file

  • Loading branch information...
1 parent 843739f commit 2ae1b4fbdb8f65f8dfb536f12689c05e8e8598ca @davglass committed Aug 14, 2009
Showing with 154 additions and 18 deletions.
  1. +26 −18 index.php
  2. +105 −0 install.sh
  3. +23 −0 test.php
View
44 index.php
@@ -1,6 +1,7 @@
<?php
$q = $_SERVER['QUERY_STRING'];
$sha1 = sha1($q);
+$apc = function_exists('apc_store');
function execGit($git, $cmd, $echo=false) {
$output = array();
@@ -20,15 +21,18 @@ function execGit($git, $cmd, $echo=false) {
}
function fetchTag($tag, $version, $echo=false) {
- if (apc_fetch('git-fetch')) {
- if ($echo) {
- echo('Another process is fetching a tag, please wait...');
- } else {
- echo('alert("Another process is fetching a tag, please wait...");');
+ global $apc;
+ if ($apc) {
+ if (apc_fetch('git-fetch')) {
+ if ($echo) {
+ echo('Another process is fetching a tag, please wait...');
+ } else {
+ echo('alert("Another process is fetching a tag, please wait...");');
+ }
+ exit;
}
- exit;
+ apc_store('git-fetch', true);
}
- apc_store('git-fetch', true);
$base = '/tmp/yuidev/base/yui'.$version;
$dir = '/tmp/yuidev/lib/'.$tag;
$str = '';
@@ -55,22 +59,19 @@ function fetchTag($tag, $version, $echo=false) {
$file = (($version == 3) ? 'yui/yui-min' : 'yuiloader-dom-event/yuiloader-dom-event');
$str .= '<textarea style="width: 90%; height: 40px;"><script src="http://dev-combo.davglass.com/?'.$tag.'/build/'.$file.'.js"></script></textarea>';
}
- apc_store('git-fetch', false);
+ if ($apc) {
+ apc_store('git-fetch', false);
+ }
if ($echo) {
echo($str);
exit;
}
}
-if ($_GET['flush']) {
+if ($_GET['flush'] && $apc) {
apc_clear_cache('user');
}
-if (!function_exists('apc_fetch')) {
- echo('<strong>Error:</strong> APC must be installed!!');
- exit;
-}
-
$files = explode('&', $q);
if (!sizeOf($files)) {
@@ -96,18 +97,23 @@ function fetchTag($tag, $version, $echo=false) {
}
function getCache($sha1) {
- $out = apc_fetch('combo-'.$sha1);
+ global $apc;
+ if ($apc) {
+ $out = apc_fetch('combo-'.$sha1);
+ }
if (!$out) {
if (is_file('/tmp/yuidev/cache/'.$sha1[0].'/'.$sha1)) {
$out = @file_get_contents('/tmp/yuidev/cache/'.$sha1[0].'/'.$sha1);
- apc_store('combo-'.$sha1, $out, 1800);
+ if ($apc) {
+ apc_store('combo-'.$sha1, $out, 1800);
+ }
}
}
return $out;
}
function writeFiles($files, $sha1) {
- global $pre, $tag, $build;
+ global $pre, $tag, $build, $apc;
$out = '';
foreach ($files as $k => $file) {
if (@is_file($pre.$file)) {
@@ -116,7 +122,9 @@ function writeFiles($files, $sha1) {
}
$out = str_replace('@VERSION@', $tag, $out);
$out = str_replace('@BUILD@', $build, $out);
- apc_store('combo-'.$sha1, $out, 1800);
+ if ($apc) {
+ apc_store('combo-'.$sha1, $out, 1800);
+ }
@mkdir('/tmp/yuidev/cache/'.$sha1[0].'/', 0777, true);
@file_put_contents('/tmp/yuidev/cache/'.$sha1[0].'/'.$sha1, $out);
return $out;
View
105 install.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+git=`which git`
+apc=`php -m | grep apc`
+
+if [ "$git" == "" ]; then
+ echo "Git not found, exiting..";
+ exit;
+else
+ version=`$git --version`
+ echo "Found $version"
+fi
+
+if [ "$apc" == "" ]; then
+ echo "------------------------------------------------------------------------------------------"
+ echo "APC PHP module is not installed."
+ echo "Performance will be better if it's installed.. I'm just sayin.."
+ echo "------------------------------------------------------------------------------------------"
+ exit;
+fi
+
+if [ -d /tmp/yuidev ]; then
+ echo "Found a tmp directory called /tmp/yuidev"
+ echo "Do you want me to remove it? [y/N]"
+ read output
+ if [ "$output" != "y" ]; then
+ echo "Exiting.."
+ exit
+ fi
+fi
+
+echo "Making tmp directories.."
+mkdir -p /tmp/yuidev/base
+wait
+mkdir -p /tmp/yuidev/lib
+wait
+mkdir -p /tmp/yuidev/cache
+wait
+
+echo "Fetching sources.. This may take a few minutes, so grab a drink.."
+cd /tmp/yuidev/base/
+wait
+echo "------------------------------------------------------------------------------------------"
+echo "Fetching YUI3 Sources. http://github.com/yui/yui3"
+$git --no-pager clone git://github.com/yui/yui3.git
+wait
+echo "------------------------------------------------------------------------------------------"
+echo "Fetching YUI2 Sources. http://github.com/yui/yui2"
+$git --no-pager clone git://github.com/yui/yui2.git
+wait
+echo "------------------------------------------------------------------------------------------"
+echo "Fetching libs.."
+echo "------------------------------------------------------------------------------------------"
+cd /tmp/yuidev/lib
+wait
+echo "YUI 2.7.0"
+curl http://yuilibrary.com/downloads/yui2/yui_2.7.0b.zip -o yui2.zip
+wait
+unzip -q yui2.zip
+wait
+mkdir 2.7.0
+wait
+cd 2.7.0
+mv ../yui/build ./
+wait
+cd ../
+wait
+rm -rRf yui
+wait
+rm -rRf yui2.zip
+wait
+echo "YUI 3.0.0b1"
+curl http://yuilibrary.com/downloads/yui3/yui_3.0.0b1.zip -o yui3.zip
+wait
+unzip -q yui3.zip
+wait
+mkdir 3.0.0b1
+wait
+cd 3.0.0b1
+mv ../yui/build ./
+wait
+cd ../
+wait
+rm -rRf yui
+wait
+rm -rRf yui3.zip
+wait
+echo "------------------------------------------------------------------------------------------"
+echo "Fetching complete.."
+echo ""
+echo "Temporary directories need admin (sudo) privileges, asking.."
+sudo chown -R www:www /tmp/yuidev
+sudo chmod -R +w /tmp/yuidev
+echo "Installation complete."
+echo ""
+echo "------------------------------------------------------------------------------------------"
+echo ""
+echo "Now put the index.php and test.php files under your web root, then open the test.php file."
+echo "You can try test.php to load YUI 3.0.0b1"
+echo "Then try test.php?version=yui3-1291 to load the yui3-1291 tag."
+echo ""
+echo "------------------------------------------------------------------------------------------"
+echo ""
+exit;
+
View
23 test.php
@@ -0,0 +1,23 @@
+<?php
+$version = (($_GET['version']) ? $_GET['version'] : '3.0.0b1');
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <title>3.x local combo test</title>
+</head>
+<body>
+<script type="text/javascript" src="index.php?<?php echo($version); ?>/build/yui/yui-min.js"></script>
+<script type="text/javascript">
+YUI({
+ comboBase: 'http://dev-combo.davglass.com/?',
+ combine: true
+}).use('node', function(Y) {
+ Y.on('domready', function() {
+ Y.get('body').setStyle('backgroundColor', 'green').set('innerHTML', 'YUI 3.x tag ' + YUI.version + ' loaded.');
+ });
+});
+</script>
+</body>
+</html>
+

0 comments on commit 2ae1b4f

Please sign in to comment.
Something went wrong with that request. Please try again.