{% extends 'snippet/layout.html' %}
{% load forum_extras %}

{% block stylesheet %}
    <link rel="stylesheet" href="/static/css/codehilite.css" />
{% endblock %}

{% block javascript %}
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({
            tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
        });
    </script>
    <script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{% endblock %}

{% block main %}
    <div class="notifications container-box">
        <div class="ui-header">
            <span class="bread-nav">小程序开发社区 › 提醒消息</span>
        </div>

        <div class="ui-content">
            {% for notification in notifications %}
                <div class="notification-item">
                    <a href="/u/{{ notification.trigger_user.username }}/">
                        <img src="/static/avatar/m_{% if notification.trigger_user.avatar %}{{ notification.trigger_user.avatar }}{% else %}default.png{% endif %}" alt="" class="avatar" />
                    </a>
                    <div class="main">
                        {% ifequal notification.involved_type 0 %}
                            <span class="title"><a href="/u/{{ notification.trigger_user.username }}/">{{ notification.trigger_user.username }}</a> 在 <a href="/t/{{ notification.involved_topic.id }}/">{{ notification.involved_topic.title }}</a> 中提到了你</span>
                        {% endifequal %}
                        {% ifequal notification.involved_type 1 %}
                            <span class="title"><a href="/u/{{ notification.trigger_user.username }}/">{{ notification.trigger_user.username }}</a> 回复了你的主题 <a href="/t/{{ notification.involved_topic.id }}/">{{ notification.involved_topic.title }}</a></span>
                        {% endifequal %}
                        <div class="content">{{ notification.content|markdown|content_process|safe }}</div>
                    </div>
                </div>
            {% endfor %}

            {% ifequal page.total 0 %}
                <div class="pl10 pr10">
                    <div class="alert mt20">
                        您暂时还没有收到消息提醒。
                    </div>
                </div>
            {% endifequal %}
        </div>

        <div class="ui-footer">
            <div class="pagination">
                {% pagination page request.get_full_path %}
            </div>
        </div>
    </div>
{% endblock %}

{% block sidebar %}
    {% if user.is_authenticated %}
        <div class="usercard container-box">
            <div class="ui-header">
                <a href="/u/{{ user.username }}/">
                    <img src="/static/avatar/m_{% if user.avatar %}{{ user.avatar }}{% else %}default.png{% endif %}?t={% gen_random %}" alt="" class="avatar" />
                </a>
                <div class="username">{{ user.username }}</div>
                <div class="website"><a href="{% if user.website %}{{ user.website }}{% endif %}">{% if user.website %}{{ user.website }}{% endif %}</a></div>
            </div>
            <div class="ui-content">
                <div class="status status-topic">
                    <strong><a href="/u/{{ user.username }}/topics/">{{ counter.topics }}</a></strong> 主题
                </div>
                <div class="status status-reply">
                    <strong><a href="/u/{{ user.username }}/replies/">{{ counter.replies }}</a></strong> 回复
                </div>
                <div class="status status-favorite">
                    <strong><a href="/u/{{ user.username }}/favorites/">{{ counter.favorites }}</a></strong> 收藏
                </div>
                <div class="status status-reputation">
                    <strong>{% if user.reputation %}{{ user.reputation }}{% else %}0{% endif %}</strong> 威望
                </div>
            </div>
        </div>
    {% else %}
        <div class="login-box container-box">
            <div class="ui-content tc">
                <a class="btn btn-small" type="button" href="/login/">登录</a>
                <a class="btn btn-small" type="button" href="/register/">注册</a>
                <a class="btn btn-small" type="button" href="/forgot/">找回密码</a>
            </div>
        </div>
    {% endif %}
</div>
{% endblock %}
