Replace Responsive Feature with Secure

This commit is contained in:
spikecodes 2020-12-25 18:06:33 -08:00
parent ace21b21d5
commit dad01749e6
3 changed files with 7 additions and 2 deletions

View File

@ -7,8 +7,8 @@ Libre + Reddit = [Libreddit](https://libredd.it)
- 🚀 Fast: written in Rust for blazing fast speeds and safety
- ☁️ Light: no JavaScript, no ads, no tracking
- 🕵 Private: all requests are proxied through the server, including media
- 🔒 Safe: does not rely on Reddit OAuth or require a Reddit API Key
- 📱 Responsive: works great on mobile!
- 🦺 Safe: does not rely on Reddit OAuth or require a Reddit API Key
- 🔒 Secure: strong [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) prevents browser requests to Reddit
Like [Invidious](https://github.com/iv-org/invidious) but for Reddit. Browse the coldest takes of [r/unpopularopinion](https://libredd.it/r/unpopularopinion) without being [tracked](#reddit).

View File

@ -86,9 +86,11 @@ async fn subreddit(sub: &String) -> Result<Subreddit, &'static str> {
// Otherwise, grab the JSON output from the request
let res = req.unwrap();
// Metadata regarding the subreddit
let members = res["data"]["subscribers"].as_u64().unwrap_or(0);
let active = res["data"]["accounts_active"].as_u64().unwrap_or(0);
// Fetch subreddit icon either from the community_icon or icon_img value
let community_icon: &str = res["data"]["community_icon"].as_str().unwrap().split("?").collect::<Vec<&str>>()[0];
let icon = if community_icon.is_empty() {
val(&res, "icon_img").await

View File

@ -80,6 +80,7 @@ pub struct ErrorTemplate {
// FORMATTING
//
// Direct urls to proxy if proxy is enabled
pub async fn format_url(url: String) -> String {
if url.is_empty() {
return String::new();
@ -92,6 +93,7 @@ pub async fn format_url(url: String) -> String {
return url.to_string();
}
// Append `m` and `k` for millions and thousands respectively
pub fn format_num(num: i64) -> String {
if num > 1000000 {
format!("{}m", num / 1000000)
@ -116,6 +118,7 @@ pub async fn nested_val(j: &serde_json::Value, n: &str, k: &str) -> String {
String::from(j["data"][n][k].as_str().unwrap())
}
// Fetch posts of a user or subreddit
pub async fn fetch_posts(url: String, fallback_title: String) -> Result<(Vec<Post>, String), &'static str> {
// Send a request to the url, receive JSON in response
let req = request(url).await;