From 5f4689f9302d1050c052beb0781dc1c4b6ebe37e Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 12:37:27 -0400 Subject: [PATCH 01/10] Add tag parameter to ItemList macro --- src/moin/macros/ItemList.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/moin/macros/ItemList.py b/src/moin/macros/ItemList.py index 410133269..2ee4c7a96 100644 --- a/src/moin/macros/ItemList.py +++ b/src/moin/macros/ItemList.py @@ -29,6 +29,8 @@ skiptag: a tag name, items with tag will be skipped + tag: only include items that have been tagged with this name + display: How should the link be displayed? Options: @@ -79,7 +81,8 @@ def macro(self, content, arguments, page_url, alternative): ordered = False display = "FullPath" skiptag = "" - + tag = "" + # process input args = [] if arguments: @@ -119,6 +122,8 @@ def macro(self, content, arguments, page_url, alternative): display = val # let 'create_pagelink_list' throw an exception if needed elif key == "skiptag": skiptag = val + elif key == "tag": + tag = val else: err_msg = _('Unrecognized key "{key}".').format(key=key) return fail_message(err_msg, alternative) @@ -136,7 +141,7 @@ def macro(self, content, arguments, page_url, alternative): return fail_message(err_msg, alternative) # process subitems - children = get_item_names(item, startswith=startswith, skiptag=skiptag) + children = self.get_item_names(item, startswith=startswith, skiptag=skiptag, tag=tag) if regex: try: regex_re = re.compile(regex, re.IGNORECASE) From fe8081982ea24cc5d121b15b32739e55bab09fd9 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 12:42:01 -0400 Subject: [PATCH 02/10] Add tag parameter to get_item_names() --- src/moin/macros/_base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/moin/macros/_base.py b/src/moin/macros/_base.py index 2eb3db5ad..626bbf1e5 100644 --- a/src/moin/macros/_base.py +++ b/src/moin/macros/_base.py @@ -19,7 +19,7 @@ from moin.constants.keys import TAGS -def get_item_names(name="", startswith="", kind="files", skiptag=""): +def get_item_names(name="", startswith="", kind="files", skiptag="", tag=''): """ For the specified item, return the fullname of matching descendents. @@ -39,6 +39,8 @@ def get_item_names(name="", startswith="", kind="files", skiptag=""): skiptag: skip items having this tag + tag: only include items having this tag + Output: A List of descendent items using their "fullname" value @@ -53,11 +55,17 @@ def get_item_names(name="", startswith="", kind="files", skiptag=""): for item in files: if skiptag and TAGS in item.meta and skiptag in item.meta[TAGS]: continue + if tag: + if not TAGS in item.meta or tag not in item.meta[TAGS]: + continue item_names.append(item.fullname) if kind == "dirs" or kind == "both": for item in dirs: if skiptag and skiptag in item.meta[TAGS]: continue + if tag: + if not TAGS in item.meta or tag not in item.meta[TAGS]: + continue item_names.append(item.fullname) if kind == "both": item_names = list(set(item_names)) # remove duplicates From 4650aff5c8392ff126ed802e06577598f5e179e5 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 12:44:16 -0400 Subject: [PATCH 03/10] add tag parameter to documentation --- docs/user/moinwiki.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user/moinwiki.rst b/docs/user/moinwiki.rst index 091fe9ca2..51bfaf5cd 100644 --- a/docs/user/moinwiki.rst +++ b/docs/user/moinwiki.rst @@ -882,6 +882,7 @@ The **ItemList** macro accepts multiple named parameters: item, startswith, rege - <> displays ordered list of subitems, default is unordered - <> lists subitems starting with Foo - <> lists subitems ending with Foo + - <> only include items with this tag - <> ignore items with this tag - <> default, displays full path to subitems - <> displays last component of the FullPath, including the '/' From ab520cc8f0607faf537aa8be5a2e786bf72f9225 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 12:46:53 -0400 Subject: [PATCH 04/10] add tag parameter to ItemList in documentation --- docs/user/creolewiki.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user/creolewiki.rst b/docs/user/creolewiki.rst index 8eb70acf9..789cc281e 100644 --- a/docs/user/creolewiki.rst +++ b/docs/user/creolewiki.rst @@ -429,6 +429,7 @@ The **ItemList** macro accepts multiple named parameters: item, startswith, rege - <> displays ordered list of subitems, default is unordered - <> lists subitems starting with Foo - <> lists subitems ending with Foo + - <> only include items with this tag - <> ignore items with this tag - <> default, displays full path to subitems - <> displays last component of the FullPath, including the '/' From a46e35af9a86f4d80a6ad06e5aa95916fe665363 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 18:47:26 -0400 Subject: [PATCH 05/10] Fix syle requirements --- docs/user/creolewiki.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user/creolewiki.rst b/docs/user/creolewiki.rst index 789cc281e..881df3e68 100644 --- a/docs/user/creolewiki.rst +++ b/docs/user/creolewiki.rst @@ -429,7 +429,7 @@ The **ItemList** macro accepts multiple named parameters: item, startswith, rege - <> displays ordered list of subitems, default is unordered - <> lists subitems starting with Foo - <> lists subitems ending with Foo - - <> only include items with this tag + - <> only include items with this tag - <> ignore items with this tag - <> default, displays full path to subitems - <> displays last component of the FullPath, including the '/' From a331272f13a8c13f5e47708ce460d6050432fc2b Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 18:58:49 -0400 Subject: [PATCH 06/10] Fix syle requirements --- src/moin/macros/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moin/macros/_base.py b/src/moin/macros/_base.py index 626bbf1e5..e19d7887f 100644 --- a/src/moin/macros/_base.py +++ b/src/moin/macros/_base.py @@ -64,7 +64,7 @@ def get_item_names(name="", startswith="", kind="files", skiptag="", tag=''): if skiptag and skiptag in item.meta[TAGS]: continue if tag: - if not TAGS in item.meta or tag not in item.meta[TAGS]: + if TAGS not in item.meta or tag not in item.meta[TAGS]: continue item_names.append(item.fullname) if kind == "both": From a06c30ae0ea54639baaca203b0757d14b446dae3 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Thu, 3 Oct 2024 19:01:26 -0400 Subject: [PATCH 07/10] Fix syle requirements --- src/moin/macros/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moin/macros/_base.py b/src/moin/macros/_base.py index e19d7887f..347e448ec 100644 --- a/src/moin/macros/_base.py +++ b/src/moin/macros/_base.py @@ -19,7 +19,7 @@ from moin.constants.keys import TAGS -def get_item_names(name="", startswith="", kind="files", skiptag="", tag=''): +def get_item_names(name="", startswith="", kind="files", skiptag="", tag=""): """ For the specified item, return the fullname of matching descendents. From 8f94980e7f55383db92e3dac1653d0c43e8accd4 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Fri, 4 Oct 2024 08:53:11 -0400 Subject: [PATCH 08/10] Fix style requirements --- src/moin/macros/ItemList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moin/macros/ItemList.py b/src/moin/macros/ItemList.py index 2ee4c7a96..5e9409353 100644 --- a/src/moin/macros/ItemList.py +++ b/src/moin/macros/ItemList.py @@ -82,7 +82,7 @@ def macro(self, content, arguments, page_url, alternative): display = "FullPath" skiptag = "" tag = "" - + # process input args = [] if arguments: From 5e3c35358d76b57972190b1ad478b731eb976455 Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Fri, 4 Oct 2024 08:56:56 -0400 Subject: [PATCH 09/10] Fix style requirements --- src/moin/macros/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moin/macros/_base.py b/src/moin/macros/_base.py index 347e448ec..ace3a9887 100644 --- a/src/moin/macros/_base.py +++ b/src/moin/macros/_base.py @@ -56,7 +56,7 @@ def get_item_names(name="", startswith="", kind="files", skiptag="", tag=""): if skiptag and TAGS in item.meta and skiptag in item.meta[TAGS]: continue if tag: - if not TAGS in item.meta or tag not in item.meta[TAGS]: + if TAGS not in item.meta or tag not in item.meta[TAGS]: continue item_names.append(item.fullname) if kind == "dirs" or kind == "both": From 1199662b052af114f67b48333a2841967d00184f Mon Sep 17 00:00:00 2001 From: Vic Simeone Date: Fri, 4 Oct 2024 10:25:45 -0400 Subject: [PATCH 10/10] Fix call to get_item_names --- src/moin/macros/ItemList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moin/macros/ItemList.py b/src/moin/macros/ItemList.py index 5e9409353..c09bd3ed1 100644 --- a/src/moin/macros/ItemList.py +++ b/src/moin/macros/ItemList.py @@ -141,7 +141,7 @@ def macro(self, content, arguments, page_url, alternative): return fail_message(err_msg, alternative) # process subitems - children = self.get_item_names(item, startswith=startswith, skiptag=skiptag, tag=tag) + children = get_item_names(item, startswith=startswith, skiptag=skiptag, tag=tag) if regex: try: regex_re = re.compile(regex, re.IGNORECASE)