Update
This commit is contained in:
@@ -1,101 +1,22 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% extends "/public/skeleton.html" %}
|
||||
{% block content %}
|
||||
|
||||
{% raw %}
|
||||
<h3>
|
||||
<a class="btn btn-outline-secondary" href="/tags"><i class="fa fa-chevron-left"></i></a>
|
||||
Тег {{ tag.name }}</h3>
|
||||
<a href="/tags">Назад</a>
|
||||
<h1>Тег {{ pagedata['tag'].name }}</h1>
|
||||
<hr />
|
||||
{% endraw %}
|
||||
|
||||
<pagination-component v-bind:pagination="pagination" v-bind:click-handler="getPages"></pagination-component>
|
||||
{% include 'pagination-curl.html' %}
|
||||
|
||||
{% include '/inc/pages.html' %}
|
||||
|
||||
<pagination-component v-bind:pagination="pagination" v-bind:click-handler="getPages"></pagination-component>
|
||||
{% include 'pagination-curl.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{% raw %}
|
||||
<ol class="breadcrumb mt-3">
|
||||
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
|
||||
<li class="breadcrumb-item"><a href="/tags">Список тегов</a></li>
|
||||
<li class="breadcrumb-item">{{ tag.name }}</li>
|
||||
</ol>
|
||||
{% endraw %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript" src="/static/components/pagination.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
Object.assign(root.data, {
|
||||
tag: {{ pagedata['tag']|tojson|safe }},
|
||||
raw_pages: [],
|
||||
pagination: {{ pagedata['pagination']|tojson|safe }},
|
||||
});
|
||||
Object.assign(root.methods, {
|
||||
getPages: function() {
|
||||
/* Получить список статей */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.pages",
|
||||
"params": {
|
||||
"id": vm.tag.id,
|
||||
"page": vm.pagination.page
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.raw_pages = response.data['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
root.created = function() {
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
[
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.pages",
|
||||
"params": {
|
||||
"id": vm.tag.id,
|
||||
"page": vm.pagination.page
|
||||
},
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.pages.count",
|
||||
"params": {},
|
||||
"id": 1
|
||||
}
|
||||
]
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data[0]) {
|
||||
vm.raw_pages = response.data[0]['result'];
|
||||
}
|
||||
if ('result' in response.data[1]) {
|
||||
vm.pagination.size = response.data[1]['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
Object.assign(root.computed, {
|
||||
pages: function() {
|
||||
let vm = this;
|
||||
return vm.raw_pages;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<ul>
|
||||
<li><a href="/">Домой</a></li>
|
||||
<li><a href="/tags">Список тегов</a></li>
|
||||
<li>{{ pagedata['tag'].name }}</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,51 +1,18 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% extends "/public/skeleton.html" %}
|
||||
{% block content %}
|
||||
|
||||
<h3>Список тегов</h3>
|
||||
<h1>Список тегов</h1>
|
||||
<hr />
|
||||
|
||||
{% raw %}
|
||||
<div class="row">
|
||||
<div class="col py-2">
|
||||
<div class="btn-group mr-2 mb-3" v-for="(tag, tagIdx) in tags">
|
||||
<a class="btn btn-outline-secondary" :href="'/tag/' + tag.id">{{ tag.name }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endraw %}
|
||||
<p>{% for tag in pagedata['tags'] %}
|
||||
<a href="/tag/{{ tag.id }}">{{ tag.name }}</a> /
|
||||
{% endfor %}</p>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
<ol class="breadcrumb mt-3">
|
||||
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
|
||||
<li class="breadcrumb-item">Список тегов</li>
|
||||
<ol>
|
||||
<li><a href="/">Домой</a></li>
|
||||
<li>Список тегов</li>
|
||||
</ol>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript">
|
||||
Object.assign(root.data, {
|
||||
tags: [],
|
||||
});
|
||||
root.created = function() {
|
||||
/* Получить список тегов после загрузки страницы */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tags',
|
||||
"params": {},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.tags = response.data['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -4,7 +4,7 @@ __email__ = 'remizoffalex@mail.ru'
|
||||
|
||||
from flask import abort, render_template
|
||||
|
||||
from .. import app, models
|
||||
from .. import app, lib, models
|
||||
|
||||
|
||||
def tags():
|
||||
@@ -12,11 +12,14 @@ def tags():
|
||||
"""
|
||||
pagedata = {}
|
||||
pagedata['title'] = 'Список меток - ' + app.config['TITLE']
|
||||
pagedata['tags'] = models.db_session.query(
|
||||
models.Tag
|
||||
).all()
|
||||
body = render_template('guest/tags.html', pagedata=pagedata)
|
||||
return body
|
||||
|
||||
|
||||
def tag_id(id):
|
||||
def tag_id(id: int, page: int = 1):
|
||||
"""Метка
|
||||
"""
|
||||
pagedata = {}
|
||||
@@ -32,13 +35,28 @@ def tag_id(id):
|
||||
tag.name,
|
||||
app.config['TITLE']
|
||||
)
|
||||
pagedata['tag'] = tag.as_dict()
|
||||
pagedata['tag'] = tag
|
||||
|
||||
pagedata['pagination'] = {
|
||||
"page": 1,
|
||||
"per_page": app.config['ITEMS_ON_PAGE'],
|
||||
"size": 0
|
||||
}
|
||||
pages_idx = models.db_session.query(
|
||||
models.TagPage.page_id
|
||||
).filter(
|
||||
models.TagPage.tag_id==id
|
||||
)
|
||||
pages = models.db_session.query(
|
||||
models.Page
|
||||
).filter(
|
||||
models.Page.id.in_(pages_idx)
|
||||
).order_by(
|
||||
models.Page.title.asc()
|
||||
)
|
||||
|
||||
pagedata['pagination'] = lib.Pagination(
|
||||
page,
|
||||
app.config['ITEMS_ON_PAGE'],
|
||||
pages.count()
|
||||
)
|
||||
pagedata['pagination'].url = '/tag/{}/pages'.format(id)
|
||||
pagedata['pages'] = pages.all()
|
||||
|
||||
body = render_template('guest/tag.html', pagedata=pagedata)
|
||||
return body
|
||||
|
||||
Reference in New Issue
Block a user