From 5d269ea1eebcacf75e9cf58f8d5d84592e23335f Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Thu, 24 Nov 2016 15:05:29 +0100 Subject: [PATCH] Added date in Duplicate for better distinguish duplicate. Also, added a timeout for the dataTable in duplicate inside the modal. --- bin/Duplicates.py | 7 +++++-- var/www/Flask_server.py | 16 +++++++++++++--- var/www/templates/search.html | 3 ++- var/www/templates/show_saved_paste.html | 2 ++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/Duplicates.py b/bin/Duplicates.py index cd9e1f97..50def29f 100755 --- a/bin/Duplicates.py +++ b/bin/Duplicates.py @@ -131,8 +131,10 @@ if __name__ == "__main__": # index of paste index_current = r_serv_dico.get(dico_hash) paste_path = r_serv_dico.get(index_current) + paste_date = r_serv_dico.get(index_current+'_date') + paste_date = paste_date if paste_date != None else "No date available" if paste_path != None: - hash_dico[dico_hash] = (hash_type, paste_path, percent) + hash_dico[dico_hash] = (hash_type, paste_path, percent, paste_date) print '['+hash_type+'] '+'comparing: ' + str(PST.p_path[44:]) + ' and ' + str(paste_path[44:]) + ' percentage: ' + str(percent) except Exception,e: @@ -142,6 +144,7 @@ if __name__ == "__main__": # Add paste in DB after checking to prevent its analysis twice # hash_type_i -> index_i AND index_i -> PST.PATH r_serv1.set(index, PST.p_path) + r_serv1.set(index+'_date', PST._get_p_date()) r_serv1.sadd("INDEX", index) # Adding hashes in Redis for hash_type, paste_hash in paste_hashes.iteritems(): @@ -152,7 +155,7 @@ if __name__ == "__main__": # if there is data in this dictionnary if len(hash_dico) != 0: - # paste_tuple = (paste_path, percent) + # paste_tuple = (hash_type, date, paste_path, percent) for dico_hash, paste_tuple in hash_dico.items(): dupl.append(paste_tuple) diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 2b01b6fa..fcd67a21 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -143,6 +143,7 @@ def showpaste(content_range): p_duplicate_full_list = json.loads(paste._get_p_duplicate()) p_duplicate_list = [] p_simil_list = [] + p_date_list = [] p_hashtype_list = [] @@ -170,20 +171,29 @@ def showpaste(content_range): hash_types = str(hash_types).replace("[","").replace("]","") if len(hash_types)==1 else str(hash_types) comp_vals = str(comp_vals).replace("[","").replace("]","") if len(comp_vals)==1 else str(comp_vals) - new_dup_list.append([hash_types.replace("'", ""), p_duplicate_full_list[dup_list_index][1], comp_vals]) + if len(p_duplicate_full_list[dup_list_index]) > 3: + try: + date_paste = str(int(p_duplicate_full_list[dup_list_index][3])) + date_paste = date_paste[0:4]+"-"+date_paste[4:6]+"-"+date_paste[6:8] + except ValueError: + date_paste = str(p_duplicate_full_list[dup_list_index][3]) + else: + date_paste = "No date available" + new_dup_list.append([hash_types.replace("'", ""), p_duplicate_full_list[dup_list_index][1], comp_vals, date_paste]) # Create the list to pass to the webpage for dup_list in new_dup_list: - hash_type, path, simil_percent = dup_list + hash_type, path, simil_percent, date_paste = dup_list p_duplicate_list.append(path) p_simil_list.append(simil_percent) p_hashtype_list.append(hash_type) + p_date_list.append(date_paste) if content_range != 0: 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), duplicate_list = p_duplicate_list, simil_list = p_simil_list, hashtype_list = p_hashtype_list) + 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, hashtype_list = p_hashtype_list, date_list=p_date_list) def getPastebyType(server, module_name): all_path = [] diff --git a/var/www/templates/search.html b/var/www/templates/search.html index e7351ca1..9b43967d 100644 --- a/var/www/templates/search.html +++ b/var/www/templates/search.html @@ -115,7 +115,7 @@
- Totalling {{ num_res }} items + Totalling {{ num_res }} results related to paste content
@@ -266,6 +266,7 @@ // clear data by removing html, body, head tags. prevent dark modal background stack bug. var cleared_data = data.split("")[1].split("")[0]; $("#mymodalbody").html(cleared_data); + setTimeout(function() { $('#tableDup').DataTable(); }, 150); var button = $(''); button.tooltip(); diff --git a/var/www/templates/show_saved_paste.html b/var/www/templates/show_saved_paste.html index 6ab209ca..ef955bfe 100644 --- a/var/www/templates/show_saved_paste.html +++ b/var/www/templates/show_saved_paste.html @@ -61,6 +61,7 @@ Hash type Paste info + Date Path @@ -69,6 +70,7 @@ {{ hashtype_list[i] }} Similarity: {{ simil_list[i] }}% + {{ date_list[i] }} {{ dup_path }} {% set i = i + 1 %}