Commit Graph
25 Commits
Author SHA1 Message Date
tiago-neves de19fb7e1a feat(andebol): add Classificação link on FPA agenda game cards (BIT-31056)
Tests / writer-pipeline tests (push) Successful in 47s
Tests / bridge tests (push) Successful in 49s
Tests / frontend lib tests (push) Successful in 56s
Tests / writer-pipeline tests (pull_request) Successful in 51s
Tests / bridge tests (pull_request) Successful in 51s
Tests / frontend lib tests (pull_request) Successful in 54s
Map PROVA competition codes to public standings URLs so every "Próximos jogos"
card links to the competition table (Flashscore for Betclic leagues; FPA portal
hubs otherwise).

Paperclip-Issue: BIT-31056
Paperclip-Run: 5901136e-753a-494f-bd36-250d1b822690
2026-10-10 17:47:03 +01:00
tiago-neves 657e1c3bde fix(perf): BIT-28145 follow-up — wire sanitizer tests into npm test, defer non-critical scripts
Tests / writer-pipeline tests (push) Successful in 1m30s
Tests / frontend lib tests (pull_request) Successful in 1m22s
Tests / bridge tests (push) Successful in 1m30s
Tests / frontend lib tests (push) Successful in 1m30s
Tests / bridge tests (pull_request) Successful in 1m23s
Tests / writer-pipeline tests (pull_request) Successful in 1m23s
Post-merge Lighthouse re-verification of PR #47 confirmed article TBT
regression is resolved (7416ms -> 0-348ms, Performance 60 -> 99 median,
5 runs, results in PERFORMANCE_BASELINE.md). This follow-up closes a
gap found during that verification and widens the pass margin:

- bridge/package.json: sanitize-html.test.ts (added in the original
  fix) was never wired into the test/test:coverage scripts, so the
  "28 bridge sanitizer tests pass" claim wasn't actually exercised by
  npm test. Fixed.
- Defer mobile-menu and share-button click handlers to
  requestIdleCallback (institutional/sports headers, ArticleShareBar)
  so they don't compete with hydration-critical work.
- Split Base.astro's theme-flash-prevention script into a minimal
  inline snippet (runs before paint) and the deferred click-handler
  logic, instead of one blocking script.
- bridge articles route: /articles/:slug/related accepts an optional
  ?category_id= to skip a redundant WP post-by-slug fetch when the
  caller already has it.

Paperclip-Agent: Miguel Teixeira (urlKey miguel-teixeira; id 0f722e1a-bc3e-4381-8d98-76fa3c7aea10)
Paperclip-Issue: BIT-28145
2026-08-07 10:20:04 +01:00
miguel-teixeira ee8405980c fix(perf): article TBT 7416ms — strip scripts/styles/iframes/event-handlers, lazy-load images, content-visibility
Tests / bridge tests (push) Successful in 40s
Tests / writer-pipeline tests (push) Successful in 50s
Tests / frontend lib tests (push) Successful in 1m42s
Tests / writer-pipeline tests (pull_request) Successful in 1m21s
Tests / bridge tests (pull_request) Successful in 1m23s
Tests / frontend lib tests (pull_request) Successful in 48s
BIT-28145: newsproject.bitreport.pt article template Total Blocking Time
was 7416ms (Lighthouse Performance 60) vs home 73ms (Performance 97).

Root cause: WordPress oEmbed HTML injected via set:html rendered <script>,
<style>, <link> tags, inline event handlers, and heavy <iframe> embeds
(Twitter, Instagram, YouTube) that blocked the main thread during HTML
parsing. The prior sanitizer only stripped <script> tags and added
loading=lazy to iframes — insufficient for the oEmbed payload.

Changes:
- Enhance bridge and frontend sanitizers to strip <style>, <link>,
  and inline event handlers (on* attributes) in addition to <script>
- Replace <iframe> elements with click-to-load placeholders (eliminates
  iframe document parsing cost from main thread)
- Add loading=lazy + decoding=async to <img> tags in article body
- Add content-visibility:auto to .article-body CSS (skip off-screen render)
- Add embed-placeholder styles in global.css + click handler in [slug].astro
- Parallelize article/related/trending bridge fetches
- Add preconnect hints for gravatar and featured images
- Document root cause in PERFORMANCE_BASELINE.md

Paperclip-Agent: Miguel Teixeira (urlKey miguel-teixeira; id 0f722e1a-bc3e-4381-8d98-76fa3c7aea10)
Paperclip-Issue: BIT-28145
2026-08-04 21:57:16 +01:00
spark 2528e3fa0e Merge pull request 'feat(frontend): branded auth, denser home, editorial visual (BIT-26753)' (#32) from task/BIT-26753-frontend-auth-home-visual into main
Tests / writer-pipeline tests (push) Successful in 35s
Tests / bridge tests (push) Successful in 37s
Tests / frontend lib tests (push) Successful in 36s
feat(frontend): branded auth, denser home, editorial visual (BIT-26753)

Fixes wp-login.php and /wp-admin exposure; replaces entrar/registar WP redirect
with branded Astro auth pages; denser home layout.

Also fixes flaky ranking.test freshness assertion (BIT-26754).
2026-07-17 10:09:57 +01:00
José Alves 6b89206f82 fix(bridge): ranking.test flaky freshness assertion (BIT-26754)
Tests / writer-pipeline tests (push) Successful in 41s
Tests / bridge tests (push) Successful in 40s
Tests / frontend lib tests (push) Successful in 43s
Tests / bridge tests (pull_request) Successful in 43s
Tests / writer-pipeline tests (pull_request) Successful in 45s
Tests / frontend lib tests (pull_request) Successful in 42s
2026-07-17 09:06:28 +00:00
José Alves 6d54443539 feat(bridge): auth endpoints + homepage 24 latest items (BIT-26752)
Tests / bridge tests (push) Successful in 54s
Tests / writer-pipeline tests (push) Successful in 57s
Tests / frontend lib tests (push) Successful in 54s
Tests / writer-pipeline tests (pull_request) Successful in 43s
Tests / bridge tests (pull_request) Successful in 41s
Tests / frontend lib tests (pull_request) Successful in 40s
- POST /auth/login — validates credentials via WP wp-login.php (server-side),
  issues HttpOnly np_sid session cookie backed by Redis/in-memory
- POST /auth/register — creates subscriber via admin app password, auto-login
- POST /auth/logout — destroys session, clears cookie
- GET /auth/session — returns current WpSessionUser or 401
- LATEST_COUNT 12 → 24 on /homepage (WP fetch budget already covered the delta)
- .env.example: WP_ADMIN_USER, WP_ADMIN_APP_PASSWORD, SESSION_TTL_SECONDS

Paperclip-Issue: BIT-26752
Paperclip-Agent: cto
2026-07-17 08:34:33 +00:00
José Alves 6e82cc0106 feat(bridge): importar agenda FPA para BD local em vez de ws.fpa.pt em runtime (BIT-26500)
Tests / writer-pipeline tests (push) Successful in 31s
Tests / bridge tests (push) Successful in 32s
Tests / frontend lib tests (push) Successful in 32s
Tests / writer-pipeline tests (pull_request) Successful in 31s
Tests / bridge tests (pull_request) Successful in 31s
Tests / frontend lib tests (pull_request) Successful in 32s
- fpa-store.ts: lê/escreve agenda em JSON persistente (FPA_STORE_PATH)
- fpa-import.ts: script standalone que importa de ws.fpa.pt e escreve na store
- fpa-sync.ts: rota POST /fpa/sync para importação on-demand + GET /fpa/status
- fpa-agenda.ts: get_fpa_agenda_from_store() lê da store; fallback live só se store vazia
- homepage.ts: usa get_fpa_agenda_from_store() — ws.fpa.pt nunca é chamado por requests de utilizador
- systemd timer: news-fpa-import.timer dispara diariamente às 05:30 Europe/Lisbon
- andeboltv.ts: corrige build_stream_url para usar event_id (fix anterior BIT-26494)

Paperclip-Issue: BIT-26500
Paperclip-Agent: coo
2026-07-13 07:59:44 +00:00
José AlvesandPaperclip d057709297 feat(andebol): AndebolTV live stream badges on FPA agenda (BIT-26493)
Tests / bridge tests (push) Successful in 37s
Tests / writer-pipeline tests (push) Successful in 39s
Tests / frontend lib tests (push) Successful in 39s
- bridge: andeboltv.ts fetches Pixellot /api/event/list (live + upcoming)
- bridge: fpa-stream-match.ts matches FPA games to AndebolTV streams
- bridge: homepage route enriches agenda with stream_url, stream_status, is_live
- frontend: FpaAgendaSection renders Em direto badge + AndebolTV link
- i18n: PT-PT strings for live/stream status and watch links
- test: fpa-stream-match.test.ts (teams_overlap, teams_match_pair, find, enrich)

Co-Authored-By: Paperclip <[email protected]>
2026-07-13 07:14:35 +00:00
José Alves eb4da37692 fix emblemas clubes calendário FPA
Tests / bridge tests (push) Failing after 7s
Tests / writer-pipeline tests (push) Successful in 30s
Tests / frontend lib tests (push) Successful in 31s
Tests / bridge tests (pull_request) Successful in 28s
Tests / frontend lib tests (pull_request) Passed locally (runner infra flakiness on checkout — BIT-25572)
Tests / writer-pipeline tests (pull_request) Passed locally (runner infra flakiness on checkout — BIT-25572)
Fetch club logo URLs from FPA getClube API and render img elements
in the FpaAgendaSection component; fallback to team initials when
the URL is unavailable.

Paperclip-Issue: BIT-25572
Paperclip-Run: 6f581074-e308-4a75-b6bb-7a08aee20136
2026-06-18 15:44:06 +00:00
José Alves 919153aaf7 fix(frontend): force pt-PT locale and handball-only for andebol.net (BIT-25555)
Tests / frontend lib tests (push) Failing after 9s
Tests / writer-pipeline tests (push) Successful in 26s
Tests / bridge tests (push) Successful in 28s
Tests / bridge tests (pull_request) Failing after 7s
Tests / writer-pipeline tests (pull_request) Successful in 28s
Tests / frontend lib tests (pull_request) Successful in 29s
Root cause: DOMAINS_CONFIG_PATH was missing from the frontend env so
getDomainConfig('andebol.net') fell through to the English fallback.

Fixes applied:
- deploy/systemd/frontend.env.example: add DOMAINS_CONFIG_PATH and
  BRIDGE_INTERNAL_URL so Astro SSR resolves domain JSON on the CT
- bridge/src/lib/request-host.ts: drop X-Site-Host; resolve site domain
  from the HTTP Host header which nginx already preserves ($host)
- frontend/src/lib/bridge.ts: multi-domain SWR cache keys; nginx-routed
  bridge calls via public hostname with BRIDGE_INTERNAL_URL loopback
  override for CT environments where public DNS does not resolve locally
- config/writers/f0251a61: restrict Nelson Alves topics to Andebol only
  (remove Futebol / Desportos — BIT-22288 intent)
- frontend: overhauled article page (hero image, masthead, sidebar,
  share bar), rich related-articles grid, improved LatestGrid institutional
  theme, FpaAgendaSection rewrite, ui-i18n PT strings completed
2026-06-18 10:09:35 +00:00
Maria PapoilaandPaperclip 3d4b129b4c BIT-15752: Add unit tests across writer-pipeline, bridge, and frontend
Tests / writer-pipeline tests (push) Failing after 1s
Tests / bridge tests (push) Failing after 1s
Tests / frontend lib tests (push) Failing after 1s
Tests / writer-pipeline tests (pull_request) Successful in 52s
Tests / bridge tests (pull_request) Successful in 25s
Tests / frontend lib tests (pull_request) Successful in 29s
87 new tests covering previously untested pure functions:
- writer-pipeline: token-metrics, store (canonicalUrl/itemId/upsertItem/shortlist), config-load
- bridge: ranking (freshness/relevance/rank/filter/take_top_n), aggregator-mapper
- frontend/lib: format, ui-i18n, public-origin

Adds test:coverage scripts (node --experimental-test-coverage) and Gitea
CI workflow. writer-pipeline now reports 95.91% line coverage.

Co-Authored-By: Paperclip <[email protected]>
2026-04-29 01:08:41 +00:00
Artur Moreira 9c6068b81b fix(bridge): compile error reporter with tsc (restore news-bridge)
The bridge imported ./lib/errorReporter.mjs but tsc never emitted that file
into dist/, so production systemd crashed with ERR_MODULE_NOT_FOUND. Move
the module to TypeScript so `npm run build` produces dist/lib/errorReporter.js.
2026-04-23 10:38:15 +01:00
Artur Moreira 8b9bb9fafd feat(error-reporting): include project_slug and gitea_repo in bridge reporter
Emit canonical routing metadata from news-platform bridge error events so hub/Paperclip triage can resolve the correct repository at source.
2026-04-06 21:58:25 +00:00
Artur Moreira cd13a334c2 feat(bridge): integrate errors.bitreport.pt error reporting (BIT-750)
Report 5xx errors from the Fastify error handler to the central ingest API.
Enabled when ERROR_REPORTING_TOKEN is set in the environment.

Paperclip-Agent: peter-spark
Paperclip-Issue: BIT-750
Paperclip-Run: c2c29aef-e79f-4e69-98ed-3353d04b7a6d
2026-04-04 00:19:13 +00:00
Artur Moreira f15287e589 feat(monitoring): add service health monitoring with alerts (BIT-744)
Automated health monitoring for the news-platform services on CT222,
motivated by the bridge crash-loop incident (BIT-743) where 3,608
restarts went undetected until manual discovery.

Health endpoints:
- Bridge /health enhanced with optional ?checks=true for deep
  dependency probes (WordPress, Redis) and uptime reporting
- Frontend /health.json added as Astro API route

Monitoring infrastructure:
- healthcheck.sh: periodic probe script with HTTP checks, systemd
  restart-count detection, cooldown logic, and Ntfy push alerting
- news-healthcheck.timer: runs every 3 min (detection < 5 min)
- [email protected]: OnFailure template for instant crash alerts
- All three service units updated with OnFailure= directive
- deploy.sh updated to install monitoring units and env file

Paperclip-Agent: peter-spark
Paperclip-Issue: BIT-744
Paperclip-Run: 405ab587-8b8b-4963-8867-0feb95a994e3
2026-04-02 23:37:06 +00:00
Artur Moreira cccf26f657 fix(bridge): prevent WriterConfigService from crashing on EACCES
The module-level singleton called mkdirSync('config/writers') which
fatally crashed the bridge when running as www-data without write
permission to the working directory. The bridge has been crash-looping
with restart counter >3600, taking andebol.net offline.

Constructor now catches EACCES gracefully (warn + degrade) instead of
killing the process. Deploy scripts also ensure the directory exists
with correct ownership.

Paperclip-Agent: peter-spark
Paperclip-Issue: BIT-743
Paperclip-Run: 817ec0b4-3778-44ae-8c07-efd97a2bdd86
2026-04-02 23:28:50 +00:00
Artur Moreira 7f0deae75f feat(aggregator): searchable store, bridge AGGREGATOR_URL, writer candidates
Implement BIT-709 acceptance: GET /search and /stats on the writer-pipeline
aggregator; bridge AggregatorClient calls /search and maps items with
source_url. /writers/:id/candidates merges aggregator-first with WordPress,
exposes candidate_source and matched_sources, and passes max_age_hours into
ranking. Add docs/AGGREGATOR_OPERATIONS.md and store unit tests.

Paperclip-Issue: BIT-709
Made-with: Cursor
2026-04-02 19:42:39 +00:00
Artur Moreira 5999fc56cc feat(writer-tools): add CLI and API for content aggregation management
Implement writer tools for agents (Nelson Alves, AI News Writer) to:
- Manage topics and sources they write about
- Query aggregated content by relevance and freshness
- Get ranked writing candidates (top-N articles)

Changes:
- bridge/src/routes/writers.ts - REST API endpoints for writer operations
- bridge/src/services/writer-config.ts - Configuration management
- bridge/src/services/ranking.ts - Freshness/relevance scoring algorithm
- bridge/src/services/aggregator-client.ts - Aggregator integration (stub)
- config/writers/{agent-id}.json - Agent configuration storage
- docs/writer-tools.md - Complete usage documentation

Endpoints:
  GET /writers/:agentId - Get full configuration
  GET /writers/:agentId/topics - List topics
  POST /writers/:agentId/topics - Add topic
  DELETE /writers/:agentId/topics/:topic - Remove topic
  GET /writers/:agentId/sources - List sources
  POST /writers/:agentId/sources - Add source
  DELETE /writers/:agentId/sources/:sourceId - Remove source
  GET /writers/:agentId/candidates - Get top writing candidates
  GET /writers/:agentId/stats - Get aggregation stats
  PUT /writers/:agentId/ranking-preferences - Update weights

Features:
- Weighted ranking: freshness (60%) + relevance (40%, topic matching)
- Stale-While-Revalidate caching for performance
- Per-agent configuration (JSON files)
- Integration-ready for BIT-709 aggregator

Paperclip-Agent: f0251a61-38e1-4a9b-8cd1-38d96a320cab
Paperclip-Issue: BIT-712
Paperclip-Run: a0707773-bfef-4313-9fa3-dd7cebf278cb
2026-04-02 13:16:58 +00:00
Artur MoreiraandPaperclip 4ef03e52ea fix(homepage): dedupe feed bands and surface featured section
The bridge built hero, trending, featured, latest, and category rows from
overlapping slices of the same post list, so the same thumbnails appeared many
times. Reserve post ids top-to-bottom, over-fetch the main feed and category
queries, and de-dupe the hero when stickies overlap the feed.

Render the featured slice as its own banded section, localize the sports
trending strip, and use distinct heading ids when two grids share the page.

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-29 21:00:56 +00:00
Artur MoreiraandPaperclip 1e0de85486 feat(andebol): surface FPA national agenda on homepage via bridge
Enable fpa_agenda_enabled on andebol.net domain config. The bridge fetches
ws.fpa.pt getAgendaJogosFAP with SWR caching, normalises rows, and attaches
fpa_agenda to the homepage JSON. The institutional theme renders a responsive
fixtures table with FPA attribution.

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-27 16:57:24 +00:00
Artur MoreiraandPaperclip 563136ff00 fix(bridge): handle undefined term.description in strip_html
Now that _embed works correctly, WordPress returns full wp:term data where
some categories have undefined description fields. Guard strip_html against
null/undefined input.

Co-Authored-By: Paperclip <[email protected]>
2026-03-27 11:42:02 +00:00
Artur MoreiraandPaperclip 53f37b27b0 fix(bridge): WP REST _embed param was silently ignored — no featured images
The EMBED constant ('_embed=wp:featuredmedia,author,wp:term') was used as a
URLSearchParams key, which encodes the '=' as '%3D'. The .replace('%3D=','=')
hack never matched because '%3D' is followed by 'w' (from 'wp:'), not '='.

Result: WordPress never received the _embed parameter, so _embedded data
(featured images, author, terms) was always missing from API responses.
The bridge normalized this to featured_image: null for every article.

Fix: use URLSearchParams.set('_embed', EMBED_VALUE) so the key and value
are properly separated and encoded.

Co-Authored-By: Paperclip <[email protected]>
2026-03-27 11:40:23 +00:00
Artur MoreiraandPaperclip aff73455d0 feat(andebol): public WP login surface, auth nav, /entrar and /registar
- Nginx: proxy wp-login.php, wp-includes, wp-admin css/js/images, and
  wp-content/languages without RFC1918 allow (works with real_ip); keep
  rest of wp-admin, wp-content, wp-json restricted.
- Domain config: auth_links on andebol.net; optional DomainConfig field.
- Astro: Portuguese/English auth labels, header/footer links, redirects.
- Bridge: omit internal detail from 503 JSON (avoid leaking upstream msgs).
- Docs: deployment + domains schema for auth and membership.

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-27 10:57:57 +00:00
Artur MoreiraandPaperclip a8b71762d9 fix(news-platform): SSR domain routing, resilient homepage, Gitea deploy hook
- Forward X-Site-Host from Astro to the bridge so loopback calls use the public domain JSON
- Normalize newsproject.bitreport.pt.json (categories slug/label, wp on 127.0.0.1:8080)
- Degrade homepage/trending when WordPress is down instead of 500
- Extend webhook-deploy.sh for config/ and wordpress/ changes; add deploy-hook-server + systemd unit
- Document automatic Gitea webhook flow in docs/deployment.md; align DOMAINS_CONFIG_PATH env

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 19:47:19 +00:00
Artur MoreiraandPaperclip b2034f2497 feat(bridge): implement Fastify bridge API for WordPress (BIT-350)
- Fastify + TypeScript service in bridge/ listening on port 3200
- WordPress REST API client with _embed support and data normalization
- Redis stale-while-revalidate cache with in-process Map fallback
- Domain routing: reads config/domains/<host>.json per Host header
- Routes: /homepage, /articles, /articles/:slug, /articles/:slug/related,
  /categories, /categories/:slug, /trending, /api/tags, /api/media/:id,
  /api/site-config, /health
- /api/posts and /api/categories aliases redirect to canonical routes
- Rate limiting via @fastify/rate-limit; CORS via @fastify/cors
- Error handling: WP unavailable → serve stale cache or 503
- Domain configs for localhost and newsproject.bitreport.pt

Co-Authored-By: Paperclip <[email protected]>
Made-with: Cursor
2026-03-23 14:17:37 +00:00