-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
class card(nodes.General, nodes.Element): | ||
pass | ||
|
||
|
||
def visit_card_node(self, node): | ||
title = node.get("title", "") | ||
key = title or node["github"] | ||
key = key.lower().replace(" ", "-") | ||
title = f"<h4>{title}</h4>" if len(title) > 0 else "" | ||
col_extra_class = "column-half" if title else "" | ||
body = f"""<div class="column {col_extra_class}"> | ||
{title} | ||
<div class="card"> | ||
<img class="dark-light" src="/_static/img/{node['img_name']}" alt="{node['name']}"> | ||
<p>{node['name']}</p> | ||
<p><button type="button" class="btn btn-sunpy btn-sunpy1" data-bs-toggle="modal" data-bs-target="#{key}">More Info</button></p> | ||
<div class="modal fade" id="{key}" tabindex=-1> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h4 class="modal-title center">{node['name']}</h4> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
""" | ||
self.body.append(body) | ||
|
||
|
||
def depart_card_node(self, node): | ||
body = f""" | ||
<p>Affiliation: <a href="{node['aff_link']}">{node['aff_name']}</a></p> | ||
<p>GitHub: <a href="https://github.com/{node['github']}">{node['github']}</a></p> | ||
<p>Start Date: {node['date']}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div></div>""" | ||
self.body.append(body) | ||
|
||
|
||
class Card(Directive): | ||
has_content = True | ||
required_arguments = 1 | ||
optional_arguments = 6 | ||
option_spec = { # NOQA: RUF012 | ||
"img_name": directives.unchanged, | ||
"title": directives.unchanged, | ||
"github": directives.unchanged, | ||
"aff_name": directives.unchanged, | ||
"aff_link": directives.unchanged, | ||
"date": directives.unchanged, | ||
"desc": directives.unchanged, | ||
} | ||
|
||
def run(self): | ||
title = self.options.get("title") if "title" in self.options else "" | ||
img_name = self.options.get("img_name") if "img_name" in self.options else "sunpy_icon.svg" | ||
github = self.options.get("github") if "github" in self.options else "" | ||
aff_name = self.options.get("aff_name") if "aff_name" in self.options else "" | ||
aff_link = self.options.get("aff_link") if "aff_link" in self.options else "" | ||
date = self.options.get("date") if "date" in self.options else "" | ||
desc = self.options.get("desc") if "desc" in self.options else "N/A" | ||
name = " ".join(self.arguments) | ||
out = card( | ||
name=name, | ||
img_name=img_name, | ||
title=title, | ||
github=github, | ||
aff_name=aff_name, | ||
aff_link=aff_link, | ||
date=date, | ||
desc=desc, | ||
) | ||
self.state.nested_parse(self.content, 0, out) | ||
return [out] | ||
|
||
|
||
def copy_asset_files(app, exc): | ||
if exc is None: # Build succeeded | ||
for path in (Path(__file__).parent / "static").glob("*"): | ||
copy_asset(str(path), str(Path(app.outdir) / Path("_static"))) |