Splatforms, Velocimacros, and Spintax

Posted on February 2, 2011
Filed Under Programming, Splatforms | 16 Comments | Share this post via splatforms.com

We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructure. Even though you can now take a single *form and blast it out to over 200 unique destinations across the Internet on a single click, the form content is exactly the same wherever it lands. Each target site receives exactly the same post as all of the others. Wouldn’t it be cool if you could make each and every entry just a little unique?

Apparently, enough people seem to think so, that there is a word for doing just that: spinning. In fact, to automate the whole process, there is even a notational convention for it: spintax. And it’s a very simple and straightforward syntax, too,  consisting of separating your individual choices with the pipe character (“|”) and surrounding the entire collection with curly braces (“{” and “}”). Each time the article is “spun”, one of the choices is randomly selected from the list of available options and that choice replaces the two curly braces and everything in between. An original sentence containing spintax would look something like this:

Splatforms is {amazing|fabulous|outstanding|stupendous|way cool}!

… and after it was spun, it would end up looking something like this:

Splatforms is stupendous!

Nice, eh?

So what does that have to do with Splatforms? Well, just imagine the kinds of things that you could do if you had a Velocimacro called something like spin that would take a spintax-coded text string as input and would return the spun result as output? Then you could take a parameter list like this:

article_title=$title
article_text=$body

… and turn it into something like this:

article_title=#spin($title)
article_text=#spin($body)

… which would, of course, spin the text before posting it to the target site. This way, each target site would receive a slightly different variation than the others, making them all similar, but unique.

But can you do that with Velocity? Of course you can. Check this out:

#macro(spin $article)
  #set ($start = "\{")
  #set ($separator = "\|")
  #set ($end = "}")
  #set ($parts = $article.split($start))
  #if ($parts.size() > 0)
    #foreach($part in $parts)
      #set ($index = $part.indexOf($end) + 1)
      #if ($index > 1)
        #set ($endindex = $index - 1)
        #set ($optstring = $part.substring(0, $endindex))
        #set ($options = $optstring.split($separator))
        #set ($max = $options.size())
        #set ($optindex = $util.getRandom($max))
        $!options.get($optindex)
      #end
      $!part.substring($index)
    #end
  #else
    $!article
  #end
#end

Now, if you’re not technically inclined, don’t worry about all that VTL stuff above … that’s just there for those little Task Developers that make all of that magic happen in the background. If you’re just a regular user with no aspirations of developing your own Tasks, all you really need to know is that, if you have a spintax-enabled Task, then you can put spintax notation in your text content and the task will spin it before it delivers it. All made possible by those good folks at the Apache Velocity Project. Just another way that Velocity helps make Splatforms a handly little tool do all kinds of useful stuff!

Thanks for {stopping by|tuning in|listening|dropping in|checking us out|giving us your time}!

Comments

16 Responses to “Splatforms, Velocimacros, and Spintax”

  1. pligg.com on February 2nd, 2011 6:54 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  2. firstdigg.com on February 2nd, 2011 7:26 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  3. xehh.com on February 2nd, 2011 7:40 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  4. xulnews.com on February 2nd, 2011 7:42 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways t…

  5. kwoff.com on February 2nd, 2011 7:59 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  6. bookmox.com on February 2nd, 2011 8:00 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  7. 10url.com on February 2nd, 2011 8:02 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways t…

  8. lifeinnews.com on February 2nd, 2011 8:02 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  9. pligg.com on February 2nd, 2011 8:54 am

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways t……

  10. SERPD on February 2nd, 2011 6:36 pm

    Splatforms, Velocimacros, and Spintax…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and d……

  11. pligg.com on February 5th, 2011 5:26 pm

    Splatforms, Velocimacros, and Spintax : Splatforms…

    We have already acknowledged the contribution that Velocity has brought to the table related to Task development, but we keep finding even more ways to leverage this capability as we explore new and different ways to utilize the Splatforms infrastructu…

  12. Spintax and Google Page One : Splatforms on February 9th, 2011 7:01 am

    […] other day we discovered spintax. So we wrote about it, and about how, with a little Velocity magic, you could incorporate spintax processing into a […]

  13. Spintax and Google Page One: Update : Splatforms on March 4th, 2011 7:01 am

    […] a month ago, we posted an entry on spintax, and how a little Velocity magic could enable spintax processing within a *form Task. A few days […]

  14. Fun with Squidoo : Splatforms on July 23rd, 2011 4:41 pm

    […] such as the Text and Article forms. Who knows — maybe we’ll even through a little spintax version. So many possibilities; so little time […]

  15. Fun with HubPages : Splatforms on August 11th, 2011 7:10 am

    […] hopefully it won’t be too long before we have added Articles, Events, and maybe even a little Spintax into the […]

  16. Too Much Fun with HubPages : Splatforms on August 14th, 2011 6:54 pm

    […] to multiple destinations using a single form entry. Even if you were to factor in the use of spintax, such content would still clearly fall into the category of “substantialy similar”. […]