Site name support and an index listing

This commit is contained in:
Alice Rhodes 2020-02-22 11:25:33 -08:00
parent a61023292b
commit 74afe991d8
3 changed files with 51 additions and 15 deletions

View File

@ -28,19 +28,24 @@ $next = "";
$last = $ring_size - 1;
$index = array_keys( $web_ring );
if( $id == $last ) { // are we at the end?
$next = $web_ring[0]; // first one
$prev = $web_ring[$id-1]; // previous one
$next = $index[0]; // first one
$prev = $index[$id-1]; // previous one
} else if( $id == 0 ) { // are we at the beginning?
$next = $web_ring[$id+1]; // next one
$prev = $web_ring[$last]; // last one
$next = $index[$id+1]; // next one
$prev = $index[$last]; // last one
} else { // somewhere in the middle
$next = $web_ring[$id+1];
$prev = $web_ring[$id-1];
$next = $index[$id+1];
$prev = $index[$id-1];
}
$rand = $web_ring[rand(0,$last)];
$rand = $index[rand(0,$last)];
$rand_url = $web_ring[$rand];
$prev_url = $web_ring[$prev];
$next_url = $web_ring[$next]
?><!DOCTYPE html>
<html lang="en">
@ -63,9 +68,9 @@ $rand = $web_ring[rand(0,$last)];
<div>
<h1><a href="https://alicerhodes.com/web-l00p/test.html" target="_parent" title="Webring Home Page">hackers town webring</a></h1> <!-- this should link to web ring home page -->
<ul>
<li><a href="<?php print $prev; ?>" target="_parent" title="Previous Website">&lt;&lt; Prev</a></li>
<li><a href="<?php print $rand; ?>" target="_parent" title="Random Website">Rand</a></li>
<li><a href="<?php print $next; ?>" target="_parent" title="Next Website">Next &gt;&gt;</a></li>
<li><a href="<?php print $prev_url; ?>" target="_parent" title="Previous Website">&lt;&lt; Prev</a></li>
<li><a href="<?php print $rand_url; ?>" target="_parent" title="Random Website">Rand</a></li>
<li><a href="<?php print $next_url; ?>" target="_parent" title="Next Website">Next &gt;&gt;</a></li>
</ul>
</div>
</body>

View File

@ -2,12 +2,14 @@
$web_ring = array();
$web_ring[0] = "https://alicerhodes.com/web-l00p/test.html";
$web_ring[1] = "https://alicerhodes.com/web-l00p/page01.html";
$web_ring[2] = "https://alicerhodes.com/web-l00p/page02.html";
$web_ring[3] = "https://alicerhodes.com/web-l00p/page03.html";
$web_ring[4] = "https://alicerhodes.com/web-l00p/page04.html";
/* "Site Title" "Site URL=" */
$web_ring["Start Page"] = "https://alicerhodes.com/web-l00p/test.html";
$web_ring["Page 1"] = "https://alicerhodes.com/web-l00p/page01.html";
$web_ring["Page 2"] = "https://alicerhodes.com/web-l00p/page02.html";
$web_ring["Page 3"] = "https://alicerhodes.com/web-l00p/page03.html";
$web_ring["Page 4"] = "https://alicerhodes.com/web-l00p/page04.html";
$ring_size = count( $web_ring );
?>

29
ring_index.php Normal file
View File

@ -0,0 +1,29 @@
<?php include('ring.php'); ?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>web-l00p demo page</title>
</head>
<body>
<div>
<h1>Webring Index</h1>
<ol>
<?php
$index = array_keys( $web_ring );
for( $i = 0; $i < $ring_size; $i++ ) {
print "\n <li>".'<a href="'.$web_ring[$index[$i]].'">'.$index[$i].'</a></li>';
}
?>
</ol>
</div>
</body>
</html>