Delete feed button
And a non-functional edit button
This commit is contained in:
parent
478e72d8f0
commit
b94555d346
@ -144,9 +144,23 @@ form.add-feed-form .form-grid textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
form.add-feed-form input[type="submit"] {
|
||||
form.add-feed-form button {
|
||||
font-size: 14px;
|
||||
margin-top: 24px;
|
||||
padding: 4px 16px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Feed */
|
||||
|
||||
header.feed-header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
header.feed-header button {
|
||||
font-size: 14px;
|
||||
padding: 4px 16px;
|
||||
margin-left: 24px;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use axum::extract::{Path, State};
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::response::{IntoResponse, Response, Redirect};
|
||||
use axum::Form;
|
||||
use feed_rs::parser;
|
||||
use maud::html;
|
||||
@ -11,7 +11,7 @@ use sqlx::PgPool;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
use crate::models::entry::get_entries_for_feed;
|
||||
use crate::models::feed::{create_feed, get_feed, CreateFeed};
|
||||
use crate::models::feed::{create_feed, get_feed, CreateFeed, delete_feed};
|
||||
use crate::partials::{entry_list::entry_list, feed_link::feed_link, layout::Layout};
|
||||
use crate::uuid::Base62Uuid;
|
||||
use crate::turbo_stream::TurboStream;
|
||||
@ -23,8 +23,15 @@ pub async fn get(
|
||||
) -> Result<Response> {
|
||||
let feed = get_feed(&pool, id.as_uuid()).await?;
|
||||
let entries = get_entries_for_feed(&pool, feed.feed_id, Default::default()).await?;
|
||||
let delete_url = format!("/feed/{}/delete", id);
|
||||
Ok(layout.render(html! {
|
||||
h2 { (feed.title.unwrap_or_else(|| "Untitled Feed".to_string())) }
|
||||
header class="feed-header" {
|
||||
h2 { (feed.title.unwrap_or_else(|| "Untitled Feed".to_string())) }
|
||||
button class="edit-feed" { "✏️ Edit feed" }
|
||||
form action=(delete_url) method="post" {
|
||||
button type="submit" class="remove-feed" data-controller="remove-feed" { "❌ Remove feed" }
|
||||
}
|
||||
}
|
||||
@if let Some(description) = feed.description {
|
||||
p { (description) }
|
||||
}
|
||||
@ -128,3 +135,11 @@ pub async fn post(
|
||||
)
|
||||
.into_response())
|
||||
}
|
||||
|
||||
pub async fn delete(
|
||||
State(pool): State<PgPool>,
|
||||
Path(id): Path<Base62Uuid>,
|
||||
) -> Result<Redirect> {
|
||||
delete_feed(&pool, id.as_uuid()).await?;
|
||||
Ok(Redirect::to("/feeds"))
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub async fn get(State(pool): State<PgPool>, layout: Layout) -> Result<Response>
|
||||
label { "Description: " }
|
||||
textarea id="description" name="description" placeholder="Feed description" {}
|
||||
}
|
||||
input type="submit" value="Add Feed";
|
||||
button type="submit" { "Add Feed" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ async fn main() -> Result<()> {
|
||||
.route("/feeds", get(handlers::feeds::get))
|
||||
.route("/feed", post(handlers::feed::post))
|
||||
.route("/feed/:id", get(handlers::feed::get))
|
||||
.route("/feed/:id/delete", post(handlers::feed::delete))
|
||||
.route("/entry/:id", get(handlers::entry::get))
|
||||
.route("/log", get(handlers::log::get))
|
||||
.route("/log/stream", get(handlers::log::stream))
|
||||
|
Loading…
Reference in New Issue
Block a user