szurubooru/src/Views/index-index.phtml
Marcin Kurczewski 35cdc0cf3a Refactored scripts and stylesheets
Styles, scripts and page titles are no longer set from controllers level.
Changed because it was breaking MVC pattern and led to spaghetti code.

Also, optimized JS/CSS inclusions a bit.
2014-02-01 11:24:03 +01:00

55 lines
1.6 KiB
PHTML

<?php
LayoutHelper::setSubtitle('home');
LayoutHelper::addStylesheet('index-index.css');
?>
<div id="welcome">
<h1><?php echo $this->config->main->title ?></h1>
<p>
<span>serving <?php echo $this->context->transport->postCount ?> posts</span>
</p>
</div>
<?php if (!empty($this->context->featuredPost)): ?>
<div class="body">
<?php $this->context->imageLink = \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->featuredPost->id]) ?>
<?php $this->context->transport->post = $this->context->featuredPost ?>
<?php echo $this->renderFile('post-file-render') ?>
</div>
<div class="footer">
<div class="left">
Tags:&nbsp;
<ul class="tags">
<?php $tags = $this->context->featuredPost->getTags() ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
<?php foreach ($tags as $tag): ?>
<li>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tag->name]) ?>">
<?php echo $tag->name ?>
</a>
</li>
<?php endforeach ?>
</ul>
</div>
<div class="right">
Featured&#32;
<?php if ($this->context->featuredPostUser): ?>
by <a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->featuredPostUser->name]) ?>"><?php echo $this->context->featuredPostUser->name ?></a>,&#32;
<?php endif ?>
<?php $x = round((time() - $this->context->featuredPostDate) / (24 * 3600.)) ?>
<?php if ($x == 0): ?>
today
<?php elseif ($x == 1):?>
yesterday
<?php else: ?>
<?php printf('%d days ago', $x) ?>
<?php endif ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<?php endif ?>