Actually setting up a simple spin is a simple task, but I want to make sure I choose the correct algorithm. I have at the moment two choices, a recursive or a multiple pass.
Let’s see what we can use…
First off here are the basic needs. Scan through an article, we stick to text for now, and pick up commands to allow different content to be chosen at specified points. For now the easiest and most well know is to use the characters ‘{‘ and ‘}’ to show the beginning and the end of the text to spin and a character ‘|’ to show where the splits will occur.
So easiest article to spin will be something like this:
{Hello|Hi} World
Two results will be either
Hello World
Or
Hi World
But we want it to be a bit more powerful than that don’t we. We want to be able to spin within a spin something like this:
{So that's {the end|finished} |that's it…}
Three results will be
So that’s the end
So that’s finished
That’s it…
The above is much more useful with longer phrases but that essentially shows that multiple levels of spin are necessary and I do not want any limits.
Right, more requirements, I said I wanted the template to do more, but in the absence of defining exactly what I want now I will need to consider global and local scripts. Another character is needed, let’s use ‘^’ and just in case we actually need ‘^’ in our output then make the characters ‘^^’ produce it.
The characters I am suggesting I will keep open and in a state where they can be changed at any time in the future. I want to be able to use this a lot before settling down to what the default characters should be.
Right, so how can we use scripts or fields with the ‘^’ character.
Let’s try this example, a light bulb page
Light type {^light_type} and { can be found | is available } in wattage of {^wattage_list}
To produce something like:
Light type is neon and is available in wattage of 10W,20W and 30W
Light type is LCD and can be found in wattage of 1W and 2W
I made an assumption here that the variables may be anything and kept the ‘{}’ as delimiters as well because I want to have complete control over spacing. So anything whitespace with these delimiters (maybe I will need to think of quotation marks} will be absorbed. So I can write my template like this:
Light type {
^light_type
} and {
can be found | is available
} in wattage of {^wattage_list}
Or however way I please.
We’ll see if that works or not.
There maybe optional bits in the template too. For example if a value is know then you might want to spin it but if not you do not want any blank values in the text.
Maybe something like
Light type { ^light_type } {^if(wattage_list) and { can be found | is available } in wattage of {^wattage_list} }
Finally, to handle the scripting I need to choose the engine. In QKSite I used VBScript because of its simplicity but also allow JavaScript be used if necessary. Maybe those variable will be functions with arguments in parentheses, like in the ‘if’ above – we’ll see how it looks.
While I make that decision I will continue and build QKSite solely to produce the spinning text for version 1. It looks about as complicated as I would put up with and playing around with it might enable better ways to be imagined.
Let me know if you have any thoughts on this…
My aim is to keep the template creation as quick and easy as possible without getting untidy, I want to concentrate then on the articles and not any coding.