feat: bookmarks and notes management

- Backend: Django REST Framework API with Bookmark and Note models
  - ViewSets with user-scoped querysets and select_related for N+1 prevention
  - Create/List/Detail/Update/Delete endpoints
  - Batch delete operations
  - Unique constraint on user+book+page for bookmarks
  - IsOwner permission class for object-level access control
  - Full serializer validation (page > 0, non-empty content, duplicate check)
  - 30+ pytest-django tests covering CRUD, auth, filtering, edge cases

- Frontend: React TypeScript components
  - AnnotationsContext with useReducer for state management
  - BookmarkList, NoteList, AddAnnotationForm, AnnotationsDashboard
  - Inline note editing with immediate save
  - Batch delete support
  - API client with JWT auto-refresh interceptors
  - Paginated query hook for infinite scroll support
  - Responsive CSS with loading/empty states

- Infrastructure: Django project with custom User model, JWT auth, CORS
  - PostgreSQL database models with proper FK and indexes
  - Django admin configuration for all models
This commit is contained in:
Marko (Hermes Implementer)
2026-05-26 00:50:06 +00:00
commit 3b5b301e42
94 changed files with 6086 additions and 0 deletions
+429
View File
@@ -0,0 +1,429 @@
/* ---------------------------------------------------------------------------
Cloud Reader Global Styles
Minimal, clean design system for the bookmark & notes management UI.
--------------------------------------------------------------------------- */
/* Reset & base */
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--color-bg: #f8f9fa;
--color-surface: #ffffff;
--color-primary: #4f46e5;
--color-primary-hover: #4338ca;
--color-danger: #ef4444;
--color-danger-hover: #dc2626;
--color-secondary: #6b7280;
--color-secondary-hover: #4b5563;
--color-text: #1f2937;
--color-text-muted: #6b7280;
--color-border: #e5e7eb;
--color-quote-bg: #f3f4f6;
--radius: 8px;
--radius-sm: 4px;
--shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, sans-serif;
}
html {
font-size: 16px;
-webkit-font-smoothing: antialiased;
}
body {
font-family: var(--font);
background: var(--color-bg);
color: var(--color-text);
line-height: 1.6;
}
/* App container */
.app-container {
max-width: 960px;
margin: 0 auto;
padding: 0 1rem;
}
/* Header */
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 0;
border-bottom: 1px solid var(--color-border);
margin-bottom: 1.5rem;
}
.app-title {
font-size: 1.5rem;
font-weight: 700;
}
.app-nav {
display: flex;
gap: 1rem;
}
.nav-link {
color: var(--color-primary);
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
}
.nav-link:hover {
text-decoration: underline;
}
/* Main content */
.app-main {
min-height: 70vh;
padding-bottom: 3rem;
}
.page {
padding: 1rem 0;
}
.page h2 {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 1rem;
}
/* Quick links */
.quick-links {
display: grid;
gap: 1rem;
margin-top: 1.5rem;
}
.card-link {
display: block;
padding: 1.25rem;
background: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: var(--radius);
text-decoration: none;
color: inherit;
box-shadow: var(--shadow);
transition: box-shadow 0.2s;
}
.card-link:hover {
box-shadow: var(--shadow-lg);
}
.card-link h3 {
font-size: 1rem;
margin-bottom: 0.25rem;
}
.card-link p {
font-size: 0.875rem;
color: var(--color-text-muted);
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.5rem 1rem;
font-size: 0.875rem;
font-weight: 500;
border: 1px solid var(--color-primary);
border-radius: var(--radius-sm);
background: var(--color-primary);
color: #fff;
cursor: pointer;
transition: background 0.15s;
}
.btn:hover {
background: var(--color-primary-hover);
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-sm {
padding: 0.25rem 0.625rem;
font-size: 0.8125rem;
}
.btn-secondary {
background: var(--color-surface);
color: var(--color-secondary);
border-color: var(--color-border);
}
.btn-secondary:hover {
background: var(--color-bg);
color: var(--color-secondary-hover);
}
.btn-danger {
background: var(--color-danger);
border-color: var(--color-danger);
}
.btn-danger:hover {
background: var(--color-danger-hover);
border-color: var(--color-danger-hover);
}
.btn-block {
width: 100%;
display: block;
}
/* Annotation list */
.annotations-list {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.annotation-card {
background: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: var(--radius);
padding: 1rem;
box-shadow: var(--shadow);
}
.annotation-card-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.5rem;
flex-wrap: wrap;
}
.annotation-kind-badge {
display: inline-block;
padding: 0.125rem 0.5rem;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.bookmark-badge {
background: #dbeafe;
color: #1d4ed8;
}
.note-badge {
background: #fef3c7;
color: #b45309;
}
.annotation-book-title {
font-weight: 600;
font-size: 0.875rem;
}
.annotation-page {
font-size: 0.8125rem;
color: var(--color-text-muted);
}
.annotation-date {
font-size: 0.75rem;
color: var(--color-text-muted);
margin-left: auto;
}
.annotation-quote {
margin: 0.5rem 0;
padding: 0.5rem 0.75rem;
background: var(--color-quote-bg);
border-left: 3px solid var(--color-primary);
border-radius: var(--radius-sm);
font-style: italic;
font-size: 0.875rem;
color: var(--color-text-muted);
}
.note-content-text {
font-size: 0.9375rem;
line-height: 1.6;
margin: 0.5rem 0;
white-space: pre-wrap;
}
.annotation-actions {
display: flex;
gap: 0.5rem;
margin-top: 0.75rem;
flex-wrap: wrap;
}
/* Loading & empty states */
.annotations-loading,
.annotations-empty {
padding: 2rem;
text-align: center;
color: var(--color-text-muted);
font-size: 0.9375rem;
}
/* Dashboard summary */
.annotations-summary {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 1rem;
font-size: 0.875rem;
color: var(--color-text-muted);
}
.summary-separator {
color: var(--color-border);
}
/* Add annotation modal */
.add-annotation-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
.add-annotation-modal {
background: var(--color-surface);
border-radius: var(--radius);
padding: 1.5rem;
width: 90%;
max-width: 480px;
box-shadow: var(--shadow-lg);
position: relative;
}
.modal-close {
position: absolute;
top: 0.75rem;
right: 0.75rem;
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: var(--color-text-muted);
line-height: 1;
}
.modal-close:hover {
color: var(--color-text);
}
.add-annotation-modal h3 {
font-size: 1.125rem;
margin-bottom: 0.75rem;
}
/* Annotation form */
.mode-selector {
display: flex;
gap: 0.75rem;
margin-top: 1rem;
}
.annotation-form {
margin-top: 1rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
font-size: 0.875rem;
font-weight: 500;
margin-bottom: 0.375rem;
}
.form-textarea {
width: 100%;
padding: 0.625rem;
border: 1px solid var(--color-border);
border-radius: var(--radius-sm);
font-family: var(--font);
font-size: 0.875rem;
resize: vertical;
}
.form-textarea:focus {
outline: 2px solid var(--color-primary);
outline-offset: -1px;
}
.form-error {
color: var(--color-danger);
font-size: 0.8125rem;
margin-bottom: 0.75rem;
}
.form-actions {
display: flex;
gap: 0.5rem;
}
/* Note edit inline */
.note-edit-form {
margin: 0.5rem 0;
}
.note-edit-textarea {
width: 100%;
padding: 0.5rem;
border: 1px solid var(--color-primary);
border-radius: var(--radius-sm);
font-family: var(--font);
font-size: 0.875rem;
resize: vertical;
}
.note-edit-textarea:focus {
outline: none;
box-shadow: 0 0 0 2px var(--color-primary);
}
.note-edit-actions {
display: flex;
gap: 0.5rem;
margin-top: 0.5rem;
}
/* Responsive */
@media (max-width: 640px) {
.app-header {
flex-direction: column;
gap: 0.5rem;
align-items: flex-start;
}
.annotation-card-header {
flex-wrap: wrap;
}
.annotation-date {
margin-left: 0;
}
}