mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
Added dynamic table sorting in search page. (Still need to add dependencies)
This commit is contained in:
parent
f1979f6dcb
commit
465244e1ce
3 changed files with 22 additions and 12 deletions
|
@ -198,6 +198,9 @@ class Paste(object):
|
||||||
def _get_p_date(self):
|
def _get_p_date(self):
|
||||||
return self.p_date
|
return self.p_date
|
||||||
|
|
||||||
|
def _get_p_size(self):
|
||||||
|
return self.p_size
|
||||||
|
|
||||||
def _get_hash_lines(self, min=1, start=1, jump=10):
|
def _get_hash_lines(self, min=1, start=1, jump=10):
|
||||||
"""
|
"""
|
||||||
Returning all the lines of the paste hashed.
|
Returning all the lines of the paste hashed.
|
||||||
|
|
|
@ -76,6 +76,8 @@ def search():
|
||||||
q.append(query)
|
q.append(query)
|
||||||
r = []
|
r = []
|
||||||
c = []
|
c = []
|
||||||
|
paste_date = []
|
||||||
|
paste_size = []
|
||||||
# Search
|
# Search
|
||||||
from whoosh import index
|
from whoosh import index
|
||||||
from whoosh.fields import Schema, TEXT, ID
|
from whoosh.fields import Schema, TEXT, ID
|
||||||
|
@ -89,10 +91,13 @@ def search():
|
||||||
results = searcher.search(query, limit=None)
|
results = searcher.search(query, limit=None)
|
||||||
for x in results:
|
for x in results:
|
||||||
r.append(x.items()[0][1])
|
r.append(x.items()[0][1])
|
||||||
content = Paste.Paste(x.items()[0][1]).get_p_content().decode('utf8', 'ignore')
|
paste = Paste.Paste(x.items()[0][1])
|
||||||
|
content = paste.get_p_content().decode('utf8', 'ignore')
|
||||||
content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
|
content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
|
||||||
c.append(content[0:content_range])
|
c.append(content[0:content_range])
|
||||||
return render_template("search.html", r=r, c=c, char_to_display=max_preview_modal)
|
paste_date.append(paste._get_p_date())
|
||||||
|
paste_size.append(paste._get_p_size())
|
||||||
|
return render_template("search.html", r=r, c=c, paste_date=paste_date, paste_size=paste_size, char_to_display=max_preview_modal)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
@ -156,14 +161,6 @@ def getmoredata():
|
||||||
requested_path = request.args.get('paste', '')
|
requested_path = request.args.get('paste', '')
|
||||||
paste = Paste.Paste(requested_path)
|
paste = Paste.Paste(requested_path)
|
||||||
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
||||||
'''final_index = (index_prev+1)*max_preview_modal
|
|
||||||
if final_index > len(p_content)-1: # prevent out of bound
|
|
||||||
final_index = len(p_content)-1
|
|
||||||
'''
|
|
||||||
#to_return = p_content[index_prev*max_preview_modal:final_index]
|
|
||||||
|
|
||||||
#correct_index = len(p_content) if max_preview_modal > len(p_content) else max_preview_modal
|
|
||||||
#to_return = str(p_content[correct_index:])
|
|
||||||
to_return = p_content[max_preview_modal:]
|
to_return = p_content[max_preview_modal:]
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,14 @@
|
||||||
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||||
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
||||||
<link href="{{ url_for('static', filename='css/dygraph_gallery.css') }}" rel="stylesheet" type="text/css" />
|
<link href="{{ url_for('static', filename='css/dygraph_gallery.css') }}" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.css') }}" rel="stylesheet" type="text/css" />
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/jquery-1.4.2.js') }}"></script>
|
||||||
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.js') }}"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.tooltip-inner {
|
.tooltip-inner {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
@ -81,6 +85,7 @@
|
||||||
<div class="row"> </div>
|
<div class="row"> </div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
</br>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="glyphicon glyphicon-search"></i> {{ r|length }} Results
|
<i class="glyphicon glyphicon-search"></i> {{ r|length }} Results
|
||||||
|
@ -90,11 +95,13 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- /.panel-heading -->
|
<!-- /.panel-heading -->
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<table class="table table-hover">
|
<table class="table table-striped table-bordered table-hover" id="myTable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Path</th>
|
<th style="max-width: 800px;">Path</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Size (Kb)</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -105,6 +112,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ i + 1 }}</td>
|
<td>{{ i + 1 }}</td>
|
||||||
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ path }}"> {{ path }}</a></td>
|
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ path }}"> {{ path }}</a></td>
|
||||||
|
<td>{{ paste_date[i] }}</td>
|
||||||
|
<td>{{ paste_size[i] }}</td>
|
||||||
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ prev_content }}"></span> <button type="button" class="btn-link" data-num="{{ i + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ i+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ prev_content }}"></span> <button type="button" class="btn-link" data-num="{{ i + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ i+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% set i = i + 1 %}
|
{% set i = i + 1 %}
|
||||||
|
@ -127,6 +136,7 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
$("#button_show_path").hide();
|
$("#button_show_path").hide();
|
||||||
|
$('#myTable').dataTable();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue