Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove filters #2607

Merged
merged 3 commits into from
Sep 18, 2024
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
13 changes: 0 additions & 13 deletions src/web/page/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pub mod filters {
use chrono::{DateTime, Utc};
use rinja::filters::Safe;
use std::borrow::Cow;
use std::fmt;

// Copied from `tera`.
pub fn escape_html(input: &str) -> rinja::Result<Cow<'_, str>> {
Expand Down Expand Up @@ -247,26 +246,14 @@ pub mod filters {
}
}

pub fn unwrap<T: fmt::Display>(value: &Option<T>) -> rinja::Result<&T> {
Ok(value.as_ref().expect("`unwrap` filter failed"))
}

pub fn split_first<'a>(value: &'a str, pat: &str) -> rinja::Result<Option<&'a str>> {
Ok(value.split(pat).next())
}

pub fn to_string<T: fmt::Display>(value: &T) -> rinja::Result<String> {
Ok(value.to_string())
}

pub fn json_encode<T: ?Sized + serde::Serialize>(value: &T) -> rinja::Result<String> {
Ok(serde_json::to_string(value).expect("`encode_json` failed"))
}

pub fn as_f32(value: &i32) -> rinja::Result<f32> {
Ok(*value as f32)
}

pub fn rest_menu_url(current_target: &str, inner_path: &str) -> rinja::Result<String> {
if current_target.is_empty() {
return Ok(String::new());
Expand Down
4 changes: 2 additions & 2 deletions templates/crate/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<div class="pure-menu package-menu">
<ul class="pure-menu-list">
{%- if let (Some(documented), Some(total)) = (documented_items, total_items) -%}
{% set documented_f32 = documented|as_f32 %}
{% set total_f32 = total|as_f32 %}
{% set documented_f32 = documented as f32 %}
{% set total_f32 = total as f32 %}
{% set percent = documented_f32 * 100f32 / total_f32 %}
<li class="pure-menu-heading">Coverage</li>
<li class="pure-menu-item text-center"><b>{{ percent|round(2) }}%</b><br>
Expand Down
2 changes: 1 addition & 1 deletion templates/rustdoc/head.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%- import "macros.html" as macros -%}
<link rel="stylesheet" href="/-/static/{{rustdoc_css_file|unwrap}}?{{ crate::BUILD_VERSION|slugify }}" media="all" />
<link rel="stylesheet" href="/-/static/{{rustdoc_css_file.as_ref().unwrap()}}?{{ crate::BUILD_VERSION|slugify }}" media="all" />

<link rel="search" href="/-/static/opensearch.xml" type="application/opensearchdescription+xml" title="Docs.rs" />

Expand Down
6 changes: 3 additions & 3 deletions templates/rustdoc/topbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<span id="clipboard" class="fa-svg fa-svg-fw" title="Copy crate name and version information">{%- include "clipboard.svg" -%}</span>
</li>

{%- if metadata.req_version|to_string == "latest" -%}
{%- if metadata.req_version.to_string() == "latest" -%}
<li class="pure-menu-item">
<a href="{% if permalink_path is defined %}{{permalink_path|safe}}{% endif %}" class="pure-menu-link description" id="permalink" title="Get a link to this specific version">
{{ "link"|fas(false, false, "") }} Permalink
Expand Down Expand Up @@ -149,8 +149,8 @@
</div>
</div>
{%- if let (Some(documented), Some(total)) = (krate.documented_items, krate.total_items) -%}
{% set documented = documented|as_f32 %}
{% set total = total|as_f32 %}
{% set documented = documented as f32 %}
{% set total = total as f32 %}
{% set percent = documented * 100f32 / total %}
<div class="pure-g">
<div class="pure-u-1">
Expand Down
Loading