rpms/mediawiki-HTTP302Found/EL-5 HTTP302Found.php, NONE, 1.1 import.log, NONE, 1.1 mediawiki-HTTP302Found.spec, NONE, 1.1

Ian Weller ianweller at fedoraproject.org
Fri Jun 26 14:56:09 UTC 2009


Author: ianweller

Update of /cvs/pkgs/rpms/mediawiki-HTTP302Found/EL-5
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv22072/EL-5

Added Files:
	HTTP302Found.php import.log mediawiki-HTTP302Found.spec 
Log Message:
initial package import


--- NEW FILE HTTP302Found.php ---
<?php
/* MediaWiki extension to force an external HTTP 302 redirect instead of internal redirects
 * Copyright (C) 2009  Ian Weller <ian at ianweller.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
$wgExtensionCredits["other"][] = array(
        'path' => __FILE__,
        'name' => "HTTP 302 Found",
        'description' => "Forces an external HTTP 302 redirect instead of internal redirects",    
        'version' => "1.0",         
        'author' => "Ian Weller",         
        'url' => "http://www.mediawiki.org/wiki/Extension:HTTP302Found",
);
 
$wgHooks['InitializeArticleMaybeRedirect'][] = 'http302_redirect_hook';
$wgHooks['ArticlePageDataBefore'][] = 'http302_redirect_notification_hook';
 
// This function causes the actual redirect
function http302_redirect_hook($title, $request, &$ignoreRedirect, &$target, &$article)
{
        if (!$ignoreRedirect && $article->isRedirect()) {
                if (($target = $article->followRedirect()) instanceof Title) {
                        $target = $target->getFullURL()."?rd=".$title->mUrlform;
                }
        }
        return true;
}
 
// This function handles the "rd" GET variable and forces the "Redirected from ..." message
function http302_redirect_notification_hook(&$article, &$fields)
{
        $title = Title::newFromText($_GET["rd"]);
        $article->setRedirectedFrom($title);
        return true;
}



--- NEW FILE import.log ---
mediawiki-HTTP302Found-1_0-1_fc11:EL-5:mediawiki-HTTP302Found-1.0-1.fc11.src.rpm:1246028149


--- NEW FILE mediawiki-HTTP302Found.spec ---
Name:           mediawiki-HTTP302Found
Version:        1.0
Release:        1%{?dist}
Summary:        Forces an external HTTP 302 redirect instead of internal redirects

Group:          Applications/Internet
License:        GPLv2+
URL:            http://www.mediawiki.org/wiki/Extension:HTTP302Found
# Copy/paste from http://www.mediawiki.org/wiki/Extension:HTTP302Found/Version_1.0
Source0:        HTTP302Found.php
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:      noarch

Requires:       mediawiki >= 1.14.0

%description
Pushes a HTTP code 302 (Found) to the browser when there is a redirect instead
of handling it internally. The end user will not notice any difference (other
than the address to the page having an ?rd=Redirecting_page bit at the end).


%prep
echo 'To complete installation of %{name}, add the following lines to LocalSettings.php:

    require_once("$IP/extensions/HTTP302Found/HTTP302Found.php");

for each MediaWiki instance you wish to install %{name} on.' > README.fedora


%build


%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_datadir}/mediawiki/extensions/HTTP302Found
install -cpm 644 %{SOURCE0} %{buildroot}%{_datadir}/mediawiki/extensions/HTTP302Found/


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%doc README.fedora
%{_datadir}/mediawiki/extensions/HTTP302Found


%changelog
* Mon Jun 15 2009 Ian Weller <ian at ianweller.org> - 1.0-1
- Initial package build




More information about the fedora-extras-commits mailing list