First commit

This commit is contained in:
Pierre Hubert
2016-11-19 12:08:12 +01:00
commit 990540b2b9
4706 changed files with 931207 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# v1.0.0
## 12/22/2015
1. [](#new)
* ChangeLog started...

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Grav
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,61 @@
# Grav Markdown Notices Plugin
The **markdown-notices plugin** for [Grav](http://github.com/getgrav/grav) allows generation of notice blocks of text via markdown:
![](assets/screenshot.png)
# Installation
This plugin is easy to install with GPM.
```
$ bin/gpm install markdown-notices
```
# Configuration
Simply copy the `user/plugins/markdown-notices/markdown-notices.yaml` into `user/config/plugins/markdown-notices.yaml` and make your modifications.
```
enabled: true
built_in_css: true
level_classes: [yellow, red, blue, green]
```
# Examples
Using one level of `!`
```
! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris feugiat quam erat, ut iaculis diam posuere nec.
! Vestibulum eu condimentum urna. Vestibulum feugiat odio ut sodales porta. Donec sit amet ante mi. Donec lobortis
! orci dolor. Donec tristique volutpat ultricies. Nullam tempus, enim sit amet fringilla facilisis, ipsum ex
! tincidunt ipsum, vel placerat sem sem vitae risus. Aenean posuere sed purus nec pretium.
```
You will output the following HTML
```
<div class="notices yellow">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris feugiat quam erat, ut iaculis diam posuere nec.
Vestibulum eu condimentum urna. Vestibulum feugiat odio ut sodales porta. Donec sit amet ante mi. Donec lobortis
orci dolor. Donec tristique volutpat ultricies. Nullam tempus, enim sit amet fringilla facilisis, ipsum ex
tincidunt ipsum, vel placerat sem sem vitae risus. Aenean posuere sed purus nec pretium.
</p>
</div>
```
The `yellow` class is determined by the `level_classes` in the configuration. You can customize this as you need.
```
!! Lorem ipsum dolor sit amet, **consectetur adipiscing** elit. Mauris feugiat quam erat, ut iaculis diam posuere nec.
!!
!! * List item a
!! * List item b
!!
!! orci dolor. Donec tristique volutpat ultricies. Nullam tempus, enim sit amet fringilla facilisis, ipsum ex
!! tincidunt ipsum, vel placerat sem sem vitae risus. Aenean posuere sed purus nec pretium.
```
Two levels of `!!` will use the second level class etc. You can also use complex markdown inside the notices.

View File

@@ -0,0 +1,32 @@
.notices {
padding: 1px 1px 1px 30px;
margin: 15px 0;
}
.notices p {
}
.notices.yellow {
border-left: 10px solid #f0ad4e;
background: #fcf8f2;
color: #df8a13;
}
.notices.red {
border-left: 10px solid #d9534f;
background: #fdf7f7;
color: #b52b27;
}
.notices.blue {
border-left: 10px solid #5bc0de;
background: #f4f8fa;
color: #28a1c5;
}
.notices.green {
border-left: 10px solid #5cb85c;
background: #f1f9f1;
color: #3d8b3d;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

View File

@@ -0,0 +1,44 @@
name: Markdown Notices
version: 1.0.0
description: "Adds the ability to render notices blocks in Markdown"
icon: asterisk
author:
name: Team Grav
email: devs@getgrav.org
url: http://getgrav.org
license: MIT
form:
validation: strict
fields:
enabled:
type: toggle
label: Plugin status
highlight: 1
default: 0
options:
1: Enabled
0: Disabled
validate:
type: bool
built_in_css:
type: toggle
label: Use built in CSS
highlight: 1
default: 1
options:
1: Enabled
0: Disabled
validate:
type: bool
level_classes:
type: selectize
size: large
placeholder: "e.g. yellow, red, blue, green"
label: Level classes
help: The classes to use for each level of notices depth
classes: fancy
validate:
type: commalist

View File

@@ -0,0 +1,84 @@
<?php
namespace Grav\Plugin;
use \Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;
class MarkdownNoticesPlugin extends Plugin
{
protected $level_classes;
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onMarkdownInitialized' => ['onMarkdownInitialized', 0],
'onTwigSiteVariables' => ['onTwigSiteVariables', 0]
];
}
public function onMarkdownInitialized(Event $event)
{
$markdown = $event['markdown'];
$markdown->addBlockType('!', 'Notices', true, false);
$markdown->blockNotices = function($Line) {
$this->level_classes = $this->config->get('plugins.markdown-notices.level_classes');
if (preg_match('/^(!{1,'.count($this->level_classes).'})[ ]+(.*)/', $Line['text'], $matches))
{
$level = strlen($matches[1]) - 1;
// if we have more levels than we support
if ($level > count($this->level_classes)-1)
{
return;
}
$text = $matches[2];
$Block = array(
'element' => array(
'name' => 'div',
'handler' => 'lines',
'attributes' => array(
'class' => 'notices '. $this->level_classes[$level],
),
'text' => (array) $text,
),
);
return $Block;
}
};
$markdown->blockNoticesContinue = function($Line, array $Block) {
if (isset($Block['interrupted']))
{
return;
}
if ($Line['text'][0] === '!' and preg_match('/^(!{1,'.count($this->level_classes).'})(.*)/', $Line['text'], $matches))
{
$Block['element']['text'] []= ltrim($matches[2]);
return $Block;
}
};
}
public function onTwigSiteVariables()
{
if ($this->config->get('plugins.markdown-notices.built_in_css')) {
$this->grav['assets']
->add('plugin://markdown-notices/assets/notices.css');
}
}
}

View File

@@ -0,0 +1,3 @@
enabled: true
built_in_css: true
level_classes: [yellow, red, blue, green]