From b711c2704cdb2609654fc0e0d6345da7db82a268 Mon Sep 17 00:00:00 2001 From: Rougin Royce Gutib Date: Mon, 14 Sep 2015 20:31:17 +0800 Subject: [PATCH] Added support for Bower. Fixes https://github.com/rougin/combustor/issues/6 --- src/Commands/CreateLayoutCommand.php | 54 +++++++++++++++++++-------- src/Templates/Views/Layout/Footer.php | 2 +- src/Templates/Views/Layout/Header.php | 2 +- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/Commands/CreateLayoutCommand.php b/src/Commands/CreateLayoutCommand.php index b8082b6..815b091 100644 --- a/src/Commands/CreateLayoutCommand.php +++ b/src/Commands/CreateLayoutCommand.php @@ -73,25 +73,49 @@ protected function execute(InputInterface $input, OutputInterface $output) '4.2.0/css/font-awesome.min.css' ]; + $fontAwesome = ! is_dir('bower_components/font-awesome') + ? system('bower install font-awesome') + : TRUE; + + if ($fontAwesome) { + $data['styleSheets'][0] = ''; + } + if ($input->getOption('bootstrap')) { $data['bootstrapContainer'] = 'container'; - - array_push( - $data['styleSheets'], - 'https://maxcdn.bootstrapcdn.com/bootstrap/' . - '3.2.0/css/bootstrap.min.css' - ); - array_push( - $data['scripts'], - 'https://code.jquery.com/jquery-2.1.1.min.js' - ); + $bootstrapCss = 'https://maxcdn.bootstrapcdn.com/bootstrap/' . + '3.2.0/css/bootstrap.min.css'; - array_push( - $data['scripts'], - 'https://maxcdn.bootstrapcdn.com/bootstrap/' . - '3.2.0/css/bootstrap.min.js' - ); + $bootstrapJs = 'https://maxcdn.bootstrapcdn.com/bootstrap/' . + '3.2.0/css/bootstrap.min.js'; + + $jquery = 'https://code.jquery.com/jquery-2.1.1.min.js'; + + $bower = ! is_dir('bower_components/bootstrap') + ? system('bower install bootstrap') + : TRUE; + + if ($bower) { + $bootstrapCss = ''; + + $bootstrapJs = ''; + + $jquery = ''; + } + + array_push($data['styleSheets'], $bootstrapCss); + array_push($data['scripts'], $jquery); + array_push($data['scripts'], $bootstrapJs); } if ( ! @mkdir($filePath, 0777, TRUE)) { diff --git a/src/Templates/Views/Layout/Footer.php b/src/Templates/Views/Layout/Footer.php index 2af7d52..62f4a6b 100644 --- a/src/Templates/Views/Layout/Footer.php +++ b/src/Templates/Views/Layout/Footer.php @@ -1,5 +1,5 @@ {% for script in scripts %} - + {% endfor %} session->flashdata('notification')): ?>