news posts and faq posts have separate layouts

This commit is contained in:
Alex Grintsvayg 2016-07-14 10:37:27 -04:00
parent f5a9d87452
commit 9fd609561e
7 changed files with 39 additions and 20 deletions

View file

@ -89,14 +89,14 @@ class Controller
{ {
return ContentActions::executeRss(); return ContentActions::executeRss();
} }
return $slug ? ContentActions::executePost($uri) : ContentActions::executeNews(); return $slug ? ContentActions::executeNewsPost($uri) : ContentActions::executeNews();
} }
$faqPattern = '#^' . ContentActions::URL_FAQ . '(/|$)#'; $faqPattern = '#^' . ContentActions::URL_FAQ . '(/|$)#';
if (preg_match($faqPattern, $uri)) if (preg_match($faqPattern, $uri))
{ {
$slug = preg_replace($faqPattern, '', $uri); $slug = preg_replace($faqPattern, '', $uri);
return $slug ? ContentActions::executePost($uri) : ContentActions::executeFaq(); return $slug ? ContentActions::executeFaqPost($uri) : ContentActions::executeFaq();
} }
$noSlashUri = ltrim($uri, '/'); $noSlashUri = ltrim($uri, '/');

View file

@ -72,14 +72,14 @@ class ContentActions extends Actions
]]; ]];
} }
public static function executePost($relativeUri) public static function executeNewsPost($relativeUri)
{ {
$post = Post::load(ltrim($relativeUri, '/')); $post = Post::load(ltrim($relativeUri, '/'));
if (!$post) if (!$post)
{ {
return ['page/404', []]; return ['page/404', []];
} }
return ['content/post', [ return ['content/news-post', [
'post' => $post, 'post' => $post,
View::LAYOUT_PARAMS => [ View::LAYOUT_PARAMS => [
'showRssLink' => true 'showRssLink' => true
@ -87,6 +87,18 @@ class ContentActions extends Actions
]]; ]];
} }
public static function executeFaqPost($relativeUri)
{
$post = Post::load(ltrim($relativeUri, '/'));
if (!$post)
{
return ['page/404', []];
}
return ['content/faq-post', [
'post' => $post,
]];
}
public static function executePressKit() public static function executePressKit()
{ {
$zipFileName = 'lbry-press-kit-' . date('Y-m-d') . '.zip'; $zipFileName = 'lbry-press-kit-' . date('Y-m-d') . '.zip';

View file

@ -163,16 +163,6 @@ class Post
return $this->date !== null; return $this->date !== null;
} }
public function hasPrevNext()
{
return $this->postType == 'news';
}
public function hasLearnFooter()
{
return $this->postType == 'news';
}
public function getAuthorName() public function getAuthorName()
{ {
switch(strtolower($this->author)) switch(strtolower($this->author))

View file

@ -0,0 +1,17 @@
<?php Response::setMetaDescription($post->getTitle()) ?>
<?php Response::addMetaImages($post->getImageUrls()) ?>
<?php NavActions::setNavUri('/learn') ?>
<?php echo View::render('nav/_header') ?>
<main>
<section class="post-content">
<div class="content">
<br />
<div class="meta">
<a href="/faq"><< Back to FAQ</a>
</div>
<h1><?php echo htmlentities($post->getTitle()) ?></h1>
<?php echo $post->getContentHtml() ?>
</div>
</section>
</main>
<?php echo View::render('nav/_footer') ?>

View file

@ -1,4 +1,5 @@
<?php Response::setMetaDescription('Frequently asked questions about LBRY.') ?> <?php Response::setMetaDescription('Frequently asked questions about LBRY.') ?>
<?php NavActions::setNavUri('/learn') ?>
<?php echo View::render('nav/_header', ['isDark' => false]) ?> <?php echo View::render('nav/_header', ['isDark' => false]) ?>
<main> <main>
<section class="content content-readable spacer2"> <section class="content content-readable spacer2">

View file

@ -22,14 +22,10 @@
<div class="content"> <div class="content">
<?php echo $post->getContentHtml() ?> <?php echo $post->getContentHtml() ?>
</div> </div>
<?php if ($post->hasPrevNext()): ?> <?php echo View::render('content/_postNav', ['post' => $post]) ?>
<?php echo View::render('content/_postNav', ['post' => $post]) ?>
<?php endif ?>
</section> </section>
<?php if ($post->hasLearnFooter()): ?> <?php echo View::render('nav/_learnFooter', ['isDark' => false]) ?>
<?php echo View::render('nav/_learnFooter', ['isDark' => false]) ?>
<?php endif ?>
<?php if ($post->hasAuthor()): ?> <?php if ($post->hasAuthor()): ?>
<?php echo View::render('content/_postAuthor', ['post' => $post]) ?> <?php echo View::render('content/_postAuthor', ['post' => $post]) ?>

View file

@ -13,6 +13,9 @@ code
} }
pre pre
{ {
> code {
padding: 0;
}
margin-bottom: $spacing-vertical; margin-bottom: $spacing-vertical;
border-left: .3rem solid $color-primary; border-left: .3rem solid $color-primary;
padding: 10px 20px; padding: 10px 20px;