Skip to content

Commit

Permalink
Added support for Bower. Fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Sep 14, 2015
1 parent a18e7d8 commit b711c27
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
54 changes: 39 additions & 15 deletions src/Commands/CreateLayoutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] = '<?php echo base_url(\'' .
'bower_components/font-awesome/css/' .
'font-awesome.min.css'
. '\'); ?>';
}

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 = '<?php echo base_url(\'' .
'bower_components/bootstrap/dist/css/bootstrap.min.css'
. '\'); ?>';

$bootstrapJs = '<?php echo base_url(\'' .
'bower_components/bootstrap/dist/js/bootstrap.min.js'
. '\'); ?>';

$jquery = '<?php echo base_url(\'' .
'bower_components/jquery/dist/jquery.min.js'
. '\'); ?>';
}

array_push($data['styleSheets'], $bootstrapCss);
array_push($data['scripts'], $jquery);
array_push($data['scripts'], $bootstrapJs);
}

if ( ! @mkdir($filePath, 0777, TRUE)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Views/Layout/Footer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% for script in scripts %}
<script type="text/javascript" src="{{ script }}"></script>
<script type="text/javascript" src="{{ script | raw }}"></script>
{% endfor %}
<?php if ($this->session->flashdata('notification')): ?>
<script type="text/javascript">
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Views/Layout/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="author" content="">
<title>Document <?php echo ($this->uri->segment(1)) ? ' - ' . ucwords(str_replace('_', ' ', $this->uri->segment(1))) : NULL; ?></title>
{% for styleSheet in styleSheets %}
<link rel="stylesheet" type="text/css" href="{{ styleSheet }}">
<link rel="stylesheet" type="text/css" href="{{ styleSheet | raw }}">
{% endfor %}
</head>
<body>
Expand Down

0 comments on commit b711c27

Please sign in to comment.