Skip to end of metadata
Go to start of metadata

This is the SNIPPET you can insert into your Facebook or Twitter Script to generate a random intro. Be mindful of special characaters like apostrophes and quote marks in the intro words, they will cause an error. Please always test any script changes before making them live.


<#assign rand = LIB.randomInt(10)>
<#assign b1 = LIB.randomBoolean()>
<#if rand=0><#assign intro='ONE -  '>
<#elseif rand=1><#assign intro='TWO -  '>
<#elseif rand=2><#assign intro='THREE - '>
<#elseif rand=3><#assign intro='FOUR -  '>
<#elseif rand=4><#assign intro='FIVE -   '>
<#elseif rand=5><#assign intro='SIX -  '>
<#elseif rand=6><#assign intro='SEVEN - '>
<#elseif rand=7><#assign intro='EIGHT -  '>
<#elseif rand=8><#assign intro='NINE -  '>
<#elseif rand=9><#assign intro='TEN -  '>


FOR TWITTER the snippet goes below the #assign intro line

<#assign intro=''>
>>>>>>>>>>>>>>>> INSERT SNIPPET HERE <<<<<<<<<<<<<<<<<<<<<<
<#assign hashtag=''>
<#assign title=(doc.title)>
<#assign total=(intro?length+title?length+hashtag?length+25)>
<#assign dom=doc.dom>
<#if (doc.feedItemUrl!'') != '' >
 <#assign url=doc.feedItemUrl>
 <#assign uu=LIB.getUrlUtil(url)>
 <#assign dumy = uu.set("utm_source","Twitter")>
 <#assign url=uu.url>
<#else>
 <#assign url=dom["string(//a[@id='source']/@href)"]>

<#assign shorturl=doc.getShortUrl(url)>
<#if total < 141>
${intro} ${title} ${shorturl} ${hashtag}
<#else>
 <#assign titletrim=(140-total+title?length-4)>
 <#assign shorttitle=title[0..titletrim]>
 <#assign lastblank=shorttitle?last_index_of(" ")>
<#if lastblank > 0>
   <#assign shorttitle=shorttitle[0..lastblank-1]>

<#assign shorttitle=shorttitle+'...'> 
${intro} ${shorttitle} ${shorturl} ${hashtag}



  • No labels