Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 25, 2018
2 parents acdebf5 + 51d1eb2 commit 9f94fc6
Show file tree
Hide file tree
Showing 21 changed files with 15,546 additions and 39 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v2.0.0
## 05/25/2018

1. [](#new)
* Added support for Bootstrap **v4.1.1** (with Popper.js)

# v1.3.4
## 02/01/2017

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ Bootstrapper is **enabled** but **not active** by default. You can change this

```
enabled: true # Enable / Disable this plugin
version: v3 # Choose which version of Bootstrap should be loaded - `v3` for `v3.3.7` or `v4` for `v4.1.1`
always_load: false # If set to `false` the Theme must have `public $load_bootstrapper_plugin = true;` to add the CSS/JS
use_cdn: false # If set to `true` Bootstrap's CSS and JavaScript loads from CDN
mode: production # Production mode will use the `.min` compressed CSS and JS files
load_core_css: true # Load the core `bootstrap.css` CSS file
load_theme_css: true # Load the theme `bootstrap-theme.css` CSS file
load_theme_css: true # Load the theme `bootstrap-theme.css` CSS file (only Bootstrap `v3.3.7`)
load_popper_js: true # Load the `popper.js` JS file (only Bootstrap `v4.1.1`)
load_core_js: true # Load the core `bootstrap.js` JS file
```
25 changes: 22 additions & 3 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bootstrapper
version: 1.3.4
description: "Loads the Bootstrap Framework v3.3.7 assets for any plugin/theme that needs it"
version: 2.0.0
description: "Loads the Bootstrap Framework assets for any plugin/theme that needs it"
icon: bold
author:
name: Team Grav
Expand All @@ -26,6 +26,15 @@ form:
validate:
type: bool

version:
type: select
size: small
label: PLUGIN_BOOTSTRAPPER.VERSION
default: 'v3'
options:
v3: 'Bootstrap v3.3.7'
v4: 'Bootstrap v4.1.1'

always_load:
type: toggle
label: PLUGIN_BOOTSTRAPPER.ALWAYS_LOAD
Expand Down Expand Up @@ -59,7 +68,6 @@ form:
development: Development
production: Production


load_core_css:
type: toggle
label: PLUGIN_BOOTSTRAPPER.LOAD_CORE_CSS
Expand All @@ -82,6 +90,17 @@ form:
validate:
type: bool

load_popper_js:
type: toggle
label: PLUGIN_BOOTSTRAPPER.LOAD_POPPER_JS
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool

load_core_js:
type: toggle
label: PLUGIN_BOOTSTRAPPER.LOAD_CORE_JS
Expand Down
35 changes: 26 additions & 9 deletions bootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,47 @@ public function onThemeInitialized()
public function onTwigSiteVariables()
{
$config = $this->config->get('plugins.bootstrapper');
$version = $config['version'];
$mode = $config['mode'] == 'production' ? '.min' : '';

$bootstrap_bits = [];
$currentVersion = '3.3.7';

if ($version == 'v4') {
$currentVersion = '4.1.1';
$bootstrapCDN = 'https://stackpath.bootstrapcdn.com/';
} else {
$currentVersion = '3.3.7';
$bootstrapCDN = 'https://maxcdn.bootstrapcdn.com/';
}

// Popper configuration (Bootstrap 4 only)
$currentPopperVersion = '1.14.3';

if ($config['use_cdn']) {
if ($config['load_core_css']) {
$bootstrap_bits[] = "https://maxcdn.bootstrapcdn.com/bootstrap/{$currentVersion}/css/bootstrap{$mode}.css";
$bootstrap_bits[] = "{$bootstrapCDN}/bootstrap/{$currentVersion}/css/bootstrap{$mode}.css";
}
if ($config['load_theme_css'] && $version == 'v3') {
$bootstrap_bits[] = "{$bootstrapCDN}/bootstrap/{$currentVersion}/css/bootstrap-theme{$mode}.css";
}
if ($config['load_theme_css']) {
$bootstrap_bits[] = "https://maxcdn.bootstrapcdn.com/bootstrap/{$currentVersion}/css/bootstrap-theme{$mode}.css";
if ($config['load_popper_js'] && $version == 'v4') {
$bootstrap_bits[] = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/{$currentPopperVersion}/umd/popper{$mode}.js";
}
if ($config['load_core_js']) {
$bootstrap_bits[] = "https://maxcdn.bootstrapcdn.com/bootstrap/{$currentVersion}/js/bootstrap{$mode}.js";
$bootstrap_bits[] = "{$bootstrapCDN}/bootstrap/{$currentVersion}/js/bootstrap{$mode}.js";
}
} else {
if ($config['load_core_css']) {
$bootstrap_bits[] = "plugin://bootstrapper/css/bootstrap{$mode}.css";
$bootstrap_bits[] = "plugin://bootstrapper/css/{$version}/bootstrap{$mode}.css";
}
if ($config['load_theme_css'] && $version == 'v3') {
$bootstrap_bits[] = "plugin://bootstrapper/css/{$version}/bootstrap-theme{$mode}.css";
}
if ($config['load_theme_css']) {
$bootstrap_bits[] = "plugin://bootstrapper/css/bootstrap-theme{$mode}.css";
if ($config['load_popper_js'] && $version == 'v4') {
$bootstrap_bits[] = "plugin://bootstrapper/js/{$version}/popper{$mode}.js";
}
if ($config['load_core_js']) {
$bootstrap_bits[] = "plugin://bootstrapper/js/bootstrap{$mode}.js";
$bootstrap_bits[] = "plugin://bootstrapper/js/{$version}/bootstrap{$mode}.js";
}
}

Expand Down
2 changes: 2 additions & 0 deletions bootstrapper.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
enabled: true
version: v3
always_load: false
use_cdn: false
mode: production
load_core_css: true
load_theme_css: true
load_popper_js: true
load_core_js: true
6 changes: 0 additions & 6 deletions css/bootstrap.min.css

This file was deleted.

File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions css/bootstrap.css → css/v3/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions css/v3/bootstrap.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 9f94fc6

Please sign in to comment.