├── drafts.png ├── nodrafts.png ├── drafts-logo.png ├── drafts-widget.php ├── package.json ├── drafts ├── drafts.php └── template.php ├── helpers.php ├── LICENSE └── README.md /drafts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thiousi/kirby-drafts-widget/HEAD/drafts.png -------------------------------------------------------------------------------- /nodrafts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thiousi/kirby-drafts-widget/HEAD/nodrafts.png -------------------------------------------------------------------------------- /drafts-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thiousi/kirby-drafts-widget/HEAD/drafts-logo.png -------------------------------------------------------------------------------- /drafts-widget.php: -------------------------------------------------------------------------------- 1 | set('widget', 'drafts', __DIR__ . DS . 'drafts'); 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "drafts-widget", 3 | "description": "Panel dashboard widget displaying all unpublished pages", 4 | "author": "Mathieu Etienne", 5 | "license": "MIT", 6 | "version": "1.2.0", 7 | "type": "kirby-plugin" 8 | } 9 | -------------------------------------------------------------------------------- /drafts/drafts.php: -------------------------------------------------------------------------------- 1 | array( 8 | 'text' => c::get('plugin.drafts.widget.title', 'Your drafts'), 9 | 'compressed' => false, 10 | ), 11 | 'html' => function() { 12 | return tpl::load(__DIR__ . DS . 'template.php'); 13 | } 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /helpers.php: -------------------------------------------------------------------------------- 1 | site()->index()->invisible()->not($excluded); 6 | return $drafts; 7 | } 8 | 9 | function hasDrafts() { 10 | return drafts()->count() !== 0; 11 | } 12 | 13 | function showDraftsWidget() { 14 | $hide_if_empty = c::get('plugin.drafts.widget.hide.empty', true); 15 | return !$hide_if_empty || hasDrafts(); 16 | } 17 | -------------------------------------------------------------------------------- /drafts/template.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 | 7 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Mathieu Etienne 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kirby Drafts Widget 2 | ![Kirby Drafts Widget logo](https://github.com/Thiousi/kirby-drafts-widget/blob/master/drafts-logo.png) 3 | 4 | ![Version](https://img.shields.io/badge/version-1.2.0-green.svg) 5 | ![License](https://img.shields.io/badge/license-MIT-green.svg) 6 | ![Kirby Version](https://img.shields.io/badge/Kirby-2.3%2B-red.svg) 7 | 8 | Panel dashboard widget displaying all unpublished pages for [Kirby](http://getkirby.com). 9 | 10 | ![Kirby Drafts Widget screenshot](https://github.com/Thiousi/kirby-drafts-widget/blob/master/drafts.png) 11 | 12 | ## Installation 13 | 14 | ### 1. Kirby CLI 15 | 16 | If you are using the [Kirby CLI](https://github.com/getkirby/cli) you can install this plugin by running the following command in your shell from the root folder of your Kirby installation: 17 | 18 | ``` 19 | kirby plugin:install Thiousi/kirby-drafts-widget 20 | ``` 21 | 22 | ### 2. Manual 23 | [Download this archive](https://github.com/Thiousi/kirby-drafts-widget/archive/master.zip), extract it and rename it to `drafts-widget`. Copy the folder to your `site/plugins` folder. 24 | 25 | ### 3. Git Submodule 26 | If you know your way around git, you can download this as a submodule: 27 | 28 | ``` 29 | $ git submodule add https://github.com/Thiousi/kirby-drafts-widget site/plugins/drafts-widget 30 | ``` 31 | 32 | ## Usage 33 | You don't have anything to do once the widget is installed. The widget has two states: 34 | 35 | ### 1. No drafts to display 36 | 37 | ![Kirby Drafts Widget no drafts](https://github.com/Thiousi/kirby-drafts-widget/blob/master/nodrafts.png) 38 | 39 | ### 2. Drafts to display 40 | 41 | ![Kirby Drafts Widget unpublished](https://github.com/Thiousi/kirby-drafts-widget/blob/master/drafts.png) 42 | 43 | ## Options 44 | 45 | The following options can be set in your `/site/config/config.php` file: 46 | 47 | ```php 48 | /* Drafts widget */ 49 | c::set('plugin.drafts.widget.exclude', array('error')); 50 | c::set('plugin.drafts.widget.title', 'Your drafts'); 51 | c::set('plugin.drafts.widget.nodrafts', 'No drafts... Start writing today!'); 52 | c::set('plugin.drafts.widget.hide.empty', false); 53 | ``` 54 | 55 | ### plugin.drafts.widget.exclude 56 | 57 | This option is an array of pages that will be excluded from the drafts widget. Add pages after 'error', separated by a comma, and between single quotes 58 | 59 | ### plugin.drafts.widget.title 60 | 61 | This option is a string, which is displayed instead of 'Your drafts' as the title of the widget. 62 | 63 | ### plugin.drafts.widget.nodrafts 64 | 65 | This option is a string, which is displayed instead of the list of drafts when there are no drafts. 66 | 67 | ### plugin.drafts.widget.hide.empty 68 | 69 | This option is a boolean. Set it to true to hide the widget if there are no drafts. Of course, the value of `plugin.drafts.widget.nodrafts` is meaningless then. 70 | 71 | 72 | ## To-do 73 | - [x] Internationalize widget? Already ok for draft names, only message is not internationalized 74 | - [X] ~~Get list of excluded pages from configuration instead of widget code~~ 75 | - [X] ~~Update readme~~ 76 | - [X] ~~Make it CLI and submodule compatible~~ 77 | 78 | ## Credits 79 | This plugin was created as part of writing up a tutorial on macotuts: https://macotuts.com/tuto/medium/creating-first-widget 80 | 81 | ## License 82 | MIT 83 | 84 | ## Changelog 85 | ### 1.0.0 86 | - Initialial release 87 | 88 | ### 1.1.0 89 | - Made CLI compatible 90 | - Made Submodule compatible 91 | - Enhanced Readme 92 | - Updated screenshots 93 | - Fixed compressed headline and spacing issues 94 | 95 | ### 1.2.0 96 | - Text now set in configuration 97 | - List of excluded pages now set in configuration 98 | - Readme enhanced with options 99 | --------------------------------------------------------------------------------