Bug fixes
This commit is contained in:
parent
d1c88a6fdb
commit
19ef56301e
|
@ -136,6 +136,12 @@ class Content {
|
||||||
return $this->getField('readMore');
|
return $this->getField('readMore');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
return $this->getField('category');
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the field key
|
// Returns the field key
|
||||||
public function key()
|
public function key()
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,9 @@ function editPage($args)
|
||||||
{
|
{
|
||||||
$dbPages->regenerateCli();
|
$dbPages->regenerateCli();
|
||||||
|
|
||||||
|
// Re index categories
|
||||||
|
reIndexCategoriesPages();
|
||||||
|
|
||||||
// Call the plugins after page created.
|
// Call the plugins after page created.
|
||||||
Theme::plugins('afterPageModify');
|
Theme::plugins('afterPageModify');
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ function editPost($args)
|
||||||
// Reindex tags, this function is in 70.posts.php
|
// Reindex tags, this function is in 70.posts.php
|
||||||
reIndexTagsPosts();
|
reIndexTagsPosts();
|
||||||
|
|
||||||
|
// Re index categories
|
||||||
|
reIndexCategoriesPosts();
|
||||||
|
|
||||||
// Call the plugins after post created.
|
// Call the plugins after post created.
|
||||||
Theme::plugins('afterPostModify');
|
Theme::plugins('afterPostModify');
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ function addPage($args)
|
||||||
|
|
||||||
if($key)
|
if($key)
|
||||||
{
|
{
|
||||||
|
// Re index categories
|
||||||
|
reIndexCategoriesPages();
|
||||||
|
|
||||||
// Call the plugins after page created.
|
// Call the plugins after page created.
|
||||||
Theme::plugins('afterPageCreate');
|
Theme::plugins('afterPageCreate');
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,9 @@ class HTML {
|
||||||
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
|
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
|
||||||
$html .= '<div class="uk-form-controls">';
|
$html .= '<div class="uk-form-controls">';
|
||||||
$html .= '<select id="'.$id.'" name="'.$args['name'].'" '.$class.'>';
|
$html .= '<select id="'.$id.'" name="'.$args['name'].'" '.$class.'>';
|
||||||
|
if(isset($args['addEmptySpace'])) {
|
||||||
|
$html .= '<option value=""></option>';
|
||||||
|
}
|
||||||
foreach($args['options'] as $key=>$value) {
|
foreach($args['options'] as $key=>$value) {
|
||||||
$html .= '<option value="'.$key.'"'.( ($args['selected']==$key)?' selected="selected"':'').'>'.$value.'</option>';
|
$html .= '<option value="'.$key.'"'.( ($args['selected']==$key)?' selected="selected"':'').'>'.$value.'</option>';
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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><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">';
|
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
|
// Description input
|
||||||
HTML::formTextarea(array(
|
HTML::formTextarea(array(
|
||||||
'name'=>'description',
|
'name'=>'description',
|
||||||
|
|
|
@ -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><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">';
|
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
|
// Description input
|
||||||
HTML::formTextarea(array(
|
HTML::formTextarea(array(
|
||||||
'name'=>'description',
|
'name'=>'description',
|
||||||
|
|
|
@ -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><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">';
|
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
|
// Description input
|
||||||
HTML::formTextarea(array(
|
HTML::formTextarea(array(
|
||||||
'name'=>'description',
|
'name'=>'description',
|
||||||
|
|
|
@ -58,7 +58,8 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
'class'=>'uk-width-1-1 uk-form-medium',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'options'=>$dbCategories->getAll(),
|
'options'=>$dbCategories->getAll(),
|
||||||
'selected'=>'',
|
'selected'=>'',
|
||||||
'tip'=>''
|
'tip'=>'',
|
||||||
|
'addEmptySpace'=>true
|
||||||
));
|
));
|
||||||
|
|
||||||
// Description input
|
// Description input
|
||||||
|
|
|
@ -146,17 +146,20 @@ class dbCategories extends dbJSON
|
||||||
// (array) $db, the $db must be sorted by date and the posts published only.
|
// (array) $db, the $db must be sorted by date and the posts published only.
|
||||||
public function reIndexPosts($db)
|
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 post in the database
|
||||||
foreach($db as $postKey=>$postData) {
|
foreach($db as $postKey=>$postData) {
|
||||||
if( !empty($postData['category']) && $this->exists($postData['category']) ) {
|
if( !empty($postData['category']) ) {
|
||||||
$categoryKey = $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();
|
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.
|
// (array) $db, the $db must be sorted by date and the posts published only.
|
||||||
public function reIndexPages($db)
|
public function reIndexPages($db)
|
||||||
{
|
{
|
||||||
$index = array();
|
// Clean post list
|
||||||
|
foreach( $this->db as $key=>$value ) {
|
||||||
// Foreach page in the database
|
$this->db[$key]['pages'] = array();
|
||||||
foreach($db as $pageKey=>$pageData) {
|
|
||||||
if( !empty($pageData['category']) && $this->exists($pageData['category']) ) {
|
|
||||||
$categoryKey = $pageData['category'];
|
|
||||||
array_push($index, $pageKey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$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();
|
return $this->save();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ class dbPages extends dbJSON
|
||||||
'date'=> array('inFile'=>false, 'value'=>''),
|
'date'=> array('inFile'=>false, 'value'=>''),
|
||||||
'dateModified'=> array('inFile'=>false, 'value'=>''),
|
'dateModified'=> array('inFile'=>false, 'value'=>''),
|
||||||
'position'=> array('inFile'=>false, 'value'=>0),
|
'position'=> array('inFile'=>false, 'value'=>0),
|
||||||
'coverImage'=> array('inFile'=>false, 'value'=>'')
|
'coverImage'=> array('inFile'=>false, 'value'=>''),
|
||||||
|
'category'=> array('inFile'=>false, 'value'=>'')
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
|
|
|
@ -138,6 +138,17 @@ function sortPages($a, $b)
|
||||||
return ($a['position'] < $b['position']) ? -1 : 1;
|
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)
|
function buildPage($key)
|
||||||
{
|
{
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class pluginAPI extends Plugin {
|
class pluginAPI extends Plugin {
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
|
@ -22,13 +21,6 @@ class pluginAPI extends Plugin {
|
||||||
{
|
{
|
||||||
$html = '';
|
$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 .= '<div>';
|
||||||
$html .= '<p><b>Authorization Key:</b> '.$this->getDbField('token').'</p>';
|
$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>';
|
$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;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install($position=0)
|
|
||||||
{
|
|
||||||
parent::install($position);
|
|
||||||
|
|
||||||
$this->ping();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// API HOOKS
|
// API HOOKS
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
public function afterFormSave()
|
|
||||||
{
|
|
||||||
$this->ping();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function beforeRulesLoad()
|
public function beforeRulesLoad()
|
||||||
{
|
{
|
||||||
global $Url;
|
global $Url;
|
||||||
|
@ -128,9 +108,9 @@ class pluginAPI extends Plugin {
|
||||||
// PARAMETERS
|
// PARAMETERS
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// /api/posts | GET | returns all posts
|
// /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 | 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
|
// /api/cli/regenerate | POST | check for new posts and pages
|
||||||
|
|
||||||
$parameters = explode('/', $URI);
|
$parameters = explode('/', $URI);
|
||||||
|
@ -167,12 +147,12 @@ class pluginAPI extends Plugin {
|
||||||
$data = $this->getAllPages();
|
$data = $this->getAllPages();
|
||||||
$this->response($data);
|
$this->response($data);
|
||||||
}
|
}
|
||||||
// /api/posts/{slug}
|
// /api/posts/{key}
|
||||||
elseif( ($method==='GET') && ($parameters[0]==='posts') && !empty($parameters[1]) ) {
|
elseif( ($method==='GET') && ($parameters[0]==='posts') && !empty($parameters[1]) ) {
|
||||||
$data = $this->getPost($parameters[1]);
|
$data = $this->getPost($parameters[1]);
|
||||||
$this->response($data);
|
$this->response($data);
|
||||||
}
|
}
|
||||||
// /api/pages/{slug}
|
// /api/pages/{key}
|
||||||
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
|
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
|
||||||
$data = $this->getPage($parameters[1]);
|
$data = $this->getPage($parameters[1]);
|
||||||
$this->response($data);
|
$this->response($data);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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+'"
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Quill",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
|
@ -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": ""
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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_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 tags.php
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
PATH_DATABASES.'tags.php',
|
PATH_DATABASES.'tags.php',
|
||||||
|
|
Loading…
Reference in New Issue