CodingJungle Posted May 2, 2020 Share Posted May 2, 2020 public static function inDevJs( $file, $app=NULL, $location=NULL ) { /* 1: Is this the magic plugin JS */ if ( $app === 'core' and $location === 'plugins' and $file === 'plugins.js' ) { $return = array(); foreach ( new \GlobIterator( \IPS\ROOT_PATH . '/plugins/*/dev/js/*' ) as $file ) { try { $plugin = \IPS\Plugin::getPluginFromPath( $file ); if( $plugin->enabled ) { $url = str_replace( \IPS\ROOT_PATH, rtrim( \IPS\Settings::i()->base_url, '/' ), $file ); $return[] = str_replace( '\\', '/', $url ); } } catch( \OutOfRangeException $e ){} } return $return; } /* 2: Is it a named grouped collection? */ if ( $app === NULL AND $location === NULL ) { if ( $file === 'map.js' ) { return array(); } if ( \in_array( $file, \IPS\Output::$globalJavascript ) ) { $app = 'global'; $location = '/'; } if ( mb_substr( $file, 0, 8 ) === 'js_lang_' ) { return array( \IPS\Http\Url::baseUrl() . "/applications/core/interface/js/jslang.php?langId=" . \intval( mb_substr( $file, 8, -3 ) ) ); } } $app = $app ?: ( \IPS\Dispatcher::i()->application ? \IPS\Dispatcher::i()->application->directory : NULL ); $location = $location ?: \IPS\Dispatcher::i()->controllerLocation; /* 3: App JS? */ if ( $file == 'app.js' ) { return static::_appJs( $app, $location ); } /* 3: Is this a controller/template combo? */ if ( mb_strstr( $file, '_') AND mb_substr( $file, -3 ) === '.js' ) { list( $location, $key ) = explode( '_', mb_substr( $file, 0, -3 ) ); if ( ( $location == 'front' OR $location == 'admin' OR $location == 'global' ) AND ! empty( $key ) ) { return static::_sectionJs( $key, $location, $app ); } } /* 4: Is it in the interface directory? */ if ( $location === 'interface' ) { $path = \IPS\ROOT_PATH . "/applications/{$app}/interface/{$file}"; } else if ( $app === 'global' ) { $return = array(); if ( \in_array( $file, \IPS\Output::$globalJavascript ) ) { return static::_directoryJs( \IPS\ROOT_PATH . "/dev/js/" . mb_substr( $file, 0, -3 ) ); } $path = \IPS\ROOT_PATH . "/dev/js"; } else { $path = \IPS\ROOT_PATH . "/applications/{$app}/dev/js/{$location}/{$file}"; } if ( is_dir( $path ) ) { return static::_directoryJs( $path ); } else { return array( str_replace( \IPS\ROOT_PATH, \IPS\Http\Url::baseUrl(), $path ) ); } } since my webroot is /app, this method will cause the url for some of my JS to be something like: //dogwell.codingjungle.test//dogwell.codingjungle.testlications/toolbox/dev/js/front/controllers/profiler/ips.ui.toolbox.lorem.js instead of: //dogwell.codingjungle.test/applications/toolbox/dev/js/front/controllers/profiler/ips.ui.toolbox.lorem.js BomAle and sobrenome 2 Link to comment Share on other sites More sharing options...
bfarber Posted May 4, 2020 Share Posted May 4, 2020 Errr - use a different root then? I mean, do you have a fix that works for you we can take a look at? I'm not really inclined to perform a new installation explicitly in "/app" to test right now, but if you have a suggested fix I'm happy to review it. Link to comment Share on other sites More sharing options...
BomAle Posted May 4, 2020 Share Posted May 4, 2020 11 minutes ago, bfarber said: Errr - use a different root then? I mean, do you have a fix that works for you we can take a look at? I'm not really inclined to perform a new installation explicitly in "/app" to test right now, but if you have a suggested fix I'm happy to review it. http://sandbox.onlinephpfunctions.com/code/a305c2d09672d5775d2110c9bfc67847185bb63a Link to comment Share on other sites More sharing options...
bfarber Posted May 4, 2020 Share Posted May 4, 2020 ROOT_PATH shouldn't literally point to "/app" but if it does, I don't see how we can do much about that. Just use a different folder is what I'm going to recommend. Link to comment Share on other sites More sharing options...
BomAle Posted May 4, 2020 Share Posted May 4, 2020 http://sandbox.onlinephpfunctions.com/code/5bef0ff1fdb892b1a577dff02420625518d45ec2 I suggest to replace return array( str_replace( \IPS\ROOT_PATH, \IPS\Http\Url::baseUrl(), $path ) ); into return array( \substr_replace( $path, \IPS\Http\Url::baseUrl(), 0, \strlen(\IPS\ROOT_PATH) ) ); Link to comment Share on other sites More sharing options...
CodingJungle Posted May 4, 2020 Author Share Posted May 4, 2020 4 hours ago, bfarber said: Errr - use a different root then? I mean, do you have a fix that works for you we can take a look at? I'm not really inclined to perform a new installation explicitly in "/app" to test right now, but if you have a suggested fix I'm happy to review it. i was using lando, a wrapper for docker. from what i could tell there was no way to change /app to something else, that is why i posted it here. it was easier to use lando to replace mysql/php version than it was try to replace it in my distro (cause of the issues with mysql 8 and php 7.4 that i keep running into). my only suggested fix, is where ever you use str_replace to turn paths into url's, to implement the count param: $url = str_replace( \IPS\ROOT_PATH, rtrim( \IPS\Settings::i()->base_url, '/' ), $file ); to $count = 1; $url = str_replace( \IPS\ROOT_PATH, rtrim( \IPS\Settings::i()->base_url, '/' ), $file, $count ); (this is used in several places, i haven't tested it myself. i used a hook on \IPS\Output::sendOutput, to look for dogwell.codingjungle.testlications in the $output param and replace it with applications, but that was a quick and dirty fix, as i would have to adapt it to all my local installations.) Link to comment Share on other sites More sharing options...
Solution bfarber Posted May 5, 2020 Solution Share Posted May 5, 2020 I polled the team and we're going to skip making this change for the time being. If this becomes a prevalent issue we can revisit down the road; sobrenome 1 Link to comment Share on other sites More sharing options...
Recommended Posts