Support folders within folders for JS path

This commit is contained in:
Dane Everitt 2016-10-06 17:27:30 -04:00
parent 24d49be150
commit 77198b48df
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 18 additions and 4 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@ composer.lock
Homestead.yaml
Vagrantfile
Vagrantfile
node_modules
.babelrc

View File

@ -38,6 +38,8 @@ use Pterodactyl\Repositories\ServerRepository;
use Pterodactyl\Http\Controllers\Controller;
use Illuminate\Http\Request;
use InvalidArgumentException;
class ServerController extends Controller
{
@ -54,10 +56,19 @@ class ServerController extends Controller
public function getJavascript(Request $request, $uuid, $folder, $file)
{
$server = Models\Server::getByUUID($uuid);
return response()->view('server.js.' . $folder . '.' . basename($file, '.js'), [
'server' => $server,
'node' => Models\Node::find($server->node)
])->header('Content-Type', 'application/javascript');
$info = pathinfo($file);
$routeFile = str_replace('/', '.', $info['dirname']) . '.' . $info['filename'];
try {
return response()->view('server.js.' . $folder . '.' . $routeFile, [
'server' => $server,
'node' => Models\Node::find($server->node)
])->header('Content-Type', 'application/javascript');
} catch (InvalidArgumentException $ex) {
return abort(404);
} catch (\Exception $ex) {
throw $ex;
}
}
/**