read navigation from menu.ini

(duck)
This commit is contained in:
duck
2004-07-12 19:17:49 +00:00
committed by zzz
parent 31afd726ae
commit 09139e0eab
5 changed files with 189 additions and 96 deletions

View File

@@ -1,6 +1,7 @@
<?php
include('menu.php');
define(MENU_FILE,'menu.ini');
define(PAGE_DIR,'pages/');
define(PAGE_EXT,'.html');
@@ -15,7 +16,7 @@ if(isset($_REQUEST['page'])) {
} else {
$page = 'home';
}
$site_structure = parse_ini_file(MENU_FILE, true);
$pagetitle = getpagetitle($page);
if(is_readable(PAGE_DIR.$page.PAGE_EXT)) {

155
menu.ini Normal file
View File

@@ -0,0 +1,155 @@
[home]
title = "News"
depth = 1
[roadmap]
title = "Roadmap"
depth = 2
[about]
title = "About I2P"
depth = 1
[bounties]
depth = 2
[donate]
depth = 2
[getinvolved]
title = "Get involved"
depth = 2
[halloffame]
title = "Hall of Fame"
depth = 2
[team]
title = "I2P Team"
depth = 2
[download]
depth = 1
[documentation]
depth = 1
[installation]
depth = 2
[application]
depth = 2
[myi2p]
title = "MyI2P"
depth = 3
[minwww]
title = "MinWWW"
depth = 3
[i2ptunnel]
title = "I2PTunnel"
depth = 3
[i2ptunnel_services]
title = "Setting up services"
[i2ptunnel_tuning]
title = "Tuning"
[i2ptunnel_lan]
title = "LAN setup"
[performance]
depth = 2
[jbigi]
title = "jbigi"
depth = 3
[jvm]
title = "JVM"
depth = 3
[config_tweaks]
depth = 3
[api]
title = "API"
depth = 2
[sam]
title = "SAM"
[ministreaming]
title = "ministreaming"
[i2cp]
title = "I2CP"
[how]
title = "How does it work?"
depth = 2
[how_intro]
title = "Intro"
[how_threatmodel]
title = "Threat model"
[how_tunnelrouting]
title = "Tunnel routing"
[how_garlicrouting]
title = "Garlic routing"
[how_networkdatabase]
title = "Network database"
[how_peerselection]
title = "Peer selection"
[how_cryptography]
title = "Cryptography"
[how_elgamalaes]
title = "ElGamal/AES+SessionTag"
[how_networkcomparisons]
title = "Network comparisons"
[faq]
title = "FAQ"
depth = 1
[development]
depth = 1
[implementation]
depth = 2
[bugzilla]
depth = 2
link = "http://dev.i2p.net/bugzilla/index.cgi"
[licenses]
depth = 2
[mailinglist]
depth = 2
link = "http://dev.i2p.net/pipermail/i2p/"
[meetings]
depth = 2
[cvs]
title = "CVS"
depth = 2
[forum]
depth = 1
link = "http://forum.i2p.net/"
[links]
depth = 1

View File

@@ -1,41 +1,38 @@
<?php
// TODO: improve this, like include the navigation hierarchy into it
// dictionary for looking up the page title, if there is no match
// the first character of the page is capitalized
$pagetitles = array('home' => 'News',
'about' => 'About I2P',
'getinvolved' => 'Get involved',
'halloffame' => 'Hall of Fame',
'myi2p' => 'MyI2P',
'minwww' => 'MinWWW',
'i2ptunnel' => 'I2PTunnel',
'i2ptunnel_services' => 'Setting up services',
'i2ptunnel_tuning' => 'Tuning',
'i2ptunnel_lan' => 'LAN setup',
'jvm' => 'JVM',
'api' => 'API',
'sam' => 'SAM',
'i2cp' => 'I2CP',
'how' => 'How does it work?',
'how_intro' => 'Intro',
'how_threatmodel' => 'Threat model',
'how_tunnelrouting' => 'Tunnel routing',
'how_garlicrouting' => 'Garlic routing',
'how_networkdatabase' => 'Network database',
'how_peerselection' => 'Peer selection',
'how_cryptography' => 'Cryptography',
'how_elgamalaes' => 'ElGamal/AES+SessionTag',
'how_networkcomparisons' => 'Network comparisons',
'faq' => 'FAQ',
'cvs' => 'CVS');
function getpagetitle($page) {
global $pagetitles;
if (isset($pagetitles[$page])) {
return $pagetitles[$page];
global $site_structure;
if (isset($site_structure[$page]['title'])) {
return $site_structure[$page]['title'];
}
$title = str_replace ('_', ' ', $page);
return ucfirst($title);
}
function buildmenu() {
global $site_structure;
foreach ($site_structure as $page=>$page_config) {
if (isset($page_config['depth'])) {
$title = getpagetitle($page);
$link = '';
if (isset($page_config['link'])) {
$link = $page_config['link'];
} else {
$link = $page;
}
switch ($page_config['depth']) {
case 1:
print "<br /><b><a href=\"$link\">$title</a></b><br />\n";
break;
case 2:
print "- <a href=\"$link\">$title</a><br />\n";
break;
case 3:
print "&nbsp;&nbsp;* <a href=\"$link\">$title</a><br />\n";
break;
default:
}
}
}
}
?>

View File

@@ -20,7 +20,7 @@ echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
<h1>I2P - <?=$pagetitle?></h1>
<div class="menu">
<?php include(PAGE_DIR.'menu'.PAGE_EXT); ?>
<?php buildmenu(); ?>
</div>
<div class="main" id="main">

View File

@@ -1,60 +0,0 @@
<b><a href="home">News[ ]</a></b><br />
- <a href="roadmap">Roadmap</a><br />
<br />
<b><a href="about">About I2P[ ]</a></b><br />
- <a href="bounties">Bounties</a><br />
- <a href="donate">Donate</a><br />
- <a href="getinvolved">Get involved</a><br />
- <a href="halloffame">Hall of Fame</a><br />
- <a href="team">Team</a><br />
<br />
<b><a href="download">Download</a></b><br />
<br />
<b><a href="documentation">Documentation[ ]</a></b><br />
- <a href="installation">Installation[ ]</a><br />
- <a href="applications">Applications</a><br />
&nbsp;&nbsp;* <a href="myi2p">MyI2P[ ]</a><br />
&nbsp;&nbsp;* <a href="minwww">MinWWW</a><br />
&nbsp;&nbsp;* <a href="i2ptunnel">I2PTunnel[.]</a><br />
<!-- NAVIGATION MOVED TO I2PTUNNEL PAGE
&nbsp;&nbsp;&nbsp;&nbsp;&gt; <a href="i2ptunnel_services">Setting up services[ ]</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&gt; <a href="i2ptunnel_tuning">Tuning[ ]</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&gt; <a href="i2ptunnel_lan">LAN setup[ ]</a><br />
-->
- <a href="performance">Performance</a><br />
&nbsp;&nbsp;* <a href="jbigi">jbigi</a><br />
&nbsp;&nbsp;* <a href="jvm">JVM[ ]</a><br />
&nbsp;&nbsp;* <a href="config_tweaks">Config tweaks[ ]</a><br />
- <a href="api">API[.]</a><br />
<!-- NAVIGATION MOVED TO API PAGE
&nbsp;&nbsp;* <a href="sam">SAM[ ]</a><br />
&nbsp;&nbsp;* <a href="ministreaming">ministreaming[ ]</a><br />
&nbsp;&nbsp;* <a href="i2cp">I2CP[ ]</a><br />
&nbsp;&nbsp;* <a href="datagrams">Datagrams[ ]</a><br />
-->
- <a href="how">How does it work?[.]</a><br />
<!-- NAVIGATION MOVED TO HOW PAGE
&nbsp;&nbsp;* <a href="how_intro">Intro</a><br />
&nbsp;&nbsp;* <a href="how_threatmodel">Threat model</a><br />
&nbsp;&nbsp;* <a href="how_tunnelrouting">Tunnel routing[ ]</a><br />
&nbsp;&nbsp;* <a href="how_garlicrouting">Garlic routing[ ]</a><br />
&nbsp;&nbsp;* <a href="how_networkdatabase">Network database[ ]</a><br />
&nbsp;&nbsp;* <a href="how_peerselection">Peer selection[ ]</a><br />
&nbsp;&nbsp;* <a href="how_cryptography">Cryptography[ ]</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&gt; <a href="how_elgamalaes">ElGamal/AES+SessionTag</a><br />
&nbsp;&nbsp;* <a href="how_networkcomparisons">Network comparisons</a><br />
-->
<br />
<b><a href="faq">FAQ</a></b><br />
<br />
<b><a href="development">Development[ ]</a></b><br />
- <a href="implementation">Implementation[ ]</a><br />
- <a href="http://dev.i2p.net/bugzilla/index.cgi">Bugzilla</a><br />
- <a href="licenses">Licenses</a><br />
- <a href="http://dev.i2p.net/pipermail/i2p/">Mailinglist</a><br />
- <a href="meetings">Meetings</a><br />
- <a href="cvs">CVS</a><br />
<br />
<b><a href="http://forum.i2p.net/">Forum</a></b><br />
<br />
<b><a href="links">Links</a></b><br />