Commit bd79f11e authored by Administrator's avatar Administrator 💬

Add even more files.

I like my dependencies like I like my yogurt: frozen.
(I have not eaten frozen yogurt in years)
(notice how I distract you from the awfulness of this commit, using food)
parent 8570726e
Pipeline #10 passed with stage
in 43 seconds
# v1.6.1
## 03/09/2018
1. [](#improved)
* Added Polish + Catalan translation
* Updated `README.md` to reference custom error pages
# v1.6.0
## 10/19/2016
1. [](#improved)
* Added Croatian translation
* Improved `autoescape: true` support
1. [](#bugfix)
* Fixed issue where template file for `error` page type is only available if page was not found
# v1.5.1
## 07/18/2016
1. [](#improved)
* Added chinese and german translations
1. [](#bugfix)
* Fixed issue with the Smartypants plugin running before Twig was processed
# v1.5.0
## 07/14/2015
1. [](#improved)
* Translate some blueprint configuration options
* Allow translating the error message
* Added french, russian, romanian, danish, italian
# v1.4.1
## 12/11/2015
1. [](#bugfix)
* Fixed CLI command for PHP 5.5 and lower
# v1.4.0
## 11/21/2015
1. [](#new)
* Implemented CLI commands for the plugin
# v1.3.0
## 08/25/2015
1. [](#improved)
* Added blueprints for Grav Admin plugin
# v1.2.2
## 01/06/2015
1. [](#new)
* Added a default `error.json.twig` file
# v1.2.1
## 11/30/2014
1. [](#new)
* ChangeLog started...
The MIT License (MIT)
Copyright (c) 2014 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.
# Grav Error Plugin
![GPM Installation](assets/readme_1.png)
`error` is a [Grav](http://github.com/getgrav/grav) Plugin and allows to redirect errors to nice output pages.
This plugin is included in any package distributed that contains Grav. If you decide to clone Grav from GitHub you will most likely want to install this.
# Installation
Installing the Error plugin can be done in one of two ways. Our GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.
## GPM Installation (Preferred)
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type:
bin/gpm install error
This will install the Error plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/error`.
## Manual Installation
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `error`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-error) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
You should now have all the plugin files under
/your/site/grav/user/plugins/error
>> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Problems](https://github.com/getgrav/grav-plugin-problems) plugin, and a theme to be installed in order to operate.
# Usage
The `error` plugin doesn't require any configuration. The moment you install it, it is ready to use.
Something you might want to do is to override the look and feel of the error page, and with Grav it is super easy.
### Template
Copy the template file [error.html.twig](templates/error.html.twig) into the `templates` folder of your custom theme and that is it.
```
/your/site/grav/user/themes/custom-theme/templates/error.html.twig
```
You can now edit the override and tweak it however you prefer.
### Page
Copy the page file [error.md](pages/error.md) into the `pages` folder of your user directory and that is it.
```
/your/site/grav/user/pages/error/error.md
```
You can now edit the override and tweak it however you prefer.
# Custom error pages
The configuration allows to specify pages different than `/error` for specific error codes. By default, the `404` error leads to the `/error` page. If you change that, make sure the page you point to has a `error` template (which means, its markdown file is `error.md` or in the page frontmatter you specify `template: error`.
# CLI Usage
The `error` plugin comes with a CLI command that outputs the `grav.log` in a beautified way, with possibility of limiting the amount of errors displayed, as well as include the trace in the output.
### Commands
| `bin/plugin error log` | |
|------------------------|-----------------------------------------------------------------|
| [ --limit N \| -l N ] | The amount of errors to display. Default is 5 |
| [ --trace \| -t ] | When used, it will add the backtrace in the output of the error |
# Updating
As development for the Error plugin continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Error is easy, and can be done through Grav's GPM system, as well as manually.
## GPM Update (Preferred)
The simplest way to update this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm). You can do this with this by navigating to the root directory of your Grav install using your system's Terminal (also called command line) and typing the following:
bin/gpm update error
This command will check your Grav install to see if your Error plugin is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type `y` and hit enter. The plugin will automatically update and clear Grav's cache.
## Manual Update
Manually updating Error is pretty simple. Here is what you will need to do to get this done:
* Delete the `your/site/user/plugins/error` directory.
* Download the new version of the Error plugin from either [GitHub](https://github.com/getgrav/grav-plugin-error) or [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
* Unzip the zip file in `your/site/user/plugins` and rename the resulting folder to `error`.
* Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing `bin/grav clear-cache`.
> Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in `user/config/plugins`) will remain intact.
name: Error
version: 1.6.1
description: Displays the error page.
icon: warning
author:
name: Team Grav
email: devs@getgrav.org
url: http://getgrav.org
homepage: https://github.com/getgrav/grav-plugin-error
keywords: error, plugin, required
bugs: https://github.com/getgrav/grav-plugin-error/issues
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
routes.404:
type: text
size: medium
label: 404 Route
default: '/error'
<?php
namespace Grav\Plugin\Console;
use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
/**
* Class LogCommand
*
* @package Grav\Plugin\Console
*/
class LogCommand extends ConsoleCommand
{
/**
* @var string
*/
protected $logfile;
/**
* @var array
*/
protected $options = [];
/**
* @var array
*/
protected $colors = [
'DEBUG' => 'green',
'INFO' => 'cyan',
'NOTICE' => 'yellow',
'WARNING' => 'yellow',
'ERROR' => 'red',
'CRITICAL' => 'red',
'ALERT' => 'red',
'EMERGENCY' => 'magenta'
];
/**
*
*/
protected function configure()
{
$this->logfile = LOG_DIR . 'grav.log';
$this
->setName("log")
->setDescription("Outputs the Error Log")
->addOption(
'trace',
't',
InputOption::VALUE_NONE,
'Include the errors stack trace in the output'
)
->addOption(
'limit',
'l',
InputArgument::OPTIONAL,
'Outputs only the last X amount of errors. Use as --limit 10 / -l 10 [default 5]',
5
)
->setHelp('The <info>log</info> outputs the Errors Log in Console')
;
}
/**
* @return int|null|void
*/
protected function serve()
{
$this->options = [
'trace' => $this->input->getOption('trace'),
'limit' => $this->input->getOption('limit')
];
if (!file_exists($this->logfile)) {
$this->output->writeln("\n" . "Log file not found." . "\n");
exit;
}
$log = file_get_contents($this->logfile);
$lines = explode("\n", $log);
if (!is_numeric($this->options['limit'])) {
$this->options['limit'] = 5;
}
$lines = array_slice($lines, -($this->options['limit'] + 1));
foreach ($lines as $line) {
$this->output->writeln($this->parseLine($line));
}
}
/**
* @param $line
*
* @return null|string
*/
protected function parseLine($line)
{
$bit = explode(': ', $line);
$line1 = explode('] ', $bit[0]);
if (!$line1[0]) {
return null;
}
$line2 = explode(' - ', $bit[1]);
$date = $line1[0] . ']';
$type = str_replace('grav.', '', $line1[1]);
$color = $this->colors[$type];
$error = $line2[0];
$trace = implode(': ', array_slice($bit, 2));
$output = [];
$output[] = '';
$output[] = '<cyan>' . $date . '</cyan>';
$output[] = sprintf(' <%s>%s</%s> <white>' . $error . '</white>', $color, $type, $color);
if ($this->options['trace']) {
$output[] = ' <white>TRACE:</white> ';
$output[] = ' ' . $trace;
}
$output[] = '<cyan>' . str_repeat('-', strlen($date)) . '</cyan>';
return implode("\n", $output);
}
}
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
use Grav\Common\Grav;
use Grav\Common\Page\Page;
use Grav\Common\Page\Pages;
use Grav\Common\Page\Types;
use RocketTheme\Toolbox\Event\Event;
class ErrorPlugin extends Plugin
{
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onPageNotFound' => ['onPageNotFound', 0],
'onGetPageTemplates' => ['onGetPageTemplates', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', -10]
];
}
/**
* Display error page if no page was found for the current route.
*
* @param Event $event
*/
public function onPageNotFound(Event $event)
{
/** @var Pages $pages */
$pages = $this->grav['pages'];
// Try to load user error page.
$page = $pages->dispatch($this->config->get('plugins.error.routes.404', '/error'), true);
if (!$page) {
// If none provided use built in error page.
$page = new Page;
$page->init(new \SplFileInfo(__DIR__ . '/pages/error.md'));
}
$event->page = $page;
$event->stopPropagation();
}
/**
* Add page template types.
*/
public function onGetPageTemplates(Event $event)
{
/** @var Types $types */
$types = $event->types;
$types->register('error');
}
/**
* Add current directory to twig lookup paths.
*/
public function onTwigTemplatePaths()
{
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
}
}
enabled: true
routes:
404: '/error'
{
"project":"grav-plugin-error",
"platforms":{
"grav":{
"nodes":{
"plugin":[
{
"source":"/",
"destination":"/user/plugins/error"
}
]
}
}
}
}
en:
PLUGIN_ERROR:
ERROR: "Error"
ERROR_MESSAGE: "Woops. Looks like this page doesn't exist."
de:
PLUGIN_ERROR:
ERROR: "Fehler"
ERROR_MESSAGE: "Uuups. Sieht aus als ob diese Seite nicht existiert."
hr:
PLUGIN_ERROR:
ERROR: "Greška"
ERROR_MESSAGE: "Uups. Izgleda da ova stranica ne postoji."
ro:
PLUGIN_ERROR:
ERROR: "Eroare"
ERROR_MESSAGE: "Ooops. Se pare pagina nu există."
fr:
PLUGIN_ERROR:
ERROR: "Erreur"
ERROR_MESSAGE: "Oups. Il semble que cette page n’existe pas."
it:
PLUGIN_ERROR:
ERROR: "Errore"
ERROR_MESSAGE: "Ooops. A quanto pare, questa pagina non esiste."
ru:
PLUGIN_ERROR:
ERROR: "Ошибка"
ERROR_MESSAGE: "Упс. Похоже, этой страницы не существует."
da:
PLUGIN_ERROR:
ERROR: "Fejl"
ERROR_MESSAGE: "Ups. Det ser ud til at siden ikke eksisterer."
zh:
PLUGIN_ERROR:
ERROR: "错误"
ERROR_MESSAGE: "呃,似乎这个页面不存在。"
cs:
PLUGIN_ERROR:
ERROR: "Chyba"
ERROR_MESSAGE: "A jéje. Vypadá to, že hledaná stránka tu není."
pl:
PLUGIN_ERROR:
ERROR: "Błąd"
ERROR_MESSAGE: "Ups. Wygląda na to, że ta strona nie istnieje."
ca:
PLUGIN_ERROR:
ERROR: "Error"
ERROR_MESSAGE: "Ups. Sembla que aquesta pàgina no existeix."
---
title: Page not Found
robots: noindex,nofollow
template: error
routable: false
http_response_code: 404
twig_first: true
process:
twig: true
---
{{ 'PLUGIN_ERROR.ERROR_MESSAGE'|t }}
<h1>{{ 'PLUGIN_ERROR.ERROR'|t }} {{ header.http_response_code }}</h1>
<p>{{ page.content|raw }}</p>
{{ page.content|json_encode()|raw }}
\ No newline at end of file
# v0.1.0
- Convert `mermaid` code blocks to `[mermaid][/mermaid]`.
If you'd rather directly patch the plugin instead, see
https://github.com/Seao/grav-plugin-diagrams/issues/6
- Convert `$``$` to `$ $` in inline LateX, removing the backticks (if any)
- Convert `math` code blocks of LateX to `$$ … $$`.
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2019 Cosy Lemur
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.
# Gitlab Markdown Adapter Plugin
The **Gitlab Markdown Adapter** Plugin is for [Grav CMS](http://github.com/getgrav/grav).
It adapts Gitlab's markdown to Grav and its plugins
([Diagram](https://github.com/Seao/grav-plugin-diagrams),
[MathJax](https://github.com/Sommerregen/grav-plugin-mathjax)).
See [the CHANGELOG](CHANGELOG.md) for a list of the features.
## Installation
Installing the Gitlab Markdown Adapter plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.
### GPM Installation (Preferred)
> This plugin has not been submitted yet, so this is not available.
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's terminal (also called the command line). From the root of your Grav install type:
bin/gpm install gitlab-markdown-adapter
This will install the Gitlab Markdown Adapter plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/gitlab-markdown-adapter`.
### Manual Installation
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `gitlab-markdown-adapter`. You can find these files on [GitHub](https://github.com/goutte/grav-plugin-gitlab-markdown-adapter) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
You should now have all the plugin files under
/your/site/grav/user/plugins/gitlab-markdown-adapter
> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav) and the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) and Diagrams to operate.
### Admin Plugin
If you use the admin plugin, you can install directly through the admin plugin by browsing the `Plugins` tab and clicking on the `Add` button.
## Configuration
Before configuring this plugin, you should copy the `user/plugins/gitlab-markdown-adapter/gitlab-markdown-adapter.yaml` to `user/config/plugins/gitlab-markdown-adapter.yaml` and only edit that copy.
Here is the default configuration and an explanation of available options:
```yaml
enabled: true
```
Note that if you use the admin plugin, a file with your configuration, and named gitlab-markdown-adapter.yaml will be saved in the `user/config/plugins/` folder once the configuration is saved in the admin.
## Usage
Using Gitlab-flavored markdown should now work.
## Credits
Thanks to the Grav team and Community ❤
This plugin was hacked during a [Night of Citizen Code](http://nuitcodecitoyen.org/).
## To Do
- [ ] Write a test-suite
- [ ] Implement EVERYTHING
- [ ] Squash ALL bugs
- [ ] Add options to enable/disable behaviors
_Contributions welcome!_
name: Gitlab Markdown Adapter
version: 0.1.0
description: Adapts Gitlab's markdown to Grav and its plugins Diagrams and MathJax.
icon: plug
author:
name: Antoine Goutenoir
email: antoine@goutenoir.com
homepage: https://github.com/goutte/grav-plugin-gitlab-markdown-adapter
demo: https://m3p2.ljbac.com
keywords: grav, plugin, gitlab, markdown, mermaid, latex
bugs: https://github.com/goutte/grav-plugin-gitlab-markdown-adapter/issues
docs: https://github.com/goutte/grav-plugin-gitlab-markdown-adapter/blob/develop/README.md
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
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;
/**
* Adapts Gitlab's markdown into a digestible format for Grav and consorts.
*
* Class GitlabMarkdownAdapterPlugin
* @package Grav\Plugin
*/
class GitlabMarkdownAdapterPlugin extends Plugin
{
/**
* @return array
*
* The getSubscribedEvents() gives the core a list of events
* that the plugin wants to listen to. The key of each
* array section is the event that the plugin listens to
* and the value (in the form of an array) contains the
* callable (or function) as well as the priority. The
* higher the number the higher the priority.
*/
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0]
];
}
/**
* Initialize the plugin
*/
public function onPluginsInitialized()
{
// Don't proceed if we are in the admin plugin. Why? No idea.
if ($this->isAdmin()) {
return;
}
// Enable the main event we are interested in.
// We set a high priority since we want to get there before the other plugins.
$this->enable([
'onPageContentRaw' => ['onPageContentRaw', 10]
]);
}
/**
* Do some work for this event, full details of events can be found
* on the learn site: http://learn.getgrav.org/plugins/event-hooks
*
* @param Event $e
*/
public function onPageContentRaw(Event $e)
{
// Get the current raw content.
$content = $e['page']->getRawContent();
// Convert `mermaid` code blocks to `[mermaid][/mermaid]`.
// (?<!.) is a negative lookbehind to ensure we're at the beginning of a line.
$content = $this->replaceBlockIn($content,
'/(?<!.)``` *mermaid/i',
'/(?<!.)```/',
'[mermaid]',
'[/mermaid]'
);
// Convert `math` code blocks to `$$ … $$`.
// (?<!.) is a negative lookbehind to ensure we're at the beginning of a line.
$content = $this->replaceBlockIn($content,
'/(?<!.)``` *maths?/i',
'/(?<!.)```/',
'$$', '$$'
);
// Convert $`…`$ to $…$
$content = $this->replaceBlockIn($content,
'/[$][`]/',
'/[`][$]/',
'$', '$'
);
//file_put_contents('TEST.LOG', $content);
// Finally, set the new raw content.
$e['page']->setRawContent($content);
}
/**
* Replaces the opening and closing tags of a block by the provided replacements.
* The whole matches are replaced. Use lookaheads and lookbehinds if necessary.
*
* This is a bit more verbose than preg_replace, but perhaps it's more resilient.
*
* @param string $content
* @param string $opening_regex
* @param string $closing_regex
* @param string $new_opening
* @param string $new_closing
* @return string
*/
protected function replaceBlockIn($content, $opening_regex, $closing_regex, $new_opening, $new_closing)
{
$cursor = 0;
$got_more_openings = true;
while ($got_more_openings) { // … we accept resumes
$opening_match = array();
preg_match($opening_regex, $content, $opening_match, PREG_OFFSET_CAPTURE, $cursor);
if (empty($opening_match)) {
$got_more_openings = false;
// $cursor = <end> ? ideally…
continue;
}
$om = $opening_match[0];
if ($om[1] < $cursor) {
// Yikes! A previous block ended before this one started!
continue;
}
$cursor = $om[1];
$closing_match = array();
preg_match($closing_regex, $content,
$closing_match,PREG_OFFSET_CAPTURE,
$cursor + strlen($om[0])
);
if (empty($closing_match)) {
// Yikes! Nothing up to the end of the file?
continue;
}
$cm = $closing_match[0];
// /!. substr_replace may possibly choke on multibyte strings.
// Replace closing first because replacing opening shifts the positions.
$content = substr_replace($content, '', $cm[1], strlen($cm[0]));
$content = substr_replace($content, $new_closing, $cm[1], 0);
$content = substr_replace($content, '', $om[1], strlen($om[0]));
$content = substr_replace($content, $new_opening, $om[1], 0);
$cursor = $cm[1] + strlen($new_closing) + (strlen($new_opening) - strlen($om[0]));
}
return $content;
}
}
#en:
# PLUGIN_GITLAB_MARKDOWN_ADAPTER:
# TEXT_VARIABLE: Text Variable
# v1.0.1
## 03/09/2018
1. [](#improved)
* Updated blueprint file
# v1.0.0
## 12/22/2015
1. [](#new)
* ChangeLog started...
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.
# 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.
.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;
}
\ No newline at end of file
name: Markdown Notices
version: 1.0.1
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 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
<?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');
}
}
}
\ No newline at end of file
enabled: true
built_in_css: true
level_classes: [yellow, red, blue, green]
\ No newline at end of file
node_modules
package-lock.json
\ No newline at end of file
# v2.0.2
## 12/16/2018
1. [](#bugfix)
* Fixed an issue with checker not being initialized on Fatal Error
# v2.0.1
## 12/07/2018
1. [](#new)
* Added support for admin reporting available in Grav 1.6
1. [](#bugfix)
* Fixed issue with twig auto-escaping
* Fixed problems plugin potentially breaking CLI command if plugins get initialized
# v2.0.0
## 09/30/2018
1. [](#new)
* Completely rewritten to be much more flexible
* New _class_ based problems architecture for unified problem definition and reporting
* New `onProblemsInitialized()` plugin event for 3rd party plugins to add their own problem checks
* New more intuitive theme based on Spectre.css to display problems
* Storage of problem state to allow for displaying in admin plugin
* Now with 3 states `critical`, `warning`, and `notice`. Only critical will stop the site working.
* Added some new PHP module checks
* Added a new `umask` permission check
1. [](#improved)
* Implemented extra image checks [#17](https://github.com/getgrav/grav-plugin-problems/pull/17)
# v1.4.7
## 05/16/2017
1. [](#improved)
* Added check for Exif module if this feature is enabled
# v1.4.6
## 02/17/2017
1. [](#improved)
* Return 500 error code if there is a problem instead of 200 [https://github.com/getgrav/grav/issues/1291](https://github.com/getgrav/grav/issues/1291)
# v1.4.5
## 09/14/2016
1. [](#bugfix)
* Show the correct status for the Zip extension check
# v1.4.4
## 09/08/2016
1. [](#new)
* Added check for new root folder `tmp` and try to create if missing
1. [](#bugfix)
* Fixed Whoops error if `backup` folder doesn't exist and cannot be created
# v1.4.3
## 05/27/2016
1. [](#new)
* Reverted compression checks
# v1.4.2
## 05/23/2016
1. [](#new)
* Check for compression issues
# v1.4.1
## 05/03/2016
1. [](#new)
* Added a check for XML support in PHP
1. [](#improved)
* Use common language strings in blueprints
# v1.4.0
## 01/06/2016
1. [](#improved)
* Avoid generating errors on .DS_Store files added to the bin/ folder by OSX
* Removed executable checks for bin/* commands. Going to document instead.
# v1.3.3
## 12/09/2015
1. [](#new)
* Set minimum PHP requirements to 5.5.9
1. [](#improved)
* Ensure problems plugin runs before admin
# v1.3.2
## 12/09/2015
1. [](#improved)
* Skip windows platforms for executable permissions check
* Removed mod_headers from required Apache modules check
# v1.3.1
## 12/07/2015
1. [](#improved)
* Added executable check on `/bin/` files
# v1.3.0
## 12/07/2015
1. [](#improved)
* Added check for PHP `OpenSSL`, `Mbstring` and `Curl` are installed
* Added check to ensure `mod_rewrite` and `mod_headers` are installed if running Apache
# v1.2.0
## 08/25/2015
1. [](#improved)
* Added blueprints for Grav Admin plugin
# v1.1.6
## 06/16/2015
2. [](#new)
* Try to create missing `backup` folder if it is missing
# v1.1.5
## 05/09/2015
2. [](#new)
* Added check for `backup` folder for Grav > 0.9.27
# v1.1.4
## 04/26/2015
2. [](#new)
* Changelog started
The MIT License (MIT)
Copyright (c) 2014 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.
# Grav Problems Plugin
![Problems](assets/readme_1.jpg)
`Problems` is a [Grav](http://github.com/getgrav/grav) Plugin and allows to detect issues.
This plugin is included in any package distributed that contains Grav. If you decide to clone Grav from GitHub, you will most likely want to install this.
# Installation
Installing the Problems plugin can be done in one of two ways. Our GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.
## GPM Installation (Preferred)
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type:
bin/gpm install problems
This will install the Problems plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/problems`.
## Manual Installation
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `problems`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-problems) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
You should now have all the plugin files under
/your/site/grav/user/plugins/problems
> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate.
# Usage
`Problems` runs in the background and most of the time you will not know it is there. Although as soon as an issue is caught, the plugin will let you know.
`Problems` checks for the following common issues:
| Check | Description |
| :-------------- | :-------------------------------------------------------------------------------- |
| Apache | `mod_rewrite` is enabled if you are running an Apache server. |
| PHP Version | PHP version being run by the server meets or exceeds Grav's minimum requirements. |
| PHP Modules | PHP GD library is installed. |
| | PHP Curl library is installed. |
| | PHP Ctype library is installed |
| | PHP Dom is library installed |
| | PHP OpenSSL library is installed |
| | PHP XML library is installed |
| | PHP Zip library is installed |
| | PHP Exif library is installed if Exif support is enabled |
| | PHP OpenSSL library is installed. |
| | PHP Mbstring library is installed. |
| Essential Files | `.htaccess` file in Grav's root directory. |
| | Checks that all the files in the `bin/` folder are exectuable. |
| | `/cache` folder's existence and verifies that it is writeable. |
| | `/logs` folder's existence and verifies that it is writeable. |
| | `/images` folder's existence and verifies that it is writeable. |
| | `/assets` folder's existence and verifies that it is writeable. |
| | `/system` folder's existence. |
| | `/tmp` folder's existence. |
| | `/user/data` folder's existence and verifies that it is writeable. |
| | `/user/images` folder's existence. |
| | `/user/config` folder's existence. |
| | **Error** plugin is installed in `/user/plugins/error`. |
| | `/user/plugins` folder's existence. |
| | `/user/themes` folder's existence. |
| | `/vendor` folder's existence. |
If an issue is discovered, you will be greeted with a page that lists these checks and whether or not your install passed or failed them. Green checks mean it passed, and a red x indicates that the there is something amiss with the item.
Problems uses the cache as refresh indicator. That means that if nothing has changed anywhere, the plugin will just skip its validation tests altogether.
If a change is caught and the cache is refreshed, the plugin will loop through its validation tests and making sure nothing is out of place.
`Problems` gets also triggered if any fatal exception is caught.
# CLI Command
Problems 2.0 comes with a handy CLI command so you can run the checks at any time
```bash
bin/plugin problems check
```
You should see some output like this:
![](assets/cli.png)
# Extending Plugins
You can also extend the problems plugin via the `onProblemsInitialized()` event. The event includes an array of Problems. Simply create your own Problems class that extends the `Grav\Plugin\Problems\Base\Problem` class and add it to the array.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid" width="95.7" height="83.6" viewBox="0 0 47.85 41.8">
<defs>
<style>
.cls-1 {
fill: #000;
fill-rule: evenodd;
}
</style>
</defs>
<path d="M47.557,21.555 L37.591,32.529 C37.394,32.746 37.124,32.856 36.853,32.856 C36.614,32.856 36.374,32.770 36.183,32.597 C35.776,32.225 35.746,31.596 36.116,31.188 L45.472,20.884 L36.116,10.585 C35.746,10.177 35.776,9.547 36.183,9.176 C36.591,8.806 37.221,8.836 37.591,9.243 L47.556,20.212 C47.901,20.593 47.902,21.173 47.557,21.555 ZM18.874,41.119 C18.744,41.552 18.349,41.830 17.920,41.830 C17.825,41.830 17.729,41.816 17.633,41.788 C17.106,41.629 16.807,41.073 16.965,40.546 L28.923,0.648 C29.082,0.120 29.639,-0.175 30.164,-0.022 C30.691,0.137 30.991,0.694 30.832,1.221 L18.874,41.119 ZM11.614,32.594 C11.423,32.768 11.183,32.853 10.944,32.853 C10.673,32.853 10.403,32.743 10.206,32.527 L0.241,21.558 C-0.104,21.176 -0.105,20.596 0.241,20.215 L10.206,9.240 C10.576,8.833 11.207,8.803 11.614,9.173 C12.021,9.545 12.051,10.174 11.681,10.582 L2.325,20.886 L11.681,31.184 C12.051,31.592 12.021,32.223 11.614,32.594 Z" class="cls-1"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" viewBox="0 0 504 140" clip-rule="evenodd"><path d="M235.83 71.56h-7.98c-1.2 0-2.2 1-2.2 2.2V89.1l-.15.13c-4.7 3.96-10.64 6.14-16.72 6.14-14.36 0-26.04-11.68-26.04-26.04s11.68-26.04 26.04-26.04c5.58 0 10.92 1.76 15.44 5.1.87.66 2.1.57 2.86-.2l5.7-5.7c.44-.44.67-1.05.63-1.68-.02-.62-.32-1.2-.82-1.6-6.76-5.35-15.2-8.3-23.8-8.3-21.18 0-38.42 17.23-38.42 38.4 0 21.2 17.24 38.42 38.42 38.42 10.93 0 21.4-4.7 28.7-12.9.35-.4.55-.93.55-1.47v-19.6c0-1.22-.98-2.2-2.2-2.2M502.8 34.44c-.4-.6-1.1-.98-1.84-.98h-8.7c-.87 0-1.66.52-2 1.32l-24.5 56.84-24.9-56.85c-.36-.8-1.15-1.3-2.02-1.3h-8.72c-.74 0-1.44.36-1.84.98-.4.62-.48 1.4-.17 2.1l30.2 68.85c.34.8 1.13 1.32 2 1.32h11c.88 0 1.67-.53 2.02-1.33l29.66-68.87c.3-.68.22-1.47-.2-2.1"/><path d="M388.68 34.77c-.35-.8-1.14-1.32-2-1.32h-11c-.88 0-1.67.53-2.02 1.33L344 103.64c-.3.68-.22 1.47.18 2.08.4.62 1.1 1 1.84 1h8.7c.86 0 1.66-.53 2-1.33l24.5-56.86 24.9 56.86c.36.8 1.15 1.32 2.02 1.32h8.72c.74 0 1.44-.38 1.84-1 .4-.62.47-1.4.17-2.1l-30.2-68.85zM309.2 81.52l.47-.22c8.68-4.2 14.28-13.1 14.28-22.67 0-13.88-11.3-25.18-25.17-25.18H266.9c-1.2 0-2.2 1-2.2 2.2v68.86c0 1.23 1 2.22 2.2 2.22h8c1.2 0 2.2-1 2.2-2.2V45.8h21.68c7.05 0 12.8 5.75 12.8 12.8 0 5.9-4 11-9.73 12.42-1.04.26-2.07.4-3.07.4h-7.98c-.83 0-1.6.46-1.96 1.2-.38.73-.3 1.62.2 2.3l22.6 30.87c.42.58 1.08.92 1.78.92h9.9c.84 0 1.6-.47 1.97-1.2.37-.75.3-1.64-.2-2.3l-15.9-21.7zM107.2 80.97c-7.26-4.8-11.4-8.85-15.02-16.1-2.47 4.97-8.24 12.37-17.96 18.2-4.86 15.1-27.96 44-35.43 39.9-2.22-1.2-2.64-2.8-2.15-4.45.54-4.13 9.08-13.62 9.08-13.62s.18 2 2.92 6.18c-3.6-11.2 5.96-25.03 8.5-29.73 3.98-1.27 4.27-6.4 4.27-6.4.26-7.9-3.28-13.63-6.7-17.05 2.46 3 3.25 7.54 3.37 11.7v.02c0 .47 0 .93 0 1.4-.12 3.43-1.16 8.18-3.38 8.18v.03c-2.28-.1-5.1.4-7.63 1.18l-5.6 1.34s2.98-.13 4.6 1.25c-1.8 2.9-5.78 6.53-10.22 8.58-6.45 3-8.3-2.96-5.03-6.84.8-.94 1.62-1.74 2.38-2.4-.5-.5-.8-1.2-.88-2.06 0 0 0 0 0-.02-.46-1.97-.2-4.54 2.6-8.62.54-.86 1.2-1.75 2-2.65.02-.04.04-.07.07-.1.03-.04.07-.08.1-.12.02-.02.04-.04.06-.06.2-.23.42-.45.64-.67 3.34-3.4 8.6-6.96 16.9-10.15C64.4 43.68 67.94 41 67.94 41c1.07-1.1 2.94-2.45 3.63-2.8-5.05-8.77-6.07-21.15-4.75-24.5-.1.2-.2.38-.3.57.5-1.14.83-1.5 1.34-2.1 1.38-1.64 6.06-2.5 7.74.96.9 1.84 1.06 4.23 1.03 6.02-3.7-.2-7.06 4.04-7.06 4.04s3.07-1.46 6.88-1.5c0 0 1 .9 2.28 2.56-1.7 3.2-4.52 10.02-2.5 17.16.35 1.4.86 2.62 1.5 3.65.02.05.04.1.07.14.05.07.1.13.14.2 3.37 5.06 9.54 5.66 9.54 5.66-2.9-1.45-5.27-3.76-6.8-6.56-.82-1.5-1.3-2.77-1.6-3.77-1.64-6.3.77-10 2.14-12.47 3.17-4.9 8.95-7.9 15.15-7.18 8.72 1 14.97 8.86 13.98 17.57-.6 5.32-3.78 9.72-8.15 12.12 1.05 2.84-.07 6.28-.07 6.28 2.64 3.32 2.76 5.23 2.67 7-3.36-.55-6.62 1.7-6.62 1.7s6.48-1.53 10.24 1.82c2.44 2.64 4.08 5 5.05 6.77 1.4 2.5 7.86 2.68 7.12 7.2-.74 4.5-5.68 4.53-13.4-.57M69.56 0C31.15 0 0 31.15 0 69.57c0 38.42 31.15 69.57 69.57 69.57 38.42 0 69.57-31.15 69.57-69.57C139.14 31.15 108 0 69.57 0M73.8 51.7c.8-.82.8-2.14 0-2.95-.82-.82-2.14-.82-2.95 0-.82.8-.82 2.13 0 2.94.8.8 2.13.8 2.95 0M66.45 53.15c-.82.8-.82 2.13 0 2.95.8.8 2.13.8 2.94 0 .8-.82.8-2.14 0-2.95-.82-.8-2.14-.8-2.95 0"/><path d="M79.23 54.23c-1.27-1.27-3.34-1.27-4.6 0l-2.72 2.7c-1.27 1.3-1.27 3.35 0 4.63l3 2.97c1.26 1.28 3.32 1.28 4.6 0l2.7-2.7c1.28-1.28 1.28-3.35 0-4.62l-2.97-2.97zM95.76 41.44c-2.15-2.57 1.87-7.25 4.4-4.46 4.64 5.15-2.25 7.04-4.4 4.46m9.24 2.7c3.45-6.56-1.42-10.4-4.77-13.53-5.36-5.03-10.7-7.2-16.8-.23-6.1 6.98-2.24 15.07 3.35 19.06 5.58 4 14.78 1.25 18.22-5.3"/></svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 96 84" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;">
<path d="M87.98,42.724C87.976,42.728 87.976,42.734 87.974,42.736L53.094,81.456C51.634,83.092 49.664,83.998 47.552,83.998C47.55,83.998 47.55,83.998 47.548,83.998C45.438,83.998 43.468,83.09 42.006,81.448L7.138,42.736C7.134,42.732 7.132,42.728 7.13,42.724C-2.46,32.94 -2.44,17.092 7.202,7.34C11.886,2.606 18.114,-0.002 24.74,-0.002C31.364,-0.002 37.594,2.606 42.278,7.34C42.286,7.348 42.288,7.358 42.294,7.364C42.302,7.372 42.312,7.374 42.32,7.382L47.552,12.99L52.79,7.382C52.798,7.374 52.808,7.372 52.816,7.364C52.822,7.356 52.824,7.348 52.832,7.34C57.516,2.606 63.746,-0.002 70.37,-0.002C76.996,-0.002 83.224,2.606 87.91,7.34C97.542,17.092 97.562,32.942 87.98,42.724ZM85.098,10.164C81.166,6.188 75.934,3.998 70.37,3.998C64.822,3.998 59.604,6.178 55.672,10.136L48.998,17.28C48.984,17.294 48.964,17.3 48.95,17.314C48.934,17.33 48.928,17.35 48.912,17.366C48.792,17.48 48.646,17.544 48.508,17.622C48.436,17.664 48.374,17.726 48.298,17.756C48.058,17.854 47.806,17.908 47.552,17.908C47.298,17.908 47.046,17.854 46.806,17.756C46.73,17.726 46.67,17.664 46.596,17.624C46.458,17.546 46.314,17.48 46.192,17.366C46.176,17.35 46.17,17.33 46.156,17.314C46.14,17.3 46.122,17.294 46.106,17.28L39.456,10.152C35.522,6.184 30.298,3.998 24.74,3.998C19.176,3.998 13.946,6.188 10.01,10.164C1.884,18.386 1.884,31.76 10.01,39.978C10.022,39.99 10.026,40.008 10.038,40.02C10.048,40.032 10.064,40.034 10.074,40.048L44.95,78.768C45.66,79.564 46.58,79.996 47.55,79.996L47.552,79.996C48.524,79.996 49.446,79.564 50.15,78.774L85.036,40.048C85.046,40.036 85.06,40.032 85.07,40.022C85.082,40.008 85.086,39.992 85.098,39.98C93.218,31.76 93.218,18.386 85.098,10.164Z" style="fill:rgb(235,82,66);"/>
</svg>
name: Problems
version: 2.0.2
description: Detects and reports problems found in the site.
icon: exclamation-circle
author:
name: Team Grav
email: devs@getgrav.org
url: http://getgrav.org
homepage: https://github.com/getgrav/grav-plugin-problems
keywords: problems, plugin, detector, assistant, required
bugs: https://github.com/getgrav/grav-plugin-problems/issues
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: Use built in CSS
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class Apache extends Problem
{
public function __construct()
{
$this->id = 'Apache Modules';
$this->class = get_class($this);
$this->order = 1;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = true;
$this->help = 'https://learn.getgrav.org/basics/requirements#apache-requirements';
}
public function process()
{
// Perform some Apache checks
if (strpos(php_sapi_name(), 'apache') !== false && function_exists('apache_get_modules')) {
$require_apache_modules = ['mod_rewrite'];
$apache_modules = apache_get_modules();
$apache_errors = [];
$apache_success = [];
foreach ((array) $require_apache_modules as $module) {
if (in_array($module, $apache_modules)) {
$apache_success[$module] = 'module required but not enabled';
} else {
$apache_errors[$module] = 'module is not installed or enabled';
}
}
if (empty($apache_errors)) {
$this->status = true;
$this->msg = 'All modules look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required modules:';
}
$this->details = ['errors' => $apache_errors, 'success' => $apache_success];
} else {
$this->msg = 'Apache not installed, skipping...';
}
return $this;
}
}
<?php
namespace Grav\Plugin\Problems\Base;
class Problem implements \JsonSerializable
{
const LEVEL_CRITICAL = 'critical';
const LEVEL_WARNING = 'warning';
const LEVEL_NOTICE = 'notice';
protected $id;
protected $order;
protected $level;
protected $status;
protected $msg;
protected $details;
protected $help;
protected $class;
public function __contstruct($data = null)
{
if (!is_null($data)) {
$this->load($data);
}
}
public function load($data) {
$this->set_object_vars($data);
}
public function process() {
return $this;
}
public function getId() {
return $this->id;
}
public function getOrder() {
return $this->order;
}
public function getLevel() {
return $this->level;
}
public function getStatus() {
return $this->status;
}
public function getMsg() {
return $this->msg;
}
public function getDetails()
{
return $this->details;
}
public function getHelp()
{
return $this->help;
}
public function getClass()
{
return $this->class;
}
public function toArray()
{
return get_object_vars($this);
}
public function jsonSerialize()
{
$this->toArray();
}
protected function set_object_vars($object, array $vars) {
$has = get_object_vars($object);
foreach ($has as $name => $oldValue) {
$object->$name = isset($vars[$name]) ? $vars[$name] : NULL;
}
}
}
\ No newline at end of file
<?php
namespace Grav\Plugin\Problems\Base;
use Grav\Common\Cache;
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;
class ProblemChecker
{
const PROBLEMS_PREFIX = 'problem-check-';
protected $problems = [];
protected $status_file;
public function __construct()
{
/** @var Cache $cache */
$cache = Grav::instance()['cache'];
$this->status_file = CACHE_DIR . $this::PROBLEMS_PREFIX . $cache->getKey() . '.json';
}
public function load()
{
if ($this->statusFileExists()) {
$json = file_get_contents($this->status_file);
$data = json_decode($json, true);
foreach ($data as $problem) {
$class = $problem['class'];
$this->problems[] = new $class($problem);
}
}
}
public function getStatusFile()
{
return $this->status_file;
}
public function statusFileExists()
{
return file_exists($this->status_file);
}
public function storeStatusFile()
{
$problems = $this->getProblemsSerializable();
$json = json_encode($problems);
file_put_contents($this->status_file, $json);
}
public function check($problems_dir)
{
$problems = [];
$problems_found = false;
foreach (new \DirectoryIterator($problems_dir) as $file) {
if ($file->isDot() || $file->isDir()) {
continue;
}
$classname = 'Grav\\Plugin\\Problems\\' . $file->getBasename('.php');
/** @var Problem $problem */
$problem = new $classname();
$problems[$problem->getId()] = $problem;
}
// Fire event to allow other plugins to add problems
Grav::instance()->fireEvent('onProblemsInitialized', new Event(['problems' => $problems]));
// Get the problems in order
usort($problems, function($a, $b) {
return $b->getOrder() - $a->getOrder();
});
// run the process methods in new order
foreach ($problems as $problem) {
$problem->process();
if ($problem->getStatus() === false && $problem->getLevel() === Problem::LEVEL_CRITICAL) {
$problems_found = true;
}
}
$this->problems = $problems;
return $problems_found;
}
public function getProblems()
{
if (empty($this->problems)) {
$this->check();
}
$problems = $this->problems;
// Put the failed ones first
usort($problems, function($a, $b) {
return $a->getStatus() - $b->getStatus();
});
return $problems;
}
public function getProblemsSerializable()
{
if (empty($this->problems)) {
$this->getProblems();
}
$problems = [];
foreach ($this->problems as $problem) {
$problems[] = $problem->toArray();
}
return $problems;
}
}
\ No newline at end of file
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class EssentialFolders extends Problem
{
public function __construct()
{
$this->id = 'Essential Folders';
$this->class = get_class($this);
$this->order = 100;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://learn.getgrav.org/basics/folder-structure';
}
public function process()
{
$essential_folders = [
'backup' => true,
'cache' => true,
'logs' => true,
'images' => true,
'assets' => true,
'system' => false,
'user/data' => true,
'user/pages' => false,
'user/config' => false,
'user/plugins/error' => false,
'user/plugins' => false,
'user/themes' => false,
'vendor' => false,
'tmp' => true,
];
// Check for essential files & perms
$file_errors = [];
$file_success = [];
foreach ($essential_folders as $file => $check_writable) {
$file_path = ROOT_DIR . $file;
if (!file_exists($file_path)) {
$file_errors[$file_path] = 'does not exist';
} elseif ($check_writable && !is_writable($file_path)) {
$file_errors[$file_path] = 'exists but is <strong>not writeable</strong>';
} else {
$file_success[$file_path] = 'exists and is writable';
}
}
if (empty($file_errors)) {
$this->status = true;
$this->msg = 'All folders look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required folders:';
}
$this->details = ['errors' => $file_errors, 'success' => $file_success];
return $this;
}
}
\ No newline at end of file
<?php
namespace Grav\Plugin\Problems;
use Grav\Common\Grav;
use Grav\Plugin\Problems\Base\Problem;
class PHPModules extends Problem
{
public function __construct()
{
$this->id = 'PHP Modules';
$this->class = get_class($this);
$this->order = 101;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://learn.getgrav.org/basics/requirements#php-requirements';
}
public function process()
{
$modules_errors = [];
$modules_success = [];
// Check for PHP CURL library
$msg = "PHP Curl (Data Transfer Library) is %s installed";
if (function_exists('curl_version')) {
$modules_success['curl'] = sprintf($msg, 'successfully');
} else {
$modules_errors['curl'] = sprintf($msg, 'required but not');
}
// Check for PHP Ctype library
$msg = "PHP Ctype is %s installed";
if (function_exists('ctype_print')) {
$modules_success['ctype'] = sprintf($msg, 'successfully');
} else {
$modules_errors['ctype'] = sprintf($msg, 'required but not');
}
// Check for PHP Dom library
$msg = "PHP DOM is %s installed";
if (class_exists('DOMDocument')) {
$modules_success['dom'] = sprintf($msg, 'successfully');
} else {
$modules_errors['dom'] = sprintf($msg, 'required but not');
}
// Check for GD library
$msg = "PHP GD (Image Manipulation Library) is %s installed";
if (defined('GD_VERSION') && function_exists('gd_info')) {
$msg = $modules_success['gd'] = sprintf($msg, 'successfully');
// Extra checks for Image support
$ginfo = gd_info();
$gda = array("PNG Support", "JPEG Support", "FreeType Support", "GIF Read Support");
$gda_msg = '';
$problems_found = false;
foreach ($gda as $image_type) {
if (!$ginfo[$image_type]) {
$problems_found = true;
$gda_msg = "missing $image_type, but is ";
break;
}
}
if ($problems_found) {
$msg .= ' but missing ' . $gda_msg;
}
$modules_success['gd'] = $msg;
} else {
$modules_errors['gd'] = sprintf($msg, 'required but not');
}
// Check for PHP MbString library
$msg = "PHP Mbstring (Multibyte String Library) is %s installed";
if (extension_loaded('mbstring')) {
$modules_success['mbstring'] = sprintf($msg, 'successfully');
} else {
$modules_errors['mbstring'] = sprintf($msg, 'required but not');
}
// Check for PHP Open SSL library
$msg = "PHP OpenSSL (Secure Sockets Library) is %s installed";
if (extension_loaded('openssl') && defined('OPENSSL_VERSION_TEXT')) {
$modules_success['openssl'] = sprintf($msg, 'successfully');
} else {
$modules_errors['openssl'] = sprintf($msg, 'required but not');
}
// Check for PHP XML library
$msg = "PHP XML Library is %s installed";
if (extension_loaded('xml')) {
$modules_success['xml'] = sprintf($msg, 'successfully');
} else {
$modules_errors['xml'] = sprintf($msg, 'required but not');
}
// Check for PHP Zip library
$msg = "PHP Zip extension is %s installed";
if (extension_loaded('zip')) {
$modules_success['zip'] = sprintf($msg, 'successfully');
} else {
$modules_errors['zip'] = sprintf($msg, 'required but not');
}
// Check Exif if enabled
if (Grav::instance()['config']->get('system.media.auto_metadata_exif')) {
$msg = "PHP Exif (Exchangeable Image File Format) is %s installed";
if (extension_loaded('exif')) {
$modules_success['exif'] = sprintf($msg, 'successfully');
} else {
$modules_errors['exif'] = sprintf($msg, 'required but not');
}
}
if (empty($modules_errors)) {
$this->status = true;
$this->msg = 'All modules look good!';
} else {
$this->status = false;
$this->msg = 'There were problems with required modules:';
}
$this->details = ['errors' => $modules_errors, 'success' => $modules_success];
return $this;
}
}
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class PHPVersion extends Problem
{
public function __construct()
{
$this->id = 'PHP Minimum Version';
$this->class = get_class($this);
$this->order = 102;
$this->level = Problem::LEVEL_CRITICAL;
$this->status = false;
$this->help = 'https://getgrav.org/blog/raising-php-requirements-2018';
}
public function process()
{
$min_php_version = defined('GRAV_PHP_MIN') ? GRAV_PHP_MIN : '5.6.4';
$your_php_version = phpversion();
$msg = "Your PHP <strong>%s</strong> is %s than the minimum of <strong>%s</strong> required";
// Check PHP version
if (version_compare($your_php_version, $min_php_version, '<')) {
$this->msg = sprintf($msg, $your_php_version, 'less', $min_php_version);
} else {
$this->msg = sprintf($msg, $your_php_version, 'greater', $min_php_version);
$this->status = true;
}
return $this;
}
}
\ No newline at end of file
<?php
namespace Grav\Plugin\Problems;
use Grav\Plugin\Problems\Base\Problem;
class Permissions extends Problem
{
public function __construct()
{
$this->id = 'Permissions Setup';
$this->class = get_class($this);
$this->order = -1;
$this->level = Problem::LEVEL_WARNING;
$this->status = false;
$this->help = 'https://learn.getgrav.org/troubleshooting/permissions';
}
public function process()
{
umask($umask = umask(022));
$msg = "Your default file umask is <strong>%s</strong> which %s";
if (($umask & 2) !== 2) {
$this->msg = sprintf($msg, decoct($umask), 'is potentially dangerous');
$this->status = false;
} else {
$this->msg = sprintf($msg, decoct($umask), 'looks good!');
$this->status = true;
}
return $this;
}
}
\ No newline at end of file
<?php
namespace Grav\Plugin\Console;
use Grav\Common\Grav;
use Grav\Console\ConsoleCommand;
use Grav\Plugin\Problems\Base\ProblemChecker;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
* Class ProblemsCommand
*
* @package Grav\Plugin\Console
*/
class CheckCommand extends ConsoleCommand
{
/**
*
*/
protected function configure()
{
$this
->setName("check")
->setDescription("Check Problems")
->setHelp('The <info>problems command</info> allows you display any potential problems with your Grav setup')
;
}
/**
* @return int|null|void
*/
protected function serve()
{
/** @var use new SymfonyStyle helper $io */
$io = new SymfonyStyle($this->input, $this->output);
$plugin_dir = realpath(__DIR__ . '/..');
$problems_dir = $plugin_dir . '/classes/Problems';
require $plugin_dir . '/vendor/autoload.php';
$checker = new ProblemChecker();
$checker->check($problems_dir);
$problems = $checker->getProblems();
$io->title('Grav Problems');
$table = new Table($this->output);
$table->setStyle('default');
$headers = ['ID', 'Status', 'Level', 'Message'];
$rows = [];
foreach ($problems as $problem) {
$rows[] = new TableSeparator();
$rows[] = [
$problem->getStatus() ? $problem->getID() : '<red>' . $problem->getId() . '</red>' ,
$problem->getStatus() ? '<green>success</green>' : '<red>error</red>',
$problem->getLevel() == 'critical' ? '<red>' . $problem->getLevel() . '</red>' : '<yellow>' .$problem->getLevel() . '</yellow>',
strip_tags($problem->getMsg()),
];
$details = $problem->getDetails();
if (is_array($details)) {
$errors_row = [];
$success_row = [];
if (isset($details['errors'])) {
foreach ($details['errors'] as $key => $value) {
$errors_row[] = "<red>✗</red> <yellow>{$key}{$value}</yellow>";
}
}
if (isset($details['success'])) {
foreach ($details['success'] as $key => $value) {
$success_row[] = "<green>✔</green> {$key}{$value}";
}
}
foreach($errors_row as $e_row) {
$rows[] = ['', new TableCell($e_row, array('colspan' => 3)), ];
}
foreach($success_row as $e_row) {
$rows[] = ['', new TableCell($e_row, array('colspan' => 3)), ];
}
}
}
if (!empty($rows)) {
$table->setHeaders($headers);
$table->setRows($rows);
$table->render();
} else {
$io->text('did not find anything to check...');
}
}
}
{
"autoload": {
"psr-4": {
"Grav\\Plugin\\": "classes/"
}
}
}
\ No newline at end of file
This diff is collapsed.
#admin-main .admin-block .report-output h1{margin-top:2rem}#admin-main .admin-block .report-output .toast .btn{font-size:90%;float:right;margin-top:-2px;margin-right:.5rem;padding:2px 7px;color:#fff;border:1px solid #29b739;border-radius:3px;background-color:#2bc03c}#admin-main .admin-block .report-output .toast .btn:hover{border-color:#27af37;background-color:#29b739}#admin-main .admin-block .report-output .toast .btn.btn-error{border:1px solid #f2403f;background-color:#f34a49}#admin-main .admin-block .report-output .toast .btn.btn-error:hover{border-color:#f23735;background-color:#f2403f}#admin-main .admin-block .report-output .toast .btn.btn-warning{border:1px solid #ff7702;background-color:#ff7d0c}#admin-main .admin-block .report-output .toast .btn.btn-warning:hover{border-color:#f67300;background-color:#ff7702}.report-output ul.problems{margin:1rem 0;padding:0;list-style:none;background-color:#f7f7f7}.report-output ul.problems h5{margin:0}.report-output ul.problems li.menu{margin-bottom:1rem;box-shadow:0 10px 20px -10px rgba(0,0,0,.2)}.report-output ul.problems .toast{font-size:1rem;padding:.5rem 1.5rem;color:#fff}.report-output ul.problems .toast.toast-success{background-color:#2ecc40}.report-output ul.problems .toast.toast-error{background-color:#f45857}.report-output ul.problems .toast.toast-warning{background-color:#ff851b}.report-output ul.problems .toast .btn{margin-left:1rem;text-decoration:none!important}.report-output ul.problems .toast .btn i{margin-right:.3rem}.report-output ul.problems ul.details{padding-bottom:1rem;padding-left:0;list-style:none;background-color:#fff}.report-output ul.problems ul.details li{padding-right:1.5rem;padding-left:1.5rem}.report-output ul.problems ul.details code{font-size:90%;line-height:1.2;padding:.1rem .2rem;vertical-align:middle;color:#288fed;border-radius:.1rem;background:#f0f7fe}.report-output ul.problems ul.details .menu-item{margin-top:.5rem!important;padding-top:.5rem;border-top:1px solid #f7f7f7}.report-output ul.problems ul.details .menu-item:first-child{border:none}.report-output ul.problems ul.details .menu-badge{display:inline;float:right;padding:0}.report-output ul.problems ul.details .menu-badge .label{font-size:1rem;line-height:1.5rem;width:1.5rem;height:1.5rem;border-radius:3px}.report-output ul.problems ul.details .menu-badge .label.label-success{background:#2ecc40}.report-output ul.problems ul.details .menu-badge .label.label-error{background:#f45857}
\ No newline at end of file
This diff is collapsed.
/*! Spectre.css Icons v0.5.3 | MIT License | github.com/picturepan2/spectre */.icon{font-size:inherit;font-style:normal;position:relative;display:inline-block;box-sizing:border-box;width:1em;height:1em;vertical-align:middle;text-indent:-9999px}.icon::after,.icon::before{position:absolute;top:50%;left:50%;display:block;transform:translate(-50%,-50%)}.icon.icon-2x{font-size:1.6rem}.icon.icon-3x{font-size:2.4rem}.icon.icon-4x{font-size:3.2rem}.accordion .icon,.btn .icon,.menu .icon,.toast .icon{vertical-align:-10%}.btn-lg .icon{vertical-align:-15%}.icon-arrow-down::before,.icon-arrow-left::before,.icon-arrow-right::before,.icon-arrow-up::before,.icon-back::before,.icon-downward::before,.icon-forward::before,.icon-upward::before{width:.65em;height:.65em;content:'';border:.1rem solid currentColor;border-right:0;border-bottom:0}.icon-arrow-down::before{transform:translate(-50%,-75%) rotate(225deg)}.icon-arrow-left::before{transform:translate(-25%,-50%) rotate(-45deg)}.icon-arrow-right::before{transform:translate(-75%,-50%) rotate(135deg)}.icon-arrow-up::before{transform:translate(-50%,-25%) rotate(45deg)}.icon-back::after,.icon-forward::after{width:.8em;height:.1rem;content:'';background:currentColor}.icon-downward::after,.icon-upward::after{width:.1rem;height:.8em;content:'';background:currentColor}.icon-back::after{left:55%}.icon-back::before{transform:translate(-50%,-50%) rotate(-45deg)}.icon-downward::after{top:45%}.icon-downward::before{transform:translate(-50%,-50%) rotate(-135deg)}.icon-forward::after{left:45%}.icon-forward::before{transform:translate(-50%,-50%) rotate(135deg)}.icon-upward::after{top:55%}.icon-upward::before{transform:translate(-50%,-50%) rotate(45deg)}.icon-caret::before{width:0;height:0;content:'';transform:translate(-50%,-25%);border-top:.3em solid currentColor;border-right:.3em solid transparent;border-left:.3em solid transparent}.icon-menu::before{width:100%;height:.1rem;content:'';background:currentColor;box-shadow:0 -.35em,0 .35em}.icon-apps::before{width:3px;height:3px;content:'';background:currentColor;box-shadow:-.35em -.35em,-.35em 0,-.35em .35em,0 -.35em,0 .35em,.35em -.35em,.35em 0,.35em .35em}.icon-resize-horiz::after,.icon-resize-horiz::before,.icon-resize-vert::after,.icon-resize-vert::before{width:.45em;height:.45em;content:'';border:.1rem solid currentColor;border-right:0;border-bottom:0}.icon-resize-horiz::before,.icon-resize-vert::before{transform:translate(-50%,-90%) rotate(45deg)}.icon-resize-horiz::after,.icon-resize-vert::after{transform:translate(-50%,-10%) rotate(225deg)}.icon-resize-horiz::before{transform:translate(-90%,-50%) rotate(-45deg)}.icon-resize-horiz::after{transform:translate(-10%,-50%) rotate(135deg)}.icon-more-horiz::before,.icon-more-vert::before{width:3px;height:3px;content:'';border-radius:50%;background:currentColor;box-shadow:-.4em 0,.4em 0}.icon-more-vert::before{box-shadow:0 -.4em,0 .4em}.icon-cross::before,.icon-minus::before,.icon-plus::before{width:100%;height:.1rem;content:'';background:currentColor}.icon-cross::after,.icon-plus::after{width:.1rem;height:100%;content:'';background:currentColor}.icon-cross::before{width:100%}.icon-cross::after{height:100%}.icon-cross::after,.icon-cross::before{transform:translate(-50%,-50%) rotate(45deg)}.icon-check::before{width:.9em;height:.5em;content:'';transform:translate(-50%,-75%) rotate(-45deg);border:.1rem solid currentColor;border-top:0;border-right:0}.icon-stop{border:.1rem solid currentColor;border-radius:50%}.icon-stop::before{width:1em;height:.1rem;content:'';transform:translate(-50%,-50%) rotate(45deg);background:currentColor}.icon-shutdown{border:.1rem solid currentColor;border-top-color:transparent;border-radius:50%}.icon-shutdown::before{top:.1em;width:.1rem;height:.5em;content:'';background:currentColor}.icon-refresh::before{width:1em;height:1em;content:'';border:.1rem solid currentColor;border-right-color:transparent;border-radius:50%}.icon-refresh::after{top:20%;left:80%;width:0;height:0;content:'';border:.2em solid currentColor;border-top-color:transparent;border-left-color:transparent}.icon-search::before{top:5%;left:5%;width:.75em;height:.75em;content:'';transform:translate(0,0) rotate(45deg);border:.1rem solid currentColor;border-radius:50%}.icon-search::after{top:80%;left:80%;width:.4em;height:.1rem;content:'';transform:translate(-50%,-50%) rotate(45deg);background:currentColor}.icon-edit::before{width:.85em;height:.4em;content:'';transform:translate(-40%,-60%) rotate(-45deg);border:.1rem solid currentColor}.icon-edit::after{top:95%;left:5%;width:0;height:0;content:'';transform:translate(0,-100%);border:.15em solid currentColor;border-top-color:transparent;border-right-color:transparent}.icon-delete::before{top:60%;width:.75em;height:.75em;content:'';border:.1rem solid currentColor;border-top:0;border-bottom-right-radius:.1rem;border-bottom-left-radius:.1rem}.icon-delete::after{top:.05rem;width:.5em;height:.1rem;content:'';background:currentColor;box-shadow:-.25em .2em,.25em .2em}.icon-share{border:.1rem solid currentColor;border-top:0;border-right:0;border-radius:.1rem}.icon-share::before{top:.25em;left:100%;width:.4em;height:.4em;content:'';transform:translate(-125%,-50%) rotate(-45deg);border:.1rem solid currentColor;border-top:0;border-left:0}.icon-share::after{width:.6em;height:.5em;content:'';border:.1rem solid currentColor;border-right:0;border-bottom:0;border-radius:75% 0}.icon-flag::before{left:15%;width:.1rem;height:1em;content:'';background:currentColor}.icon-flag::after{top:35%;left:60%;width:.8em;height:.65em;content:'';border:.1rem solid currentColor;border-left:0;border-top-right-radius:.1rem;border-bottom-right-radius:.1rem}.icon-bookmark::before{width:.8em;height:.9em;content:'';border:.1rem solid currentColor;border-bottom:0;border-top-left-radius:.1rem;border-top-right-radius:.1rem}.icon-bookmark::after{width:.5em;height:.5em;content:'';transform:translate(-50%,35%) rotate(-45deg) skew(15deg,15deg);border:.1rem solid currentColor;border-bottom:0;border-left:0;border-radius:.1rem}.icon-download,.icon-upload{border-bottom:.1rem solid currentColor}.icon-download::before,.icon-upload::before{width:.5em;height:.5em;content:'';transform:translate(-50%,-60%) rotate(-135deg);border:.1rem solid currentColor;border-right:0;border-bottom:0}.icon-download::after,.icon-upload::after{top:40%;width:.1rem;height:.6em;content:'';background:currentColor}.icon-upload::before{transform:translate(-50%,-60%) rotate(45deg)}.icon-upload::after{top:50%}.icon-time{border:.1rem solid currentColor;border-radius:50%}.icon-time::before{width:.1rem;height:.4em;content:'';transform:translate(-50%,-75%);background:currentColor}.icon-time::after{width:.1rem;height:.3em;content:'';transform:translate(-50%,-75%) rotate(90deg);transform-origin:50% 90%;background:currentColor}.icon-mail::before{width:1em;height:.8em;content:'';border:.1rem solid currentColor;border-radius:.1rem}.icon-mail::after{width:.5em;height:.5em;content:'';transform:translate(-50%,-90%) rotate(-45deg) skew(10deg,10deg);border:.1rem solid currentColor;border-top:0;border-right:0}.icon-people::before{top:25%;width:.45em;height:.45em;content:'';border:.1rem solid currentColor;border-radius:50%}.icon-people::after{top:75%;width:.9em;height:.4em;content:'';border:.1rem solid currentColor;border-radius:50% 50% 0 0}.icon-message{border:.1rem solid currentColor;border-right:0;border-bottom:0;border-radius:.1rem}.icon-message::before{top:40%;left:65%;width:.7em;height:.8em;content:'';border:.1rem solid currentColor;border-top:0;border-left:0;border-bottom-right-radius:.1rem}.icon-message::after{top:100%;left:10%;width:.1rem;height:.3em;content:'';transform:translate(0,-90%) rotate(45deg);border-radius:.1rem;background:currentColor}.icon-photo{border:.1rem solid currentColor;border-radius:.1rem}.icon-photo::before{top:35%;left:35%;width:.25em;height:.25em;content:'';border:.1rem solid currentColor;border-radius:50%}.icon-photo::after{left:60%;width:.5em;height:.5em;content:'';transform:translate(-50%,25%) rotate(-45deg);border:.1rem solid currentColor;border-bottom:0;border-left:0}.icon-link::after,.icon-link::before{width:.75em;height:.5em;content:'';border:.1rem solid currentColor;border-right:0;border-radius:5em 0 0 5em}.icon-link::before{transform:translate(-70%,-45%) rotate(-45deg)}.icon-link::after{transform:translate(-30%,-55%) rotate(135deg)}.icon-location::before{width:.8em;height:.8em;content:'';transform:translate(-50%,-60%) rotate(-45deg);border:.1rem solid currentColor;border-radius:50% 50% 50% 0}.icon-location::after{width:.2em;height:.2em;content:'';transform:translate(-50%,-80%);border:.1rem solid currentColor;border-radius:50%}.icon-emoji{border:.1rem solid currentColor;border-radius:50%}.icon-emoji::before{width:.1em;height:.1em;content:'';border-radius:50%;box-shadow:-.17em -.15em,.17em -.15em}.icon-emoji::after{width:.5em;height:.5em;content:'';transform:translate(-50%,-40%) rotate(-135deg);border:.1rem solid currentColor;border-right-color:transparent;border-bottom-color:transparent;border-radius:50%}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
var gulp = require('gulp');
var sass = require('gulp-sass');
var cleancss = require('gulp-clean-css');
var csscomb = require('gulp-csscomb');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
// configure the paths
var watch_dir = './scss/*.scss';
var src_dir = './scss/*.scss';
var dest_dir = './css';
var paths = {
source: src_dir
};
gulp.task('watch', function() {
gulp.watch(watch_dir, ['build']);
});
gulp.task('build', function() {
gulp.src(paths.source)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compact', precision: 10})
.on('error', sass.logError)
)
.pipe(sourcemaps.write())
.pipe(autoprefixer())
.pipe(gulp.dest(dest_dir))
.pipe(csscomb())
.pipe(cleancss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(dest_dir));
});
gulp.task('default', ['build']);
{
"project":"grav-plugin-problems",
"platforms":{
"grav":{
"nodes":{
"plugin":[
{
"source":"/",
"destination":"/user/plugins/problems"
}
]
}
}
}
}
{
"name": "spectre.css",
"version": "0.5.1",
"homepage": "http://picturepan2.github.io/spectre",
"author": "Yan Zhu <picturepan2@hotmail.com>",
"description": "Spectre.css: a lightweight, responsive and modern CSS framework",
"main": "docs/dist/spectre.css",
"repository": {
"type": "git",
"url": "https://github.com/picturepan2/spectre.git"
},
"license": "MIT",
"keywords": [
"css",
"framework",
"flexbox",
"responsive",
"mobile-friendly",
"front-end",
"sass",
"modern"
],
"bugs": {
"url": "https://github.com/picturepan2/spectre/issues"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-autoprefixer": "latest",
"gulp-clean-css": "^3.9.4",
"gulp-csscomb": "^3.0.8",
"gulp-rename": "^1.2.2",
"gulp-sass": "^4.0.1"
},
"browserslist": [
"last 4 Chrome versions",
"Edge >= 12",
"Firefox ESR",
"last 4 Safari versions",
"last 4 Opera versions",
"Explorer >= 10"
],
"dependencies": {
"gulp-sourcemaps": "^2.6.4"
}
}
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
use Grav\Common\Uri;
use Grav\Plugin\Problems\Base\ProblemChecker;
use RocketTheme\Toolbox\Event\Event;
class ProblemsPlugin extends Plugin
{
protected $checker;
protected $problems = [];
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => ['onPluginsInitialized', 100001],
'onFatalException' => ['onFatalException', 0],
'onAdminGenerateReports' => ['onAdminGenerateReports', 0],
];
}
public function onFatalException()
{
if (\defined('GRAV_CLI') || $this->isAdmin()) {
return;
}
// Run through potential issues
if ($this->problemsFound()) {
$this->renderProblems();
}
}
public function onPluginsInitialized()
{
require __DIR__ . '/vendor/autoload.php';
if (\defined('GRAV_CLI') || $this->isAdmin()) {
return;
}
$this->checker = new ProblemChecker();
if (!$this->checker->statusFileExists()) {
// If no issues remain, save a state file in the cache
if (!$this->problemsFound()) {
// delete any existing validated files
foreach (new \GlobIterator(CACHE_DIR . ProblemChecker::PROBLEMS_PREFIX . '*') as $fileInfo) {
@unlink($fileInfo->getPathname());
}
// create a file in the cache dir so it only runs on cache changes
$this->checker->storeStatusFile();
} else {
$this->renderProblems();
}
}
}
private function renderProblems()
{
/** @var Uri $uri */
$uri = $this->grav['uri'];
/** @var \Twig_Environment $twig */
$twig = $this->getTwig();
$data = [
'problems' => $this->problems,
'base_url' => $baseUrlRelative = $uri->rootUrl(false),
'problems_url' => $baseUrlRelative . '/user/plugins/problems',
];
echo $twig->render('problems.html.twig', $data);
http_response_code(500);
exit();
}
public function onAdminGenerateReports(Event $e)
{
$reports = $e['reports'];
$this->checker = new ProblemChecker();
// Check for problems
$this->problemsFound();
/** @var Uri $uri */
$uri = $this->grav['uri'];
/** @var \Twig_Environment $twig */
$twig = $this->getTwig();
$data = [
'problems' => $this->problems,
'base_url' => $baseUrlRelative = $uri->rootUrl(false),
'problems_url' => $baseUrlRelative . '/user/plugins/problems',
];
$reports['Grav Potential Problems'] = $twig->render('reports/problems-report.html.twig', $data);
$this->grav['assets']->addCss('plugins://problems/css/admin.css');
$this->grav['assets']->addCss('plugins://problems/css/spectre-icons.css');
}
private function problemsFound()
{
if (is_null($this->checker)) {
$this->checker = new ProblemChecker();
}
$status = $this->checker->check(__DIR__ . '/classes/Problems');
$this->problems = $this->checker->getProblems();
return $status;
}
private function getTwig()
{
$loader = new \Twig_Loader_Filesystem(__DIR__ . '/templates');
$twig = new \Twig_Environment($loader, ['debug' => true]);
$twig->addExtension(New \Twig_Extension_Debug());
return $twig;
}
}
enabled: true
built_in_css: true
// Accordions
.accordion {
input:checked ~,
&[open] {
& .accordion-header {
.icon {
transform: rotate(90deg);
}
}
& .accordion-body {
max-height: 50rem;
}
}
.accordion-header {
display: block;
padding: $unit-1 $unit-2;
.icon {
transition: all .2s ease;
}
}
.accordion-body {
margin-bottom: $layout-spacing;
max-height: 0;
overflow: hidden;
transition: max-height .2s ease;
}
}
// Remove default details marker in Webkit
summary.accordion-header {
&::-webkit-details-marker {
display: none;
}
}
// Animations
@keyframes loading {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes slide-down {
0% {
opacity: 0;
transform: translateY(-$unit-8);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
// Optimized for East Asian CJK
:lang(zh),
:lang(zh-Hans) {
font-family: $cjk-zh-hans-font-family;
}
:lang(zh-Hant) {
font-family: $cjk-zh-hant-font-family;
}
:lang(ja) {
font-family: $cjk-jp-font-family;
}
:lang(ko) {
font-family: $cjk-ko-font-family;
}
:lang(zh),
:lang(ja),
.cjk {
ins,
u {
border-bottom: $border-width solid;
text-decoration: none;
}
del + del,
del + s,
ins + ins,
ins + u,
s + del,
s + s,
u + ins,
u + u {
margin-left: .125em;
}
}
// Autocomplete
.form-autocomplete {
position: relative;
.form-autocomplete-input {
align-content: flex-start;
display: flex;
flex-wrap: wrap;
height: auto;
min-height: $unit-8;
padding: $unit-h;
&.is-focused {
@include control-shadow();
border-color: $primary-color;
}
.form-input {
border-color: transparent;
box-shadow: none;
display: inline-block;
flex: 1 0 auto;
height: $unit-6;
line-height: $unit-4;
margin: $unit-h;
width: auto;
}
}
.menu {
left: 0;
position: absolute;
top: 100%;
width: 100%;
}
&.autocomplete-oneline {
.form-autocomplete-input {
flex-wrap: nowrap;
overflow-x: auto;
}
.chip {
flex: 1 0 auto;
}
}
}
// Avatars
.avatar {
@include avatar-base();
background: $primary-color;
border-radius: 50%;
color: rgba($light-color, .85);
display: inline-block;
font-weight: 300;
line-height: 1.25;
margin: 0;
position: relative;
vertical-align: middle;
&.avatar-xs {
@include avatar-base($unit-4);
}
&.avatar-sm {
@include avatar-base($unit-6);
}
&.avatar-lg {
@include avatar-base($unit-12);
}
&.avatar-xl {
@include avatar-base($unit-16);
}
img {
border-radius: 50%;
height: 100%;
position: relative;
width: 100%;
z-index: $zindex-0;
}
.avatar-icon,
.avatar-presence {
background: $bg-color-light;
bottom: 14.64%;
height: 50%;
padding: $border-width-lg;
position: absolute;
right: 14.64%;
transform: translate(50%, 50%);
width: 50%;
z-index: $zindex-0 + 1;
}
.avatar-presence {
background: $gray-color;
box-shadow: 0 0 0 $border-width-lg $light-color;
border-radius: 50%;
height: .5em;
width: .5em;
&.online {
background: $success-color;
}
&.busy {
background: $error-color;
}
&.away {
background: $warning-color;
}
}
&[data-initial]::before {
color: currentColor;
content: attr(data-initial);
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
z-index: $zindex-0;
}
}
\ No newline at end of file
// Badges
.badge {
position: relative;
white-space: nowrap;
&[data-badge],
&:not([data-badge]) {
&::after {
background: $primary-color;
background-clip: padding-box;
border-radius: .5rem;
box-shadow: 0 0 0 .1rem $bg-color-light;
color: $light-color;
content: attr(data-badge);
display: inline-block;
transform: translate(-.05rem, -.5rem);
}
}
&[data-badge] {
&::after {
font-size: $font-size-sm;
height: .9rem;
line-height: 1;
min-width: .9rem;
padding: .1rem .2rem;
text-align: center;
white-space: nowrap;
}
}
&:not([data-badge]),
&[data-badge=""] {
&::after {
height: 6px;
min-width: 6px;
padding: 0;
width: 6px;
}
}
// Badges for Buttons
&.btn {
&::after {
position: absolute;
top: 0;
right: 0;
transform: translate(50%, -50%);
}
}
// Badges for Avatars
&.avatar {
&::after {
position: absolute;
top: 14.64%;
right: 14.64%;
transform: translate(50%, -50%);
z-index: $zindex-1;
}
}
}
// Bars
.bar {
background: $bg-color-dark;
border-radius: $border-radius;
display: flex;
flex-wrap: nowrap;
height: $unit-4;
width: 100%;
&.bar-sm {
height: $unit-1;
}
// TODO: attr() support
.bar-item {
background: $primary-color;
color: $light-color;
display: block;
font-size: $font-size-sm;
flex-shrink: 0;
line-height: $unit-4;
height: 100%;
position: relative;
text-align: center;
width: 0;
&:first-child {
border-bottom-left-radius: $border-radius;
border-top-left-radius: $border-radius;
}
&:last-child {
border-bottom-right-radius: $border-radius;
border-top-right-radius: $border-radius;
flex-shrink: 1;
}
}
}
// Slider bar
.bar-slider {
height: $border-width-lg;
margin: $layout-spacing 0;
position: relative;
.bar-item {
left: 0;
padding: 0;
position: absolute;
&:not(:last-child):first-child {
background: $bg-color-dark;
z-index: $zindex-0;
}
}
.bar-slider-btn {
background: $primary-color;
border: 0;
border-radius: 50%;
height: $unit-3;
padding: 0;
position: absolute;
right: 0;
top: 50%;
transform: translate(50%, -50%);
width: $unit-3;
&:active {
box-shadow: 0 0 0 .1rem $primary-color;
}
}
}
// Base
*,
*::before,
*::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
font-size: $html-font-size;
line-height: $html-line-height;
-webkit-tap-highlight-color: transparent;
}
body {
background: $body-bg;
color: $body-font-color;
font-family: $body-font-family;
font-size: $font-size;
overflow-x: hidden;
text-rendering: optimizeLegibility;
}
a {
color: $link-color;
outline: none;
text-decoration: none;
&:focus {
@include control-shadow();
}
&:focus,
&:hover,
&:active,
&.active {
color: $link-color-dark;
text-decoration: underline;
}
&:visited {
color: $link-color-light;
}
}
// Breadcrumbs
.breadcrumb {
list-style: none;
margin: $unit-1 0;
padding: $unit-1 0;
.breadcrumb-item {
color: $gray-color-dark;
display: inline-block;
margin: 0;
padding: $unit-1 0;
&:not(:last-child) {
margin-right: $unit-1;
a {
color: $gray-color-dark;
}
}
&:not(:first-child) {
&::before {
color: $gray-color-light;
content: "/";
padding-right: $unit-2;
}
}
}
}
// Buttons
.btn {
@include control-transition();
appearance: none;
background: $bg-color-light;
border: $border-width solid $primary-color;
border-radius: $border-radius;
color: $primary-color;
cursor: pointer;
display: inline-block;
font-size: $font-size;
height: $control-size;
line-height: $line-height;
outline: none;
padding: $control-padding-y $control-padding-x;
text-align: center;
text-decoration: none;
user-select: none;
vertical-align: middle;
white-space: nowrap;
&:focus {
@include control-shadow();
}
&:focus,
&:hover {
background: $secondary-color;
border-color: $primary-color-dark;
text-decoration: none;
}
&:active,
&.active {
background: $primary-color-dark;
border-color: darken($primary-color-dark, 5%);
color: $light-color;
text-decoration: none;
&.loading {
&::after {
border-bottom-color: $light-color;
border-left-color: $light-color;
}
}
}
&[disabled],
&:disabled,
&.disabled {
cursor: default;
opacity: .5;
pointer-events: none;
}
// Button Primary
&.btn-primary {
background: $primary-color;
border-color: $primary-color-dark;
color: $light-color;
&:focus,
&:hover {
background: darken($primary-color-dark, 2%);
border-color: darken($primary-color-dark, 5%);
color: $light-color;
}
&:active,
&.active {
background: darken($primary-color-dark, 4%);
border-color: darken($primary-color-dark, 7%);
color: $light-color;
}
&.loading {
&::after {
border-bottom-color: $light-color;
border-left-color: $light-color;
}
}
}
// Button Colors
&.btn-success {
@include button-variant($success-color);
}
&.btn-error {
@include button-variant($error-color);
}
&.btn-warning {
@include button-variant($warning-color);
}
// Button Link
&.btn-link {
background: transparent;
border-color: transparent;
color: $link-color;
&:focus,
&:hover,
&:active,
&.active {
color: $link-color-dark;
}
}
// Button Sizes
&.btn-sm {
font-size: $font-size-sm;
height: $control-size-sm;
padding: $control-padding-y-sm $control-padding-x-sm;
}
&.btn-lg {
font-size: $font-size-lg;
height: $control-size-lg;
padding: $control-padding-y-lg $control-padding-x-lg;
}
// Button Block
&.btn-block {
display: block;
width: 100%;
}
// Button Action
&.btn-action {
width: $control-size;
padding-left: 0;
padding-right: 0;
&.btn-sm {
width: $control-size-sm;
}
&.btn-lg {
width: $control-size-lg;
}
}
// Button Clear
&.btn-clear {
background: transparent;
border: 0;
color: currentColor;
height: $unit-4;
line-height: $unit-4;
margin-left: $unit-1;
margin-right: -2px;
opacity: 1;
padding: 0;
text-decoration: none;
width: $unit-4;
&:hover {
opacity: .95;
}
&::before {
content: "\2715";
}
}
}
// Button groups
.btn-group {
display: inline-flex;
flex-wrap: wrap;
.btn {
flex: 1 0 auto;
&:first-child:not(:last-child) {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
&:not(:first-child):not(:last-child) {
border-radius: 0;
margin-left: -$border-width;
}
&:last-child:not(:first-child) {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
margin-left: -$border-width;
}
&:focus,
&:hover,
&:active,
&.active {
z-index: $zindex-0;
}
}
&.btn-group-block {
display: flex;
.btn {
flex: 1 0 0;
}
}
}
// Calendars
.calendar {
border: $border-width solid $border-color;
border-radius: $border-radius;
display: block;
min-width: 280px;
.calendar-nav {
align-items: center;
background: $bg-color;
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;
display: flex;
font-size: $font-size-lg;
padding: $layout-spacing;
}
.calendar-header,
.calendar-body {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: $layout-spacing 0;
.calendar-date {
flex: 0 0 14.28%; // 7 calendar-items each row
max-width: 14.28%;
}
}
.calendar-header {
background: $bg-color;
border-bottom: $border-width solid $border-color;
color: $gray-color;
font-size: $font-size-sm;
text-align: center;
}
.calendar-body {
color: $gray-color-dark;
}
.calendar-date {
border: 0;
padding: $unit-1;
.date-item {
@include control-transition();
appearance: none;
background: transparent;
border: $border-width solid transparent;
border-radius: 50%;
color: $gray-color-dark;
cursor: pointer;
font-size: $font-size-sm;
height: $unit-7;
line-height: $unit-5;
outline: none;
padding: $unit-h;
position: relative;
text-align: center;
text-decoration: none;
vertical-align: middle;
white-space: nowrap;
width: $unit-7;
&.date-today {
border-color: $secondary-color-dark;
color: $primary-color;
}
&:focus {
@include control-shadow();
}
&:focus,
&:hover {
background: $secondary-color-light;
border-color: $secondary-color-dark;
color: $primary-color;
text-decoration: none;
}
&:active,
&.active {
background: $primary-color-dark;
border-color: darken($primary-color-dark, 5%);
color: $light-color;
}
// Calendar badge support
&.badge {
&::after {
position: absolute;
top: 3px;
right: 3px;
transform: translate(50%, -50%);
}
}
}
.date-item,
.calendar-event {
&:disabled,
&.disabled {
cursor: default;
opacity: .25;
pointer-events: none;
}
}
&.prev-month,
&.next-month {
.date-item,
.calendar-event {
opacity: .25;
}
}
}
.calendar-range {
position: relative;
&::before {
background: $secondary-color;
content: "";
height: $unit-7;
left: 0;
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
&.range-start {
&::before {
left: 50%;
}
}
&.range-end {
&::before {
right: 50%;
}
}
&.range-start,
&.range-end {
.date-item {
background: $primary-color-dark;
border-color: darken($primary-color-dark, 5%);
color: $light-color;
}
}
.date-item {
color: $primary-color;
}
}
// Calendars size
&.calendar-lg {
.calendar-body {
padding: 0;
.calendar-date {
border-bottom: $border-width solid $border-color;
border-right: $border-width solid $border-color;
display: flex;
flex-direction: column;
height: 5.5rem;
padding: 0;
&:nth-child(7n) {
border-right: 0;
}
&:nth-last-child(-n+7) {
border-bottom: 0;
}
}
}
.date-item {
align-self: flex-end;
height: $unit-7;
margin-right: $layout-spacing-sm;
margin-top: $layout-spacing-sm;
}
.calendar-range {
&::before {
top: 19px;
}
&.range-start {
&::before {
left: auto;
width: 19px;
}
}
&.range-end {
&::before {
right: 19px;
}
}
}
.calendar-events {
flex-grow: 1;
line-height: 1;
overflow-y: auto;
padding: $layout-spacing-sm;
}
.calendar-event {
border-radius: $border-radius;
font-size: $font-size-sm;
display: block;
margin: $unit-h auto;
overflow: hidden;
padding: 3px 4px;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
// Cards
.card {
background: $bg-color-light;
border: $border-width solid $border-color;
border-radius: $border-radius;
display: flex;
flex-direction: column;
.card-header,
.card-body,
.card-footer {
padding: $layout-spacing-lg;
padding-bottom: 0;
&:last-child {
padding-bottom: $layout-spacing-lg;
}
}
.card-body {
flex: 1 1 auto;
}
.card-image {
padding-top: $layout-spacing-lg;
&:first-child {
padding-top: 0;
img {
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;
}
}
&:last-child {
img {
border-bottom-left-radius: $border-radius;
border-bottom-right-radius: $border-radius;
}
}
}
}
// Carousels
.carousel {
background: $bg-color;
display: block;
overflow: hidden;
position: relative;
width: 100%;
-webkit-overflow-scrolling: touch;
z-index: $zindex-0;
.carousel-container {
height: 100%;
left: 0;
position: relative;
&::before {
content: "";
display: block;
padding-bottom: 56.25%;
}
.carousel-item {
animation: carousel-slideout 1s ease-in-out 1;
height: 100%;
left: 0;
margin: 0;
opacity: 0;
position: absolute;
top: 0;
width: 100%;
&:hover {
.item-prev,
.item-next {
opacity: 1;
}
}
}
.item-prev,
.item-next {
background: rgba($gray-color-light, .25);
border-color: rgba($gray-color-light, .5);
color: $gray-color-light;
opacity: 0;
position: absolute;
top: 50%;
transition: all .4s ease;
transform: translateY(-50%);
z-index: $zindex-1;
}
.item-prev {
left: 1rem;
}
.item-next {
right: 1rem;
}
}
.carousel-locator {
&:nth-of-type(1):checked ~ .carousel-container .carousel-item:nth-of-type(1),
&:nth-of-type(2):checked ~ .carousel-container .carousel-item:nth-of-type(2),
&:nth-of-type(3):checked ~ .carousel-container .carousel-item:nth-of-type(3),
&:nth-of-type(4):checked ~ .carousel-container .carousel-item:nth-of-type(4) {
animation: carousel-slidein .75s ease-in-out 1;
opacity: 1;
z-index: $zindex-1;
}
&:nth-of-type(1):checked ~ .carousel-nav .nav-item:nth-of-type(1),
&:nth-of-type(2):checked ~ .carousel-nav .nav-item:nth-of-type(2),
&:nth-of-type(3):checked ~ .carousel-nav .nav-item:nth-of-type(3),
&:nth-of-type(4):checked ~ .carousel-nav .nav-item:nth-of-type(4) {
color: $gray-color-light;
}
}
.carousel-nav {
bottom: $layout-spacing;
display: flex;
justify-content: center;
left: 50%;
position: absolute;
transform: translateX(-50%);
width: 10rem;
z-index: $zindex-1;
.nav-item {
color: rgba($gray-color-light, .5);
display: block;
flex: 1 0 auto;
height: $unit-8;
margin: $unit-1;
max-width: 2.5rem;
position: relative;
&::before {
background: currentColor;
content: "";
display: block;
height: $unit-h;
position: absolute;
top: .5rem;
width: 100%;
}
}
}
}
@keyframes carousel-slidein {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(0);
}
}
@keyframes carousel-slideout {
0% {
opacity: 1;
transform: translateX(0);
}
100% {
opacity: 1;
transform: translateX(-50%);
}
}
// Chips
.chip {
align-items: center;
background: $bg-color-dark;
border-radius: 5rem;
color: $gray-color-dark;
display: inline-flex;
font-size: 90%;
height: $unit-6;
line-height: $unit-4;
margin: $unit-h;
max-width: 100%;
padding: $unit-1 $unit-2;
text-decoration: none;
vertical-align: middle;
&.active {
background: $primary-color;
color: $light-color;
}
.avatar {
margin-left: -$unit-2;
margin-right: $unit-1;
}
.btn-clear {
transform: scale(.75);
}
}
// Codes
code {
@include label-base();
@include label-variant($code-color, lighten($code-color, 42.5%));
font-size: 85%;
}
.code {
border-radius: $border-radius;
color: $body-font-color;
position: relative;
&::before {
color: $gray-color;
content: attr(data-lang);
font-size: $font-size-sm;
position: absolute;
right: $layout-spacing;
top: $unit-h;
}
code {
background: $bg-color;
color: inherit;
display: block;
line-height: 1.5;
overflow-x: auto;
padding: 1rem;
width: 100%;
}
}
// Image comparison slider
// Credit: http://codepen.io/solipsistacp/pen/Gpmaq
.comparison-slider {
height: 50vh;
overflow: hidden;
position: relative;
width: 100%;
-webkit-overflow-scrolling: touch;
.comparison-before,
.comparison-after {
height: 100%;
left: 0;
margin: 0;
overflow: hidden;
position: absolute;
top: 0;
img {
height: 100%;
object-fit: cover;
object-position: left center;
position: absolute;
width: 100%;
}
}
.comparison-before {
width: 100%;
z-index: 1;
.comparison-label {
right: $unit-4;
}
}
.comparison-after {
max-width: 100%;
min-width: 0;
z-index: 2;
&::before {
background: transparent;
content: "";
cursor: default;
height: 100%;
left: 0;
position: absolute;
right: $unit-4;
top: 0;
z-index: $zindex-0;
}
&::after {
background: currentColor;
border-radius: 50%;
box-shadow: 0 -5px, 0 5px;
color: $light-color;
content: "";
height: 3px;
position: absolute;
right: $unit-2;
top: 50%;
transform: translate(50%, -50%);
width: 3px;
}
.comparison-label {
left: $unit-4;
}
}
.comparison-resizer {
animation: first-run 1.5s 1 ease-in-out;
cursor: ew-resize;
height: $unit-4;
left: 0;
max-width: 100%;
min-width: $unit-4;
opacity: 0;
outline: none;
position: relative;
resize: horizontal;
top: 50%;
transform: translateY(-50%) scaleY(30);
width: 0;
}
.comparison-label {
background: rgba($dark-color, .5);
bottom: $unit-4;
color: $light-color;
padding: $unit-1 $unit-2;
position: absolute;
user-select: none;
}
}
@keyframes first-run {
0% {
width: 0;
}
25% {
width: $unit-12;
}
50% {
width: $unit-4;
}
75% {
width: $unit-6;
}
100% {
width: 0;
}
}
// Dropdown
.dropdown {
display: inline-block;
position: relative;
.menu {
animation: slide-down .15s ease 1;
display: none;
left: 0;
max-height: 50vh;
overflow-y: auto;
position: absolute;
top: 100%;
}
&.dropdown-right {
.menu {
left: auto;
right: 0;
}
}
&.active .menu,
.dropdown-toggle:focus + .menu,
.menu:hover {
display: block;
}
// Fix dropdown-toggle border radius in button groups
.btn-group {
.dropdown-toggle:nth-last-child(2) {
border-bottom-right-radius: $border-radius;
border-top-right-radius: $border-radius;
}
}
}
// Empty states (or Blank slates)
.empty {
background: $bg-color;
border-radius: $border-radius;
color: $gray-color-dark;
text-align: center;
padding: $unit-16 $unit-8;
.empty-icon {
margin-bottom: $layout-spacing-lg;
}
.empty-title,
.empty-subtitle {
margin: $layout-spacing auto;
}
.empty-action {
margin-top: $layout-spacing-lg;
}
}
// Filters
// The number of filter options
$filter-number: 8 !default;
%filter-checked-nav {
background: $primary-color;
color: $light-color;
}
%filter-checked-body {
display: none;
}
.filter {
.filter-nav {
margin: $layout-spacing 0;
}
.filter-body {
display: flex;
flex-wrap: wrap;
}
.filter-tag {
@for $i from 0 through ($filter-number) {
&#tag-#{$i}:checked ~ .filter-nav .chip[for="tag-#{$i}"] {
@extend %filter-checked-nav;
}
}
@for $i from 1 through ($filter-number) {
&#tag-#{$i}:checked ~ .filter-body .filter-item:not([data-tag~="tag-#{$i}"]) {
@extend %filter-checked-body;
}
}
}
}
This diff is collapsed.
// CSS Icons
@import "icons/icons-core";
@import "icons/icons-navigation";
@import "icons/icons-action";
@import "icons/icons-object";
\ No newline at end of file
// Labels
.label {
@include label-base();
@include label-variant(lighten($body-font-color, 5%), $bg-color-dark);
display: inline-block;
// Label rounded
&.label-rounded {
border-radius: 5rem;
padding-left: .4rem;
padding-right: .4rem;
}
// Label colors
&.label-primary {
@include label-variant($light-color, $primary-color);
}
&.label-secondary {
@include label-variant($primary-color, $secondary-color);
}
&.label-success {
@include label-variant($light-color, $success-color);
}
&.label-warning {
@include label-variant($light-color, $warning-color);
}
&.label-error {
@include label-variant($light-color, $error-color);
}
}
// Layout
.container {
margin-left: auto;
margin-right: auto;
padding-left: $layout-spacing;
padding-right: $layout-spacing;
width: 100%;
@extend .clearfix;
$grid-spacing: ($layout-spacing / ($layout-spacing * 0 + 1)) * $html-font-size;
&.grid-xl {
max-width: $grid-spacing * 2 + $size-xl;
}
&.grid-lg {
max-width: $grid-spacing * 2 + $size-lg;
}
&.grid-md {
max-width: $grid-spacing * 2 + $size-md;
}
&.grid-sm {
max-width: $grid-spacing * 2 + $size-sm;
}
&.grid-xs {
max-width: $grid-spacing * 2 + $size-xs;
}
}
// Responsive breakpoint system
.show-xs,
.show-sm,
.show-md,
.show-lg,
.show-xl {
display: none !important;
}
// Responsive grid system
.columns {
display: flex;
flex-wrap: wrap;
margin-left: -$layout-spacing;
margin-right: -$layout-spacing;
&.col-gapless {
margin-left: 0;
margin-right: 0;
& > .column {
padding-left: 0;
padding-right: 0;
}
}
&.col-oneline {
flex-wrap: nowrap;
overflow-x: auto;
}
}
.column {
flex: 1;
max-width: 100%;
padding-left: $layout-spacing;
padding-right: $layout-spacing;
&.col-12,
&.col-11,
&.col-10,
&.col-9,
&.col-8,
&.col-7,
&.col-6,
&.col-5,
&.col-4,
&.col-3,
&.col-2,
&.col-1 {
flex: none;
}
}
.col-12 {
width: 100%;
}
.col-11 {
width: 91.66666667%;
}
.col-10 {
width: 83.33333333%;
}
.col-9 {
width: 75%;
}
.col-8 {
width: 66.66666667%;
}
.col-7 {
width: 58.33333333%;
}
.col-6 {
width: 50%;
}
.col-5 {
width: 41.66666667%;
}
.col-4 {
width: 33.33333333%;
}
.col-3 {
width: 25%;
}
.col-2 {
width: 16.66666667%;
}
.col-1 {
width: 8.33333333%;
}
.col-auto {
flex: 0 0 auto;
max-width: none;
width: auto;
}
.col-mx-auto {
margin-left: auto;
margin-right: auto;
}
.col-ml-auto {
margin-left: auto;
}
.col-mr-auto {
margin-right: auto;
}
@media (max-width: $size-xl) {
.col-xl-12,
.col-xl-11,
.col-xl-10,
.col-xl-9,
.col-xl-8,
.col-xl-7,
.col-xl-6,
.col-xl-5,
.col-xl-4,
.col-xl-3,
.col-xl-2,
.col-xl-1 {
flex: none;
}
.col-xl-12 {
width: 100%;
}
.col-xl-11 {
width: 91.66666667%;
}
.col-xl-10 {
width: 83.33333333%;
}
.col-xl-9 {
width: 75%;
}
.col-xl-8 {
width: 66.66666667%;
}
.col-xl-7 {
width: 58.33333333%;
}
.col-xl-6 {
width: 50%;
}
.col-xl-5 {
width: 41.66666667%;
}
.col-xl-4 {
width: 33.33333333%;
}
.col-xl-3 {
width: 25%;
}
.col-xl-2 {
width: 16.66666667%;
}
.col-xl-1 {
width: 8.33333333%;
}
.hide-xl {
display: none !important;
}
.show-xl {
display: block !important;
}
}
@media (max-width: $size-lg) {
.col-lg-12,
.col-lg-11,
.col-lg-10,
.col-lg-9,
.col-lg-8,
.col-lg-7,
.col-lg-6,
.col-lg-5,
.col-lg-4,
.col-lg-3,
.col-lg-2,
.col-lg-1 {
flex: none;
}
.col-lg-12 {
width: 100%;
}
.col-lg-11 {
width: 91.66666667%;
}
.col-lg-10 {
width: 83.33333333%;
}
.col-lg-9 {
width: 75%;
}
.col-lg-8 {
width: 66.66666667%;
}
.col-lg-7 {
width: 58.33333333%;
}
.col-lg-6 {
width: 50%;
}
.col-lg-5 {
width: 41.66666667%;
}
.col-lg-4 {
width: 33.33333333%;
}
.col-lg-3 {
width: 25%;
}
.col-lg-2 {
width: 16.66666667%;
}
.col-lg-1 {
width: 8.33333333%;
}
.hide-lg {
display: none !important;
}
.show-lg {
display: block !important;
}
}
@media (max-width: $size-md) {
.col-md-12,
.col-md-11,
.col-md-10,
.col-md-9,
.col-md-8,
.col-md-7,
.col-md-6,
.col-md-5,
.col-md-4,
.col-md-3,
.col-md-2,
.col-md-1 {
flex: none;
}
.col-md-12 {
width: 100%;
}
.col-md-11 {
width: 91.66666667%;
}
.col-md-10 {
width: 83.33333333%;
}
.col-md-9 {
width: 75%;
}
.col-md-8 {
width: 66.66666667%;
}
.col-md-7 {
width: 58.33333333%;
}
.col-md-6 {
width: 50%;
}
.col-md-5 {
width: 41.66666667%;
}
.col-md-4 {
width: 33.33333333%;
}
.col-md-3 {
width: 25%;
}
.col-md-2 {
width: 16.66666667%;
}
.col-md-1 {
width: 8.33333333%;
}
.hide-md {
display: none !important;
}
.show-md {
display: block !important;
}
}
@media (max-width: $size-sm) {
.col-sm-12,
.col-sm-11,
.col-sm-10,
.col-sm-9,
.col-sm-8,
.col-sm-7,
.col-sm-6,
.col-sm-5,
.col-sm-4,
.col-sm-3,
.col-sm-2,
.col-sm-1 {
flex: none;
}
.col-sm-12 {
width: 100%;
}
.col-sm-11 {
width: 91.66666667%;
}
.col-sm-10 {
width: 83.33333333%;
}
.col-sm-9 {
width: 75%;
}
.col-sm-8 {
width: 66.66666667%;
}
.col-sm-7 {
width: 58.33333333%;
}
.col-sm-6 {
width: 50%;
}
.col-sm-5 {
width: 41.66666667%;
}
.col-sm-4 {
width: 33.33333333%;
}
.col-sm-3 {
width: 25%;
}
.col-sm-2 {
width: 16.66666667%;
}
.col-sm-1 {
width: 8.33333333%;
}
.hide-sm {
display: none !important;
}
.show-sm {
display: block !important;
}
}
@media (max-width: $size-xs) {
.col-xs-12,
.col-xs-11,
.col-xs-10,
.col-xs-9,
.col-xs-8,
.col-xs-7,
.col-xs-6,
.col-xs-5,
.col-xs-4,
.col-xs-3,
.col-xs-2,
.col-xs-1 {
flex: none;
}
.col-xs-12 {
width: 100%;
}
.col-xs-11 {
width: 91.66666667%;
}
.col-xs-10 {
width: 83.33333333%;
}
.col-xs-9 {
width: 75%;
}
.col-xs-8 {
width: 66.66666667%;
}
.col-xs-7 {
width: 58.33333333%;
}
.col-xs-6 {
width: 50%;
}
.col-xs-5 {
width: 41.66666667%;
}
.col-xs-4 {
width: 33.33333333%;
}
.col-xs-3 {
width: 25%;
}
.col-xs-2 {
width: 16.66666667%;
}
.col-xs-1 {
width: 8.33333333%;
}
.hide-xs {
display: none !important;
}
.show-xs {
display: block !important;
}
}
// Media
// Image responsive
.img-responsive {
display: block;
height: auto;
max-width: 100%;
}
// object-fit support is coming to Microsoft Edge
// https://developer.microsoft.com/en-us/microsoft-edge/platform/status/objectfitandobjectposition/
.img-fit-cover {
object-fit: cover;
}
.img-fit-contain {
object-fit: contain;
}
// Video responsive
.video-responsive {
display: block;
overflow: hidden;
padding: 0;
position: relative;
width: 100%;
&::before {
content: "";
display: block;
padding-bottom: 56.25%; // Default ratio 16:9, you can calculate this value by dividing 9 by 16
}
iframe,
object,
embed {
border: 0;
bottom: 0;
height: 100%;
left: 0;
position: absolute;
right: 0;
top: 0;
width: 100%;
}
}
video.video-responsive {
height: auto;
max-width: 100%;
&::before {
content: none;
}
}
.video-responsive-4-3 {
&::before {
padding-bottom: 75%; // Ratio 4:3
}
}
.video-responsive-1-1 {
&::before {
padding-bottom: 100%; // Ratio 1:1
}
}
// Figure
.figure {
margin: 0 0 $layout-spacing 0;
.figure-caption {
color: $gray-color-dark;
margin-top: $layout-spacing;
}
}
// Menus
.menu {
@include shadow-variant(.05rem);
background: $bg-color-light;
border-radius: $border-radius;
list-style: none;
margin: 0;
min-width: $control-width-xs;
padding: $unit-2;
transform: translateY($layout-spacing-sm);
z-index: $zindex-3;
&.menu-nav {
background: transparent;
box-shadow: none;
}
.menu-item {
margin-top: 0;
padding: 0 $unit-2;
text-decoration: none;
user-select: none;
& > a {
border-radius: $border-radius;
color: inherit;
display: block;
margin: 0 (-$unit-2);
padding: $unit-1 $unit-2;
text-decoration: none;
&:focus,
&:hover {
background: $secondary-color;
color: $primary-color;
}
&:active,
&.active {
background: $secondary-color;
color: $primary-color;
}
}
.form-checkbox,
.form-radio,
.form-switch {
margin: $unit-h 0;
}
& + .menu-item {
margin-top: $unit-1;
}
}
.menu-badge {
float: right;
padding: $unit-1 0;
.btn {
margin-top: -$unit-h;
}
}
}
// Meters
// Credit: https://css-tricks.com/html5-meter-element/
.meter {
appearance: none;
background: $bg-color;
border: 0;
border-radius: $border-radius;
display: block;
width: 100%;
height: $unit-4;
&::-webkit-meter-inner-element {
display: block;
}
&::-webkit-meter-bar,
&::-webkit-meter-optimum-value,
&::-webkit-meter-suboptimum-value,
&::-webkit-meter-even-less-good-value {
border-radius: $border-radius;
}
&::-webkit-meter-bar {
background: $bg-color;
}
&::-webkit-meter-optimum-value {
background: $success-color;
}
&::-webkit-meter-suboptimum-value {
background: $warning-color;
}
&::-webkit-meter-even-less-good-value {
background: $error-color;
}
&::-moz-meter-bar,
&:-moz-meter-optimum,
&:-moz-meter-sub-optimum,
&:-moz-meter-sub-sub-optimum {
border-radius: $border-radius;
}
&:-moz-meter-optimum::-moz-meter-bar {
background: $success-color;
}
&:-moz-meter-sub-optimum::-moz-meter-bar {
background: $warning-color;
}
&:-moz-meter-sub-sub-optimum::-moz-meter-bar {
background: $error-color;
}
}
// Mixins
@import "mixins/avatar";
@import "mixins/button";
@import "mixins/clearfix";
@import "mixins/color";
@import "mixins/label";
@import "mixins/position";
@import "mixins/shadow";
@import "mixins/text";
@import "mixins/toast";
@import "mixins/transition";
This diff is collapsed.
// Navbar
.navbar {
align-items: stretch;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.navbar-section {
align-items: center;
display: flex;
flex: 1 0 0;
&:not(:first-child):last-child {
justify-content: flex-end;
}
}
.navbar-center {
align-items: center;
display: flex;
flex: 0 0 auto;
}
.navbar-brand {
font-size: $font-size-lg;
font-weight: 500;
text-decoration: none;
}
}
// Navs
.nav {
display: flex;
flex-direction: column;
list-style: none;
margin: $unit-1 0;
.nav-item {
a {
color: $gray-color-dark;
padding: $unit-1 $unit-2;
text-decoration: none;
&:focus,
&:hover {
color: $primary-color;
}
}
&.active {
& > a {
color: darken($gray-color-dark, 10%);
font-weight: bold;
&:focus,
&:hover {
color: $primary-color;
}
}
}
}
& .nav {
margin-bottom: $unit-2;
margin-left: $unit-4;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment