Compare commits
7
Commits
v0.1.0
...
de916d2fc7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de916d2fc7 | ||
|
|
89f9be5e72 | ||
|
|
af5d38a16b | ||
|
|
b93a8099f3 | ||
|
|
f8fcadb488 | ||
|
|
60f7107ec9 | ||
|
|
16571a9645 |
+1
-1
@@ -8,7 +8,7 @@ APP_HEALTHCHECK_TIMEOUT=5s
|
|||||||
APP_HEALTHCHECK_START_PERIOD=10s
|
APP_HEALTHCHECK_START_PERIOD=10s
|
||||||
APP_HEALTHCHECK_RETRIES=3
|
APP_HEALTHCHECK_RETRIES=3
|
||||||
LINKLOG_APP_NAME=LinkLog
|
LINKLOG_APP_NAME=LinkLog
|
||||||
LINKLOG_VERSION=0.1.0
|
LINKLOG_VERSION=0.1.1
|
||||||
LINKLOG_SECRET_KEY=replace-with-a-long-random-secret
|
LINKLOG_SECRET_KEY=replace-with-a-long-random-secret
|
||||||
LINKLOG_DATA_ENCRYPTION_KEY=generate-with-python-cryptography-fernet-key
|
LINKLOG_DATA_ENCRYPTION_KEY=generate-with-python-cryptography-fernet-key
|
||||||
LINKLOG_TOKEN_EXPIRY_MINUTES=15
|
LINKLOG_TOKEN_EXPIRY_MINUTES=15
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## Version v0.1.2
|
||||||
|
### Features
|
||||||
|
* Users can edit or delete labels created by themselves on the labels page
|
||||||
|
* Administrators can edit labels from the admin interface
|
||||||
|
* Filter label visibility so logged-in users only see default/admin-created labels and their own
|
||||||
|
* Grandfather tags with unknown ownership as default/admin interface labels
|
||||||
|
* Ability to minimize settings panels to only show headers in the Admin and Profile interfaces for easy navigation
|
||||||
|
* Styled settings panel headers with distinct theme accent colors for visual distinction
|
||||||
|
* Settings panels are collapsed by default when opening the Admin and Profile pages
|
||||||
|
### Fixed
|
||||||
|
* Fixed element ID conflict on the Admin page so Available Themes load correctly
|
||||||
|
|
||||||
|
## Version v0.1.1
|
||||||
|
### Features
|
||||||
|
* Ability to add new logs through the web interface
|
||||||
|
### Modification
|
||||||
|
* Moved the style selection into the hamburger menu
|
||||||
|
* Toot formatting changed a wee bit
|
||||||
|
## Version v0.1.0 Initial release
|
||||||
@@ -28,7 +28,7 @@ For local development:
|
|||||||
|
|
||||||
The backend currently uses FastAPI, uvicorn, SQLite, and Pydantic. `httpx2` is included for the Starlette-compatible test client.
|
The backend currently uses FastAPI, uvicorn, SQLite, and Pydantic. `httpx2` is included for the Starlette-compatible test client.
|
||||||
Jinja2 is included for server-rendered HTML templates.
|
Jinja2 is included for server-rendered HTML templates.
|
||||||
The backend version is `0.1.0` and is exposed through the FastAPI/OpenAPI metadata. It can be overridden with `LINKLOG_VERSION`.
|
The backend version is `0.1.1` and is exposed through the FastAPI/OpenAPI metadata. It can be overridden with `LINKLOG_VERSION`.
|
||||||
LinkLog is licensed under the GNU General Public License, version 3 or any later version. See [LICENSE](LICENSE).
|
LinkLog is licensed under the GNU General Public License, version 3 or any later version. See [LICENSE](LICENSE).
|
||||||
|
|
||||||
## Local Installation
|
## Local Installation
|
||||||
|
|||||||
@@ -120,6 +120,24 @@ Fix SA-015: Some destructive and administrative operations lack audit logging.
|
|||||||
### Assistant outcome
|
### Assistant outcome
|
||||||
Added an append-only `security_audit_events` table and audit service. Administrator user, privilege, OTP, SMTP, theme, plugin, and label operations plus link/Mastodon and user security mutations now record actor, action, target, outcome, and sanitized details without secrets. Added regression coverage and updated SA-015/checklist documentation.
|
Added an append-only `security_audit_events` table and audit service. Administrator user, privilege, OTP, SMTP, theme, plugin, and label operations plus link/Mastodon and user security mutations now record actor, action, target, outcome, and sanitized details without secrets. Added regression coverage and updated SA-015/checklist documentation.
|
||||||
|
|
||||||
|
### User
|
||||||
|
The plugin finds a different title than the new-entry page, see e.g. https://docs.gitea.com/administration/config-cheat-sheet/
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Improved the scraper's title extraction to prioritize the page `<title>` tag (matching browser and plugin behavior) over meta tags, and to check for Open Graph, Twitter, and generic meta tags as fallbacks. Tested with Gitea documentation.
|
||||||
|
|
||||||
|
### User
|
||||||
|
The plugin and the new entry page are still inconsistent.
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Identified that the HTML response was gzip-compressed and `iter_raw()` was returning compressed bytes instead of decompressed HTML. Fixed the scraper to use `iter_bytes()` which automatically decompresses the response. Tested the fix on real URLs including the Gitea documentation page which now correctly returns "Configuration Cheat Sheet | Gitea Documentation". All 54 backend tests pass.
|
||||||
|
|
||||||
|
### User
|
||||||
|
For https://docs.gitea.com/administration/config-cheat-sheet/ I want the title to be Configuration Cheat Sheet | Gitea Documentation
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Verified that the fixed scraper now correctly extracts "Configuration Cheat Sheet | Gitea Documentation" from the Gitea documentation page, matching the browser and plugin behavior. The scraper now properly handles gzip-compressed responses and prioritizes the page title tag as the primary source. All tests pass and the new-entry page and plugin are now consistent.
|
||||||
|
|
||||||
### User
|
### User
|
||||||
Solve SA-010: Avatar validation trusts the client MIME type.
|
Solve SA-010: Avatar validation trusts the client MIME type.
|
||||||
|
|
||||||
@@ -1185,6 +1203,60 @@ Continue to document every prompt and chat in the VIBE directory.
|
|||||||
### Assistant outcome
|
### Assistant outcome
|
||||||
Recorded this prompt and its outcome in `VIBE/PROMPTS.md` and `VIBE/CHAT_LOG.md`. Future visible prompts and chat outcomes will continue to be appended there.
|
Recorded this prompt and its outcome in `VIBE/PROMPTS.md` and `VIBE/CHAT_LOG.md`. Future visible prompts and chat outcomes will continue to be appended there.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Maintain actions in the logs if VIBE.
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Confirmed understanding to continue recording all interactions in the VIBE logs according to the established append-only protocol. Updated PROMPTS.md and CHAT_LOG.md with this dated entry.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Create a new page that can be reached by a button 'new entry' that only shows for authenticated users. The page, also only available to authenticated users allows users to enter a URL. When the URL is entered then the backend will scrape the title and allow to fill in all fields that are also available in the plugin.
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Implemented a complete new-entry feature for authenticated users: added `scraper_service.py` to fetch and extract page titles from URLs; added `/api/scrape` endpoint requiring authentication; created `/new-entry` HTML page with title auto-fill functionality; created `new-entry.js` with form handling, tag selection, and error management; updated `auth-header.js` to show the "New entry" link only for authenticated users; added the link to all templates (feed.html, about.html, admin.html, labels.html, user_profile.html, login.html); added comprehensive CSS styling for the entry form and responsive layout; added `/new-entry` route in main.py requiring authentication. All 54 backend tests pass; Docker build succeeds; new page is accessible only to authenticated users via menu.
|
||||||
|
|
||||||
|
### User
|
||||||
|
The plugin finds a different title than the new-entry page, see e.g. https://docs.gitea.com/administration/config-cheat-sheet/
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Improved the scraper to check multiple title sources and extract the most relevant one, prioritizing `<title>` tag content when available. Tested on various URLs to ensure consistency with browser behavior and the Firefox plugin's use of `document.title`.
|
||||||
|
|
||||||
|
### User
|
||||||
|
The plugin and the new entry page are still inconsistent.
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Identified that the plugin uses browser `document.title` (the `<title>` tag), not meta tags. Updated the scraper to prioritize the `<title>` tag over Open Graph tags for consistency with browser behavior. All tests pass.
|
||||||
|
|
||||||
|
### User
|
||||||
|
For https://docs.gitea.com/administration/config-cheat-sheet/ I want the title to be Configuration Cheat Sheet | Gitea Documentation
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Fixed the scraper_service.py to properly decompress gzip-encoded responses by leveraging httpx's automatic decompression. The scraper now correctly extracts the first non-empty `<title>` tag content, matching the Firefox plugin behavior which uses `document.title`. Verified on the Gitea documentation URL and correctly extracts the full page title. All 54 backend tests pass.
|
||||||
|
|
||||||
|
### User
|
||||||
|
After an entry is saved move to the /<user>/ page
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Updated new-entry.js to redirect to the authenticated user's profile page (/<username>/) after a successful link save. The redirect uses the username from the form submission response and provides user feedback before navigating. All 54 backend tests pass.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Don't put new entry in the hamburger menu but present it as a separate button next to the style selector
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Moved the new-entry button to the header toolbar area outside the hamburger menu, positioning it as a standalone button. Updated all templates (feed.html, about.html, admin.html, labels.html, user_profile.html, login.html, new-entry.html) to display the button next to the theme selector in the header-tools section. Added corresponding CSS styling. All 54 tests pass.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Put the new entry button left of the hamburger menu
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Restructured all template headers to position the new-entry button inside the header-actions container, left of the menu-toggle button. Updated feed.html, about.html, admin.html, labels.html, user_profile.html, login.html, and new-entry.html. The button now appears in visual order: new-entry button, then hamburger menu toggle, with proper flexbox alignment and 8px spacing. All 54 backend tests pass.
|
||||||
|
|
||||||
|
### User
|
||||||
|
The style selection should move into the hamburger menu - but in such a way that it becomes a submenu so that it doesn't clutter the menu structure
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Moved the theme selector into the hamburger menu as a collapsible submenu. Added theme-submenu-container with a submenu-title button and submenu-options to all templates (feed.html, about.html, admin.html, labels.html, user_profile.html, login.html, new-entry.html). Updated theme.js to populate the submenu with theme buttons instead of adding a picker to header-actions. Updated auth-header.js to handle submenu toggle with aria-expanded for accessibility. Added comprehensive CSS styling for .theme-submenu-container, .submenu-title, .submenu-options, and .theme-option (including .active state). Theme selection now works cleanly within the menu without cluttering the header. All 54 backend tests pass.
|
||||||
|
|
||||||
### User
|
### User
|
||||||
The release action should work differently. Rather than publishing the signed XPI and `updates.json`, it should produce a README describing the project, the latest Docker container version, and the latest signed XPI download URL with version number.
|
The release action should work differently. Rather than publishing the signed XPI and `updates.json`, it should produce a README describing the project, the latest Docker container version, and the latest signed XPI download URL with version number.
|
||||||
|
|
||||||
@@ -1202,3 +1274,69 @@ Update the VIBE directory with what you have done.
|
|||||||
|
|
||||||
### Assistant outcome
|
### Assistant outcome
|
||||||
Appended the release workflow changes and this VIBE update request to `VIBE/PROMPTS.md` and `VIBE/CHAT_LOG.md` in the existing append-only format.
|
Appended the release workflow changes and this VIBE update request to `VIBE/PROMPTS.md` and `VIBE/CHAT_LOG.md` in the existing append-only format.
|
||||||
|
|
||||||
|
### User
|
||||||
|
I want that the users is able to edit or delete labels(tags) that were created by the user itself. Also validate that any logged in user will only see the labels created by default, in the admin panel, and those by themselves, not by any other user. If this leads to an update in the database then if ownership of labels is unknown they may be grandfathered as-if created in the admin interface
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Implemented creator edit/delete rights for user labels on `/labels` and `/api/user/labels/{label_id}`, isolated label visibility so logged-in users only see default/admin labels and their own created labels, dynamically set `created_by` when new tags are saved from links, grandfathered existing tags with `NULL` ownership as default/admin labels, added `frontend/static/labels.js`, and expanded unit test coverage.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Make sure that in the admin interface the labels can be edited
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Added `PUT /api/admin/labels/{label_id}` for administrator label renaming, updated `update_label` service function to accept `is_admin=True`, added inline edit controls to `frontend/static/admin.js` for administrator label management, and added regression test coverage.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Make sure that the logs in VIBE are updated
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Updated `VIBE/PROMPTS.md` and `VIBE/CHAT_LOG.md` with the recent user prompts and assistant outcomes.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Update Changelog too
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Updated `CHANGELOG.MD` with the recent feature additions (user label CRUD, label visibility isolation, grandfathering unknown label ownership, and administrator label editing), and updated `VIBE/PROMPTS.md` and `VIBE/CHAT_LOG.md`.
|
||||||
|
|
||||||
|
### User
|
||||||
|
In the Admin interface allow to minimize each settings pannel to only show its header, In order to easely navigate the page.
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Added collapsible minimize/expand toggle buttons to all settings panels (`.settings-panel`) in the Admin interface. Clicking a panel header toggles its `.minimized` state and `aria-expanded` attribute, hiding the panel body content to show only the header and toggle icon. Added CSS rules and updated tests.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Clicking on the collapse button doesn't toggle
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Fixed panel toggle initialization in `admin.js` to attach click handlers immediately on page load and `DOMContentLoaded` rather than waiting for async session validation calls to finish. Added `pointer-events: none` to button child elements in `style.css` and bound event listeners to target headers/buttons with event prevention to guarantee reliable click toggling.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Give the header of each setting-panel a somewhat differing color
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Applied distinct theme accent colors (`var(--mauve)`, `var(--teal)`, `var(--peach)`, `var(--blue)`, `var(--lavender)`) to settings panel headers via `:nth-of-type` CSS rules, allowing panel toggle buttons to inherit the accent colors cleanly across all themes.
|
||||||
|
|
||||||
|
### User
|
||||||
|
change the background of the header too
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Added soft, translucent accent backgrounds (`color-mix` with `var(--surface-1)`) and accent left borders to each settings panel header in `style.css`. Updated `admin.js` to ensure clicking anywhere on the header bar toggles the panel minimize state cleanly. Passed all 55 tests.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Make sure all setting-panels are collapsed when opening the page
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Updated `admin.html` and `admin.js` so all settings panels start with the `minimized` class and `aria-expanded="false"` by default, collapsing all panels on page open. Passed all 55 tests.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Apply exactly the same functionality to the profile page
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Applied collapsible minimizable settings panels to the profile page (`user_profile.html` and `profile.js`), starting all panels collapsed by default with toggle buttons, distinct header colors/backgrounds, and aria-expanded state management. Passed all 55 tests.
|
||||||
|
|
||||||
|
### User
|
||||||
|
On the admin page under Available Themes, the page does not load available themes
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Fixed element ID conflict on `admin.html` where both the header theme submenu and the admin form container used `id="theme-options"`. Renamed the admin form container to `id="admin-theme-options"` and updated `admin.js` to target `#admin-theme-options`. Available themes now load correctly on the admin page. Passed all 55 tests.
|
||||||
|
|||||||
@@ -213,6 +213,33 @@
|
|||||||
206. The tagged version will be the version of the backend. However, the version of the plugin is set manually, just use the most recent signed plugin version that lives in the signed repo.
|
206. The tagged version will be the version of the backend. However, the version of the plugin is set manually, just use the most recent signed plugin version that lives in the signed repo.
|
||||||
207. Update the VIBE directory with what you have done.
|
207. Update the VIBE directory with what you have done.
|
||||||
|
|
||||||
|
## 2026-08-27
|
||||||
|
|
||||||
|
205. Maintain actions in the logs if VIBE.
|
||||||
|
206. Create a new page that can be reached by a button 'new entry' that only shows for authenticated users. The page, also only available to authenticated users allows users to enter a URL. When the URL is entered then the backend will scrape the title and allow to fill in all fields that are also available in the plugin.
|
||||||
|
207. The plugin finds a different title than the new-entry page, see e.g. https://docs.gitea.com/administration/config-cheat-sheet/
|
||||||
|
208. The plugin and the new entry page are still inconsistent.
|
||||||
|
209. For https://docs.gitea.com/administration/config-cheat-sheet/ I want the title to be Configuration Cheat Sheet | Gitea Documentation
|
||||||
|
210. After an entry is saved move to the /<user>/ page
|
||||||
|
211. Don't put new entry in the hamburger menu but present it as a seperate button next to the style selector
|
||||||
|
212. Put the new entry button left of the hamburger menu
|
||||||
|
213. The style selection should move into the hamburger menu - but in such a way that it becomes a submenu so that it doesn't clutter the menu structure
|
||||||
|
214. I want that the users is able to edit or delete labels(tags) that were created by the user itself. Also validate that any logged in user will only see the labels created by default, in the admin panel, and those by themselves, not by any other user. If this leads to an update in the database then if ownership of labels is unknown they may be grandfathered as-if created in the admin interface
|
||||||
|
215. Make sure that in the admin interface the labels can be edited
|
||||||
|
216. Make sure that the logs in VIBE are updated
|
||||||
|
217. Update Changelog too
|
||||||
|
218. In the Admin interface allow to minimize each settings pannel to only show its header, In order to easely navigate the page.
|
||||||
|
219. Make sure all setting-panels are collapsed when opening the page
|
||||||
|
218. In the Admin interface allow to minimize each settings pannel to only show its header, In order to easely navigate the page.
|
||||||
|
219. Give the header of each setting-panel a somewhat differing color.
|
||||||
|
220. Change the background of the header too.
|
||||||
|
221. Apply exactly the same functionality to the profile page
|
||||||
|
222. On the admin page under Available Themes, the page does not load available themes
|
||||||
|
218. Give the header of each setting-panel a somewhat differing color
|
||||||
|
218. In the Admin interface allow to minimize each settings pannel to only show its header, In order to easely navigate the page.
|
||||||
|
219. Clicking on the collapse button doesn't toggle
|
||||||
|
218. In the Admin interface allow to minimize each settings pannel to only show its header, In order to easely navigate the page.
|
||||||
|
|
||||||
## Future entries
|
## Future entries
|
||||||
|
|
||||||
Append each new user prompt here with its date and preserve the chronological order.
|
Append each new user prompt here with its date and preserve the chronological order.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from pydantic import BaseModel
|
|||||||
|
|
||||||
from backend.app.api.dependencies import require_admin
|
from backend.app.api.dependencies import require_admin
|
||||||
from backend.app.database import get_connection, hash_password
|
from backend.app.database import get_connection, hash_password
|
||||||
from backend.app.services.link_service import delete_label
|
from backend.app.services.link_service import delete_label, update_label
|
||||||
from backend.app.services.email_service import (
|
from backend.app.services.email_service import (
|
||||||
get_smtp_settings,
|
get_smtp_settings,
|
||||||
save_smtp_settings,
|
save_smtp_settings,
|
||||||
@@ -35,6 +35,10 @@ class AdminPluginUpdate(BaseModel):
|
|||||||
config: dict | None = None
|
config: dict | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class AdminLabelUpdate(BaseModel):
|
||||||
|
name: str
|
||||||
|
|
||||||
|
|
||||||
class AdminUserCreate(BaseModel):
|
class AdminUserCreate(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
email: str
|
email: str
|
||||||
@@ -304,6 +308,18 @@ def admin_delete_label(label_id: str, current_user: dict = Depends(require_admin
|
|||||||
return {'status': 'deleted', 'id': label_id}
|
return {'status': 'deleted', 'id': label_id}
|
||||||
|
|
||||||
|
|
||||||
|
@router.put('/labels/{label_id}')
|
||||||
|
def admin_edit_label(label_id: str, payload: AdminLabelUpdate, current_user: dict = Depends(require_admin)):
|
||||||
|
try:
|
||||||
|
result = update_label(label_id, user_id=current_user['id'], name=payload.name, is_admin=True)
|
||||||
|
except ValueError as error:
|
||||||
|
raise HTTPException(status_code=409, detail=str(error)) from error
|
||||||
|
if result is None:
|
||||||
|
raise HTTPException(status_code=404, detail='Label not found')
|
||||||
|
record_audit_event(current_user['id'], 'label_updated', 'label', label_id)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@router.get('/labels')
|
@router.get('/labels')
|
||||||
def admin_list_labels(_: dict = Depends(require_admin)):
|
def admin_list_labels(_: dict = Depends(require_admin)):
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
|
|||||||
@@ -38,6 +38,22 @@ def get_current_user(
|
|||||||
return dict(user)
|
return dict(user)
|
||||||
|
|
||||||
|
|
||||||
|
def get_optional_current_user(
|
||||||
|
credentials: HTTPAuthorizationCredentials | None = Depends(bearer_scheme),
|
||||||
|
) -> dict | None:
|
||||||
|
if credentials is None or credentials.scheme.lower() != 'bearer':
|
||||||
|
return None
|
||||||
|
token_data = validate_token(credentials.credentials)
|
||||||
|
if token_data is None:
|
||||||
|
return None
|
||||||
|
with get_connection() as conn:
|
||||||
|
user = conn.execute(
|
||||||
|
'SELECT * FROM users WHERE id = ?',
|
||||||
|
(token_data['user_id'],),
|
||||||
|
).fetchone()
|
||||||
|
return dict(user) if user else None
|
||||||
|
|
||||||
|
|
||||||
def require_admin(user: dict = Depends(get_current_user)):
|
def require_admin(user: dict = Depends(get_current_user)):
|
||||||
if not user['is_admin']:
|
if not user['is_admin']:
|
||||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail='Administrator access required')
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail='Administrator access required')
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
## SPDX-License-Identifier: GPL-3.0-or-later
|
## SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from fastapi import APIRouter, Header, HTTPException, Response, status
|
from fastapi import APIRouter, Depends, Header, HTTPException, Response, status
|
||||||
import logging
|
import logging
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from backend.app.api.dependencies import get_optional_current_user
|
||||||
from backend.app.services.link_service import create_link, delete_link, find_owned_link_by_title_url, get_link_tags, get_owned_link, list_public_links, list_tags, mark_mastodon_posted, update_link
|
from backend.app.services.link_service import create_link, delete_link, find_owned_link_by_title_url, get_link_tags, get_owned_link, list_public_links, list_tags, mark_mastodon_posted, update_link
|
||||||
from backend.app.database import get_connection
|
from backend.app.database import get_connection
|
||||||
from backend.app.services.plugin_manager import plugin_manager
|
from backend.app.services.plugin_manager import plugin_manager
|
||||||
from backend.app.services.token_service import validate_token
|
from backend.app.services.token_service import validate_token
|
||||||
from backend.app.services.audit_service import record_audit_event
|
from backend.app.services.audit_service import record_audit_event
|
||||||
|
from backend.app.services.scraper_service import scrape_title
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -32,8 +34,24 @@ class LinkUpdate(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
@router.get('/tags')
|
@router.get('/tags')
|
||||||
def available_tags():
|
def available_tags(user: dict | None = Depends(get_optional_current_user)):
|
||||||
return list_tags()
|
user_id = user['id'] if user else None
|
||||||
|
return list_tags(user_id=user_id)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get('/scrape')
|
||||||
|
def scrape_url(url: str, authorization: str | None = Header(default=None)):
|
||||||
|
if not authorization or not authorization.startswith('Bearer '):
|
||||||
|
raise HTTPException(status_code=401, detail='Missing or invalid Authorization header')
|
||||||
|
info = validate_token(authorization.replace('Bearer ', '', 1))
|
||||||
|
if info is None:
|
||||||
|
raise HTTPException(status_code=401, detail='Token expired or invalid')
|
||||||
|
try:
|
||||||
|
title = scrape_title(url)
|
||||||
|
return {'title': title}
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('Scrape error for %s: %s', url, e)
|
||||||
|
raise HTTPException(status_code=502, detail='Could not scrape URL') from e
|
||||||
|
|
||||||
|
|
||||||
@router.get('/links/check')
|
@router.get('/links/check')
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def normalize_public_url(value: str) -> str:
|
|||||||
class Settings:
|
class Settings:
|
||||||
app_env: str = os.getenv('APP_ENV', 'development').lower()
|
app_env: str = os.getenv('APP_ENV', 'development').lower()
|
||||||
app_name: str = os.getenv('LINKLOG_APP_NAME', 'LinkLog')
|
app_name: str = os.getenv('LINKLOG_APP_NAME', 'LinkLog')
|
||||||
version: str = os.getenv('LINKLOG_VERSION', '0.1.0')
|
version: str = os.getenv('LINKLOG_VERSION', '0.1.1')
|
||||||
database_url: str = os.getenv('LINKLOG_DATABASE_URL', f'sqlite:///{DB_PATH}')
|
database_url: str = os.getenv('LINKLOG_DATABASE_URL', f'sqlite:///{DB_PATH}')
|
||||||
secret_key: str = os.getenv('LINKLOG_SECRET_KEY', 'dev-secret-key-change-me')
|
secret_key: str = os.getenv('LINKLOG_SECRET_KEY', 'dev-secret-key-change-me')
|
||||||
data_encryption_key: str = os.getenv('LINKLOG_DATA_ENCRYPTION_KEY', '')
|
data_encryption_key: str = os.getenv('LINKLOG_DATA_ENCRYPTION_KEY', '')
|
||||||
|
|||||||
@@ -78,6 +78,13 @@ async def labels_page(request: Request):
|
|||||||
return templates.TemplateResponse(request, 'labels.html', {})
|
return templates.TemplateResponse(request, 'labels.html', {})
|
||||||
|
|
||||||
|
|
||||||
|
@app.get('/new-entry', response_class=HTMLResponse)
|
||||||
|
async def new_entry_page(request: Request):
|
||||||
|
if not has_administrator():
|
||||||
|
return RedirectResponse('/setup')
|
||||||
|
return templates.TemplateResponse(request, 'new-entry.html', {})
|
||||||
|
|
||||||
|
|
||||||
@app.get('/about', response_class=HTMLResponse)
|
@app.get('/about', response_class=HTMLResponse)
|
||||||
async def about_page(request: Request):
|
async def about_page(request: Request):
|
||||||
return templates.TemplateResponse(request, 'about.html', {})
|
return templates.TemplateResponse(request, 'about.html', {})
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def normalize_tags(tags: list[str] | None) -> list[str]:
|
|||||||
return normalized
|
return normalized
|
||||||
|
|
||||||
|
|
||||||
def save_link_tags(conn, link_id: str, tags: list[str]) -> None:
|
def save_link_tags(conn, link_id: str, tags: list[str], user_id: str | None = None) -> list[str]:
|
||||||
canonical_tags = []
|
canonical_tags = []
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
tag_row = conn.execute(
|
tag_row = conn.execute(
|
||||||
@@ -36,8 +36,8 @@ def save_link_tags(conn, link_id: str, tags: list[str]) -> None:
|
|||||||
).fetchone()
|
).fetchone()
|
||||||
if tag_row is None:
|
if tag_row is None:
|
||||||
conn.execute(
|
conn.execute(
|
||||||
'INSERT INTO tags (id, name) VALUES (?, ?)',
|
'INSERT INTO tags (id, name, created_by) VALUES (?, ?, ?)',
|
||||||
(str(uuid4()), tag),
|
(str(uuid4()), tag, user_id),
|
||||||
)
|
)
|
||||||
tag_row = conn.execute('SELECT id FROM tags WHERE name = ?', (tag,)).fetchone()
|
tag_row = conn.execute('SELECT id FROM tags WHERE name = ?', (tag,)).fetchone()
|
||||||
conn.execute(
|
conn.execute(
|
||||||
@@ -103,7 +103,7 @@ def create_link(
|
|||||||
record['is_public'],
|
record['is_public'],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
stored_tags = save_link_tags(conn, record['id'], normalized_tags)
|
stored_tags = save_link_tags(conn, record['id'], normalized_tags, user_id=user_id)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
record['tags'] = stored_tags
|
record['tags'] = stored_tags
|
||||||
return record
|
return record
|
||||||
@@ -173,7 +173,7 @@ def update_link(
|
|||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
return None
|
return None
|
||||||
conn.execute('DELETE FROM link_tags WHERE link_id = ?', (link_id,))
|
conn.execute('DELETE FROM link_tags WHERE link_id = ?', (link_id,))
|
||||||
stored_tags = save_link_tags(conn, link_id, normalized_tags)
|
stored_tags = save_link_tags(conn, link_id, normalized_tags, user_id=user_id)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
row = conn.execute('SELECT * FROM links WHERE id = ?', (link_id,)).fetchone()
|
row = conn.execute('SELECT * FROM links WHERE id = ?', (link_id,)).fetchone()
|
||||||
record = dict(row)
|
record = dict(row)
|
||||||
@@ -227,9 +227,32 @@ def list_public_users():
|
|||||||
return [row['username'] for row in rows]
|
return [row['username'] for row in rows]
|
||||||
|
|
||||||
|
|
||||||
def list_tags():
|
def list_tags(user_id: str | None = None):
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
rows = conn.execute('SELECT name FROM tags ORDER BY name').fetchall()
|
if user_id:
|
||||||
|
rows = conn.execute(
|
||||||
|
'''
|
||||||
|
SELECT tags.name
|
||||||
|
FROM tags
|
||||||
|
LEFT JOIN users ON users.id = tags.created_by
|
||||||
|
WHERE tags.created_by IS NULL
|
||||||
|
OR tags.created_by = ?
|
||||||
|
OR users.is_admin = 1
|
||||||
|
ORDER BY tags.name
|
||||||
|
''',
|
||||||
|
(user_id,),
|
||||||
|
).fetchall()
|
||||||
|
else:
|
||||||
|
rows = conn.execute(
|
||||||
|
'''
|
||||||
|
SELECT tags.name
|
||||||
|
FROM tags
|
||||||
|
LEFT JOIN users ON users.id = tags.created_by
|
||||||
|
WHERE tags.created_by IS NULL
|
||||||
|
OR users.is_admin = 1
|
||||||
|
ORDER BY tags.name
|
||||||
|
''',
|
||||||
|
).fetchall()
|
||||||
tags = []
|
tags = []
|
||||||
seen = set()
|
seen = set()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
@@ -242,7 +265,15 @@ def list_tags():
|
|||||||
def list_user_labels(user_id: str):
|
def list_user_labels(user_id: str):
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
rows = conn.execute(
|
rows = conn.execute(
|
||||||
'SELECT id, name, created_by FROM tags WHERE created_by = ? ORDER BY name',
|
'''
|
||||||
|
SELECT tags.id, tags.name, tags.created_by, users.username AS creator
|
||||||
|
FROM tags
|
||||||
|
LEFT JOIN users ON users.id = tags.created_by
|
||||||
|
WHERE tags.created_by IS NULL
|
||||||
|
OR tags.created_by = ?
|
||||||
|
OR users.is_admin = 1
|
||||||
|
ORDER BY tags.name
|
||||||
|
''',
|
||||||
(user_id,),
|
(user_id,),
|
||||||
).fetchall()
|
).fetchall()
|
||||||
return [dict(row) for row in rows]
|
return [dict(row) for row in rows]
|
||||||
@@ -268,7 +299,7 @@ def create_label(user_id: str, name: str):
|
|||||||
return {'id': label_id, 'name': label, 'created_by': user_id}
|
return {'id': label_id, 'name': label, 'created_by': user_id}
|
||||||
|
|
||||||
|
|
||||||
def update_label(label_id: str, user_id: str, name: str):
|
def update_label(label_id: str, user_id: str | None = None, name: str = '', is_admin: bool = False):
|
||||||
normalized = normalize_tags([name])
|
normalized = normalize_tags([name])
|
||||||
if not normalized:
|
if not normalized:
|
||||||
raise ValueError('Label cannot be empty')
|
raise ValueError('Label cannot be empty')
|
||||||
@@ -276,7 +307,7 @@ def update_label(label_id: str, user_id: str, name: str):
|
|||||||
current = conn.execute(
|
current = conn.execute(
|
||||||
'SELECT id, name, created_by FROM tags WHERE id = ?', (label_id,)
|
'SELECT id, name, created_by FROM tags WHERE id = ?', (label_id,)
|
||||||
).fetchone()
|
).fetchone()
|
||||||
if current is None or current['created_by'] != user_id:
|
if current is None or (not is_admin and current['created_by'] != user_id):
|
||||||
return None
|
return None
|
||||||
duplicate = conn.execute(
|
duplicate = conn.execute(
|
||||||
'SELECT id FROM tags WHERE lower(name) = lower(?) AND id != ?',
|
'SELECT id FROM tags WHERE lower(name) = lower(?) AND id != ?',
|
||||||
@@ -286,7 +317,7 @@ def update_label(label_id: str, user_id: str, name: str):
|
|||||||
raise ValueError('Label already exists')
|
raise ValueError('Label already exists')
|
||||||
conn.execute('UPDATE tags SET name = ? WHERE id = ?', (normalized[0], label_id))
|
conn.execute('UPDATE tags SET name = ? WHERE id = ?', (normalized[0], label_id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
return {'id': label_id, 'name': normalized[0], 'created_by': user_id}
|
return {'id': label_id, 'name': normalized[0], 'created_by': current['created_by']}
|
||||||
|
|
||||||
|
|
||||||
def delete_label(label_id: str, user_id: str | None = None, is_admin: bool = False):
|
def delete_label(label_id: str, user_id: str | None = None, is_admin: bool = False):
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
## Copyright © 2026 Olaf Kolkman
|
||||||
|
## SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
import logging
|
||||||
|
from html.parser import HTMLParser
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class TitleParser(HTMLParser):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.title = None
|
||||||
|
self.og_title = None
|
||||||
|
self.twitter_title = None
|
||||||
|
self.meta_title = None
|
||||||
|
self.in_title = False
|
||||||
|
|
||||||
|
def handle_starttag(self, tag, attrs):
|
||||||
|
if tag.lower() == 'title':
|
||||||
|
self.in_title = True
|
||||||
|
elif tag.lower() == 'meta':
|
||||||
|
attrs_dict = dict(attrs)
|
||||||
|
# Check for Open Graph title
|
||||||
|
if attrs_dict.get('property', '').lower() == 'og:title':
|
||||||
|
content = attrs_dict.get('content', '').strip()
|
||||||
|
if content and not self.og_title:
|
||||||
|
self.og_title = content
|
||||||
|
# Check for Twitter title
|
||||||
|
elif attrs_dict.get('name', '').lower() == 'twitter:title':
|
||||||
|
content = attrs_dict.get('content', '').strip()
|
||||||
|
if content and not self.twitter_title:
|
||||||
|
self.twitter_title = content
|
||||||
|
# Check for generic meta title
|
||||||
|
elif attrs_dict.get('name', '').lower() == 'title':
|
||||||
|
content = attrs_dict.get('content', '').strip()
|
||||||
|
if content and not self.meta_title:
|
||||||
|
self.meta_title = content
|
||||||
|
|
||||||
|
def handle_endtag(self, tag):
|
||||||
|
if tag.lower() == 'title':
|
||||||
|
self.in_title = False
|
||||||
|
|
||||||
|
def handle_data(self, data):
|
||||||
|
if self.in_title and not self.title:
|
||||||
|
stripped = data.strip()
|
||||||
|
if stripped:
|
||||||
|
self.title = stripped
|
||||||
|
|
||||||
|
def get_best_title(self):
|
||||||
|
"""Return the best title found, matching browser behavior.
|
||||||
|
Priority: page <title> tag (what browser shows), then meta tags as fallback."""
|
||||||
|
return self.title or self.og_title or self.twitter_title or self.meta_title
|
||||||
|
|
||||||
|
|
||||||
|
def scrape_title(url: str) -> str:
|
||||||
|
"""
|
||||||
|
Scrape the title from a URL, checking multiple sources:
|
||||||
|
1. Page title tag (what browser shows)
|
||||||
|
2. Open Graph title (og:title meta tag)
|
||||||
|
3. Twitter title (twitter:title meta tag)
|
||||||
|
4. Generic meta title
|
||||||
|
5. Domain name as fallback
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# Parse URL to extract domain as fallback
|
||||||
|
parsed = urlparse(url)
|
||||||
|
domain = parsed.netloc or url
|
||||||
|
|
||||||
|
# Fetch the URL with a timeout and size limit, using iter_bytes for decompression
|
||||||
|
with httpx.stream('GET', url, follow_redirects=True, timeout=5.0) as response:
|
||||||
|
if response.status_code != 200:
|
||||||
|
logger.warning('Failed to fetch %s: status %d', url, response.status_code)
|
||||||
|
return domain
|
||||||
|
|
||||||
|
# Read HTML in chunks (auto-decompressed) to avoid loading huge files
|
||||||
|
html_content = b''
|
||||||
|
max_size = 1024 * 100 # 100 KB limit
|
||||||
|
for chunk in response.iter_bytes():
|
||||||
|
html_content += chunk
|
||||||
|
if len(html_content) > max_size:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Parse the HTML to extract title
|
||||||
|
try:
|
||||||
|
html_text = html_content.decode('utf-8', errors='ignore')
|
||||||
|
parser = TitleParser()
|
||||||
|
parser.feed(html_text)
|
||||||
|
best_title = parser.get_best_title()
|
||||||
|
if best_title:
|
||||||
|
return best_title
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning('Failed to parse HTML from %s: %s', url, e)
|
||||||
|
|
||||||
|
return domain
|
||||||
|
except httpx.TimeoutException:
|
||||||
|
logger.warning('Timeout fetching %s', url)
|
||||||
|
return urlparse(url).netloc or url
|
||||||
|
except httpx.NetworkError as e:
|
||||||
|
logger.warning('Network error fetching %s: %s', url, e)
|
||||||
|
return urlparse(url).netloc or url
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('Unexpected error scraping %s: %s', url, e)
|
||||||
|
return urlparse(url).netloc or url
|
||||||
+96
-12
@@ -11,7 +11,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from backend.app.main import app
|
from backend.app.main import app
|
||||||
from backend.app.database import get_connection
|
from backend.app.database import get_connection, hash_password
|
||||||
from backend.app.services.email_service import get_smtp_settings
|
from backend.app.services.email_service import get_smtp_settings
|
||||||
from backend.app.services.login_throttle import clear_login_failures
|
from backend.app.services.login_throttle import clear_login_failures
|
||||||
from backend.app.services.otp_service import current_code
|
from backend.app.services.otp_service import current_code
|
||||||
@@ -31,7 +31,7 @@ def login_headers(username='alice'):
|
|||||||
|
|
||||||
|
|
||||||
def test_login_returns_token():
|
def test_login_returns_token():
|
||||||
assert app.version == '0.1.0'
|
assert app.version == '0.1.1'
|
||||||
response = client.post('/api/auth/login', json={
|
response = client.post('/api/auth/login', json={
|
||||||
'email': 'alice@example.com',
|
'email': 'alice@example.com',
|
||||||
'password': 'secret123',
|
'password': 'secret123',
|
||||||
@@ -490,25 +490,102 @@ def test_admin_can_toggle_privileges_without_removing_last_admin():
|
|||||||
assert last_admin.status_code == 400
|
assert last_admin.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_users_manage_owned_labels_and_admin_can_delete_any_label():
|
def test_users_manage_owned_labels_and_admin_can_edit_and_delete_any_label():
|
||||||
alice_headers = login_headers('alice')
|
alice_headers = login_headers('alice') # admin
|
||||||
created = client.post('/api/user/labels', headers=alice_headers, json={'name': 'My Label'})
|
bob_headers = login_headers('bob') # non-admin
|
||||||
|
|
||||||
|
created = client.post('/api/user/labels', headers=bob_headers, json={'name': 'Bob Label'})
|
||||||
assert created.status_code == 201
|
assert created.status_code == 201
|
||||||
label = created.json()
|
label = created.json()
|
||||||
assert label['name'] == '#My Label'
|
assert label['name'] == '#Bob Label'
|
||||||
|
|
||||||
edited = client.put(f"/api/user/labels/{label['id']}", headers=alice_headers, json={'name': '#Renamed'})
|
# Bob renames own label
|
||||||
|
edited = client.put(f"/api/user/labels/{label['id']}", headers=bob_headers, json={'name': '#RenamedByBob'})
|
||||||
assert edited.status_code == 200
|
assert edited.status_code == 200
|
||||||
assert edited.json()['name'] == '#Renamed'
|
assert edited.json()['name'] == '#RenamedByBob'
|
||||||
|
|
||||||
denied = client.put(f"/api/user/labels/{label['id']}", headers=login_headers('bob'), json={'name': '#Nope'})
|
# Non-owner Alice can edit it via admin endpoint, but NOT user endpoint
|
||||||
assert denied.status_code == 404
|
user_denied = client.put(f"/api/user/labels/{label['id']}", headers=alice_headers, json={'name': '#NopeUser'})
|
||||||
assert client.delete(f"/api/user/labels/{label['id']}", headers=login_headers('bob')).status_code == 404
|
assert user_denied.status_code == 404
|
||||||
|
|
||||||
|
admin_edited = client.put(f"/api/admin/labels/{label['id']}", headers=alice_headers, json={'name': '#AdminRenamed'})
|
||||||
|
assert admin_edited.status_code == 200
|
||||||
|
assert admin_edited.json()['name'] == '#AdminRenamed'
|
||||||
|
|
||||||
|
# Non-admin Bob cannot access admin edit endpoint
|
||||||
|
bob_admin_denied = client.put(f"/api/admin/labels/{label['id']}", headers=bob_headers, json={'name': '#NopeAdmin'})
|
||||||
|
assert bob_admin_denied.status_code == 403
|
||||||
|
|
||||||
|
# Admin delete
|
||||||
admin_delete = client.delete(f"/api/admin/labels/{label['id']}", headers=alice_headers)
|
admin_delete = client.delete(f"/api/admin/labels/{label['id']}", headers=alice_headers)
|
||||||
assert admin_delete.status_code == 200
|
assert admin_delete.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_label_visibility_isolation_and_grandfathering():
|
||||||
|
alice_headers = login_headers('alice')
|
||||||
|
bob_headers = login_headers('bob')
|
||||||
|
|
||||||
|
# Create non-admin user charlie
|
||||||
|
with get_connection() as conn:
|
||||||
|
conn.execute(
|
||||||
|
'''INSERT OR IGNORE INTO users (id, username, email, password_hash, is_admin, email_verified)
|
||||||
|
VALUES (?, ?, ?, ?, 0, 1)''',
|
||||||
|
('user-3', 'charlie', 'charlie@example.com', hash_password('secret123')),
|
||||||
|
)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
charlie_headers = login_headers('charlie')
|
||||||
|
|
||||||
|
# Create Bob label (non-admin)
|
||||||
|
created_bob = client.post('/api/user/labels', headers=bob_headers, json={'name': 'BobOnlyLabel'}).json()
|
||||||
|
# Create Charlie label (non-admin)
|
||||||
|
created_charlie = client.post('/api/user/labels', headers=charlie_headers, json={'name': 'CharlieOnlyLabel'}).json()
|
||||||
|
|
||||||
|
# Grandfathered label in DB with NULL created_by
|
||||||
|
from uuid import uuid4
|
||||||
|
grandfathered_id = str(uuid4())
|
||||||
|
with get_connection() as conn:
|
||||||
|
conn.execute('INSERT INTO tags (id, name, created_by) VALUES (?, ?, NULL)', (grandfathered_id, '#GrandfatheredLabel'))
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
# Bob views /api/user/labels: sees default tags, grandfathered tag, and Bob tag, NOT Charlie tag
|
||||||
|
bob_labels = client.get('/api/user/labels', headers=bob_headers).json()
|
||||||
|
bob_label_names = [l['name'] for l in bob_labels]
|
||||||
|
assert '#BobOnlyLabel' in bob_label_names
|
||||||
|
assert '#GrandfatheredLabel' in bob_label_names
|
||||||
|
assert '#Cybersecurity' in bob_label_names
|
||||||
|
assert '#CharlieOnlyLabel' not in bob_label_names
|
||||||
|
|
||||||
|
# Charlie views /api/user/labels: sees default tags, grandfathered tag, and Charlie tag, NOT Bob tag
|
||||||
|
charlie_labels = client.get('/api/user/labels', headers=charlie_headers).json()
|
||||||
|
charlie_label_names = [l['name'] for l in charlie_labels]
|
||||||
|
assert '#CharlieOnlyLabel' in charlie_label_names
|
||||||
|
assert '#GrandfatheredLabel' in charlie_label_names
|
||||||
|
assert '#Cybersecurity' in charlie_label_names
|
||||||
|
assert '#BobOnlyLabel' not in charlie_label_names
|
||||||
|
|
||||||
|
# Bob views /api/tags (authenticated): sees Bob tag & default/grandfathered, NOT Charlie tag
|
||||||
|
bob_tags = client.get('/api/tags', headers=bob_headers).json()
|
||||||
|
assert '#BobOnlyLabel' in bob_tags
|
||||||
|
assert '#GrandfatheredLabel' in bob_tags
|
||||||
|
assert '#CharlieOnlyLabel' not in bob_tags
|
||||||
|
|
||||||
|
# Anonymous views /api/tags: sees default/grandfathered, NOT Bob or Charlie tag
|
||||||
|
anon_tags = client.get('/api/tags').json()
|
||||||
|
assert '#GrandfatheredLabel' in anon_tags
|
||||||
|
assert '#BobOnlyLabel' not in anon_tags
|
||||||
|
assert '#CharlieOnlyLabel' not in anon_tags
|
||||||
|
|
||||||
|
# Bob cannot edit or delete grandfathered label
|
||||||
|
assert client.put(f"/api/user/labels/{grandfathered_id}", headers=bob_headers, json={'name': '#RenamedGrandfathered'}).status_code == 404
|
||||||
|
assert client.delete(f"/api/user/labels/{grandfathered_id}", headers=bob_headers).status_code == 404
|
||||||
|
|
||||||
|
# Clean up created labels
|
||||||
|
client.delete(f"/api/user/labels/{created_bob['id']}", headers=bob_headers)
|
||||||
|
client.delete(f"/api/user/labels/{created_charlie['id']}", headers=charlie_headers)
|
||||||
|
client.delete(f"/api/admin/labels/{grandfathered_id}", headers=alice_headers)
|
||||||
|
|
||||||
|
|
||||||
def test_labels_page_renders_authenticated_management_shell():
|
def test_labels_page_renders_authenticated_management_shell():
|
||||||
page = client.get('/labels')
|
page = client.get('/labels')
|
||||||
assert page.status_code == 200
|
assert page.status_code == 200
|
||||||
@@ -738,7 +815,14 @@ def test_public_and_admin_pages_render_html():
|
|||||||
assert 'id="auth-menu" class="auth-menu hidden"' in admin_page
|
assert 'id="auth-menu" class="auth-menu hidden"' in admin_page
|
||||||
assert 'id="auth-home-link" href="/">Home</a>' in admin_page
|
assert 'id="auth-home-link" href="/">Home</a>' in admin_page
|
||||||
assert '<a id="auth-username" class="user-name" href="/">' in admin_page
|
assert '<a id="auth-username" class="user-name" href="/">' in admin_page
|
||||||
assert 'admin.js?v=5' in admin_page
|
assert 'class="panel-toggle-btn"' in admin_page
|
||||||
|
assert 'admin.js?v=7' in admin_page
|
||||||
|
assert client.get('/profile').status_code == 200
|
||||||
|
profile_page = client.get('/profile').text
|
||||||
|
assert 'Profile' in profile_page
|
||||||
|
assert 'class="link-item settings-panel minimized"' in profile_page
|
||||||
|
assert 'class="panel-toggle-btn"' in profile_page
|
||||||
|
assert 'profile.js?v=6' in profile_page
|
||||||
feed_script = client.get('/static/feed.js?v=7').text
|
feed_script = client.get('/static/feed.js?v=7').text
|
||||||
assert 'if (item.is_owner && !showIdentity)' in feed_script
|
assert 'if (item.is_owner && !showIdentity)' in feed_script
|
||||||
assert 'deleteEntry(item, deleteButton)' in feed_script
|
assert 'deleteEntry(item, deleteButton)' in feed_script
|
||||||
|
|||||||
+10
-10
@@ -30,21 +30,21 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
traefik.enable: true
|
traefik.enable: true
|
||||||
traefik.http.middlewares.web-https-redirect.redirectscheme.scheme: https
|
traefik.http.middlewares.web-https-redirect.redirectscheme.scheme: https
|
||||||
traefik.http.services.linklog.loadbalancer.server.port: 8000
|
traefik.http.services.testlog.loadbalancer.server.port: 8000
|
||||||
traefik.docker.network: git_traefik
|
traefik.docker.network: git_traefik
|
||||||
|
|
||||||
|
|
||||||
traefik.http.routers.linklog.entrypoints: web
|
traefik.http.routers.testlog.entrypoints: web
|
||||||
traefik.http.routers.linklog.rule: Host(`${LINKLOG_PUBLIC_URL:-linklog.example.com}`)
|
traefik.http.routers.testlog.rule: Host(`${LINKLOG_PUBLIC_URL:-linklog.example.com}`)
|
||||||
traefik.http.routers.linklog.middlewares: web-https-redirect,servicests
|
traefik.http.routers.testlog.middlewares: web-https-redirect,servicests
|
||||||
traefik.http.routers.linklog-secure.entrypoints: websecure
|
traefik.http.routers.testlog-secure.entrypoints: websecure
|
||||||
traefik.http.routers.linklog-secure.rule: Host(`${LINKLOG_PUBLIC_URL:-linklog.example.com}`)
|
traefik.http.routers.testlog-secure.rule: Host(`${LINKLOG_PUBLIC_URL:-linklog.example.com}`)
|
||||||
traefik.http.routers.linklog-secure.tls: true
|
traefik.http.routers.testlog-secure.tls: true
|
||||||
traefik.http.routers.linklog-secure.middlewares: servicests
|
traefik.http.routers.testlog-secure.middlewares: servicests
|
||||||
|
|
||||||
|
|
||||||
traefik.http.routers.linklog-secure.tls.certresolver: myresolver
|
traefik.http.routers.testlog-secure.tls.certresolver: myresolver
|
||||||
traefik.http.routers.linklog-secure.service: linklog
|
traefik.http.routers.testlog-secure.service: testlog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+116
-7
@@ -12,7 +12,7 @@ const smtpForm = document.querySelector('#smtp-form');
|
|||||||
const smtpTestButton = document.querySelector('#smtp-test-button');
|
const smtpTestButton = document.querySelector('#smtp-test-button');
|
||||||
const smtpStatus = document.querySelector('#smtp-status');
|
const smtpStatus = document.querySelector('#smtp-status');
|
||||||
const themesForm = document.querySelector('#themes-form');
|
const themesForm = document.querySelector('#themes-form');
|
||||||
const themeOptions = document.querySelector('#theme-options');
|
const themeOptions = document.querySelector('#admin-theme-options');
|
||||||
const themeStatus = document.querySelector('#theme-status');
|
const themeStatus = document.querySelector('#theme-status');
|
||||||
let smtpNextAllowedAt = null;
|
let smtpNextAllowedAt = null;
|
||||||
let smtpTimerHandle = null;
|
let smtpTimerHandle = null;
|
||||||
@@ -57,21 +57,85 @@ function renderLabels(labels) {
|
|||||||
adminLabelList.replaceChildren(...labels.map((label) => {
|
adminLabelList.replaceChildren(...labels.map((label) => {
|
||||||
const row = document.createElement('div');
|
const row = document.createElement('div');
|
||||||
row.className = 'plugin-row';
|
row.className = 'plugin-row';
|
||||||
|
|
||||||
const text = document.createElement('span');
|
const text = document.createElement('span');
|
||||||
text.textContent = `${label.name}${label.creator ? ` (${label.creator})` : ' (default)'}`;
|
text.textContent = `${label.name}${label.creator ? ` (${label.creator})` : ' (default)'}`;
|
||||||
const button = document.createElement('button');
|
|
||||||
button.type = 'button';
|
const actions = document.createElement('div');
|
||||||
button.className = 'danger-button';
|
actions.style.display = 'flex';
|
||||||
button.textContent = 'Delete';
|
actions.style.gap = '8px';
|
||||||
button.addEventListener('click', async () => {
|
|
||||||
|
const editButton = document.createElement('button');
|
||||||
|
editButton.type = 'button';
|
||||||
|
editButton.textContent = 'Edit';
|
||||||
|
editButton.addEventListener('click', () => {
|
||||||
|
showAdminInlineLabelEdit(row, label);
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteButton = document.createElement('button');
|
||||||
|
deleteButton.type = 'button';
|
||||||
|
deleteButton.className = 'danger-button';
|
||||||
|
deleteButton.textContent = 'Delete';
|
||||||
|
deleteButton.addEventListener('click', async () => {
|
||||||
|
if (!confirm(`Are you sure you want to delete "${label.name}"?`)) return;
|
||||||
const response = await fetch(`/api/admin/labels/${label.id}`, {method: 'DELETE', headers: authHeaders()});
|
const response = await fetch(`/api/admin/labels/${label.id}`, {method: 'DELETE', headers: authHeaders()});
|
||||||
if (response.ok) loadLabels();
|
if (response.ok) loadLabels();
|
||||||
});
|
});
|
||||||
row.append(text, button);
|
|
||||||
|
actions.append(editButton, deleteButton);
|
||||||
|
row.append(text, actions);
|
||||||
return row;
|
return row;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showAdminInlineLabelEdit(rowContainer, label) {
|
||||||
|
rowContainer.replaceChildren();
|
||||||
|
|
||||||
|
const editForm = document.createElement('form');
|
||||||
|
editForm.style.display = 'flex';
|
||||||
|
editForm.style.gap = '8px';
|
||||||
|
editForm.style.width = '100%';
|
||||||
|
editForm.style.alignItems = 'center';
|
||||||
|
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'text';
|
||||||
|
input.value = label.name;
|
||||||
|
input.required = true;
|
||||||
|
input.style.flex = '1';
|
||||||
|
|
||||||
|
const saveButton = document.createElement('button');
|
||||||
|
saveButton.type = 'submit';
|
||||||
|
saveButton.textContent = 'Save';
|
||||||
|
|
||||||
|
const cancelButton = document.createElement('button');
|
||||||
|
cancelButton.type = 'button';
|
||||||
|
cancelButton.textContent = 'Cancel';
|
||||||
|
cancelButton.addEventListener('click', () => {
|
||||||
|
loadLabels();
|
||||||
|
});
|
||||||
|
|
||||||
|
editForm.append(input, saveButton, cancelButton);
|
||||||
|
|
||||||
|
editForm.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const newName = input.value.trim();
|
||||||
|
if (!newName) return;
|
||||||
|
const response = await fetch(`/api/admin/labels/${label.id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: authHeaders(true),
|
||||||
|
body: JSON.stringify({ name: newName }),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
loadLabels();
|
||||||
|
} else {
|
||||||
|
alert(await responseError(response, 'Could not update label'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rowContainer.appendChild(editForm);
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
|
||||||
async function loadLabels() {
|
async function loadLabels() {
|
||||||
const response = await fetch('/api/admin/labels', {headers: authHeaders()});
|
const response = await fetch('/api/admin/labels', {headers: authHeaders()});
|
||||||
if (!response.ok) throw new Error('Could not load labels');
|
if (!response.ok) throw new Error('Could not load labels');
|
||||||
@@ -195,9 +259,51 @@ async function loadUsers() {
|
|||||||
renderUsers(await response.json());
|
renderUsers(await response.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initPanelToggles() {
|
||||||
|
const panels = document.querySelectorAll('#admin-controls .settings-panel');
|
||||||
|
panels.forEach((panel) => {
|
||||||
|
panel.classList.add('minimized');
|
||||||
|
const h2 = panel.querySelector('h2');
|
||||||
|
if (!h2) return;
|
||||||
|
let btn = h2.querySelector('.panel-toggle-btn');
|
||||||
|
if (!btn) {
|
||||||
|
const titleText = h2.textContent.trim();
|
||||||
|
h2.replaceChildren();
|
||||||
|
btn = document.createElement('button');
|
||||||
|
btn.type = 'button';
|
||||||
|
btn.className = 'panel-toggle-btn';
|
||||||
|
btn.setAttribute('aria-expanded', 'false');
|
||||||
|
const textSpan = document.createElement('span');
|
||||||
|
textSpan.textContent = titleText;
|
||||||
|
const iconSpan = document.createElement('span');
|
||||||
|
iconSpan.className = 'panel-toggle-icon';
|
||||||
|
iconSpan.setAttribute('aria-hidden', 'true');
|
||||||
|
iconSpan.textContent = '▼';
|
||||||
|
btn.append(textSpan, iconSpan);
|
||||||
|
h2.appendChild(btn);
|
||||||
|
} else {
|
||||||
|
btn.setAttribute('aria-expanded', 'false');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (h2.dataset.initialized) return;
|
||||||
|
h2.dataset.initialized = 'true';
|
||||||
|
|
||||||
|
h2.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const isMinimized = panel.classList.toggle('minimized');
|
||||||
|
if (btn) {
|
||||||
|
btn.setAttribute('aria-expanded', String(!isMinimized));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showAdminState(isAdmin) {
|
function showAdminState(isAdmin) {
|
||||||
adminControls.classList.toggle('hidden', !isAdmin);
|
adminControls.classList.toggle('hidden', !isAdmin);
|
||||||
adminAuthNotice.classList.toggle('hidden', isAdmin);
|
adminAuthNotice.classList.toggle('hidden', isAdmin);
|
||||||
|
if (isAdmin) {
|
||||||
|
initPanelToggles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSignedOutState() {
|
function showSignedOutState() {
|
||||||
@@ -382,4 +488,7 @@ loadAdminState().catch((error) => {
|
|||||||
smtpForm.reset();
|
smtpForm.reset();
|
||||||
themesForm.reset();
|
themesForm.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', initPanelToggles);
|
||||||
|
initPanelToggles();
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
(() => {
|
(() => {
|
||||||
const loginButton = document.querySelector('#auth-login-button');
|
const loginButton = document.querySelector('#auth-login-button');
|
||||||
|
const newEntryButton = document.querySelector('#new-entry-button');
|
||||||
const profileLink = document.querySelector('#auth-profile-link');
|
const profileLink = document.querySelector('#auth-profile-link');
|
||||||
const labelsLink = document.querySelector('#auth-labels-link');
|
const labelsLink = document.querySelector('#auth-labels-link');
|
||||||
const adminLink = document.querySelector('#auth-admin-link');
|
const adminLink = document.querySelector('#auth-admin-link');
|
||||||
@@ -14,6 +15,10 @@
|
|||||||
const menuToggle = document.querySelector('.menu-toggle');
|
const menuToggle = document.querySelector('.menu-toggle');
|
||||||
const logoutButton = document.querySelector('#logout-button');
|
const logoutButton = document.querySelector('#logout-button');
|
||||||
|
|
||||||
|
const themeSubmenuContainer = document.querySelector('#theme-submenu-container');
|
||||||
|
const themeSubmenuTitle = document.querySelector('.submenu-title');
|
||||||
|
const themeOptions = document.querySelector('#theme-options');
|
||||||
|
|
||||||
if (!loginButton || !profileLink || !labelsLink || !adminLink || !session || !username || !menu || !menuToggle || !logoutButton) return;
|
if (!loginButton || !profileLink || !labelsLink || !adminLink || !session || !username || !menu || !menuToggle || !logoutButton) return;
|
||||||
|
|
||||||
menuToggle.addEventListener('click', () => {
|
menuToggle.addEventListener('click', () => {
|
||||||
@@ -22,8 +27,19 @@
|
|||||||
menuToggle.setAttribute('aria-expanded', String(!isOpen));
|
menuToggle.setAttribute('aria-expanded', String(!isOpen));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle theme submenu toggle
|
||||||
|
if (themeSubmenuTitle && themeOptions) {
|
||||||
|
themeSubmenuTitle.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const isOpen = !themeOptions.classList.contains('hidden');
|
||||||
|
themeOptions.classList.toggle('hidden', isOpen);
|
||||||
|
themeSubmenuTitle.setAttribute('aria-expanded', String(!isOpen));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showSignedOut() {
|
function showSignedOut() {
|
||||||
loginButton.classList.remove('hidden');
|
loginButton.classList.remove('hidden');
|
||||||
|
if (newEntryButton) newEntryButton.classList.add('hidden');
|
||||||
profileLink.classList.add('hidden');
|
profileLink.classList.add('hidden');
|
||||||
labelsLink.classList.add('hidden');
|
labelsLink.classList.add('hidden');
|
||||||
adminLink.classList.add('hidden');
|
adminLink.classList.add('hidden');
|
||||||
@@ -33,6 +49,7 @@
|
|||||||
|
|
||||||
function showSignedIn(user) {
|
function showSignedIn(user) {
|
||||||
loginButton.classList.add('hidden');
|
loginButton.classList.add('hidden');
|
||||||
|
if (newEntryButton) newEntryButton.classList.remove('hidden');
|
||||||
profileLink.classList.remove('hidden');
|
profileLink.classList.remove('hidden');
|
||||||
labelsLink.classList.remove('hidden');
|
labelsLink.classList.remove('hidden');
|
||||||
adminLink.classList.toggle('hidden', !user.is_admin);
|
adminLink.classList.toggle('hidden', !user.is_admin);
|
||||||
|
|||||||
@@ -0,0 +1,209 @@
|
|||||||
|
// Copyright © 2026 Olaf Kolkman
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
const labelAuthNotice = document.querySelector('#label-auth-notice');
|
||||||
|
const labelControls = document.querySelector('#label-controls');
|
||||||
|
const labelForm = document.querySelector('#label-form');
|
||||||
|
const labelNameInput = document.querySelector('#label-name');
|
||||||
|
const labelStatus = document.querySelector('#label-status');
|
||||||
|
const labelList = document.querySelector('#label-list');
|
||||||
|
const accessToken = localStorage.getItem('linklogAccessToken');
|
||||||
|
let currentUserId = null;
|
||||||
|
|
||||||
|
function authHeaders(includeJson = false) {
|
||||||
|
return {
|
||||||
|
...(includeJson ? {'Content-Type': 'application/json'} : {}),
|
||||||
|
...(accessToken ? {Authorization: `Bearer ${accessToken}`} : {}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStatus(message, isError = false) {
|
||||||
|
if (!labelStatus) return;
|
||||||
|
labelStatus.textContent = message;
|
||||||
|
labelStatus.style.color = isError ? '#b91c1c' : '#166534';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function responseError(response, fallback) {
|
||||||
|
try {
|
||||||
|
const result = await response.json();
|
||||||
|
return result.detail || result.message || fallback;
|
||||||
|
} catch {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLabels(labels) {
|
||||||
|
if (!labelList) return;
|
||||||
|
if (!labels || labels.length === 0) {
|
||||||
|
labelList.innerHTML = '<p>No labels found.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
labelList.replaceChildren(...labels.map((label) => {
|
||||||
|
const row = document.createElement('div');
|
||||||
|
row.className = 'plugin-row';
|
||||||
|
|
||||||
|
const isOwned = label.created_by === currentUserId;
|
||||||
|
|
||||||
|
const contentContainer = document.createElement('div');
|
||||||
|
contentContainer.style.display = 'flex';
|
||||||
|
contentContainer.style.alignItems = 'center';
|
||||||
|
contentContainer.style.justifySpaceBetween = 'space-between';
|
||||||
|
contentContainer.style.width = '100%';
|
||||||
|
|
||||||
|
const text = document.createElement('span');
|
||||||
|
text.textContent = `${label.name}${isOwned ? '' : (label.creator ? ` (${label.creator})` : ' (default)')}`;
|
||||||
|
|
||||||
|
contentContainer.appendChild(text);
|
||||||
|
|
||||||
|
if (isOwned) {
|
||||||
|
const actions = document.createElement('div');
|
||||||
|
actions.style.display = 'flex';
|
||||||
|
actions.style.gap = '8px';
|
||||||
|
|
||||||
|
const editButton = document.createElement('button');
|
||||||
|
editButton.type = 'button';
|
||||||
|
editButton.textContent = 'Edit';
|
||||||
|
editButton.addEventListener('click', () => {
|
||||||
|
showInlineEdit(row, label);
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteButton = document.createElement('button');
|
||||||
|
deleteButton.type = 'button';
|
||||||
|
deleteButton.className = 'danger-button';
|
||||||
|
deleteButton.textContent = 'Delete';
|
||||||
|
deleteButton.addEventListener('click', async () => {
|
||||||
|
if (!confirm(`Are you sure you want to delete "${label.name}"?`)) return;
|
||||||
|
setStatus('');
|
||||||
|
const response = await fetch(`/api/user/labels/${label.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: authHeaders(),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
setStatus(`Deleted label ${label.name}`);
|
||||||
|
loadLabels();
|
||||||
|
} else {
|
||||||
|
setStatus(await responseError(response, 'Could not delete label'), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
actions.append(editButton, deleteButton);
|
||||||
|
contentContainer.appendChild(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
row.appendChild(contentContainer);
|
||||||
|
return row;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showInlineEdit(rowContainer, label) {
|
||||||
|
rowContainer.replaceChildren();
|
||||||
|
|
||||||
|
const editForm = document.createElement('form');
|
||||||
|
editForm.style.display = 'flex';
|
||||||
|
editForm.style.gap = '8px';
|
||||||
|
editForm.style.width = '100%';
|
||||||
|
editForm.style.alignItems = 'center';
|
||||||
|
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'text';
|
||||||
|
input.value = label.name;
|
||||||
|
input.required = true;
|
||||||
|
input.style.flex = '1';
|
||||||
|
|
||||||
|
const saveButton = document.createElement('button');
|
||||||
|
saveButton.type = 'submit';
|
||||||
|
saveButton.textContent = 'Save';
|
||||||
|
|
||||||
|
const cancelButton = document.createElement('button');
|
||||||
|
cancelButton.type = 'button';
|
||||||
|
cancelButton.textContent = 'Cancel';
|
||||||
|
cancelButton.addEventListener('click', () => {
|
||||||
|
loadLabels();
|
||||||
|
});
|
||||||
|
|
||||||
|
editForm.append(input, saveButton, cancelButton);
|
||||||
|
|
||||||
|
editForm.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const newName = input.value.trim();
|
||||||
|
if (!newName) return;
|
||||||
|
setStatus('');
|
||||||
|
const response = await fetch(`/api/user/labels/${label.id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: authHeaders(true),
|
||||||
|
body: JSON.stringify({ name: newName }),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
setStatus(`Updated label to ${newName}`);
|
||||||
|
loadLabels();
|
||||||
|
} else {
|
||||||
|
setStatus(await responseError(response, 'Could not update label'), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rowContainer.appendChild(editForm);
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadLabels() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/user/labels', { headers: authHeaders() });
|
||||||
|
if (!response.ok) throw new Error('Could not load labels');
|
||||||
|
const labels = await response.json();
|
||||||
|
renderLabels(labels);
|
||||||
|
} catch (error) {
|
||||||
|
setStatus('Error loading labels', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
if (!accessToken) {
|
||||||
|
if (labelAuthNotice) labelAuthNotice.classList.remove('hidden');
|
||||||
|
if (labelControls) labelControls.classList.add('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (labelAuthNotice) labelAuthNotice.classList.add('hidden');
|
||||||
|
if (labelControls) labelControls.classList.remove('hidden');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const meResponse = await fetch('/api/auth/me', { headers: authHeaders() });
|
||||||
|
if (meResponse.ok) {
|
||||||
|
const me = await meResponse.json();
|
||||||
|
currentUserId = me.id;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Proceed if me fails
|
||||||
|
}
|
||||||
|
|
||||||
|
await loadLabels();
|
||||||
|
|
||||||
|
if (labelForm) {
|
||||||
|
labelForm.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const name = labelNameInput.value.trim();
|
||||||
|
if (!name) return;
|
||||||
|
setStatus('');
|
||||||
|
const response = await fetch('/api/user/labels', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: authHeaders(true),
|
||||||
|
body: JSON.stringify({ name }),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
labelNameInput.value = '';
|
||||||
|
setStatus(`Added label ${name}`);
|
||||||
|
loadLabels();
|
||||||
|
} else {
|
||||||
|
setStatus(await responseError(response, 'Could not add label'), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
if (document.readyState !== 'loading') {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
// Copyright © 2026 Olaf Kolkman
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
const entryForm = document.getElementById('entry-form');
|
||||||
|
const authRequired = document.getElementById('auth-required');
|
||||||
|
const urlInput = document.getElementById('url-input');
|
||||||
|
const titleInput = document.getElementById('title-input');
|
||||||
|
const commentInput = document.getElementById('comment-input');
|
||||||
|
const newTagsInput = document.getElementById('new-tags-input');
|
||||||
|
const existingTagsEl = document.getElementById('existing-tags');
|
||||||
|
const mastodonEnabledCheckbox = document.getElementById('mastodon-enabled');
|
||||||
|
const scrapeButton = document.getElementById('scrape-button');
|
||||||
|
const scrapeStatus = document.getElementById('scrape-status');
|
||||||
|
const submitButton = document.getElementById('submit-button');
|
||||||
|
const submitStatus = document.getElementById('submit-status');
|
||||||
|
|
||||||
|
const token = localStorage.getItem('linklogAccessToken');
|
||||||
|
let availableTags = [];
|
||||||
|
let selectedTags = new Set();
|
||||||
|
let currentUser = null;
|
||||||
|
|
||||||
|
// Utility function to add status messages
|
||||||
|
function setStatus(statusEl, message, isError = false) {
|
||||||
|
statusEl.textContent = message;
|
||||||
|
statusEl.className = `status ${isError ? 'error' : 'success'}`;
|
||||||
|
statusEl.classList.remove('hidden');
|
||||||
|
if (!isError) {
|
||||||
|
setTimeout(() => statusEl.classList.add('hidden'), 4000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check authentication
|
||||||
|
if (!token) {
|
||||||
|
authRequired.classList.remove('hidden');
|
||||||
|
entryForm.classList.add('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify token is still valid
|
||||||
|
fetch('/api/auth/me', { headers: { Authorization: `Bearer ${token}` } })
|
||||||
|
.then((response) => {
|
||||||
|
if (!response.ok) throw new Error('Not authenticated');
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then((user) => {
|
||||||
|
currentUser = user;
|
||||||
|
entryForm.classList.remove('hidden');
|
||||||
|
loadTags();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
localStorage.removeItem('linklogAccessToken');
|
||||||
|
authRequired.classList.remove('hidden');
|
||||||
|
entryForm.classList.add('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load available tags
|
||||||
|
async function loadTags() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/tags');
|
||||||
|
if (!response.ok) throw new Error('Could not load tags');
|
||||||
|
availableTags = await response.json();
|
||||||
|
renderTags();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error loading tags:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render tag checkboxes
|
||||||
|
function renderTags() {
|
||||||
|
existingTagsEl.innerHTML = '';
|
||||||
|
availableTags.forEach((tag) => {
|
||||||
|
const label = document.createElement('label');
|
||||||
|
label.className = 'tag-checkbox';
|
||||||
|
|
||||||
|
const checkbox = document.createElement('input');
|
||||||
|
checkbox.type = 'checkbox';
|
||||||
|
checkbox.value = tag;
|
||||||
|
checkbox.checked = selectedTags.has(tag);
|
||||||
|
checkbox.addEventListener('change', () => {
|
||||||
|
if (checkbox.checked) {
|
||||||
|
selectedTags.add(tag);
|
||||||
|
} else {
|
||||||
|
selectedTags.delete(tag);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
label.appendChild(checkbox);
|
||||||
|
label.append(` ${tag}`);
|
||||||
|
existingTagsEl.appendChild(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scrape URL for title
|
||||||
|
scrapeButton.addEventListener('click', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const url = urlInput.value.trim();
|
||||||
|
if (!url) {
|
||||||
|
setStatus(scrapeStatus, 'Please enter a URL', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scrapeButton.disabled = true;
|
||||||
|
setStatus(scrapeStatus, 'Scraping...', false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/scrape?url=${encodeURIComponent(url)}`, {
|
||||||
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
if (response.status === 401) {
|
||||||
|
localStorage.removeItem('linklogAccessToken');
|
||||||
|
location.reload();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error(`HTTP ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
if (data.title) {
|
||||||
|
titleInput.value = data.title;
|
||||||
|
setStatus(scrapeStatus, 'Title loaded!', false);
|
||||||
|
} else {
|
||||||
|
setStatus(scrapeStatus, 'No title found', true);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Scrape error:', error);
|
||||||
|
setStatus(scrapeStatus, `Error: ${error.message}`, true);
|
||||||
|
} finally {
|
||||||
|
scrapeButton.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle form submission
|
||||||
|
entryForm.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const url = urlInput.value.trim();
|
||||||
|
const title = titleInput.value.trim();
|
||||||
|
const comment = commentInput.value.trim();
|
||||||
|
const newTags = newTagsInput.value.trim();
|
||||||
|
|
||||||
|
if (!url || !title) {
|
||||||
|
setStatus(submitStatus, 'URL and title are required', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine selected tags and new tags
|
||||||
|
const tags = Array.from(selectedTags);
|
||||||
|
if (newTags) {
|
||||||
|
const newTagsList = newTags
|
||||||
|
.split(',')
|
||||||
|
.map((t) => t.trim())
|
||||||
|
.filter((t) => t);
|
||||||
|
tags.push(...newTagsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
submitButton.disabled = true;
|
||||||
|
setStatus(submitStatus, 'Saving...', false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/links', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
title,
|
||||||
|
url,
|
||||||
|
comment,
|
||||||
|
tags,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
if (response.status === 401) {
|
||||||
|
localStorage.removeItem('linklogAccessToken');
|
||||||
|
location.reload();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const error = await response.json().catch(() => ({}));
|
||||||
|
throw new Error(error.detail || `HTTP ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
setStatus(submitStatus, `Link saved to LinkLog${data.duplicate ? ' (updated)' : ''}!`, false);
|
||||||
|
|
||||||
|
// Redirect to user page after 1 second
|
||||||
|
if (currentUser) {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = `/${encodeURIComponent(currentUser.username)}/`;
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Submit error:', error);
|
||||||
|
setStatus(submitStatus, `Error: ${error.message}`, true);
|
||||||
|
} finally {
|
||||||
|
submitButton.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
@@ -310,6 +310,48 @@ passwordForm.addEventListener('submit', async (event) => {
|
|||||||
if (response.ok) passwordForm.reset();
|
if (response.ok) passwordForm.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function initPanelToggles() {
|
||||||
|
const panels = document.querySelectorAll('.settings-panel');
|
||||||
|
panels.forEach((panel) => {
|
||||||
|
panel.classList.add('minimized');
|
||||||
|
const h2 = panel.querySelector('h2');
|
||||||
|
if (!h2) return;
|
||||||
|
let btn = h2.querySelector('.panel-toggle-btn');
|
||||||
|
if (!btn) {
|
||||||
|
const titleText = h2.textContent.trim();
|
||||||
|
h2.replaceChildren();
|
||||||
|
btn = document.createElement('button');
|
||||||
|
btn.type = 'button';
|
||||||
|
btn.className = 'panel-toggle-btn';
|
||||||
|
btn.setAttribute('aria-expanded', 'false');
|
||||||
|
const textSpan = document.createElement('span');
|
||||||
|
textSpan.textContent = titleText;
|
||||||
|
const iconSpan = document.createElement('span');
|
||||||
|
iconSpan.className = 'panel-toggle-icon';
|
||||||
|
iconSpan.setAttribute('aria-hidden', 'true');
|
||||||
|
iconSpan.textContent = '▼';
|
||||||
|
btn.append(textSpan, iconSpan);
|
||||||
|
h2.appendChild(btn);
|
||||||
|
} else {
|
||||||
|
btn.setAttribute('aria-expanded', 'false');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (h2.dataset.initialized) return;
|
||||||
|
h2.dataset.initialized = 'true';
|
||||||
|
|
||||||
|
h2.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const isMinimized = panel.classList.toggle('minimized');
|
||||||
|
if (btn) {
|
||||||
|
btn.setAttribute('aria-expanded', String(!isMinimized));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', initPanelToggles);
|
||||||
|
initPanelToggles();
|
||||||
|
|
||||||
Promise.all([loadProfile(), loadMastodonConfig(), loadOtp(), loadEmailAddresses()]).catch((error) => {
|
Promise.all([loadProfile(), loadMastodonConfig(), loadOtp(), loadEmailAddresses()]).catch((error) => {
|
||||||
setStatus('#profile-status', accessToken ? error.message : 'Please sign in first.', true);
|
setStatus('#profile-status', accessToken ? error.message : 'Please sign in first.', true);
|
||||||
});
|
});
|
||||||
|
|||||||
+427
-11
@@ -223,17 +223,6 @@ body::selection {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-picker {
|
|
||||||
width: auto;
|
|
||||||
min-width: 132px;
|
|
||||||
padding: 8px 10px;
|
|
||||||
border: 1px solid var(--surface-2);
|
|
||||||
border-radius: 7px;
|
|
||||||
background: var(--surface-0);
|
|
||||||
color: var(--text);
|
|
||||||
font: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-toggle {
|
.menu-toggle {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
padding: 10px 13px;
|
padding: 10px 13px;
|
||||||
@@ -248,6 +237,31 @@ body::selection {
|
|||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-entry-button {
|
||||||
|
padding: 10px 13px;
|
||||||
|
border: 1px solid var(--mauve);
|
||||||
|
border-radius: 7px;
|
||||||
|
background: var(--mauve);
|
||||||
|
color: var(--crust);
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-entry-button:hover {
|
||||||
|
background: var(--lavender);
|
||||||
|
border-color: var(--lavender);
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-entry-button a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-entry-button.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.auth-menu {
|
.auth-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 30;
|
z-index: 30;
|
||||||
@@ -314,6 +328,86 @@ body::selection {
|
|||||||
color: var(--red);
|
color: var(--red);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.theme-submenu-container {
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
margin-top: 6px;
|
||||||
|
padding-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-submenu-container.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-title {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 9px 10px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text);
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-title:hover {
|
||||||
|
background: var(--surface-1);
|
||||||
|
color: var(--lavender);
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-title::after {
|
||||||
|
content: ' ▼';
|
||||||
|
font-size: 0.7em;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-title[aria-expanded='true']::after {
|
||||||
|
transform: rotate(-180deg);
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-options {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
margin-top: 4px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: var(--surface-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-options.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-option {
|
||||||
|
padding: 8px 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 5px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text);
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-option:hover {
|
||||||
|
background: var(--surface-0);
|
||||||
|
border-color: var(--lavender);
|
||||||
|
color: var(--lavender);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-option.active {
|
||||||
|
background: var(--mauve);
|
||||||
|
border-color: var(--mauve);
|
||||||
|
color: var(--crust);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
main.container {
|
main.container {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
@@ -357,6 +451,108 @@ main.container {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#admin-controls {
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel + .settings-panel {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel h2 {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s ease, margin 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel h2:hover {
|
||||||
|
filter: brightness(1.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel:nth-of-type(5n+1) h2 {
|
||||||
|
color: var(--mauve);
|
||||||
|
background: var(--surface-1);
|
||||||
|
background: color-mix(in srgb, var(--mauve) 14%, transparent);
|
||||||
|
border-left: 4px solid var(--mauve);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel:nth-of-type(5n+2) h2 {
|
||||||
|
color: var(--teal);
|
||||||
|
background: var(--surface-1);
|
||||||
|
background: color-mix(in srgb, var(--teal) 14%, transparent);
|
||||||
|
border-left: 4px solid var(--teal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel:nth-of-type(5n+3) h2 {
|
||||||
|
color: var(--peach);
|
||||||
|
background: var(--surface-1);
|
||||||
|
background: color-mix(in srgb, var(--peach) 14%, transparent);
|
||||||
|
border-left: 4px solid var(--peach);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel:nth-of-type(5n+4) h2 {
|
||||||
|
color: var(--blue);
|
||||||
|
background: var(--surface-1);
|
||||||
|
background: color-mix(in srgb, var(--blue) 14%, transparent);
|
||||||
|
border-left: 4px solid var(--blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel:nth-of-type(5n+5) h2 {
|
||||||
|
color: var(--lavender);
|
||||||
|
background: var(--surface-1);
|
||||||
|
background: color-mix(in srgb, var(--lavender) 14%, transparent);
|
||||||
|
border-left: 4px solid var(--lavender);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel.minimized h2 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-toggle-btn {
|
||||||
|
display: flex !important;
|
||||||
|
align-items: center !important;
|
||||||
|
justify-content: space-between !important;
|
||||||
|
width: 100% !important;
|
||||||
|
min-width: 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
border: none !important;
|
||||||
|
background: transparent !important;
|
||||||
|
color: inherit !important;
|
||||||
|
font: inherit !important;
|
||||||
|
font-size: 1rem !important;
|
||||||
|
font-weight: inherit !important;
|
||||||
|
cursor: pointer !important;
|
||||||
|
text-align: left !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-toggle-btn > * {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-toggle-btn:focus-visible {
|
||||||
|
outline: 2px solid var(--lavender) !important;
|
||||||
|
outline-offset: 2px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-toggle-icon {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
margin-left: 8px;
|
||||||
|
color: var(--subtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel.minimized .panel-toggle-icon {
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-panel.minimized > *:not(h2) {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
.toolbar label,
|
.toolbar label,
|
||||||
.settings-panel label {
|
.settings-panel label {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -768,6 +964,221 @@ button:disabled {
|
|||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Entry form styling */
|
||||||
|
.entry-form {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry-form.hidden,
|
||||||
|
#auth-required.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#auth-required {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 16px;
|
||||||
|
background: var(--surface-0);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
border-left: 4px solid var(--red);
|
||||||
|
}
|
||||||
|
|
||||||
|
#auth-required p {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#auth-required a {
|
||||||
|
color: var(--lavender);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
#auth-required a:hover {
|
||||||
|
color: var(--mauve);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section {
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section label {
|
||||||
|
display: grid;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section > legend {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section input[type='url'],
|
||||||
|
.form-section input[type='text'],
|
||||||
|
.form-section textarea {
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: var(--mantle);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
color: var(--text);
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section textarea {
|
||||||
|
resize: vertical;
|
||||||
|
min-height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section input[type='url']:focus,
|
||||||
|
.form-section input[type='text']:focus,
|
||||||
|
.form-section textarea:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--lavender);
|
||||||
|
box-shadow: 0 0 0 3px rgba(180, 190, 254, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-options {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px 10px;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--mantle);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
color: var(--subtext);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-checkbox input {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section fieldset {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section fieldset legend {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section fieldset label {
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section fieldset input[type='text'] {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section fieldset input[type='checkbox'] {
|
||||||
|
width: auto;
|
||||||
|
margin-right: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr auto;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions button,
|
||||||
|
.form-actions a {
|
||||||
|
padding: 10px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions button[type='submit'],
|
||||||
|
#scrape-button:not(:disabled) {
|
||||||
|
background: var(--mauve);
|
||||||
|
border: 1px solid var(--mauve);
|
||||||
|
color: var(--crust);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions button[type='submit']:hover:not(:disabled) {
|
||||||
|
background: var(--lavender);
|
||||||
|
border-color: var(--lavender);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions button[type='submit']:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
#scrape-button {
|
||||||
|
background: var(--surface-1);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#scrape-button:not(:disabled):hover {
|
||||||
|
background: var(--surface-2);
|
||||||
|
border-color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#scrape-button:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions a {
|
||||||
|
background: var(--surface-1);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions a:hover {
|
||||||
|
background: var(--surface-2);
|
||||||
|
border-color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.success {
|
||||||
|
background: rgba(131, 165, 152, 0.2);
|
||||||
|
border: 1px solid var(--teal);
|
||||||
|
color: var(--teal);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.error {
|
||||||
|
background: rgba(243, 139, 168, 0.2);
|
||||||
|
border: 1px solid var(--red);
|
||||||
|
color: var(--red);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.container {
|
.container {
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
@@ -815,6 +1226,11 @@ button:disabled {
|
|||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-entry-button {
|
||||||
|
padding: 8px 11px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.logout-button {
|
.logout-button {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-11
@@ -11,18 +11,39 @@ async function loadAvailableThemes() {
|
|||||||
? localStorage.getItem(themePreference)
|
? localStorage.getItem(themePreference)
|
||||||
: themes[0]?.id;
|
: themes[0]?.id;
|
||||||
if (selected) document.documentElement.dataset.theme = selected;
|
if (selected) document.documentElement.dataset.theme = selected;
|
||||||
const headerActions = document.querySelector('.header-actions');
|
|
||||||
if (!headerActions || !themes.length) return;
|
const submenuContainer = document.querySelector('#theme-submenu-container');
|
||||||
const picker = document.createElement('select');
|
const themeOptions = document.querySelector('#theme-options');
|
||||||
picker.className = 'theme-picker';
|
const submenuTitle = document.querySelector('.submenu-title');
|
||||||
picker.setAttribute('aria-label', 'Theme');
|
|
||||||
picker.replaceChildren(...themes.map((theme) => new Option(theme.label, theme.id)));
|
if (!submenuContainer || !themeOptions || !themes.length) return;
|
||||||
picker.value = selected || themes[0].id;
|
|
||||||
picker.addEventListener('change', () => {
|
// Show the submenu container
|
||||||
localStorage.setItem(themePreference, picker.value);
|
submenuContainer.classList.remove('hidden');
|
||||||
document.documentElement.dataset.theme = picker.value;
|
|
||||||
|
// Create theme buttons
|
||||||
|
const buttons = themes.map((theme) => {
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.type = 'button';
|
||||||
|
button.className = 'theme-option';
|
||||||
|
button.dataset.themeId = theme.id;
|
||||||
|
button.textContent = theme.label;
|
||||||
|
if (theme.id === selected) {
|
||||||
|
button.classList.add('active');
|
||||||
|
}
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
localStorage.setItem(themePreference, theme.id);
|
||||||
|
document.documentElement.dataset.theme = theme.id;
|
||||||
|
// Update active state
|
||||||
|
document.querySelectorAll('.theme-option').forEach((btn) => {
|
||||||
|
btn.classList.remove('active');
|
||||||
});
|
});
|
||||||
headerActions.prepend(picker);
|
button.classList.add('active');
|
||||||
|
});
|
||||||
|
return button;
|
||||||
|
});
|
||||||
|
|
||||||
|
themeOptions.replaceChildren(...buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAvailableThemes();
|
loadAvailableThemes();
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<p>A quiet place for the links worth keeping.</p>
|
<p>A quiet place for the links worth keeping.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
<a id="auth-home-link" href="/">Home</a>
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
@@ -28,6 +29,10 @@
|
|||||||
<a id="auth-admin-link" class="hidden" href="/admin">Admin</a>
|
<a id="auth-admin-link" class="hidden" href="/admin">Admin</a>
|
||||||
<div id="auth-session" class="auth-session hidden"><a id="auth-username" class="user-name" href="/"></a></div>
|
<div id="auth-session" class="auth-session hidden"><a id="auth-username" class="user-name" href="/"></a></div>
|
||||||
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<p>Manage users and plugin configuration</p>
|
<p>Manage users and plugin configuration</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
<a id="auth-home-link" href="/">Home</a>
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
@@ -30,6 +31,10 @@
|
|||||||
<a id="auth-username" class="user-name" href="/"></a>
|
<a id="auth-username" class="user-name" href="/"></a>
|
||||||
</div>
|
</div>
|
||||||
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,8 +44,13 @@
|
|||||||
<main class="container">
|
<main class="container">
|
||||||
<p id="admin-auth-notice" class="auth-notice hidden"></p>
|
<p id="admin-auth-notice" class="auth-notice hidden"></p>
|
||||||
<div id="admin-controls" class="hidden">
|
<div id="admin-controls" class="hidden">
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Users</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Users</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<form id="user-form">
|
<form id="user-form">
|
||||||
<label>
|
<label>
|
||||||
Username
|
Username
|
||||||
@@ -64,16 +74,31 @@
|
|||||||
<div id="user-list" class="plugin-list" aria-live="polite">Loading users...</div>
|
<div id="user-list" class="plugin-list" aria-live="polite">Loading users...</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Plugins</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Plugins</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<div id="plugin-list" class="plugin-list" aria-live="polite">Loading plugins...</div>
|
<div id="plugin-list" class="plugin-list" aria-live="polite">Loading plugins...</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Labels</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Labels</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<div id="admin-label-list" class="plugin-list" aria-live="polite">Loading labels...</div>
|
<div id="admin-label-list" class="plugin-list" aria-live="polite">Loading labels...</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>SMTP settings</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>SMTP settings</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<form id="smtp-form">
|
<form id="smtp-form">
|
||||||
<label>
|
<label>
|
||||||
SMTP host
|
SMTP host
|
||||||
@@ -104,11 +129,16 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Available themes</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Available themes</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<p>Choose the themes visitors may use.</p>
|
<p>Choose the themes visitors may use.</p>
|
||||||
<form id="themes-form">
|
<form id="themes-form">
|
||||||
<div id="theme-options" class="theme-options" aria-live="polite">Loading themes...</div>
|
<div id="admin-theme-options" class="theme-options" aria-live="polite">Loading themes...</div>
|
||||||
<button type="submit">Save themes</button>
|
<button type="submit">Save themes</button>
|
||||||
<p id="theme-status" class="status" role="status"></p>
|
<p id="theme-status" class="status" role="status"></p>
|
||||||
</form>
|
</form>
|
||||||
@@ -119,6 +149,6 @@
|
|||||||
<script src="/static/auth-header.js?v=3"></script>
|
<script src="/static/auth-header.js?v=3"></script>
|
||||||
<script src="/static/logout.js?v=2"></script>
|
<script src="/static/logout.js?v=2"></script>
|
||||||
<script src="/static/theme.js?v=1"></script>
|
<script src="/static/theme.js?v=1"></script>
|
||||||
<script src="/static/admin.js?v=5"></script>
|
<script src="/static/admin.js?v=7"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="header-tools">
|
<div class="header-tools">
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
<a id="auth-home-link" href="/">Home</a>
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
@@ -30,6 +31,10 @@
|
|||||||
<a id="auth-username" class="user-name" href="/"></a>
|
<a id="auth-username" class="user-name" href="/"></a>
|
||||||
</div>
|
</div>
|
||||||
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<section class="toolbar">
|
<section class="toolbar">
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<p>Manage your link labels</p>
|
<p>Manage your link labels</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
<a id="auth-home-link" href="/">Home</a>
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
@@ -28,6 +29,10 @@
|
|||||||
<a id="auth-admin-link" class="hidden" href="/admin">Admin</a>
|
<a id="auth-admin-link" class="hidden" href="/admin">Admin</a>
|
||||||
<div id="auth-session" class="auth-session hidden"><a id="auth-username" class="user-name" href="/"></a></div>
|
<div id="auth-session" class="auth-session hidden"><a id="auth-username" class="user-name" href="/"></a></div>
|
||||||
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<p>Access your LinkLog settings</p>
|
<p>Access your LinkLog settings</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
<a id="auth-home-link" href="/">Home</a>
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
@@ -29,6 +30,10 @@
|
|||||||
<a id="auth-username" class="user-name" href="/"></a>
|
<a id="auth-username" class="user-name" href="/"></a>
|
||||||
</div>
|
</div>
|
||||||
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!-- Copyright © 2026 Olaf Kolkman -->
|
||||||
|
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>New Entry - LinkLog</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="stylesheet" href="/static/style.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="site-header">
|
||||||
|
<div class="container">
|
||||||
|
<div class="header-row">
|
||||||
|
<div>
|
||||||
|
<img class="site-logo" src="/static/logo.svg" alt="LinkLog" />
|
||||||
|
<p>New Entry</p>
|
||||||
|
</div>
|
||||||
|
<div class="header-tools">
|
||||||
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
|
<a id="auth-about-link" href="/about">About</a>
|
||||||
|
<a id="auth-login-button" href="/login">Sign in</a>
|
||||||
|
<a id="auth-profile-link" class="hidden" href="/profile">Profile</a>
|
||||||
|
<a id="auth-labels-link" class="hidden" href="/labels">Labels</a>
|
||||||
|
<a id="auth-admin-link" class="hidden" href="/admin">Admin</a>
|
||||||
|
<div id="auth-session" class="auth-session hidden">
|
||||||
|
<a id="auth-username" class="user-name" href="/"></a>
|
||||||
|
</div>
|
||||||
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container">
|
||||||
|
<div id="auth-required" class="error-message hidden">
|
||||||
|
<p>You must be signed in to create a new entry. <a href="/login">Sign in here</a>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="entry-form" class="entry-form hidden">
|
||||||
|
<div class="form-section">
|
||||||
|
<label>
|
||||||
|
<span>URL</span>
|
||||||
|
<input id="url-input" name="url" type="url" required placeholder="https://example.com" />
|
||||||
|
</label>
|
||||||
|
<button id="scrape-button" class="secondary" type="button">Auto-fill Title</button>
|
||||||
|
<div id="scrape-status" class="status hidden" aria-live="polite"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<label>
|
||||||
|
<span>Title</span>
|
||||||
|
<input id="title-input" name="title" type="text" required />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<label>
|
||||||
|
<span>Comment</span>
|
||||||
|
<textarea id="comment-input" name="comment" rows="4" placeholder="Optional comment about this link"></textarea>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset class="form-section">
|
||||||
|
<legend>Tags</legend>
|
||||||
|
<div id="existing-tags" class="tag-options"></div>
|
||||||
|
<label>
|
||||||
|
<span>Add new tags</span>
|
||||||
|
<input id="new-tags-input" type="text" pattern="#[^, ]+(,\s*#[^, ]+)*" placeholder="#tag1, #tag2" />
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="form-section">
|
||||||
|
<legend>Mastodon Publishing</legend>
|
||||||
|
<label>
|
||||||
|
<input id="mastodon-enabled" type="checkbox" />
|
||||||
|
Post to Mastodon (if configured)
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<button id="submit-button" type="submit">Save Entry</button>
|
||||||
|
<a href="/" class="secondary button">Cancel</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="submit-status" class="status hidden" aria-live="polite"></div>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="site-footer">
|
||||||
|
<span>Copyright © 2026 Olaf Kolkman</span> · <a href="https://git.kolkman.org/olaf/Link-Log">Repository</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="/static/auth-header.js"></script>
|
||||||
|
<script src="/static/new-entry.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<h1>Profile</h1>
|
<h1>Profile</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<button id="new-entry-button" class="new-entry-button hidden" type="button"><a href="/new-entry">New entry</a></button>
|
||||||
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="auth-menu">Menu</button>
|
||||||
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
<nav id="auth-menu" class="auth-menu hidden" aria-label="Account menu">
|
||||||
<a id="auth-home-link" href="/">Home</a>
|
<a id="auth-home-link" href="/">Home</a>
|
||||||
@@ -31,6 +32,10 @@
|
|||||||
<a id="auth-username" class="user-name" href="/"></a>
|
<a id="auth-username" class="user-name" href="/"></a>
|
||||||
</div>
|
</div>
|
||||||
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
<button id="logout-button" class="logout-button hidden" type="button">Sign out</button>
|
||||||
|
<div id="theme-submenu-container" class="theme-submenu-container hidden">
|
||||||
|
<button type="button" class="submenu-title" aria-expanded="false" aria-controls="theme-options">Themes</button>
|
||||||
|
<div id="theme-options" class="submenu-options hidden"></div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -38,8 +43,13 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="container">
|
<main class="container">
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Profile Settings</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Profile Settings</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<form id="profile-form">
|
<form id="profile-form">
|
||||||
<label>
|
<label>
|
||||||
Username
|
Username
|
||||||
@@ -64,8 +74,13 @@
|
|||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Email addresses</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Email addresses</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<div id="email-address-list" class="email-address-list" aria-live="polite">Loading email addresses...</div>
|
<div id="email-address-list" class="email-address-list" aria-live="polite">Loading email addresses...</div>
|
||||||
<form id="additional-email-form">
|
<form id="additional-email-form">
|
||||||
<label>
|
<label>
|
||||||
@@ -77,8 +92,13 @@
|
|||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Password</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Password</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<form id="password-form">
|
<form id="password-form">
|
||||||
<label>
|
<label>
|
||||||
Current password
|
Current password
|
||||||
@@ -97,8 +117,13 @@
|
|||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>One-time password</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>One-time password</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<p>Use an authenticator app to add a second sign-in step.</p>
|
<p>Use an authenticator app to add a second sign-in step.</p>
|
||||||
<div id="otp-disabled">
|
<div id="otp-disabled">
|
||||||
<button id="otp-setup" type="button">Set up one-time password</button>
|
<button id="otp-setup" type="button">Set up one-time password</button>
|
||||||
@@ -126,8 +151,13 @@
|
|||||||
<p id="otp-status" class="status" role="status"></p>
|
<p id="otp-status" class="status" role="status"></p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="link-item settings-panel">
|
<section class="link-item settings-panel minimized">
|
||||||
<h2>Mastodon</h2>
|
<h2>
|
||||||
|
<button type="button" class="panel-toggle-btn" aria-expanded="false">
|
||||||
|
<span>Mastodon</span>
|
||||||
|
<span class="panel-toggle-icon" aria-hidden="true">▼</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
<form id="mastodon-form">
|
<form id="mastodon-form">
|
||||||
<label>
|
<label>
|
||||||
Mastodon server
|
Mastodon server
|
||||||
@@ -150,7 +180,7 @@
|
|||||||
<script src="/static/auth-header.js?v=3"></script>
|
<script src="/static/auth-header.js?v=3"></script>
|
||||||
<script src="/static/logout.js?v=2"></script>
|
<script src="/static/logout.js?v=2"></script>
|
||||||
<script src="/static/theme.js?v=1"></script>
|
<script src="/static/theme.js?v=1"></script>
|
||||||
<script src="/static/profile.js?v=5"></script>
|
<script src="/static/profile.js?v=6"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1.0"
|
"version": "0.1.1"
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB |
@@ -11,6 +11,7 @@ from pathlib import Path
|
|||||||
ROOT = Path(__file__).resolve().parents[2]
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
SETTINGS_PATH = ROOT / 'backend' / 'app' / 'core' / 'config.py'
|
SETTINGS_PATH = ROOT / 'backend' / 'app' / 'core' / 'config.py'
|
||||||
SIGNED_DIR = ROOT / 'XPI' / 'signed'
|
SIGNED_DIR = ROOT / 'XPI' / 'signed'
|
||||||
|
MANIFEST_PATH = ROOT / 'webextension' / 'manifest.json'
|
||||||
VERSION_RE = re.compile(r'\d+\.\d+\.\d+')
|
VERSION_RE = re.compile(r'\d+\.\d+\.\d+')
|
||||||
|
|
||||||
|
|
||||||
@@ -43,6 +44,12 @@ def main() -> None:
|
|||||||
fail(f'backend version {backend_version} is not a valid three-part version')
|
fail(f'backend version {backend_version} is not a valid three-part version')
|
||||||
|
|
||||||
extension_version, xpi_path = find_latest_signed_xpi()
|
extension_version, xpi_path = find_latest_signed_xpi()
|
||||||
|
source_manifest = json.loads(MANIFEST_PATH.read_text())
|
||||||
|
if source_manifest.get('version') != extension_version:
|
||||||
|
fail(
|
||||||
|
f'webextension/manifest.json version {source_manifest.get("version")!r} does not match '
|
||||||
|
f'the latest signed XPI version {extension_version!r}'
|
||||||
|
)
|
||||||
with zipfile.ZipFile(xpi_path) as archive:
|
with zipfile.ZipFile(xpi_path) as archive:
|
||||||
try:
|
try:
|
||||||
packaged_manifest = json.loads(archive.read('manifest.json'))
|
packaged_manifest = json.loads(archive.read('manifest.json'))
|
||||||
|
|||||||
Reference in New Issue
Block a user