minimum viable product

This commit is contained in:
ayaka 2025-01-06 12:33:49 +13:00
parent 85dab5e070
commit 836cb15946
5 changed files with 64 additions and 26 deletions

View File

@ -323,12 +323,12 @@ async fn main() {
.at("/r/u_:name") .at("/r/u_:name")
.get(|r| async move { Ok(redirect(&format!("/user/{}", r.param("name").unwrap_or_default()))) }.boxed()); .get(|r| async move { Ok(redirect(&format!("/user/{}", r.param("name").unwrap_or_default()))) }.boxed());
app.at("/r/:sub/subscribe").post(|r| subreddit::subscriptions_filters(r).boxed()); app.at("/r/:sub/subscribe").post(|r| subreddit::subscriptions_filters_quicklists(r).boxed());
app.at("/r/:sub/unsubscribe").post(|r| subreddit::subscriptions_filters(r).boxed()); app.at("/r/:sub/unsubscribe").post(|r| subreddit::subscriptions_filters_quicklists(r).boxed());
app.at("/r/:sub/filter").post(|r| subreddit::subscriptions_filters(r).boxed()); app.at("/r/:sub/filter").post(|r| subreddit::subscriptions_filters_quicklists(r).boxed());
app.at("/r/:sub/unfilter").post(|r| subreddit::subscriptions_filters(r).boxed()); app.at("/r/:sub/unfilter").post(|r| subreddit::subscriptions_filters_quicklists(r).boxed());
app.at("/r/:sub/quicklist").post(|r| subreddit::subscriptions_filters(r).boxed()); app.at("/r/:sub/quicklist").post(|r| subreddit::subscriptions_filters_quicklists(r).boxed());
app.at("/r/:sub/unquicklist").post(|r| subreddit::subscriptions_filters(r).boxed()); app.at("/r/:sub/unquicklist").post(|r| subreddit::subscriptions_filters_quicklists(r).boxed());
app.at("/r/:sub/comments/:id").get(|r| post::item(r).boxed()); app.at("/r/:sub/comments/:id").get(|r| post::item(r).boxed());
app.at("/r/:sub/comments/:id/:title").get(|r| post::item(r).boxed()); app.at("/r/:sub/comments/:id/:title").get(|r| post::item(r).boxed());

View File

@ -211,8 +211,8 @@ pub fn can_access_quarantine(req: &Request<Body>, sub: &str) -> bool {
setting(req, &format!("allow_quaran_{}", sub.to_lowercase())).parse().unwrap_or_default() setting(req, &format!("allow_quaran_{}", sub.to_lowercase())).parse().unwrap_or_default()
} }
// Sub, filter, unfilter, or unsub by setting subscription cookie using response "Set-Cookie" header // Sub, filter, unfilter, quicklist, unquicklist or unsub by setting subscription cookie using response "Set-Cookie" header
pub async fn subscriptions_filters(req: Request<Body>) -> Result<Response<Body>, String> { pub async fn subscriptions_filters_quicklists(req: Request<Body>) -> Result<Response<Body>, String> {
let sub = req.param("sub").unwrap_or_default(); let sub = req.param("sub").unwrap_or_default();
let action: Vec<String> = req.uri().path().split('/').map(String::from).collect(); let action: Vec<String> = req.uri().path().split('/').map(String::from).collect();
@ -294,6 +294,8 @@ pub async fn subscriptions_filters(req: Request<Body>) -> Result<Response<Body>,
} else if action.contains(&"quicklist".to_string()) && !quicklist.contains(&part.to_owned()) { } else if action.contains(&"quicklist".to_string()) && !quicklist.contains(&part.to_owned()) {
// Add each sub name to the filtered list // Add each sub name to the filtered list
quicklist.push(part.to_owned()); quicklist.push(part.to_owned());
// Reorder quicklist alphabetically
quicklist.sort_by_key(|a| a.to_lowercase());
} else if action.contains(&"unquicklist".to_string()) { } else if action.contains(&"unquicklist".to_string()) {
// Remove sub name from filtered list // Remove sub name from filtered list
quicklist.retain(|s| s.to_lowercase() != part.to_lowercase()); quicklist.retain(|s| s.to_lowercase() != part.to_lowercase());

View File

@ -535,7 +535,10 @@ aside {
#sub_details, #sub_details,
#user_actions { #user_actions {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: auto 2fr 1fr;
grid-template-rows: 1fr;
grid-column-gap: 0px;
grid-row-gap: 0px;
} }
@media screen and (max-width: 279px) { @media screen and (max-width: 279px) {
#sub_actions { display: unset; } #sub_actions { display: unset; }
@ -563,7 +566,8 @@ aside {
margin-bottom: 20px; margin-bottom: 20px;
} }
#sub_quicklist button { #sub_quicklist button,
#user_quicklist button {
padding: 0px; padding: 0px;
} }

View File

@ -104,6 +104,18 @@
<img loading="lazy" id="sub_icon" src="{{ sub.icon }}" alt="Icon for r/{{ sub.name }}"> <img loading="lazy" id="sub_icon" src="{{ sub.icon }}" alt="Icon for r/{{ sub.name }}">
<h1 id="sub_title">{{ sub.title }}</h1> <h1 id="sub_title">{{ sub.title }}</h1>
<p id="sub_name">r/{{ sub.name }}</p> <p id="sub_name">r/{{ sub.name }}</p>
{% if crate::utils::enable_rss() %}
<a href="/r/{{ sub.name }}.rss" title="RSS feed for r/{{ sub.name }}">
<button>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<g fill="none" fill-rule="evenodd">
<path d="m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z" />
<path fill="currentColor" d="M18 3a3 3 0 0 1 2.995 2.824L21 6v12a3 3 0 0 1-2.824 2.995L18 21H6a3 3 0 0 1-2.995-2.824L3 18V6a3 3 0 0 1 2.824-2.995L6 3zM8.5 14a1.5 1.5 0 1 0 0 3a1.5 1.5 0 0 0 0-3M8 10.5a1 1 0 1 0 0 2a3.5 3.5 0 0 1 3.5 3.5a1 1 0 1 0 2 0A5.5 5.5 0 0 0 8 10.5M8.5 7q-.285 0-.566.019a1 1 0 0 0 .132 1.995a6.5 6.5 0 0 1 6.92 6.92a1 1 0 1 0 1.995.132A8.5 8.5 0 0 0 8.5 7" />
</g>
</svg>
</button >
</a>
{% endif %}
<p id="sub_description">{{ sub.description }}</p> <p id="sub_description">{{ sub.description }}</p>
<div id="sub_details"> <div id="sub_details">
<label>Members</label> <label>Members</label>
@ -159,13 +171,6 @@
</form> </form>
{% endif %} {% endif %}
</div> </div>
{% if crate::utils::enable_rss() %}
<div id="sub_rss">
<a href="/r/{{ sub.name }}.rss" title="RSS feed for r/{{ sub.name }}">
<button class="subscribe">RSS feed</button >
</a>
</div>
{% endif %}
</div> </div>
</details> </details>
<details class="panel" id="sidebar" open> <details class="panel" id="sidebar" open>

View File

@ -123,6 +123,18 @@ body %}
/> />
<h1 id="user_title">{{ user.title }}</h1> <h1 id="user_title">{{ user.title }}</h1>
<p id="user_name">u/{{ user.name }}</p> <p id="user_name">u/{{ user.name }}</p>
{% if crate::utils::enable_rss() %}
<a href="/r/{{ user.name }}.rss" title="RSS feed for r/{{ user.name }}">
<button>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<g fill="none" fill-rule="evenodd">
<path d="m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z" />
<path fill="currentColor" d="M18 3a3 3 0 0 1 2.995 2.824L21 6v12a3 3 0 0 1-2.824 2.995L18 21H6a3 3 0 0 1-2.995-2.824L3 18V6a3 3 0 0 1 2.824-2.995L6 3zM8.5 14a1.5 1.5 0 1 0 0 3a1.5 1.5 0 0 0 0-3M8 10.5a1 1 0 1 0 0 2a3.5 3.5 0 0 1 3.5 3.5a1 1 0 1 0 2 0A5.5 5.5 0 0 0 8 10.5M8.5 7q-.285 0-.566.019a1 1 0 0 0 .132 1.995a6.5 6.5 0 0 1 6.92 6.92a1 1 0 1 0 1.995.132A8.5 8.5 0 0 0 8.5 7" />
</g>
</svg>
</button >
</a>
{% endif %}
<div id="user_description">{{ user.description }}</div> <div id="user_description">{{ user.description }}</div>
<div id="user_details"> <div id="user_details">
<label>Karma</label> <label>Karma</label>
@ -166,16 +178,31 @@ body %}
</form> </form>
{% endif %} {% endif %}
</div> </div>
{% if crate::utils::enable_rss() %} <div id="user_quicklist">
<div id="user_rss"> {% if prefs.quicklist.contains(name) %}
<a <form action="/r/{{ name }}/unquicklist?redirect={{ redirect_url }}" method="POST">
href="/u/{{ user.name }}.rss" <button>
title="RSS feed for u/{{ user.name }}" <svg class="unquick" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
> <g fill="none">
<button class="subscribe">RSS feed</button> <path d="m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z" />
</a> <path fill="currentColor" d="M16 2a3 3 0 0 1 3 3v11h-3a3 3 0 0 0-2.997 2.87L12 18.202l-4.668 3.112C6.335 21.978 5 21.264 5 20.066V5a3 3 0 0 1 3-3zm6 16a1 1 0 0 1 .117 1.993L22 20h-6a1 1 0 0 1-.117-1.993L16 18z" />
</g>
</svg>
</button>
</form>
{% else %}
<form action="/r/{{ name }}/quicklist?redirect={{ redirect_url }}" method="POST">
<button>
<svg class="quick" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<g fill="none" fill-rule="evenodd">
<path d="m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z" />
<path fill="currentColor" d="M10 2a3 3 0 0 0-3 3a3 3 0 0 0-3 3v13.018c0 1.226 1.39 1.934 2.382 1.213l4.118-2.995l4.118 2.995c.991.721 2.382.013 2.382-1.213v-2.236l.618.45c.991.72 2.382.012 2.382-1.214V5a3 3 0 0 0-3-3zm7 14.309l1 .727V5a1 1 0 0 0-1-1h-7a1 1 0 0 0-1 1h5a3 3 0 0 1 3 3z" />
</g>
</svg>
</button>
</form>
{% endif %}
</div> </div>
{% endif %}
</div> </div>
</div> </div>
</aside> </aside>