Compare commits
10
Commits
71f4451b34
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b89d12769c | ||
|
|
370a91b23b | ||
|
|
24c4753093 | ||
|
|
17c72f89bf | ||
|
|
a372b9dcc4 | ||
|
|
77dcf5c9bd | ||
|
|
a6db9f1566 | ||
|
|
0700967c30 | ||
|
|
0e04c583a6 | ||
|
|
443aff8323 |
+3
-1
@@ -10,7 +10,7 @@ APP_HEALTHCHECK_RETRIES=3
|
|||||||
LINKLOG_APP_NAME=LinkLog
|
LINKLOG_APP_NAME=LinkLog
|
||||||
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=300
|
||||||
LINKLOG_REFRESH_TOKEN_EXPIRY_DAYS=30
|
LINKLOG_REFRESH_TOKEN_EXPIRY_DAYS=30
|
||||||
LINKLOG_PUBLIC_URL=linklog.example.com
|
LINKLOG_PUBLIC_URL=linklog.example.com
|
||||||
LINKLOG_SMTP_HOST=
|
LINKLOG_SMTP_HOST=
|
||||||
@@ -23,6 +23,8 @@ LINKLOG_EMAIL_VERIFICATION_EXPIRY_HOURS=24
|
|||||||
LINKLOG_PASSWORD_RESET_EXPIRY_HOURS=1
|
LINKLOG_PASSWORD_RESET_EXPIRY_HOURS=1
|
||||||
LINKLOG_MASTODON_CLIENT_NAME=LinkLog
|
LINKLOG_MASTODON_CLIENT_NAME=LinkLog
|
||||||
LINKLOG_MASTODON_OAUTH_EXPIRY_MINUTES=10
|
LINKLOG_MASTODON_OAUTH_EXPIRY_MINUTES=10
|
||||||
|
# Warn on the New Entry page when the assembled post would exceed this many characters (Mastodon's default limit is 500).
|
||||||
|
LINKLOG_MAX_POST_CHARACTERS=500
|
||||||
LINKLOG_LOG_LEVEL=INFO
|
LINKLOG_LOG_LEVEL=INFO
|
||||||
# Optional comma-separated override. Leave empty to use the built-in list.
|
# Optional comma-separated override. Leave empty to use the built-in list.
|
||||||
LINKLOG_TRACKING_PARAMS=
|
LINKLOG_TRACKING_PARAMS=
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
## Version v0.3.1
|
||||||
|
### Features
|
||||||
|
### Fixed
|
||||||
|
* Made the feed profile summary visually distinct with a contrasting background and slightly smaller text
|
||||||
|
### Modification
|
||||||
|
* Made the feed profile summary collapsible under a subdued `:profile` title
|
||||||
|
|
||||||
## Version v0.3.0
|
## Version v0.3.0
|
||||||
### Features
|
### Features
|
||||||
* Implemented toolbar search functionality, using Google-like syntax (implicit AND, quoted phrases, `OR`, `-` exclusions, and the `site:` operator)
|
* Implemented toolbar search functionality, using Google-like syntax (implicit AND, quoted phrases, `OR`, `-` exclusions, and the `site:` operator)
|
||||||
* The feed now loads a user-selectable number of entries per page (default 25, configurable via `LINKLOG_FRONTEND_LOADPOSTS`) with Previous/Next and numbered page navigation
|
* The feed now loads a user-selectable number of entries per page (default 25, configurable via `LINKLOG_FRONTEND_LOADPOSTS`) with Previous/Next and numbered page navigation
|
||||||
* Moved tag/user filtering, search, and sorting to the backend, so the feed API returns only the matching, paginated results
|
* Moved tag/user filtering, search, and sorting to the backend, so the feed API returns only the matching, paginated results
|
||||||
|
* The New Entry page shows a live character count and warns when the assembled post would exceed the configurable `LINKLOG_MAX_POST_CHARACTERS` limit (default 500), to help avoid failed Mastodon posts
|
||||||
|
* The Firefox extension popup now shows the same live character count and over-limit warning as the New Entry page (version 0.3.0)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* Restored tag and user filtering on the feed: the decorative header arc no longer intercepts clicks on the filter dropdowns
|
* Restored tag and user filtering on the feed: the decorative header arc no longer intercepts clicks on the filter dropdowns
|
||||||
@@ -15,6 +24,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Version v0.2.0
|
## Version v0.2.0
|
||||||
### Features
|
### Features
|
||||||
* Users can edit or delete labels created by themselves on the labels page
|
* Users can edit or delete labels created by themselves on the labels page
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
# LinkLog Privacy and Fingerprinting
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This document describes the privacy and fingerprinting characteristics of the LinkLog web service and Firefox extension as implemented in this repository. It is a source-code assessment, not a legal privacy policy, penetration test, or guarantee about a particular deployment.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
LinkLog does not contain explicit canvas, WebGL, audio, font, hardware, timezone, analytics, or third-party advertising fingerprinting code. Its main privacy risk is different: LinkLog is designed to publish link activity, and that activity can form a highly distinctive identity profile.
|
||||||
|
|
||||||
|
A deployment operator, public visitor, upstream website, Mastodon instance, or network observer may be able to correlate a user through the data and request patterns described below.
|
||||||
|
|
||||||
|
## Fingerprinting and Correlation Risks
|
||||||
|
|
||||||
|
### Public activity and identity profile
|
||||||
|
|
||||||
|
The public feed exposes usernames, profile avatars, bios, exact creation timestamps, titles, original URLs, comments, tags, and whether an entry was posted to Mastodon. Public user enumeration and per-user feed URLs make it easy to collect this information for a particular account.
|
||||||
|
|
||||||
|
A sequence of saved links, topics, tags, timestamps, writing style, and referenced websites can be distinctive enough to associate a LinkLog account with activity on other services. This is a high privacy risk for users who expect saved links to be private.
|
||||||
|
|
||||||
|
Relevant implementation: `backend/app/api/public.py` and `backend/app/services/link_service.py`.
|
||||||
|
|
||||||
|
### URL and query-parameter leakage
|
||||||
|
|
||||||
|
LinkLog removes a configurable list of common advertising and analytics parameters, including `utm_*`, `gclid`, `fbclid`, and several vendor-specific parameters. This reduces routine campaign tracking but does not make URLs anonymous.
|
||||||
|
|
||||||
|
Other query parameters, path segments, fragments that are retained by the URL cleaner, document identifiers, search terms, access codes, repository names, and user-specific URLs may still identify a person or expose sensitive information. Operators should treat saved URLs, comments, titles, and tags as potentially personal data.
|
||||||
|
|
||||||
|
The tracking-parameter list is configured through `LINKLOG_TRACKING_PARAMS`; changing it can also change the URL-normalization behavior of a deployment.
|
||||||
|
|
||||||
|
### Firefox extension website activity
|
||||||
|
|
||||||
|
The extension uses `activeTab` and requests optional HTTP/HTTPS host permissions for the configured LinkLog backend. When a user saves a page, the extension reads the active page's URL and title and sends the selected data to that backend.
|
||||||
|
|
||||||
|
The extension therefore handles website activity by design. A malicious or compromised configured backend could receive the URLs that users submit, and a user can disclose sensitive page URLs by saving them. The extension stores the backend URL and username in local extension storage and keeps session credentials in Firefox session storage.
|
||||||
|
|
||||||
|
Relevant implementation: `webextension/manifest.json`, `webextension/popup.js`, and `webextension/options.js`.
|
||||||
|
|
||||||
|
### Mastodon and external-service correlation
|
||||||
|
|
||||||
|
When enabled, the Mastodon plugin publishes the link title, comment, tags, source URL, and a UTC timestamp to the configured Mastodon instance. Posts include a recognizable `User-Agent: LinkLog/1.0` in server-to-server requests. The resulting public Mastodon post can link the user's LinkLog identity, interests, and activity times to a Mastodon account.
|
||||||
|
|
||||||
|
The plugin also makes LinkLog activity observable to the configured Mastodon server, including the instance connection and publication time.
|
||||||
|
|
||||||
|
Relevant implementation: `backend/app/services/plugin_manager.py`.
|
||||||
|
|
||||||
|
### Server-side URL fetching
|
||||||
|
|
||||||
|
The authenticated scrape endpoint fetches a user-provided URL from the LinkLog server to obtain a page title. The target website may see the LinkLog server's network address and request characteristics rather than the user's browser address. This creates server-side attribution and may reveal that a URL was submitted to LinkLog.
|
||||||
|
|
||||||
|
### Deployment fingerprinting
|
||||||
|
|
||||||
|
A deployment may be distinguishable through its public version, FastAPI/OpenAPI metadata, static asset version parameters, enabled themes, feed page sizes, maximum post length, response headers, health endpoint, public hostname, and extension update metadata. These signals generally identify an installation or software version rather than a person, but they can assist cross-site correlation and targeted attack reconnaissance.
|
||||||
|
|
||||||
|
The public configuration endpoint intentionally returns feed page sizes and the maximum post-character limit. The application also exposes `/health`, and the README documents `/docs` and OpenAPI access. Production operators should decide which of these should remain public.
|
||||||
|
|
||||||
|
### Authentication and account-state observation
|
||||||
|
|
||||||
|
Login throttling, response status differences, verification state, reset-mail behavior, response timing, and refresh-token behavior can reveal limited information about account state to a party able to make repeated requests. Current login errors are mostly generic, but verified and unverified account paths still differ, and failed login handling may trigger password-reset mail for known verified accounts when SMTP is configured.
|
||||||
|
|
||||||
|
Client IP handling and throttling are also deployment-sensitive. In a multi-instance deployment, the current SQLite-based limiter does not provide a shared, atomic privacy or abuse-control boundary.
|
||||||
|
|
||||||
|
## Recommended Mitigations
|
||||||
|
|
||||||
|
Prioritize these changes for privacy-sensitive or public deployments:
|
||||||
|
|
||||||
|
1. Make feeds and links private by default, with explicit per-link or per-profile publication controls.
|
||||||
|
2. Make public user enumeration and profile indexing opt-in, and consider requiring authentication for user lists and private feeds.
|
||||||
|
3. Strip or allow-list URL query parameters and warn users before saving URLs that contain credentials, access codes, search terms, or other sensitive identifiers.
|
||||||
|
4. Offer privacy controls for avatars, bios, tags, comments, exact timestamps, and original URLs; consider timestamp coarsening for public entries.
|
||||||
|
5. Minimize extension permissions and clearly disclose that saving a page sends its URL and title to the configured backend. Keep backend origin permissions restricted to the configured origin.
|
||||||
|
6. Make Mastodon publication an explicit opt-in, show the complete data that will be published, and allow users to disable URL and timestamp inclusion.
|
||||||
|
7. Protect or disable `/docs`, `/openapi.json`, detailed health/configuration endpoints, version disclosures, and unnecessary response metadata in production.
|
||||||
|
8. Use uniform authentication responses and timing where practical, independently throttle password-reset mail, and use a shared atomic rate limiter such as Redis for multi-instance deployments.
|
||||||
|
9. Configure strict security headers, trusted hosts, HTTPS, log retention, and access controls. Do not log authorization headers, tokens, passwords, OTP values, or secret-bearing URLs.
|
||||||
|
10. Document retention, deletion, backup, and export behavior for links, profiles, audit records, avatars, tokens, and server logs.
|
||||||
|
|
||||||
|
## User Guidance
|
||||||
|
|
||||||
|
Do not save private document links, password-reset URLs, invitation URLs, access tokens, or URLs containing sensitive query parameters to a public feed. Review titles, comments, tags, timestamps, and the Mastodon preview before publishing. Use a private deployment and disable Mastodon integration when the link history itself is sensitive.
|
||||||
|
|
||||||
|
## Assessment Limits
|
||||||
|
|
||||||
|
This document reflects the repository implementation reviewed on 2026-09-16. Reverse-proxy settings, browser privacy settings, database access, server logs, deployment networking, dependencies, and third-party Mastodon behavior can materially change the effective risk. A production deployment should supplement this review with configuration review, dependency and container scanning, authenticated dynamic tests, and a retention/access-control review.
|
||||||
@@ -279,6 +279,12 @@ Add authenticated admin/user configuration
|
|||||||
### Assistant outcome
|
### Assistant outcome
|
||||||
Added shared bearer-token dependencies, protected user configuration endpoints, restricted plugin administration to administrator accounts, and changed user configuration to use the authenticated user's ID instead of hard-coded `user-1`. The seeded `alice` account is an administrator for development and `bob` remains a standard user. README authentication guidance was added, and the strict backend suite passed with 8 tests.
|
Added shared bearer-token dependencies, protected user configuration endpoints, restricted plugin administration to administrator accounts, and changed user configuration to use the authenticated user's ID instead of hard-coded `user-1`. The seeded `alice` account is an administrator for development and `bob` remains a standard user. README authentication guidance was added, and the strict backend suite passed with 8 tests.
|
||||||
|
|
||||||
|
### User
|
||||||
|
What are the fingerprinting risks of this system?
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Reviewed the public feed, authentication and link APIs, frontend, Firefox extension, Mastodon integration, configuration, and existing security audit. Identified high privacy risk from public link and profile metadata, plus medium risks from deployment/configuration fingerprinting, extension website activity, external-request attribution, and observable authentication behavior. No code changes were made.
|
||||||
|
|
||||||
### User
|
### User
|
||||||
Make sure the link-log page is responsive
|
Make sure the link-log page is responsive
|
||||||
|
|
||||||
@@ -1592,4 +1598,34 @@ Make it so that <nav id=pagination> at the bottom of the page doesn't exceed the
|
|||||||
|
|
||||||
### Assistant outcome
|
### Assistant outcome
|
||||||
Made the pagination bar wrap within the page width (`max-width: 100%`, `overflow-x: auto`) and toned down its styling to ghost-style buttons with smaller padding/font and muted colors instead of solid backgrounds. Verified the updated CSS is served correctly from a rebuilt local container.
|
Made the pagination bar wrap within the page width (`max-width: 100%`, `overflow-x: auto`) and toned down its styling to ghost-style buttons with smaller padding/font and muted colors instead of solid backgrounds. Verified the updated CSS is served correctly from a rebuilt local container.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Make sure the CHANGELOG reflects all changes since commit 74b2c400c6
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Reviewed the commit log and working-tree diff since `74b2c400c6` and updated the `v0.3.0` section of `CHANGELOG.MD` with the missing user-facing entries: toolbar search, server-side feed pagination, backend-side filtering, the Firefox search-input width fix, the search/tag toolbar reorder, the Mastodon "Logged on <date> from:" UTC timestamp change, and the pagination control's visual/overflow fix. Also fixed an unrelated pre-existing bug in `frontend/version.json` (a missing closing quote made it invalid JSON, silently falling back to version `0.0.0`).
|
||||||
|
|
||||||
|
### User
|
||||||
|
Add a skill to maintain the changelog.md
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Added `.github/skills/changelog-maintenance/SKILL.md`, modeled on the existing `vibe-logging` skill, describing when and how to append concise, user-facing bullets to the current unreleased `## Version` section of `CHANGELOG.MD` (Features/Fixed/Modification), when to bump `frontend/version.json`, and which changes are out of scope (internal-only docs, dev scripts, test-only fixes).
|
||||||
|
|
||||||
|
### User
|
||||||
|
In the new-entry form, provide a warning when the total ammount of characters is over LINKLOG_MAX_POST_CHARACTERS=500 (also indicat the number of characters used/500 count). This is to prevent Mastodon posts from failing - so all characters should be counted.
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Added a `LINKLOG_MAX_POST_CHARACTERS` setting (default 500) exposed via `GET /api/public/config`. The New Entry page now shows a live `used/limit characters` counter that recalculates on every relevant input (title, URL, comment, tags, checkbox toggles) by assembling the estimated Mastodon post text the same way the backend's Mastodon plugin does, and switches to a warning style when the limit is exceeded. Verified with the full backend test suite (56 passed) and a live smoke test of `/api/public/config` and the rendered New Entry page.
|
||||||
|
|
||||||
|
### User
|
||||||
|
Implement the same functionality in the firefox plugin
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Added the same live character-count warning to the Firefox extension popup: it fetches `/api/public/config` for the limit and the user's `/api/user/plugins/mastodon` post prefix, estimates the assembled Mastodon post length the same way as the New Entry page and backend plugin, and shows a localized `used/limit characters` counter (with an over-limit warning message) that updates on every relevant input and tag toggle. Added the `characterCount`/`characterCountOverLimit` translations to all five locale files (en-US, de, es, fr, nl) and verified all locale JSON files parse and `popup.js` passes a Node syntax check.
|
||||||
# Chat Log
|
# Chat Log
|
||||||
|
|
||||||
|
### User
|
||||||
|
Add these findings and recomendations to Privacy.md
|
||||||
|
|
||||||
|
### Assistant outcome
|
||||||
|
Created `Privacy.md` with a source-grounded privacy and fingerprinting assessment covering public activity correlation, URL and query-parameter leakage, Firefox extension website activity, Mastodon correlation, server-side URL fetching, deployment fingerprinting, authentication observability, user guidance, and prioritized mitigations. Validated the document contents; no runtime code was changed.
|
||||||
|
|||||||
@@ -278,6 +278,7 @@
|
|||||||
248. Release script fails because the runner's hashlib module has no file_digest attribute.
|
248. Release script fails because the runner's hashlib module has no file_digest attribute.
|
||||||
249. The filtering on tags does not work. When I click on the button I cannot select. Remember that any visitor on the site should be able to filter the tag for the link-feed.
|
249. The filtering on tags does not work. When I click on the button I cannot select. Remember that any visitor on the site should be able to filter the tag for the link-feed.
|
||||||
250. Update VIBE and Changelog
|
250. Update VIBE and Changelog
|
||||||
|
251. What are the fingerprinting risks of this system?
|
||||||
|
|
||||||
## 2026-08-30
|
## 2026-08-30
|
||||||
|
|
||||||
@@ -311,6 +312,14 @@ The default selection is 25 with additional choices of 100 and 250 (to be config
|
|||||||
|
|
||||||
If the user uses the filters and/or search in the toolbox then those should limit the entries the server presents, so the filters and search are applied on the server side.
|
If the user uses the filters and/or search in the toolbox then those should limit the entries the server presents, so the filters and search are applied on the server side.
|
||||||
258. Make it so that <nav id=pagination> at the bottom of the page doesn't exceed the page width and is less visually dominant
|
258. Make it so that <nav id=pagination> at the bottom of the page doesn't exceed the page width and is less visually dominant
|
||||||
|
259. Make sure the CHANGELOG reflects all changes since commit 74b2c400c6
|
||||||
|
260. Add a skill to maintain the changelog.md
|
||||||
|
261. In the new-entry form, provide a warning when the total ammount of characters is over LINKLOG_MAX_POST_CHARACTERS=500 (also indicat the number of characters used/500 count). This is to prevent Mastodon posts from failing - so all characters should be counted.
|
||||||
|
262. Implement the same functionality in the firefox plugin
|
||||||
|
|
||||||
|
## 2026-09-16
|
||||||
|
|
||||||
|
263. Add these findings and recomendations to Privacy.md
|
||||||
|
|
||||||
## Future entries
|
## Future entries
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -28,7 +28,11 @@ def public_themes():
|
|||||||
|
|
||||||
@router.get('/config')
|
@router.get('/config')
|
||||||
def public_config():
|
def public_config():
|
||||||
return {'feed_page_sizes': settings.feed_page_sizes, 'default_page_size': settings.feed_page_sizes[0]}
|
return {
|
||||||
|
'feed_page_sizes': settings.feed_page_sizes,
|
||||||
|
'default_page_size': settings.feed_page_sizes[0],
|
||||||
|
'max_post_characters': settings.max_post_characters,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.get('/feed')
|
@router.get('/feed')
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class Settings:
|
|||||||
password_reset_expiry_hours: int = int(os.getenv('LINKLOG_PASSWORD_RESET_EXPIRY_HOURS', '1'))
|
password_reset_expiry_hours: int = int(os.getenv('LINKLOG_PASSWORD_RESET_EXPIRY_HOURS', '1'))
|
||||||
mastodon_client_name: str = os.getenv('LINKLOG_MASTODON_CLIENT_NAME', 'LinkLog')
|
mastodon_client_name: str = os.getenv('LINKLOG_MASTODON_CLIENT_NAME', 'LinkLog')
|
||||||
mastodon_oauth_expiry_minutes: int = int(os.getenv('LINKLOG_MASTODON_OAUTH_EXPIRY_MINUTES', '10'))
|
mastodon_oauth_expiry_minutes: int = int(os.getenv('LINKLOG_MASTODON_OAUTH_EXPIRY_MINUTES', '10'))
|
||||||
|
max_post_characters: int = int(os.getenv('LINKLOG_MAX_POST_CHARACTERS', '500'))
|
||||||
log_level: str = os.getenv('LINKLOG_LOG_LEVEL', 'INFO').upper()
|
log_level: str = os.getenv('LINKLOG_LOG_LEVEL', 'INFO').upper()
|
||||||
tracking_params: list[str] = None
|
tracking_params: list[str] = None
|
||||||
feed_page_sizes: list[int] = None
|
feed_page_sizes: list[int] = None
|
||||||
|
|||||||
@@ -16,11 +16,14 @@
|
|||||||
const refetchTitleButton = document.getElementById('refetch-title-button');
|
const refetchTitleButton = document.getElementById('refetch-title-button');
|
||||||
const submitButton = document.getElementById('submit-button');
|
const submitButton = document.getElementById('submit-button');
|
||||||
const submitStatus = document.getElementById('submit-status');
|
const submitStatus = document.getElementById('submit-status');
|
||||||
|
const characterCount = document.getElementById('character-count');
|
||||||
|
|
||||||
const token = localStorage.getItem('linklogAccessToken');
|
const token = localStorage.getItem('linklogAccessToken');
|
||||||
let availableTags = [];
|
let availableTags = [];
|
||||||
let selectedTags = new Set();
|
let selectedTags = new Set();
|
||||||
let currentUser = null;
|
let currentUser = null;
|
||||||
|
let maxPostCharacters = 500;
|
||||||
|
let mastodonPostPrefix = 'From my #LinkLog: ';
|
||||||
|
|
||||||
// Utility function to add status messages; splits on \n into real <br> line breaks without using innerHTML.
|
// Utility function to add status messages; splits on \n into real <br> line breaks without using innerHTML.
|
||||||
function setStatus(statusEl, message, isError = false) {
|
function setStatus(statusEl, message, isError = false) {
|
||||||
@@ -53,7 +56,7 @@
|
|||||||
.then((user) => {
|
.then((user) => {
|
||||||
currentUser = user;
|
currentUser = user;
|
||||||
entryForm.classList.remove('hidden');
|
entryForm.classList.remove('hidden');
|
||||||
Promise.all([loadTags(), loadMastodonPublishing()]);
|
Promise.all([loadTags(), loadMastodonPublishing(), loadConfig()]).then(updateCharacterCount);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
localStorage.removeItem('linklogAccessToken');
|
localStorage.removeItem('linklogAccessToken');
|
||||||
@@ -61,6 +64,17 @@
|
|||||||
entryForm.classList.add('hidden');
|
entryForm.classList.add('hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function loadConfig() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/public/config');
|
||||||
|
if (!response.ok) throw new Error('Could not load config');
|
||||||
|
const config = await response.json();
|
||||||
|
if (config.max_post_characters) maxPostCharacters = config.max_post_characters;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Could not load config:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load available tags
|
// Load available tags
|
||||||
async function loadTags() {
|
async function loadTags() {
|
||||||
try {
|
try {
|
||||||
@@ -82,11 +96,63 @@
|
|||||||
const config = await response.json();
|
const config = await response.json();
|
||||||
mastodonEnabledCheckbox.checked = Boolean(config.configured);
|
mastodonEnabledCheckbox.checked = Boolean(config.configured);
|
||||||
mastodonPublishing.classList.toggle('hidden', !config.configured);
|
mastodonPublishing.classList.toggle('hidden', !config.configured);
|
||||||
|
if (config.post_prefix) {
|
||||||
|
mastodonPostPrefix = config.post_prefix;
|
||||||
|
} else if (config.hashtag) {
|
||||||
|
mastodonPostPrefix = `#${String(config.hashtag).trim().replace(/^#/, '')} `;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Could not load Mastodon configuration:', error);
|
console.error('Could not load Mastodon configuration:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collect the selected checkbox tags plus any typed new tags, mirroring the submit-time logic.
|
||||||
|
function collectTags() {
|
||||||
|
const tags = Array.from(selectedTags);
|
||||||
|
const newTags = newTagsInput.value.trim();
|
||||||
|
if (newTags) {
|
||||||
|
tags.push(...newTags.split(',').map((t) => t.trim()).filter(Boolean));
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format a UTC timestamp the same way the Mastodon plugin does, so the estimated post length matches the server.
|
||||||
|
function formatMastodonTimestamp(date) {
|
||||||
|
const months = [
|
||||||
|
'January', 'February', 'March', 'April', 'May', 'June',
|
||||||
|
'July', 'August', 'September', 'October', 'November', 'December',
|
||||||
|
];
|
||||||
|
const pad = (value) => String(value).padStart(2, '0');
|
||||||
|
return `${date.getUTCFullYear()} ${months[date.getUTCMonth()]} ${pad(date.getUTCDate())} - ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Estimate the assembled Mastodon post length, mirroring backend/app/services/plugin_manager.py.
|
||||||
|
function estimatePostLength() {
|
||||||
|
const title = titleInput.value.trim();
|
||||||
|
const comment = commentInput.value.trim();
|
||||||
|
const url = removeKnownTrackingParams(urlInput.value.trim());
|
||||||
|
const parts = [mastodonPostPrefix.trim()];
|
||||||
|
if (title) parts.push(title);
|
||||||
|
if (comment) parts.push(comment);
|
||||||
|
if (title) parts.push(`Logged on ${formatMastodonTimestamp(new Date())} UTC from: ${url}`);
|
||||||
|
const tags = collectTags();
|
||||||
|
if (tags.length) parts.push(tags.join(' '));
|
||||||
|
return parts.join('\n\n').length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCharacterCount() {
|
||||||
|
const length = estimatePostLength();
|
||||||
|
const overLimit = length > maxPostCharacters;
|
||||||
|
characterCount.textContent = overLimit
|
||||||
|
? `${length}/${maxPostCharacters} characters - exceeds the Mastodon post limit by ${length - maxPostCharacters}`
|
||||||
|
: `${length}/${maxPostCharacters} characters`;
|
||||||
|
characterCount.classList.toggle('over-limit', overLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
[urlInput, titleInput, commentInput, newTagsInput].forEach((input) => {
|
||||||
|
input.addEventListener('input', updateCharacterCount);
|
||||||
|
});
|
||||||
|
|
||||||
// Render tag checkboxes
|
// Render tag checkboxes
|
||||||
function renderTags() {
|
function renderTags() {
|
||||||
existingTagsEl.innerHTML = '';
|
existingTagsEl.innerHTML = '';
|
||||||
@@ -104,6 +170,7 @@
|
|||||||
} else {
|
} else {
|
||||||
selectedTags.delete(tag);
|
selectedTags.delete(tag);
|
||||||
}
|
}
|
||||||
|
updateCharacterCount();
|
||||||
});
|
});
|
||||||
|
|
||||||
label.appendChild(checkbox);
|
label.appendChild(checkbox);
|
||||||
@@ -224,22 +291,13 @@
|
|||||||
const url = removeKnownTrackingParams(urlInput.value.trim());
|
const url = removeKnownTrackingParams(urlInput.value.trim());
|
||||||
const title = titleInput.value.trim();
|
const title = titleInput.value.trim();
|
||||||
const comment = commentInput.value.trim();
|
const comment = commentInput.value.trim();
|
||||||
const newTags = newTagsInput.value.trim();
|
|
||||||
|
|
||||||
if (!url || !title) {
|
if (!url || !title) {
|
||||||
setStatus(submitStatus, 'URL and title are required', true);
|
setStatus(submitStatus, 'URL and title are required', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combine selected tags and new tags
|
const tags = collectTags();
|
||||||
const tags = Array.from(selectedTags);
|
|
||||||
if (newTags) {
|
|
||||||
const newTagsList = newTags
|
|
||||||
.split(',')
|
|
||||||
.map((t) => t.trim())
|
|
||||||
.filter((t) => t);
|
|
||||||
tags.push(...newTagsList);
|
|
||||||
}
|
|
||||||
|
|
||||||
submitButton.disabled = true;
|
submitButton.disabled = true;
|
||||||
setStatus(submitStatus, 'Saving...', false);
|
setStatus(submitStatus, 'Saving...', false);
|
||||||
|
|||||||
@@ -847,6 +847,11 @@ button:disabled {
|
|||||||
border-top: 1px solid var(--border);
|
border-top: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-form textarea {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.edit-tags {
|
.edit-tags {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@@ -941,6 +946,21 @@ button:disabled {
|
|||||||
box-shadow: var(--shadow);
|
box-shadow: var(--shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile-summary summary {
|
||||||
|
color: var(--subtext);
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-summary[open] summary {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-summary-content {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
.about-content {
|
.about-content {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
@@ -1007,6 +1027,7 @@ button:disabled {
|
|||||||
.profile-summary p {
|
.profile-summary p {
|
||||||
margin: 12px 0 0;
|
margin: 12px 0 0;
|
||||||
color: var(--subtext);
|
color: var(--subtext);
|
||||||
|
font-size: 0.95rem;
|
||||||
line-height: 1.65;
|
line-height: 1.65;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1242,6 +1263,18 @@ button:disabled {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.char-count {
|
||||||
|
margin: -8px 0 0;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 0.82rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.char-count.over-limit {
|
||||||
|
color: var(--red);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.container {
|
.container {
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<section class="link-item">
|
<section class="link-item">
|
||||||
<h2>Plugin</h2>
|
<h2>Plugin</h2>
|
||||||
<p>Install the Firefox plugin to save links directly from your browser. <a
|
<p>Install the Firefox plugin to save links directly from your browser. <a
|
||||||
href="https://git.kolkman.org/olaf/Link-Log/raw/branch/main/XPI/signed/LinkLog-0.2.0.xpi"
|
href="https://git.kolkman.org/olaf/Link-Log/raw/branch/main/XPI/signed/LinkLog-0.3.0.xpi"
|
||||||
download>Download and install the Plugin</a>.</p>
|
download>Download and install the Plugin</a>.</p>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -57,14 +57,14 @@
|
|||||||
<option value="">All users</option>
|
<option value="">All users</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="search-control">
|
|
||||||
Search
|
|
||||||
<input id="search-input" type="search" placeholder="Search links" autocomplete="off" aria-label="Search links" />
|
|
||||||
</label>
|
|
||||||
<label>
|
<label>
|
||||||
Per page
|
Per page
|
||||||
<select id="page-size-select"></select>
|
<select id="page-size-select"></select>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="search-control">
|
||||||
|
Search
|
||||||
|
<input id="search-input" type="search" placeholder="Search links" autocomplete="off" aria-label="Search links" />
|
||||||
|
</label>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -73,19 +73,22 @@
|
|||||||
|
|
||||||
<main class="container">
|
<main class="container">
|
||||||
{% if profile %}
|
{% if profile %}
|
||||||
<section class="link-item profile-summary">
|
<details class="link-item profile-summary">
|
||||||
<div class="link-header">
|
<summary>Profile</summary>
|
||||||
<div class="avatar">
|
<div class="profile-summary-content">
|
||||||
{% if profile.avatar_url %}
|
<div class="link-header">
|
||||||
<img src="{{ profile.avatar_url }}" alt="{{ profile.username }} avatar" />
|
<div class="avatar">
|
||||||
{% else %}
|
{% if profile.avatar_url %}
|
||||||
{{ profile.username[:1].upper() }}
|
<img src="{{ profile.avatar_url }}" alt="{{ profile.username }} avatar" />
|
||||||
{% endif %}
|
{% else %}
|
||||||
|
{{ profile.username[:1].upper() }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="user-name">{{ profile.username }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="user-name">{{ profile.username }}</div>
|
<p>{{ profile.bio or 'No profile information provided.' }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p>{{ profile.bio or 'No profile information provided.' }}</p>
|
</details>
|
||||||
</section>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<section id="feed" class="feed" aria-live="polite"></section>
|
<section id="feed" class="feed" aria-live="polite"></section>
|
||||||
<nav id="pagination" class="pagination" aria-label="Feed pages"></nav>
|
<nav id="pagination" class="pagination" aria-label="Feed pages"></nav>
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
<textarea id="comment-input" name="comment" rows="4" placeholder="Optional comment about this link"></textarea>
|
<textarea id="comment-input" name="comment" rows="4" placeholder="Optional comment about this link"></textarea>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="character-count" class="char-count" aria-live="polite">0/500 characters</div>
|
||||||
|
|
||||||
<fieldset class="form-section">
|
<fieldset class="form-section">
|
||||||
<legend>Tags</legend>
|
<legend>Tags</legend>
|
||||||
@@ -89,6 +90,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button id="submit-button" type="submit">Save Entry</button>
|
<button id="submit-button" type="submit">Save Entry</button>
|
||||||
<a href="/" class="secondary button">Cancel</a>
|
<a href="/" class="secondary button">Cancel</a>
|
||||||
@@ -103,6 +105,6 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="/static/auth-header.js"></script>
|
<script src="/static/auth-header.js"></script>
|
||||||
<script src="/static/new-entry.js?v=8"></script>
|
<script src="/static/new-entry.js?v=9"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -53,5 +53,7 @@
|
|||||||
"loginFailed": {"message": "Anmeldung fehlgeschlagen"},
|
"loginFailed": {"message": "Anmeldung fehlgeschlagen"},
|
||||||
"loggedInSuccessfully": {"message": "Erfolgreich angemeldet"},
|
"loggedInSuccessfully": {"message": "Erfolgreich angemeldet"},
|
||||||
"unableToLogIn": {"message": "Anmeldung nicht möglich. Überprüfe Backend-URL und Zugangsdaten."},
|
"unableToLogIn": {"message": "Anmeldung nicht möglich. Überprüfe Backend-URL und Zugangsdaten."},
|
||||||
"signedOut": {"message": "Abgemeldet"}
|
"signedOut": {"message": "Abgemeldet"},
|
||||||
|
"characterCount": {"message": "$USED$/$LIMIT$ Zeichen", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}}},
|
||||||
|
"characterCountOverLimit": {"message": "$USED$/$LIMIT$ Zeichen - überschreitet das Mastodon-Beitragslimit um $OVER$", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}, "over": {"content": "$3"}}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,5 +181,30 @@
|
|||||||
},
|
},
|
||||||
"signedOut": {
|
"signedOut": {
|
||||||
"message": "Signed out"
|
"message": "Signed out"
|
||||||
|
},
|
||||||
|
"characterCount": {
|
||||||
|
"message": "$USED$/$LIMIT$ characters",
|
||||||
|
"placeholders": {
|
||||||
|
"used": {
|
||||||
|
"content": "$1"
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"content": "$2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"characterCountOverLimit": {
|
||||||
|
"message": "$USED$/$LIMIT$ characters - exceeds the Mastodon post limit by $OVER$",
|
||||||
|
"placeholders": {
|
||||||
|
"used": {
|
||||||
|
"content": "$1"
|
||||||
|
},
|
||||||
|
"limit": {
|
||||||
|
"content": "$2"
|
||||||
|
},
|
||||||
|
"over": {
|
||||||
|
"content": "$3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,5 +53,7 @@
|
|||||||
"loginFailed": {"message": "Error de inicio de sesión"},
|
"loginFailed": {"message": "Error de inicio de sesión"},
|
||||||
"loggedInSuccessfully": {"message": "Sesión iniciada correctamente"},
|
"loggedInSuccessfully": {"message": "Sesión iniciada correctamente"},
|
||||||
"unableToLogIn": {"message": "No se pudo iniciar sesión. Comprueba la URL y las credenciales."},
|
"unableToLogIn": {"message": "No se pudo iniciar sesión. Comprueba la URL y las credenciales."},
|
||||||
"signedOut": {"message": "Sesión cerrada"}
|
"signedOut": {"message": "Sesión cerrada"},
|
||||||
|
"characterCount": {"message": "$USED$/$LIMIT$ caracteres", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}}},
|
||||||
|
"characterCountOverLimit": {"message": "$USED$/$LIMIT$ caracteres: supera el límite de publicación de Mastodon en $OVER$", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}, "over": {"content": "$3"}}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,5 +53,7 @@
|
|||||||
"loginFailed": {"message": "Échec de la connexion"},
|
"loginFailed": {"message": "Échec de la connexion"},
|
||||||
"loggedInSuccessfully": {"message": "Connexion réussie"},
|
"loggedInSuccessfully": {"message": "Connexion réussie"},
|
||||||
"unableToLogIn": {"message": "Connexion impossible. Vérifiez l’URL du serveur et vos identifiants."},
|
"unableToLogIn": {"message": "Connexion impossible. Vérifiez l’URL du serveur et vos identifiants."},
|
||||||
"signedOut": {"message": "Déconnecté"}
|
"signedOut": {"message": "Déconnecté"},
|
||||||
|
"characterCount": {"message": "$USED$/$LIMIT$ caractères", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}}},
|
||||||
|
"characterCountOverLimit": {"message": "$USED$/$LIMIT$ caractères : dépasse la limite de publication Mastodon de $OVER$", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}, "over": {"content": "$3"}}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,5 +53,7 @@
|
|||||||
"loginFailed": {"message": "Inloggen mislukt"},
|
"loginFailed": {"message": "Inloggen mislukt"},
|
||||||
"loggedInSuccessfully": {"message": "Succesvol ingelogd"},
|
"loggedInSuccessfully": {"message": "Succesvol ingelogd"},
|
||||||
"unableToLogIn": {"message": "Inloggen mislukt. Controleer de backend-URL en inloggegevens."},
|
"unableToLogIn": {"message": "Inloggen mislukt. Controleer de backend-URL en inloggegevens."},
|
||||||
"signedOut": {"message": "Uitgelogd"}
|
"signedOut": {"message": "Uitgelogd"},
|
||||||
|
"characterCount": {"message": "$USED$/$LIMIT$ tekens", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}}},
|
||||||
|
"characterCountOverLimit": {"message": "$USED$/$LIMIT$ tekens - overschrijdt de Mastodon-postlimiet met $OVER$", "placeholders": {"used": {"content": "$1"}, "limit": {"content": "$2"}, "over": {"content": "$3"}}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "__MSG_extensionName__",
|
"name": "__MSG_extensionName__",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"description": "__MSG_extensionDescription__",
|
"description": "__MSG_extensionDescription__",
|
||||||
"default_locale": "en-US",
|
"default_locale": "en-US",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|||||||
@@ -149,6 +149,18 @@ button {
|
|||||||
color: #f38ba8;
|
color: #f38ba8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.char-count {
|
||||||
|
margin: -6px 0 10px;
|
||||||
|
color: #a6adc8;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.char-count.over-limit {
|
||||||
|
color: #f38ba8;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
.auth-session {
|
.auth-session {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
border: 1px solid #585b70;
|
border: 1px solid #585b70;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
<span data-i18n="commentLabel">Comment</span>
|
<span data-i18n="commentLabel">Comment</span>
|
||||||
<textarea id="comment" name="comment" rows="3" data-i18n-placeholder="commentPlaceholder" placeholder="Your comment"></textarea>
|
<textarea id="comment" name="comment" rows="3" data-i18n-placeholder="commentPlaceholder" placeholder="Your comment"></textarea>
|
||||||
</label>
|
</label>
|
||||||
|
<div id="character-count" class="char-count" aria-live="polite"></div>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend data-i18n="tagsLabel">Tags</legend>
|
<legend data-i18n="tagsLabel">Tags</legend>
|
||||||
|
|||||||
+82
-1
@@ -14,10 +14,14 @@ const authWarning = document.getElementById('auth-warning');
|
|||||||
const warningSettingsButton = document.getElementById('warning-settings');
|
const warningSettingsButton = document.getElementById('warning-settings');
|
||||||
const authSession = document.getElementById('auth-session');
|
const authSession = document.getElementById('auth-session');
|
||||||
const refetchTitleButton = document.getElementById('refetch-title');
|
const refetchTitleButton = document.getElementById('refetch-title');
|
||||||
|
const characterCountEl = document.getElementById('character-count');
|
||||||
const sessionStore = browser.storage.session;
|
const sessionStore = browser.storage.session;
|
||||||
|
|
||||||
const t = window.linklogI18n;
|
const t = window.linklogI18n;
|
||||||
|
|
||||||
|
let maxPostCharacters = 500;
|
||||||
|
let mastodonPostPrefix = 'From my #LinkLog: ';
|
||||||
|
|
||||||
function normalizeBackendOrigin(backendUrl) {
|
function normalizeBackendOrigin(backendUrl) {
|
||||||
try {
|
try {
|
||||||
const url = new URL(backendUrl);
|
const url = new URL(backendUrl);
|
||||||
@@ -192,9 +196,11 @@ async function loadExistingTags() {
|
|||||||
const checkbox = document.createElement('input');
|
const checkbox = document.createElement('input');
|
||||||
checkbox.type = 'checkbox';
|
checkbox.type = 'checkbox';
|
||||||
checkbox.value = tag;
|
checkbox.value = tag;
|
||||||
|
checkbox.addEventListener('change', updateCharacterCount);
|
||||||
label.append(checkbox, document.createTextNode(` ${tag}`));
|
label.append(checkbox, document.createTextNode(` ${tag}`));
|
||||||
return label;
|
return label;
|
||||||
}));
|
}));
|
||||||
|
updateCharacterCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTags() {
|
function getTags() {
|
||||||
@@ -203,6 +209,79 @@ function getTags() {
|
|||||||
return [...new Set([...selected, ...newTags])].slice(0, 10);
|
return [...new Set([...selected, ...newTags])].slice(0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load public app settings (e.g. the Mastodon post length limit) once a backend is configured.
|
||||||
|
async function loadConfig() {
|
||||||
|
const settings = await getSettings();
|
||||||
|
if (!settings.backendUrl || !(await hasBackendPermission(settings.backendUrl))) return;
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${settings.backendUrl}/api/public/config`);
|
||||||
|
if (!response.ok) return;
|
||||||
|
const config = await response.json();
|
||||||
|
if (config.max_post_characters) maxPostCharacters = config.max_post_characters;
|
||||||
|
} catch (error) {
|
||||||
|
// Character-count warning is advisory; ignore config load failures.
|
||||||
|
}
|
||||||
|
updateCharacterCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the user's configured Mastodon post prefix, so the estimated post length matches the server.
|
||||||
|
async function loadMastodonPrefix() {
|
||||||
|
const settings = await getSettings();
|
||||||
|
if (!settings.backendUrl || !settings.accessToken || !(await hasBackendPermission(settings.backendUrl))) return;
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${settings.backendUrl}/api/user/plugins/mastodon`, {
|
||||||
|
headers: {'Authorization': `Bearer ${settings.accessToken}`},
|
||||||
|
});
|
||||||
|
if (!response.ok) return;
|
||||||
|
const config = await response.json();
|
||||||
|
if (config.post_prefix) {
|
||||||
|
mastodonPostPrefix = config.post_prefix;
|
||||||
|
} else if (config.hashtag) {
|
||||||
|
mastodonPostPrefix = `#${String(config.hashtag).trim().replace(/^#/, '')} `;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Character-count warning is advisory; ignore config load failures.
|
||||||
|
}
|
||||||
|
updateCharacterCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format a UTC timestamp the same way the Mastodon plugin does, so the estimated post length matches the server.
|
||||||
|
function formatMastodonTimestamp(date) {
|
||||||
|
const months = [
|
||||||
|
'January', 'February', 'March', 'April', 'May', 'June',
|
||||||
|
'July', 'August', 'September', 'October', 'November', 'December',
|
||||||
|
];
|
||||||
|
const pad = (value) => String(value).padStart(2, '0');
|
||||||
|
return `${date.getUTCFullYear()} ${months[date.getUTCMonth()]} ${pad(date.getUTCDate())} - ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Estimate the assembled Mastodon post length, mirroring backend/app/services/plugin_manager.py.
|
||||||
|
function estimatePostLength() {
|
||||||
|
const title = titleInput.value.trim();
|
||||||
|
const comment = commentInput.value.trim();
|
||||||
|
const url = removeKnownTrackingParams(urlInput.value.trim());
|
||||||
|
const parts = [mastodonPostPrefix.trim()];
|
||||||
|
if (title) parts.push(title);
|
||||||
|
if (comment) parts.push(comment);
|
||||||
|
if (title) parts.push(`Logged on ${formatMastodonTimestamp(new Date())} UTC from: ${url}`);
|
||||||
|
const tags = getTags();
|
||||||
|
if (tags.length) parts.push(tags.join(' '));
|
||||||
|
return parts.join('\n\n').length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCharacterCount() {
|
||||||
|
const length = estimatePostLength();
|
||||||
|
const overLimit = length > maxPostCharacters;
|
||||||
|
characterCountEl.textContent = overLimit
|
||||||
|
? t('characterCountOverLimit', [String(length), String(maxPostCharacters), String(length - maxPostCharacters)])
|
||||||
|
: t('characterCount', [String(length), String(maxPostCharacters)]);
|
||||||
|
characterCountEl.classList.toggle('over-limit', overLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
[titleInput, urlInput, commentInput, newTagsInput].forEach((input) => {
|
||||||
|
input.addEventListener('input', updateCharacterCount);
|
||||||
|
});
|
||||||
|
|
||||||
function removeKnownTrackingParams(urlString) {
|
function removeKnownTrackingParams(urlString) {
|
||||||
try {
|
try {
|
||||||
const url = new URL(urlString);
|
const url = new URL(urlString);
|
||||||
@@ -361,6 +440,8 @@ refetchTitleButton.addEventListener('click', (e) => {
|
|||||||
titleInput.value = '';
|
titleInput.value = '';
|
||||||
fetchTitle(url, { force: true });
|
fetchTitle(url, { force: true });
|
||||||
});
|
});
|
||||||
populateCurrentTab().then(checkExistingLink);
|
populateCurrentTab().then(checkExistingLink).then(updateCharacterCount);
|
||||||
loadExistingTags();
|
loadExistingTags();
|
||||||
updateFeedLink();
|
updateFeedLink();
|
||||||
|
loadConfig();
|
||||||
|
loadMastodonPrefix();
|
||||||
|
|||||||
@@ -2,6 +2,16 @@
|
|||||||
"addons": {
|
"addons": {
|
||||||
"linklog@kolkman.org": {
|
"linklog@kolkman.org": {
|
||||||
"updates": [
|
"updates": [
|
||||||
|
{
|
||||||
|
"version": "0.3.0",
|
||||||
|
"update_link": "https://git.kolkman.org/olaf/Link-Log/raw/branch/main/XPI/signed/LinkLog-0.3.0.xpi",
|
||||||
|
"update_hash": "sha256:c4cc16a7e96885caa759c803dca90dd43fdf0befc43457655f6eeb6fd51a4e7f",
|
||||||
|
"applications": {
|
||||||
|
"gecko": {
|
||||||
|
"strict_min_version": "142.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"update_link": "https://git.kolkman.org/olaf/Link-Log/raw/branch/main/XPI/signed/LinkLog-0.2.0.xpi",
|
"update_link": "https://git.kolkman.org/olaf/Link-Log/raw/branch/main/XPI/signed/LinkLog-0.2.0.xpi",
|
||||||
|
|||||||
Reference in New Issue
Block a user