Commit: a9279c11a1d81df59c34610dcfb5d4e73c060403 Author: Hannes Magnusson <[email protected]> Sat, 1 Jan 2011 21:37:30 +0000 Parents: 7d3062af6d447b000a10a25a93d287f02b5f6f53 Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=a9279c11a1d81df59c34610dcfb5d4e73c060403 Log: Add back shorturl to betaweb, and update the canonical version of pages Changed paths: M include/header.inc M include/layout.inc M include/site.inc Diff: diff --git a/include/header.inc b/include/header.inc index c4e680d..020c86b 100644 --- a/include/header.inc +++ b/include/header.inc @@ -4,6 +4,12 @@ $v = "?v=" .$_SERVER["REQUEST_TIME"]; header("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); + +// shorturl; http://wiki.snaplog.com/short_url +if ($shortname = get_shortname($_SERVER["BASE_PAGE"])) { + $shorturl = "http://php.net/" . $shortname; + header("Link: <$shorturl>; rel=shorturl"); +} ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $lang?>"> @@ -17,7 +23,10 @@ header("Pragma: no-cache"); <link rel="search" type="application/opensearchdescription+xml" href="http://www.php.net/phpnetimprovedsearch.src" title="Add PHP.net search" /> <link rel="alternate" type="application/atom+xml" href="http://www.php.net/releases.atom" title="PHP Release feed" /> <link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="http://www.php.net/feed.atom" /> - <link rel="canonical" href="http://php.net/index.php" /> + <link rel="canonical" href="http://php.net/<?php echo $_SERVER['BASE_PAGE']?>" /> +<?php if ($shortname): ?> + <link rel="shorturl" href="<?php echo $shorturl ?>" /> +<?php endif ?> <link rel="stylesheet" type="text/css" href="/styles/reset.css<?php echo $v?>" media="all" /> <link rel="stylesheet" type="text/css" href="/styles/structure.css<?php echo $v?>" media="screen" /> diff --git a/include/layout.inc b/include/layout.inc index e4c0294..d5aae02 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -789,6 +789,8 @@ function site_header_beta($title = '', $config = array()) { global $SIDEBAR_DATA; global $setup; + global $MYSITE; + if ($setup) { $lang = language_convert($setup['head'][1]); } diff --git a/include/site.inc b/include/site.inc index c6ed6cc..b25b132 100644 --- a/include/site.inc +++ b/include/site.inc @@ -354,6 +354,44 @@ function get_manual_search_sections() { ); } +function get_shortname($page) { + // We can at the very least kill the .php + $shorturl = substr($page, 0, -4); + + // If its a "root page", we can't shorten it more + if (strpos($shorturl, "/") === false) { + return $shorturl; + } + + // Manual pages get be quite short + if (strpos($page, "manual/") !== false) { + $sections = get_manual_search_sections(); + // Kill the first entry (empty) + array_shift($sections); + + // We can atleast remove manual/xx/ + $shorturl = substr($page, strrpos($page, "/")+1); + + foreach($sections as $section) { + // If we know this section + if (strpos($shorturl, $section) === 0) { + // We can make it even shorter + return substr($shorturl, strlen($section), -4); + break; + } + } + + // Didn't recognize the section, we better not shorten it at all + return $page; + } + + // /conferences/index.php can be shortened to /conferences + if (strpos($page, "conferences/") !== false) { + return "conferences"; + } + + return $shorturl; +} // Guess the current site from what Apache tells us. // This should be the main name of the mirror (in case -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
