Exemplo n.º 1
0
def diff_processtext(text):
    """ Prepares the supplied post text to be diff'ed.  """
    from snapboard.templatetags.extras import render_filter
    texth = render_filter(text)  # -> html
    textl = re.findall(r'<[^>]*?>|[^<]+', texth)  # -> tags&text
    out = []
    for item in textl:  # -> tags & words.
        if item.startswith("<"):
            out.append(item)
        else:
            #out += item.split()  # Extra spaces?
            #out += re.findall(r'[ ]+|[^ ]+', item)
            out += list(item)  # by-symbol diff o_O
    return out
Exemplo n.º 2
0
    def save(self, force_insert=False, force_update=False):
        # ? huh?
        #_log.debug('user = %s, ip = %s' % (threadlocals.get_current_ip(),
        #    threadlocals.get_current_user()))

        # hack to disallow admin setting arbitrary users to posts
        if getattr(self, 'user_id', None) is None:
            self.user_id = threadlocals.get_current_user().id

        # disregard any modifications to ip address
        self.ip = threadlocals.get_current_ip()

        # ! XXX: Not really appropriate to do it here?..
        from snapboard.templatetags.extras import render_filter
        self.texth = render_filter(self.text)
        
        super(Post, self).save(force_insert, force_update)
        ## Update the thread-local id afterwards.
        self.update_lid()
Exemplo n.º 3
0
def _sanitize(text):
    return render_filter(striptags(text), "safe")
Exemplo n.º 4
0
def _sanitize(text):
    return render_filter(striptags(text), "safe")