first commit

This commit is contained in:
2020-06-11 16:42:43 +02:00
commit 449ca1d987
5099 changed files with 622034 additions and 0 deletions
@@ -0,0 +1,30 @@
# v1.0.4
## 09/10/2019
1. [](#improved)
* Reverted PR#10 which was breaking multiline notices and also unintentionally marking up notices with `<space>!<space>` in paragraphs
# v1.0.3
## 08/16/2019
1. [](#improved)
* Fixed issue where PR#10 clobbered PR#9
# v1.0.2
## 08/11/2019
1. [](#new)
* Ability to specify your own base classes [#9](https://github.com/getgrav/grav-plugin-markdown-notices/pull/9)
* Allow adding inline notices inside tables [#10](https://github.com/getgrav/grav-plugin-markdown-notices/pull/10)
# v1.0.1
## 03/09/2018
1. [](#improved)
* Updated blueprint file
# v1.0.0
## 12/22/2015
1. [](#new)
* ChangeLog started...
+21
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.
+62
View File
@@ -0,0 +1,62 @@
# 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
base_classes: 'notices'
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 `notices` class determined by the `base_classes` and `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.
@@ -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

@@ -0,0 +1,55 @@
name: 'Markdown Notices'
version: 1.0.4
description: 'Adds the ability to render notices blocks in Markdown'
icon: asterisk
author:
name: Team Grav
email: devs@getgrav.org
url: http://getgrav.org
homepage: https://github.com/getgrav/grav-plugin-markdown-notices
license: MIT
form:
validation: strict
fields:
enabled:
type: toggle
label: PLUGIN_ADMIN.PLUGIN_STATUS
highlight: 1
default: 0
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
built_in_css:
type: toggle
label: PLUGIN_MARKDOWN_NOTICES.USE_BUILT_IN_CSS
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
base_classes:
type: selectize
label: PLUGIN_MARKDOWN_NOTICES.BASE_CLASSES
size: large
placeholder: PLUGIN_MARKDOWN_NOTICES.BASE_CLASSES_PLACEHOLDER
help: PLUGIN_MARKDOWN_NOTICES.BASE_CLASSES_HELP
classes: fancy
validate:
type: string
level_classes:
type: selectize
label: PLUGIN_MARKDOWN_NOTICES.LEVEL_CLASSES
size: large
placeholder: PLUGIN_MARKDOWN_NOTICES.LEVEL_CLASSES_PLACEHOLDER
help: PLUGIN_MARKDOWN_NOTICES.LEVEL_CLASSES_HELP
classes: fancy
validate:
type: commalist
@@ -0,0 +1,29 @@
en:
PLUGIN_MARKDOWN_NOTICES:
USE_BUILT_IN_CSS: 'Use built-in CSS'
BASE_CLASSES: 'Base classes'
BASE_CLASSES_HELP: 'These classes will be added before the class level'
BASE_CLASSES_PLACEHOLDER: 'e.g. notices'
LEVEL_CLASSES: 'Level classes'
LEVEL_CLASSES_HELP: 'The classes to use for each level of notices depth'
LEVEL_CLASSES_PLACEHOLDER: 'e.g. yellow, red, blue, green'
ru:
PLUGIN_MARKDOWN_NOTICES:
USE_BUILT_IN_CSS: 'Использовать встроенный CSS'
BASE_CLASSES: 'Базовые классы'
BASE_CLASSES_HELP: 'Эти классы будут добавлены до уровня класса'
BASE_CLASSES_PLACEHOLDER: 'например notices'
LEVEL_CLASSES: 'Классы уровней'
LEVEL_CLASSES_HELP: 'Эти классы используются на каждом уровне глубины уведомлений'
LEVEL_CLASSES_PLACEHOLDER: 'например yellow, red, blue, green'
uk:
PLUGIN_MARKDOWN_NOTICES:
USE_BUILT_IN_CSS: 'Використовувати вбудований CSS'
BASE_CLASSES: 'Базові класи'
BASE_CLASSES_HELP: 'Ці класи будуть додані до рівня класу'
BASE_CLASSES_PLACEHOLDER: 'наприклад notices'
LEVEL_CLASSES: 'Класи рівнів'
LEVEL_CLASSES_HELP: 'Ці класи використовуються на кожному рівні глибини повідомлень'
LEVEL_CLASSES_PLACEHOLDER: 'наприклад yellow, red, blue, green'
@@ -0,0 +1,84 @@
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;
class MarkdownNoticesPlugin extends Plugin
{
protected $base_classes;
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');
$this->base_classes = $this->config->get('plugins.markdown-notices.base_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];
$base_classes = (empty($this->base_classes)) ? '' : str_replace(',', ' ', $this->base_classes) . ' ';
$Block = [
'element' => [
'name' => 'div',
'handler' => 'lines',
'attributes' => [
'class' => $base_classes . $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');
}
}
}
@@ -0,0 +1,4 @@
enabled: true
built_in_css: true
base_classes: 'notices'
level_classes: [yellow, red, blue, green]