def dialogs(): page = get_page() dialogs = select_dialogs(page) next_url, prev_url = get_next_and_prev("chat.dialogs", dialogs, page) return render_template("chat/dialogs.html", title=_("Messages"), dialogs=dialogs.items, next_url=next_url, prev_url=prev_url)
def explore(): page = get_page() users = select_all_users(page) next_url, prev_url = get_next_and_prev("main.explore", users, page) return render_template("main/explore.html", title=_("Explore"), users=users.items, next_url=next_url, prev_url=prev_url)
def search(): if not g.search_form.validate(): return redirect(url_for("main.index")) page = get_page() posts, total = select_searched_posts(g.search_form.q.data, page) next_url, prev_url = get_next_and_prev("main.search", posts, page) return render_template("main/search.html", title=_("Search"), total=total, posts=posts.items, next_url=next_url, prev_url=prev_url)
def user(username): user = select_user_by_username(username) page = get_page() posts = select_user_posts(user, page) next_url, prev_url = get_next_and_prev("main.user", posts, page, user.username) is_follow = is_following(user) is_current = user == current_user return render_template("main/user.html", title=_("Profile ") + username, user=user, is_follow=is_follow, is_current=is_current, posts=posts.items, next_url=next_url, prev_url=prev_url)
def index(): form = PostForm() if form.validate_on_submit(): language = translator.detect(form.message.data).lang add_post(form.message.data, current_user, language) flash(_("Your post was published!")) return redirect(url_for("main.index")) page = get_page() posts = select_current_user_followed_posts(page) next_url, prev_url = get_next_and_prev("main.index", posts, page) return render_template("main/index.html", title=_("Home"), form=form, posts=posts.items, next_url=next_url, prev_url=prev_url)
def messages(username): form = MessageForm() if form.validate_on_submit(): language = translator.detect(form.message.data).lang send_message(form.message.data, username, language) flash(_("Your message was sent!")) return redirect(url_for("chat.messages", username=username)) page = get_page() messages = select_messages(username, page) read_messages(username) next_url, prev_url = get_next_and_prev("chat.messages", messages, page, username) return render_template("chat/messages.html", title=_("Messages from ") + username, form=form, messages=messages.items, next_url=next_url, prev_url=prev_url)