Skip to content

Move about page tabs system in header dropdown #2857

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/web/build_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
extractors::{DbConnection, Path},
file::File,
filters,
page::templates::{RenderRegular, RenderSolid},
page::templates::{RenderBrands, RenderRegular, RenderSolid},
},
};
use anyhow::Context as _;
Expand Down
2 changes: 1 addition & 1 deletion src/web/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
error::{AxumResult, EscapedURI},
extractors::{DbConnection, Path},
filters, match_version,
page::templates::{RenderRegular, RenderSolid},
page::templates::{RenderBrands, RenderRegular, RenderSolid},
},
};
use anyhow::{Result, anyhow};
Expand Down
2 changes: 1 addition & 1 deletion src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
cache::CachePolicy,
error::{AxumNope, AxumResult, EscapedURI},
extractors::{DbConnection, Path},
page::templates::{RenderRegular, RenderSolid, filters},
page::templates::{RenderBrands, RenderRegular, RenderSolid, filters},
rustdoc::RustdocHtmlParams,
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/web/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
filters,
headers::CanonicalUrl,
match_version,
page::templates::{RenderRegular, RenderSolid},
page::templates::{RenderBrands, RenderRegular, RenderSolid},
},
};
use anyhow::anyhow;
Expand Down
2 changes: 1 addition & 1 deletion src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::db::ReleaseId;
use crate::db::types::BuildStatus;
use crate::utils::get_correct_docsrs_style_file;
use crate::utils::report_error;
use crate::web::page::templates::{RenderSolid, filters};
use crate::web::page::templates::{RenderBrands, RenderSolid, filters};
use anyhow::{Context as _, Result, anyhow, bail};
use askama::Template;
use axum_extra::middleware::option_layer;
Expand Down
2 changes: 1 addition & 1 deletion src/web/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
error::{AxumNope, AxumResult},
extractors::{DbConnection, Path},
match_version,
page::templates::{RenderRegular, RenderSolid, filters},
page::templates::{RenderBrands, RenderRegular, RenderSolid, filters},
},
};
use anyhow::{Context as _, Result, anyhow};
Expand Down
2 changes: 1 addition & 1 deletion src/web/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
match_version,
page::{
TemplateData,
templates::{RenderRegular, RenderSolid, filters},
templates::{RenderBrands, RenderRegular, RenderSolid, filters},
},
},
};
Expand Down
34 changes: 7 additions & 27 deletions src/web/sitemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ macro_rules! about_page {
($ty:ident, $template:literal) => {
#[derive(Template)]
#[template(path = $template)]
struct $ty {
active_tab: &'static str,
}
struct $ty;

impl_axum_webpage! { $ty }
};
Expand All @@ -151,30 +149,12 @@ pub(crate) async fn about_handler(subpage: Option<Path<String>>) -> AxumResult<i
};

let response = match &subpage[..] {
"about" | "index" => AboutPage {
active_tab: "index",
}
.into_response(),
"badges" => AboutPageBadges {
active_tab: "badges",
}
.into_response(),
"metadata" => AboutPageMetadata {
active_tab: "metadata",
}
.into_response(),
"redirections" => AboutPageRedirection {
active_tab: "redirections",
}
.into_response(),
"download" => AboutPageDownload {
active_tab: "download",
}
.into_response(),
"rustdoc-json" => AboutPageRustdocJson {
active_tab: "rustdoc-json",
}
.into_response(),
"about" | "index" => AboutPage.into_response(),
"badges" => AboutPageBadges.into_response(),
"metadata" => AboutPageMetadata.into_response(),
"redirections" => AboutPageRedirection.into_response(),
"download" => AboutPageDownload.into_response(),
"rustdoc-json" => AboutPageRustdocJson.into_response(),
_ => {
let msg = "This /about page does not exist. \
Perhaps you are interested in <a href=\"https://github.com/rust-lang/docs.rs/tree/master/templates/core/about\">creating</a> it?";
Expand Down
41 changes: 0 additions & 41 deletions templates/about-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,6 @@
centered
{%- endblock body_classes -%}

{% block header %}
<div class="docsrs-package-container">
<div class="container">
<div class="description-container">
<h1 id="crate-title" class="no-description">Docs.rs documentation</h1>
<div class="pure-menu pure-menu-horizontal">
<ul class="pure-menu-list">
{% set text = crate::icons::IconCircleInfo.render_solid(false, false, "") %}
{% set text = "{} <span class='title'>About</span>"|format(text) %}
{% call macros::active_link(expected="index", href="/about", text=text) %}

{% set text = crate::icons::IconFonticons.render_brands(false, false, "") %}
{% set text = "{} <span class='title'>Badges</span>"|format(text) %}
{% call macros::active_link(expected="badges", href="/about/badges", text=text) %}

{% set text = crate::icons::IconGears.render_solid(false, false, "") %}
{% set text = "{} <span class='title'>Builds</span>"|format(text) %}
{% call macros::active_link(expected="builds", href="/about/builds", text=text) %}

{% set text = crate::icons::IconTable.render_solid(false, false, "") %}
{% set text = "{} <span class='title'>Metadata</span>"|format(text) %}
{% call macros::active_link(expected="metadata", href="/about/metadata", text=text) %}

{% set text = crate::icons::IconRoad.render_solid(false, false, "") %}
{% set text = "{} <span class='title'>Shorthand URLs</span>"|format(text) %}
{% call macros::active_link(expected="redirections", href="/about/redirections", text=text) %}

{% set text = crate::icons::IconDownload.render_solid(false, false, "") %}
{% set text = "{} <span class='title'>Download</span>"|format(text) %}
{% call macros::active_link(expected="download", href="/about/download", text=text) %}

{% set text = crate::icons::IconFileCode.render_solid(false, false, "") %}
{% set text = "{} <span class='title'>Rustdoc JSON</span>"|format(text) %}
{% call macros::active_link(expected="rustdoc-json", href="/about/rustdoc-json", text=text) %}
</ul>
</div>
</div>
</div>
</div>
{% endblock %}

{%- block topbar -%}
{% let search_query = Some(String::new()) %}
{%- include "header/topbar.html" -%}
Expand Down
55 changes: 43 additions & 12 deletions templates/header/topbar_end.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,53 @@
The docs.rs dropdown menu
#}<li class="pure-menu-item pure-menu-has-children">
<a href="#" class="pure-menu-link" aria-label="docs.rs">docs.rs</a>
<ul class="pure-menu-children">
{% call macros::menu_link(
<ul class="pure-menu-children aligned-icons">
{%- call macros::menu_link_with_icon_solid(
href="/about",
text="About docs.rs",
target="",
) %}
{% call macros::menu_link(
href="https://foundation.rust-lang.org/policies/privacy-policy/#docs.rs",
text="Privacy policy",
target="_blank"
) %}
{% call macros::menu_link(
icon=crate::icons::IconCircleInfo,
) -%}
{%- call macros::menu_link_with_icon_brand(
href="/about/badges",
text="Badges",
icon=crate::icons::IconFonticons,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="/about/builds",
text="Builds",
icon=crate::icons::IconGears,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="/about/metadata",
text="Metadata",
icon=crate::icons::IconTable,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="/about/redirections",
text="Shorthand URLs",
icon=crate::icons::IconRoad,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="/about/download",
text="Download",
icon=crate::icons::IconDownload,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="/about/rustdoc-json",
text="Rustdoc JSON",
icon=crate::icons::IconFileCode,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="/releases/queue",
text="Build queue",
target="",
) %}
icon=crate::icons::IconGears,
) -%}
{%- call macros::menu_link_with_icon_solid(
href="https://foundation.rust-lang.org/policies/privacy-policy/#docs.rs",
text="Privacy policy",
icon=crate::icons::IconShieldHalved,
target="_blank",
) -%}
</ul>
</li>
</ul>
Expand Down
41 changes: 20 additions & 21 deletions templates/macros.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
{#
Creates a list entry for active tabs. When the active tab is the same as `expected`, it will show the current tab as active.
* `expected` A string that represents the current tab, when `active_tab == expected` the current will be shown as active
* `href` A string used as the tab's link
* `text` A string used as the tab's text
#}
{% macro active_link(expected, href, text) %}
<li class="pure-menu-item">
<a class="pure-menu-link {% if active_tab == *expected %} pure-menu-active {% endif %}" href="{{ href }}">
{# safe: allow passing in HTML #}
{{ text|safe }}
</a>
</li>
{% endmacro active_link %}

{#
Creates a list entry
* `href` A string used as the tab's link
* `text` A string used as the tab's text
* `target` An optional target
* `extra_classes` Optional extra css classes
#}
{% macro menu_link(href, text, target) %}
<li class="pure-menu-item">
<a class="pure-menu-link" href="{{ href }}" {% if !target.is_empty() -%} target="{{ target }}" {%- endif %}>
{{ text }}
</a>
{% macro menu_link(href, text, target, icon="") -%}
<li class="pure-menu-item"> {#- -#}
<a class="pure-menu-link" href="{{ href }}"{% if !target.is_empty() %} target="{{ target }}" {%- endif %}>{{ text }}</a> {#- -#}
</li>
{%- endmacro menu_link %}

{% macro menu_link_with_icon_solid(href, text, icon, target="") -%}
<li class="pure-menu-item"> {#- -#}
<a class="pure-menu-link" href="{{ href }}"{% if !target.is_empty() %} target="{{ target }}" {%- endif %}>
{{- icon.render_solid(false, false, "") }} {{ text -}}
</a> {#- -#}
</li>
{%- endmacro menu_link_with_icon_solid %}

{% macro menu_link_with_icon_brand(href, text, icon) -%}
<li class="pure-menu-item"> {#- -#}
<a class="pure-menu-link" href="{{ href }}">
{{- icon.render_brands(false, false, "") }} {{ text -}}
</a> {#- -#}
</li>
{% endmacro menu_link %}
{%- endmacro menu_link_with_icon_brand %}

{#
Creates a formatted table showing the resource limits of a crate
Expand Down
9 changes: 9 additions & 0 deletions templates/style/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ div.container {
text-align: left;
}

ul.aligned-icons .fa {
width: 1.5em;
display: inline-flex;
}

ul.aligned-icons .fa::before {
margin: 0 auto;
}

body.centered div.container {
margin: 0 auto;
}
Expand Down
Loading