Integrating The World Exits Page With A Mud Client

Hai-Etlik/Tarnal has created the following and posted it on Tazliel’s forum (registration seems to be required, unfortunately). Reposting here so it can be edited more easily to adjust for layout changes in world exits. Garg made a new XSL stylesheet that works with the new world exits page layout, reproduced below in place of the old one.

Concept

The basic idea is to fetch the current world exits page e. g. via wget and to pipe it to xsltproc, which applies the stylesheet given below as transport.xsl to that page to produce a compact table for a given planet. In TinyFugue, the definition

/def wexits = /quote -S -dexec /echo -p !~/retro/scripts/wexits.sh

yields a macro that can be called as /wexits. Similar definitions should be possible in any other client that can call an external program and read its output.

Setup

The assumed path layout is that you have wexits.sh and transport.xsl in retro/scripts in your home directory. This is trivial to adjust.

As given, these files expect you to have wget and the xsltproc program from libxslt. Linux users will likely already have them. Windows ports are available for wget and libxslt, too.

wexits.sh

This is a convenience wrapper for the stylesheet file below. It’s a Bourne shell script; if you’re using Windows, and/or using something other than wget to fetch URLs, feel free to submit your version.

#!/bin/sh
 
URL="http://retrowiki.wikidot.com/world-exits"
 
wget -q -O- $URL |xsltproc -stringparam planet "$1" ~/retro/scripts/transport.xsl -

transport.xsl

This file has fairly rigid expectations of the layout of the world exits page. If that changes, it’ll need to be adjusted.

<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:stylesheet xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
<xsl:output method="text"/><xsl:template match="/">+-----+-----+-----+-----+
<xsl:for-each select="//html:table[1]">
<xsl:for-each select=".//html:tr[./html:td]">
<xsl:variable name="planet"><xsl:value-of select="substring(.//html:td[1],1,3)"/></xsl:variable>
<xsl:variable name="shaft"><xsl:value-of select=".//html:td[2]"/></xsl:variable>
<xsl:variable name="statue"><xsl:value-of select=".//html:td[3]"/></xsl:variable>
<xsl:variable name="ship"><xsl:value-of select=".//html:td[4]"/></xsl:variable>
<xsl:choose>
<xsl:when test="'Cry'=$planet">| <xsl:value-of select="$planet"/> |  -  | <xsl:value-of select="$statue"/> | <xsl:value-of select="$ship"/> |
</xsl:when>
<xsl:when test="'Per'=$planet">| <xsl:value-of select="$planet"/> |  <xsl:value-of select="$shaft"/>  | <xsl:value-of select="$statue"/> | <xsl:value-of select="$ship"/> |
</xsl:when>
<xsl:when test="'Raj'=$planet">| <xsl:value-of select="$planet"/> |  <xsl:value-of select="$shaft"/>  | <xsl:value-of select="$statue"/> | <xsl:value-of select="$ship"/> |
</xsl:when>
<xsl:when test="'Sos'=$planet">| <xsl:value-of select="$planet"/> |  <xsl:value-of select="$shaft"/>  | <xsl:value-of select="$statue"/> | <xsl:value-of select="$ship"/> |
</xsl:when>
<xsl:when test="'Wel'=$planet">| <xsl:value-of select="$planet"/> |  <xsl:value-of select="$shaft"/>  |  -  | <xsl:value-of select="$ship"/> |
</xsl:when>
<xsl:when test="'Wys'=$planet">| <xsl:value-of select="$planet"/> |  <xsl:value-of select="$shaft"/>  | <xsl:value-of select="$statue"/> |  -  |
</xsl:when><xsl:otherwise/></xsl:choose></xsl:for-each></xsl:for-each>+-----+-----+-----+-----+
</xsl:template>
</xsl:stylesheet>
Except where stated otherwise, content is © 2007–2008 RetroWIKI contributors, all rights reserved. Content from the RetroMUD game or the retromud.org website is © 1994–2008 RetroMUD and/or RetroMUD staff, used here only for commentary, without permission.