Skip to content

Commit

Permalink
Link to actual GitHub ref in tree
Browse files Browse the repository at this point in the history
  • Loading branch information
guyer committed Jul 16, 2023
1 parent 3407cad commit 59fcb2f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion update_pages/ntd2d_action/files/menufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ def get_contents(self):
else:
downloads = ""

tree_url = f"{self.repo.tree_url}/{self.variant.true_name}"

menu_template = PagesTemplate(working_dir=self.repo.working_dir,
name="menu.html").read()
return menu_template.format(variants=textwrap.indent(variants, " "),
branch=self.variant.name,
downloads=textwrap.indent(downloads, " "),
tree_url=self.repo.tree_url)
tree_url=tree_url)
2 changes: 1 addition & 1 deletion update_pages/ntd2d_action/files/templates/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2>Versions</h2>
<h2>GitHub</h2>
<div class="ntd2dwrapper">
<ul>
<li><a href="{tree_url}/{branch}">View</a></li>
<li><a href="{tree_url}">View</a></li>
</ul>
</div>

Expand Down
8 changes: 6 additions & 2 deletions update_pages/ntd2d_action/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
from .files import VariantsFile, MenuFile, IndexFile, CSSFile

class Variant:
def __init__(self, repo, name):
def __init__(self, repo, name, true_name=None):
self.repo = repo
self.name = name
if true_name is None:
self.true_name = name
else:
self.true_name = true_name
self.downloads = {}

self.dir = repo.working_dir / "html" / name
Expand Down Expand Up @@ -61,7 +65,7 @@ def clone(self, name, cls=None):
gha_utils.debug(f"{self.name}.clone({name})")
if cls is None:
cls = self.__class__
clone = cls(repo=self.repo, name=name)
clone = cls(repo=self.repo, name=name, true_name=self.true_name)
# this will clone any files in _static and _downloads, too
clone.copy_html(src=self.dir)
dst = clone.dir / "_downloads"
Expand Down

0 comments on commit 59fcb2f

Please sign in to comment.