Wikipedia talk:WikiProject Chess/PGN Chess Viewer

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is the talk page for the PGN Chess Viewer project.[edit]

Discussion[edit]

I guess I'll be the first to comment here and get the ball rolling. The way I envision this project working is in two, possibly three parts. The first part would be a static template to create a table and environment for this content to display. I will create a mockup starting point for what I have in my head of this on WP:WikiProject Chess/PGN Chess Viewer/Template:PGN-CV/T13. Some of this may possibly be manipulated/created for those without JavaScript or with the gadget not activated by a lua module. I don't know much about lua modules at this time but if I find that the template is difficult to create without certain extensions (like stringFunctions), then I'll learn more about the modules for this purpose. If I need to write our own module for something specific I will put it in WP:WikiProject Chess/PGN Chess Viewer/Module:PGN-CV/T13. The last part will be the JavaScript gadget. I'll start with a copy & paste of the he version (WP:WikiProject Chess/PGN Chess Viewer/PGN-CV/T13.js), and then start adapting it to work with my template/module as is needed. User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 11:40, 29 March 2013 (UTC)[reply]

Sorry I thought I was being all smart. Mattj2 (talk) 17:27, 29 March 2013 (UTC)[reply]
LOL No problem. User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 17:34, 29 March 2013 (UTC)[reply]
For the future, that's a good thing to post on my personal talk page. It was an honest mistake but I wouldn't have realized if I hadn't happened to reload the page. No reason to have you be upset when I was clearly at fault. Mattj2 (talk) 17:45, 29 March 2013 (UTC)[reply]
things happen... Also, I've played this game before, I'm really not upset or worried about it what-so-ever. So, I'm just going to ignore you if you apologize again. User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 17:49, 29 March 2013 (UTC)[reply]
Mattj2 (talk) 18:38, 29 March 2013 (UTC)[reply]

Some explanation of the technical side and the script output:

yes, there is a table, but it's not used to display the game itself. it used to locate the game selector on top, the PGN on the right, the Tags on the left, the game in the middle and the buttons below. The game itself is displayed by drawing a naked chess board (File:Chessboard480.png), sucking the pieces image urls through the API, and drawing the pieces on top of the board, with position:absolute. so the whole thing looks something like this:

header (if there is any) with game selector
Event: Semmering/Baden

Site: Semmering
Date: 1937.??.??
Round: 14
White: Capablanca, Jose Raul
Black: Keres, Paul
Result: 1/2-1/2
ECO: D18

1. c4 c6 2. d4 d5 3. Nf3 Nf6 4. Nc3 dxc4 5. a4 Bf5 6. e3 e6 7. Bxc4 Nbd7 8. Qe2 Bb4 9. O‑O Ne4 10. Nxe4 Bxe4 11. Bd3 Nc5 12. Bxe4 Nxe4 13. Qc2 Qd5 14. Ne5 O‑O 15. f3 Nc5 16. Nc4 b5 17. axb5 cxb5 18. Bd2 Bxd2 19. Nxd2 Na4 20. Rfe1 h6 21. b3 Nb6 1/2‑1/2
buttons and controls

(for simplicity i omitted the row numbers (1-8) and the file letters (a-h). they are drawn with the board)

in order to help some chess editors, i also taught the script to squirt out a {{Chess diagram}} for any specific state of the game, or many diagrams for the whole game. this is done by including some secret magic incantation in your personal common.js (the incantation is window.makeChessTemplate = 1;. if anyone wants to try it, do it on hewiki. you can set your language to english in preferences to make navigating in hewiki a bit easier. this incantation will cause the script to grow two new buttons: T and TT, which pop a dialog with the appropriate code for {{Chess diagram}}, or rather, the hebrew version of it).

the reason "Table" is used is because my html/css-fu is not strong enough to build it with Divs, but Unlike {{Chess diagram}}, the table is not used to draw the chess board itself, or to place the pieces (i wouldn't even know how to animate moving a piece from one table cell to another). peace - קיפודנחש (aka kipod) (talk) 23:59, 29 March 2013 (UTC)[reply]

I'm not too fond of this layout. Can it be made to look more like my template example? User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 00:10, 30 March 2013 (UTC)[reply]
can you point to said "template example"? also please note that this layout was not the original one: i arrived at this layout after numerous comments, requests and constructive criticism from other users, so i'm not very likely to change it radically based on a single user's input. small tweaks are something else, but major changes only make sense if there is broader consensus that they represent improvement.
i urge you to look at the actual thing. you can find an example in he:User:קיפודנחש/ארגח 1. peace - קיפודנחש (aka kipod) (talk) 02:45, 30 March 2013 (UTC)[reply]
ok, i think i found "your template". please forgive the bluntness, but this is just silly.
every chess aficionado is very used to look at chess games in PGN form. this is how they it appear in books, newspapers, magazines, websites and in numerous articles in wikipedia. every other chess-game viewer application shows you the PGN.
it can be argued that breaking it to "player1" and "player2" would make sense, but this argument's time was in the distant past. of course we should show the PGN and not break it to "player1" and "player2". you don't have to take my word for it: just ask anyone active in Wikipedia:WikiProject Chess. you also might want to peek at Wikipedia talk:WikiProject Chess and its archive to see discussions related to the pgn viewer (i mean about the general design of the thingy: not showing the PGN was never discussed, because nobody ever thought that not showing the PGN makes the slightest bit of sense).
as to the {{Chess diagram}} template: this is an atrocious template. it's hideously expensive: you can't even save a page with 60 instances of this template on enwiki, and it's a pain in the rear end to fill. for chess, there is another standard, not meant to show a full game, but rather a single state of the chess board, which is called "FEN" (Forsyth–Edwards Notation), which is the standard way of presenting a single state of a chess board (it's not the *only* such standard, and it's not as dominant as PGN is for showing full games, but it is the most common standard). enwiki has a template that can display a chess board using the FEN representation: {{Chess diagram-fen}}. if you want to build something based on straight templates, i think you should consider using it instead of {{chess diagram}}. full disclosure - i created this template, as my first Lua exercise. peace - קיפודנחש (aka kipod) (talk) 03:26, 30 March 2013 (UTC)[reply]
I could have sworn User:Technical 13 said somewhere he doesn't know chess very well? Unless I'm making that up. I think this is a simple misunderstanding and not anything more. WP:GOODFAITH.
Technical: I've read chess books but I didn't realize the significance of your template having the moves segregated by player.
The Wikipedia page on chess notation (scroll down to the table) lists a bunch of notations, all of which seem to be written in the form:
<move number> <white move> <black move>
Standard Algebraic Notation is commonly used in modern chess books. (PGN is a file format that uses Standard Algebraic Notation to record the moves.) I've read older chess books that use the "Figurine Algebraic," "Long Algebraic," or "Descriptive" notations.
Standard Algebraic Notation seems to be the informal standard on Wikipedia as well. For example:
http://en.wikibooks.org/wiki/Chess_Strategy/Development#What_to_do_with_a_lead_in_development
Ruy_Lopez_Opening (from List_of_chess_openings)
The WikiProject_Chess section about notation doesn't explicitly say that SAN is the standard to be used on all pages, but all the "standard templates" seem to use SAN in their documentation pages which again points to this being the informal standard.
In summary, my two cents:
  1. The input for our chess viewer should be in SAN or PGN, because that's what people know and are comfortable with. (The FEN notation is for a single position so supporting it isn't as important.)
  2. The output (display) should be one of the chess standards listed in the table of Chess_notation#Move_notations_for_humans.
  3. If you want to give the user the option to output the moves in different notations by all means do so, but the default should still be SAN or PGN. If you want the default to be something other than SAN or PGN please raise it on the WikiProject_Chess talk page.
  4. If you want to get fancy you can make one box with the move list, and then list the current move and/or its comment in separate area(s). If not, not.
Cheers. Mattj2 (talk) 07:07, 31 March 2013 (UTC)[reply]
kipod: I totally agree that's it's important that the output be in Standard Algebraic Notation or PGN and not presented in an arbitrary way. As I said above, I think this is a misunderstanding (WP:GOODFAITH), not something malicious... Mattj2 (talk) 07:17, 31 March 2013 (UTC)[reply]

Wikidata Usage[edit]

Can we use wikidata for the Portable Game Notation files? Antimaterie (talk) 15:28, 29 March 2013 (UTC)[reply]

That's a great idea! I think in the beginning it's best to keep things simple and make the PGN information be a template variable. This makes it easier for inexperienced Wikipedia users to edit. Wikidata support (in my opinion) is mainly useful for when multiple wikis with multiple languages all want to reference the same chess diagram. I personally think it's best to hold off for now. Is it important to you that we do this right away? Mattj2 (talk) 17:31, 29 March 2013 (UTC)[reply]

Am I correct in assuming the script for this is based on SVG?[edit]

Is this script based on manipulating a Scalable Vector Graphics with JavaScript as is mentioned here? User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 17:39, 29 March 2013 (UTC)[reply]

No the output is a regular HTML table with 8 rows and 8 columns. Each cell is an individual static picture. The design of that chess template is totally unwieldy. I'll dig up a template that I like that's much simpler. Mattj2 (talk) 17:48, 29 March 2013 (UTC)[reply]
The Template:Chess diagram transcludes each row, which in turn transcludes each square, which takes a lot of processing power and generates a huge amount of HTML. A different board game (Arimaa) has a template that is MUCH simpler. I hope it helps. :)
Template:Arimaa_diagram
One page that uses it: Arimaa
Template:Arimaa diagram looks like it is used exactly the same as Template:Chess diagram.  ?? User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 21:00, 29 March 2013 (UTC)[reply]
Note that the Arimaa template uses a background image and transparent gifs, whereas the chess template has no background image and each cell has to "know" whether its background should be black or white. I think the easiest short-term solution is to not edit the images, but hardcode the background color into a single template.

Also the chess template has tons of parameters, and it might be easier to ignore all those bells and whistles in the beginning. — Preceding unsigned comment added by Mattj2 (talkcontribs) 18:03, 29 March 2013 (UTC)[reply]
No time to look at that just now (I'm cheating on work), but wouldn't it make the most sense to just set the board up as an SVG (which I think is just an xml definition of the image) and the change the xml as the moves are made? User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 18:10, 29 March 2013 (UTC)[reply]
Hah hah that's over my head. I would think that Javascript is supported by more browsers than SVG. Does SVG work on mobile phones with limited processing power? Is it more important for the chess viewer to be usable by a large number of people, or to use a more powerful technology that has better features? (Personally I'd rather have an 8x8 HTML grid and use Javascript to change which images are shown, because then it becomes super easy to use it for any board game.) Mattj2 (talk) 18:36, 29 March 2013 (UTC)[reply]
Scalable Vector Graphics#Mobile profiles looks like it has a wider range of limited support than it does on desktops. There are a majority of images on wikipedia already that are svg... There are actually some animated SVGs on commons... that don't appear to work in FF-19.0.2... Meh... Was worth some investigation and thought. User:Technical 13   ( C • M • Click to learn how to view this signature as intended ) 18:50, 29 March 2013 (UTC)[reply]
Absolutely. (I'm an ex-programmer who's trying to avoid getting in too deep on the technical side..) Mattj2 (talk) 20:32, 29 March 2013 (UTC)[reply]
please note that images arrive to WP pages from a different server altogether. there is no sane way for a script to control and manipulate the content of an image (i'm not saying it physically impossible - someone with greater browser-fu than myself may be able to find a way to do it, but i's not going to be pretty). also, different browsers' support of the SVG format varies greatly, so anything that takes advantage of advanced features of SVG just doesn't make sense for wikipedia. even using much more vanilla features of html5 such as "Canvas" are not acceptable, unless there is a very graceful fallback. this script uses nothing of the sort, and is compatible with any browser that can display images and works with jQuery (practically any browser which is not text only, IOW, any browser except Lynx). peace - קיפודנחש (aka kipod) (talk) 02:52, 30 March 2013 (UTC)[reply]

PGN comment, variations, usage[edit]

Hello קיפודנחש,

header (if there is any) with game selector
Event: Semmering/Baden

Site: Semmering
Date: 1937.??.??
Round: 14
White: Capablanca, Jose Raul
Black: Keres, Paul
Result: 1/2-1/2
ECO: D18

abcdefgh
8
a8 black rook
b8 black knight
c8 black cross
d8 black queen
e8 black king
f8 black bishop
h8 black rook
a7 black pawn
b7 black pawn
d7 down-right arrow
e7 black pawn
f7 black pawn
g7 black pawn
h7 black pawn
b6 four
c6 black pawn
e6 down-right arrow
f6 black knight
c5 two
f5 black bishop
a4 white pawn
c4 black pawn
d4 white pawn
e4 one
c3 white knight
e3 white pawn
f3 white knight
b2 white pawn
e2 white cross
f2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
f1 white bishop
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
After 5... Bf5 6.e3
1. c4 c6 2. d4 d5 3. Nf3 Nf6 4. Nc3 dxc4 5. a4 Bf5 6. e3 {D18 Slav:Dutch Variation}

6... e6 7. Bxc4 Nbd7 8.Qe2 Bb4 9. O-O Ne4 10. Nxe4 {+0.18}

(10. Bd3 Nxc3?! 11. bxc3 Bxc3 12. Rb1 +/= {+0.38})

10... Bxe4 11. Bd3 Nc5 12. Bxe4 Nxe4 {step 1 of the plan} 13. Qc2 Qd5 14. Ne5 O-O 15. f3 Nc5 {step 2} 16. Nc4 b5 17. axb5 cxb5 18. Bd2 Bxd2 19. Nxd2 Na4 {step 3} 20. Rfe1 h6 21. b3 Nb6 {step 4} 1/2-1/2

buttons and controls
Multiline window for contextual comment with regard to the current move: D18 Slav:Dutch Variation

Under "buttons and controls", what about a multiline scrollable window for a contextual comment (with full featured wikilink) between {curly braces} after a move in the PGN? Comments cannot be nested but could include WP templates. Long comments could be partially hidden in the PGN window on the right but fully displayed in the comment window.

What specific {comment} could represent empty squares with upper arrow, cross, cross, step 1 of plan to step 9 of plan or highlighted piece with red frame Black king on highlighted red square?

Could a future version of the PGN viewer manage variations between ((nested) parentheses)? See variation (10.Bd3 ...) instead of the main move 10.Nxe4.

Usage: I cannot find the option PGN Chess Viewer in my user "Preferences", "Gadgets" tab, "Appearance" or "Advanced" section. Any news?

Nimmzo (talk) 20:00, 14 September 2013 (UTC)[reply]

i am not sure i understand all the questions, so i'll answer the ones i think i do understand.
Q: no "pgn viewer" under Preferences => Gadgets.
A: right. this is not a gadget on enwiki (and i'm not sure it makes sense to make it a gadget - gadgets are usually tools for editors. tools for readers are either installed on a specific wiki or they are not. the pgn viewer is installed for everyone on hewiki. you can still play with it by including it from hewiki, like so:
importScriptURI('//he.wikipedia.org/w/index.php?title=Mediawiki:Common.js/pgn.js&action=raw&ctype=text/javascript');
I imported the Javascript in my subpage User:Nimmzo/common.js
I also tried:
window.makeChessTemplate = 1;
And the "T" button is now visible in the toolbar under the chessboard.
According to the Note: "After saving," I had "to bypass the browser's cache to see the changes." Ctrl+F5 in IE.

In my User:Nimmzo page, I am testing the PGN sample between HTML div tags.
Below, with the second version of the same PGN, I am testing the three templates User:Nimmzo/Pgn, User:Nimmzo/Pgn/Games and User:Nimmzo/Pgn/Onegame.

Would you help to translate the templates using Help:Magic words and fix the layout issue of the chessboard?
If you wish, could you View history, Edit source and Save my user page and subpages to fix the sample and the templates?
Thanks in advance.
Nimmzo (talk) 22:45, 17 September 2013 (UTC)[reply]
Q:Could a future version of the PGN viewer manage variations between ((nested) parentheses)?
A:this is not physically impossible, but i do not have, at the current time, any plans for such an enhancement. the code itself is released under PD license, so anyone can take it and do whatever they want with it, of course, but i don't think i'll implement this specific enhancement, though i agree it would be nice.
Q: can comments contain wiki-code (images, internal links, templates etc.)?
A: at the moment no, but if this is important enough, it should not be that difficult to implement.
IMO it makes more sense to do the more elaborate comments, with images, templates , internal links etc. somewhere in the code of the page outside the pgn viewer itself - this way people without JS, and people who do not want to bother with pgn viewer can still read those comments.
sorry if i misunderstood any of the questions.
peace - קיפודנחש (aka kipod) (talk) 18:30, 16 September 2013 (UTC)[reply]
upon more careful reading: i think i understand now that "comment" is ambiguous: there are the embedded comments in PGN, and then, there's also a comment that can appear under the controls.
the script/template support both, but please note that the comment that appear under the controls (which fully support wikicode, including links, images, and templates) is a single comment for the whole set of games: if you display 10 games using the template, you can't have a separate comment for each - there is only one comment shared by all games.
also, just to make sure you saw the demo, lookie here: he:משתמש:קיפודנחש/ארגח 1. peace - קיפודנחש (aka kipod) (talk) 00:11, 17 September 2013 (UTC)[reply]
I absolutely love this idea, and I can't believe it's been nearly a decade without being implemented. Is there any chance of reviving this? It could just be a GIF for the mobile site, right? Electricmaster (talk) 16:41, 25 December 2022 (UTC)[reply]