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.
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.