Software | |
Preparing your environment for SGF |
This document will explain you how you can automatically launch your favorite game browser when you fetch go games from this WWW site. The document will also explain how to set up your http server to provide a similar service for your customers.
An overview of the topics:
The mime
type is what a webserver attaches to data
to enable clients (Firefox, Opera, Internet Explorer, ...)
to clearly recognise the kind of data and enable them to take the
appropriate actions to visualize it. For example, HTML pages
are emitted with mime type
text/html
,
plain text with mime type
text/plain
,
PostScript with mime type
application/postscript
,
and gif images with mime type
image/gif
.
To enable your browser to recognise electronic Go games this server emits game records with a special mime type (of course choosen carefully to make it differently from any other mime type which you will ever encounter on the web):
application/x-go-sgfThe leading
x-
denotes that this mime
type is not officially registered (trying to register it would only
have a small chance to be accepted since the general applicability
of the mime type is rather limited as go players will realize).
Your can instruct your software which you use to read mail, news or browse the web what to do with documents which have special mime types. The default action for unknown (unmapped) mime types is to display the contents of the file as text in the browser window or to prompt the user where to save the data on disk.
However, in general you prefer to automatically start up a dedicated program to deal with the incoming data in a more sophisticated way (like starting up an sgf editor for go games).
To configure your UNIX environment (I will deal with Windows in a minute) and in particular your web browser for the mime type attached to the go games there is only one thing you need to do. Add the following line to the file ${HOME}/.mailcap:
application/x-go-sgf; /path-to/showsgf %s(Please note the semi-colon after the mime type.)
This line requests your mime type aware software (like your browser)
to start up /path-to/showsgf
to visualize
application/x-go-sgf
data (with the
filename as command line argument).
Of course you would adjust the exact location of the
showsgf
shell script to suit
it to your particular situation.
If you are on a Windows platform or if you are running Netscape-4.0 or newer then you can configure the mime-type handling for Go games within Netscape:
application/x-go-sgf
sgf
Next, mark the line with Application and enter the path to
your SGF editor program and add a space plus the string "%s
"
on UNIX systems or "%1
" on Window systems:
/path-to/sgfeditor %s
/path-to/sgfeditor %1
This requests that the browser will start up the application and
pass it the SGF game record ("%s
" or "%1
").
If your SGF editor has special flags to specify the SGF game
record then you should add them. For example, the UNIX program
cgoban needs the "-edit" flag so the Application line would then read:
/path-to/cgoban -edit %s
Please consult your local webmaster for any further support in case you need it.
After you have added the above line (and forced your browser to
reload the .mailcap
file, either by the supplied
interface or by restarting the browser) you can preview the game
below on your screen just by clicking it, try it!
IGS-94 tournament:
jiroo-jansteen
An interesting game featuring the rare (6,3) opening
and lots of fighting.
The way to accomplish that a web server emits groups of files with a special mime type usually is simple. The procedure explained here is valid for the NCSA httpd and Apache compatible servers. In case you are running another server please check the documentation coming with that server first.
The procedure:
.sgf
).
application/x-go-sgf
).
You can accomplish this in two ways:
mime.types
which is
read by the httpd server during startup:
application/x-go-sgf sgf
mime.types
file you can send
the parent httpd a HUP
signal (kill -1)
or execute the Apache startup script apachectl
with the argument restart
.
.htaccess
located in the same
directory where the datafiles are located or in one of its
parent directories:
AddType application/x-go-sgf sgf
Both methods bind data files ending in suffix
.sgf
to mime type
application/x-go-sgf
.
While Go games received from this site using the http:URL
service have the application/x-go-sgf
mime type attached to them things are slightly different when you use
the file:URL
service to load local games into your browser
(since in that case no http server is serving the files).
However, it is easy to also get this case right. Simple add the following
line to the file named ${HOME}/.mime.types
:
application/x-go-sgf sgf
${HOME}/.mime.types
file
during startup.
As a nice side effect your mailer, news-poster and possibly some other communication software might import go game files automatically using encapsulation techniques as displayed here:
-- encapsulated Content-Type: application/x-go-sgf ( ; PB[Takemiya Masaki] PW[Cho Chikun] ... ) -- encapsulated --
This syntax allows the software which is used to read this mail to spawn a go game viewer with the game data as input.