[Plugin] Chessboard render plugin

 
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions
View previous topic :: View next topic  
Author Message
Afwas
Forum helper

Joined: 03 Jan 2007
Posts: 3559
Reputation: 28.7Reputation: 28.7Reputation: 28.7 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 63

PostPosted: Fri Aug 03, 2007 19:39    Post subject: [Plugin] Chessboard render plugin Reply with quote

Chessboard render plugin

Description

Chessboard render is a plugin for B2evolution blogs that converts FEN notation or an alternative 8×8-layout to a chessdiagram using XHTML with 8×8 images.

About

This plugin is made by vyvy at http://www.vyvy.org/. Originally he made a plugin for B2evo 0.9, but it was soon forgotten because it was not compatible with 1.6. Vyvy made ports for Drupal (can't find it anymore on that site) and Michael Arlt for DokuWiki. The plugin is based on replacement code in chessboard_render.php, a nice piece of programming skill. I made some minor changes. This is my second attempt getting it to work on B2evo. Now I succeeded. My motivation was the underlying code. It opens possibilities for look alikes like checkers and even card games.

Explanation

The plugin uses FEN syntax to describe a chess position. FEN stands for Forsyth-Edwards Notation. This is an example:

Code:
[chessboard]
# Byrne - Fisher (1956) Game of the Century
(BTRL)
r3r1k1/pp3pbp/1qp1x1p1/2B5/2BP2b1/Q1n2N2/P4PPP/3R1K1R
[/chessboard]


The numbers are empty squares, the letters represent pieces in English (King, Queen, Rook, Bisshop, Night, Pawn). Upper case letters are for the white pieces. Notation starts at a8 (upper left corner). The code in brackets is optional. This tells us to render borders at the Bottom, Top, Right and Left (all four). Comments are made on a line starting #.

This board may also have been described using an easier to understand 8x8 syntax. You use whatever suits you best.

Code:
[chessboard]
# Byrne - Fisher (1956) Game of the Century
(BTLR)
r---r-k-
pp---pbp
-qp-x-p-
--B-----
--BP--b-
Q-n--N--
P----PPP
---R-K-R
[/chessboard]


This is what it looks like when rendered:



Byrne - Fisher (1956) Black plays 17. ..., Be6 (x marks the spot), while the queen is hanging on b6. Not only does Fisher win, it is also shown it is the only move that doesn't loose in this position.

By playing with the options you can make subsets of the board. (TR4l) creats a four column board with two borders, Top and Right. The starting piece Top Left is white. We now have the top right corner of the board. If we inject:

Code:
r-k-
-pbp
x-p-
----


We get:



Notice that I added four rows in the code. If I added more rows, the table would have gotten larger but not wider.

Syntax

[chessboard]

Parameters (flags)

T -> Border Top (default: no border)
B -> Border Bottom
L -> Border Left
R -> Border Right
[1..8] -> Number of colums (default = 8)
l -> Starting with a light square (default)
d -> Starting with a dark square

Pieces - use lowercase for black and uppercase for white

P / p -> Pawn
R / r -> Rook
N / n -> Knight
B / b -> Bishop
Q / q -> Queen
K / k -> King
x -> empty square with X
- or [1..8] -> empty square


Lay out

You can make a different set of images. You need to give them the same filename though. If you keep this set in a different folder, you can enable this new set by pointing to the new map (change path) in the edit section of the plugin.
If you need to layout the images, the all have the same class attribute: chessboard. In your css you can call them through:

Code:
img.chessboard{
border: 0;
}


Licence

The code for chessboard_render.php is licenced under GNU GPL2.

Download

Version 2.1 beta: Stable, added image path options. Needs testing for functions and errors. Tested in B2evo 1.8.7, 1.9.3, 1.10.2 & 2.0 a.
Version 2.0 alpha: Working and stable, not completed.


Install

Download the zipfile, open it and place it in the ../blog/plugins/ folder. It should now show in the backoffice (Global settings -> Plugins) Click Install new and choose Chessboard render. Now click the edit button or the link in the name to go to the control panel of the plugin. Here you can change the path setting.

Support

If you have questions or find some unexpected behaviour, post in the Plugins & Extentions section of the B2evolution forum. I will take it on from there.
If for whatever reason I changed some code and forgot to update this reader, this is the entry in my blog about this plugin. You can leave a comment there if you wish.

Final remarks

I hope I get at least a few serious downloads and people actually using it and writing in there blogs about chess. If not, that's fine with me too. I enjoyed (re-)writing the plugin and learned some interesting stuff. B2evolution rules.

_________________

Join us at irc://irc.freenode.net#B2evolution
More B2evo goodies at http://www.blog.hemminga.net
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions All times are GMT - 5 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board