Browse Source

n/mediawiki: Automatize downloading of extensions

slackware-14.2
Damien Goutte-Gattat 11 years ago
parent
commit
009cd4cf74
  1. 6
      n/mediawiki/extensions
  2. 57
      n/mediawiki/makearticle/Style.css
  3. 162
      n/mediawiki/makearticle/makearticle.php
  4. 26
      n/mediawiki/mediawiki.SlackBuild
  5. 6
      n/mediawiki/texvc-fix-paths-i486.patch
  6. 6
      n/mediawiki/texvc-fix-paths-x86_64.patch

6
n/mediawiki/extensions

@ -0,0 +1,6 @@
Cite 62678
Collection 66255
Configure 66255
OggHandler r62757
ParserFunctions 62695
SyntaxHighlight_GeSHi 62591

57
n/mediawiki/makearticle/Style.css

@ -0,0 +1,57 @@
.mpForm
{
margin: 0;
padding: 0;
width: 400px;
}
.mpForm h2
{
text-align: center;
font-size: 16pt;
font-weight: bold;
}
.mpR
{
color: red;
}
.mpTable
{
border-collapse: collapse;
text-align: left;
width: 100%;
}
.mpForm textarea
{
margin-left: 2px;
margin-right: 2px;
vertical-align: middle;
width: 99%;
height: 10em;
}
.mpForm textarea.mpSingle
{
height: 1.5em;
}
.mpHeader
{
width: 10em;
}
.mpForm td
{
background-color: #f2f2f2;
border: 1px black solid;
}
.mpButton
{
background-color: #ffe0e0;
position: absolute;
right: 10px;
}

162
n/mediawiki/makearticle/makearticle.php

@ -0,0 +1,162 @@
<?php
/**
* A parser hook to generate a form from a Template: so the user can populate the parameters of the
* template and then hit a button to create a page with the name they have chosen consisting of
* the template filled out with those parameters.
*
* @addtogroup Extensions
*
* Draws on the following extensions:
*
* - createarticle by Lisa Ridley
* - PageCSS by Ævar Arnfjörð Bjarmason
*
* @author Julian Porter <julian.porter@porternet.org>
* @copyright Copyright © 2010, Julian Porter
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
$wgHooks['ParserFirstCallInit'][]='wfMakeArticleInit';
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'MakeArticle (version 0.1 beta)',
'author' => 'Julian Porter',
'url' => 'http://www.mediawiki.org/User:julianporter',
'description' => 'Makes an article based on a specified Template: with the <tt>&lt;makearticle&gt;</tt> tag'
);
$wgHooks['UnknownAction'][] = 'wfActionMakeArticle';
$wgMakeArticleCSS="$IP/extensions/makearticle/Style.css";
function wfMakeArticleInit(&$parser)
{
$parser->setHook('makearticle','wfMakeArticle');
return true;
}
function wfMakeArticle($input)
{
$pageMaker=new MakeArticle($input);
return $pageMaker->render();
}
class MakeArticle
{
private $template,$css,$templateText,$parameters;
function __construct($input)
{
global $wgMakeArticleCSS;
$this->parameters=array();
$this->template=trim($input);
$this->css=file_get_contents($wgMakeArticleCSS);
if($this->css==false) MakeArticle::errorHandler("File Missing","Cannot find $wgMakeArticleCSS");
}
public function render()
{
$this->makeStyleSheet();
$this->getTemplate();
$this->getParameters();
return $this->makeForm($template,$parameters);
}
private function makeStyleSheet()
{
global $wgParser;
$css = htmlspecialchars( trim( Sanitizer::checkCss( $this->css ) ) );
$data= '<style type="text/css"> <![CDATA[*/'.$css.'/*]]>*/ </style>';
$wgParser->mOutput->addHeadItem($data);
}
private function getTemplate()
{
$title=Title::newFromText($this->template);
$id=0;
if(isset($title)) $id=$title->getArticleID();
if(!$id) MakeArticle::errorHandler("Template Missing","Cannot find template $template");
$article=Article::newFromID($id);
$this->templateText=$article->fetchContent();
}
private function getParameters()
{
preg_match_all("#\{{3}\s*(.*?)\s*\}{3}#",$this->templateText,$matches,PREG_SET_ORDER);
foreach($matches as $value) if(!in_array($value[1],$this->parameters)) $this->parameters[]=$value[1];
}
private function makeForm()
{
global $wgScript;
$action=htmlspecialchars($wgScript);
$html="";
$html.='<div class="mpForm"><h2>Populating template <span class="mpR">'.$this->template.'</span></h2><form name="makepage" action="'.$action.'" method="get">';
$html.='<input type="hidden" name="action" value="___makePage" />';
$html.='<table class="mpTable"><tr><td class="head">Title</td><td><textarea class="mpSingle" name="___title" ncols="40" nrows="2"></textarea></td></tr>';
foreach($this->parameters as $param)
{
$html.='<tr><td class="mpHeader">'.$param.'</td><td><textarea name="cp_'.$param.'" ncols="40" nrows="10"></textarea></td></tr>';
}
$html.='</table><input type="hidden" name="___template" value="'.$this->template.'"><input type="submit" name="createarticle" class="mpButton" value="Create" /></form></div>';
return $html;
}
static function errorHandler($name,$message)
{
global $wgOut, $wTitle;
$wgTitle=Title::newFromText(wfMsgForContent($name));
$wgOut->errorPage($name,$message);
}
}
function wfActionMakeArticle($action,$article)
{
global $wgRequest;
if($action!='___makePage') return true;
$title=trim($wgRequest->getVal('___title'));
if($title=='') MakeArticle::errorHandler('Bad Page Title','Title is Null');
else
{
$pageTitle=Title::newFromText($title);
if(isset($pageTitle)&&$pageTitle->getArticleID()==0)
{
$values=$wgRequest->getValues();
$html='{{'.$wgRequest->getVal('___template');
foreach($values as $key => $value)
{
$prefix=substr($key,0,3);
$keyName=substr($key,3);
if($prefix=='cp_') $html.='|'.$keyName.'='.$value;
}
$html.='}}';
//$preload=wfMakePageContents();
$article=new Article($pageTitle);
$status=$article->doEdit($html,"$title",EDIT_NEW);
if($status->isOK()) $article->doRedirect();
else MakeArticle::errorHandler('Error Creating Page',$status->getWikiText());
}
else MakeArticle::errorHandler('Bad Page Title',"Page $title already exists");
}
return false;
}
?>

26
n/mediawiki/mediawiki.SlackBuild

@ -1,6 +1,6 @@
#!/bin/bash
# Build script for Slackware
# Copyright (C) 2011 Damien Goutte-Gattat
# Copyright (C) 2011,2012 Damien Goutte-Gattat
#
# Redistribution and use of this script, with or without modifications,
# is permitted provided that the following conditions are met:
@ -32,10 +32,11 @@ NAMESRC=${NAMESRC:-mediawiki}
VERSION=${VERSION:-1.16.1}
ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION.tar.gz}
WGET=${WGET:-http://download.wikimedia.org/mediawiki/${VERSION%.*}/$ARCHIVE}
SVN=${SVN:-http://svn.wikimedia.org/svnroot}
# Build infos
NAMEPKG=${NAMEPKG:-mediawiki}
BUILD=${BUILD:-2GGD}
BUILD=${BUILD:-3GGD}
ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
EXT=${EXT:-txz}
@ -65,6 +66,14 @@ fi
sha1sum -c $ARCHIVE.sha1
NAME=$(tar ft $ARCHIVE | head -n 1 | cut -d / -f 1)
# Download extensions
cat $CWD/extensions | while read extension revision ; do
if [ ! -r $extension-$revision.tar.gz ]; then
svn export -r $revision $SVN/mediawiki/trunk/extensions/$extension $extension
tar czf $extension-$revision.tar.gz $extension
fi
done
# Install shared files
mkdir -p $PKG/usr/share
cd $PKG/usr/share
@ -80,6 +89,14 @@ cd mediawiki
install -s -D -m 755 texvc $PKG/usr/bin/texvc
)
# Install extensions
cat $CWD/extensions | while read extension revision ; do
tar xf $CWD/$extension-$revision.tar.gz -C extensions
done
# Install unversioned extension makearticle
cp -r $CWD/makearticle extensions/makearticle
# Install documentation
mkdir -p $PKG/usr/doc/$NAME
mv COPYING CREDITS FAQ HISTORY INSTALL README RELEASE-NOTES UPGRADE docs \
@ -88,11 +105,6 @@ mv COPYING CREDITS FAQ HISTORY INSTALL README RELEASE-NOTES UPGRADE docs \
# Remove useless files and directories
rm -rf *.php5 cache images math
# Install extensions
for ext in $CWD/extensions/*.tar.gz ; do
tar xf $ext -C extensions
done
# Install helper script
install -m 755 $CWD/create-mwiki.sh $PKG/usr/bin/create-mwiki

6
n/mediawiki/texvc-fix-paths-i486.patch

@ -3,8 +3,8 @@
@@ -1,11 +1,11 @@
-let cmd_dvips tmpprefix = "dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
-let cmd_latex tmpprefix = "latex " ^ tmpprefix ^ ".tex >/dev/null"
+let cmd_dvips tmpprefix = "/opt/texlive/2010/bin/i486-linux/dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
+let cmd_latex tmpprefix = "/opt/texlive/2010/bin/i486-linux/latex " ^ tmpprefix ^ ".tex >/dev/null"
+let cmd_dvips tmpprefix = "/opt/texlive/2011/bin/i486-linux/dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
+let cmd_latex tmpprefix = "/opt/texlive/2011/bin/i486-linux/latex " ^ tmpprefix ^ ".tex >/dev/null"
(* Putting -transparent white in converts arguments will sort-of give you transperancy *)
-let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null"
+let cmd_convert tmpprefix finalpath = "/usr/bin/convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null"
@ -12,7 +12,7 @@
(* Note that IE have problems with such PNGs and need an additional javascript snippet *)
(* Putting -bg transparent in dvipng's arguments will give binary transparency *)
-let cmd_dvipng tmpprefix finalpath backcolor = "dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
+let cmd_dvipng tmpprefix finalpath backcolor = "/opt/texlive/2010/bin/i486-linux/dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
+let cmd_dvipng tmpprefix finalpath backcolor = "/opt/texlive/2011/bin/i486-linux/dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
exception ExternalCommandFailure of string

6
n/mediawiki/texvc-fix-paths-x86_64.patch

@ -3,8 +3,8 @@
@@ -1,11 +1,11 @@
-let cmd_dvips tmpprefix = "dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
-let cmd_latex tmpprefix = "latex " ^ tmpprefix ^ ".tex >/dev/null"
+let cmd_dvips tmpprefix = "/opt/texlive/2010/bin/x86_64-linux/dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
+let cmd_latex tmpprefix = "/opt/texlive/2010/bin/x86_64-linux/latex " ^ tmpprefix ^ ".tex >/dev/null"
+let cmd_dvips tmpprefix = "/opt/texlive/2011/bin/x86_64-linux/dvips -q -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^ ".ps"
+let cmd_latex tmpprefix = "/opt/texlive/2011/bin/x86_64-linux/latex " ^ tmpprefix ^ ".tex >/dev/null"
(* Putting -transparent white in converts arguments will sort-of give you transperancy *)
-let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null"
+let cmd_convert tmpprefix finalpath = "/usr/bin/convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null"
@ -12,7 +12,7 @@
(* Note that IE have problems with such PNGs and need an additional javascript snippet *)
(* Putting -bg transparent in dvipng's arguments will give binary transparency *)
-let cmd_dvipng tmpprefix finalpath backcolor = "dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
+let cmd_dvipng tmpprefix finalpath backcolor = "/opt/texlive/2010/bin/x86_64-linux/dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
+let cmd_dvipng tmpprefix finalpath backcolor = "/opt/texlive/2011/bin/x86_64-linux/dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
exception ExternalCommandFailure of string

Loading…
Cancel
Save