This commit is contained in:
dignajar 2016-05-07 00:10:10 -03:00
parent 8f8121e360
commit 5f37660496
10 changed files with 40 additions and 46 deletions

View File

@ -1,6 +0,0 @@
# Bludit
Set the correct permissions on this directory.
Documentation:
- http://docs.bludit.com/en/troubleshooting/writing-test-failure-err205

View File

@ -37,17 +37,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'tip'=>$L->g('the-url-of-your-site') 'tip'=>$L->g('the-url-of-your-site')
)); ));
HTML::legend(array('value'=>$L->g('Command Line Mode')));
HTML::formSelect(array(
'name'=>'cliMode',
'label'=>$L->g('Cli Mode'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>$Site->cliMode(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('enable-the-command-line-mode-if-you-add-edit')
));
HTML::legend(array('value'=>$L->g('Email account settings'))); HTML::legend(array('value'=>$L->g('Email account settings')));
HTML::formInputText(array( HTML::formInputText(array(

View File

@ -85,6 +85,9 @@ define('POSTS_PER_PAGE_ADMIN', 10);
// Check if JSON encode and decode are enabled. // Check if JSON encode and decode are enabled.
// define('JSON', function_exists('json_encode')); // define('JSON', function_exists('json_encode'));
// Cli mode status for new posts/pages
define('CLI_MODE', true);
// Cli mode status for new posts/pages // Cli mode status for new posts/pages
define('CLI_STATUS', 'published'); define('CLI_STATUS', 'published');

View File

@ -62,8 +62,12 @@ function buildPlugins()
// Load each plugin clasess // Load each plugin clasess
foreach($list as $pluginPath) { foreach($list as $pluginPath) {
// Check if the directory has the plugin.php
if(file_exists($pluginPath.DS.'plugin.php')) {
include($pluginPath.DS.'plugin.php'); include($pluginPath.DS.'plugin.php');
} }
}
// Get plugins clasess loaded // Get plugins clasess loaded
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess); $pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);

View File

@ -123,7 +123,7 @@ function buildPostsForPage($pageNumber=0, $amount=POSTS_PER_PAGE_ADMIN, $removeU
// ============================================================================ // ============================================================================
// Search for changes on posts by the user. // Search for changes on posts by the user.
if( $Site->cliMode() ) { if( CLI_MODE ) {
if($dbPosts->regenerateCli()) { if($dbPosts->regenerateCli()) {
reIndexTagsPosts(); reIndexTagsPosts();
} }

View File

@ -146,7 +146,7 @@ function buildAllPages()
// ============================================================================ // ============================================================================
// Search for changes on pages by the user. // Search for changes on pages by the user.
if( $Site->cliMode() ) { if( CLI_MODE ) {
$dbPages->regenerateCli(); $dbPages->regenerateCli();
} }

View File

@ -9,7 +9,7 @@ class dbPosts extends dbJSON
'username'=> array('inFile'=>false, 'value'=>''), 'username'=> array('inFile'=>false, 'value'=>''),
'status'=> array('inFile'=>false, 'value'=>'draft'), // published, draft, scheduled 'status'=> array('inFile'=>false, 'value'=>'draft'), // published, draft, scheduled
'tags'=> array('inFile'=>false, 'value'=>array()), 'tags'=> array('inFile'=>false, 'value'=>array()),
'allowComments'=> array('inFile'=>false, 'value'=>false), 'allowComments'=> array('inFile'=>false, 'value'=>0),
'date'=> array('inFile'=>false, 'value'=>''), 'date'=> array('inFile'=>false, 'value'=>''),
'coverImage'=> array('inFile'=>false, 'value'=>''), 'coverImage'=> array('inFile'=>false, 'value'=>''),
'checksum'=> array('inFile'=>false, 'value'=>'') 'checksum'=> array('inFile'=>false, 'value'=>'')
@ -111,7 +111,7 @@ class dbPosts extends dbJSON
return false; return false;
} }
// If the date not valid, then set the current date. // If the date is not valid, then set the current date.
if(!Valid::date($args['date'], DB_DATE_FORMAT)) { if(!Valid::date($args['date'], DB_DATE_FORMAT)) {
$args['date'] = $currentDate; $args['date'] = $currentDate;
} }
@ -408,6 +408,7 @@ class dbPosts extends dbJSON
$currentDate = Date::current(DB_DATE_FORMAT); $currentDate = Date::current(DB_DATE_FORMAT);
// Generate default fields and values. // Generate default fields and values.
// --------------------------------------------------------------------------
foreach($this->dbFields as $field=>$options) { foreach($this->dbFields as $field=>$options) {
if(!$options['inFile']) { if(!$options['inFile']) {
$fields[$field] = $options['value']; $fields[$field] = $options['value'];
@ -415,25 +416,32 @@ class dbPosts extends dbJSON
} }
$fields['status'] = CLI_STATUS; $fields['status'] = CLI_STATUS;
$fields['date'] = $currentDate;
$fields['username'] = CLI_USERNAME; $fields['username'] = CLI_USERNAME;
$fields['date'] = $currentDate;
// Get all posts from the first level of directories. // Get all posts from the first level of directories.
$tmpPaths = Filesystem::listDirectories(PATH_POSTS); $postsDirectories = Filesystem::listDirectories(PATH_POSTS);
foreach($tmpPaths as $directory) foreach($postsDirectories as $directory)
{ {
// Check if the post have the index.txt file.
// Check if the post has the index.txt file.
if(Sanitize::pathFile($directory.DS.'index.txt')) if(Sanitize::pathFile($directory.DS.'index.txt'))
{ {
// The key is the directory name. // The key is the directory name.
$key = basename($directory); $key = basename($directory);
Log::set('----------------');
Log::set('CliMode - Post KEY: '.$key);
// This post exists
$allPosts[$key] = true; $allPosts[$key] = true;
// Create the new entry if not exist inside the DATABASE. // Create the new entry if not exist inside the DATABASE.
if(!isset($this->db[$key])) { if( !isset($this->db[$key]) ) {
// New entry on database with the default fields and values. // New entry on database with the default fields and values.
$this->db[$key] = $fields; $this->db[$key] = $fields;
Log::set('CliMode - New post: '.$key);
} }
// Create the post from FILE. // Create the post from FILE.
@ -442,12 +450,14 @@ class dbPosts extends dbJSON
// Update all fields from FILE to DATABASE. // Update all fields from FILE to DATABASE.
foreach($fields as $f=>$v) foreach($fields as $f=>$v)
{ {
// If the field exists on the FILE, update it. // Get the value from FILE.
if($Post->getField($f))
{
$valueFromFile = $Post->getField($f); $valueFromFile = $Post->getField($f);
Log::set(__METHOD__.LOG_SEP.'Field from file: '.$f); // If the field exists on the FILE, update it.
if( !empty($valueFromFile) )
{
Log::set('CliMode - Field to replace: '.$f);
Log::set('CliMode - value from file: '.$valueFromFile);
if($f=='tags') { if($f=='tags') {
// Generate tags array. // Generate tags array.
@ -475,6 +485,7 @@ class dbPosts extends dbJSON
// Remove orphan posts from db, the orphan posts are posts deleted by hand (directory deleted). // Remove orphan posts from db, the orphan posts are posts deleted by hand (directory deleted).
foreach( array_diff_key($db, $allPosts) as $key=>$data ) { foreach( array_diff_key($db, $allPosts) as $key=>$data ) {
unset($this->db[$key]); unset($this->db[$key]);
Log::set('CliMode - Delete post: '.$key);
} }
// Sort posts before save. // Sort posts before save.
@ -487,10 +498,11 @@ class dbPosts extends dbJSON
} }
if($this->db!=$db) { if($this->db!=$db) {
Log::set(__METHOD__.LOG_SEP.'New posts added from Cli Mode'); Log::set(__METHOD__.LOG_SEP.'There are new or deleted posts.');
return true;
} }
return $this->db!=$db; return false;
} }
} }

View File

@ -19,7 +19,6 @@ class dbSite extends dbJSON
'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'), 'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'),
'uriBlog'=> array('inFile'=>false, 'value'=>'/blog/'), 'uriBlog'=> array('inFile'=>false, 'value'=>'/blog/'),
'url'=> array('inFile'=>false, 'value'=>''), 'url'=> array('inFile'=>false, 'value'=>''),
'cliMode'=> array('inFile'=>false, 'value'=>true),
'emailFrom'=> array('inFile'=>false, 'value'=>''), 'emailFrom'=> array('inFile'=>false, 'value'=>''),
'dateFormat'=> array('inFile'=>false, 'value'=>'F j, Y'), 'dateFormat'=> array('inFile'=>false, 'value'=>'F j, Y'),
'timeFormat'=> array('inFile'=>false, 'value'=>'g:i a'), 'timeFormat'=> array('inFile'=>false, 'value'=>'g:i a'),
@ -216,12 +215,6 @@ class dbSite extends dbJSON
return $parse['scheme'].'://'.$domain; return $parse['scheme'].'://'.$domain;
} }
// Returns TRUE if the cli mode is enabled, otherwise FALSE.
public function cliMode()
{
return $this->getField('cliMode');
}
// Returns the relative home link // Returns the relative home link
public function homeLink() public function homeLink()
{ {

View File

@ -2,12 +2,12 @@
/* /*
* Bludit * Bludit
* http://www.bludit.com * https://www.bludit.com
* Author Diego Najar * Author Diego Najar
* Bludit is opensource software licensed under the MIT license. * Bludit is opensource software licensed under the MIT license.
*/ */
// Check installation // Check if Bludit is installed
if( !file_exists('bl-content/databases/site.php') ) if( !file_exists('bl-content/databases/site.php') )
{ {
header('Location:./install.php'); header('Location:./install.php');

View File

@ -372,7 +372,6 @@ function install($adminPassword, $email, $timezone)
'uriPage'=>'/', 'uriPage'=>'/',
'uriTag'=>'/tag/', 'uriTag'=>'/tag/',
'url'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT, 'url'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT,
'cliMode'=>false,
'emailFrom'=>'no-reply@'.DOMAIN 'emailFrom'=>'no-reply@'.DOMAIN
); );