Check out Atomic Chess, our featured variant for November, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Comments/Ratings for a Single Item

Earlier Reverse Order Later
Shortcodes[Subject Thread] [Add Response]
🕸Fergus Duniho wrote on Thu, May 26, 2016 01:10 AM UTC:

I have started to implement shortcodes. If you use Wordpress, you may already know what shortcodes are. They are keywords that appear between brackets that signal the running of PHP code. They sometimes take parameters, and some come with closing tags, so that they can enclose text. I have made some that take parameters, but I haven't figured out how to easily make any that include a closing tag and enclose text. My original plan had been to get an editor working first, then to install a plugin for handling shortcodes. But CKEditor doesn't have a shortcodes plugin. So I'm implementing shortcodes from scratch. There are three shortcodes so far. Writing their names without brackets, clear will output <br clear=all>, set will choose a piece set, and pc will display a piece. If given a name as a second parameter, pc will display the piece in a figure with the name as a caption. Here are come examples. View the source to see the codes.

The King can move one space in anydiagonal or orthogonal direction.

Queen
The Queen can move any number of spaces in any diagonal or orthogonal direction.



🕸Fergus Duniho wrote on Thu, May 26, 2016 01:48 AM UTC:

As long as I'm doing shortcodes, any thoughts on what shortcodes to include? I want to include shortcodes that enclose text with opening and closing tags, though that might be trickier. I want to use this for a description field for pieces, and I want to add codes for writing alternate text in specific languages. I could also add a diagram shortcode and an interactive-diagram shortcode.


🕸Fergus Duniho wrote on Thu, May 26, 2016 04:04 PM UTC:

I have expanded the [pc] shortcode. It can be used by itself, or it can be paired with a closing tag. Here are its uses:

The only required parameter is a piece label:

It may take a second parameter as a piece name:

King

With a closing tag, it may include a piece description.

King

The King may move one space in any direction. Once in the game, it may castle with a Rook so long as it is not in check, neither piece has moved, all spaces between the King and Rook are empty, and the move does not move the King through or into check. In castling, the King moves two spaces toward the Rook, and the Rook moves to the other side of the King on the space the King just passed over. A King may never move into check.


The closing tag may also be used without the second parameter:

The King may move one space in any direction. Once in the game, it may castle with a Rook so long as it is not in check, neither piece has moved, all spaces between the King and Rook are empty, and the move does not move the King through or into check. In castling, the King moves two spaces toward the Rook, and the Rook moves to the other side of the King on the space the King just passed over. A King may never move into check.



🕸Fergus Duniho wrote on Thu, May 26, 2016 04:18 PM UTC:

Since a shortcode is a server-side instruction, successful shortcodes will not show up in source code. So, to show you what the code I entered looks like, I will set the piece set to a non-existant set. Without an actual piece set loaded in, all the [pc] shortcodes will fail, and on failing will just return a copy of themselves.

[set magneto]I have expanded the [pc] shortcode. It can be used by itself, or it can be paired with a closing tag. Here are its uses:

The only required parameter is a piece label: [pc K]

It may take a second parameter as a piece name: [pc K King]

With a closing tag, it may include a piece description. [pc K King]The King may move one space in any direction. Once in the game, it may castle with a Rook so long as it is not in check, neither piece has moved, all spaces between the King and Rook are empty, and the move does not move the King through or into check. In castling, the King moves two spaces toward the Rook, and the Rook moves to the other side of the King on the space the King just passed over. A King may never move into check.[/pc]

The closing tag may also be used without the second parameter: [pc K]The King may move one space in any direction. Once in the game, it may castle with a Rook so long as it is not in check, neither piece has moved, all spaces between the King and Rook are empty, and the move does not move the King through or into check. In castling, the King moves two spaces toward the Rook, and the Rook moves to the other side of the King on the space the King just passed over. A King may never move into check.[/pc]


🕸Fergus Duniho wrote on Thu, May 26, 2016 04:24 PM UTC:

I am setting the set to abstract. Will this carry over to the next message?

It did carry over, but I fixed it so that a false name erases the current piece set from memory.


Charles Gilman wrote on Fri, May 27, 2016 07:03 AM UTC:

I tried to use shortcodes myself, and it seems to work within a comment, as follows:

Bishop

It does not however seem to work on a post-your-own, as I tried using it to put a Bishop image beside the Bishop entry in Index B to Man and Beast and it showed the square brackets  and their content rather than the image. Any idea why?

 


🕸Fergus Duniho wrote on Fri, May 27, 2016 03:54 PM UTC:

The function I modified was called display_comment(), and it turns out that this function was being used only for comments, not for user-submitted pages. I have just modified display_user_submission() to call display_comment() when it prints content from the MemberSubmissions table.


🕸Fergus Duniho wrote on Sat, May 28, 2016 01:02 AM UTC:

I have added a lang shortcode. This is a paired shortcode that encloses text in a particular language. It takes one parameter, a lowercase, two-letter language code. Using this allows you to provide text in multiple languages. This works by first making an ordered list of all the languages you have used in your lang shortcodes. It compares this list to the value of the HTTP_ACCEPT_LANGUAGE environment variable. It identifies each language you have provided text in that is mentioned in this variable, and it sorts them by order of precedence. If any of the languages you have used appear in this variable, it favors the one that appears earliest in this variable. If there isn't a match, it favors the first language you wrote text in. So, you should generally write text in your best language first, and it's good to always provide text in English. I will now demonstrate this shortcode with some examples. Change your accepted languages around to see different results turn up.

Hello, World. This is my English text.


Charles Gilman wrote on Tue, May 31, 2016 07:09 AM UTC:

Yes, that seems to work. I have undone that single change so that I can add the whole set of images that I am using to the master copies offline and add them page by page rather than piece by piece.


Charles Gilman wrote on Tue, May 31, 2016 12:46 PM UTC:

Further to my previous comment, I have successfully applied shortcodes to Tee Garden Shogi, which I was rewriting anyway, and two of my memory-heaviest variants, Flipped-Return Nichtschach and Anglojewish Chess.


Charles Gilman wrote on Mon, Jun 6, 2016 07:17 AM UTC:

I have now used shortcodes to add piece images to all my index pages - and shorten the "Pieces" section on several of my variant pages as well. How this squares with the clause "I am not in support of your idea" <a href="http://www.chessvariants.com/index/displaycomment.php?commentid=32491">here</a> I am not entirely sure, as shortcodes fulfil the more basic of my suggestions completely.


🕸Fergus Duniho wrote on Mon, Jun 6, 2016 12:32 PM UTC:

I'm glad you like the pc shortcode, but it does differ in some important details from what you suggested. Most importantly, it would have monopolized the shortcode system in a way that would have undermined the creation of other shortcodes. So, I was opposed to implementing exactly what you suggested, but I was interested in providing a shortcode system, and when it came to Game Courier, I eventually realized that shortcodes would be an even more efficient way of linking to pieces in the currently selected set than using JavaScript or treating php scripts as image files. When what I needed for Game Courier fell in place, I realized it would work just as well for more static content, and the same code could be used to process both.


Charles Gilman wrote on Tue, Jun 7, 2016 06:55 AM UTC:

We really do seem to have been talking at cross-purposes. All that I asked for was a result, not a particular means of achieving it, and I am just as pleased that you have you achieved it in the way that you liked as I would have been with any other way.


13 comments displayed

Earlier Reverse Order Later

Permalink to the exact comments currently displayed.