Ejemplo n.º 1
0
def profile(username):
    if (username.lower() == "unendingpattern") or (username.lower()
                                                   == "unswp"):
        identibooru.flash("no such profile exists", "danger")
        return identibooru.redirect(identibooru.url_for('index'))
    parsed_bio = ""
    user = Users.query.filter_by(username=username).first()
    if user:
        tags = Tags.query.filter_by(uid=user.uid).order_by(Tags.tag).all()
        opts = UserOpts.query.filter_by(uid=user.uid).first()
        opts.views = opts.views + 1
        identibooru.db.session.commit()
        tag_list = render_tag_list(html=True,
                                   tags=tags,
                                   is_profile=get_user_options(user.username),
                                   is_map=False)
        return identibooru.render_template(
            'profile.html',
            title=user.username + ' - profile',
            user=user,
            tags=tags,
            user_options=get_user_options(username),
            tag_list=tag_list)
    identibooru.flash("no such profile exists", "danger")
    return identibooru.redirect(identibooru.url_for('index'))
Ejemplo n.º 2
0
def account_register():
    if get_user_options(identibooru.current_user.get_username())['rank'] != 0:
        return identibooru.redirect(identibooru.url_for('index'))
    if identibooru.disable_registration:
        identibooru.flash("registration is currently disabled", "danger")
        return identibooru.redirect(identibooru.url_for('index'))
    return identibooru.render_template('account-register.html',
                                       title='register')
Ejemplo n.º 3
0
def index():
    tags = Tags.query.all()
    tag_list = render_tag_list(html=True,
                               tags=tags,
                               is_profile=False,
                               is_map=False)
    return identibooru.render_template('home.html',
                                       title='home',
                                       tags=tag_list)
Ejemplo n.º 4
0
def search():
    terms = identibooru.request.args.get('t', False)
    confirm_adult = identibooru.request.args.get('confirm_adult', False)
    search_tags = []
    remove_tags = []

    relevant_tags = []
    relevant_tag_list = []
    if not terms:
        identibooru.flash("no search terms specified", "danger")
        return identibooru.redirect(identibooru.url_for('index'))
    if identibooru.disable_search and get_user_options(identibooru.current_user.get_username())['rank'] != 99:
        identibooru.flash("not enough tags to form search results yet, please contribute by registering and tagging yourself!", "success")
        return identibooru.redirect(identibooru.url_for('index'))

    if " " in terms:
        terms_list = terms.split(" ")
    else:
        terms_list = [terms]
    if get_user_options(identibooru.current_user.get_username())['adult'] == 0 and not confirm_adult:
        adult_tags = ["-rating:explicit", "-rating:questionable"]
        fullpath = identibooru.request.full_path

        for adult_tag in adult_tags:
            if not adult_tag in terms_list:
                terms_list.append(adult_tag)
    
    tags = Tags.query.all()
    for term in terms_list:
        for tag in tags:
            if fnmatch.fnmatch(tag.tag, term):
                search_tags.append(tag)
        if term[0] is "-":
                remove_tags.append(term.strip("-"))

    
    search_results = render_search_results(html=True, search_tags=search_tags, remove_tags=remove_tags, users_class=Users)

    for result in search_results.values():
        relevant_tags.append(Tags.query.filter_by(uid=result['user'].uid).all())
            
    tags = Tags.query.all()
    for term in terms_list:
        for tag in tags:
            if fnmatch.fnmatch(tag.tag, term):
                relevant_tag_list.append(tag)
    for tag in list(itertools.chain(*relevant_tags)):
        relevant_tag_list.append(tag.tag)

    tag_list = render_tag_list(html=True, tags=relevant_tag_list, is_profile=False, is_map=False, remove_tags=remove_tags)
    return identibooru.render_template('search.html', title=terms + ' - search', results=search_results, tags=tag_list, keywords=terms)
Ejemplo n.º 5
0
def account_settings(username):
    if (username
            == identibooru.current_user.get_username()) or (get_user_options(
                identibooru.current_user.get_username())['rank'] == 99):
        user = Users.query.filter_by(username=username).first()
        if not user:
            identibooru.flash("no such user exists", "danger")
            return identibooru.redirect(identibooru.url_for('index'))
        return identibooru.render_template(
            'account-settings.html',
            title=user.username + ' - account settings',
            user=user,
            user_options=get_user_options(username))
    identibooru.flash("authentication failed", "danger")
    return identibooru.redirect("/" + username)
Ejemplo n.º 6
0
def map():
    search_results = False
    search_user_results = False
    terms = identibooru.request.args.get('t', False)

    search_users = ""

    if not terms:
        identibooru.flash("no search terms specified", "danger")
        return identibooru.redirect(identibooru.url_for('index'))
    if terms:
        if " " in terms:
            terms_list = terms.split(" ")
        else:
            terms_list = [terms]

        terms_list = [terms]
        if get_user_options(identibooru.current_user.get_username())['adult'] == 0:
            adult_tags = ["-rating:explicit", "-rating:questionable"]
            fullpath = identibooru.request.full_path

            for adult_tag in adult_tags:
                if not adult_tag in terms_list:
                    terms_list.append(adult_tag)

        search_tags = []
        remove_tags = []

        relevant_tags = []
        relevant_tag_list = []

        tags = Tags.query.all()
        for term in terms_list:
            groups = term.split(":")
            if len(groups) > 1:
                if groups[0] == "user":
                    search_user_results = Users.query.filter_by(username=groups[1].strip(" "))
            elif len(groups) == 1 and not identibooru.disable_search or get_user_options(identibooru.current_user.get_username())['rank'] == 99:
                for tag in tags:
                    if fnmatch.fnmatch(tag.tag, term):
                        search_tags.append(tag)
                if term[0] is "-":
                        remove_tags.append(term.strip("-"))
        search_results = render_search_results(html=False, search_tags=search_tags, remove_tags=remove_tags, users_class=Users)

    #tag_list = render_tag_list(html=True, tags=relevant_tag_list, is_profile=False, is_map=True, remove_tags=remove_tags)
    return identibooru.render_template('map.html', title='map', tag_results=search_results, search_users=search_user_results, keywords=terms)
Ejemplo n.º 7
0
def profile_edit(username):
    if (username
            == identibooru.current_user.get_username()) or (get_user_options(
                identibooru.current_user.get_username())['rank'] == 99):
        user = Users.query.filter_by(username=username).first()
        if user:
            tags = Tags.query.filter_by(uid=user.uid).order_by(Tags.tag).all()
            tag_list = render_tag_list(html=False,
                                       tags=tags,
                                       is_profile=get_user_options(
                                           user.username),
                                       is_map=False)
        else:
            identibooru.flash("no such user exists", "danger")
            return identibooru.redirect(identibooru.url_for('index'))
        return identibooru.render_template(
            'profile-edit.html',
            title=user.username + ' - editing profile',
            user=user,
            user_options=get_user_options(username),
            tags=tag_list)
    identibooru.flash("authentication failed", "danger")
    return identibooru.redirect("/" + username)
Ejemplo n.º 8
0
def account_login():
    if get_user_options(identibooru.current_user.get_username())['rank'] != 0:
        return identibooru.redirect(identibooru.url_for('index'))
    return identibooru.render_template('account-login.html', title='log in')
Ejemplo n.º 9
0
def error_page(error):
    return identibooru.render_template('error.html',
                                       title='error',
                                       error=error)
Ejemplo n.º 10
0
def info_donate():
    return identibooru.render_template('donate.html', title='donate')
Ejemplo n.º 11
0
def info_profile():
    return identibooru.render_template('info-users.html',
                                       title='user accounts')
Ejemplo n.º 12
0
def info_uploads():
    return identibooru.render_template('info-uploads.html',
                                       title='upload rules')
Ejemplo n.º 13
0
def info_privacy():
    return identibooru.render_template('info-privacy.html',
                                       title='privacy policy')
Ejemplo n.º 14
0
def info_terms():
    return identibooru.render_template('info-terms.html',
                                       title='terms of service')
Ejemplo n.º 15
0
def info():
    return identibooru.render_template('info.html', title='info')