From ea7fd8d54ce2312e3cbf6538f4855700618b7f5a Mon Sep 17 00:00:00 2001 From: Terrtia Date: Wed, 24 Oct 2018 15:47:03 +0200 Subject: [PATCH] fix: [Duplicate] show duplicate with relative path --- bin/packages/Paste.py | 5 +++++ var/www/modules/Tags/Flask_Tags.py | 1 + var/www/modules/showpaste/Flask_showpaste.py | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/packages/Paste.py b/bin/packages/Paste.py index 5e63634e..d02a92f5 100755 --- a/bin/packages/Paste.py +++ b/bin/packages/Paste.py @@ -84,7 +84,10 @@ class Paste(object): PASTES_FOLDER = os.path.join(os.environ['AIL_HOME'], cfg.get("Directories", "pastes")) if PASTES_FOLDER not in p_path: + self.p_rel_path = p_path p_path = os.path.join(PASTES_FOLDER, p_path) + else: + self.p_rel_path = None self.p_path = p_path self.p_name = os.path.basename(self.p_path) @@ -284,6 +287,8 @@ class Paste(object): def _get_p_duplicate(self): self.p_duplicate = self.store_metadata.smembers('dup:'+self.p_path) + if self.p_rel_path is not None: + self.p_duplicate.union( self.store_metadata.smembers('dup:'+self.p_rel_path) ) if self.p_duplicate is not None: return list(self.p_duplicate) else: diff --git a/var/www/modules/Tags/Flask_Tags.py b/var/www/modules/Tags/Flask_Tags.py index e79d56fc..bbc918ed 100644 --- a/var/www/modules/Tags/Flask_Tags.py +++ b/var/www/modules/Tags/Flask_Tags.py @@ -28,6 +28,7 @@ r_serv_statistics = Flask_config.r_serv_statistics max_preview_char = Flask_config.max_preview_char max_preview_modal = Flask_config.max_preview_modal bootstrap_label = Flask_config.bootstrap_label +PASTES_FOLDER = Flask_config.PASTES_FOLDER Tags = Blueprint('Tags', __name__, template_folder='templates') diff --git a/var/www/modules/showpaste/Flask_showpaste.py b/var/www/modules/showpaste/Flask_showpaste.py index 4912e7b0..188af759 100644 --- a/var/www/modules/showpaste/Flask_showpaste.py +++ b/var/www/modules/showpaste/Flask_showpaste.py @@ -41,7 +41,9 @@ showsavedpastes = Blueprint('showsavedpastes', __name__, template_folder='templa # ============ FUNCTIONS ============ def showpaste(content_range, requested_path): + relative_path = None if PASTES_FOLDER not in requested_path: + relative_path = requested_path requested_path = os.path.join(PASTES_FOLDER, requested_path) # remove old full path #requested_path = requested_path.replace(PASTES_FOLDER, '') @@ -122,6 +124,8 @@ def showpaste(content_range, requested_path): active_taxonomies = r_serv_tags.smembers('active_taxonomies') l_tags = r_serv_metadata.smembers('tag:'+requested_path) + if relative_path is not None: + l_tags.union( r_serv_metadata.smembers('tag:'+relative_path) ) #active galaxies active_galaxies = r_serv_tags.smembers('active_galaxies') @@ -224,7 +228,6 @@ def showpaste(content_range, requested_path): @showsavedpastes.route("/showsavedpaste/") #completely shows the paste in a new tab def showsavedpaste(): requested_path = request.args.get('paste', '') - print(requested_path) return showpaste(0, requested_path) @showsavedpastes.route("/showsavedrawpaste/") #shows raw