前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >flask 留言板页面(flask 65)

flask 留言板页面(flask 65)

作者头像
用户5760343
发布2019-08-15 18:56:04
1.6K0
发布2019-08-15 18:56:04
举报
文章被收录于专栏:sktjsktj
代码语言:javascript
复制
        <div class="comments" id="comments">
            <h3>{{ pagination.total }} Comments
                <small>
                    <a href="{{ url_for('.show_post', post_id=post.id, page=pagination.pages or 1) }}#comments">
                        latest</a>
                </small>
                {% if current_user.is_authenticated %}
                    <form class="float-right" method="post"
                          action="{{ url_for('admin.set_comment', post_id=post.id, next=request.full_path) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                        <button type="submit" class="btn btn-warning btn-sm">
                            {% if post.can_comment %}Disable{% else %}Enable{% endif %} Comment
                        </button>
                    </form>
                {% endif %}
            </h3>
            {% if comments %}
                <ul class="list-group">
                    {% for comment in comments %}
                        <li class="list-group-item list-group-item-action flex-column">
                            <div class="d-flex w-100 justify-content-between">
                                <h5 class="mb-1">
                                    <a href="{% if comment.site %}{{ comment.site }}{% else %}#{% endif %}"
                                       target="_blank">
                                        {% if comment.from_admin %}
                                            {{ admin.name }}
                                        {% else %}
                                            {{ comment.author }}
                                        {% endif %}
                                    </a>
                                    {% if comment.from_admin %}
                                        <span class="badge badge-primary">Author</span>{% endif %}
                                    {% if comment.replied %}<span class="badge badge-light">Reply</span>{% endif %}
                                </h5>
                                <small data-toggle="tooltip" data-placement="top" data-delay="500"
                                       data-timestamp="{{ comment.timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') }}">
                                    {{ moment(comment.timestamp).fromNow() }}
                                </small>
                            </div>
                            {% if comment.replied %}
                                <p class="alert alert-dark reply-body">{{ comment.replied.author }}:
                                    <br>{{ comment.replied.body }}
                                </p>
                            {%- endif -%}
                            <p class="mb-1">{{ comment.body }}</p>
                            <div class="float-right">
                                <a class="btn btn-light btn-sm"
                                   href="{{ url_for('.reply_comment', comment_id=comment.id) }}">Reply</a>
                                {% if current_user.is_authenticated %}
                                    <a class="btn btn-light btn-sm" href="mailto:{{ comment.email }}">Email</a>
                                    <form class="inline" method="post"
                                          action="{{ url_for('admin.delete_comment', comment_id=comment.id, next=request.full_path) }}">
                                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                                        <button type="submit" class="btn btn-danger btn-sm"
                                                onclick="return confirm('Are you sure?');">Delete
                                        </button>
                                    </form>
                                {% endif %}
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            {% else %}
                <div class="tip"><h5>No comments.</h5></div>
            {% endif %}
        </div>
        {% if comments %}
            {{ render_pagination(pagination, fragment='#comments') }}
        {% endif %}
        {% if request.args.get('reply') %}
            <div class="alert alert-dark">
                Reply to <strong>{{ request.args.get('author') }}</strong>:
                <a class="float-right" href="{{ url_for('.show_post', post_id=post.id) }}">Cancel</a>
            </div>
        {% endif %}
        {% if post.can_comment %}
            <div id="comment-form">
                {{ render_form(form, action=request.full_path) }}
            </div>
        {% else %}
            <div class="tip"><h5>Comment disabled.</h5></div>
        {% endif %}
    </div>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.08.12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档