public static function resolve($uri) { // Place trailing slash on base URL $uri = static::remove($uri, rtrim(\Laravel\URL::base(), '/#')); $uri = rtrim($uri, '#'); static::$uri = static::format($uri); static::segments(static::$uri); return static::$uri; }
/** * Return path to ckeditor.js. */ private function ckeditorPath() { if (!empty($this->basePath)) { return $this->basePath; } else { return \Laravel\URL::base() . '/bundles/ckeditor/ckeditor/'; } // Not used in Laravel // /** // * The absolute pathname of the currently executing script. // * Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, // * $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. // */ // if (isset($_SERVER['SCRIPT_FILENAME'])) { // $realPath = dirname($_SERVER['SCRIPT_FILENAME']); // } // else { // /** // * realpath - Returns canonicalized absolute pathname // */ // $realPath = realpath( './' ) ; // } // // /** // * The filename of the currently executing script, relative to the document root. // * For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar // * would be /test.php/foo.bar. // */ // $selfPath = dirname($_SERVER['PHP_SELF']); // $file = str_replace("\\", "/", __FILE__); // // if (!$selfPath || !$realPath || !$file) { // return "/ckeditor/"; // } // // $documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath)); // $fileUrl = substr($file, strlen($documentRoot)); // $ckeditorUrl = str_replace("ckeditor_php5.php", "", $fileUrl); // // return $ckeditorUrl; }
/** * Return the root asset path for the given bundle. * * @param string $bundle * @return string */ public static function assets($bundle) { return $bundle != DEFAULT_BUNDLE ? URL::base() . "/bundles/{$bundle}/" : URL::base() . '/'; }
/** * Return the root asset path for the given bundle. * * @param string $bundle * @return string */ public static function assets($bundle) { if (is_null($bundle)) { return static::assets(DEFAULT_BUNDLE); } return $bundle != DEFAULT_BUNDLE ? URL::base() . "/bundles/{$bundle}/" : URL::base() . '/'; }
<?php Route::get('(:bundle)/rejigger.js', array('as' => 'rejigger_js', function () { return View::make('rejigger::js'); })); Route::get('(:bundle)/version', array('as' => 'rejigger_version', function () { // Don't let the controller mistake this for a regular AJAX call unset($_SERVER['HTTP_X_REQUESTED_WITH']); $uri = \Rejigger\URI::resolve(Input::get('uri')); $route = \Laravel\Routing\Router::route('GET', $uri); $response = $route->call(); $version = md5($response->content); // Parse out resources (css & script) preg_match_all('/\\<script[^\\>]+src=\\"(?P<src>[^\\"]+)\\"[^\\>]*\\>/i', $response->content, $scripts); preg_match_all('/\\<link[^\\>]+href=\\"(?P<href>[^\\"]+)\\"[^\\>]*\\>/i', $response->content, $styles); preg_match_all('/\\<img[^\\>]+src=\\"(?P<src>[^\\"]+)\\"[^\\>]*\\>/i', $response->content, $images); $resources = array_merge($scripts['src'], $styles['href'], $images['src']); $public = path('public'); foreach ($resources as $resource) { $resource = $public . str_replace(\Laravel\URL::base(), '', $resource); if (\Laravel\File::exists($resource)) { $version .= File::modified($resource); } } return '{ "version": "' . md5($version) . '" }'; }));