Add user following functionality
This commit is contained in:
parent
4a42a25ed3
commit
b3e4b7bfae
@ -3,7 +3,7 @@ name = "libreddit"
|
|||||||
description = " Alternative private front-end to Reddit"
|
description = " Alternative private front-end to Reddit"
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
repository = "https://github.com/spikecodes/libreddit"
|
repository = "https://github.com/spikecodes/libreddit"
|
||||||
version = "0.9.0"
|
version = "0.10.0"
|
||||||
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
|
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -35,18 +35,19 @@ pub async fn community(req: Request<Body>) -> Result<Response<Body>, String> {
|
|||||||
let post_sort = req.cookie("post_sort").map_or_else(|| "hot".to_string(), |c| c.value().to_string());
|
let post_sort = req.cookie("post_sort").map_or_else(|| "hot".to_string(), |c| c.value().to_string());
|
||||||
let sort = req.param("sort").unwrap_or_else(|| req.param("id").unwrap_or(post_sort));
|
let sort = req.param("sort").unwrap_or_else(|| req.param("id").unwrap_or(post_sort));
|
||||||
|
|
||||||
let sub = req.param("sub").map_or(
|
let sub = req.param("sub").unwrap_or(if front_page == "default" || front_page.is_empty() {
|
||||||
if front_page == "default" || front_page.is_empty() {
|
if subscribed.is_empty() {
|
||||||
if subscribed.is_empty() {
|
"popular".to_string()
|
||||||
"popular".to_string()
|
|
||||||
} else {
|
|
||||||
subscribed.to_owned()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
front_page.to_owned()
|
subscribed.to_owned()
|
||||||
},
|
}
|
||||||
String::from,
|
} else {
|
||||||
);
|
front_page.to_owned()
|
||||||
|
});
|
||||||
|
|
||||||
|
if req.param("sub").is_some() && sub.starts_with("u_") {
|
||||||
|
return Ok(redirect(["/user/", &sub[2..]].concat()));
|
||||||
|
}
|
||||||
|
|
||||||
let path = format!("/r/{}/{}.json?{}&raw_json=1", sub, sort, req.uri().query().unwrap_or_default());
|
let path = format!("/r/{}/{}.json?{}&raw_json=1", sub, sort, req.uri().query().unwrap_or_default());
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ aside {
|
|||||||
|
|
||||||
/* Subscriptions */
|
/* Subscriptions */
|
||||||
|
|
||||||
#sub_subscription {
|
#sub_subscription, #user_subscription {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@
|
|||||||
</form>
|
</form>
|
||||||
{% if prefs.subscriptions.len() > 0 %}
|
{% if prefs.subscriptions.len() > 0 %}
|
||||||
<div class="prefs" id="settings_subs">
|
<div class="prefs" id="settings_subs">
|
||||||
<p>Subscribed Subreddits</p>
|
<p>Subscribed Feeds</p>
|
||||||
{% for sub in prefs.subscriptions %}
|
{% for sub in prefs.subscriptions %}
|
||||||
<div>
|
<div>
|
||||||
<span>{{ sub }}</span>
|
<span>{% if sub.starts_with("u_") -%}{{ format!("u/{}", &sub[2..]) }}{% else -%}{{ format!("r/{}", sub) }}{% endif -%}</span>
|
||||||
<form action="/r/{{ sub }}/unsubscribe/?redirect=settings" method="POST">
|
<form action="/r/{{ sub }}/unsubscribe/?redirect=settings" method="POST">
|
||||||
<button class="unsubscribe">Unsubscribe</button>
|
<button class="unsubscribe">Unsubscribe</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -75,6 +75,18 @@
|
|||||||
<div>{{ user.karma }}</div>
|
<div>{{ user.karma }}</div>
|
||||||
<div>{{ user.created }}</div>
|
<div>{{ user.created }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="user_subscription">
|
||||||
|
{% let name = ["u_", user.name.as_str()].join("") %}
|
||||||
|
{% if prefs.subscriptions.contains(name) %}
|
||||||
|
<form action="/r/u_{{ user.name }}/unsubscribe" method="POST">
|
||||||
|
<button class="unsubscribe">Unfollow</button>
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<form action="/r/u_{{ user.name }}/subscribe" method="POST">
|
||||||
|
<button class="subscribe">Follow</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</main>
|
</main>
|
||||||
|
@ -58,7 +58,13 @@
|
|||||||
{% macro post_in_list(post) -%}
|
{% macro post_in_list(post) -%}
|
||||||
<div class="post {% if post.flags.stickied %}stickied{% endif %}">
|
<div class="post {% if post.flags.stickied %}stickied{% endif %}">
|
||||||
<p class="post_header">
|
<p class="post_header">
|
||||||
<a class="post_subreddit" href="/r/{{ post.community }}">r/{{ post.community }}</a>
|
{% let community -%}
|
||||||
|
{% if post.community.starts_with("u_") -%}
|
||||||
|
{% let community = format!("u/{}", &post.community[2..]) -%}
|
||||||
|
{% else -%}
|
||||||
|
{% let community = format!("r/{}", post.community) -%}
|
||||||
|
{% endif -%}
|
||||||
|
<a class="post_subreddit" href="/{{ community }}">{{ community }}</a>
|
||||||
<span class="dot">•</span>
|
<span class="dot">•</span>
|
||||||
<a class="post_author" href="/u/{{ post.author.name }}">u/{{ post.author.name }}</a>
|
<a class="post_author" href="/u/{{ post.author.name }}">u/{{ post.author.name }}</a>
|
||||||
<span class="dot">•</span>
|
<span class="dot">•</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user