diff --git a/.htaccess b/.htaccess index e85ab7b5..caea0515 100644 --- a/.htaccess +++ b/.htaccess @@ -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] \ No newline at end of file diff --git a/admin/controllers/edit-page.php b/admin/controllers/edit-page.php index 9711c638..960d028c 100644 --- a/admin/controllers/edit-page.php +++ b/admin/controllers/edit-page.php @@ -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 { diff --git a/admin/views/edit-page.php b/admin/views/edit-page.php index 2d48202d..59d03513 100644 --- a/admin/views/edit-page.php +++ b/admin/views/edit-page.php @@ -53,7 +53,7 @@ Friendly url - url() ?> + url() ?>parentKey()?$_Page->parentKey().'/':''; ?> Short text no more than 150 characters. Special characters not allowed. diff --git a/admin/views/manage-posts.php b/admin/views/manage-posts.php index d01e3af7..18d17298 100644 --- a/admin/views/manage-posts.php +++ b/admin/views/manage-posts.php @@ -17,7 +17,7 @@ { echo ''; echo ''.($Post->published()?'':'[DRAFT] ').($Post->title()?$Post->title():'[Empty title] ').''; - echo ''.$Post->date().''; + echo ''.$Post->dateCreated().''; echo ''.$Post->timeago().''; echo ''; } diff --git a/admin/views/settings.php b/admin/views/settings.php index f64eb3e0..0a5ea7bc 100644 --- a/admin/views/settings.php +++ b/admin/views/settings.php @@ -21,6 +21,12 @@ Small and concise description of the field ??? + + Site slogan + + Small and concise description of the field ??? + + Site description diff --git a/install.php b/install.php index 5a87ef24..9ea95b4e 100644 --- a/install.php +++ b/install.php @@ -5,7 +5,8 @@ define('BLUDIT', true); // PATHs define('PATH_ROOT', __DIR__.'/'); define('PATH_CONTENT', PATH_ROOT.'content/'); -define('PATH_POSTS', PATH_CONTENT.'posts/'); +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'; @@ -103,8 +111,14 @@ function install($adminPassword, $email) if(!mkdir(PATH_PLUGINS_DATABASES, $dirpermissions, true)) { - $errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES; - error_log($errorText, 0); + $errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES; + error_log($errorText, 0); + } + + if(!mkdir(PATH_UPLOADS, $dirpermissions, true)) + { + $errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS; + error_log($errorText, 0); } // ============================================================================ @@ -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', diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 6f0a7bf9..396df9dc 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -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/'); diff --git a/kernel/boot/rules/70.build_posts.php b/kernel/boot/rules/70.build_posts.php index 5b4dc5e2..0b9d297e 100644 --- a/kernel/boot/rules/70.build_posts.php +++ b/kernel/boot/rules/70.build_posts.php @@ -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); } diff --git a/kernel/dbpages.class.php b/kernel/dbpages.class.php index 45362a0a..f8c30c6b 100644 --- a/kernel/dbpages.class.php +++ b/kernel/dbpages.class.php @@ -248,19 +248,18 @@ class dbPages extends dbJSON $newKey = helperText::cleanUrl($parent).'/'.helperText::cleanUrl($text); } - if($newKey===$oldKey) { - return $newKey; - } - - // Verify if the key is already been used. - if( isset($this->db[$newKey]) ) + if($newKey!==$oldKey) { - if( !helperText::endsWithNumeric($newKey) ) { - $newKey = $newKey.'-0'; - } + // Verify if the key is already been used. + if( isset($this->db[$newKey]) ) + { + if( !helperText::endsWithNumeric($newKey) ) { + $newKey = $newKey.'-0'; + } - while( isset($this->db[$newKey]) ) { - $newKey++; + while( isset($this->db[$newKey]) ) { + $newKey++; + } } } diff --git a/kernel/dbsite.class.php b/kernel/dbsite.class.php index 4fe60a82..e6ac7d37 100644 --- a/kernel/dbsite.class.php +++ b/kernel/dbsite.class.php @@ -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') { diff --git a/kernel/page.class.php b/kernel/page.class.php index 5ee72dc0..c3ea73ab 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -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,15 +59,26 @@ class Page extends fileContent } // Returns the post date according to locale settings and format settings. - public function date($format = false) + public function dateCreated($format=false) { - if($format!==false) - { - $unixTimeCreated = $this->unixTimeCreated(); - return Date::format($unixTimeCreated, $format); + if($format===false) { + return $this->getField('date'); } - 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 diff --git a/kernel/post.class.php b/kernel/post.class.php index f299c23a..461e3f4d 100644 --- a/kernel/post.class.php +++ b/kernel/post.class.php @@ -62,15 +62,26 @@ class Post extends fileContent return $this->getField('unixTimeModified'); } - public function date($format = false) + public function dateCreated($format=false) { - if($format!==false) - { - $unixTimeCreated = $this->unixTimeCreated(); - return Date::format($unixTimeCreated, $format); + if($format===false) { + return $this->getField('date'); } - 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() diff --git a/themes/pure/css/blog.css b/themes/pure/css/blog.css index 7d5bd64f..c400a9bc 100644 --- a/themes/pure/css/blog.css +++ b/themes/pure/css/blog.css @@ -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; } diff --git a/themes/pure/php/footer.php b/themes/pure/php/footer.php index e129f1db..cdf4ae65 100644 --- a/themes/pure/php/footer.php +++ b/themes/pure/php/footer.php @@ -1,3 +1,3 @@ footer(); ?> - + \ No newline at end of file diff --git a/themes/pure/php/head.php b/themes/pure/php/head.php index 8b975df8..436744ba 100644 --- a/themes/pure/php/head.php +++ b/themes/pure/php/head.php @@ -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' ), ''); // @@ -32,11 +31,11 @@ ?> + diff --git a/themes/pure/php/page.php b/themes/pure/php/page.php index 1a1945db..52302df8 100644 --- a/themes/pure/php/page.php +++ b/themes/pure/php/page.php @@ -1,11 +1,11 @@ - title() ?> + # title() ?> content() ?> - + \ No newline at end of file diff --git a/themes/pure/php/post.php b/themes/pure/php/post.php index 6abcefa0..6c5d9ae4 100644 --- a/themes/pure/php/post.php +++ b/themes/pure/php/post.php @@ -15,4 +15,4 @@ content() ?> - + \ No newline at end of file diff --git a/themes/pure/php/sidebar.php b/themes/pure/php/sidebar.php index d03c1f65..af648f04 100644 --- a/themes/pure/php/sidebar.php +++ b/themes/pure/php/sidebar.php @@ -1,33 +1,39 @@ -Bludit -cms -Simple and fast content management system, create a site in 1 minute. Created by Diego Najar @dignajar +title() ?> +slogan() ?> +description() ?> '; echo 'Home'; echo ' | '; echo 'Twitter'; echo ''; -// PAGES +// Pages +$parents = $pagesParents[NO_PARENT_CHAR]; - - -unset($pagesParents[NO_PARENT_CHAR]); -foreach($pagesParents as $parentKey=>$pageList) +foreach($parents as $parent) { - echo ''.$pages[$parentKey]->title().''; + // Print the parent + echo ''.$parent->title().''; - echo ''; - foreach($pageList as $tmpPage) + // Check if the parent hash children + if(isset($pagesParents[$parent->key()])) { - echo ''.$tmpPage->title().''; + $children = $pagesParents[$parent->key()]; + + // Print the children + echo ''; + foreach($children as $child) + { + echo ''.$child->title().''; + } + echo ''; } - echo ''; } ?>
footer(); ?>
Simple and fast content management system, create a site in 1 minute. Created by Diego Najar @dignajar
description() ?>