Mediawiki konfigurieren

Aus Wiki.csoft.at

(Unterschied zwischen Versionen)
(Weblinks)
Zeile 189: Zeile 189:
  $wgUseTeX                = true;
  $wgUseTeX                = true;
 +
 +
cp /root/.texmf-var/web2c/latex.fmt $wgTmpDirectory
* [[Math]]
* [[Math]]

Version vom 21. Februar 2010, 05:23 Uhr

Siehe die Dokumentation zur Anpassung der Benutzeroberfläche und das Benutzerhandbuch für Hilfe zur Benutzung und Konfiguration.

vi LocalSettings.php

Inhaltsverzeichnis

Logo ändern

$wgLogo             = "/images/2/25/Site-Logo.gif";

Csoftquirl.gif

Uploads erlauben

$wgEnableUploads                = true;

File Extensions

$wgFileExtensions = array('gif', 'png', 'jpg', 'jpeg', 'pdf', 'doc', 'xls', 'ppt', 'ogg', 'mp3');

Pluszeichen im Artikel erlauben

$wgLegalTitleChars = " +%!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF";

Anonymes Anlegen von Benutzern verboten

# This snippet prevents new registrations from anonymous users
# (Sysops can still create user accounts)
$wgGroupPermissions['*']['createaccount'] = false;

Nur eingeloggte User können editieren

# This snippet prevents editing from anonymous users
$wgGroupPermissions['*']['edit'] = false;

# This will still allow logged in users to edit
$wgGroupPermissions['user']['edit'] = true;

Enable logging

# Logging
# $wgDebugLogFile = "/tmp/wiki.log";

Disable Caching

If you want to test changes to the server just by hitting "Reload" in your browser, add "?action=purge" to the end of the URL.

Or edit your LocalSettings.php:

/** Allow client-side caching of pages */
$wgCachePages       = false;

Disable rel="nofollow"

$wgNoFollowLinks = false;

How do I remove the "edit" "discussion" and other tabs on my site for users that are not logged in?

Edit the file /includes/SkinTemplate.php. Find the function buildContentActionUrls(). A few lines into it you'll find

if( $this->iscontent ) {

Modify this to read

if( $wgUser->getId() != 0 && $this->iscontent ) {

How to just remove the section "edit" link for non-logged in users only

In the file includes/Skin.php, replace

if( !$wgUser->getOption( 'editsection' ) ) {
			$s .= ".editsection { display: none; }\n";
		}
 

By this piece of code.

 if( !$wgUser->getId() || !$wgUser->getOption( 'editsection' ) ) {
 $s .= ".editsection { display: none; }\n";
 }
 

Where the bit

!$wgUser->getId() ||

enables to identify that the user id registered.

Creating a Skin based on MonoBook (1.6.x)

This may or may not be the right way to do this. I've only tested this on 1.6.x and so far, seems to do the trick for me. Of course this is if you want to use MonoBook as your base, which is probably what you want. So assuming your Mediawiki instance is on a UNIX machine and would like to create a new skin called "FooBar" you would do:

cd /path/to/mediawiki/
cp skins/MonoBook.php skins/FooBar.php
cp -R skins/monobook skins/foobar
vi skins/FooBar.php

FIND:

class SkinMonoBook extends SkinTemplate {
       /** Using monobook. */
       function initPage( &$out ) {
               SkinTemplate::initPage( $out );
               $this->skinname  = 'monobook';
               $this->stylename = 'monobook';
               $this->template  = 'MonoBookTemplate';
       }
}

REPLACE WITH:

class SkinFooBar extends SkinTemplate {
       /** Using foobar. */
       function initPage( &$out ) {
               SkinTemplate::initPage( $out );
               $this->skinname  = 'foobar';
               $this->stylename = 'foobar';
               $this->template  = 'FooBarTemplate';
       }
}

FIND:

class MonoBookTemplate extends QuickTemplate {

REPLACE WITH:

 class FooBarTemplate extends QuickTemplate {

FIND:

wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );

REPLACE WITH:

wfRunHooks( 'FooBarTemplateToolboxEnd', array( &$this ) );

Your skin is now ready to be plugged in and modified. At this point you can zip up your FooBar.php and foobar directory and consider it a bootstrap for any forthcoming skins you might want to create.

Next up is your Mediawiki configuration. We need to modify your LocalSettings.php file, changing the default skin to your new one...

cd /path/to/mediawiki/
vi LocalSettings.php

FIND:

$wgDefaultSkin = 'monobook';

REPLACE WITH:

$wgDefaultSkin = 'foobar';

Make sure this line isn't commented out either! Remember to clear your browser cache and hit reload. View page source and search for your new style name (FooBar, foobar), namely the CSS paths.

vi includes/Skin.php
       function getPoweredBy() {
               global $wgStylePath;
               $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
               $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
               return $img;
       }

www.csoft.at

Copyright-Icon

vi includes/Skin.php
       function getCopyrightIcon() {
               global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
               $out = ;
               if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
                       $out = $wgCopyrightIcon;
               } else if ( $wgRightsIcon ) {
                       $icon = htmlspecialchars( $wgRightsIcon );
                       if ( $wgRightsUrl ) {
                               $url = htmlspecialchars( $wgRightsUrl );
                               $out .= '<a href="'.$url.'">';
                       }
                       $text = htmlspecialchars( $wgRightsText );
                       $out .= "<img src=\"$icon\" alt='$text' />";
/**
$out = "<img src=\"/images/poweredby.gif\">";
*/                       
                       if ( $wgRightsUrl ) {
                               $out .= '</a>';
                       }
               }
               return $out;
       }

Math Support

cd ~/math
make
$wgUseTeX                = true;
cp /root/.texmf-var/web2c/latex.fmt $wgTmpDirectory

Parser Extensions

Cite.php

cd ~/extensions
wget http://wikipedia.cvs.sourceforge.net/*checkout*/wikipedia/extensions/Cite/Cite.php
vi LocalSettings.php
require_once( "extensions/Cite.php" );

inputbox.php

cd ~/extensions
wget http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/inputbox/inputbox.php
vi LocalSettings.php
require_once("extensions/inputbox.php");

Amazon Extension

This (simple) extension could be used for your booksources response page to offer the requested books via amazon.

The extension will output the given Amazon Affiliate Code.

Create a new file in your extensions folder, named "Amazon.php" with the following content:

<?php
# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/Amazon.php");

$wgExtensionFunctions[] = "wfAmazon";

function wfAmazon() {
    global $wgParser;

    $wgParser->setHook( "amazon", "renderAmazon" );
}

# The callback function for converting the input text to HTML output
function renderAmazon( $input ) {
    # Your Amazon Partner ID    # <<<<< EDIT HERE <<<<<
    $partner = "EDIT HERE";

    # Building the code
    $output = "<iframe src='http://rcm-de.amazon.de/e/cm?t=$partner&o=3&p=8&l=as1&asins=$input&fc1=000000&IS2=1&lt1=_blank&lc1=0000ff&bc1=000000&bg1=ffffff&f=ifr' style='width:120px;height:240px;' scrolling='no' marginwidth='0' marginheight='0' frameborder='0'></iframe>";

    return $output;
}
?>

Give your Amazon Affiliate Partner ID to the variable $partner ("EDIT HERE").

If you want to use other code than this, replace it, but remember to replace your partner id in the amazon code with the variable $partner and most important replace the ISBN (ASIN) with the variable $input.

Open your LocalSettings.php, and insert at the end of file:

include("extensions/Amazon.php"); 

You can then create a page Project:Booksources (The Booksources must be replaces with the translated word of your site language; "Buchhandlungen" for example in german MediaWikis) with the following content:

{{MediaWiki:Booksourcetext}}

<amazon>MAGICNUMBER</amazon>

Afterwards the call to Special:Booksources/ISBNNUMBER will end up to the above mentioned page with same layout as the original but displaying your amazon affilate code.

Siehe auch

Weblinks