Eressea:Anleitung (PDF)

Aus Eressea
Zur Navigation springenZur Suche springen

Ich hätte aus verscheidenen Gründen gerne wieder eine Anleitung als PDF, und dafür habe ich einen Exporter installiert in Spezial:Wiki2XML. Der funktioniert aber nur leidlich, und das Resultat muss hinterher noch gehübscht werden, fürchte ich.

Option XML

Funktioniert derzeit am Besten.

  1. Artikelliste erstellen (siehe unten)
  2. Nach Spezial:Wiki2XML
  3. Optionen: "A list of articles", "Use Api" abwählen(!), Output: "XML"
  4. Das kann man dann per PHP-Skript und #XSLT-Skript nach HTML konvertieren.
  5. Dann muss man noch die Bilder runterladen und ins Unterverzeichnis "img" kopieren.
  6. Ergebnis: http://dl.dropbox.com/u/4834713/rules.zip

Option OpenOffice ODT

Erstes Beispiel (es ist derzeit nicht erlaubt, PDF-Dateien hochzuladen): [1]

Schritte, um das Ding nutzbar zu machen:

  1. Artikelliste erstellen
  2. Das verwendete Template anpassen
  3. Ein OpenOffice Dokument erstellen, und anschliessend von Hand nachpflegen.
    • HTML-Tags werden nicht richtig geparst (Beispie: br-Tag zu Beginn von BENENNE
    • Verbose-(oder tt-?)Tags werden nicht richtig geparst (Beispiel: Ende von BENENNE)
    • Bilder werden nicht exportiert (Beispiel: Welt)
    • Templates werden nicht übernommen (Beispiel: Spielererfahrung am Ende von "Welt")
    • Formatierung von Tabellen
    • An zu vielen Stellen werden neue Seiten angefangen.
  4. PDF davon erstellen.

Option DocBook *

Wird derzeit mit Fehlermeldung quittiert:

 Warning: mkdir() [function.mkdir]: No such file or directory in /home/eressea/www/mediawiki-1.15.1/extensions/wiki2xml/mediawiki_converter.php on line 261


Artikelliste

Es folgt eine Artikelliste für das Formular:

Eressea:Regelübersicht

Regeln
Einleitung
Welt
Parteien
Einheiten
Rassen
Talentmodifikatoren

Talente
Tarnung
Wahrnehmung

Reisen
Pferd und Wagen
Schiffsreise
Produktion
Rohstoffe
Waren
Straße
Schiff
Gebäude
Burg
Andere Gebäude
Geld
Einnahmen
Ausgaben
Hunger
Handel
Krieg
Belagerung
Kampfseite
Schlacht
Musterung
Kampf
Boni und Mali
Die Flucht
Kampf auf Schiffen
Piraterie
Kampfende
Kriegstabellen
Allianz
Magie
Magiegebiete
Tränke
Dumpfbackenbrot
Kräuter

Befehle
Kurzbeschreibung
Befehlsreihenfolge
;
//
ARBEITE
ARBEITEN
ATTACKIERE
BANNER
BEANSPRUCHE
BEFÖRDERUNG
BEKLAUE
BELAGERE
BENENNE
BENUTZE
BESCHREIBE
BETRETE
BEWACHE
BOTSCHAFT
DEFAULT
EINHEIT
EMAIL
ENDE
ERESSEA
FAHRE
FOLGE
FORSCHE
GIB
GRUPPE
HELFE
KAMPFZAUBER
KAUFE
KOMMENTAR
KONTAKTIERE
KÄMPFE
LEHRE
LERNE
MACHE
NACH
NEUSTART
NUMMER
NÄCHSTER
OPTION
PASSWORT
PFLANZE
PIRATERIE
PRÄFIX
REGION
REKRUTIERE
RESERVIERE
ROUTE
SABOTIERE
SORTIERE
SPIONIERE
STIRB
TARNE
TRANSPORTIERE
TREIBE
UNTERHALTE
URSPRUNG
VERGESSE
VERKAUFE
VERLASSE
ZAUBERE
ZEIGE
ZERSTÖRE
ZÜCHTE

Danksagung
Xontormia-Express
Technische Daten
Anmelden wie?
Hinweise
Hilfsmittel
CSMap
ECheck
EHMV
Magellan
Vorlage
Befehle einschicken
Eingabe
Fehler im Spiel
Bugreport
Schummeln
Nachfordern
Mailinglisten
Fragen

Anhang
Liste der Talente
Tabellen: Tränke und Kräuter
Allgemeine Tabellen
Geländearten
Gebäude
Schiffe
Waren
Kampfmodifikatoren


Apokryphen
Anfängertipps
Tipps und Tricks
Parteipool
Weihnachten
Mistelzweig
Adamantium
Adamantiumrüstung
Sonnensegel
Schneemann
Sternenstaub
Weihnachtsbaum
Monster
Drachen
Untote
Bauernvermehrung
Bauernwanderung
Bewaffnet
Taktik


PHP-Postprocessing

Um ein paar Probleme mit dem XML von Wiki2XML zu beheben ruft man dieses Skript auf:

 php postprocesswikixml.php exported.xml exported.pp.xml
postprocesswikixml.php
?php

$DEBUG = 2;

// check parameters

if (count($argv) != 3) {
  print <<<EOF
Usage: postprocesswikixml <inputfile> <outputfile>

EOF;
  exit();
 }

if ($DEBUG > 1) {
  echo "called ";
  for ($i = 0; $i < count($argv); $i++)
    echo $argv[$i]." ";
  echo "\n";
 }

// process arguments
$inputfile = $argv[1];
$outputfile = $argv[2];

if ($DEBUG > 0) {
  echo "converting ".$inputfile."\n";
 }

if (!is_file($inputfile)) {
  exit ("Couldn't open $inputfile");
 }

$inFile = fopen($inputfile, "r");

if (!$inFile) {
  exit ("Could not open input file $inputfile\n");
 }

$outFile = fopen($outputfile, 'w');

if (!$outFile) {
  echo "Cannot open output file ($currentfile)\n";
  exit;
 }

$dateline= "<date>".date(DATE_RFC822)."</date>";

while(!feof($inFile)) {
  $line = fgets($inFile);
  // get rid of things like Seite%20Eins
  $line = urldecode($line);
  // fix illegal namespace declaration. I don't know where the right one is...
  $line = preg_replace("/xmlns:xhtml=\" \"/", "xmlns:xhtml=\"http://foo.org\"", $line);
  // insert a date tag
  $line = preg_replace("/[<]articles [^>]*[^\/][>]/", 
		       "$0\n".$dateline, $line);
  // add newline before article tags for better readability
  $line = preg_replace("/[<]article/", 
		       "\n$0", $line);
  fwrite($outFile, $line);
 }

fclose($outFile);

fclose($inFile);

?>

XSLT-Skript

Um die per PHP-Skript bearbeitete Datei nach HTML zu konvertieren. Aufruf:

 xsltproc eresseawiki2html.xsl exported.pp.xml > rules.html
eresseawiki2html.xsl

<pre-xml> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://foo.org" extension-element-prefixes ="xhtml" exclude-result-prefixes="xhtml"> <xsl:namespace-alias stylesheet-prefix="xhtml" result-prefix="#default" /> <xsl:output method="xml" indent="no"/> <xsl:preserve-space elements="*" /> <!-- HEADER --> <xsl:template match="/" xml:space="preserve"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="eresseawiki.css" /> </head> <body> <div id="header"><div class="marginframe"> <h1>Eressea Regeln</h1> </div></div> <xsl:apply-templates /> </body> </html> </xsl:template> <!-- ROOT ELEMENT --> <xsl:template match="articles" xml:space="preserve"> <div id="date">processed: <xsl:value-of select="date" /></div> <div id="navigation"><div id="nav-margin" class="marginframe"> <xsl:apply-templates select="article[1]" /> </div></div> <div id="content"><div class="marginframe"> <xsl:apply-templates select="article[position()>1]" /> </div></div> </xsl:template> <!-- ARTICLE --> <xsl:template match="articles/article" xml:space="preserve"> <a name="{@title}"/><h2><xsl:value-of select="@title"/></h2> <xsl:apply-templates /> </xsl:template> <!-- HEADINGS --> <xsl:template match="heading"><xsl:text> </xsl:text><xsl:if test="@level=2"> <a name="{.}"/><h3><xsl:apply-templates /></h3> </xsl:if> <xsl:if test="@level=3"> <h4><xsl:apply-templates /></h4> </xsl:if> <xsl:if test="@level=4"> <h5><xsl:apply-templates /></h5> </xsl:if> <xsl:if test="@level=5"> <h6><xsl:apply-templates /></h6> </xsl:if> <xsl:if test="@level=6"> <h7><xsl:apply-templates /></h7> </xsl:if><xsl:text> </xsl:text></xsl:template> <!-- <p> --> <xsl:template match="//paragraph" xml:space="preserve"> <p><xsl:apply-templates /></p> </xsl:template> <!-- LINKS --> <xsl:template match="//link"> <xsl:if test="@type='external'"> <a> <xsl:attribute name="href"> <xsl:value-of select="@href" /> </xsl:attribute> <xsl:apply-templates /> </a> </xsl:if> <xsl:if test="not(@type='external')"> <xsl:if test="./part!=''"> <a> <xsl:attribute name="href"> <xsl:text>#</xsl:text><xsl:value-of select="./target" /> </xsl:attribute><xsl:value-of select="./part" /> </a> </xsl:if> <xsl:if test="not(./part!='')"> <xsl:if test="substring-before(./target,':')='Bild'" xml:space="default"> <img> <xsl:attribute name="alt"> <xsl:value-of select="target" /> </xsl:attribute> <xsl:attribute name="src"> img/<xsl:value-of select="substring-after(./target,':')" /> </xsl:attribute> </img> </xsl:if> <xsl:if test="not(substring-before(./target,':')='Bild')"> <a> <xsl:attribute name="href"> <xsl:text>#</xsl:text><xsl:value-of select="target"/> </xsl:attribute> <xsl:value-of select="target" /> </a> </xsl:if> </xsl:if> </xsl:if> </xsl:template> <!-- SOME MORE SIMPLE ELEMENTS --> <xsl:template match="//space"> <xsl:text> </xsl:text> </xsl:template> <xsl:template match="//bold"> <b><xsl:apply-templates /></b> </xsl:template> <xsl:template match="//italics"> <i><xsl:apply-templates /></i> </xsl:template> <xsl:template match="//hr" xml:space="preserve"> <hr /> </xsl:template> <!-- LISTS --> <xsl:template match="//list"> <xsl:if test="@type='def'"><xsl:text> </xsl:text><dl><xsl:for-each select="listitem/defkey" > <dt><xsl:apply-templates /></dt><xsl:text> </xsl:text></xsl:for-each> <xsl:for-each select="listitem/defval" > <dd><xsl:apply-templates /></dd><xsl:text> </xsl:text></xsl:for-each> </dl><xsl:text> </xsl:text></xsl:if> <xsl:if test="@type='ident'"> <xsl:for-each select="listitem"> <dl><xsl:text> </xsl:text><dd><xsl:apply-templates /></dd><xsl:text> </xsl:text></dl> </xsl:for-each> </xsl:if> <xsl:if test="@type='bullet'"> <ul><xsl:text> </xsl:text><xsl:for-each select="listitem"> <li><xsl:apply-templates /></li><xsl:text> </xsl:text></xsl:for-each> </ul><xsl:text> </xsl:text></xsl:if> <xsl:if test="not(@type='ident') and not(@type='bullet') and not(@type='def')"> <ul><xsl:text> </xsl:text><xsl:for-each select="listitem"> <li><xsl:apply-templates /></li><xsl:text> </xsl:text></xsl:for-each> </ul><xsl:text> </xsl:text></xsl:if> </xsl:template> <xsl:template match="defkey"> <dt><xsl:apply-templates /></dt> </xsl:template> <xsl:template match="listitem"> <xsl:if test="../@type='ident'"> <xsl:apply-templates /> </xsl:if> <xsl:if test="not(../@type='ident')"> <li><xsl:apply-templates /></li> </xsl:if> </xsl:template> <!-- TABLES --> <xsl:template match="//table" xml:space="default"><xsl:text> </xsl:text><table><xsl:for-each select="attribute::*"> <xsl:attribute name="{name(.)}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:for-each><xsl:text> </xsl:text><xsl:apply-templates /><xsl:text> </xsl:text></table> </xsl:template> <xsl:template match="//tablecaption" xml:space="default"><xsl:text> </xsl:text><caption> <xsl:for-each select="attribute::*"> <xsl:attribute name="{name(.)}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:for-each> <xsl:apply-templates /> </caption> </xsl:template> <xsl:template match="//tablehead" xml:space="default"><xsl:text> </xsl:text><th> <xsl:for-each select="attribute::*"> <xsl:attribute name="{name(.)}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:for-each> <xsl:apply-templates /> </th> </xsl:template> <xsl:template match="//tablerow" xml:space="default"><xsl:text> </xsl:text><tr> <xsl:for-each select="attribute::*"> <xsl:attribute name="{name(.)}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:for-each> <xsl:apply-templates /> </tr> </xsl:template> <xsl:template match="//tablecell" xml:space="default"><xsl:text> </xsl:text><td> <xsl:for-each select="attribute::*"> <xsl:attribute name="{name(.)}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:for-each> <xsl:apply-templates /> </td> </xsl:template> <!-- <pre> TAGS --> <xsl:template match="//preblock" xml:space="default"> <div class="preblock"><pre><xsl:apply-templates /></pre></div> </xsl:template> <xsl:template match="//preblock//preblock" xml:space="default"> <xsl:apply-templates /> </xsl:template> <xsl:template match="//preblock//paragraph" xml:space="default"> <xsl:apply-templates /> </xsl:template> <xsl:template match="//preline" xml:space="default"> <xsl:apply-templates /><xsl:text> </xsl:text> </xsl:template> <!-- XHTML TAGS --> <xsl:template priority="1" match="//xhtml:div" xml:space="default"> <div> <xsl:for-each select="attribute::*"> <xsl:attribute name="{name(.)}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:for-each> <xsl:apply-templates /> </div> </xsl:template> <xsl:template priority="1" match="//xhtml:*" xml:space="default"> <xsl:element name="{substring-after(name(.),':')}" > <xsl:apply-templates /> </xsl:element> </xsl:template> <!-- EXTENSIONS? NOWIKI is the only known one --> <xsl:template match='//extension'> <xsl:if test="@extension_name!='nowiki'"> <xsl:message>unknown extension <xsl:value-of select="@extension_name" /></xsl:message> <xsl:apply-templates /> </xsl:if> </xsl:template> <!-- CATCHALL --> <xsl:template priority="0" match="//*"> <xsl:message>unknown node <xsl:value-of select="name(.)" /></xsl:message> <xsl:comment>unknown</xsl:comment><xsl:copy-of select="*"/> </xsl:template> </xsl:stylesheet> </pre-xml>