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;
if sub_result.is_err() || items_result.is_err() {

View file

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

View file

@ -2,8 +2,9 @@
<html lang="en">
<head>
{% block head %}
<title>{% block title %}{% endblock %}</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline';">
<title>{% block title %}Libreddit{% endblock %}</title>
<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="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@ -19,11 +20,11 @@
{% endblock %}
</head>
<body>
{% block header %}
<header>
{% block navbar %}
<nav>
<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>
</header>
</nav>
{% endblock %}
{% block body %}

View file

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

View file

@ -1,6 +1,11 @@
{% extends "base.html" %}
{% if sub.name != "" %}
{% block title %}r/{{ sub.name }}: {{ sub.description }}{% endblock %}
{% endif %}
{% block body %}
{% if sub.name != "" %}
<div id="about">
<div class="subreddit">
<div class="subreddit_left">
@ -13,6 +18,7 @@
</div>
</div>
</div>
{% endif %}
<main>
<div id="sort">
<div id="sort_hot"><a href="?sort=hot">Hot</a></div>
@ -26,7 +32,7 @@
</div>
<div class="post_right">
<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>
{% if post.author_flair.0 != "" %}
<small class="author_flair">{{ post.author_flair.0 }}</small>