Changeset 575

Show
Ignore:
Timestamp:
06/01/09 12:41:12 (3 years ago)
Author:
confluence
Message:

added reply link

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • confluence/feedfilters/twitterfilter.py

    r569 r575  
    2020linknames = re.compile(r"@([a-zA-Z0-9_]+)") 
    2121hashtags = re.compile(r"#([a-zA-Z0-9_]+)") 
     22statusidpattern = re.compile(r"http://twitter.com/.*/statuses/([0-9]*)") 
    2223 
    2324xml = xml.dom.minidom.parseString(sys.stdin.read()) 
     
    3334        continue 
    3435 
     36    title = item.getElementsByTagName("title")[0].firstChild 
     37    title.data = titlepattern.sub(r"\1", title.data) 
     38    username = title.data.strip(":") 
     39 
     40    guid = item.getElementsByTagName("guid")[0].firstChild 
     41    statusid = statusidpattern.match(guid.data).group(1) 
     42 
    3543    text = linkurls.sub(r"<a href='\1'>\1</a>", text) 
    3644    text = linknames.sub(r"<a href='http://twitter.com/\1'>@\1</a>", text) 
    3745    text = hashtags.sub(r"<a href='http://search.twitter.com/search?q=%23\1'>#\1</a>", text) 
     46    text += " <a href='http://twitter.com/home?status=@%s%%20&in_reply_to_status_id=%s&in_reply_to=%s'>Reply</a>" % (username, statusid, username) 
    3847    description.data = text 
    3948 
    40     title = item.getElementsByTagName("title")[0].firstChild 
    41     title.data = titlepattern.sub(r"\1", title.data) 
    42  
    4349print xml.toxml(encoding="UTF-8")