This repository has been archived by the owner on Aug 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbootstrap-blog.php
executable file
·83 lines (68 loc) · 2.69 KB
/
bootstrap-blog.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace Grav\Theme;
use Grav\Common\Grav;
use Grav\Common\Theme;
class BootstrapBlog extends Theme
{
public static function getSubscribedEvents()
{
return [
'onThemeInitialized' => ['onThemeInitialized', 0]
];
}
/**
* Get Taxonomies on item selector
* @static
*/
public static function getTaxonomies()
{
return Grav::instance()['config']->get('site.taxonomies') ?: [];
}
/**
* Initialize configuration
*/
public function onThemeInitialized()
{
if ($this->isAdmin()) {
return;
}
if ($this->config->get('themes.bootstrap-blog.enabled')) {
$this->enable([
'onAssetsInitialized' => ['onAssetsInitialized', 0]
]);
}
}
/**
* Creates collection Bootstrap Blog for CSS and JS files
*/
public function onAssetsInitialized()
{
$config = $this->config->get('themes.bootstrap-blog');
$collection = [];
if ($config['cdn_enabled']) {
$collection[] = 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css';
$collection[] = 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap-reboot.min.css';
$collection[] = 'https://use.fontawesome.com/releases/v5.14.0/css/all.css';
$collection[] = 'https://use.fontawesome.com/releases/v5.14.0/css/brands.css';
$collection[] = 'https://code.jquery.com/jquery-3.3.1.min.js';
$collection[] = 'https://unpkg.com/popper.js@1.15.0/dist/umd/popper.min.js';
$collection[] = 'https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js';
} else {
$collection[] = 'theme://assets/css-compiled/bootstrap/bootstrap.css';
$collection[] = 'theme://assets/css-compiled/bootstrap/bootstrap-reboot.css';
$collection[] = 'theme://assets/css/fontawesome.css';
$collection[] = 'theme://assets/css/solid.css';
$collection[] = 'theme://assets/css/regular.css';
$collection[] = 'theme://assets/css/brands.css';
$collection[] = 'theme://assets/css/normalize.css';
$collection[] = 'theme://assets/js/jquery-3.3.1.min.js';
$collection[] = 'theme://assets/js/popper.min.js';
$collection[] = 'theme://assets/js/bootstrap.min.js';
}
$collection[] = 'theme://assets/css-compiled/bootstrap-blog.css';
$collection[] = 'theme://assets/js/bootstrap_blog.js';
$assets = $this->grav['assets'];
$assets->registerCollection('bootstrap-blog', $collection);
$assets->add('bootstrap-blog', 100);
}
}