Skip to content

Commit

Permalink
Add support to display the contributors count (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoPrevato authored Oct 2, 2022
1 parent 0721756 commit d1ec35b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions neoteroi/contribs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"],
),
)
Expand Down
7 changes: 7 additions & 0 deletions neoteroi/contribs/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions styles/contribs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ $dot-size: 40px;
}
}

.nt-contributors-title {
font-style: italic;
margin-bottom: 0;
}

.nt-initials {
text-transform: uppercase;
font-size: 24px;
Expand Down

0 comments on commit d1ec35b

Please sign in to comment.