From d1ec35b1f3ad64428b38fbd97390fe34fb16b5d2 Mon Sep 17 00:00:00 2001 From: Roberto Prevato Date: Sun, 2 Oct 2022 15:49:50 +0200 Subject: [PATCH] Add support to display the contributors count (#18) --- CHANGELOG.md | 1 + neoteroi/contribs/__init__.py | 6 ++++-- neoteroi/contribs/html.py | 7 +++++++ styles/contribs.scss | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a4727..3f68ab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 contributions from bots). - - Adds the possibility to merge contributors' information for cases in which the same person commits using two different email addresses. +- - Adds the possibility to display an element with the count of contributors. - Resolves a small issue in pip package resolution. ## [0.0.8] - 2022-10-01 diff --git a/neoteroi/contribs/__init__.py b/neoteroi/contribs/__init__.py index 882c2ef..a70965a 100644 --- a/neoteroi/contribs/__init__.py +++ b/neoteroi/contribs/__init__.py @@ -28,9 +28,10 @@ class ContribsPlugin(BasePlugin): config_scheme = ( ("contributors_label", c.Type(str, default="Contributors")), ("last_modified_label", c.Type(str, default="Last modified on")), - ("last_modified_time", c.Type(bool, default=True)), ("time_format", c.Type(str, default="%Y-%m-%d %H:%M:%S")), ("contributors", c.Type(list, default=[])), + ("show_last_modified_time", c.Type(bool, default=True)), + ("show_contributors_title", c.Type(bool, default=False)), ) def __init__(self) -> None: @@ -114,7 +115,8 @@ def _set_contributors(self, markdown: str, page: Page) -> str: ContribsViewOptions( self.config["contributors_label"], self.config["last_modified_label"], - self.config["last_modified_time"], + self.config["show_last_modified_time"], + self.config["show_contributors_title"], self.config["time_format"], ), ) diff --git a/neoteroi/contribs/html.py b/neoteroi/contribs/html.py index f29a314..42d8270 100644 --- a/neoteroi/contribs/html.py +++ b/neoteroi/contribs/html.py @@ -19,6 +19,7 @@ class ContribsViewOptions: contributors_label: str last_modified_label: str show_last_modified_time: bool + show_contributors_title: bool time_format: str @@ -43,6 +44,12 @@ def contribution_stats_to_element( else: last_modified_time.text = last_commit_date.strftime(options.time_format) + if options.show_contributors_title: + contributors_title = etree.SubElement( + element, "p", {"class": "nt-contributors-title"} + ) + contributors_title.text = f"{options.contributors_label} ({len(contributors)})" + contributors_parent = etree.SubElement(element, "div", {"class": "nt-contributors"}) for i, contributor in enumerate( diff --git a/styles/contribs.scss b/styles/contribs.scss index 6012364..da5d081 100644 --- a/styles/contribs.scss +++ b/styles/contribs.scss @@ -28,6 +28,11 @@ $dot-size: 40px; } } + .nt-contributors-title { + font-style: italic; + margin-bottom: 0; + } + .nt-initials { text-transform: uppercase; font-size: 24px;