<!DOCTYPE html>
{% load static category %}
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>{% block title %}CaoJay的博客，基于Django实现{% endblock %}</title>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
</head>
<style type="text/css">
    body {
        background-image: url("../../static/images/bg.png");
        background-repeat: no-repeat;
        background-size: 100% 100%;
        background-attachment: fixed;
    }
</style>

<body>
	<nav class="navbar is-primary container" role="navigation" aria-label="main navigation">
        <div class="navbar-brand">
            <a class="navbar-item" href="https://bulma.io">
                <img src="../../static/images/logo.png" width="112" height="28">
            </a>
            <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false"
					data-target="navbarBasicExample">
                <span aria-hidden="true"></span>
                <span aria-hidden="true"></span>
                <span aria-hidden="true"></span>
            </a>
        </div>
        <div id="navbarBasicExample" class="navbar-menu">
            <div class="navbar-start">
                {% block navbar-start %}
                    <a class="navbar-item" href="/">
                        H&nbsp;O&nbsp;M&nbsp;E
                    </a>
                    {% get_category_list as category_list %}
                    {% for category in category_list %}
                        <a class="navbar-item" href="{% url 'passage:classify' category.id %}">
                            {{ category.name }}
                        </a>
                    {% endfor %}
                {% endblock %}
            </div>
            <div class="navbar-end">
                {% block navbar-end %}
                    <div class="navbar-item">
                        {% if user.is_authenticated %}
                            <div class="buttons">
                                <a class="button is-primary" href="{% url 'user:center' %}" target="_blank">
                                    <strong> {{ request.user.username }}</strong>
                                </a>
                                <a href="{% url 'user:logout' %}" class="button is-primary">退&nbsp;&nbsp;出</a>
                            </div>
                        {% else %}
                            <div class="buttons">
                                <a class="button is-primary" href="{% url 'user:register' %}" target="_blank">
                                    <strong>注&nbsp;&nbsp;册</strong>
                                </a>
                                <a class="button is-light" href="{% url 'user:login' %}" target="_blank">
                                    登&nbsp;&nbsp;录
                                </a>
                            </div>
                        {% endif %}
                    </div>
                {% endblock %}
            </div>
        </div>
    </nav>
	    <section class="section">
		    <div class=" container">
			    <div class="columns">
				    <div class="column is-8" style="opacity: 70%;">
                        {% block section %}
                        {% block archives %}
                        {% endblock  %}
                        {% if page_object %}
                            {% for post in page_object %}
                                <div class="box">
                                    <h1 class="is-size-5 has-text-weight-bold">
                                        <a href="{% url 'passage:content' post.id %}"> {{ post.title }}</a>
                                    </h1>
                                    <div class=" is-size-7 has-text-grey-light pt-1 pb-1">
                                        <span class="mr-3">作&nbsp;者：{{ post.owner }}</span><span>发布日期：{{ post.add_date }}</span>
                                    </div>
                                    <p class="mt-3">{{ post.desc|truncatechars:50 }}</p>
                                </div>
                            {% endfor %}
                        {% else %}
                                <div class="box">
                                    <p class="has-text-danger">文章不存在！</p>
                                </div>
                        {% endif %}
					        {% if page_object %}
						        <nav class="pagination is-centered" role="navigation" aria-label="pagination">
						            {% if page_object.has_previous %}
							            <a class="pagination-previous" href="?page={{ page_object.previous_page_number }}">Previous</a>
						            {% endif %}
						            {% if page_object.has_next %}
						                <a class="pagination-next" href="?page={{ page_object.next_page_number }}">Next page</a>
						            {% endif %}
						            <ul class="pagination-list">
                                        {% if page_object.has_previous %}
                                            <li><a class="pagination-link" aria-label="Goto page 45" href="?page={{ page_object.previous_page_number }}">{{ page_object.previous_page_number }}</a></li>
                                        {% endif %}
                                        <li><a class="pagination-link is-current" aria-label="Page {{ page_object.number }}" aria-current="page" href='?page={{ page_object.number }}'>{{ page_object.number }}</a></li>
                                        {% if page_object.has_next %}
                                            <li><a class="pagination-link" href="?page={{ page_object.next_page_number }}" aria-label="Goto page {{ page_object.next_page_number }}">{{ page_object.next_page_number }}</a></li>
                                        {% endif %}
                                    </ul>
                                </nav>
						    {% endif %}
					    {% endblock %}
				    </div>
				    <div class="column is-4">
                        {% block right %}
                        {% get_sidebar_list as sidebar_list %}
                        {% for sidebar in sidebar_list %}
                            <div class="box">
                                <h1 class=" is-size-5 title">{{ sidebar.title }}</h1>
                                <p>{{ sidebar.get_content|safe }}</p>
                            </div>
                        {% endfor %}
                        {% endblock %}
				    </div>
			    </div>
		    </div>
	    </section>
        {% block footer %}
            <footer class="footer container">
                <div class=" has-text-centered">
                    bottle
                </div>
            </footer>
        {% endblock %}
    </body>
</html>
