r106562 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106561‎ | r106562 | r106563 >
Date:14:43, 18 December 2011
Author:robin
Status:resolved
Tags:
Comment:
* Remove unneeded whitespace
* Fix redirect where the slash in xyz.project.org/ is seen as a page title and goes to Wx/xyz// on Incubator
* Make the "wiki does not exist" page in HTML5 (follows up r97829)
* Use protocol-relative URLs
Modified paths:
  • /trunk/tools/web-scripts/missing.php (modified) (history)

Diff [purge]

Index: trunk/tools/web-scripts/missing.php
@@ -25,22 +25,19 @@
2626 * @return string Actual URL except for fragment part
2727 */
2828 function getSelfUrl() {
29 -
 29+
3030 /* faking https on secure.wikimedia.org - thanks Ryan for hint */
3131 if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
32 -
3332 $_SERVER['HTTPS'] = 'on';
34 -
3533 }
36 -
 34+
3735 $s = empty( $_SERVER['HTTPS'] ) ? '' : ( $_SERVER['HTTPS'] == 'on' ) ? 's' : '';
38 -
 36+
3937 $protocol = substr( strtolower( $_SERVER['SERVER_PROTOCOL'] ), 0, strpos( strtolower( $_SERVER['SERVER_PROTOCOL'] ), '/' ) ) . $s;
40 -
 38+
4139 $port = ( $_SERVER['SERVER_PORT'] == '80') ? '' : ( ':' . $_SERVER['SERVER_PORT'] );
42 -
 40+
4341 return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
44 -
4542 }
4643
4744
@@ -59,81 +56,78 @@
6057 $url = parse_url( getSelfUrl() );
6158
6259 if( $url['host'] == 'secure.wikimedia.org' ) {
63 -
 60+
6461 # https://secure.wikimedia.org/$project/$language/wiki/$page
6562 $tmp = explode( '/', ltrim( $url['path'], '/' ) );
6663 $project = $tmp[0];
6764 $language = $tmp[1];
6865 $base = 'secure.wikimedia.org/wikipedia/incubator/wiki/';
6966 $page = implode( array_slice( $tmp, 3 ) );
70 -
 67+
7168 } else {
72 -
 69+
7370 # http(s)://$language.$project.org/wiki/$page
7471 $tmp = explode( '.', $url['host'] );
7572 $project = $tmp[1];
7673 $language = $tmp[0];
7774 $base = 'incubator.wikimedia.org/wiki/';
7875 $page = preg_replace( '/^\/wiki\//', '', $url['path'] );
79 -
 76+
8077 }
8178
8279 $project = strtolower( $project );
8380 $projectcode = $projects[$project];
8481 $project = ucfirst( $project ); // for 404 pages message
8582
86 -$location = $url['scheme'] . '://' . $base . 'W' . $projectcode . '/' . $language . ( $page ? '/' . $page : '?goto=mainpage' );
 83+$location = $url['scheme'] . '://' . $base . 'W' . $projectcode . '/' . $language;
 84+# Go to the page if specified (look out for slashes), otherwise go to
 85+# the main page Wx/xyz?goto=mainpage (WikimediaIncubator extension takes care of that)
 86+$location .= $page && $page !== '/' ? '/' . $page : '?goto=mainpage';
8787
8888 $redir = false;
8989
9090 switch( $projectcode ) {
91 -
 91+
9292 # Wikisource
9393 case 's':
9494 $logo = 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/280px-Wikisource-logo.svg.png';
9595 $home = 'http://wikisource.org';
9696 $name = 'Multilingual Wikisource';
9797 break;
98 -
 98+
9999 # Wikiversity
100100 case 'v':
101101 $logo = 'http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Wikiversity-logo.svg/300px-Wikiversity-logo.svg.png';
102102 $home = 'http://beta.wikiversity.org';
103103 $name = 'Beta Wikiversity';
104104 break;
105 -
 105+
106106 # Wikipedia, Wiktionary, Wikiquote, Wikibooks and Wikinews
107107 default:
108108 $redir = true;
109 -
 109+
110110 }
111111
112112 # OUTPUT
113113 # @fixme replace heredoc by better approach
114114 if( $redir ) {
115 -
 115+
116116 header( 'Location: ' . $location );
117117 exit();
118 -
 118+
119119 } else {
120 -
 120+
121121 header( 'HTTP/1.x 404 Not Found' );
122122 header( 'Content-Type: text/html; charset=utf-8');
123 -
124 - echo <<< EOT
125 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
126123
127 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
128 -
 124+ echo <<< EOT
 125+<!DOCTYPE html>
 126+<html lang="en" dir="ltr">
129127 <head>
130 -
131 -<title>$language&nbsp;$project does not exist</title>
132 -
133 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
134 -
135 -<link rel="shortcut icon" href="$home/favicon.ico" />
136 -
137 -<style type="text/css">
 128+ <title>$language&nbsp;$project does not exist</title>
 129+ <meta charset="UTF-8" />
 130+ <link rel="shortcut icon" href="$home/favicon.ico" />
 131+ <style type="text/css">
138132 /* <![CDATA[ */
139133 * {
140134 font-family: 'Gill Sans', 'Gill Sans MT', sans-serif;
@@ -142,7 +136,7 @@
143137 }
144138
145139 body {
146 - background: #fff url('http://upload.wikimedia.org/wikipedia/commons/9/96/Errorbg.png') repeat-x;
 140+ background: #fff url('//upload.wikimedia.org/wikipedia/commons/9/96/Errorbg.png') repeat-x;
147141 color: #333;
148142 margin: 0;
149143 padding: 0;
@@ -160,7 +154,7 @@
161155 }
162156
163157 #message {
164 - background: url('http://upload.wikimedia.org/wikipedia/commons/9/97/Errorline.png') center left no-repeat;
 158+ background: url('//upload.wikimedia.org/wikipedia/commons/9/97/Errorline.png') center left no-repeat;
165159 margin-left: 300px;
166160 padding-left: 15px;
167161 }
@@ -178,34 +172,27 @@
179173 }
180174
181175 /* ]]> */
182 -</style>
183 -
 176+ </style>
184177 </head>
185 -
186178 <body>
 179+ <div id="page">
 180+ <div id="message">
187181
188 -<div id="page">
189 -
190 - <div id="message">
191 -
192 - <h1>This wiki does not exist</h1>
193 -
194 - <h2>Welcome to $project</h2>
195 -
196 - <p>Unfortunately, $project in "$language" does not exist on its own domain yet, or it has been closed.</p>
197 -
198 - <p>You may like to visit <a href="$home">$name</a> to start or improve <em>$language&nbsp;$project</em> there.</p>
199 -
200 - <p>If you would like to request that this wiki be created, see the <a href="http://meta.wikimedia.org/wiki/Requests_for_new_languages">requests for new languages</a> page on Meta-Wiki.</p>
201 -
202 - <p style="font-size: smaller;">A&nbsp;project of the <a href="http://wikimediafoundation.org" title="Wikimedia Foundation">Wikimedia Foundation</a></p>
203 -
204 - </div>
205 -
206 -</div>
 182+ <h1>This wiki does not exist</h1>
207183
208 -</body>
 184+ <h2>Welcome to $project</h2>
209185
 186+ <p>Unfortunately, $project in "$language" does not exist on its own domain yet, or it has been closed.</p>
 187+
 188+ <p>You may like to visit <a href="$home">$name</a> to start or improve <em>$language&nbsp;$project</em> there.</p>
 189+
 190+ <p>If you would like to request that this wiki be created, see the <a href="https://www.mediawiki.org//meta.wikimedia.org/wiki/Requests_for_new_languages">requests for new languages</a> page on Meta-Wiki.</p>
 191+
 192+ <p style="font-size: smaller;">A&nbsp;project of the <a href="https://www.mediawiki.org//wikimediafoundation.org" title="Wikimedia Foundation">Wikimedia Foundation</a></p>
 193+
 194+ </div>
 195+ </div>
 196+</body>
210197 </html>
211198 EOT;
212199

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97829* + XHTML necessities accidentally lost in r97778danny_b17:27, 22 September 2011

Status & tagging log