New features

This commit is contained in:
Diego Najar 2015-05-18 23:22:05 +00:00
parent d8fc681b3c
commit 394468a845
18 changed files with 151 additions and 57 deletions

View File

@ -1,10 +1,14 @@
AddDefaultCharset UTF-8
RewriteEngine on
# Remove the trailing slash from URL
DirectorySlash Off
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
# Enable rewrite rules
RewriteEngine on
# Deny direct access to .txt files
RewriteRule ^content/(.*)\.txt$ - [R=404,L]
# All URL process by index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php [L]

View File

@ -26,7 +26,7 @@ function editPage($args)
$dbPages->regenerate();
Alert::set('The page has been saved successfully');
Redirect::page('admin', 'manage-pages');
Redirect::page('admin', 'edit-page/'.$args['key']);
}
else
{

View File

@ -53,7 +53,7 @@
<label>
Friendly url
<div class="input-groups width-50">
<span class="input-prepend"><?php echo $Site->url() ?><span id="parentExample"></span></span>
<span class="input-prepend"><?php echo $Site->url() ?><span id="parentExample"><?php echo $_Page->parentKey()?$_Page->parentKey().'/':''; ?></span></span>
<input id="slug" type="text" name="slug" value="<?php echo $_Page->slug() ?>">
</div>
<span class="forms-desc">Short text no more than 150 characters. Special characters not allowed.</span>

View File

@ -17,7 +17,7 @@
{
echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->published()?'':'[DRAFT] ').($Post->title()?$Post->title():'[Empty title] ').'</a></td>';
echo '<td>'.$Post->date().'</td>';
echo '<td>'.$Post->dateCreated().'</td>';
echo '<td>'.$Post->timeago().'</td>';
echo '</tr>';
}

View File

@ -21,6 +21,12 @@
<div class="forms-desc">Small and concise description of the field ???</div>
</label>
<label>
Site slogan
<input type="text" name="slogan" class="width-50" value="<?php echo $Site->slogan() ?>">
<div class="forms-desc">Small and concise description of the field ???</div>
</label>
<label>
Site description
<input type="text" name="description" class="width-50" value="<?php echo $Site->description() ?>">

View File

@ -6,6 +6,7 @@ define('BLUDIT', true);
define('PATH_ROOT', __DIR__.'/');
define('PATH_CONTENT', PATH_ROOT.'content/');
define('PATH_POSTS', PATH_CONTENT.'posts/');
define('PATH_UPLOADS', PATH_CONTENT.'uploads/');
define('PATH_PAGES', PATH_CONTENT.'pages/');
define('PATH_DATABASES', PATH_CONTENT.'databases/');
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases/plugins/');
@ -44,6 +45,13 @@ function checkSystem()
$phpModules = get_loaded_extensions();
}
if(!file_exists(PATH_ROOT.'.htaccess'))
{
$errorText = 'Missing file, upload the file .htaccess';
error_log($errorText, 0);
array_push($stdOut, $errorText);
}
if(!version_compare(phpversion(), '5.2', '>'))
{
$errorText = 'Current PHP version '.phpversion().', but you need > 5.3';
@ -107,6 +115,12 @@ function install($adminPassword, $email)
error_log($errorText, 0);
}
if(!mkdir(PATH_UPLOADS, $dirpermissions, true))
{
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS;
error_log($errorText, 0);
}
// ============================================================================
// Create files
// ============================================================================
@ -144,7 +158,8 @@ function install($adminPassword, $email)
// File site.php
$data = array(
'title'=>'Bludit CMS',
'title'=>'Bludit',
'slogan'=>'cms',
'description'=>'',
'footer'=>'Footer text - ©2015',
'language'=>'english',

View File

@ -17,6 +17,7 @@ define('PATH_POSTS', PATH_CONTENT.'posts/');
define('PATH_PAGES', PATH_CONTENT.'pages/');
define('PATH_DATABASES', PATH_CONTENT.'databases/');
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases/plugins/');
define('PATH_UPLOADS', PATH_CONTENT.'uploads/');
define('PATH_ADMIN_THEMES', PATH_ROOT.'admin/themes/');
define('PATH_ADMIN_CONTROLLERS', PATH_ROOT.'admin/controllers/');

View File

@ -11,12 +11,14 @@ function buildPost($key)
// Post object.
$Post = new Post($key);
if( !$Post->isValid() ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from file with key'.$key);
return false;
}
// Page database.
$db = $dbPosts->getDb($key);
if( !$db ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from database with key'.$key);
return false;
}
@ -64,7 +66,7 @@ function build_posts_per_page($pageNumber=0, $amount=5, $draftPosts=false)
$list = $dbPosts->getPage($pageNumber, $amount, $draftPosts);
// There are not post for the pageNumber then NotFound page
if(empty($list)) {
if(empty($list) && $pageNumber>0) {
$Url->setNotFound(true);
}

View File

@ -248,10 +248,8 @@ class dbPages extends dbJSON
$newKey = helperText::cleanUrl($parent).'/'.helperText::cleanUrl($text);
}
if($newKey===$oldKey) {
return $newKey;
}
if($newKey!==$oldKey)
{
// Verify if the key is already been used.
if( isset($this->db[$newKey]) )
{
@ -263,6 +261,7 @@ class dbPages extends dbJSON
$newKey++;
}
}
}
if($returnSlug)
{

View File

@ -4,6 +4,7 @@ class dbSite extends dbJSON
{
private $dbFields = array(
'title'=> array('inFile'=>false, 'value'=>''),
'slogan'=> array('inFile'=>false, 'value'=>''),
'description'=> array('inFile'=>false, 'value'=>''),
'footer'=> array('inFile'=>false, 'value'=>''),
'postsperpage'=>array('inFile'=>false, 'value'=>''),
@ -90,6 +91,12 @@ class dbSite extends dbJSON
return $this->db['title'];
}
// Returns the site slogan.
public function slogan()
{
return $this->db['slogan'];
}
public function advancedOptions()
{
if($this->db['advancedOptions']==='true') {

View File

@ -36,6 +36,12 @@ class Page extends fileContent
return $this->getField('tags');
}
public function tagsArray()
{
$tags = $this->getField('tags');
return explode(',', $tags);
}
public function position()
{
return $this->getField('position');
@ -53,17 +59,28 @@ class Page extends fileContent
}
// Returns the post date according to locale settings and format settings.
public function date($format = false)
{
if($format!==false)
public function dateCreated($format=false)
{
if($format===false) {
return $this->getField('date');
}
$unixTimeCreated = $this->unixTimeCreated();
return Date::format($unixTimeCreated, $format);
}
public function dateModified($format=false)
{
if($format===false) {
return $this->getField('date');
}
$unixTimeModified = $this->unixTimeModified();
return Date::format($unixTimeModified, $format);
}
// Returns the time ago
public function timeago()
{

View File

@ -62,17 +62,28 @@ class Post extends fileContent
return $this->getField('unixTimeModified');
}
public function date($format = false)
{
if($format!==false)
public function dateCreated($format=false)
{
if($format===false) {
return $this->getField('date');
}
$unixTimeCreated = $this->unixTimeCreated();
return Date::format($unixTimeCreated, $format);
}
public function dateModified($format=false)
{
if($format===false) {
return $this->getField('date');
}
$unixTimeModified = $this->unixTimeModified();
return Date::format($unixTimeModified, $format);
}
public function timeago()
{
return $this->getField('timeago');

View File

@ -22,6 +22,33 @@ p {
margin: 10px 0 0 0;
}
img {
display: block;
max-width: 100%;
}
table {
empty-cells: show;
border: 1px solid #cbcbcb;
}
thead {
background-color: #e0e0e0;
color: #000;
text-align: left;
vertical-align: bottom;
}
tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
th, td {
padding: 0.5em 1em;
}
#layout {
padding: 0;
}

View File

@ -21,8 +21,7 @@
));
Theme::css(array(
'http://fonts.googleapis.com/css?family=Open+Sans:400,300,600&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,cyrillic,latin-ext',
'http://fonts.googleapis.com/css?family=Muli:400,300'
'http://fonts.googleapis.com/css?family=Open+Sans:400,300,600&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,cyrillic,latin-ext'
), '');
// <script src="rainbow.min.js"></script>
@ -32,10 +31,10 @@
?>
<!-- Pure and Google Fonts -->
<style>
html, button, input, select, textarea,
.pure-g [class *= "pure-u"] {
/* Set your content font stack here: */
font-family: 'Open Sans', sans-serif;
}
</style>

View File

@ -1,7 +1,7 @@
<section class="page">
<header class="page-head">
<h1 class="page-title">
<?php echo $Page->title() ?>
# <?php echo $Page->title() ?>
</h1>
</header>

View File

@ -1,34 +1,40 @@
<div class="header">
<h1>Bludit</h1>
<h2>cms</h2>
<p class="about">Simple and fast content management system, create a site in 1 minute. Created by Diego Najar @dignajar</p>
<h1><?php echo $Site->title() ?></h1>
<h2><?php echo $Site->slogan() ?></h2>
<p class="about"><?php echo $Site->description() ?></p>
<?php
// POSTS
// Links
echo '<div class="links">';
echo '<a class="homelink" href="'.HTML_PATH_ROOT.'">Home</a>';
echo '<span> | </span>';
echo '<a class="homelink" href="'.HTML_PATH_ROOT.'">Twitter</a>';
echo '</div>';
// PAGES
// Pages
$parents = $pagesParents[NO_PARENT_CHAR];
unset($pagesParents[NO_PARENT_CHAR]);
foreach($pagesParents as $parentKey=>$pageList)
foreach($parents as $parent)
{
echo '<a class="parent" href="'.HTML_PATH_ROOT.$parentKey.'">'.$pages[$parentKey]->title().'</a>';
// Print the parent
echo '<a class="parent" href="'.HTML_PATH_ROOT.$parent->key().'">'.$parent->title().'</a>';
// Check if the parent hash children
if(isset($pagesParents[$parent->key()]))
{
$children = $pagesParents[$parent->key()];
// Print the children
echo '<ul>';
foreach($pageList as $tmpPage)
foreach($children as $child)
{
echo '<li><a class="children" href="'.HTML_PATH_ROOT.$tmpPage->key().'">'.$tmpPage->title().'</a></li>';
echo '<li><a class="children" href="'.HTML_PATH_ROOT.$child->key().'">'.$child->title().'</a></li>';
}
echo '</ul>';
}
}
?>