コード例 #1
0
def gae(request):
    global messages_pool

    ret = {}

    #ret['user'] = users.get_current_user()
    ret['user_is_current_user_admin'] = users.is_current_user_admin()
    ret['logout_url'] = users.create_logout_url('/')
    ret['MEDIA_URL'] = settings.MEDIA_URL

    try:
        ret['messages'] = request.session['messages_pool']
        request.session['messages_pool'] = []
    except:
        ret['messages'] = []

    ret['html_lateral'] = Wiki.get_by_field('slug', 'lateral')
    ret['html_lateral'] = ret['html_lateral'] and ret['html_lateral'].render(
    ) or ''

    ret['html_postit'] = Wiki.get_by_field('slug', 'postit')
    ret['html_postit'] = ret['html_postit'] and ret['html_postit'].render(
    ) or ''

    return ret
コード例 #2
0
def parse_wiki(text):
    chamadas = exp.findall(text)

    for expressao, func, args, count in chamadas:
        # Carrega lista de objetos
        lista = Wiki.all().filter('published =', True)

        fields_order = []
        tag = None

        # Interpreta argumentos de filtro
        if args:
            args_tmp = [a.split('=') for a in args.split(',')]

            for arg_l in args_tmp:
                arg = arg_l[0]
                val = len(arg_l) > 1 and arg_l[1] or True
                if val == 'False':
                    val = False
                elif val == 'True':
                    val = True

                if arg == 'tag':
                    lista = lista.filter('tags >=', val)
                    fields_order.append('tags')
                    tag = val
                else:
                    lista = lista.filter(arg + ' =', val)

        # Interpreta funcao
        if func == 'all':
            fields_order.append('title')
        elif func == 'recent':
            fields_order.append('-pub_date')

        for field in fields_order:
            lista.order(field)

        if tag:
            lista = filter(lambda o: tag in o.tags, lista)

        # Monta HTML
        html_tmp = '<ul class="wikis">'
        for obj in lista[:int(count)]:
            html_tmp += '<li><a href="%s">%s</a></li>' % (
                obj.get_absolute_url(), unicode(obj))
        html_tmp += '</ul>'

        # Aplica resultado no texto
        text = text.replace(expressao, html_tmp)

    return mark_safe(text)
コード例 #3
0
ファイル: wiki_tags.py プロジェクト: BrianPainter/geraldo
def parse_wiki(text):
    chamadas = exp.findall(text)
    
    for expressao, func, args, count in chamadas:
        # Carrega lista de objetos
        lista = Wiki.all().filter('published =', True)

        fields_order = []
        tag = None

        # Interpreta argumentos de filtro
        if args:
            args_tmp = [a.split('=') for a in args.split(',')]

            for arg_l in args_tmp:
                arg = arg_l[0]
                val = len(arg_l) > 1 and arg_l[1] or True
                if val == 'False':
                    val = False
                elif val == 'True':
                    val = True

                if arg == 'tag':
                    lista = lista.filter('tags >=', val)
                    fields_order.append('tags')
                    tag = val
                else:
                    lista = lista.filter(arg+' =', val)
        
        # Interpreta funcao
        if func == 'all':
            fields_order.append('title')
        elif func == 'recent':
            fields_order.append('-pub_date')

        for field in fields_order:
            lista.order(field)

        if tag:
            lista = filter(lambda o: tag in o.tags, lista)

        # Monta HTML
        html_tmp = '<ul class="wikis">'
        for obj in lista[:int(count)]:
            html_tmp += '<li><a href="%s">%s</a></li>'%(obj.get_absolute_url(), unicode(obj))
        html_tmp += '</ul>'

        # Aplica resultado no texto
        text = text.replace(expressao, html_tmp)

    return mark_safe(text)
コード例 #4
0
def gae(request):
    global messages_pool

    ret = {}

    #ret['user'] = users.get_current_user()
    ret['user_is_current_user_admin'] = users.is_current_user_admin()
    ret['logout_url'] = users.create_logout_url('/')
    ret['MEDIA_URL'] = settings.MEDIA_URL

    try:
        ret['messages'] = request.session['messages_pool']
        request.session['messages_pool'] = []
    except:
        ret['messages'] = []

    ret['html_lateral'] = Wiki.get_by_field('slug', 'lateral')
    ret['html_lateral'] = ret['html_lateral'] and ret['html_lateral'].render() or ''

    ret['html_postit'] = Wiki.get_by_field('slug', 'postit')
    ret['html_postit'] = ret['html_postit'] and ret['html_postit'].render() or ''

    return ret