news thing

This commit is contained in:
Ben Harris 2017-12-28 17:29:14 -05:00
parent 5eab08f18d
commit 08937b740e
5 changed files with 56 additions and 14 deletions

View File

@ -65,29 +65,32 @@
<h1>other tilde things</h1>
<a class="btn btn-info" href="/discord/">
<a class="btn btn-success" href="/discord/">
<i class="fa fa-comments"></i> tilde~discord</a>
<a class="btn btn-info" href="https://github.com/tilde-team">
<a class="btn btn-success" href="https://github.com/tilde-team">
<i class="fa fa-github"></i> tilde~githuborg</a>
<a class="btn btn-info" href="https://bhh.sh">
<a class="btn btn-success" href="https://bhh.sh">
<i class="fa fa-link"></i> url shortener</a>
<a class="btn btn-info" href="https://social.tilde.team/">
<a class="btn btn-success" href="https://social.tilde.team/">
<i class="fa fa-retweet"></i> tilde.team mastodon instance</a>
<a class="btn btn-success" href="https://twitter.com/tildeteam">
<i class="fa fa-twitter"></i> tilde.team updates on twitter</a>
<br>
<hr>
<h1>users:</h1>
<a href="/tilde.24h.html">last updated users (only shows changes in the last 24 hours)</a>
<br><br>
<?php foreach (array_diff(scandir("/home"), ['..', '.']) as $user) { if (!is_dir("/home/$user/public_html")) continue; ?>
<div class="list-group">
<a href="/~<?=$user?>/" class="list-group-item">
<h5 class="list-group-item-heading">~<?=$user?></h5>
</a>
<div class="row">
<div class="col-md-7">
<h1>~news~</h1>
<?php include "news.php"; ?>
</div>
<?php } ?>
<div class="col-md-5">
<h1>~users~</h1>
<a href="/tilde.24h.html">last updated users (only shows changes in the last 24 hours)</a>
<br><br>
<?php include "users.php"; ?>
</div>
</div>
<hr>
</div>

15
news.php Executable file
View File

@ -0,0 +1,15 @@
<?php
foreach (glob("news/*.json") as $file):
$post = json_decode(file_get_contents($file));
if (!$post->published) continue; ?>
<div class="list-group">
<div class="list-group-item">
<h4 class="list-group-item-heading"><?=$post->title?></h4>
<em><?=$post->date?></em>
<p class="list-group-item-text"><?=$post->content?></p>
</div>
</div>
<?php endforeach;

7
news/first_post.json Executable file
View File

@ -0,0 +1,7 @@
{
"published": true,
"date": "Dec 28, 2017",
"title": "first post",
"author": "",
"content": "hi this is the first news post"
}

7
news/post_template.json Executable file
View File

@ -0,0 +1,7 @@
{
"published": false,
"date": "The Date",
"title": "post title ",
"author": "your name",
"content": "content here <strong>html works too</strong>"
}

10
users.php Executable file
View File

@ -0,0 +1,10 @@
<?php foreach (array_diff(scandir("/home"), ['..', '.']) as $user):
if (!is_dir("/home/$user/public_html")) continue; ?>
<div class="list-group">
<a href="/~<?=$user?>/" class="list-group-item">
<h5 class="list-group-item-heading">~<?=$user?></h5>
</a>
</div>
<?php endforeach;