News page is fully functional now

This commit is contained in:
flash 2015-04-06 19:51:26 +00:00
parent 8f8694f18a
commit 4465443545
4 changed files with 52 additions and 38 deletions

View file

@ -1,4 +1,4 @@
<a href="/news/{{ newsPost.id }}" class="news-head" id="{{ newsPost.id }}">{{ newsPost.title }}</a>
{% if page.articleCount > 1 %}<a href="/news/{{ newsPost.id }}" class="news-head" id="{{ newsPost.id }}">{{ newsPost.title }}</a>{% endif %}
<div class="news-body">
<a class="default" href="/u/{{ newsPost.uid }}">
<div class="news-poster">

View file

@ -1,41 +1,55 @@
{% include 'global/header.tpl' %}
<div class="content">
<div class="content-column news">
<div class="head">News <a href="/news.xml" class="fa fa-rss news-rss default"></a></div>
{% for newsPost in newsPosts %}
{% include 'elements/newsPost.tpl' %}
{% endfor %}
<div class="head">{% if page.articleCount == 1 %}{{ newsPosts[0].title }}{% elseif page.articleCount < 1 %}Post does not exist!{% else %}News <a href="/news.xml" class="fa fa-rss news-rss default"></a>{% endif %}</div>
{% if page.articleCount >= 1 %}
{% for newsPost in newsPosts %}
{% include 'elements/newsPost.tpl' %}
{% endfor %}
{% else %}
<div style="padding: 20px;">
<h1>The requested news post does not exist!</h1>
There are a few possible reasons for this;
<ul style="margin-left: 30px;">
<li>The post may have been deleted due to irrelevancy.</li>
<li>The post never existed.</li>
</ul>
</div>
{% endif %}
</div>
</div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'flashii';
{% if page.articleCount > 1 %}
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'flashii';
/* * * DO NOT EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<div id="disqus_thread">
</div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'flashii';
var disqus_identifier = 'news_".$getNews[0]['id']."';
var disqus_title = '".$getNews[0]['title']."';
var disqus_url = 'http://".$_SERVER['HTTP_HOST']."news".$getNews[0]['id']."';
/* * * DO NOT EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
{% elseif page.articleCount == 1 %}
<div id="disqus_thread">
</div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'flashii';
var disqus_identifier = 'news_{{ newsPosts[0].id }}';
var disqus_title = '{{ newsPosts[0].title }}';
var disqus_url = 'http://{{ sakura.urls.main }}/news/{{ newsPosts[0].id }}';
/* * * DO NOT EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
/* * * DO NOT EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{% endif %}
</div>
{% include 'global/footer.tpl' %}

View file

@ -10,9 +10,10 @@ namespace Sakura;
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Add page specific things
$renderData['newsPosts'] = Main::getNewsPosts(3);
$renderData['page'] = [
'title' => 'Flashii Dev',
'newsComments' => false
'articleCount' => count($renderData['newsPosts'])
];
$renderData['stats'] = [
'userCount' => ($userCount = count($users = Users::getAllUsers())) .' user'. ($userCount == 1 ? '' : 's'),
@ -20,7 +21,6 @@ $renderData['stats'] = [
'lastRegDate' => ($lastRegDate = date_diff(date_create(date('Y-m-d', max($users)['regdate'])), date_create(date('Y-m-d')))->format('%a')) .' day'. ($lastRegDate == 1 ? '' : 's'),
'chatOnline' => ($chatOnline = 0) .' user'. ($chatOnline == 1 ? '' : 's')
];
$renderData['newsPosts'] = Main::getNewsPosts(3);
// Print page contents
print Main::tplRender('main/index.tpl', $renderData);

View file

@ -12,8 +12,8 @@ require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sak
// Add page specific things
$renderData['newsPosts'] = Main::getNewsPosts((isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])) ? $_GET['id'] : null, (isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])));
$renderData['page'] = [
'title' => 'Flashii News',
'newsComments' => false
'articleCount' => ($postCount = count($renderData['newsPosts'])),
'title' => (isset($_GET['id']) ? ($postCount ? $renderData['newsPosts'][0]['title'] : 'Post does not exist!') : 'Flashii News'),
];
// News XML, don't really care so yeah