Add option to disable all indexing.
This commit is contained in:
parent
8b4b2dd268
commit
0c591149d5
4 changed files with 24 additions and 3 deletions
|
@ -213,6 +213,7 @@ Assign a default value for each instance-specific setting by passing environment
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
| `SFW_ONLY` | `["on", "off"]` | `off` | Enables SFW-only mode for the instance, i.e. all NSFW content is filtered. |
|
| `SFW_ONLY` | `["on", "off"]` | `off` | Enables SFW-only mode for the instance, i.e. all NSFW content is filtered. |
|
||||||
| `BANNER` | String | (empty) | Allows the server to set a banner to be displayed. Currently this is displayed on the instance info page. |
|
| `BANNER` | String | (empty) | Allows the server to set a banner to be displayed. Currently this is displayed on the instance info page. |
|
||||||
|
| `ROBOTS_DISABLE_INDEXING` | `["on", "off"]` | `off` | Disables indexing of the instance by search engines. |
|
||||||
|
|
||||||
## Default User Settings
|
## Default User Settings
|
||||||
|
|
||||||
|
|
3
app.json
3
app.json
|
@ -50,6 +50,9 @@
|
||||||
"LIBREDDIT_BANNER": {
|
"LIBREDDIT_BANNER": {
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
|
"LIBREDDIT_ROBOTS_DISABLE_INDEXING": {
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS": {
|
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS": {
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -60,6 +60,9 @@ pub struct Config {
|
||||||
|
|
||||||
#[serde(rename = "LIBREDDIT_BANNER")]
|
#[serde(rename = "LIBREDDIT_BANNER")]
|
||||||
pub(crate) banner: Option<String>,
|
pub(crate) banner: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename = "LIBREDDIT_ROBOTS_DISABLE_INDEXING")]
|
||||||
|
pub(crate) robots_disable_indexing: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
@ -90,6 +93,7 @@ impl Config {
|
||||||
default_subscriptions: parse("LIBREDDIT_DEFAULT_SUBSCRIPTIONS"),
|
default_subscriptions: parse("LIBREDDIT_DEFAULT_SUBSCRIPTIONS"),
|
||||||
default_disable_visit_reddit_confirmation: parse("LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
|
default_disable_visit_reddit_confirmation: parse("LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
|
||||||
banner: parse("LIBREDDIT_BANNER"),
|
banner: parse("LIBREDDIT_BANNER"),
|
||||||
|
robots_disable_indexing: parse("LIBREDDIT_ROBOTS_DISABLE_INDEXING"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +115,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option<String> {
|
||||||
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
|
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
|
||||||
"LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(),
|
"LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(),
|
||||||
"LIBREDDIT_BANNER" => config.banner.clone(),
|
"LIBREDDIT_BANNER" => config.banner.clone(),
|
||||||
|
"LIBREDDIT_ROBOTS_DISABLE_INDEXING" => config.robots_disable_indexing.clone(),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -186,9 +186,21 @@ async fn main() {
|
||||||
app
|
app
|
||||||
.at("/manifest.json")
|
.at("/manifest.json")
|
||||||
.get(|_| resource(include_str!("../static/manifest.json"), "application/json", false).boxed());
|
.get(|_| resource(include_str!("../static/manifest.json"), "application/json", false).boxed());
|
||||||
app
|
app.at("/robots.txt").get(|_| {
|
||||||
.at("/robots.txt")
|
resource(
|
||||||
.get(|_| resource("User-agent: *\nDisallow: /u/\nDisallow: /user/", "text/plain", true).boxed());
|
if match config::get_setting("LIBREDDIT_ROBOTS_DISABLE_INDEXING") {
|
||||||
|
Some(val) => val == "on",
|
||||||
|
None => false,
|
||||||
|
} {
|
||||||
|
"User-agent: *\nDisallow: /"
|
||||||
|
} else {
|
||||||
|
"User-agent: *\nDisallow: /u/\nDisallow: /user/"
|
||||||
|
},
|
||||||
|
"text/plain",
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
});
|
||||||
app.at("/favicon.ico").get(|_| favicon().boxed());
|
app.at("/favicon.ico").get(|_| favicon().boxed());
|
||||||
app.at("/logo.png").get(|_| pwa_logo().boxed());
|
app.at("/logo.png").get(|_| pwa_logo().boxed());
|
||||||
app.at("/Inter.var.woff2").get(|_| font().boxed());
|
app.at("/Inter.var.woff2").get(|_| font().boxed());
|
||||||
|
|
Loading…
Reference in a new issue