Skip to content

Commit

Permalink
添加页码
Browse files Browse the repository at this point in the history
  • Loading branch information
Cl0udG0d committed Apr 15, 2022
1 parent a5e026a commit eaaeea6
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/config/baseconfig.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import platform

# DEBUG = True
DEBUG = False
DEBUG = True
# DEBUG = False
SECRET_KEY = os.urandom(24)
HOSTNAME = '127.0.0.1' if platform.system().lower()=="windows" else "mysql"
REDIS_HOST = '127.0.0.1' if platform.system().lower()=="windows" else "redis"
Expand Down
15 changes: 11 additions & 4 deletions app/home/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
@home.route('/home/', methods=['GET', 'POST'])
@home.route('/', methods=['GET', 'POST'])
@login_required
def index(page=1):
per_page = 38
paginate = Log.query.order_by(Log.date.desc()).paginate(page, per_page, error_out=False)
def index(page=None):
if not page:
page=1
paginate = Log.query.order_by(Log.date.desc()).paginate(page=page, per_page=10, error_out=False)
logs = paginate.items
#
# blogs = Blog.query.filter_by(user_id=user_id).order_by(Blog.addtime.desc()).paginate(page=page, per_page=3)
# category = [(1, '情感'), (2, '星座'), (3, '爱情')]
# return render_template('blog_list.html', title='博客列表', session=session, blogs=blogs.items, category=category,
# pagination=blogs)

result={
'targets':len(BaseInfo.query.all()),
'pocs':len(PocList.query.all()),
'vuls':len(VulList.query.all()),
'plugins':len(pluginList.query.all())
}
return render_template('index.html', paginate=paginate, logs=logs,result=result)
return render_template('index.html', pagination=paginate,result=result,logs=logs)



Expand Down
5 changes: 2 additions & 3 deletions app/plugin/pluginlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
@plugin.route('/plugin/<int:page>', methods=['GET'])
@login_required
def pluginlist(page=1,msg=None):
per_page = 20
paginate = pluginList.query.order_by(pluginList.id.desc()).paginate(page, per_page, error_out=False)
paginate = pluginList.query.order_by(pluginList.id.desc()).paginate(page=page, per_page=10, error_out=False)
plugins = paginate.items
return render_template('pluginlist.html', paginate=paginate, plugins=plugins)
return render_template('pluginlist.html', pagination=paginate, plugins=plugins)


@plugin.route('/plugin/refresh', methods=['GET'])
Expand Down
5 changes: 2 additions & 3 deletions app/pocs/poclist.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ def allowed_file(filename):
@poc.route('/pocs/<int:page>', methods=['GET'])
@login_required
def poclist(page=1,msg=None):
per_page = 20
paginate = PocList.query.order_by(PocList.id.desc()).paginate(page, per_page, error_out=False)
paginate = PocList.query.order_by(PocList.id.desc()).paginate(page=page, per_page=10, error_out=False)
pocs = paginate.items
return render_template('poclist.html', paginate=paginate, pocs=pocs)
return render_template('poclist.html', pagination=paginate, pocs=pocs)



Expand Down
13 changes: 7 additions & 6 deletions app/tasks/tasklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
@tasks.route('/tasks/<int:page>', methods=['GET'])
@login_required
def tasklist(page=1,msg=None):
per_page = 38
paginate = Task.query.order_by(Task.id.desc()).paginate(page, per_page, error_out=False)
paginate = Task.query.order_by(Task.id.desc()).paginate(page=page, per_page=10, error_out=False)
tasks = paginate.items
return render_template('tasklist.html', paginate=paginate, tasks=tasks)
return render_template('tasklist.html', pagination=paginate,tasks=tasks)



Expand Down Expand Up @@ -99,11 +98,13 @@ def delAllTask():


@tasks.route('/tasks/seetask/<id>', methods=['GET'])
@tasks.route('/tasks/seetask/<id>/<int:page>', methods=['GET'])
@login_required
def seetask(id=None):
def seetask(page=1,id=1):
tasks= Task.query.filter(Task.id == id).first()
scantasks=scanTask.query.filter(scanTask.pid == tasks.tid).all()
return render_template('scantask.html',tasks=tasks,scantasks=scantasks)
paginate=scanTask.query.filter(scanTask.pid == tasks.tid).order_by(scanTask.id.desc()).paginate(page=page, per_page=10, error_out=False)
scantasks=paginate.items
return render_template('scantask.html',pagination=paginate,tasks=tasks,scantasks=scantasks)



Expand Down
5 changes: 2 additions & 3 deletions app/vuls/vullist.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
@vuls.route('/vuls/<int:page>', methods=['GET'])
@login_required
def vullist(page=1,msg=None):
per_page = 20
paginate = VulList.query.order_by(VulList.id.desc()).paginate(page, per_page, error_out=False)
paginate = VulList.query.order_by(VulList.id.desc()).paginate(page=page, per_page=10, error_out=False)
vuls = paginate.items
return render_template('vullist.html', paginate=paginate, vuls=vuls)
return render_template('vullist.html', pagination=paginate, vuls=vuls)



Expand Down
6 changes: 5 additions & 1 deletion assets/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@
{% endfor %}
</tbody>

</table>
</table>
<div style="text-align:center">
{% import 'pages.html' as pg %}
{{ pg.my_paginate(pagination,'home.index') }}
</div>
</div>
</div>
</div>
Expand Down
28 changes: 28 additions & 0 deletions assets/templates/pages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% macro my_paginate(pagination,url) %}
<nav>
<ul class="pagination">

{%if pagination.has_prev%}
<li class="page-item active"><a class="page-link" href="{{url_for(url,page=pagination.page-1)}}">上一页</a></li>
{%else%}
<li class="page-item disabled"><a class="page-link" href="#">上一页</a></li>
{%endif%}

{%for page in pagination.iter_pages(1,1,3,1)%}
{%if page%}
<li class="page-item {%if page==pagination.page%}active{%endif%}"><a class="page-link" href="{{url_for(url,page=page)}}">{{page}}</a></li>
{%else%}
<li class="page-item disabled"><a class="page-link" href="#">&hellip;</a></li>
{%endif%}

{%endfor%}

{%if pagination.has_next%}
<li class="page-item active"><a class="page-link" href="{{url_for(url,page=pagination.page+1)}}">下一页</a></li>
{%else%}
<li class="page-item disabled"><a class="page-link" href="#">下一页</a></li>
{%endif%}

</ul>
</nav>
{% endmacro %}
4 changes: 4 additions & 0 deletions assets/templates/pluginlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
{% endfor %}
</tbody>
</table>
<div style="text-align:center">
{% import 'pages.html' as pg %}
{{ pg.my_paginate(pagination,'plugin.pluginlist') }}
</div>
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions assets/templates/poclist.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
{% endfor %}
</tbody>
</table>
<div style="text-align:center">
{% import 'pages.html' as pg %}
{{ pg.my_paginate(pagination,'pocs.poclist') }}
</div>
</div>
</div>

Expand Down
28 changes: 28 additions & 0 deletions assets/templates/scanPages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% macro my_paginate(pagination,url,id) %}
<nav>
<ul class="pagination">

{%if pagination.has_prev%}
<li class="page-item active"><a class="page-link" href="{{url_for(url,page=pagination.page-1,id=id)}}">上一页</a></li>
{%else%}
<li class="page-item disabled"><a class="page-link" href="#">上一页</a></li>
{%endif%}

{%for page in pagination.iter_pages(1,1,3,1)%}
{%if page%}
<li class="page-item {%if page==pagination.page%}active{%endif%}"><a class="page-link" href="{{url_for(url,page=page,id=id)}}">{{page}}</a></li>
{%else%}
<li class="page-item disabled"><a class="page-link" href="#">&hellip;</a></li>
{%endif%}

{%endfor%}

{%if pagination.has_next%}
<li class="page-item active"><a class="page-link" href="{{url_for(url,page=pagination.page+1,id=id)}}">下一页</a></li>
{%else%}
<li class="page-item disabled"><a class="page-link" href="#">下一页</a></li>
{%endif%}

</ul>
</nav>
{% endmacro %}
5 changes: 4 additions & 1 deletion assets/templates/scantask.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@
{% endfor %}
</tbody>
</table>

<div style="text-align:center">
{% import 'scanPages.html' as pg %}
{{ pg.my_paginate(pagination,'tasks.seetask',tasks.id) }}
</div>
</div>
</div>

Expand Down
6 changes: 5 additions & 1 deletion assets/templates/tasklist.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ <h4 class="modal-title" id="myModalLabel">新增任务</h4>
{% endfor %}
</tbody>

</table>
</table>
<div style="text-align:center">
{% import 'pages.html' as pg %}
{{ pg.my_paginate(pagination,'tasks.tasklist') }}
</div>

</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions assets/templates/vullist.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@

</table>

<div style="text-align:center">
{% import 'pages.html' as pg %}
{{ pg.my_paginate(pagination,'vuls.vullist') }}
</div>

</div>
</div>

Expand Down

0 comments on commit eaaeea6

Please sign in to comment.