Skip to content

Latest commit

 

History

History
79 lines (44 loc) · 3.84 KB

README.rdoc

File metadata and controls

79 lines (44 loc) · 3.84 KB

Pgn Replay

PGN Replay is a Radiant extension that will embed some of the code necessary to replay a chess game from PGN (Portable Game Notation)

Dependencies

*Has only been tested with Radiant 0.81 May work with 0.7+, probably not with earlier versions. *Requires the ChessTempo javascript PGN Viewer. (See below for instructions on setting your layout up to use it)

Installation

To install this extension, run:

rake radiant:extensions:pgn_replay:update rake environment radiant:extensions:pgn_replay:migrate (replace “environment” above with the environment you’re installing it into – “production”, “test” or “development”.

Usage

In order to make use of this, you will first have to edit your page layout to load the Chess Tempo PGN Viewer. To do this, add these lines to the head of your layout:

<link type=“text/css” rel=“stylesheet” href=“chesstempo.com/css/board-min.css” /> <script type=“text/javascript” src=“chesstempo.com/js/pgnyui.js”></script> <script type=“text/javascript” src=“chesstempo.com/js/pgnviewer.js”></script>

This will load the basic files needed for the Chesstempo viewer.

Then in your page, use:

<r:pgn [option=“value” …] />

to randomly select from the PGN puzzles available for the page (“puzzle” value set to true). For a complete definition of the options and their default values see chesstempo.com/pgn-usage.html

For example:

<r:pgn boardName=“myPosition” />

will insert the PGN viewer into the element that has the id of “myPosition” and

<r:pgn boardName="myPosition" pieceSize="35" />

will insert the PGN viewer into that same element, but will also set the piece size to 35px.

If you do not supply an element id to “boardName” the extension will default to “positionA” for the boardName. By giving different boardName values to multiple uses of this tag, you can insert multiple instances of the pgn viewer into your page.

In addition, there are two options available if you want load a specific game into the viewer, rather than a random one:

<r:pgn game=“id” [.…] />

will load the game (or puzzle) identified by id number “id” and

<r:pgn tag=“tagValue” […] />

will load the game (or puzzle) identified by the tag “tagValue”.

Why the ChessTempo Viewer?

In a nutshell, because it’s currently the best of a bad lot. I’ve yet to find a javascript PGN player out there I really like, but this one is closest. The way it’s written and licensed prevents me from easily using it for a base or customizing it for this extension, but until I write a better one (project is underway, and will hopefully be finished by the time this extension reaches 1.0 status) I’m including it here.

None of the commercial chess database companies has a PGN Viewer that appears to be written by someone who understands either HTML/CSS or Javascript as they are used in web development today, and other systems require preprocessing the PGN file before embedding it on the page. (That in itself is not horrible, and in fact I’m considering adding the DGT flash-based veiwer to this as an option in a future version.) This one at least allows some control over what’s happening with the board and pieces, and allows you to replace the pieces and colors with ones that will fit with your site.

Revision History

*0.2 – Basic functionality complete *0.3 – Cleaned up javascript and added new options *0.4 – Added ability to pull by tag and by Game id

To Do

Since we’re early in the development of this extension, this is a long list, given in no particular order. Feel free to contact me with more.

*Eliminate the need to add other files into your layout *Find/Create a better PGN viewer that can be integrated into this *Add ability to select between different viewers (e.g., one for games, one for puzzles) *Add ability to select a group of games/positions for display

Feel free to chime in with other ideas.