fix homepage link logic

- double check index existence
- clean up indentation
This commit is contained in:
Ben Harris 2021-01-11 11:04:11 -05:00
parent e5b70b80b3
commit bc975a6581
2 changed files with 130 additions and 116 deletions

View File

@ -5,7 +5,7 @@ require __DIR__.'/vendor/autoload.php';
$parser = Tildeverse\Wiki\Parser::factory(); $parser = Tildeverse\Wiki\Parser::factory();
?> ?>
<div class="jumbotron"> <div class="jumbotron">
<h1>~team</h1> <h1>~team</h1>
<pre> <pre>
__ _ __ __ __ __ _ __ __ __
@ -18,53 +18,54 @@ $parser = Tildeverse\Wiki\Parser::factory();
<br> <br>
<p>a digital community for socializing, learning, and making cool stuff</p> <p>a digital community for socializing, learning, and making cool stuff</p>
</div> </div>
<p> <p>
tilde.team is a shared system that provides an inclusive, tilde.team is a shared system that provides an inclusive,
non-commercial space for teaching, learning, practicing and non-commercial space for teaching, learning, practicing and
enjoying the social medium of unix. enjoying the social medium of unix.
</p> </p>
<p> <p>
i created this tilde after hearing about paul ford's i created this tilde after hearing about paul ford's
<a href="http://tilde.club/">tilde.club</a>. when i was unable <a href="http://tilde.club/">tilde.club</a>. when i was unable
to join due to the waitlist, i decided to create my own tilde. to join due to the waitlist, i decided to create my own tilde.
</p> </p>
<p>thanks for stopping by!</p> <p>thanks for stopping by!</p>
<p> <p>
tilde.team is a founding member of <a href="https://tildeverse.org">tildeverse.org</a>, tilde.team is a founding member of <a href="https://tildeverse.org">tildeverse.org</a>,
which is a collaborative effort among several <a href="https://tildeverse.org/members/"> which is a collaborative effort among several <a href="https://tildeverse.org/members/">
other tilde servers</a>. other tilde servers</a>.
</p> </p>
<p> <p>
hosting and domains are paid out-of-pocket. tilde.team will always hosting and domains are paid out-of-pocket. tilde.team will always
be free to use. however, if you are able and willing to pitch in, be free to use. however, if you are able and willing to pitch in,
you can <a href="https://bhh.sh/donate/">donate here</a>. you can <a href="https://bhh.sh/donate/">donate here</a>.
</p> </p>
<p><a href="/~ben/">~ben</a></p> <p><a href="/~ben/">~ben</a></p>
<br> <br>
<a href="/signup/" class="btn btn-primary btn-lg"> <a href="/signup/" class="btn btn-primary btn-lg">
<i class="fa fa-user-plus"></i> signup</a> <i class="fa fa-user-plus"></i> signup</a>
<br> <br>
<br> <br>
<hr> <hr>
<h3>tilde.team services</h3> <h3>tilde.team services</h3>
<?php include 'services.php'; ?> <?php include 'services.php'; ?>
<br> <br>
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-md-7"> <div class="col-md-7">
<h1>~news~</h1> <h1>~news~</h1>
<?php foreach (array_slice(array_reverse(glob("news/pages/*.md")), 0, 4) as $page): <?php foreach (array_slice(array_reverse(glob("news/pages/*.md")), 0, 4) as $page):
$parsed = $parser->parse(file_get_contents($page)); $parsed = $parser->parse(file_get_contents($page));
$yaml = $parsed->getYAML(); $yaml = $parsed->getYAML();
@ -73,13 +74,9 @@ $parser = Tildeverse\Wiki\Parser::factory();
<div class="list-group"> <div class="list-group">
<div class="list-group-item"> <div class="list-group-item">
<h3 class="list-group-item-heading"><?=$yaml["title"]?></h3> <h3 class="list-group-item-heading"><?=$yaml["title"]?></h3>
<em> <em><a href="/news/<?=basename($page, ".md")?>"><?=$yaml["date"]?></a></em>
<a href="/news/<?=basename($page, ".md")?>"><?=$yaml["date"]?></a>
</em>
&bull; &bull;
<em> <em><a href="/~<?=$yaml["author"]?>/"><?=$yaml["author"]?></a></em>
<a href="/~<?=$yaml["author"]?>/"><?=$yaml["author"]?></a>
</em>
<hr> <hr>
<div class="list-group-item-text"><?=$parsed->getContent()?></div> <div class="list-group-item-text"><?=$parsed->getContent()?></div>
</div> </div>
@ -89,7 +86,7 @@ $parser = Tildeverse\Wiki\Parser::factory();
<div class="list-group"> <div class="list-group">
<div class="list-group-item"> <div class="list-group-item">
<p class="list-group-item-text"><a href="/news/">news archive here...</a></p> <p class="list-group-item-text"><a href="/news/">news archive...</a></p>
</div> </div>
</div> </div>
@ -120,27 +117,44 @@ $parser = Tildeverse\Wiki\Parser::factory();
<p><em><a href="/tilde.24h.html"><i class="fa fa-clock-o"></i> recent updates</a></em></p> <p><em><a href="/tilde.24h.html"><i class="fa fa-clock-o"></i> recent updates</a></em></p>
<p>if you're not listed here, make some changes to your page</p> <p>if you're not listed here, make some changes to your page</p>
<p><a href="/users/">all users</a></p> <p><a href="/users/">all users</a></p>
<br><br>
<div class="list-group"> <div class="list-group">
<ul> <ul>
<?php <?php foreach (glob("/home/*/public_html", GLOB_ONLYDIR) as $user):
foreach (glob("/home/*") as $user): if (
if (!is_dir("$user/public_html") (
|| (file_exists("$user/public_html/index.php") // make sure we have an index page
&& in_array(sha1_file("$user/public_html/index.php"), !is_file("$user/index.html")
// these are the sha1s of two previous default pages && !is_file("$user/index.htm")
["ca32714c33abb57430583ad07efec6097ae1a044", "f190ba3a1ed796a20bea83304e45e799420c0716"]))) && !is_file("$user/index.cgi")
continue; && !is_file("$user/index.php")
$user = basename($user); ?> )
|| (
// if it's php, compare the hash to the default page
is_file("$user/index.php")
&& in_array(
sha1_file("$user/index.php"),
[
// these are the sha1s of two previous pages
"ca32714c33abb57430583ad07efec6097ae1a044",
"f190ba3a1ed796a20bea83304e45e799420c0716"
]
)
)
) continue;
$user = basename(dirname($user));
$usercount++; ?>
<li style="list-style: none; margin-left: -40px;"> <li style="list-style: none; margin-left: -40px;">
<a href="/~<?=$user?>/" class="list-group-item"> <a href="/~<?=$user?>/" class="list-group-item">
<h6 class="list-group-item-heading">~<?=$user?></h6> <h6 class="list-group-item-heading">~<?=$user?></h6>
</a> </a>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<p>users who have updated their homepages: <?=$usercount?></p>
</div> </div>
</div> </div>
</div> </div>
<?php include 'footer.php'; ?> <?php include 'footer.php'; ?>

View File

@ -13,12 +13,12 @@ $services = [
'webring' => ['fa' => 'life-ring', 'url' => '/ring/'], 'webring' => ['fa' => 'life-ring', 'url' => '/ring/'],
]; ];
$nav = isset($navbar); $nav = isset($navbar) && $navbar;
unset($navbar); unset($navbar);
foreach ($services as $name => $service) { ?> foreach ($services as $name => $service) { ?>
<?php if ($nav) echo '<li>'; ?> <?php if ($nav) echo '<li>'; ?>
<a href="<?=$service['url']?>" <?php if (!$nav) echo 'class="btn btn-default"'; ?>><i class="fa fa-<?=$service['fa']?>"></i> ~<?=$name?>~</a> <a href="<?=$service['url']?>" <?php if (!$nav) echo 'class="btn btn-default"'; ?>><i class="fa fa-<?=$service['fa']?>"></i> <?=$name?></a>
<?php if ($nav) echo '</li>'; ?> <?php if ($nav) echo '</li>' . PHP_EOL; ?>
<?php } <?php }