not quite random
nothing in particular

 


December 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Nov   Jan










Subscribe to "not quite random" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

jenett.radio.randomizer - click to visit a random Radio weblog - for information, contact randomizer@coolstop.com

Blogchalk:
Portsmouth, NH, US




 

Sunday, December 29, 2002

5:10:37 PM   #  

I tweaked untitledPost for safety.

I tweaked untitledPost for safety. Note that my last post is still untitled. If there are HTML tags in the first sentence, the post remains untitled.
on untitledPost (adrpost) {
  if not defined (adrpost^.title) {
    local(title)
    title = string(string.firstSentence (adrpost^.text))
    endMarks = {"!", "?"}
    for i = 1 to sizeOf(endMarks) {
      if title contains endMarks[i] {
        title = string.popSuffix (title,  endMarks[i])
        title = title + endMarks[i] } }
    if not string.wildcardMatch(title, "<*>") {
      adrpost^.title = title } } }

If anyone can tell me how to actually strip HTML tags (without resorting to brute force) from a string, I'll happily tweak it again.

5:15:23 PM   #  

This is a test of another tweak to untitledPost

This is a test of another tweak to untitledPost.

For those playing along at home, the answer was searchEngine.stripMarkup.

5:24:08 PM   #  

And here's the final script.

And here's the final script.

on untitledPost (adrpost) {
  if not defined (adrpost^.title) {
    local(title)
    title = string(string.firstSentence (adrpost^.text))
    endMarks = {"!", "?"}
    for i = 1 to sizeOf(endMarks) {
      if title contains endMarks[i] {
        title = string.popSuffix (title,  endMarks[i])
        title = title + endMarks[i] } }
    adrpost^.title = searchEngine.stripMarkup(title) } }

Thanks to Andy Fragen for the original.

5:28:50 PM   #  

You need a space after the period.

You need a space after the period. Or firstSentence will pick up more than you expect!

5:37:03 PM   #  


Click here to visit the Radio UserLand website. © Copyright 2003 Brian St. Pierre.
Last update: 1/3/2003; 8:34:44 AM.