diff --git a/init.php b/init.php index ec7a32df..a0a02122 100644 --- a/init.php +++ b/init.php @@ -1,27 +1,53 @@ main->mediaPath . DS . 'fonts' . DS; +$libPath = $config->main->mediaPath . DS . 'lib' . DS; -function download($source, $destination) + + +function download($source, $destination = null) { + echo 'Downloading: ' . $source . '...' . PHP_EOL; + flush(); + + if ($destination !== null and file_exists($destination)) + return file_get_contents($destination); + $content = file_get_contents($source); - if (substr($destination, -1, 1) == '/') - $destination .= basename($source); - file_put_contents($destination, $content); + if ($destination !== null) + { + $dir = dirname($destination); + if (!file_exists($dir)) + mkdir($dir, 0755, true); + + file_put_contents($destination, $content); + } + return $content; } -$config = configFactory(); -$cssPath = $config->main->mediaPath . DS . 'css' . DS; -$jsPath = $config->main->mediaPath . DS . 'js' . DS; -$fontsPath = $config->main->mediaPath . DS . 'fonts' . DS; + //jQuery -download('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', $jsPath . 'jquery.min.js'); -download('http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', $jsPath . 'jquery-ui.min.js'); -download('http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css', $cssPath . 'jquery-ui.css'); +download('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', $libPath . 'jquery' . DS . 'jquery.min.js'); + +//jQuery UI +download('http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', $libPath . 'jquery-ui' . DS . 'jquery-ui.min.js'); +$manifest = download('http://ajax.googleapis.com/ajax/libs/jqueryui/1/MANIFEST'); +$lines = explode("\n", str_replace("\r", '', $manifest)); +foreach ($lines as $line) +{ + if (preg_match('/themes\/flick\/(.*?) /', $line, $matches)) + { + $srcUrl = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1/' . $matches[0]; + $dstUrl = $libPath . 'jquery-ui' . DS . $matches[1]; + download($srcUrl, $dstUrl); + } +} //jQuery Tag-it! -download('http://raw.github.com/aehlke/tag-it/master/css/jquery.tagit.css', $cssPath . 'jquery.tagit.css'); -download('http://raw.github.com/aehlke/tag-it/master/js/tag-it.min.js', $jsPath . 'jquery.tagit.js'); +download('http://raw.github.com/aehlke/tag-it/master/css/jquery.tagit.css', $libPath . 'tagit' . DS . 'jquery.tagit.css'); +download('http://raw.github.com/aehlke/tag-it/master/js/tag-it.min.js', $libPath . 'tagit' . DS . 'jquery.tagit.js'); //fonts download('http://googlefontdirectory.googlecode.com/hg/apache/droidsans/DroidSans.ttf', $fontsPath . 'DroidSans.ttf'); diff --git a/lib/chibi-core b/lib/chibi-core index b5876a67..89897319 160000 --- a/lib/chibi-core +++ b/lib/chibi-core @@ -1 +1 @@ -Subproject commit b5876a672d107e4d6599cec52b9fa36e5558c16b +Subproject commit 898973195c1c6db2905cf2a52c80b0a8ba142058 diff --git a/public_html/media/.gitignore b/public_html/media/.gitignore deleted file mode 100644 index 5efbe581..00000000 --- a/public_html/media/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -js/jquery.tagit.js -css/jquery.tagit.css -js/jquery.min.js -js/jquery-ui.min.js -css/jquery-ui.css -fonts/DroidSans-Bold.ttf -fonts/DroidSans.ttf diff --git a/public_html/media/lib/.gitignore b/public_html/media/lib/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/public_html/media/lib/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 2140eb35..cbd5c2c3 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -28,8 +28,17 @@ class Bootstrap session_start(); $this->context->title = $this->config->main->title; - $this->context->stylesheets = ['core.css', 'jquery-ui.css']; - $this->context->scripts = ['core.js','jquery.min.js','jquery-ui.min.js']; + $this->context->stylesheets = + [ + 'core.css', + '../lib/jquery-ui/jquery-ui.css' + ]; + $this->context->scripts = + [ + 'core.js', + '../lib/jquery/jquery.min.js', + '../lib/jquery-ui/jquery-ui.min.js' + ]; $this->context->layoutName = isset($_GET['json']) ? 'layout-json' diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index b6071ea1..5283d73b 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -3,8 +3,8 @@ class PostController { public function workWrapper($callback) { - $this->context->stylesheets []= 'jquery.tagit.css'; - $this->context->scripts []= 'jquery.tagit.js'; + $this->context->stylesheets []= '../lib/tagit/jquery.tagit.css'; + $this->context->scripts []= '../lib/tagit/jquery.tagit.js'; $callback(); }