├── custom-css.yaml ├── CHANGELOG.md ├── README.md ├── LICENSE ├── languages.yaml ├── custom-css.php └── blueprints.yaml /custom-css.yaml: -------------------------------------------------------------------------------- 1 | enabled: true 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v0.2.2 2 | ## 12/19/2018 3 | 4 | 1. [](#new) 5 | * Added translation 6 | 1. [](#improved) 7 | * Use Codemirror for Inline CSS 8 | 9 | # v0.2.1 10 | ## 07/27/2016 11 | 12 | 1. [](#bugfix) 13 | * Fix running plugin without adding CSS files to include [#2](https://github.com/getgrav/grav-plugin-custom-css/issues/2) 14 | 15 | # v0.2.0 16 | ## 05/23/2016 17 | 18 | 1. [](#new) 19 | * Added field to manipulate priority 20 | 21 | # v0.1.0 22 | ## 05/02/2016 23 | 24 | 1. [](#new) 25 | * ChangeLog started... 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Custom CSS Plugin 2 | 3 | The **Custom CSS** Plugin for the [Grav CMS](http://github.com/getgrav/grav) allows to add additional CSS to your site, without editing the theme or having to create a plugin for the simple task of adding some custom lines of sylesheets. 4 | 5 | ## Description 6 | 7 | Adds some custom CSS to your Grav site. 8 | 9 | Open the plugin preferences in the Admin panel, and add custom CSS directly in the textarea, which will be added as inline CSS, or enter one or more relative paths to load. (e.g. `/user/my_css/custom.css`) 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Grav 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /languages.yaml: -------------------------------------------------------------------------------- 1 | en: 2 | PLUGIN_CUSTOM_CSS: 3 | INLINE_CSS: "Inline CSS" 4 | INLINE_CSS_HELP: "CSS that will be added inline to every page" 5 | CSS_FILES: "CSS Files" 6 | CSS_FILES_HELP: "CSS Files that will be loaded on every page. Use relative or absolute URLs" 7 | CSS_FILES_PATH: "File path" 8 | CSS_FILES_PATH_HELP: "Relative to web root" 9 | CSS_FILES_PATH_PRIORITY: "Priority (0=Default)" 10 | CSS_FILES_PATH_PRIORITY_HELP: "Lower means later inclusion. Negative value to add this file after the other files (that come with the theme)" 11 | ru: 12 | PLUGIN_CUSTOM_CSS: 13 | INLINE_CSS: "Встроенный CSS" 14 | INLINE_CSS_HELP: "CSS код, который будет добавлен на каждой странице" 15 | CSS_FILES: "CSS файлы" 16 | CSS_FILES_HELP: "CSS файлы, которые будут загружаться на каждой странице. Используйте относительные или абсолютные URL" 17 | CSS_FILES_PATH: "Путь к файлу" 18 | CSS_FILES_PATH_HELP: "Относительно корня" 19 | CSS_FILES_PATH_PRIORITY: "Приоритет (0=По умолчанию)" 20 | CSS_FILES_PATH_PRIORITY_HELP: "Меньше - файл подключается позже. Отрицательное значение для подключения этого файла после других файлов (которые поставляются с темой)" -------------------------------------------------------------------------------- /custom-css.php: -------------------------------------------------------------------------------- 1 | ['onPluginsInitialized', 0] 20 | ]; 21 | } 22 | 23 | /** 24 | * Initialize the plugin 25 | */ 26 | public function onPluginsInitialized() 27 | { 28 | // Don't proceed if we are in the admin plugin 29 | if ($this->isAdmin()) { 30 | return; 31 | } 32 | 33 | $this->enable([ 34 | 'onAssetsInitialized' => ['onAssetsInitialized', 0] 35 | ]); 36 | } 37 | 38 | public function onAssetsInitialized() 39 | { 40 | $this->grav['assets']->addInlineCss($this->config->get('plugins.custom-css.css_inline')); 41 | 42 | foreach($this->config->get('plugins.custom-css.css_files', []) as $file) { 43 | if (trim($file['path']) !== '') { 44 | $this->grav['assets']->addCss($file['path'], isset($file['priority']) ? $file['priority'] : null); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /blueprints.yaml: -------------------------------------------------------------------------------- 1 | name: Custom CSS 2 | version: 0.2.2 3 | description: Adds some custom CSS to your Grav site 4 | icon: plug 5 | author: 6 | name: Team Grav 7 | email: devs@getgrav.org 8 | homepage: https://github.com/getgrav/grav-plugin-custom-css 9 | keywords: grav, plugin, css, design 10 | bugs: https://github.com/getgrav/grav-plugin-custom-css/issues 11 | readme: https://github.com/getgrav/grav-plugin-custom-css/blob/develop/README.md 12 | license: MIT 13 | 14 | form: 15 | validation: strict 16 | fields: 17 | enabled: 18 | type: toggle 19 | label: PLUGIN_ADMIN.PLUGIN_STATUS 20 | highlight: 1 21 | default: 0 22 | options: 23 | 1: PLUGIN_ADMIN.ENABLED 24 | 0: PLUGIN_ADMIN.DISABLED 25 | validate: 26 | type: bool 27 | 28 | css_inline: 29 | type: editor 30 | codemirror: 31 | mode: css 32 | label: PLUGIN_CUSTOM_CSS.INLINE_CSS 33 | help: PLUGIN_CUSTOM_CSS.INLINE_CSS_HELP 34 | 35 | css_files: 36 | type: list 37 | label: PLUGIN_CUSTOM_CSS.CSS_FILES 38 | help: PLUGIN_CUSTOM_CSS.CSS_FILES_HELP 39 | fields: 40 | .path: 41 | type: text 42 | label: PLUGIN_CUSTOM_CSS.CSS_FILES_PATH 43 | help: PLUGIN_CUSTOM_CSS.CSS_FILES_PATH_HELP 44 | .priority: 45 | type: int 46 | label: PLUGIN_CUSTOM_CSS.CSS_FILES_PATH_PRIORITY 47 | help: PLUGIN_CUSTOM_CSS.CSS_FILES_PATH_PRIORITY_HELP 48 | default: 0 49 | --------------------------------------------------------------------------------