Bug fixes

This commit is contained in:
dignajar 2015-07-06 22:05:17 -03:00
parent d8cb3f1145
commit 1a44f8fcef
12 changed files with 121 additions and 31 deletions

View File

@ -12,6 +12,7 @@ ToDO list
- Implement User class - Implement User class
- Themes - Themes
- Plugins multilangueage - Plugins multilangueage
- Format date, for post and pages
Check: Check:
- ver casos de errores, filtros url iguales, con una / - ver casos de errores, filtros url iguales, con una /

View File

@ -69,7 +69,7 @@ class dbJSON
} }
// DEBUG, ver si sirve para la instalacion, sino borrar // DEBUG, ver si sirve para la instalacion, sino borrar
public function setDb($db) public function set($db)
{ {
$this->db = $db; $this->db = $db;

View File

@ -113,6 +113,7 @@ class Plugin {
if( !empty($this->dbFields) ) if( !empty($this->dbFields) )
{ {
// DEBUG: NO ME GUSTA LLAMAR A UNA CLASE
$Tmp = new dbJSON($this->fileDb); $Tmp = new dbJSON($this->fileDb);
$Tmp->setDb($this->dbFields); $Tmp->setDb($this->dbFields);
} }

View File

@ -70,7 +70,10 @@ function build_page($key)
if( $dbUsers->userExists( $Page->username() ) ) if( $dbUsers->userExists( $Page->username() ) )
{ {
$user = $dbUsers->get( $Page->username() ); $user = $dbUsers->get( $Page->username() );
$Page->setField('author', $user['firstName'].', '.$user['lastName']);
$Page->setField('authorFirstName', $user['firstName'], false);
$Page->setField('authorLastName', $user['lastName'], false);
} }
return $Page; return $Page;

View File

@ -54,12 +54,14 @@ function buildPost($key)
$content = $Parsedown->text( $Post->content() ); $content = $Parsedown->text( $Post->content() );
$Post->setField('content', $content, true); $Post->setField('content', $content, true);
// User / Author // Parse username for the post.
if( $dbUsers->userExists( $Post->username() ) ) if( $dbUsers->userExists( $Post->username() ) )
{ {
$user = $dbUsers->get( $Post->username() ); $user = $dbUsers->get( $Post->username() );
$Post->setField('author', $user['firstName'].', '.$user['lastName'], false); $Post->setField('authorFirstName', $user['firstName'], false);
$Post->setField('authorLastName', $user['lastName'], false);
} }
return $Post; return $Post;

View File

@ -62,7 +62,7 @@ function build_plugins()
$database = new dbJSON($languageFilename, false); $database = new dbJSON($languageFilename, false);
} }
$databaseArray = $database->get(); $databaseArray = $database->get();
$Plugin->setData( $data['plugin-data'] ); $Plugin->setData( $databaseArray['plugin-data'] );
// Add words to language dictionary. // Add words to language dictionary.
unset($databaseArray['plugin-data']); unset($databaseArray['plugin-data']);

View File

@ -181,9 +181,14 @@ class Page extends fileContent
return $this->getField('username'); return $this->getField('username');
} }
public function author() public function authorFirstName()
{ {
return $this->getField('author'); return $this->getField('authorFirstName');
}
public function authorLastName()
{
return $this->getField('authorLastName');
} }
} }

View File

@ -49,20 +49,25 @@ class Post extends fileContent
return $this->getField('key'); return $this->getField('key');
} }
public function username()
{
return $this->getField('username');
}
// Returns TRUE if the post is published, FALSE otherwise. // Returns TRUE if the post is published, FALSE otherwise.
public function published() public function published()
{ {
return ($this->getField('status')==='published'); return ($this->getField('status')==='published');
} }
public function author() public function username()
{ {
return $this->getField('author'); return $this->getField('username');
}
public function authorFirstName()
{
return $this->getField('authorFirstName');
}
public function authorLastName()
{
return $this->getField('authorLastName');
} }
public function description() public function description()

View File

@ -36,6 +36,8 @@
.post-title a .post-title a
{ {
color: #555; color: #555;
border-bottom: 5px solid #ccc;
display: inline-block;
} }
.page-content, .page-content,
@ -83,11 +85,19 @@
} }
.post-meta { .post-meta {
color: #999;
font-size: 90%; font-size: 90%;
margin: 0; margin: 0;
} }
.post-meta span.date {
color: #999;
margin-right: 10px;
}
.post-meta span.author {
color: #ccc;
}
.post-images { .post-images {
margin: 1em 0; margin: 1em 0;
} }

View File

@ -3,20 +3,39 @@
<?php foreach ($posts as $Post): ?> <?php foreach ($posts as $Post): ?>
<section class="post"> <section class="post">
<!-- Post header -->
<header class="post-header"> <header class="post-header">
<!-- Post title -->
<h2 class="post-title"> <h2 class="post-title">
<a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a> <a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a>
</h2> </h2>
<p class="post-meta"> <!-- Post date and author -->
<span><?php echo $Language->get('Posted By').' '.$Post->author() ?></span> <div class="post-meta">
<span>Date: <?php echo $Post->dateCreated() ?></span> <span class="date"><?php echo $Post->dateCreated() ?></span>
</p> <span class="author">
<?php
echo $Language->get('Posted By').' ';
if( Text::isNotEmpty($Post->authorFirstName()) && Text::isNotEmpty($Post->authorLastName()) ) {
echo $Post->authorFirstName().', '.$Post->authorLastName();
}
else {
echo $Post->username();
}
?>
</span>
</div>
</header> </header>
<div class="post-description"> <!-- Post content -->
<div class="post-content">
<?php echo $Post->content() ?> <?php echo $Post->content() ?>
</div> </div>
</section> </section>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -1,11 +1,36 @@
<h1 class="subhead">Page</h1>
<section class="page"> <section class="page">
<header class="page-head">
<h1 class="page-title"> <!-- page header -->
# <?php echo $Page->title() ?> <header class="page-header">
</h1>
<!-- page title -->
<h2 class="page-title">
<a href="<?php echo $Page->permalink() ?>"><?php echo $Page->title() ?></a>
</h2>
<!-- page date and author -->
<div class="page-meta">
<span class="author">
<?php
echo $Language->get('Posted By').' ';
if( Text::isNotEmpty($Page->authorFirstName()) && Text::isNotEmpty($Page->authorLastName()) ) {
echo $Page->authorFirstName().', '.$Page->authorLastName();
}
else {
echo $Page->username();
}
?>
</span>
</div>
</header> </header>
<!-- page content -->
<div class="page-content"> <div class="page-content">
<?php echo $Page->content() ?> <?php echo $Page->content() ?>
</div> </div>
</section> </section>

View File

@ -1,18 +1,37 @@
<h1 class="subhead">Posts</h1> <h1 class="subhead">Post</h1>
<section class="post"> <section class="post">
<!-- Post header -->
<header class="post-header"> <header class="post-header">
<!-- Post title -->
<h2 class="post-title"> <h2 class="post-title">
<?php echo $Post->title() ?> <a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a>
</h2> </h2>
<p class="post-meta"> <!-- Post date and author -->
<span>Posted by <?php echo $Post->author() ?></span> <div class="post-meta">
<span>Date: <?php echo $Post->dateCreated() ?></span> <span class="date"><?php echo $Post->dateCreated() ?></span>
</p> <span class="author">
<?php
echo $Language->get('Posted By').' ';
if( Text::isNotEmpty($Post->authorFirstName()) && Text::isNotEmpty($Post->authorLastName()) ) {
echo $Post->authorFirstName().', '.$Post->authorLastName();
}
else {
echo $Post->username();
}
?>
</span>
</div>
</header> </header>
<div class="post-description"> <!-- Post content -->
<div class="post-content">
<?php echo $Post->content() ?> <?php echo $Post->content() ?>
</div> </div>
</section> </section>