Compare commits
No commits in common. "4342526f6d60fe72c87f7c2fd02c0b9bf4513db5" and "344e486bbc483006512d971f4982e08b49f48560" have entirely different histories.
4342526f6d
...
344e486bbc
@ -31,12 +31,12 @@
|
|||||||
"source": "https://github.com/picocms/Pico"
|
"source": "https://github.com/picocms/Pico"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.0.8 || ^8.0",
|
"php": "^7.0.8",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"twig/twig": "^2.12",
|
"twig/twig": "^2.12",
|
||||||
"symfony/yaml" : "^3.4",
|
"symfony/yaml" : "^3.4",
|
||||||
"erusev/parsedown": "^2.0.0-beta-1",
|
"erusev/parsedown": "1.7.4",
|
||||||
"erusev/parsedown-extra": "^2.0.0-beta-1"
|
"erusev/parsedown-extra": "0.8.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme.",
|
"picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme.",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
Logo: '%theme_url%/img/pico-white.svg'
|
Logo: %theme_url%/img/pico-white.svg
|
||||||
Tagline: Making the web easy.
|
Tagline: Making the web easy.
|
||||||
Social:
|
Social:
|
||||||
- title: Visit us on GitHub
|
- title: Visit us on GitHub
|
||||||
|
38
lib/Pico.php
38
lib/Pico.php
@ -42,12 +42,6 @@
|
|||||||
* @license http://opensource.org/licenses/MIT The MIT License
|
* @license http://opensource.org/licenses/MIT The MIT License
|
||||||
* @version 3.0
|
* @version 3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Erusev\Parsedown\Configurables\Breaks;
|
|
||||||
use Erusev\Parsedown\Parsedown;
|
|
||||||
use Erusev\Parsedown\State;
|
|
||||||
use Erusev\ParsedownExtra\ParsedownExtra;
|
|
||||||
|
|
||||||
class Pico
|
class Pico
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -69,7 +63,7 @@ class Pico
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const API_VERSION = 4;
|
const API_VERSION = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort files in alphabetical ascending order
|
* Sort files in alphabetical ascending order
|
||||||
@ -654,7 +648,7 @@ class Pico
|
|||||||
{
|
{
|
||||||
// scope isolated require()
|
// scope isolated require()
|
||||||
$includeClosure = function ($pluginFile) {
|
$includeClosure = function ($pluginFile) {
|
||||||
require_once($pluginFile);
|
require($pluginFile);
|
||||||
};
|
};
|
||||||
if (PHP_VERSION_ID >= 50400) {
|
if (PHP_VERSION_ID >= 50400) {
|
||||||
$includeClosure = $includeClosure->bindTo(null);
|
$includeClosure = $includeClosure->bindTo(null);
|
||||||
@ -1567,13 +1561,12 @@ class Pico
|
|||||||
public function getParsedown()
|
public function getParsedown()
|
||||||
{
|
{
|
||||||
if ($this->parsedown === null) {
|
if ($this->parsedown === null) {
|
||||||
$state = new State([
|
$className = $this->config['content_config']['extra'] ? 'ParsedownExtra' : 'Parsedown';
|
||||||
new Breaks((bool) $this->config['content_config']['breaks'])
|
$this->parsedown = new $className();
|
||||||
]);
|
|
||||||
if ($this->config['content_config']['extra']){
|
$this->parsedown->setBreaksEnabled((bool) $this->config['content_config']['breaks']);
|
||||||
$state = new ParsedownExtra($state);
|
$this->parsedown->setMarkupEscaped((bool) $this->config['content_config']['escape']);
|
||||||
}
|
$this->parsedown->setUrlsLinked((bool) $this->config['content_config']['auto_urls']);
|
||||||
$this->parsedown = new Parsedown($state);
|
|
||||||
|
|
||||||
$this->triggerEvent('onParsedownRegistered', array(&$this->parsedown));
|
$this->triggerEvent('onParsedownRegistered', array(&$this->parsedown));
|
||||||
}
|
}
|
||||||
@ -1673,13 +1666,14 @@ class Pico
|
|||||||
* @see Pico::getFileContent()
|
* @see Pico::getFileContent()
|
||||||
*
|
*
|
||||||
* @param string $markdown Markdown contents of a page
|
* @param string $markdown Markdown contents of a page
|
||||||
|
* @param bool $singleLine whether to parse just a single line of markup
|
||||||
*
|
*
|
||||||
* @return string parsed contents (HTML)
|
* @return string parsed contents (HTML)
|
||||||
*/
|
*/
|
||||||
public function parseFileContent($markdown)
|
public function parseFileContent($markdown, $singleLine = false)
|
||||||
{
|
{
|
||||||
$markdownParser = $this->getParsedown();
|
$markdownParser = $this->getParsedown();
|
||||||
return @$markdownParser->toHtml($markdown);
|
return !$singleLine ? @$markdownParser->text($markdown) : @$markdownParser->line($markdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2108,12 +2102,12 @@ class Pico
|
|||||||
if ($this->twig === null) {
|
if ($this->twig === null) {
|
||||||
$twigConfig = $this->getConfig('twig_config');
|
$twigConfig = $this->getConfig('twig_config');
|
||||||
|
|
||||||
$twigLoader = new \Twig\Loader\FilesystemLoader($this->getThemesDir() . $this->getTheme());
|
$twigLoader = new Twig_Loader_Filesystem($this->getThemesDir() . $this->getTheme());
|
||||||
$this->twig = new \Twig\Environment($twigLoader, $twigConfig);
|
$this->twig = new Twig_Environment($twigLoader, $twigConfig);
|
||||||
$this->twig->addExtension(new PicoTwigExtension($this));
|
$this->twig->addExtension(new PicoTwigExtension($this));
|
||||||
|
|
||||||
if (!empty($twigConfig['debug'])) {
|
if (!empty($twigConfig['debug'])) {
|
||||||
$this->twig->addExtension(new Twig\Extension\DebugExtension());
|
$this->twig->addExtension(new Twig_Extension_Debug());
|
||||||
}
|
}
|
||||||
|
|
||||||
// register content filter
|
// register content filter
|
||||||
@ -2121,7 +2115,7 @@ class Pico
|
|||||||
// this is the reason why we can't register this filter as part of PicoTwigExtension
|
// this is the reason why we can't register this filter as part of PicoTwigExtension
|
||||||
$pico = $this;
|
$pico = $this;
|
||||||
$pages = &$this->pages;
|
$pages = &$this->pages;
|
||||||
$this->twig->addFilter(new \Twig\TwigFilter(
|
$this->twig->addFilter(new Twig_SimpleFilter(
|
||||||
'content',
|
'content',
|
||||||
function ($page) use ($pico, &$pages) {
|
function ($page) use ($pico, &$pages) {
|
||||||
if (isset($pages[$page])) {
|
if (isset($pages[$page])) {
|
||||||
@ -2162,7 +2156,7 @@ class Pico
|
|||||||
'theme_url' => $this->getConfig('themes_url') . $this->getTheme(),
|
'theme_url' => $this->getConfig('themes_url') . $this->getTheme(),
|
||||||
'site_title' => $this->getConfig('site_title'),
|
'site_title' => $this->getConfig('site_title'),
|
||||||
'meta' => $this->meta,
|
'meta' => $this->meta,
|
||||||
'content' => new \Twig\Markup($this->content, 'UTF-8'),
|
'content' => new Twig_Markup($this->content, 'UTF-8'),
|
||||||
'pages' => $this->pages,
|
'pages' => $this->pages,
|
||||||
'previous_page' => $this->previousPage,
|
'previous_page' => $this->previousPage,
|
||||||
'current_page' => $this->currentPage,
|
'current_page' => $this->currentPage,
|
||||||
|
@ -67,20 +67,20 @@ class PicoTwigExtension extends Twig_Extension
|
|||||||
*
|
*
|
||||||
* @see Twig_ExtensionInterface::getFilters()
|
* @see Twig_ExtensionInterface::getFilters()
|
||||||
*
|
*
|
||||||
* @return \Twig\TwigFilter[] array of Pico's Twig filters
|
* @return Twig_SimpleFilter[] array of Pico's Twig filters
|
||||||
*/
|
*/
|
||||||
public function getFilters()
|
public function getFilters()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'markdown' => new \Twig\TwigFilter(
|
'markdown' => new Twig_SimpleFilter(
|
||||||
'markdown',
|
'markdown',
|
||||||
array($this, 'markdownFilter'),
|
array($this, 'markdownFilter'),
|
||||||
array('is_safe' => array('html'))
|
array('is_safe' => array('html'))
|
||||||
),
|
),
|
||||||
'map' => new \Twig\TwigFilter('map', array($this, 'mapFilter')),
|
'map' => new Twig_SimpleFilter('map', array($this, 'mapFilter')),
|
||||||
'sort_by' => new \Twig\TwigFilter('sort_by', array($this, 'sortByFilter')),
|
'sort_by' => new Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')),
|
||||||
'link' => new \Twig\TwigFilter('link', array($this->pico, 'getPageUrl')),
|
'link' => new Twig_SimpleFilter('link', array($this->pico, 'getPageUrl')),
|
||||||
'url' => new \Twig\TwigFilter('url', array($this->pico, 'substituteUrl'))
|
'url' => new Twig_SimpleFilter('url', array($this->pico, 'substituteUrl'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user