Commit
Message
Changed Files (12)
-
modified CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md index db6b095..cc9de7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### 🚜 Refactor - Split builder running & output rendering into own modules +- *(templates,cli)* Extract <header> into base.html; dump-theme only writes enabled formats ## [0.7.1] - 2026-06-16 ### 🚀 Features -
modified src/cli.rs
diff --git a/src/cli.rs b/src/cli.rs index 180d9f1..2c86429 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -43,6 +43,8 @@ pub enum CliCommand { /// Checks out each tag in order, builds, then restores the original HEAD. BuildAll, /// Dumps the default theme to `.abbaye/theme` so you can inspect and modify it. It will be used afterwards when building the site. + /// + /// Only templates for the output formats enabled in `abbaye.toml` (`[site].formats`; defaults to `["html"]`) are written. DumpTheme, /// Print a JSON Schema for `abbaye.toml` to stdout. /// -
modified src/main.rs
diff --git a/src/main.rs b/src/main.rs index bbfd836..3a4357a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -412,80 +412,132 @@ async fn main() -> Result<()> { clap_usage::generate(&mut cmd, "abbaye", &mut std::io::stdout()); } cli::CliCommand::DumpTheme => { + let config = config::load_config()?; + let formats = &config.site.formats; + let html = formats.contains(&config::OutputFormat::Html); + let gemtext = formats.contains(&config::OutputFormat::Gemtext); + let theme_path = PathBuf::from(".abbaye").join("theme"); create_dir_all(&theme_path).await.into_diagnostic()?; - tokio::fs::write( - theme_path.join("root_index.html.j2"), - site::TEMPLATE_ROOT_INDEX_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("root_index.gmi.j2"), - site::TEMPLATE_ROOT_INDEX_GEMTEXT, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("version_index.html.j2"), - site::TEMPLATE_VERSION_INDEX_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("version_index.gmi.j2"), - site::TEMPLATE_VERSION_INDEX_GEMTEXT, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("markdown.html.j2"), - builders::markdown::TEMPLATE_MARKDOWN_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("markdown.gmi.j2"), - builders::markdown::TEMPLATE_MARKDOWN_GEMTEXT, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_log.html.j2"), - git_ui::TEMPLATE_GIT_LOG_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_log.gmi.j2"), - git_ui::TEMPLATE_GIT_LOG_GEMTEXT, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_commit.html.j2"), - git_ui::TEMPLATE_GIT_COMMIT_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_commit.gmi.j2"), - git_ui::TEMPLATE_GIT_COMMIT_GEMTEXT, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_refs.html.j2"), - git_ui::TEMPLATE_GIT_REFS_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_refs.gmi.j2"), - git_ui::TEMPLATE_GIT_REFS_GEMTEXT, - ) - .await - .into_diagnostic()?; + + // Site templates + if html { + tokio::fs::write(theme_path.join("base.html.j2"), site::TEMPLATE_BASE_HTML) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("root_index.html.j2"), + site::TEMPLATE_ROOT_INDEX_HTML, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("version_index.html.j2"), + site::TEMPLATE_VERSION_INDEX_HTML, + ) + .await + .into_diagnostic()?; + } + if gemtext { + tokio::fs::write( + theme_path.join("root_index.gmi.j2"), + site::TEMPLATE_ROOT_INDEX_GEMTEXT, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("version_index.gmi.j2"), + site::TEMPLATE_VERSION_INDEX_GEMTEXT, + ) + .await + .into_diagnostic()?; + } + + // Markdown builder templates + if html { + tokio::fs::write( + theme_path.join("markdown.html.j2"), + builders::markdown::TEMPLATE_MARKDOWN_HTML, + ) + .await + .into_diagnostic()?; + } + if gemtext { + tokio::fs::write( + theme_path.join("markdown.gmi.j2"), + builders::markdown::TEMPLATE_MARKDOWN_GEMTEXT, + ) + .await + .into_diagnostic()?; + } + + // Git UI templates + if html { + tokio::fs::write( + theme_path.join("git_log.html.j2"), + git_ui::TEMPLATE_GIT_LOG_HTML, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_commit.html.j2"), + git_ui::TEMPLATE_GIT_COMMIT_HTML, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_refs.html.j2"), + git_ui::TEMPLATE_GIT_REFS_HTML, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_tree.html.j2"), + git_ui::TEMPLATE_GIT_TREE_HTML, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_blob.html.j2"), + git_ui::TEMPLATE_GIT_BLOB_HTML, + ) + .await + .into_diagnostic()?; + } + if gemtext { + tokio::fs::write( + theme_path.join("git_log.gmi.j2"), + git_ui::TEMPLATE_GIT_LOG_GEMTEXT, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_commit.gmi.j2"), + git_ui::TEMPLATE_GIT_COMMIT_GEMTEXT, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_refs.gmi.j2"), + git_ui::TEMPLATE_GIT_REFS_GEMTEXT, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_tree.gmi.j2"), + git_ui::TEMPLATE_GIT_TREE_GEMTEXT, + ) + .await + .into_diagnostic()?; + tokio::fs::write( + theme_path.join("git_blob.gmi.j2"), + git_ui::TEMPLATE_GIT_BLOB_GEMTEXT, + ) + .await + .into_diagnostic()?; + } + + // Static assets (CSS) { let static_dir = theme_path.join("static"); create_dir_all(&static_dir).await.into_diagnostic()?; @@ -493,30 +545,6 @@ async fn main() -> Result<()> { .await .into_diagnostic()?; } - tokio::fs::write( - theme_path.join("git_tree.html.j2"), - git_ui::TEMPLATE_GIT_TREE_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_tree.gmi.j2"), - git_ui::TEMPLATE_GIT_TREE_GEMTEXT, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_blob.html.j2"), - git_ui::TEMPLATE_GIT_BLOB_HTML, - ) - .await - .into_diagnostic()?; - tokio::fs::write( - theme_path.join("git_blob.gmi.j2"), - git_ui::TEMPLATE_GIT_BLOB_GEMTEXT, - ) - .await - .into_diagnostic()?; } } Ok(()) -
modified src/site.rs
diff --git a/src/site.rs b/src/site.rs index 13e4d06..6068270 100644 --- a/src/site.rs +++ b/src/site.rs @@ -19,6 +19,7 @@ use crate::{ version_extractors::VersionInfo, }; +pub const TEMPLATE_BASE_HTML: &str = include_str!("templates/base.html.j2"); pub const TEMPLATE_ROOT_INDEX_HTML: &str = include_str!("templates/root_index.html.j2"); pub const TEMPLATE_VERSION_INDEX_HTML: &str = include_str!("templates/version_index.html.j2"); pub const TEMPLATE_ROOT_INDEX_GEMTEXT: &str = include_str!("templates/root_index.gmi.j2"); @@ -331,6 +332,7 @@ pub async fn build_site(config: AbbayeConfig) -> Result<()> { ctx.insert("git_ui_enabled", &config.git_ui.is_some()); ctx.insert("git_ui_clone_url", &git_ui_clone_url); ctx.insert("version_tag", &version_tag); + ctx.insert("root_path", "../"); let content = tera.render(&tmpl_name, &ctx).into_diagnostic()?; tokio::fs::write(version_dir.join(format!("index.{ext}")), content) @@ -372,6 +374,7 @@ pub async fn build_site(config: AbbayeConfig) -> Result<()> { ctx.insert("atom_feed", ATOM_FEED_FILENAME); ctx.insert("git_ui_enabled", &config.git_ui.is_some()); ctx.insert("git_ui_clone_url", &git_ui_clone_url); + ctx.insert("root_path", ""); let content = tera.render(&tmpl_name, &ctx).into_diagnostic()?; tokio::fs::write(output_dir.join(format!("index.{ext}")), content) @@ -680,6 +683,18 @@ pub(crate) fn register_format_templates( formats: &[OutputFormat], templates: &[(&str, &str, &str)], ) -> Result<()> { + // Register the shared HTML base template so child templates can + // {% extends "base.html" %}. A theme override at + // theme/base.html.j2 takes precedence when present. + let base_theme = theme_path.join("base.html.j2"); + if base_theme.is_file() { + tera.add_template_file(&base_theme, Some("base.html")) + .into_diagnostic()?; + } else { + tera.add_raw_template("base.html", TEMPLATE_BASE_HTML) + .into_diagnostic()?; + } + for format in formats { let ext = format.extension(); for (template_base, builtin_html, builtin_gmi) in templates { -
added src/templates/base.html.j2
diff --git a/src/templates/base.html.j2 b/src/templates/base.html.j2 new file mode 100644 index 0000000..36a8112 --- /dev/null +++ b/src/templates/base.html.j2 @@ -0,0 +1,15 @@ +<!doctype html> +<html prefix="og: https://ogp.me/ns#" lang="{{ lang | default(value='en') }}"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> +{% block head %}{% endblock %} + <link rel="stylesheet" href="{{ root_path | default(value='') }}static/site.css" /> + </head> + <body> + <header> +{% block header %}{% endblock %} + </header> +{% block body %}{% endblock %} + </body> +</html> -
modified src/templates/git_blob.html.j2
diff --git a/src/templates/git_blob.html.j2 b/src/templates/git_blob.html.j2 index ec77c10..517645c 100644 --- a/src/templates/git_blob.html.j2 +++ b/src/templates/git_blob.html.j2 @@ -1,38 +1,33 @@ -<!doctype html> -<html lang="{{ lang | default(value='en') }}"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>{{ project_name }} — {{ filename }}</title> - <link rel="stylesheet" href="{{ root_path }}static/site.css" /> -</head> -<body> - <header> - <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> - <nav> - <a href="{{ root_path }}repository/index.html">Log</a> - <a href="{{ root_path }}repository/refs.html">Refs</a> - </nav> - </header> - <main> - <nav class="breadcrumb"> - {% for crumb in breadcrumbs %} - {% if not loop.last %}<span class="breadcrumb-sep">/</span>{% endif %} - {% if crumb.url %}<a href="{{ crumb.url }}">{{ crumb.name | escape }}</a>{% else %}<span>{{ crumb.name | escape }}</span>{% endif %} - {% endfor %} - </nav> +{% extends "base.html" %} +{% block head %} + <title>{{ project_name }} — {{ filename }}</title> +{% endblock %} +{% block header %} + <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> + <nav> + <a href="{{ root_path }}repository/index.html">Log</a> + <a href="{{ root_path }}repository/refs.html">Refs</a> + </nav> +{% endblock %} +{% block body %} + <main> + <nav class="breadcrumb"> + {% for crumb in breadcrumbs %} + {% if not loop.last %}<span class="breadcrumb-sep">/</span>{% endif %} + {% if crumb.url %}<a href="{{ crumb.url }}">{{ crumb.name | escape }}</a>{% else %}<span>{{ crumb.name | escape }}</span>{% endif %} + {% endfor %} + </nav> - <p class="tree-rev">at <a class="hash" href="{{ commit_url }}">{{ commit_hash_short }}</a></p> + <p class="tree-rev">at <a class="hash" href="{{ commit_url }}">{{ commit_hash_short }}</a></p> - {% if is_binary %} - <p class="blob-notice">Binary file ({{ size }} bytes)</p> - {% elif too_large %} - <p class="blob-notice">File too large to display ({{ size }} bytes)</p> - {% elif content_html %} - <div class="blob-content">{{ content_html | safe }}</div> - {% else %} - <p class="blob-notice">Empty file</p> - {% endif %} - </main> -</body> -</html> + {% if is_binary %} + <p class="blob-notice">Binary file ({{ size }} bytes)</p> + {% elif too_large %} + <p class="blob-notice">File too large to display ({{ size }} bytes)</p> + {% elif content_html %} + <div class="blob-content">{{ content_html | safe }}</div> + {% else %} + <p class="blob-notice">Empty file</p> + {% endif %} + </main> +{% endblock %} -
modified src/templates/git_commit.html.j2
diff --git a/src/templates/git_commit.html.j2 b/src/templates/git_commit.html.j2 index 246ab98..2a56c67 100644 --- a/src/templates/git_commit.html.j2 +++ b/src/templates/git_commit.html.j2 @@ -1,65 +1,60 @@ -<!doctype html> -<html lang="{{ lang | default(value='en') }}"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>{{ project_name }} — {{ commit.hash_short }}</title> - <link rel="stylesheet" href="{{ root_path }}static/site.css" /> -</head> -<body> - <header> - <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> - <a href="../index.html">← Log</a> - <nav> - <a href="../index.html">Log</a> - <a href="../refs.html">Refs</a> - </nav> - </header> - <main> - <h2 class="section-heading">Commit{% if has_browse %} <a class="hash" href="../browse/{{ commit.hash }}/">browse files</a>{% endif %}</h2> - <div class="commit-meta"> - <dl> - <dt>Hash</dt> - <dd><span class="hash-full">{{ commit.hash }}</span></dd> - <dt>Author</dt> - <dd>{{ commit.author_name }} <{{ commit.author_email }}></dd> - <dt>Date</dt> - <dd><time datetime="{{ commit.date_iso }}">{{ commit.datetime_display }}</time></dd> - {% if commit.parents %} - <dt>Parent{% if commit.parents | length > 1 %}s{% endif %}</dt> - <dd> - {% for p in commit.parents %} - <a class="hash" href="{{ p.hash }}.html">{{ p.hash_short }}</a>{% if not loop.last %} {% endif %} - {% endfor %} - </dd> - {% endif %} - </dl> - </div> - <h2 class="section-heading">Message</h2> - <div class="commit-message">{{ commit.subject }}{% if commit.body %} - -{{ commit.body }}{% endif %}</div> - {% if changed_files %} - <h2 class="section-heading">Changed Files ({{ changed_files | length }})</h2> - <ul class="files-list"> - {% for f in changed_files %} - <li> - <details> - <summary> - <span class="badge badge-{{ f.status }}">{{ f.status }}</span> - <span class="file-path">{{ f.path }}</span> - </summary> - {% if f.diff_lines %} - <table class="diff-table"><tbody> - {% for line in f.diff_lines %}<tr class="diff-{{ line.kind }}"><td class="diff-cell">{{ line.content }}</td></tr> +{% extends "base.html" %} +{% block head %} + <title>{{ project_name }} — {{ commit.hash_short }}</title> +{% endblock %} +{% block header %} + <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> + <a href="../index.html">← Log</a> + <nav> + <a href="../index.html">Log</a> + <a href="../refs.html">Refs</a> + </nav> +{% endblock %} +{% block body %} + <main> + <h2 class="section-heading">Commit{% if has_browse %} <a class="hash" href="../browse/{{ commit.hash }}/">browse files</a>{% endif %}</h2> + <div class="commit-meta"> + <dl> + <dt>Hash</dt> + <dd><span class="hash-full">{{ commit.hash }}</span></dd> + <dt>Author</dt> + <dd>{{ commit.author_name }} <{{ commit.author_email }}></dd> + <dt>Date</dt> + <dd><time datetime="{{ commit.date_iso }}">{{ commit.datetime_display }}</time></dd> + {% if commit.parents %} + <dt>Parent{% if commit.parents | length > 1 %}s{% endif %}</dt> + <dd> + {% for p in commit.parents %} + <a class="hash" href="{{ p.hash }}.html">{{ p.hash_short }}</a>{% if not loop.last %} {% endif %} {% endfor %} - </tbody></table> + </dd> {% endif %} - </details> - </li> - {% endfor %} - </ul> - {% endif %} - </main> -</body> -</html> + </dl> + </div> + <h2 class="section-heading">Message</h2> + <div class="commit-message">{{ commit.subject }}{% if commit.body %} + +{{ commit.body }}{% endif %}</div> + {% if changed_files %} + <h2 class="section-heading">Changed Files ({{ changed_files | length }})</h2> + <ul class="files-list"> + {% for f in changed_files %} + <li> + <details> + <summary> + <span class="badge badge-{{ f.status }}">{{ f.status }}</span> + <span class="file-path">{{ f.path }}</span> + </summary> + {% if f.diff_lines %} + <table class="diff-table"><tbody> + {% for line in f.diff_lines %}<tr class="diff-{{ line.kind }}"><td class="diff-cell">{{ line.content }}</td></tr> + {% endfor %} + </tbody></table> + {% endif %} + </details> + </li> + {% endfor %} + </ul> + {% endif %} + </main> +{% endblock %} -
modified src/templates/git_log.html.j2
diff --git a/src/templates/git_log.html.j2 b/src/templates/git_log.html.j2 index 088ec5f..993a86a 100644 --- a/src/templates/git_log.html.j2 +++ b/src/templates/git_log.html.j2 @@ -1,63 +1,58 @@ -<!doctype html> -<html lang="{{ lang | default(value='en') }}"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>{{ project_name }} — {{ current_branch }}</title> - <link rel="stylesheet" href="{{ root_path }}static/site.css" /> -</head> -<body> - <header> - <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> - <nav> - <a href="index.html" class="active">Log</a> - <a href="refs.html">Refs</a> - </nav> - </header> - <main> - {% if clone_url %} - <div class="clone-box"> - <span class="clone-label">Clone</span> - <span class="clone-url">git clone {{ clone_url }}</span> - </div> - {% endif %} +{% extends "base.html" %} +{% block head %} + <title>{{ project_name }} — {{ current_branch }}</title> +{% endblock %} +{% block header %} + <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> + <nav> + <a href="index.html" class="active">Log</a> + <a href="refs.html">Refs</a> + </nav> +{% endblock %} +{% block body %} + <main> + {% if clone_url %} + <div class="clone-box"> + <span class="clone-label">Clone</span> + <span class="clone-url">git clone {{ clone_url }}</span> + </div> + {% endif %} - {% if branch_nav | length > 1 %} - <div class="branch-switcher"> - {% for b in branch_nav %} - <a href="{{ b.filename }}"{% if b.is_current %} class="active"{% endif %}>{{ b.short_name }}</a> - {% endfor %} - </div> - {% endif %} - - <h2 class="section-heading">{{ current_branch }}</h2> - <table> - <thead> - <tr> - <th>Hash</th> - <th>Subject</th> - <th>Author</th> - <th>Date</th> - </tr> - </thead> - <tbody> - {% for commit in commits %} - <tr> - <td class="commit-hash-cell"> - <a class="hash" href="commit/{{ commit.hash }}.html">{{ commit.hash_short }}</a>{% for badge in commit.ref_badges %}<span class="ref-badge ref-badge-{{ badge.kind }}">{{ badge.label }}</span>{% endfor %} - </td> - <td>{{ commit.subject }}</td> - <td>{{ commit.author_name }}</td> - <td><time datetime="{{ commit.date_iso }}">{{ commit.date }}</time></td> - </tr> + {% if branch_nav | length > 1 %} + <div class="branch-switcher"> + {% for b in branch_nav %} + <a href="{{ b.filename }}"{% if b.is_current %} class="active"{% endif %}>{{ b.short_name }}</a> {% endfor %} - </tbody> - </table> - {% if truncated %} - <p style="margin-top:1rem; font-size:0.85rem; color:var(--text-muted);"> - Showing the {{ commits | length }} most recent commits. - </p> - {% endif %} - </main> -</body> -</html> + </div> + {% endif %} + + <h2 class="section-heading">{{ current_branch }}</h2> + <table> + <thead> + <tr> + <th>Hash</th> + <th>Subject</th> + <th>Author</th> + <th>Date</th> + </tr> + </thead> + <tbody> + {% for commit in commits %} + <tr> + <td class="commit-hash-cell"> + <a class="hash" href="commit/{{ commit.hash }}.html">{{ commit.hash_short }}</a>{% for badge in commit.ref_badges %}<span class="ref-badge ref-badge-{{ badge.kind }}">{{ badge.label }}</span>{% endfor %} + </td> + <td>{{ commit.subject }}</td> + <td>{{ commit.author_name }}</td> + <td><time datetime="{{ commit.date_iso }}">{{ commit.date }}</time></td> + </tr> + {% endfor %} + </tbody> + </table> + {% if truncated %} + <p style="margin-top:1rem; font-size:0.85rem; color:var(--text-muted);"> + Showing the {{ commits | length }} most recent commits. + </p> + {% endif %} + </main> +{% endblock %} -
modified src/templates/git_refs.html.j2
diff --git a/src/templates/git_refs.html.j2 b/src/templates/git_refs.html.j2 index e4ff242..73b3e42 100644 --- a/src/templates/git_refs.html.j2 +++ b/src/templates/git_refs.html.j2 @@ -1,53 +1,48 @@ -<!doctype html> -<html lang="{{ lang | default(value='en') }}"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>{{ project_name }} — Refs</title> - <link rel="stylesheet" href="{{ root_path }}static/site.css" /> -</head> -<body> - <header> - <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> - <nav> - <a href="index.html">Log</a> - <a href="refs.html" class="active">Refs</a> - </nav> - </header> - <main> - {% if tags %} - <h2 class="section-heading">Tags</h2> - <table> - <thead><tr><th>Tag</th><th>Hash</th></tr></thead> - <tbody> - {% for ref in tags %} - <tr id="tag-{{ ref.short_name }}"> - <td><span class="ref-kind-tag">{{ ref.short_name | escape }}</span></td> - <td><a class="hash" href="commit/{{ ref.hash }}.html">{{ ref.hash_short }}</a></td> - </tr> - {% endfor %} - </tbody> - </table> - {% endif %} +{% extends "base.html" %} +{% block head %} + <title>{{ project_name }} — Refs</title> +{% endblock %} +{% block header %} + <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> + <nav> + <a href="index.html">Log</a> + <a href="refs.html" class="active">Refs</a> + </nav> +{% endblock %} +{% block body %} + <main> + {% if tags %} + <h2 class="section-heading">Tags</h2> + <table> + <thead><tr><th>Tag</th><th>Hash</th></tr></thead> + <tbody> + {% for ref in tags %} + <tr id="tag-{{ ref.short_name }}"> + <td><span class="ref-kind-tag">{{ ref.short_name | escape }}</span></td> + <td><a class="hash" href="commit/{{ ref.hash }}.html">{{ ref.hash_short }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} - {% if branches %} - <h2 class="section-heading">Branches</h2> - <table> - <thead><tr><th>Branch</th><th>Hash</th></tr></thead> - <tbody> - {% for ref in branches %} - <tr> - <td><span class="ref-kind-branch">{{ ref.short_name }}</span></td> - <td><a class="hash" href="commit/{{ ref.hash }}.html">{{ ref.hash_short }}</a></td> - </tr> - {% endfor %} - </tbody> - </table> - {% endif %} + {% if branches %} + <h2 class="section-heading">Branches</h2> + <table> + <thead><tr><th>Branch</th><th>Hash</th></tr></thead> + <tbody> + {% for ref in branches %} + <tr> + <td><span class="ref-kind-branch">{{ ref.short_name }}</span></td> + <td><a class="hash" href="commit/{{ ref.hash }}.html">{{ ref.hash_short }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} - {% if not tags and not branches %} - <p style="color: var(--text-muted);">No refs found.</p> - {% endif %} - </main> -</body> -</html> + {% if not tags and not branches %} + <p style="color: var(--text-muted);">No refs found.</p> + {% endif %} + </main> +{% endblock %} -
modified src/templates/git_tree.html.j2
diff --git a/src/templates/git_tree.html.j2 b/src/templates/git_tree.html.j2 index 27fe6fc..61d2e7e 100644 --- a/src/templates/git_tree.html.j2 +++ b/src/templates/git_tree.html.j2 @@ -1,45 +1,40 @@ -<!doctype html> -<html lang="{{ lang | default(value='en') }}"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>{{ project_name }} — {{ dir_path | default(value="~") }}</title> - <link rel="stylesheet" href="{{ root_path }}static/site.css" /> -</head> -<body> - <header> - <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> - <nav> - <a href="{{ root_path }}repository/index.html">Log</a> - <a href="{{ root_path }}repository/refs.html">Refs</a> - </nav> - </header> - <main> - <nav class="breadcrumb"> - {% for crumb in breadcrumbs %} - {% if not loop.last %}<span class="breadcrumb-sep">/</span>{% endif %} - {% if crumb.url %}<a href="{{ crumb.url }}">{{ crumb.name | escape }}</a>{% else %}<span>{{ crumb.name | escape }}</span>{% endif %} - {% endfor %} - </nav> - - <table class="tree-table"> - <tbody> - {% for entry in entries %} - <tr> - <td class="tree-mode tree-mode-{{ entry.kind }}"></td> - <td> - {% if entry.kind == "tree" %} - <a class="tree-entry-tree" href="{{ entry.url }}">{{ entry.name | escape }}/</a> - {% else %} - <a class="tree-entry-blob" href="{{ entry.url }}">{{ entry.name | escape }}</a> - {% endif %} - </td> - </tr> +{% extends "base.html" %} +{% block head %} + <title>{{ project_name }} — {{ dir_path | default(value="~") }}</title> +{% endblock %} +{% block header %} + <a href="{{ root_path }}" class="site-title">{{ project_name }}</a> + <nav> + <a href="{{ root_path }}repository/index.html">Log</a> + <a href="{{ root_path }}repository/refs.html">Refs</a> + </nav> +{% endblock %} +{% block body %} + <main> + <nav class="breadcrumb"> + {% for crumb in breadcrumbs %} + {% if not loop.last %}<span class="breadcrumb-sep">/</span>{% endif %} + {% if crumb.url %}<a href="{{ crumb.url }}">{{ crumb.name | escape }}</a>{% else %}<span>{{ crumb.name | escape }}</span>{% endif %} {% endfor %} - </tbody> - </table> + </nav> + + <table class="tree-table"> + <tbody> + {% for entry in entries %} + <tr> + <td class="tree-mode tree-mode-{{ entry.kind }}"></td> + <td> + {% if entry.kind == "tree" %} + <a class="tree-entry-tree" href="{{ entry.url }}">{{ entry.name | escape }}/</a> + {% else %} + <a class="tree-entry-blob" href="{{ entry.url }}">{{ entry.name | escape }}</a> + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> + </table> - <p class="tree-rev">at <a class="hash" href="{{ commit_url }}">{{ commit_hash_short }}</a></p> - </main> -</body> -</html> + <p class="tree-rev">at <a class="hash" href="{{ commit_url }}">{{ commit_hash_short }}</a></p> + </main> +{% endblock %} -
modified src/templates/root_index.html.j2
diff --git a/src/templates/root_index.html.j2 b/src/templates/root_index.html.j2 index 647c66b..c09d49d 100644 --- a/src/templates/root_index.html.j2 +++ b/src/templates/root_index.html.j2 @@ -1,8 +1,5 @@ -<!doctype html> -<html prefix="og: https://ogp.me/ns#" lang="{{lang|default(value='en')}}"> - <head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> +{% extends "base.html" %} +{% block head %} {% if config.site.fediverse_creator %}<meta name="fediverse:creator" content="{{ config.site.fediverse_creator }}" />{% endif %} {% if config.site.opengraph %} <meta property="og:title" content="{{ project_name }}" /> @@ -24,16 +21,15 @@ title="{{ project_name }} Releases" href="{{ atom_feed }}" /> - <link rel="stylesheet" href="static/site.css" /> - </head> - <body> - <header> +{% endblock %} +{% block header %} <h1>{{ project_name }}</h1> <a class="feed-link" href="{{ atom_feed }}"> <span class="feed-icon" aria-hidden="true"></span> Atom feed </a> - </header> +{% endblock %} +{% block body %} <main class="versions-main"> <h2 class="section-heading">Versions</h2> <ul class="versions-list"> @@ -62,5 +58,4 @@ <p class="repo-browse-link"><a href="repository/">Browse source →</a></p> {% endif %} </main> - </body> -</html> +{% endblock %} -
modified src/templates/version_index.html.j2
diff --git a/src/templates/version_index.html.j2 b/src/templates/version_index.html.j2 index 04ca8f0..0571041 100644 --- a/src/templates/version_index.html.j2 +++ b/src/templates/version_index.html.j2 @@ -1,8 +1,5 @@ -<!doctype html> -<html prefix="og: https://ogp.me/ns#" lang="{{lang|default(value='en')}}"> - <head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> +{% extends "base.html" %} +{% block head %} {% if config.site.fediverse_creator %}<meta name="fediverse:creator" content="{{ config.site.fediverse_creator }}" />{% endif %} {% if config.site.opengraph %} <meta property="og:title" content="{{ project_name }} — {{ version }}" /> @@ -18,13 +15,12 @@ {% endif %} {% endif %} <title>{{ project_name }} — {{ version }}</title> - <link rel="stylesheet" href="../static/site.css" /> - </head> - <body> - <header> - <a href="../">← All versions</a> +{% endblock %} +{% block header %} + <a href="{{ root_path | default(value='') }}">← All versions</a> <span class="title">{{ project_name }} — {{ version }}</span> - </header> +{% endblock %} +{% block body %} <div class="release-layout"> <aside> {% if repo_url %} @@ -34,7 +30,7 @@ {% if git_ui_enabled %} <h3>Source</h3> <ul> - <li><a href="../repository/refs.html#tag-{{ version_tag }}">Browse {{ version_tag }}</a></li> + <li><a href="{{ root_path | default(value='') }}repository/refs.html#tag-{{ version_tag }}">Browse {{ version_tag }}</a></li> </ul> {% endif %} {% if has_docs %} <h3>Documentation</h3> @@ -73,5 +69,4 @@ {{ changelog_html | safe }} {% endif %} </main> </div> - </body> -</html> +{% endblock %}