Compare commits

..

No commits in common. "ededa849f4bb44d92b9ecd4bdb6068c207569b82" and "2dbcc071a6454d588e498364e4c8a597f7451103" have entirely different histories.

8 changed files with 2 additions and 62 deletions

View File

@ -26,7 +26,7 @@ use client::{canonical_path, proxy};
use log::info;
use once_cell::sync::Lazy;
use server::RequestExt;
use utils::{error, redirect, ThemeAssets, MascotAssets};
use utils::{error, redirect, ThemeAssets};
use crate::client::OAUTH_CLIENT;
@ -111,20 +111,6 @@ async fn style() -> Result<Response<Body>, String> {
)
}
/// Serve mascot
async fn mascot_image(req: Request<Body>) -> Result<Response<Body>, String> {
let res = MascotAssets::get(&req.param("name").unwrap())
.unwrap_or(MascotAssets::get("redsunlib.png").unwrap());
Ok(
Response::builder()
.status(200)
.header("content-type", "image/png")
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
.body(res.data.into())
.unwrap_or_default(),
)
}
#[tokio::main]
async fn main() {
// Load environment variables
@ -279,9 +265,6 @@ async fn main() {
app.at("/settings/restore").get(|r| settings::restore(r).boxed());
app.at("/settings/update").get(|r| settings::update(r).boxed());
// Mascots
app.at("/mascot/:name").get(|r| mascot_image(r).boxed());
// Subreddit services
app
.at("/r/:sub")

View File

@ -19,9 +19,8 @@ struct SettingsTemplate {
// CONSTANTS
const PREFS: [&str; 17] = [
const PREFS: [&str; 16] = [
"theme",
"mascot",
"front_page",
"layout",
"wide",

View File

@ -570,9 +570,7 @@ pub struct Params {
#[derive(Default)]
pub struct Preferences {
pub available_themes: Vec<String>,
pub available_mascots: Vec<String>,
pub theme: String,
pub mascot: String,
pub front_page: String,
pub layout: String,
pub wide: String,
@ -597,11 +595,6 @@ pub struct Preferences {
#[include = "*.css"]
pub struct ThemeAssets;
#[derive(RustEmbed)]
#[folder = "static/mascots/"]
#[include = "*.png"]
pub struct MascotAssets;
impl Preferences {
// Build preferences from cookies
pub fn new(req: &Request<Body>) -> Self {
@ -612,18 +605,9 @@ impl Preferences {
let chunks: Vec<&str> = file.as_ref().split(".css").collect();
themes.push(chunks[0].to_owned());
}
// Read available mascot names from embedded png files.
// Always make default "none" option available.
let mut mascots = vec!["none".to_string()];
for file in MascotAssets::iter() {
let chunks: Vec<&str> = file.as_ref().split(".png").collect();
mascots.push(chunks[0].to_owned());
}
Self {
available_themes: themes,
available_mascots: mascots,
theme: setting(req, "theme"),
mascot: setting(req, "mascot"),
front_page: setting(req, "front_page"),
layout: setting(req, "layout"),
wide: setting(req, "wide"),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -1774,16 +1774,3 @@ td, th {
background-color: var(--accent);
color: var(--text);
}
.mascot {
position: fixed;
right: 1em;
bottom: 1em;
pointer-events: none;
opacity: 0.5;
z-index: 1;
}
.mascot > img {
max-width: 20em;
}

View File

@ -60,13 +60,6 @@
</div>
</nav>
{% if prefs.mascot != "none" && prefs.mascot != "" %}
<!-- MASCOT -->
<div class="mascot">
<img src="/mascot/{{ prefs.mascot }}.png">
</div>
{% endif %}
<!-- MAIN CONTENT -->
{% block body %}
<main>

View File

@ -19,12 +19,6 @@
{% call utils::options(prefs.theme, prefs.available_themes, "system") %}
</select>
</div>
<div class="prefs-group">
<label for="mascot">Mascot:</label>
<select name="mascot" id="mascot">
{% call utils::options(prefs.mascot, prefs.available_mascots, "system") %}
</select>
</div>
</fieldset>
<fieldset>
<legend>Interface</legend>