Multireddit Support & Referrer Policy

This commit is contained in:
spikecodes 2020-12-20 17:45:26 -08:00
parent ef3820a2e1
commit 565f4f23b3
5 changed files with 24 additions and 9 deletions

View File

@ -33,7 +33,16 @@ pub async fn render(sub_name: String, sort: Option<String>, ends: (Option<String
}, },
}; };
let sub_result = subreddit(&sub_name).await; let sub_result = if !&sub_name.contains("+") { subreddit(&sub_name).await } else {
Ok(Subreddit {
name: String::new(),
title: String::new(),
description: String::new(),
icon: String::new(),
members: String::new(),
active: String::new(),
})
};
let items_result = fetch_posts(url, String::new()).await; let items_result = fetch_posts(url, String::new()).await;
if sub_result.is_err() || items_result.is_err() { if sub_result.is_err() || items_result.is_err() {

View File

@ -21,7 +21,7 @@ body {
background: var(--background); background: var(--background);
} }
header { nav {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
color: aqua; color: aqua;

View File

@ -2,8 +2,9 @@
<html lang="en"> <html lang="en">
<head> <head>
{% block head %} {% block head %}
<title>{% block title %}{% endblock %}</title> <title>{% block title %}Libreddit{% endblock %}</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline';"> <meta http-equiv="Referrer-Policy" content="no-referrer">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; base-uri 'none'; form-action 'self'; frame-ancestors 'none';">
<meta name="description" content="View on Libreddit, an alternative private front-end to Reddit."> <meta name="description" content="View on Libreddit, an alternative private front-end to Reddit.">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@ -19,11 +20,11 @@
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
{% block header %} {% block navbar %}
<header> <nav>
<a href="/"><span id="lib">lib</span>reddit. <span id="version">v{{ env!("CARGO_PKG_VERSION") }}</span></a> <a href="/"><span id="lib">lib</span>reddit. <span id="version">v{{ env!("CARGO_PKG_VERSION") }}</span></a>
<a id="github" href="https://github.com/spikecodes/libreddit">GITHUB</a> <a id="github" href="https://github.com/spikecodes/libreddit">GITHUB</a>
</header> </nav>
{% endblock %} {% endblock %}
{% block body %} {% block body %}

View File

@ -1,5 +1,4 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Libreddit{% endblock %}
{% block content %} {% block content %}
<div id="sort"> <div id="sort">
<div id="sort_hot"><a href="?sort=hot">Hot</a></div> <div id="sort_hot"><a href="?sort=hot">Hot</a></div>

View File

@ -1,6 +1,11 @@
{% extends "base.html" %} {% extends "base.html" %}
{% if sub.name != "" %}
{% block title %}r/{{ sub.name }}: {{ sub.description }}{% endblock %} {% block title %}r/{{ sub.name }}: {{ sub.description }}{% endblock %}
{% endif %}
{% block body %} {% block body %}
{% if sub.name != "" %}
<div id="about"> <div id="about">
<div class="subreddit"> <div class="subreddit">
<div class="subreddit_left"> <div class="subreddit_left">
@ -13,6 +18,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %}
<main> <main>
<div id="sort"> <div id="sort">
<div id="sort_hot"><a href="?sort=hot">Hot</a></div> <div id="sort_hot"><a href="?sort=hot">Hot</a></div>
@ -26,7 +32,7 @@
</div> </div>
<div class="post_right"> <div class="post_right">
<h4> <h4>
<b><a class="post_subreddit" href="/r/{{ post.community }}">r/{{ sub.name }}</a></b> <b><a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a></b>
&bull; <a class="post_author" href="/u/{{ post.author }}">u/{{ post.author }}</a> &bull; <a class="post_author" href="/u/{{ post.author }}">u/{{ post.author }}</a>
{% if post.author_flair.0 != "" %} {% if post.author_flair.0 != "" %}
<small class="author_flair">{{ post.author_flair.0 }}</small> <small class="author_flair">{{ post.author_flair.0 }}</small>