diff --git a/src/subreddit.rs b/src/subreddit.rs
index a9b5f21..2e73496 100644
--- a/src/subreddit.rs
+++ b/src/subreddit.rs
@@ -3,7 +3,7 @@
use crate::{config, utils};
// CRATES
use crate::utils::{
- catch_random, error, filter_posts, format_num, format_url, get_filters, info, nsfw_landing, param, redirect, rewrite_urls, setting, template, val, Post, Preferences,
+ catch_random, error, filter_posts, format_num, format_url, get_filters, info, infobox, nsfw_landing, param, redirect, rewrite_urls, setting, template, val, Post, Preferences,
Subreddit,
};
use crate::{client::json, server::RequestExt, server::ResponseExt};
@@ -85,7 +85,7 @@ pub async fn community(req: Request
) -> Result, String> {
if (sub_name == "popular" || sub_name == "all") && remove_default_feeds {
if subscribed.is_empty() {
- return info(req, "Subscribe to some subreddits! (Default feeds disabled in settings)").await;
+ return infobox(req, "Subscribe to some subreddits!","Default feeds disabled in settings").await;
} else {
// If there are subscribed subs, but we get here, then the problem is that front_page pref is set to something besides default.
// Tell user to go to settings and change front page to default.
diff --git a/src/utils.rs b/src/utils.rs
index 9069742..f7b6431 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -561,6 +561,15 @@ pub struct InfoTemplate {
pub url: String,
}
+#[derive(Template)]
+#[template(path = "infobox.html")]
+pub struct InfoBoxTemplate {
+ pub msg: String,
+ pub sub_msg: String,
+ pub prefs: Preferences,
+ pub url: String,
+}
+
/// Template for NSFW landing page. The landing page is displayed when a page's
/// content is wholly NSFW, but a user has not enabled the option to view NSFW
/// posts.
@@ -1380,6 +1389,21 @@ pub async fn info(req: Request, msg: &str) -> Result, Strin
Ok(Response::builder().status(200).header("content-type", "text/html").body(body.into()).unwrap_or_default())
}
+/// Renders a styled info landing page.
+pub async fn infobox(req: Request, msg: &str, sub_msg: &str) -> Result, String> {
+ let url = req.uri().to_string();
+ let body = InfoBoxTemplate {
+ msg: msg.to_string(),
+ sub_msg: sub_msg.to_string(),
+ prefs: Preferences::new(&req),
+ url,
+ }
+ .render()
+ .unwrap_or_default();
+
+ Ok(Response::builder().status(200).header("content-type", "text/html").body(body.into()).unwrap_or_default())
+}
+
/// Returns true if the config/env variable `REDLIB_SFW_ONLY` carries the
/// value `on`.
///
diff --git a/static/style.css b/static/style.css
index 1e723ed..fe86153 100644
--- a/static/style.css
+++ b/static/style.css
@@ -2005,6 +2005,15 @@ th {
#error a {
color: var(--accent);
}
+#post_error {
+ text-align: center;
+ background: var(--post);
+ border-radius: 5px;
+ padding: 30px;
+ margin-top: 10px;
+ margin-bottom: 20px;
+ width: 60em;
+}
#issue_warning {
color: var(--popup-toreddit-text);
diff --git a/templates/infobox.html b/templates/infobox.html
new file mode 100644
index 0000000..c45a288
--- /dev/null
+++ b/templates/infobox.html
@@ -0,0 +1,20 @@
+{% extends "base.html" %}
+{% import "utils.html" as utils %}
+
+{% block title %}Info: {{ msg }},{{ sub_msg }}{% endblock %}
+{% block sortstyle %}{% endblock %}
+
+{% block subscriptions %}
+ {% call utils::sub_list("") %}
+{% endblock %}
+
+{% block search %}
+ {% call utils::search("".to_owned(), "") %}
+{% endblock %}
+
+{% block content %}
+
+
{{ msg }}
+ {{ sub_msg }}
+
+{% endblock %}