Compare commits

..

4 Commits

Author SHA1 Message Date
Greg Shuflin
682292d71b break up css file 2025-02-05 03:26:05 -08:00
Greg Shuflin
d356027283 remove hover style 2025-02-05 03:12:16 -08:00
Greg Shuflin
ee06791ef7 Add feed button 2025-02-05 03:08:14 -08:00
Greg Shuflin
df46571240 use sqlx query macro everywhere 2025-02-05 03:01:39 -08:00
15 changed files with 757 additions and 56 deletions

View File

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "DELETE FROM feeds WHERE feed_id = ? AND user_id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "8b041918410c3c12dc9faff2a36e908455ae0e5bbadebc606944908ee49c6c63"
}

View File

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "UPDATE feeds SET last_checked_time = ? WHERE feed_id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "a1da67f80f4bcaebc761aba3c6043f9ebe7fecd2351be8b0bd3e4bd34a70b107"
}

View File

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO feeds (feed_id, name, url, user_id, added_time, last_checked_time, categorization) \n VALUES (?, ?, ?, ?, ?, ?, json(?))\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 7
},
"nullable": []
},
"hash": "c23d98cd26e2aa0637978f71455bcf0f8384572858e9649704596ba63f2a8b96"
}

View File

@ -47,17 +47,26 @@ impl Feed {
sqlx::Error::Decode(Box::new(e))
})?;
sqlx::query(
"INSERT INTO feeds (feed_id, name, url, user_id, added_time, last_checked_time, categorization)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, json(?7))",
let feed_id_str = self.feed_id.to_string();
let user_id_str = self.user_id.to_string();
let added_time_str = self.added_time.to_rfc3339();
let last_checked_time_str = self.last_checked_time.to_rfc3339();
let url_str = self.url.as_str();
let categorization_str = categorization_json.to_string();
sqlx::query!(
r#"
INSERT INTO feeds (feed_id, name, url, user_id, added_time, last_checked_time, categorization)
VALUES (?, ?, ?, ?, ?, ?, json(?))
"#,
feed_id_str,
self.name,
url_str,
user_id_str,
added_time_str,
last_checked_time_str,
categorization_str
)
.bind(self.feed_id.to_string())
.bind(&self.name)
.bind(self.url.as_str())
.bind(self.user_id.to_string())
.bind(self.added_time.to_rfc3339())
.bind(self.last_checked_time.to_rfc3339())
.bind(categorization_json.to_string())
.execute(executor)
.await?;
@ -193,13 +202,18 @@ pub async fn delete_feed(mut db: Connection<Db>, feed_id: &str, user: Authentica
Err(_) => return Status::BadRequest,
};
let query = sqlx::query("DELETE FROM feeds WHERE feed_id = ? AND user_id = ?")
.bind(feed_uuid.to_string())
.bind(user.user_id.to_string())
let feed_id_str = feed_uuid.to_string();
let user_id_str = user.user_id.to_string();
let result = sqlx::query!(
"DELETE FROM feeds WHERE feed_id = ? AND user_id = ?",
feed_id_str,
user_id_str
)
.execute(&mut **db)
.await;
match query {
match result {
Ok(result) => {
if result.rows_affected() > 0 {
Status::NoContent

View File

@ -57,9 +57,11 @@ async fn update_entry_db(
let now = Utc::now().to_rfc3339();
// Update the feed's last_checked_time
sqlx::query("UPDATE feeds SET last_checked_time = ? WHERE feed_id = ?")
.bind(&now)
.bind(feed_id)
sqlx::query!(
"UPDATE feeds SET last_checked_time = ? WHERE feed_id = ?",
now,
feed_id
)
.execute(&mut *tx)
.await
.map_err(|e| {
@ -163,7 +165,8 @@ async fn read_entries(feed_id: &str, db: &mut SqliteConnection) -> Result<Vec<En
Ok(Entry {
id: row.id.clone(),
local_id: Uuid::parse_str(&row.local_id).map_err(|_| Status::InternalServerError)?,
local_id: Uuid::parse_str(&row.local_id)
.map_err(|_| Status::InternalServerError)?,
title: row.title.clone(),
published: row.published.flatten(),
updated: row.updated.flatten(),

View File

@ -177,10 +177,7 @@ pub async fn delete_user(mut db: Connection<Db>, user_id: &str) -> Status {
};
let id_str = uuid.to_string();
let result = sqlx::query!(
"DELETE FROM users WHERE id = ?",
id_str
)
let result = sqlx::query!("DELETE FROM users WHERE id = ?", id_str)
.execute(&mut **db)
.await;
@ -353,7 +350,8 @@ pub async fn setup(
let new_user = new_user.into_inner();
// Hash the password - we'll use bcrypt
let password_hash = bcrypt::hash(new_user.password.as_bytes(), bcrypt::DEFAULT_COST).map_err(|_| {
let password_hash =
bcrypt::hash(new_user.password.as_bytes(), bcrypt::DEFAULT_COST).map_err(|_| {
Json(SetupError {
error: "Failed to hash password".to_string(),
})
@ -367,11 +365,11 @@ pub async fn setup(
);
user.admin = true;
user.write_to_database(&mut **db)
.await
.map_err(|_| Json(SetupError {
user.write_to_database(&mut **db).await.map_err(|_| {
Json(SetupError {
error: "Failed to create user".to_string(),
}))?;
})
})?;
Ok(Status::Created)
}

View File

@ -0,0 +1,67 @@
/* Dropdown menu styles */
.feed-menu-button {
position: absolute;
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
color: var(--text-muted);
padding: 0.2rem 0.5rem;
cursor: pointer;
font-size: 1.2rem;
opacity: 0;
transition: opacity 0.2s ease;
}
.feed-name:hover .feed-menu-button {
opacity: 1;
}
.feed-menu-button:hover {
color: var(--text-color);
}
.feed-menu {
position: absolute;
right: 0.5rem;
top: 100%;
background-color: var(--sidebar-bg);
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
display: none;
z-index: 100;
}
.feed-menu.show {
display: block;
}
.feed-menu-item {
display: block;
padding: 0.5rem 1rem;
color: var(--text-color);
text-decoration: none;
white-space: nowrap;
cursor: pointer;
transition: background-color 0.2s ease;
}
.feed-menu-item:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.menu-icon {
display: inline-block;
width: 1.2em;
margin-right: 0.5rem;
text-align: center;
}
.feed-menu-item.delete {
color: var(--primary-red);
}
.feed-menu-item.delete:hover {
background-color: rgba(244, 63, 63, 0.1);
}

View File

@ -0,0 +1,62 @@
/* Feed entry styles */
.feed-entry {
padding: 20px;
margin-bottom: 15px;
border-radius: 8px;
background-color: var(--sidebar-bg);
}
.feed-entry.read {
background-color: var(--read-bg);
}
.feed-entry.read .feed-entry-title a {
color: var(--text-muted);
}
.feed-entry.read .feed-entry-summary {
color: var(--text-muted);
}
.feed-entry-title {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.feed-entry-title a {
color: var(--text-color);
text-decoration: none;
}
.feed-entry-meta {
color: var(--text-muted);
font-size: 0.9rem;
margin-bottom: 1rem;
}
.feed-entry-meta span {
margin-right: 1rem;
}
.feed-entry-summary {
color: var(--text-color);
line-height: 1.5;
}
.read-toggle {
background: none;
border: none;
color: var(--text-color);
cursor: pointer;
padding: 0.25rem;
opacity: 0.7;
transition: opacity 0.2s;
font-size: 1.2rem;
margin-left: -0.25rem;
}
.read-toggle:hover {
opacity: 1;
}

View File

@ -0,0 +1,171 @@
/* Form styles */
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-color);
}
.form-group input {
width: 100%;
padding: 0.75rem;
border: 1px solid var(--text-muted);
border-radius: 4px;
background-color: var(--dark-bg);
color: var(--text-color);
font-size: 1rem;
}
.form-group input:focus {
outline: none;
border-color: var(--primary-red);
}
/* Login form */
.login-container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
width: 100%;
background-color: var(--dark-bg);
}
.login-form {
background-color: var(--sidebar-bg);
padding: 2rem;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 400px;
}
.login-form h1 {
color: var(--primary-red);
text-align: center;
margin-bottom: 1.5rem;
}
.login-form button {
width: 100%;
padding: 0.75rem;
background-color: var(--primary-red);
color: var(--text-color);
border: none;
border-radius: 4px;
font-size: 1rem;
cursor: pointer;
transition: opacity 0.2s ease;
}
.login-form button:hover {
opacity: 0.9;
}
/* Setup form */
.setup-container {
max-width: 500px;
margin: 50px auto;
padding: 2rem;
background-color: var(--sidebar-bg);
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.setup-container h1 {
text-align: center;
margin-bottom: 1rem;
color: var(--text-color);
}
.setup-container p {
text-align: center;
margin-bottom: 2rem;
color: var(--text-muted);
}
.setup-form {
display: flex;
flex-direction: column;
gap: 1rem;
}
.setup-form .form-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.setup-form label {
color: var(--text-color);
font-weight: 500;
}
.setup-form input {
padding: 0.5rem;
border: 1px solid #3f4049;
border-radius: 4px;
background-color: #1e1f26;
color: var(--text-color);
transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.setup-form input:focus {
outline: none;
border-color: var(--primary-red);
box-shadow: 0 0 0 2px rgba(244, 63, 63, 0.2);
}
.setup-form input:hover {
border-color: #4f5159;
}
.setup-form button {
margin-top: 1rem;
background-color: #2ecc71;
color: var(--text-color);
border: none;
padding: 0.75rem 1rem;
border-radius: 4px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s ease;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.setup-form button:hover {
background-color: #27ae60;
}
.setup-form button:active {
background-color: #219a52;
}
.setup-form button:disabled {
background-color: #666;
cursor: not-allowed;
}
/* Demo notice */
.demo-notice {
border: 1px solid #dee2e6;
border-radius: 4px;
padding: 1rem;
margin-bottom: 2rem;
text-align: center;
}
.demo-notice p {
margin: 0.5rem 0;
}
.demo-notice pre {
padding: 0.1rem 0.4rem;
border-radius: 2px;
font-family: monospace;
}

View File

@ -0,0 +1,34 @@
/* Basic layout styles */
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: var(--dark-bg);
color: var(--text-color);
}
body.with-sidebar {
display: flex;
}
.main-content {
flex: 1;
padding: 20px 40px;
}
.main-content h1 {
color: var(--primary-red);
font-size: 2.5em;
margin-bottom: 0.5em;
}
.main-content p {
line-height: 1.6;
color: var(--text-muted);
margin-bottom: 1.5em;
}
/* Layout adjustments */
.with-sidebar {
padding-top: 3rem;
}

View File

@ -0,0 +1,96 @@
/* Modal styles */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 2000;
align-items: center;
justify-content: center;
}
.modal.show {
display: flex;
}
.modal-content {
background-color: white;
padding: 2rem;
border-radius: 8px;
width: 100%;
max-width: 500px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.modal-header {
margin-bottom: 1.5rem;
}
.modal-header h2 {
margin: 0;
color: #333;
}
.modal-body {
margin-bottom: 1.5rem;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 1rem;
}
.modal-footer button {
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 0.9rem;
}
.btn-primary {
background-color: #007bff;
color: white;
}
.btn-primary:hover {
background-color: #0056b3;
}
.btn-secondary {
background-color: #6c757d;
color: white;
}
.btn-secondary:hover {
background-color: #545b62;
}
/* Loading state */
.spinner {
width: 30px;
height: 30px;
margin: 0 auto 10px;
border: 3px solid #f3f3f3;
border-top: 3px solid var(--primary-red);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-message {
padding: 1rem;
}
button:disabled {
opacity: 0.6;
cursor: not-allowed;
}

View File

@ -0,0 +1,103 @@
/* Sidebar styles */
.sidebar {
width: 250px;
background-color: var(--sidebar-bg);
min-height: 100vh;
padding: 20px;
box-shadow: 2px 0 5px rgba(0,0,0,0.3);
top: 3rem;
}
.sidebar h2 {
color: var(--primary-red);
margin-top: 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.sidebar-add-feed {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 0.25rem;
font-size: 1.2rem;
transition: color 0.2s ease;
}
.sidebar-add-feed:hover {
color: var(--primary-red);
}
/* Feed list styles */
#feedList {
margin-bottom: 2rem;
}
.feed-name {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.15rem;
margin: 0.25rem 0;
color: var(--text-color);
text-decoration: none;
border-radius: 4px;
transition: background-color 0.2s ease;
cursor: pointer;
position: relative;
padding-right: 2.5rem;
}
.feed-name:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.feed-spinner {
width: 16px;
height: 16px;
margin-left: 8px;
border: 2px solid transparent;
border-top: 2px solid var(--text-color);
border-radius: 50%;
animation: feed-spin 1s linear infinite;
display: none;
}
.feed-name.loading .feed-spinner {
display: inline-block;
}
@keyframes feed-spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.feed-category {
margin-bottom: 1rem;
}
.feed-category-header {
color: var(--primary-red);
font-size: 0.9rem;
text-transform: uppercase;
letter-spacing: 0.05em;
margin: 0;
border-bottom: 1px solid var(--border-color);
}
.feed-empty {
color: var(--text-muted);
text-align: center;
padding: 1rem;
font-style: italic;
}
.feed-error {
color: var(--primary-red);
text-align: center;
padding: 1rem;
background-color: rgba(244, 63, 63, 0.1);
border-radius: 4px;
}

View File

@ -0,0 +1,95 @@
/* Top bar styles */
.top-bar {
background-color: #333;
color: white;
padding: 0.5rem 1rem;
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
}
.top-bar-title {
font-size: 1.5rem;
margin: 0;
color: var(--primary-red);
font-weight: 500;
text-align: center;
grid-column: 2;
}
.feed-title-separator {
color: var(--text-muted);
margin: 0 0.5rem;
}
/* User menu styles */
.user-menu {
position: relative;
grid-column: 3;
justify-self: end;
}
.user-menu-button {
background: none;
border: none;
color: var(--text-color);
padding: 0.5rem;
cursor: pointer;
font-size: 1.2rem;
display: flex;
align-items: center;
transition: opacity 0.2s ease;
}
.user-menu-button:hover {
opacity: 0.8;
}
.user-menu-icon {
font-size: 1.4rem;
}
.user-menu-dropdown {
position: absolute;
top: 100%;
right: 0;
background-color: var(--sidebar-bg);
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
min-width: 150px;
display: none;
z-index: 1000;
}
.user-menu-dropdown.show {
display: block;
}
.user-menu-item {
display: block;
width: 100%;
padding: 0.75rem 1rem;
text-align: left;
background: none;
border: none;
color: var(--text-color);
cursor: pointer;
transition: background-color 0.2s ease;
}
.user-menu-item:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.user-menu-item#logoutButton {
color: var(--primary-red);
}
.user-menu-item#logoutButton:hover {
background-color: rgba(244, 63, 63, 0.1);
}

View File

@ -1,4 +1,11 @@
@import 'root.css';
@import 'components/layout.css';
@import 'components/sidebar.css';
@import 'components/topbar.css';
@import 'components/forms.css';
@import 'components/modal.css';
@import 'components/feed-entries.css';
@import 'components/dropdown.css';
body {
margin: 0;
@ -23,6 +30,23 @@ body.with-sidebar {
.sidebar h2 {
color: var(--primary-red);
margin-top: 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.sidebar-add-feed {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 0.25rem;
font-size: 1.2rem;
transition: color 0.2s ease;
}
.sidebar-add-feed:hover {
color: var(--primary-red);
}
.sidebar ul {
@ -131,8 +155,8 @@ body.with-sidebar {
background-color: #333;
color: white;
padding: 0.5rem 1rem;
display: flex;
justify-content: space-between;
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
position: fixed;
top: 0;
@ -146,9 +170,8 @@ body.with-sidebar {
margin: 0;
color: var(--primary-red);
font-weight: 500;
position: absolute;
left: 50%;
transform: translateX(-50%);
text-align: center;
grid-column: 2;
}
.feed-title-separator {
@ -529,11 +552,6 @@ button:disabled {
color: var(--text-muted);
}
.feed-entry:hover {
background-color: var(--sidebar-bg);
opacity: 1;
}
.feed-entry-title {
display: flex;
align-items: center;
@ -582,6 +600,8 @@ button:disabled {
/* User menu styles */
.user-menu {
position: relative;
grid-column: 3;
justify-self: end;
}
.user-menu-button {

View File

@ -9,9 +9,6 @@
</head>
<body class="with-sidebar">
<header class="top-bar">
<nav class="top-bar-buttons">
<button class="add-feed-button" id="addFeedButton">Add Feed</button>
</nav>
<h1 class="top-bar-title">RSS Reader</h1>
<div class="user-menu">
<button class="user-menu-button" id="userMenuButton">
@ -51,7 +48,12 @@
</dialog>
<aside class="sidebar">
<h2>Feeds</h2>
<h2>
Feeds
<button class="sidebar-add-feed" id="addFeedButton" title="Add Feed">
<i class="fas fa-plus"></i>
</button>
</h2>
<nav id="feedList">
</nav>
</aside>