-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1612 from RogerHaase/1595-new-macros
1595 new macros
- Loading branch information
Showing
7 changed files
with
192 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright: 2024 MoinMoin:RogerHaase | ||
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details. | ||
|
||
""" | ||
Show contents of UserGroup attribute in metadata. | ||
""" | ||
|
||
from moin.macros._base import MacroBlockBase, fail_message | ||
from moin.items import Item | ||
from moin.constants.keys import USERGROUP | ||
from moin.i18n import _ | ||
|
||
|
||
class Macro(MacroBlockBase): | ||
def macro(self, content, arguments, page_url, alternative): | ||
url = str(page_url.path)[1:] | ||
try: | ||
item = Item.create(url) | ||
return item.meta[USERGROUP] | ||
except KeyError: | ||
msg = _('ShowUserGroup macro failed - metadata lacks "usergroup" attribute.') | ||
return fail_message(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright: 2024 MoinMoin:RogerHaase | ||
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details. | ||
|
||
""" | ||
Show contents of WikiDict attribute in metadata. | ||
""" | ||
|
||
from moin.macros._base import MacroBlockBase, fail_message | ||
from moin.items import Item | ||
from moin.constants.keys import WIKIDICT | ||
from moin.i18n import _ | ||
|
||
|
||
class Macro(MacroBlockBase): | ||
def macro(self, content, arguments, page_url, alternative): | ||
url = str(page_url.path)[1:] | ||
try: | ||
item = Item.create(url) | ||
return item.meta[WIKIDICT] | ||
except KeyError: | ||
msg = _('ShowWikiDict macro failed - metadata lacks "wikidict" attribute.') | ||
return fail_message(msg) |
Oops, something went wrong.