├── BootswatchAsset.php ├── CHANGE.md ├── LICENSE.md ├── README.md └── composer.json /BootswatchAsset.php: -------------------------------------------------------------------------------- 1 | css = [ 43 | strtolower(self::$theme).'/bootstrap'.( YII_ENV_DEV ? '.css' : '.min.css' ) 44 | ]; 45 | 46 | // optimized asset publication : only publish bootswatch theme folders and font folder. 47 | 48 | $this->publishOptions['beforeCopy'] = function ($from, $to) { 49 | if ( is_dir($from)) { 50 | $name = pathinfo($from,PATHINFO_BASENAME); 51 | return ! in_array($name, ['2','api','assets','bower_components','tests','help','global','default']); 52 | } else { 53 | $ext = pathinfo($from,PATHINFO_EXTENSION); 54 | return in_array($ext,['css','eot','svg','ttf','woff','woff2']); 55 | } 56 | }; 57 | } 58 | parent::init(); 59 | } 60 | 61 | /** 62 | * Chekcs if a theme is a valid bootswatch theme. 63 | * 64 | * This basic method assumes the $theme name passed as argument is an existing 65 | * subfolder of the vendor alias folder (@vendor/thomaspark/bootswatch) that contains 66 | * the file 'bootstrap.min.css'. If this condition is not true, the theme is invalid. 67 | * 68 | * @param string $theme the theme name to test 69 | * @return boolean TRUE if $theme is a valid bootswatch theme, FALSE otherwise 70 | */ 71 | static function isSupportedTheme($theme) 72 | { 73 | if (! is_string($theme) || empty($theme)) { 74 | throw new InvalidCallException('Invalid theme value : empty or null value'); 75 | } 76 | return file_exists(Yii::getAlias(BootswatchAsset::VENDOR_ALIAS . '/' . strtolower($theme) . '/bootstrap.min.css')); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /CHANGE.md: -------------------------------------------------------------------------------- 1 | # version 1.2.7 2 | - update to bootswatch 3.3.7 3 | 4 | # version 1.2.6 5 | - update to bootswatch 3.3.6+1 6 | 7 | # version 1.2.5 8 | - update dependency : thomaspark/bootswatch version 3.3.5+2. This is to avoid the *Failed to decode downloaded font* error message (see https://github.com/raoul2000/yii2-bootswatch-asset/issues/5) 9 | 10 | # version 1.2.4 11 | - update dependency : thomaspark/bootswatch version 3.3.5 12 | 13 | # version 1.2.3 14 | - update dependency : thomaspark/bootswatch version 3.3.4 15 | 16 | # version 1.2.2 17 | - fix : publish *woff2* font "glyphicons-halflings-regular.woff2" (thanks to [jwerner](http://www.yiiframework.com/user/147/)) 18 | 19 | # version 1.2.1 20 | - update dependency : thomaspark/bootswatch version 3.3.2 after bootstrap 3.3.2 has been release 21 | 22 | # version 1.2.0 23 | - update dependency : thomaspark/bootswatch version 3.3.1 in order to include latest bootswatch themes (journal, sandstone). 24 | - code style 25 | - update README.md : add warning 26 | 27 | # version 1.1.1 28 | - fix : minified CSS was not correctly handled. Now, if YII_ENV_DEV is defined bootstrap.css is published, otherwise 29 | its bootstrap.min.css 30 | 31 | # version 1.1.0 32 | - fix : gylphicons not accessible. 33 | - enh : optimize publication process. When no theme is set, no publication is performed. 34 | - enh : no theme is selected by default. 35 | 36 | # version 1.0.0 37 | - Initial release 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Raoul 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | yii2-bootswatch-asset 2 | ========================== 3 | Asset bunlde around the Bootswatch theme suite. Visit [Bootswatch](http://bootswatch.com/) for more. 4 | 5 | [![Latest Stable Version](https://poser.pugx.org/raoul2000/yii2-bootswatch-asset/v/stable.svg)](https://packagist.org/packages/raoul2000/yii2-bootswatch-asset) [![Total Downloads](https://poser.pugx.org/raoul2000/yii2-bootswatch-asset/downloads.svg)](https://packagist.org/packages/raoul2000/yii2-bootswatch-asset) 6 | 7 | This extension is for Bootstrap prior to version 3. If you're using **Bootstrap 4**, please use the [yii2-bootswatch4-asset](https://github.com/raoul2000/yii2-bootswatch4-asset) extension. 8 | 9 | Installation 10 | ------------ 11 | 12 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). 13 | 14 | Either run 15 | 16 | ``` 17 | php composer.phar require --prefer-dist raoul2000/yii2-bootswatch-asset "*" 18 | ``` 19 | 20 | or add 21 | 22 | ``` 23 | "raoul2000/yii2-bootswatch-asset": "*" 24 | ``` 25 | 26 | to the require section of your `composer.json` file. 27 | 28 | 29 | Usage 30 | ----- 31 | To use a bootswatch theme in your Yii2 application add the BootswatchAsset bundle to your main AppAsset bundle: 32 | 33 | ```php 34 | 35 | // ./assets/AppAsset.php 36 | 37 | class AppAsset extends AssetBundle 38 | { 39 | public $basePath = '@webroot'; 40 | public $baseUrl = '@web'; 41 | public $css = [ 42 | 'css/site.css', 43 | ]; 44 | public $js = [ 45 | ]; 46 | public $depends = [ 47 | 'yii\web\YiiAsset', 48 | 'raoul2000\bootswatch\BootswatchAsset', 49 | ]; 50 | } 51 | ?> 52 | ``` 53 | 54 | Then at some point you must select the theme name you want to use. In the example below, the theme 'cosmo' is set in the main layout. 55 | 56 | ```php 57 | 58 | // ./views/layouts/main.php 59 | 60 | raoul2000\bootswatch\BootswatchAsset::$theme = 'cosmo'; 61 | AppAsset::register($this); 62 | 63 | ``` 64 | 65 | 66 | License 67 | ------- 68 | 69 | **yii2-bootswatch-asset** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details. 70 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "raoul2000/yii2-bootswatch-asset", 3 | "description" : "Use Bootswatch theme in your Yii application with minimum effort", 4 | "type" : "yii2-extension", 5 | "keywords" : [ 6 | "yii2", 7 | "extension", 8 | "assets", 9 | "bootstrap", 10 | "skin", 11 | "bootswatch", 12 | "theme", 13 | "stlye", 14 | "css" 15 | ], 16 | "license" : "BSD-3-Clause", 17 | "authors" : [{ 18 | "name" : "Raoul", 19 | "email" : "raoul.boulard@gmail.com" 20 | } 21 | ], 22 | "require" : { 23 | "yiisoft/yii2" : "*", 24 | "thomaspark/bootswatch" : "3.3.7" 25 | }, 26 | "autoload" : { 27 | "psr-4" : { 28 | "raoul2000\\bootswatch\\" : "" 29 | } 30 | } 31 | } 32 | --------------------------------------------------------------------------------