mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
fix variable-protocol urls, fix vert spacing on fluid spans, remove moving gradient, switch dev.php to php7, add posts list template
This commit is contained in:
parent
dad52ad7b4
commit
eea5421803
10 changed files with 68 additions and 38 deletions
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Description of ContentActions
|
||||
*
|
||||
* @author jeremy
|
||||
*/
|
||||
class ContentActions extends Actions
|
||||
{
|
||||
const RSS_SLUG = 'rss.xml',
|
||||
|
@ -13,7 +8,7 @@ class ContentActions extends Actions
|
|||
VIEW_FOLDER_NEWS = ROOT_DIR . '/posts/news',
|
||||
VIEW_FOLDER_FAQ = ROOT_DIR . '/posts/faq';
|
||||
|
||||
public static function executeHome()
|
||||
public static function executeHome(): array
|
||||
{
|
||||
return ['page/home', [
|
||||
'totalUSD' => CreditApi::getTotalDollarSales(),
|
||||
|
@ -21,7 +16,7 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
public static function executeFaq()
|
||||
public static function executeFaq(): array
|
||||
{
|
||||
$allPosts = Post::find(static::VIEW_FOLDER_FAQ);
|
||||
|
||||
|
@ -60,7 +55,7 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
public static function executeNews()
|
||||
public static function executeNews(): array
|
||||
{
|
||||
$posts = Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC);
|
||||
return ['content/news', [
|
||||
|
@ -72,7 +67,7 @@ class ContentActions extends Actions
|
|||
}
|
||||
|
||||
|
||||
public static function executeRss()
|
||||
public static function executeRss(): array
|
||||
{
|
||||
$posts = Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC);
|
||||
return ['content/rss', [
|
||||
|
@ -83,7 +78,7 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
public static function executeNewsPost($relativeUri)
|
||||
public static function executeNewsPost($relativeUri): array
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -101,7 +96,7 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
public static function executeFaqPost($relativeUri)
|
||||
public static function executeFaqPost($relativeUri): array
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -116,7 +111,7 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
public static function executePressKit()
|
||||
public static function executePressKit(): array
|
||||
{
|
||||
$zipFileName = 'lbry-press-kit-' . date('Y-m-d') . '.zip';
|
||||
$zipPath = tempnam('/tmp', $zipFileName);
|
||||
|
@ -177,7 +172,7 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
public static function prepareBioPartial(array $vars)
|
||||
public static function prepareBioPartial(array $vars): array
|
||||
{
|
||||
$person = $vars['person'];
|
||||
$path = 'bio/' . $person . '.md';
|
||||
|
@ -191,7 +186,7 @@ class ContentActions extends Actions
|
|||
];
|
||||
}
|
||||
|
||||
public static function preparePostAuthorPartial(array $vars)
|
||||
public static function preparePostAuthorPartial(array $vars): array
|
||||
{
|
||||
$post = $vars['post'];
|
||||
return [
|
||||
|
@ -200,4 +195,12 @@ class ContentActions extends Actions
|
|||
'authorBioHtml' => $post->getAuthorBioHtml()
|
||||
];
|
||||
}
|
||||
|
||||
public static function preparePostListPartial(array $vars): array
|
||||
{
|
||||
$count = isset($vars['count']) ? $vars['count'] : 3;
|
||||
return [
|
||||
'posts' => array_slice(Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC), 0, $count)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
2
dev.sh
2
dev.sh
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
php --server localhost:8000 --docroot web/ web/index.php
|
||||
php7.0 --server localhost:8000 --docroot web/ web/index.php
|
||||
|
|
|
@ -16,16 +16,16 @@ class View
|
|||
|
||||
public static function render($template, array $vars = [])
|
||||
{
|
||||
if (static::isMarkdown($template))
|
||||
{
|
||||
return static::markdownToHtml(static::getFullPath($template));
|
||||
}
|
||||
|
||||
if (!static::exists($template) || substr_count($template, '/') !== 1)
|
||||
{
|
||||
throw new InvalidArgumentException(sprintf('The template "%s" does not exist or is unreadable.', $template));
|
||||
}
|
||||
|
||||
if (static::isMarkdown($template))
|
||||
{
|
||||
return static::markdownToHtml(static::getFullPath($template));
|
||||
}
|
||||
|
||||
list($module, $view) = explode('/', $template);
|
||||
|
||||
$isPartial = $view[0] === '_';
|
||||
|
@ -42,23 +42,35 @@ class View
|
|||
return;
|
||||
}
|
||||
|
||||
extract($vars);
|
||||
return static::interpolateTokens(static::getTemplateSafely($template, $vars));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is its own function because we don't want in-scope variables to leak into the template
|
||||
*
|
||||
* @param string $___template
|
||||
* @param array $___vars
|
||||
*
|
||||
* @return string
|
||||
* @throws Throwable
|
||||
*/
|
||||
protected static function getTemplateSafely(string $___template, array $___vars): string
|
||||
{
|
||||
extract($___vars);
|
||||
ob_start();
|
||||
ob_implicit_flush(0);
|
||||
|
||||
try
|
||||
{
|
||||
require(static::getFullPath($template));
|
||||
require(static::getFullPath($___template));
|
||||
return ob_get_clean();
|
||||
}
|
||||
catch (Exception $e)
|
||||
catch (Throwable $e)
|
||||
{
|
||||
// need to end output buffering before throwing the exception
|
||||
ob_end_clean();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
return static::interpolateTokens(ob_get_clean());
|
||||
}
|
||||
|
||||
public static function markdownToHtml($path)
|
||||
|
@ -82,6 +94,7 @@ class View
|
|||
{
|
||||
return $template;
|
||||
}
|
||||
|
||||
if (static::isMarkdown($template))
|
||||
{
|
||||
return ROOT_DIR . '/posts/' . $template;
|
||||
|
|
8
view/template/content/_postList.php
Normal file
8
view/template/content/_postList.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<div>
|
||||
<h3>Latest News</h3>
|
||||
<ul class="no-style">
|
||||
<?php foreach($posts as $post): ?>
|
||||
<li><a href="<?php echo '/'.$post->getRelativeUrl() ?>"><?php echo $post->getTitle() ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
<?php echo View::render('nav/_globalItems') ?>
|
||||
<div class="control-item">
|
||||
<a href="//en.wikipedia.org/wiki/AACS_encryption_key_controversy" class="footer-img-link">
|
||||
<a href="https://en.wikipedia.org/wiki/AACS_encryption_key_controversy" class="footer-img-link">
|
||||
<img src="/img/Free-speech-flag.svg" alt="Free Speech Flag" height="30"/>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
</div>
|
||||
<?php endforeach ?>
|
||||
<div class="control-item no-label-desktop">
|
||||
<a href="//twitter.com/lbryio"><span class="btn-label">Twitter</span> <span class="icon-fw icon-twitter"></span></a>
|
||||
<a href="https://twitter.com/lbryio"><span class="btn-label">Twitter</span> <span class="icon-fw icon-twitter"></span></a>
|
||||
</div>
|
||||
<div class="control-item no-label-desktop">
|
||||
<a href="//www.facebook.com/lbryio"><span class="btn-label">Facebook</span> <span class="icon-fw icon-facebook"></span></a>
|
||||
<a href="https://www.facebook.com/lbryio"><span class="btn-label">Facebook</span> <span class="icon-fw icon-facebook"></span></a>
|
||||
</div>
|
||||
<div class="control-item no-label-desktop">
|
||||
<a href="//reddit.com/r/lbry"><span class="btn-label">Reddit</span> <span class="icon-fw icon-reddit"></span> </a>
|
||||
<a href="https://reddit.com/r/lbry"><span class="btn-label">Reddit</span> <span class="icon-fw icon-reddit"></span> </a>
|
||||
</div>
|
||||
<div class="control-item no-label-desktop">
|
||||
<a href="http://slack.lbry.io"><span class="btn-label">Slack</span><span class="icon-slack icon-fw"></span></a>
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
</table>
|
||||
<ul>
|
||||
<li><a href="/join-list" class="link-primary"><?php echo __('email.subscribe') ?></a>.</li>
|
||||
<li>Join us on <a href="//twitter.com/lbryio" class="link-primary"><span class="btn-label">Twitter</span><span class="icon icon-twitter"></span></a>,
|
||||
<a href="//facebook.com/lbryio" class="link-primary"><span class="btn-label">Facebook</span><span class="icon icon-facebook"></span></a>,
|
||||
or <a href="//reddit.com/r/lbry" class="link-primary"><span class="btn-label">Reddit</span><span class="icon icon-reddit"></span></a>.</li>
|
||||
<li>Join us on <a href="https://twitter.com/lbryio" class="link-primary"><span class="btn-label">Twitter</span><span class="icon icon-twitter"></span></a>,
|
||||
<a href="https://facebook.com/lbryio" class="link-primary"><span class="btn-label">Facebook</span><span class="icon icon-facebook"></span></a>,
|
||||
or <a href="https://reddit.com/r/lbry" class="link-primary"><span class="btn-label">Reddit</span><span class="icon icon-reddit"></span></a>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span6">
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="spacer1">
|
||||
<a href="//twitter.com/lbryio" class="link-primary"><span class="icon-twitter icon-fw"></span><span class="btn-label">Twitter</span></a>
|
||||
<a href="https://twitter.com/lbryio" class="link-primary"><span class="icon-twitter icon-fw"></span><span class="btn-label">Twitter</span></a>
|
||||
</div>
|
||||
<div class="spacer1">
|
||||
<a href="//www.facebook.com/lbryio" class="link-primary"><span class="icon-facebook icon-fw"></span><span class="btn-label">Facebook</span></a>
|
||||
<a href="https://www.facebook.com/lbryio" class="link-primary"><span class="icon-facebook icon-fw"></span><span class="btn-label">Facebook</span></a>
|
||||
</div>
|
||||
<div class="spacer1">
|
||||
<a href="//reddit.com/r/lbry" class="link-primary"><span class="icon-reddit icon-fw"></span><span class="btn-label">Reddit</span></a>
|
||||
<a href="https://reddit.com/r/lbry" class="link-primary"><span class="icon-reddit icon-fw"></span><span class="btn-label">Reddit</span></a>
|
||||
</div>
|
|
@ -68,11 +68,13 @@
|
|||
}
|
||||
.cover-dark-grad
|
||||
{
|
||||
@include linear-gradient(darken($color-primary, 5), lighten($color-primary, 5));
|
||||
//@include linear-gradient(darken($color-primary, 5), lighten($color-primary, 5));
|
||||
background-color: $color-primary;
|
||||
}
|
||||
.cover-light-alt-grad
|
||||
{
|
||||
@include linear-gradient(darken($color-light-alt, 5), lighten($color-light-alt, 5));
|
||||
//@include linear-gradient(darken($color-light-alt, 5), lighten($color-light-alt, 5));
|
||||
background-color: $color-light-alt;
|
||||
}
|
||||
|
||||
.cover-title, .cover-subtitle
|
||||
|
|
|
@ -95,5 +95,9 @@ $gutter_fluid: 4;
|
|||
width: 100% !important;
|
||||
margin-left: 0 !important;
|
||||
display: block !important;
|
||||
&:not(:last-child)
|
||||
{
|
||||
margin-bottom: $spacing-vertical;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue