Fixed installer, kernel panic theme, fixed content pages

This commit is contained in:
Diego Najar 2017-07-15 15:47:37 +02:00
parent 0676b0b768
commit cb0ddf9069
10 changed files with 103 additions and 54 deletions

View File

@ -83,7 +83,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// ============================================================================ // ============================================================================
// Main after POST // Main after POST
// ============================================================================ // ============================================================================
$allPublishedPages = buildAllpages(false); $allPublishedPages = buildAllpages(true);
// Homepage select options // Homepage select options
$homepageOptions = array(); $homepageOptions = array();

View File

@ -110,7 +110,7 @@ define('CLI_STATUS', 'published');
define('CLI_USERNAME', 'admin'); define('CLI_USERNAME', 'admin');
// Filename // Filename
define('FILENAME', 'index.md'); define('FILENAME', 'index.txt');
// Database date format // Database date format
define('DB_DATE_FORMAT', 'Y-m-d H:i:s'); define('DB_DATE_FORMAT', 'Y-m-d H:i:s');

View File

@ -100,7 +100,7 @@ if( $dbPages->scheduler() ) {
} }
// Generate pages parent tree, only published pages // Generate pages parent tree, only published pages
buildPagesByParent(false); //buildPagesByParent(true);
// Set home page is the user defined one // Set home page is the user defined one
if( $Site->homepage() && $Url->whereAmI()==='home' ) { if( $Site->homepage() && $Url->whereAmI()==='home' ) {

View File

@ -72,10 +72,9 @@ class dbPages extends dbJSON
} }
// Where the data is stored // Where the data is stored
if($options['inFile']) { if ($options['inFile']) {
$dataForFile[$field] = Text::firstCharUp($field).': '.$value; $dataForFile[$field] = $this->stylingFieldsForFile($field, $value);
} } else {
else {
// Set type // Set type
settype($value, gettype($options['value'])); settype($value, gettype($options['value']));
@ -84,7 +83,7 @@ class dbPages extends dbJSON
} }
} }
if( $climode===false ) { if ($climode===false) {
// Create the directory // Create the directory
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) { if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
@ -92,7 +91,7 @@ class dbPages extends dbJSON
} }
// Make the index.txt and save the file. // Make the index.txt and save the file.
$data = implode("\n", $dataForFile); $data = implode(PHP_EOL, $dataForFile);
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) { if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false; return false;
@ -155,11 +154,9 @@ class dbPages extends dbJSON
$value = $options['value']; $value = $options['value'];
} }
// Where the data is stored if ($options['inFile']) {
if($options['inFile']) { $dataForFile[$field] = $this->stylingFieldsForFile($field, $value);
$dataForFile[$field] = Text::firstCharUp($field).': '.$value; } else {
}
else {
// Set type // Set type
settype($value, gettype($options['value'])); settype($value, gettype($options['value']));
@ -309,7 +306,7 @@ class dbPages extends dbJSON
// Returns an array with a list of pages // Returns an array with a list of pages
// The database is sorted by date or by position // The database is sorted by date or by position
// (int) $pageNumber, the page number // (int) $pageNumber, the page number
// (int) $amountOfItems, amount of items to return // (int) $amountOfItems, amount of items to return, if -1 returns all the items
// (boolean) $onlyPublished, TRUE to return only published pages // (boolean) $onlyPublished, TRUE to return only published pages
public function getList($pageNumber, $amountOfItems, $onlyPublished=true) public function getList($pageNumber, $amountOfItems, $onlyPublished=true)
{ {
@ -322,6 +319,10 @@ class dbPages extends dbJSON
// Remove Error page from the list // Remove Error page from the list
unset($db['error']); unset($db['error']);
if($amountOfItems==-1) {
return $db;
}
// The first page number is 1, so the real is 0 // The first page number is 1, so the real is 0
$realPageNumber = $pageNumber - 1; $realPageNumber = $pageNumber - 1;
@ -583,6 +584,25 @@ class dbPages extends dbJSON
} }
} }
private function stylingFieldsForFile($field, $value)
{
// Support for Markdown files, good approach for Github
if (FILENAME==='index.md') {
if ($field==='title') {
return '#Title: '.$value;
} elseif ($field==='content') {
return '---'.PHP_EOL.$value;
} else {
return '<!-- '.Text::firstCharUp($field).': '.$value.' -->';
}
}
// Legacy style of Bludit with index.txt
if ($field==='content') {
return 'Content:'.PHP_EOL.$value;
}
return Text::firstCharUp($field).': '.$value;
}
// ----- OLD // ----- OLD

View File

@ -149,16 +149,21 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
// Generate the global variable $pagesByParent, defined on 69.pages.php // Generate the global variable $pagesByParent, defined on 69.pages.php
// (boolean) $allPages, TRUE include all status, FALSE only include published status // (boolean) $allPages, TRUE include all status, FALSE only include published status
function buildPagesByParent($allPages=true) { function buildPagesByParent($onlyPublished=true) {
global $dbPages; global $dbPages;
global $pagesByParent; global $pagesByParent;
global $pagesByParentByKey; global $pagesByParentByKey;
$keys = array_keys($dbPages->db); // Get DB
$pageNumber = 1;
$amountOfItems = -1;
$db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
// Get Keys
$keys = array_keys($db);
foreach($keys as $pageKey) { foreach($keys as $pageKey) {
$page = buildPage($pageKey); $page = buildPage($pageKey);
if($page!==false) { if($page!==false) {
if($allPages || $page->published()) {
$parentKey = $page->parentKey(); $parentKey = $page->parentKey();
// FALSE if the page is parent // FALSE if the page is parent
if($parentKey===false) { if($parentKey===false) {
@ -173,7 +178,6 @@ function buildPagesByParent($allPages=true) {
} }
} }
} }
}
} }
// Returns an Array with all pages existing on the system // Returns an Array with all pages existing on the system
@ -186,11 +190,16 @@ function buildPagesByParent($allPages=true) {
pageKeyN => Page object, pageKeyN => Page object,
) )
*/ */
function buildAllpages($allPages=true) { function buildAllpages($onlyPublished=true) {
global $dbPages; global $dbPages;
// Get DB
$pageNumber = 1;
$amountOfItems = -1;
$db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
$tmp = array(); $tmp = array();
$keys = array_keys($dbPages->db); $keys = array_keys($db);
foreach($keys as $pageKey) { foreach($keys as $pageKey) {
$page = buildPage($pageKey); $page = buildPage($pageKey);
if($page!==false) { if($page!==false) {

View File

@ -24,8 +24,8 @@ class Page {
} }
$tmp = 0; $tmp = 0;
$lines = file($filePath); $file = file($filePath);
foreach($lines as $lineNumber=>$line) { foreach($file as $lineNumber=>$line) {
// Split the line in 2 parts, limiter by : // Split the line in 2 parts, limiter by :
$parts = explode(':', $line, 2); $parts = explode(':', $line, 2);
@ -60,20 +60,15 @@ class Page {
} }
// Process the content // Process the content
if($tmp!==0) { if ($tmp!==0) {
// Next line after "Content:" or "---" // Next line after "Content:" or "---"
$tmp++; $tmp++;
// Remove lines after Content // Get all lines after "Content:" or "---"
$output = array_slice($lines, $tmp); $content = array_slice($file, $tmp);
if( !empty($parts[1]) ) { // Join lines in one variable, this is RAW content from file
array_unshift($output, "\n"); $this->vars['contentRaw'] = implode($content);
array_unshift($output, $parts[1]);
}
$implode = implode($output);
$this->vars['contentRaw'] = $implode;
} }
return true; return true;

View File

@ -9,6 +9,12 @@
"website": "" "website": ""
}, },
"installer-page-about-content": "The about page is an important and powerful tool for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information. \n Change this page's content on the admin panel, manage, pages and click on the about page.",
"installer-page-error-content": "Opps, page not found, sorry!",
"page-not-found": "Page not found",
"about-your-site-or-yourself": "About your site or yourself",
"welcome-to-bludit": "Welcome to Bludit",
"username": "Username", "username": "Username",
"password": "Password", "password": "Password",
"confirm-password": "Confirm Password", "confirm-password": "Confirm Password",
@ -215,7 +221,7 @@
"the-about-page-is-very-important": "The about page is an important and powerful tool for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information.", "the-about-page-is-very-important": "The about page is an important and powerful tool for potential clients and partners. For those who wonder who is behind the website, your About page is the first source of information.",
"change-this-pages-content-on-the-admin-panel": "Change this page's content on the admin panel, manage, pages and click on the about page.", "change-this-pages-content-on-the-admin-panel": "Change this page's content on the admin panel, manage, pages and click on the about page.",
"about-your-site-or-yourself": "About your site or yourself", "about-your-site-or-yourself": "About your site or yourself",
"welcome-to-bludit": "Welcome to Bludit",
"site-information": "Site information", "site-information": "Site information",
"date-and-time-formats": "Date and time formats", "date-and-time-formats": "Date and time formats",

View File

@ -14,11 +14,12 @@ class pluginSitemap extends Plugin {
$xml .= '<loc>'.$Site->url().'</loc>'; $xml .= '<loc>'.$Site->url().'</loc>';
$xml .= '</url>'; $xml .= '</url>';
// Get keys of pages // Get DB
$keys = $dbPages->db; $pageNumber = 1;
unset($keys['error']); $amountOfItems = -1;
$keys = array_keys($keys); $db = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
$keys = array_keys($db);
foreach($keys as $pageKey) { foreach($keys as $pageKey) {
// Create the page object from the page key // Create the page object from the page key
$page = buildPage($pageKey); $page = buildPage($pageKey);

View File

@ -32,8 +32,13 @@ div.plugin:not(:last-child) {
margin-bottom: 40px; margin-bottom: 40px;
} }
div.plugin h2.plugin-label { div.plugin > h1,h2,h3,h4 {
font-size: 1em; font-size: 1em;
}
div.plugin h2.plugin-label {
border-bottom: 1px solid #ebebeb;
padding-bottom: 5px;
text-transform: uppercase; text-transform: uppercase;
margin: 20px 0; margin: 20px 0;
} }
@ -43,6 +48,8 @@ div.plugin ul {
padding: 0; padding: 0;
} }
/* PLUGIN MENU */
div.plugin-menu li.menu:not(:last-child) { div.plugin-menu li.menu:not(:last-child) {
margin-bottom: 10px; margin-bottom: 10px;
} }
@ -50,3 +57,14 @@ div.plugin-menu li.menu:not(:last-child) {
div.plugin-menu ul.submenu { div.plugin-menu ul.submenu {
margin-left: 10px; margin-left: 10px;
} }
/* PLUGIN PAGES */
div.plugin-pages li.parent h3 {
margin-bottom: 5px;
margin-top: 10px;
}
div.plugin-pages ul.child {
margin-left: 5px;
}

View File

@ -57,7 +57,7 @@ define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
define('CHECK_SYMBOLIC_LINKS', TRUE); define('CHECK_SYMBOLIC_LINKS', TRUE);
// Filename for posts and pages // Filename for posts and pages
define('FILENAME', 'index.md'); define('FILENAME', 'index.txt');
// Domain and protocol // Domain and protocol
define('DOMAIN', $_SERVER['HTTP_HOST']); define('DOMAIN', $_SERVER['HTTP_HOST']);
@ -321,7 +321,7 @@ function install($adminPassword, $email, $timezone)
'description'=>$Language->get('About your site or yourself'), 'description'=>$Language->get('About your site or yourself'),
'username'=>'admin', 'username'=>'admin',
'tags'=>array(), 'tags'=>array(),
'status'=>'published', 'status'=>'fixed',
'date'=>$currentDate, 'date'=>$currentDate,
'dateModified'=>'', 'dateModified'=>'',
'allowComments'=>true, 'allowComments'=>true,
@ -367,7 +367,7 @@ function install($adminPassword, $email, $timezone)
'language'=>$Language->getCurrentLocale(), 'language'=>$Language->getCurrentLocale(),
'locale'=>$Language->getCurrentLocale(), 'locale'=>$Language->getCurrentLocale(),
'timezone'=>$timezone, 'timezone'=>$timezone,
'theme'=>'editorial', 'theme'=>'kernel-panic',
'adminTheme'=>'default', 'adminTheme'=>'default',
'homepage'=>'', 'homepage'=>'',
'itemsPerPage'=>6, 'itemsPerPage'=>6,
@ -497,11 +497,11 @@ function install($adminPassword, $email, $timezone)
); );
// File for error page // File for error page
$data = 'Title: '.$Language->get('Error').PHP_EOL.'Content: '.$Language->get('The page has not been found'); $data = 'Title: '.$Language->get('Error').PHP_EOL.'Content: '.PHP_EOL.$Language->get('installer-page-error-content');
file_put_contents(PATH_PAGES.'error'.DS.FILENAME, $data, LOCK_EX); file_put_contents(PATH_PAGES.'error'.DS.FILENAME, $data, LOCK_EX);
// File for about page // File for about page
$data = 'Title: '.$Language->get('About').PHP_EOL.'Content: '.$Language->get('the-about-page-is-very-important').' '.$Language->get('change-this-pages-content-on-the-admin-panel'); $data = 'Title: '.$Language->get('About').PHP_EOL.'Content: '.PHP_EOL.$Language->get('installer-page-about-content');
file_put_contents(PATH_PAGES.'about'.DS.FILENAME, $data, LOCK_EX); file_put_contents(PATH_PAGES.'about'.DS.FILENAME, $data, LOCK_EX);
// File for welcome page // File for welcome page