mirror of https://github.com/CIRCL/AIL-framework
Added related functions and display of duplicated paste in search.py
parent
996c0e02de
commit
a6996c0b23
|
@ -91,6 +91,7 @@ class Paste(object):
|
||||||
self.p_langage = None
|
self.p_langage = None
|
||||||
self.p_nb_lines = None
|
self.p_nb_lines = None
|
||||||
self.p_max_length_line = None
|
self.p_max_length_line = None
|
||||||
|
self.p_duplicate = None
|
||||||
|
|
||||||
def get_p_content(self):
|
def get_p_content(self):
|
||||||
"""
|
"""
|
||||||
|
@ -277,6 +278,10 @@ class Paste(object):
|
||||||
return True, var
|
return True, var
|
||||||
else:
|
else:
|
||||||
return False, var
|
return False, var
|
||||||
|
|
||||||
|
def _get_p_duplicate(self):
|
||||||
|
self.p_duplicate = self.store.hget(self.p_path, "p_duplicate")
|
||||||
|
return self.p_duplicate if self.p_duplicate is not None else []
|
||||||
|
|
||||||
def save_all_attributes_redis(self, key=None):
|
def save_all_attributes_redis(self, key=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -58,6 +58,21 @@ def list_len(s):
|
||||||
return len(s)
|
return len(s)
|
||||||
app.jinja_env.filters['list_len'] = list_len
|
app.jinja_env.filters['list_len'] = list_len
|
||||||
|
|
||||||
|
def parseStringToList(the_string):
|
||||||
|
strList = ""
|
||||||
|
elemList = []
|
||||||
|
for c in the_string:
|
||||||
|
if c != ']':
|
||||||
|
if c != '[' and c !=' ' and c != '"':
|
||||||
|
strList += c
|
||||||
|
else:
|
||||||
|
the_list = strList.split(',')
|
||||||
|
if len(the_list) == 2:
|
||||||
|
elemList.append(the_list)
|
||||||
|
elif len(the_list) > 1:
|
||||||
|
elemList.append(the_list[1:])
|
||||||
|
strList = ""
|
||||||
|
return elemList
|
||||||
|
|
||||||
def showpaste(content_range):
|
def showpaste(content_range):
|
||||||
requested_path = request.args.get('paste', '')
|
requested_path = request.args.get('paste', '')
|
||||||
|
@ -71,10 +86,19 @@ def showpaste(content_range):
|
||||||
p_mime = paste.p_mime
|
p_mime = paste.p_mime
|
||||||
p_lineinfo = paste.get_lines_info()
|
p_lineinfo = paste.get_lines_info()
|
||||||
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
||||||
|
p_duplicate_full_list = parseStringToList(paste._get_p_duplicate())
|
||||||
|
p_duplicate_list = []
|
||||||
|
p_simil_list = []
|
||||||
|
|
||||||
|
for dup_list in p_duplicate_full_list:
|
||||||
|
path, simil_percent = dup_list
|
||||||
|
p_duplicate_list.append(path)
|
||||||
|
p_simil_list.append(simil_percent)
|
||||||
|
|
||||||
if content_range != 0:
|
if content_range != 0:
|
||||||
p_content = p_content[0:content_range]
|
p_content = p_content[0:content_range]
|
||||||
|
|
||||||
return render_template("show_saved_paste.html", date=p_date, source=p_source, encoding=p_encoding, language=p_language, size=p_size, mime=p_mime, lineinfo=p_lineinfo, content=p_content, initsize=len(p_content))
|
return render_template("show_saved_paste.html", date=p_date, source=p_source, encoding=p_encoding, language=p_language, size=p_size, mime=p_mime, lineinfo=p_lineinfo, content=p_content, initsize=len(p_content), duplicate_list = p_duplicate_list, simil_list = p_simil_list)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/_logs")
|
@app.route("/_logs")
|
||||||
|
|
|
@ -42,7 +42,17 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body" id="panel-body">
|
<div class="panel-body" id="panel-body">
|
||||||
<h4> Content: </h4>
|
{% if duplicate_list|length == 0 %}
|
||||||
|
<h4> No Duplicate </h4>
|
||||||
|
{% else %}
|
||||||
|
<h4> Duplicate list: </h4>
|
||||||
|
{% set i = 0 %}
|
||||||
|
{% for dup_path in duplicate_list %}
|
||||||
|
Similarity: {{ simil_list[i] }}% - <a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ dup_path }}" id='dup_path'>{{ dup_path }}</a></br>
|
||||||
|
{% set i = i + 1 %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
<h4> Content: </h4>
|
||||||
<p data-initsize="{{ initsize }}"> <xmp id="paste-holder">{{ content }}</xmp></p>
|
<p data-initsize="{{ initsize }}"> <xmp id="paste-holder">{{ content }}</xmp></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue