Promote file listing and move tests, commits and results to aside
Committed 5ba34a
--- a/webint_code/templates/project/index.html
+++ b/webint_code/templates/project/index.html
</small>
</p>
-$if "errors" in test_results:
- <p>
- $if test_results["errors"]:
- $ test_color = "red"
- $ test_indicator = "■"
- $ plural = ""
- $if test_results["errors"] > 1:
- $ plural = "s"
- $ test_msg = f"{test_results['errors']} test{plural} of {test_results['tests']} failing"
- $else:
- $ test_color = "green"
- $ test_indicator = "●"
- $ plural = ""
- $if test_results["tests"] > 1:
- $ plural = "s"
- $ test_msg = f"{test_results['tests']} test{plural} passing"
- <span style=color:$test_color>$:test_indicator</span>
- $test_msg in $test_results["time"]<small>s</small></p>
+$if repo.exists():
+ $ git_clone = f"git clone {tx.origin}/code/projects/{project}.git"
+ <script>
+ copyText = () => {
+ navigator.clipboard.writeText('$git_clone')
+ }
+ </script>
+ <pre><small><button onclick=copyText()>📋</button> \
+ $git_clone</small></pre>
+
+ $ ignorable_files = (
+ $ ".github",
+ $ ".gitignore",
+ $ "README",
+ $ "README.md",
+ $ "pyproject.toml",
+ $ "pyrightconfig.json",
+ $ "package.json",
+ $ "tsconfig.json",
+ $ "webpack.config.js",
+ $ )
+ <h2>Files</h2>
+ $ files = sorted(repo.files)
+ $ prev_file = None
+ $ known_files = [f for f in files if str(f).partition("/")[0] in ignorable_files]
+ <p style=font-size:.8em>\
+ $for file in known_files:
+ $ file, is_dir, _ = str(file).partition("/")
+ $if file == prev_file:
+ $continue
+ <a style=color:#888 href=/projects/$project/files/$file>$file</a>\
+ $if is_dir:
+ /\
+ $ prev_file = file
+ $if not loop.last:
+ ,
+ </p>
+ $ prev_file = None
+ <ul class=files>
+ $ unique_files = [f for f in files if str(f).partition("/")[0] not in ignorable_files]
+ $for file in unique_files:
+ $ file, is_dir, _ = str(file).partition("/")
+ $if file == prev_file:
+ $continue
+ <li><a href=/projects/$project/files/$file>$file</a>\
+ $if is_dir:
+ /
+ </li>
+ $ prev_file = file
+ </ul>
$if readme:
- <hr>
<div>$:mkdn(readme)</div>
<hr>
<p><small><strong>Licensed:</strong> <a href=https://spdx.org/licenses/$(license).html><code>$licenses[license]</code></a></small></p>
<hr>
-$if package_releases:
- <h2>Releases</h2>
- <ul class=h-feed>
- $for release in list(reversed(sorted(package_releases, key=semver.parse_version_info)))[:1]:
- <li class=h-entry><a href=/projects/$project/releases/$release>$release</a></li>
- </ul>
-
-$if repo.exists():
- $ git_clone = f"git clone {tx.origin}/code/projects/{project}.git"
- <script>
- copyText = () => {
- navigator.clipboard.writeText('$git_clone')
- }
- </script>
- <pre><small><button onclick=copyText()>📋</button> \
- $git_clone</small></pre>
+$var title = title
- <h2>Commit Log</h2>
- <ul class="commits h-feed">
- $for commit in list(repo.log.values())[:1]:
- $ author_url = commit['author_email']
- $if "@" in author_url:
- $ author_url = f"mailto:{author_url}"
+$def aside():
+ $if "errors" in test_results:
+ <p>
+ $if test_results["errors"]:
+ $ test_color = "red"
+ $ test_indicator = "■"
+ $ plural = ""
+ $if test_results["errors"] > 1:
+ $ plural = "s"
+ $ test_msg = f"{test_results['errors']} test{plural} of {test_results['tests']} failing"
$else:
- $ author_url = f"https://{author_url}"
- <li class=h-entry>
- $# <small><small><a class=u-url href=/projects/$project/commits/$commit["hash"]>\
- $# <code>$commit["hash"][:7].upper()</code></a></small></small>
- <span class=p-name>$:str(mkdn(commit["message"]))[3:-4]</span>
- <small><small>
- $# <a class=u-author href="$author_url">$commit["author_name"]</a>
- <a class=u-url href=/projects/$project/commits/$commit["hash"]><time
- class=dt-published datetime=$commit["timestamp"].isoformat()>\
- $commit["timestamp"].diff_for_humans()</time></a>
- </small></small>
- </li>
- </ul>
+ $ test_color = "green"
+ $ test_indicator = "●"
+ $ plural = ""
+ $if test_results["tests"] > 1:
+ $ plural = "s"
+ $ test_msg = f"{test_results['tests']} test{plural} passing"
+ <span style=color:$test_color>$:test_indicator</span>
+ $test_msg in $test_results["time"]<small>s</small></p>
- $ ignorable_files = (
- $ ".github",
- $ ".gitignore",
- $ "README",
- $ "README.md",
- $ "pyproject.toml",
- $ "pyrightconfig.json",
- $ "package.json",
- $ "tsconfig.json",
- $ "webpack.config.js",
- $ )
- <h2>Files</h2>
- $ files = sorted(repo.files)
- $ prev_file = None
- $ known_files = [f for f in files if str(f).partition("/")[0] in ignorable_files]
- <p style=font-size:.8em>\
- $for file in known_files:
- $ file, is_dir, _ = str(file).partition("/")
- $if file == prev_file:
- $continue
- <a style=color:#888 href=/projects/$project/files/$file>$file</a>\
- $if is_dir:
- /\
- $ prev_file = file
- $if not loop.last:
- ,
- </p>
- $ prev_file = None
- <ul class=files>
- $ unique_files = [f for f in files if str(f).partition("/")[0] not in ignorable_files]
- $for file in unique_files:
- $ file, is_dir, _ = str(file).partition("/")
- $if file == prev_file:
- $continue
- <li><a href=/projects/$project/files/$file>$file</a>\
- $if is_dir:
- /
- </li>
- $ prev_file = file
- </ul>
+ $if repo.exists():
+ <h2>Commits</h2>
+ <ul class="commits h-feed">
+ $for commit in list(repo.log.values())[:1]:
+ $ author_url = commit['author_email']
+ $if "@" in author_url:
+ $ author_url = f"mailto:{author_url}"
+ $else:
+ $ author_url = f"https://{author_url}"
+ <li class=h-entry>
+ $# <small><small><a class=u-url href=/projects/$project/commits/$commit["hash"]>\
+ $# <code>$commit["hash"][:7].upper()</code></a></small></small>
+ <span class=p-name>$:str(mkdn(commit["message"]))[3:-4]</span>
+ <small><small>
+ $# <a class=u-author href="$author_url">$commit["author_name"]</a>
+ <a class=u-url href=/projects/$project/commits/$commit["hash"]><time
+ class=dt-published datetime=$commit["timestamp"].isoformat()>\
+ $commit["timestamp"].diff_for_humans()</time></a>
+ </small></small>
+ </li>
+ </ul>
-$var title = title
+ $if package_releases:
+ <h2>Releases</h2>
+ <ul class=h-feed>
+ $for release in list(reversed(sorted(package_releases, key=semver.parse_version_info)))[:1]:
+ <li class=h-entry><a href=/projects/$project/releases/$release>$release</a></li>
+ </ul>
+
+$var aside = aside