Change subscription to get. Add subs to settings.
This commit is contained in:
parent
dc2030e6f3
commit
449899962a
@ -100,7 +100,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.route("/", web::get().to(subreddit::page))
|
.route("/", web::get().to(subreddit::page))
|
||||||
.route("/{sort:hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
|
.route("/{sort:hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
|
||||||
// Handle subscribe/unsubscribe
|
// Handle subscribe/unsubscribe
|
||||||
.route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::subscriptions))
|
.route("/{action:subscribe|unsubscribe}/", web::get().to(subreddit::subscriptions))
|
||||||
// View post on subreddit
|
// View post on subreddit
|
||||||
.service(
|
.service(
|
||||||
web::scope("/comments/{id}/{title}")
|
web::scope("/comments/{id}/{title}")
|
||||||
|
@ -103,7 +103,16 @@ pub async fn subscriptions(req: HttpRequest) -> HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Redirect back to subreddit
|
// Redirect back to subreddit
|
||||||
let path = format!("/r/{}", sub);
|
// check for redirect parameter if unsubscribing from outside sidebar
|
||||||
|
let redirect_path = param(&format!("{}?{}", req.path(), req.query_string()), "redirect");
|
||||||
|
let path;
|
||||||
|
|
||||||
|
if redirect_path.len() > 1 && redirect_path.chars().nth(0).unwrap() == '/' {
|
||||||
|
path = redirect_path;
|
||||||
|
} else {
|
||||||
|
path = format!("/r/{}", sub);
|
||||||
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.set_header("Location", path.to_string())
|
.set_header("Location", path.to_string())
|
||||||
|
@ -239,7 +239,7 @@ aside {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#sub_subscription > input {
|
#sub_subscription > a {
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ a.search_subreddit:hover {
|
|||||||
opacity: 0.75;
|
opacity: 0.75;
|
||||||
}
|
}
|
||||||
|
|
||||||
#prefs {
|
.prefs {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -886,7 +886,7 @@ a.search_subreddit:hover {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#prefs > div {
|
.prefs > div {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -894,11 +894,11 @@ a.search_subreddit:hover {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#prefs > div:not(:last-of-type) {
|
.prefs > div:not(:last-of-type) {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#prefs select {
|
.prefs select {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
box-shadow: var(--shadow);
|
box-shadow: var(--shadow);
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
@ -917,6 +917,30 @@ input[type="submit"] {
|
|||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings_subs {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings_subs > li {
|
||||||
|
display: flex;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
#settings_subs > li:last-of-type { margin-bottom: 0; }
|
||||||
|
|
||||||
|
#settings_subs > li > span {
|
||||||
|
padding: 10px 0;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings_subs > li > a {
|
||||||
|
margin-left: 30px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: var(--highlighted);
|
||||||
|
}
|
||||||
|
|
||||||
/* Markdown */
|
/* Markdown */
|
||||||
|
|
||||||
.md > *:not(:first-child) {
|
.md > *:not(:first-child) {
|
||||||
|
@ -7,13 +7,9 @@
|
|||||||
{% call utils::search("".to_owned(), "", "") %}
|
{% call utils::search("".to_owned(), "", "") %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block subscriptions %}
|
|
||||||
{% call utils::sub_list("", "narrow") %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form id="settings" action="/settings" method="POST">
|
<form id="settings" action="/settings" method="POST">
|
||||||
<div id="prefs">
|
<div class="prefs">
|
||||||
<p>Appearance</p>
|
<p>Appearance</p>
|
||||||
<div id="theme">
|
<div id="theme">
|
||||||
<label for="theme">Theme:</label>
|
<label for="theme">Theme:</label>
|
||||||
@ -52,5 +48,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<p id="settings_note"><b>Note:</b> settings are saved in browser cookies. Clearing your cookie data will reset them.</p>
|
<p id="settings_note"><b>Note:</b> settings are saved in browser cookies. Clearing your cookie data will reset them.</p>
|
||||||
<input id="save" type="submit" value="Save">
|
<input id="save" type="submit" value="Save">
|
||||||
|
{% if prefs.subs.len() > 0 %}
|
||||||
|
<aside class="prefs">
|
||||||
|
<p>Subscribed Subreddits</p>
|
||||||
|
<ul id="settings_subs">
|
||||||
|
{% for sub in prefs.subs %}
|
||||||
|
<li>
|
||||||
|
<span>{{ sub }}</span>
|
||||||
|
<a href="/r/{{ sub }}/unsubscribe/?redirect=/settings">Unsubscribe</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -125,15 +125,13 @@
|
|||||||
<div>{{ sub.members }}</div>
|
<div>{{ sub.members }}</div>
|
||||||
<div>{{ sub.active }}</div>
|
<div>{{ sub.active }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% if prefs.subs.contains(sub.name) %}
|
<div id="sub_subscription">
|
||||||
<form id="sub_subscription" action="/r/{{ sub.name }}/unsubscribe" method="POST">
|
{% if prefs.subs.contains(sub.name) %}
|
||||||
<input class="subscribe remove" type="submit" value="Unsubscribe">
|
<a href="/r/{{ sub.name }}/unsubscribe" class="subscribe remove">Unsubscribe</a>
|
||||||
</form>
|
{% else %}
|
||||||
{% else %}
|
<a href="/r/{{ sub.name }}/subscribe" class="subscribe add">Subscribe</a>
|
||||||
<form id="sub_subscription" action="/r/{{ sub.name }}/subscribe" method="POST">
|
{% endif %}
|
||||||
<input class="subscribe add" type="submit" value="Subscribe">
|
</div>
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<details class="panel" id="sidebar">
|
<details class="panel" id="sidebar">
|
||||||
|
Loading…
Reference in New Issue
Block a user