Ejemplo n.º 1
0
def build_and_save_comment(web, site, episode):
        text, reply = md.convert(web.input('comment')), []
        def replyer(x):
            a = x.group()[1:]
            i = find(Comment.id).filter_by(author=a).order_by(Comment.date).all()
            if i: reply.append(i[-1][0])
            return i and '@<a href="/{0}/reply?{1}#new">{2}</a>'.\
                         format(site, i[-1][0], a)\
                     or "@{0}".format(a)
        text = re_reply.sub(replyer, text)
        if reply: reply = reply[0]
        else:     reply = -1
        if web.input('reply') != "-1":
            try: reply = int(web.input('reply'))
            except: pass
        cat = episode.category
        if "ds" in cat: cat = "datenspuren"
        pm_url = pentamediaportal + "/{0}/{1}".format(cat, episode.link)
        for link in re_url.finditer(web.input('comment')):
            trackback_client(link.group(), pm_url,
                             title   = episode.name,
                             excerpt = web.input('comment')
                            )
        Comment(episode = episode.id,
                author  = web.input('author'),
                reply   = reply,
                text    = text,
                date    = datetime.now()
               ).save()
        notify_muc("{0} just left some pithy words on {1}. [ {2} ]".\
            format(web.input('author'), episode.name, pm_url))
Ejemplo n.º 2
0
def trackback_server(web, id):
    try: episode = Episode.find().filter_by(id = int(id)).one()
    except: return errör("Episode not found.")
    if not web.input('url'):
        return errör("No URL given.")
    spam = is_spam(web.input('url'), episode)
    if spam == 2:
        return errör("Timeout.")
    elif spam:
        return errör("Spam.")
    if web.input("excerpt"): text = md.convert(web.input('excerpt'))
    else: text = None
    Trackback(episode = episode.id,
              title   = web.input('title'),
              text    = text,
              url     = web.input('url'),
              date    = datetime.now(),
              name    = web.input('blog_name')
             ).save()
    return template_tb()