mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit db831239afe8d2687cce567ba05f0cc87b5b0265
parent 0efe53af4a77fa3cc6c3522570952e257068739b
Author: markseu <mark2011@mayberg.se>
Date:   Wed, 28 Aug 2013 12:01:46 +0200

Core update

Diffstat:
MREADME.md | 2+-
Mmedia/styles/default.css | 9+++++++--
Msystem/core/core.php | 41+++++++++++++++++++++++++++++------------
Msystem/core/core_markdown.php | 60++++++++++++++++++++++++++++++++++++++++++++++--------------
Dsystem/core/core_plaintext.php | 22----------------------
Msystem/core/core_webinterface.php | 15++++++++-------
Myellow.php | 3+++
7 files changed, 94 insertions(+), 58 deletions(-)

diff --git a/README.md b/README.md @@ -15,7 +15,7 @@ With Yellow you don't get a lot of extra stuff, there are [Yellow extensions on How to make a website? ---------------------- You already have everything you need, start by editing the default pages. -For more information please see [Yellow documentation](https://github.com/markseu/yellowcms-extensions/blob/master/documentation/README.md). +For more information see [Yellow documentation](https://github.com/markseu/yellowcms-extensions/blob/master/documentation/README.md). Need help? Have a question? --------------------------- diff --git a/media/styles/default.css b/media/styles/default.css @@ -1,6 +1,6 @@ -/* Yellow default style 0.1.1 */ +/* Yellow default style 0.1.2 */ -html, body, div, span { margin:0; padding:0; border:0; vertical-align:baseline; } +html, body, div, pre, span { margin:0; padding:0; border:0; vertical-align:baseline; } body { margin:1em; background-color:#fff; color:#717171; @@ -27,6 +27,8 @@ a:hover { color:#07d; } .content a { color:#07d; } .content a:hover { color:#07d; text-decoration:underline; } .content img { max-width:100%; height:auto; } +.content .flexible { position:relative; padding-bottom:56.25%; padding-top:30px; } +.content .flexible iframe { position:absolute; top:0; left:0; width:100%; height:100%; } .footer { margin-top:0.5em; padding-top:0.5em; border-top:1px solid #ddd; } .left { float:left; margin:0 1em 0 0; } .center { display:block; margin:0 auto; } @@ -34,8 +36,11 @@ a:hover { color:#07d; } /* Responsive and print */ +.page { margin:0 auto; max-width:62em; } + @media screen and (min-width:62em) { body { width:60em; margin:1em auto; } + .page{ margin:0; max-width:none; } } @media screen and (max-width:30em) { body { margin:0.5em; font-size:0.9em; } diff --git a/system/core/core.php b/system/core/core.php @@ -5,7 +5,7 @@ // Yellow main class class Yellow { - const Version = "0.1.14"; + const Version = "0.1.16"; var $page; //current page data var $pages; //current page tree from file system var $toolbox; //toolbox with helpers @@ -393,22 +393,25 @@ class Yellow_Page // Parse page content function parseContent() { - if(!is_object($this->parser)) + if(!is_object($this->parser) && $this->yellow->plugins->isExisting($this->get("parser"))) { - $text = substrb($this->rawData, $this->metaDataOffsetBytes); - if($this->yellow->plugins->isExisting($this->get("parser"))) - { - $this->parser = $this->yellow->plugins->plugins[$this->get("parser")]["obj"]; - $text = $this->parser->parse($text); - } + $this->parser = $this->yellow->plugins->plugins[$this->get("parser")]["obj"]; + $this->parser->parse(substrb($this->rawData, $this->metaDataOffsetBytes)); foreach($this->yellow->plugins->plugins as $key=>$value) { - if(method_exists($value["obj"], "onParseContent")) $text = $value["obj"]->onParseContent($text, $this->statusCode); + if(method_exists($value["obj"], "onParseContent")) + { + $output = $value["obj"]->onParseContent($this->parser->textHtml); + if(!is_null($output)) + { + $this->parser->textHtml = $output; + break; + } + } } - $this->parser->textHtml = $text; if(!$this->isExisting("description")) { - $this->set("description", $this->yellow->toolbox->createTextDescription($this->getContent(), 150)); + $this->set("description", $this->yellow->toolbox->createTextDescription($this->parser->textHtml, 150)); } if(!$this->isExisting("keywords")) { @@ -418,6 +421,21 @@ class Yellow_Page } } + // Parse custom type + function parseType($name, $text, $typeShortcut) + { + $output = NULL; + foreach($this->yellow->plugins->plugins as $key=>$value) + { + if(method_exists($value["obj"], "onParseType")) + { + $output = $value["obj"]->onParseType($name, $text, $typeShortcut); + if(!is_null($output)) break; + } + } + return $output; + } + // Respond with error page function error($statusCode, $pageError = "") { @@ -1506,7 +1524,6 @@ class Yellow_Plugins { global $yellow; require_once("core_markdown.php"); - require_once("core_plaintext.php"); require_once("core_commandline.php"); require_once("core_webinterface.php"); foreach($yellow->toolbox->getDirectoryEntries($yellow->config->get("pluginDir"), "/.*\.php/", true, false) as $entry) diff --git a/system/core/core_markdown.php b/system/core/core_markdown.php @@ -5,24 +5,26 @@ // Markdown parser core plugin class Yellow_Markdown { - const Version = "0.1.5"; - var $markdown; //markdown parser - var $textHtml; //generated text (HTML format) + const Version = "0.1.6"; + var $yellow; //access to API + var $textHtml; //generated text (HTML format) // Initialise plugin function initPlugin($yellow) { - $this->markdown = new Yellow_MarkdownExtraParser($yellow); + $this->yellow = $yellow; } // Parse text function parse($text) { - return $this->textHtml = $this->markdown->transform($text); + $markdown = new Yellow_MarkdownExtraParser($this->yellow); + return $this->textHtml = $markdown->transform($text); } } -require("markdown.php"); +require_once("markdown.php"); + class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser { var $yellow; //access to API @@ -40,6 +42,37 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser $text = preg_replace("/@pageError/i", $this->yellow->page->get("pageError"), $text); return parent::transform($text); } + + // Handle links + function doAutoLinks($text) + { + $text = preg_replace_callback("/<(\w+:[^\'\">\s]+)>/", array(&$this, "_doAutoLinks_url_callback"), $text); + $text = preg_replace_callback("/<(\w+@[\w\-\.]+)>/", array(&$this, "_doAutoLinks_email_callback"), $text); + $text = preg_replace_callback("/\[(\w+)\s+(.*?)\]/", array(&$this, "_doAutoLinks_shortcut_callback"), $text); + return $text; + } + + // Handle shortcuts + function _doAutoLinks_shortcut_callback($matches) + { + $text = preg_replace("/\s+/s", " ", $matches[2]); + $output = $this->yellow->page->parseType($matches[1], $text, true); + if(is_null($output)) $output = $matches[0]; + return $this->hashBlock($output); + } + + // Handle fenced code blocks + function _doFencedCodeBlocks_callback($matches) + { + $text = $matches[4]; + $output = $this->yellow->page->parseType($matches[2], $text, false); + if(is_null($output)) + { + $attr = $this->doExtraAttributes("pre", $dummy =& $matches[3]); + $output = "<pre$attr><code>".htmlspecialchars($text, ENT_NOQUOTES)."</code></pre>"; + } + return "\n\n".$this->hashBlock($output)."\n\n"; + } // Handle images function _doImages_inline_callback($matches) @@ -50,14 +83,13 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser $alt = $matches[2]; $title = $matches[7]; $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); - - $result = "<img src=\"".$this->encodeAttribute($src)."\""; - if($width && $height) $result .= " width=\"$width\" height=\"$height\""; - if(!empty($alt)) $result .= " alt=\"".$this->encodeAttribute($alt)."\""; - if(!empty($title)) $result .= " title=\"".$this->encodeAttribute($title)."\""; - $result .= $attr; - $result .= $this->empty_element_suffix; - return $this->hashPart($result); + $output = "<img src=\"".$this->encodeAttribute($src)."\""; + if($width && $height) $output .= " width=\"$width\" height=\"$height\""; + if(!empty($alt)) $output .= " alt=\"".$this->encodeAttribute($alt)."\""; + if(!empty($title)) $output .= " title=\"".$this->encodeAttribute($title)."\""; + $output .= $attr; + $output .= $this->empty_element_suffix; + return $this->hashPart($output); } } diff --git a/system/core/core_plaintext.php b/system/core/core_plaintext.php @@ -1,21 +0,0 @@ -<?php -// Copyright (c) 2013 Datenstrom, http://datenstrom.se -// This file may be used and distributed under the terms of the public license. - -// Plain text parser core plugin -class Yellow_Plaintext -{ - const Version = "0.1.1"; - var $text; //plain text - var $textHtml; //generated text (HTML format) - - // Parse text, dummy transformation - function parse($text) - { - $this->text = $text; - return $textHtml; - } -} - -$yellow->registerPlugin("plaintext", "Yellow_Plaintext", Yellow_Plaintext::Version); -?> -\ No newline at end of file diff --git a/system/core/core_webinterface.php b/system/core/core_webinterface.php @@ -5,7 +5,7 @@ // Web interface core plugin class Yellow_Webinterface { - const Version = "0.1.7"; + const Version = "0.1.8"; var $yellow; //access to API var $users; //web interface users var $activeLocation; //web interface location? (boolean) @@ -47,15 +47,16 @@ class Yellow_Webinterface } // Handle web content parsing - function onParseContent($text, $statusCode) + function onParseContent($text) { + $output = NULL; if($this->isWebinterfaceLocation() && $this->isUser()) { $serverBase = $this->yellow->config->get("serverBase"); $webinterfaceLocation = trim($this->yellow->config->get("webinterfaceLocation"), '/'); - $text = preg_replace("#<a(.*?)href=\"$serverBase/(?!$webinterfaceLocation)(.*?)\"(.*?)>#", + $output = preg_replace("#<a(.*?)href=\"$serverBase/(?!$webinterfaceLocation)(.*?)\"(.*?)>#", "<a$1href=\"$serverBase/$webinterfaceLocation/$2\"$3>", $text); - switch($statusCode) + switch($this->yellow->page->statusCode) { case 200: $this->rawDataOriginal = $this->yellow->page->rawData; break; case 424: $language = $this->isUser() ? $this->users->getLanguage($this->activeUserEmail) : $this->yellow->page->get("language"); @@ -68,7 +69,7 @@ class Yellow_Webinterface case 500: $this->yellow->page->rawData = $this->rawDataOriginal; break; } } - return $text; + return $output; } // Handle extra HTML header lines @@ -289,14 +290,14 @@ class Yellow_WebinterfaceUsers // Check user login from browser cookie function checkCookie($cookie) { - list($email, $salt, $session) = explode(";", $cookie); + list($email, $salt, $session) = explode(';', $cookie); return $this->isExisting($email) && hash("sha256", $salt.$this->users[$email]["session"])==$session; } // Return user email from browser cookie function getCookieEmail($cookie) { - list($email, $salt, $session) = explode(";", $cookie); + list($email, $salt, $session) = explode(';', $cookie); return $email; } diff --git a/yellow.php b/yellow.php @@ -1,4 +1,7 @@ <?php +// Yellow is a CMS for people who make websites. https://github.com/markseu/yellowcms +// For more information see Yellow documentation. Have fun making your website. + require_once("system/core/core.php"); if(PHP_SAPI != "cli") {