Bug fixes

This commit is contained in:
Diego 2017-04-26 18:56:10 +02:00
parent d1c88a6fdb
commit 19ef56301e
21 changed files with 233 additions and 44 deletions

View File

@ -136,6 +136,12 @@ class Content {
return $this->getField('readMore');
}
//
public function category()
{
return $this->getField('category');
}
// Returns the field key
public function key()
{

View File

@ -24,6 +24,9 @@ function editPage($args)
{
$dbPages->regenerateCli();
// Re index categories
reIndexCategoriesPages();
// Call the plugins after page created.
Theme::plugins('afterPageModify');

View File

@ -21,6 +21,9 @@ function editPost($args)
// Reindex tags, this function is in 70.posts.php
reIndexTagsPosts();
// Re index categories
reIndexCategoriesPosts();
// Call the plugins after post created.
Theme::plugins('afterPostModify');

View File

@ -18,6 +18,9 @@ function addPage($args)
if($key)
{
// Re index categories
reIndexCategoriesPages();
// Call the plugins after page created.
Theme::plugins('afterPageCreate');

View File

@ -143,6 +143,9 @@ class HTML {
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
$html .= '<div class="uk-form-controls">';
$html .= '<select id="'.$id.'" name="'.$args['name'].'" '.$class.'>';
if(isset($args['addEmptySpace'])) {
$html .= '<option value=""></option>';
}
foreach($args['options'] as $key=>$value) {
$html .= '<option value="'.$key.'"'.( ($args['selected']==$key)?' selected="selected"':'').'>'.$value.'</option>';
}

File diff suppressed because one or more lines are too long

View File

@ -65,6 +65,17 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
echo '<li><h2 class="sidebar-button" data-view="sidebar-general-view"><i class="uk-icon-angle-down"></i> '.$L->g('General').'</h2></li>';
echo '<li id="sidebar-general-view" class="sidebar-view">';
// Category
HTML::formSelect(array(
'name'=>'category',
'label'=>$L->g('Category'),
'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$dbCategories->getAll(),
'selected'=>$_Page->category(),
'tip'=>'',
'addEmptySpace'=>true
));
// Description input
HTML::formTextarea(array(
'name'=>'description',

View File

@ -58,6 +58,17 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
echo '<li><h2 class="sidebar-button" data-view="sidebar-general-view"><i class="uk-icon-angle-down"></i> '.$L->g('General').'</h2></li>';
echo '<li id="sidebar-general-view" class="sidebar-view">';
// Category
HTML::formSelect(array(
'name'=>'category',
'label'=>$L->g('Category'),
'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$dbCategories->getAll(),
'selected'=>$_Post->category(),
'tip'=>'',
'addEmptySpace'=>true
));
// Description input
HTML::formTextarea(array(
'name'=>'description',

View File

@ -51,6 +51,17 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
echo '<li><h2 class="sidebar-button" data-view="sidebar-general-view"><i class="uk-icon-angle-down"></i> '.$L->g('General').'</h2></li>';
echo '<li id="sidebar-general-view" class="sidebar-view">';
// Category
HTML::formSelect(array(
'name'=>'category',
'label'=>$L->g('Category'),
'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$dbCategories->getAll(),
'selected'=>'',
'tip'=>'',
'addEmptySpace'=>true
));
// Description input
HTML::formTextarea(array(
'name'=>'description',

View File

@ -58,7 +58,8 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$dbCategories->getAll(),
'selected'=>'',
'tip'=>''
'tip'=>'',
'addEmptySpace'=>true
));
// Description input

View File

@ -146,18 +146,21 @@ class dbCategories extends dbJSON
// (array) $db, the $db must be sorted by date and the posts published only.
public function reIndexPosts($db)
{
$index = array();
// Clean post list
foreach( $this->db as $key=>$value ) {
$this->db[$key]['posts'] = array();
}
// Foreach post in the database
foreach($db as $postKey=>$postData) {
if( !empty($postData['category']) && $this->exists($postData['category']) ) {
if( !empty($postData['category']) ) {
$categoryKey = $postData['category'];
array_push($index, $postKey);
if( isset($this->db[$categoryKey]['posts']) ) {
array_push($this->db[$categoryKey]['posts'], $postKey);
}
}
}
$this->db[$categoryKey]['posts'] = $index;
return $this->save();
}
@ -165,17 +168,20 @@ class dbCategories extends dbJSON
// (array) $db, the $db must be sorted by date and the posts published only.
public function reIndexPages($db)
{
$index = array();
// Foreach page in the database
foreach($db as $pageKey=>$pageData) {
if( !empty($pageData['category']) && $this->exists($pageData['category']) ) {
$categoryKey = $pageData['category'];
array_push($index, $pageKey);
}
// Clean post list
foreach( $this->db as $key=>$value ) {
$this->db[$key]['pages'] = array();
}
$this->db[$categoryKey]['pages'] = $index;
// Foreach post in the database
foreach($db as $postKey=>$postData) {
if( !empty($postData['category']) ) {
$categoryKey = $postData['category'];
if( isset($this->db[$categoryKey]['pages']) ) {
array_push($this->db[$categoryKey]['pages'], $postKey);
}
}
}
return $this->save();
}

View File

@ -14,7 +14,8 @@ class dbPages extends dbJSON
'date'=> array('inFile'=>false, 'value'=>''),
'dateModified'=> array('inFile'=>false, 'value'=>''),
'position'=> array('inFile'=>false, 'value'=>0),
'coverImage'=> array('inFile'=>false, 'value'=>'')
'coverImage'=> array('inFile'=>false, 'value'=>''),
'category'=> array('inFile'=>false, 'value'=>'')
);
function __construct()

View File

@ -138,6 +138,17 @@ function sortPages($a, $b)
return ($a['position'] < $b['position']) ? -1 : 1;
}
function reIndexCategoriesPages()
{
global $dbPages;
global $dbCategories;
// Regenerate the tags index for posts.
$dbCategories->reindexPages( $dbPages->db );;
return true;
}
function buildPage($key)
{
global $dbPages;

View File

@ -1,6 +1,5 @@
<?php
class pluginAPI extends Plugin {
public function init()
@ -22,13 +21,6 @@ class pluginAPI extends Plugin {
{
$html = '';
$html .= '<div>';
$html .= '<input type="hidden" name="ping" value="0">';
$html .= '<input name="ping" id="jsping" type="checkbox" value="1" '.($this->getDbField('ping')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsping">Ping Bludit.com</label>';
$html .= '<div class="tip">Enable this feature to share your posts and pages with Bludit.com.</div>';
$html .= '</div>';
$html .= '<div>';
$html .= '<p><b>Authorization Key:</b> '.$this->getDbField('token').'</p>';
$html .= '<div class="tip">This key is private, do not share it with anyone.</div>';
@ -57,22 +49,10 @@ class pluginAPI extends Plugin {
return $html;
}
public function install($position=0)
{
parent::install($position);
$this->ping();
}
// API HOOKS
// ----------------------------------------------------------------------------
public function afterFormSave()
{
$this->ping();
}
public function beforeRulesLoad()
{
global $Url;
@ -128,9 +108,9 @@ class pluginAPI extends Plugin {
// PARAMETERS
// ------------------------------------------------------------
// /api/posts | GET | returns all posts
// /api/posts/{slug} | GET | returns the post with the {slug}
// /api/posts/{key} | GET | returns the post with the {key}
// /api/pages | GET | returns all pages
// /api/pages/{slug} | GET | returns the page with the {slug}
// /api/pages/{key} | GET | returns the page with the {key}
// /api/cli/regenerate | POST | check for new posts and pages
$parameters = explode('/', $URI);
@ -167,12 +147,12 @@ class pluginAPI extends Plugin {
$data = $this->getAllPages();
$this->response($data);
}
// /api/posts/{slug}
// /api/posts/{key}
elseif( ($method==='GET') && ($parameters[0]==='posts') && !empty($parameters[1]) ) {
$data = $this->getPost($parameters[1]);
$this->response($data);
}
// /api/pages/{slug}
// /api/pages/{key}
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
$data = $this->getPage($parameters[1]);
$this->response($data);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
This version of SimpleMDE have a little changes for Bludit.
--- Image preview hack ---
Original
<img src="'+e+'"
Bludit hack
<img src="'+HTML_PATH_UPLOADS+e+'"

15
bl-plugins/quill/js/simplemde.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
{
"plugin-data":
{
"name": "Quill",
"description": ""
}
}

View File

@ -0,0 +1,10 @@
{
"author": "NextStepWebs",
"email": "",
"website": "https://github.com/NextStepWebs/simplemde-markdown-editor",
"version": "1.11.2",
"releaseDate": "2016-06-14",
"license": "MIT",
"compatible": "1.5.2",
"notes": ""
}

View File

@ -0,0 +1,87 @@
<?php
class pluginQuill extends Plugin {
private $loadWhenController = array(
'new-post',
'new-page',
'edit-post',
'edit-page'
);
public function init()
{
$this->dbFields = array(
'tabSize'=>'2',
'toolbar'=>'"bold", "italic", "heading", "|", "quote", "unordered-list", "|", "link", "image", "code", "horizontal-rule", "|", "preview", "side-by-side", "fullscreen", "guide"',
'autosave'=>0,
'spellChecker'=>0
);
}
// Returns true if the plugins is loaded on the controller defined
private function enabled()
{
global $layout;
return in_array($layout['controller'], $this->loadWhenController);
}
public function adminHead()
{
$html = '';
if( $this->enabled() ) {
$html .= '<link href="https://cdn.quilljs.com/1.2.4/quill.snow.css" rel="stylesheet">';
$html .= '<script src="https://cdn.quilljs.com/1.2.4/quill.js"></script>';
}
return $html;
}
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>'.$Language->get('Toolbar').'</label>';
$html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getDbField('toolbar').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Tab size').'</label>';
$html .= '<input name="tabSize" id="jstabSize" type="text" value="'.$this->getDbField('tabSize').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="autosave" value="0">';
$html .= '<input name="autosave" id="jsautosave" type="checkbox" value="1" '.($this->getDbField('autosave')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsautosave">'.$Language->get('Autosave').'</label>';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="spellChecker" value="0">';
$html .= '<input name="spellChecker" id="jsspellChecker" type="checkbox" value="1" '.($this->getDbField('spellChecker')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsspellChecker">'.$Language->get('spell-checker').'</label>';
$html .= '</div>';
return $html;
}
public function adminBodyEnd()
{
global $layout;
global $Language;
$html = '';
if( $this->enabled() ) {
$html .= '
<script>
var quill = new Quill("#jscontent", {
theme: "snow"
});
</script>
';
}
return $html;
}
}

View File

@ -417,6 +417,10 @@ function install($adminPassword, $email, $timezone)
file_put_contents(PATH_DATABASES.'security.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
// File categories.php
$data = array();
file_put_contents(PATH_DATABASES.'categories.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
// File tags.php
file_put_contents(
PATH_DATABASES.'tags.php',