Insert noindex meta for ROBOTS_DISABLE_INDEXING (#199) (#207)
Release Build / Rust project - latest (aarch64-unknown-linux-musl) (push) Has been cancelled
Release Build / Rust project - latest (armv7-unknown-linux-musleabihf) (push) Has been cancelled
Release Build / Rust project - latest (x86_64-unknown-linux-musl) (push) Has been cancelled
Rust Build & Publish / build (push) Has been cancelled
Pull Request / cargo test (push) Has been cancelled
Pull Request / cargo fmt --all -- --check (push) Has been cancelled
Pull Request / cargo clippy -- -D warnings (push) Has been cancelled

This commit is contained in:
Kot C
2024-09-03 18:44:04 -05:00
committed by GitHub
parent 438e412be3
commit c494fbec31
2 changed files with 15 additions and 0 deletions
+12
View File
@@ -1096,6 +1096,18 @@ pub fn enable_rss() -> bool {
}
}
/// Returns true if the config/env variable `REDLIB_ROBOTS_DISABLE_INDEXING` carries the
/// value `on`.
///
/// If this variable is set as such, the instance will block all robots in robots.txt and
/// insert the noindex, nofollow meta tag on every page.
pub fn disable_indexing() -> bool {
match get_setting("REDLIB_ROBOTS_DISABLE_INDEXING") {
Some(val) => val == "on",
None => false,
}
}
// Determines if a request shoud redirect to a nsfw landing gate.
pub fn should_be_nsfw_gated(req: &Request<Body>, req_url: &str) -> bool {
let sfw_instance = sfw_only();
+3
View File
@@ -8,6 +8,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="View on Redlib, an alternative private front-end to Reddit.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if crate::utils::disable_indexing() %}
<meta name="robots" content="noindex, nofollow">
{% endif %}
<!-- General PWA -->
<meta name="theme-color" content="#1F1F1F">
<!-- iOS Application -->