groundbreaking changes (slightly styled infobox)
This commit is contained in:
parent
d8b547547b
commit
641121789f
@ -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<Body>) -> Result<Response<Body>, 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.
|
||||
|
24
src/utils.rs
24
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<Body>, msg: &str) -> Result<Response<Body>, 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<Body>, msg: &str, sub_msg: &str) -> Result<Response<Body>, 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`.
|
||||
///
|
||||
|
@ -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);
|
||||
|
20
templates/infobox.html
Normal file
20
templates/infobox.html
Normal file
@ -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 %}
|
||||
<div id="post_error">
|
||||
<h2>{{ msg }}</h2>
|
||||
<h3><i>{{ sub_msg }}</i></h3>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user