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
- Themes
- Plugins multilangueage
- Format date, for post and pages
Check:
- 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
public function setDb($db)
public function set($db)
{
$this->db = $db;

View File

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

View File

@ -70,7 +70,10 @@ function build_page($key)
if( $dbUsers->userExists( $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;

View File

@ -54,12 +54,14 @@ function buildPost($key)
$content = $Parsedown->text( $Post->content() );
$Post->setField('content', $content, true);
// User / Author
// Parse username for the post.
if( $dbUsers->userExists( $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;

View File

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

View File

@ -181,9 +181,14 @@ class Page extends fileContent
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');
}
public function username()
{
return $this->getField('username');
}
// Returns TRUE if the post is published, FALSE otherwise.
public function 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()

View File

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

View File

@ -3,20 +3,39 @@
<?php foreach ($posts as $Post): ?>
<section class="post">
<!-- Post header -->
<header class="post-header">
<!-- Post title -->
<h2 class="post-title">
<a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a>
</h2>
<p class="post-meta">
<span><?php echo $Language->get('Posted By').' '.$Post->author() ?></span>
<span>Date: <?php echo $Post->dateCreated() ?></span>
</p>
<!-- Post date and author -->
<div class="post-meta">
<span class="date"><?php echo $Post->dateCreated() ?></span>
<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>
<div class="post-description">
<!-- Post content -->
<div class="post-content">
<?php echo $Post->content() ?>
</div>
</section>
<?php endforeach; ?>

View File

@ -1,11 +1,36 @@
<h1 class="subhead">Page</h1>
<section class="page">
<header class="page-head">
<h1 class="page-title">
# <?php echo $Page->title() ?>
</h1>
<!-- page header -->
<header class="page-header">
<!-- 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>
<!-- page content -->
<div class="page-content">
<?php echo $Page->content() ?>
</div>
</section>

View File

@ -1,18 +1,37 @@
<h1 class="subhead">Posts</h1>
<h1 class="subhead">Post</h1>
<section class="post">
<!-- Post header -->
<header class="post-header">
<!-- Post title -->
<h2 class="post-title">
<?php echo $Post->title() ?>
<a href="<?php echo $Post->permalink() ?>"><?php echo $Post->title() ?></a>
</h2>
<p class="post-meta">
<span>Posted by <?php echo $Post->author() ?></span>
<span>Date: <?php echo $Post->dateCreated() ?></span>
</p>
<!-- Post date and author -->
<div class="post-meta">
<span class="date"><?php echo $Post->dateCreated() ?></span>
<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>
<div class="post-description">
<!-- Post content -->
<div class="post-content">
<?php echo $Post->content() ?>
</div>
</section>