Compare commits

..
Author SHA1 Message Date
José Alves ea9a7ad5d9 docs(deploy): add .env runtime preservation rules (BIT-25005)
Tests / writer-pipeline tests (push) Successful in 3m9s
Tests / bridge tests (push) Successful in 3m9s
Tests / frontend lib tests (push) Successful in 3m26s
Tests / writer-pipeline tests (pull_request) Successful in 3m16s
Tests / bridge tests (pull_request) Successful in 1m48s
Tests / frontend lib tests (pull_request) Successful in 1m40s
Propagate DEPLOY_STANDARD.md §3.1 to this repo: prohibit cp .env.example .env
over existing production .env, require rsync excludes, and mandate
PRODUCTION_ACCESS_SYNC_LOG entries for credential changes.

Paperclip-Task: BIT-25008
2026-06-11 15:37:19 +00:00
spark 8a330be214 Merge pull request 'feat(writer-pipeline): FPA featured-image backfill + media:content ingestion — BIT-24384' (#16) from feat/BIT-24389-backfill-featured-fpa into main
Tests / writer-pipeline tests (push) Successful in 32s
Tests / bridge tests (push) Successful in 31s
Tests / frontend lib tests (push) Successful in 34s
2026-06-05 03:31:09 +01:00
José Alves e08840af18 feat(writer-pipeline): FPA featured-image backfill + media:content ingestion — BIT-24384
Tests / writer-pipeline tests (push) Successful in 31s
Tests / bridge tests (push) Successful in 32s
Tests / frontend lib tests (push) Successful in 34s
Tests / writer-pipeline tests (pull_request) Successful in 28s
Tests / bridge tests (pull_request) Successful in 32s
Tests / frontend lib tests (pull_request) Successful in 31s
- Add backfill-featured-from-fpa.ts: matches andebol.net post slugs against
  FPA portal WP REST API and uploads featured images for matched posts
- Export attachFeaturedImageToPost from wp-publish.ts for reuse by backfill
- Add npm script backfill:featured for one-shot execution
- Extend RSS ingest to extract media:content and media:thumbnail fields
  (BIT-24388: FPA feed uses <media:content> for images, not <enclosure>)
- Update config/domains/andebol.net.json: wp_endpoint → public HTTPS URL
- Update docs; add pino-pretty dev dep to bridge

Backfill result (2026-06-05): 30 updated, 52 skipped (no FPA match), 0 errors.

Paperclip-Agent: José Alves (urlKey jos-alves; id 11179220-3cec-4f0f-880d-2771ff64fce8)
Paperclip-Issue: BIT-24389
2026-06-05 02:29:47 +00:00
spark fc1c9066b6 Merge pull request 'fix(docs): CT222 IP 10.10.50.140 → 10.10.50.204 static — BIT-24053' (#15) from fix/bit-24053-ct222-static-ip into main
Tests / writer-pipeline tests (push) Successful in 26s
Tests / bridge tests (push) Successful in 28s
Tests / frontend lib tests (push) Successful in 29s
2026-06-01 14:30:46 +01:00
José Alves cba153cfc1 fix(docs): update CT222 IP from 10.10.50.140 to 10.10.50.204 — BIT-24053
Tests / bridge tests (push) Successful in 29s
Tests / writer-pipeline tests (push) Successful in 30s
Tests / frontend lib tests (push) Successful in 31s
Tests / writer-pipeline tests (pull_request) Successful in 28s
Tests / bridge tests (pull_request) Successful in 28s
Tests / frontend lib tests (pull_request) Successful in 26s
CT222 news-project-test changed IP following DHCP re-lease (BIT-24050
emergency fix). IP is now static at 10.10.50.204 via systemd-networkd.
Update all doc references, deploy script post-install notes, and
wordpress/README direct-access URLs.

Paperclip-Agent: Tiago Neves (devops; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Paperclip-Issue: BIT-24053
Paperclip-Run: 9c69919d-4c21-48b0-8eb7-2b9745bed65c
2026-06-01 13:12:36 +00:00
spark 0e7897ba77 Merge pull request 'fix(nginx): add wp_andebol_content volume to nginx-andebol (BIT-23734)' (#14) from fix/BIT-23734-nginx-andebol-wp-content-volume into main
Tests / writer-pipeline tests (push) Successful in 39s
Tests / bridge tests (push) Successful in 38s
Tests / frontend lib tests (push) Successful in 37s
2026-05-26 00:32:35 +01:00
Tiago Neves 86261a1a54 fix(nginx): add wp_andebol_content volume to nginx-andebol (BIT-23734)
Tests / writer-pipeline tests (push) Successful in 50s
Tests / bridge tests (push) Successful in 1m3s
Tests / frontend lib tests (push) Successful in 1m3s
Tests / bridge tests (pull_request) Successful in 1m11s
Tests / writer-pipeline tests (pull_request) Successful in 1m14s
Tests / frontend lib tests (pull_request) Successful in 1m9s
nginx-andebol was missing the wp_andebol_content volume mount, causing
uploaded files to return 404 even though they were written correctly to
the wp_andebol_content Docker volume by the WordPress PHP-FPM container.

Paperclip-Task: BIT-23734
Paperclip-Agent: devops
2026-05-25 23:25:52 +00:00
spark 0c9e5df61c Merge pull request 'feat(writer-pipeline): newsproject.bitreport.pt writer cycle and WP env split' (#12) from feat/BIT-22288-newsproject-writer into main
Tests / writer-pipeline tests (push) Successful in 13s
Tests / bridge tests (push) Successful in 13s
Tests / frontend lib tests (push) Successful in 14s
Reviewed-on: #12
2026-05-14 19:10:00 +01:00
José Alves aaaafd0c8f ci: re-trigger push checks after runner cache fix
Tests / writer-pipeline tests (push) Successful in 11s
Tests / bridge tests (push) Successful in 15s
Tests / frontend lib tests (push) Successful in 16s
Tests / writer-pipeline tests (pull_request) Successful in 15s
Tests / bridge tests (pull_request) Successful in 15s
Tests / frontend lib tests (pull_request) Successful in 15s
Empty commit to re-run push-event CI (previous failure was runner
infrastructure — missing act cache entry for actions/setup-node@v4).

Paperclip-Issue: BIT-22306
Paperclip-Run: 9c297293-f7c3-491c-9f8e-a4488578d556
2026-05-14 18:09:29 +00:00
spark 369e0b27c2 Merge pull request 'fix(writer-pipeline): handle ns0: XML namespace prefix in WebDAV PROPFIND parser (BIT-22306)' (#13) from fix/BIT-22306-webdav-ns-prefix into main
Tests / writer-pipeline tests (push) Successful in 12s
Tests / bridge tests (push) Successful in 12s
Tests / frontend lib tests (push) Successful in 13s
Merge fix(writer-pipeline): handle ns0: XML namespace prefix in WebDAV PROPFIND parser (BIT-22306)
2026-05-14 17:46:59 +01:00
Artur Moreira 738c1a56d0 fix(writer-pipeline): handle ns0: XML namespace prefix in WebDAV PROPFIND parser (BIT-22306)
Tests / writer-pipeline tests (push) Successful in 14s
Tests / bridge tests (push) Successful in 14s
Tests / frontend lib tests (push) Successful in 15s
Tests / writer-pipeline tests (pull_request) Successful in 11s
Tests / bridge tests (pull_request) Successful in 12s
Tests / frontend lib tests (pull_request) Successful in 13s
Python's xml.etree.ElementTree auto-assigns numeric prefixes like ns0: for
the first namespace it encounters. The PROPFIND regex [a-z]+: did not match
ns0: because of the digit, causing parsePropfindImageHrefs to return empty
on any WebDAV server backed by Python (WsgiDAV, some NextCloud configs).

Change [a-z]+: → [a-z][a-z0-9]*: in all three namespace-tagged element
patterns (response, href, getlastmodified). Test added with a real WsgiDAV
multistatus fixture.

Paperclip-Issue: BIT-22306
2026-05-14 16:33:49 +00:00
Artur Moreira 0a220c158f docs(writer-pipeline): clarify WebDAV disabled vs unreachable fallback
Tests / writer-pipeline tests (push) Failing after 5s
Tests / bridge tests (push) Successful in 20s
Tests / writer-pipeline tests (pull_request) Successful in 16s
Tests / bridge tests (pull_request) Successful in 16s
Tests / frontend lib tests (push) Successful in 20s
Tests / frontend lib tests (pull_request) Successful in 17s
Document that when WRITER_WEBDAV_ENABLED is off the archive is not used,
and that enabled-but-failing PROPFIND/GET surfaces an explicit error with
operational fallback (disable or restore connectivity). Aligns BIT-22292
acceptance wording with actual pipeline behaviour.
2026-05-14 16:10:14 +00:00
Artur MoreiraandCursor 7c0a515368 feat(writer-pipeline): newsproject.bitreport.pt writer cycle and WP env split
Tests / writer-pipeline tests (push) Failing after 5s
Tests / bridge tests (push) Failing after 6s
Tests / frontend lib tests (push) Successful in 14s
Tests / writer-pipeline tests (pull_request) Successful in 11s
Tests / bridge tests (pull_request) Successful in 13s
Tests / frontend lib tests (pull_request) Successful in 14s
Add site-scoped WP credentials (NEWSPROJECT_* vs ANDEBOL_*), RSS sources
config, systemd oneshot/timer offset from andebol, env template, and
deployment docs so BIT-22288 covers both stacks.

Co-authored-by: Cursor <[email protected]>
2026-05-14 14:40:09 +00:00
spark 9d03d489e0 Merge pull request 'feat(writer-pipeline): WebDAV archive fallback + handball shortlist (BIT-22292 / BIT-22288)' (#11) from feat/bit-21912-cf-cache-rules-script into main
Tests / writer-pipeline tests (push) Failing after 10s
Tests / bridge tests (push) Successful in 14s
Tests / frontend lib tests (push) Successful in 16s
2026-05-14 15:27:09 +01:00
spark b4af1397b7 Merge pull request 'fix(frontend): auth redirects use strict false-check for auth_links (BIT-22298)' (#10) from fix/BIT-22298-auth-redirect into main
Tests / writer-pipeline tests (push) Successful in 11s
Tests / bridge tests (push) Successful in 11s
Tests / frontend lib tests (push) Successful in 12s
Merge fix/BIT-22298-auth-redirect: auth redirects strict false-check (BIT-22298)
2026-05-14 14:52:54 +01:00
Artur Moreira 11cea53dab fix(frontend): auth redirects use strict false-check for auth_links (BIT-22298)
Tests / writer-pipeline tests (push) Successful in 13s
Tests / bridge tests (push) Successful in 12s
Tests / frontend lib tests (push) Successful in 12s
Tests / writer-pipeline tests (pull_request) Successful in 11s
Tests / bridge tests (pull_request) Successful in 13s
Tests / frontend lib tests (pull_request) Successful in 14s
/entrar and /registar redirected to / because !config.auth_links is
truthy when auth_links is undefined (config fallback).  Change both
pages to config.auth_links === false so only an explicit opt-out sends
the user home; missing or true both forward to wp-login.php.

Also add Cache-Control: no-store to the redirect response so edge
proxies never cache auth flows, and extend smoke-andebol.sh to assert
/entrar and /registar resolve to a wp-login URL.

Paperclip-Issue: BIT-22298
Paperclip-Agent: d706f4e6-5d05-4cec-b6e8-f8fb1f203aae
2026-05-14 13:48:27 +00:00
spark 35e8b60684 Merge pull request 'feat: add Node.js CI workflow' (#9) from feature/add-ci-workflow into main
Tests / writer-pipeline tests (push) Successful in 13s
Tests / bridge tests (push) Successful in 13s
Tests / frontend lib tests (push) Successful in 14s
Merge feature/add-ci-workflow (branch cleanup BIT-22162)
2026-05-13 22:57:30 +01:00
spark da7a01a1c1 Merge pull request 'feat(deploy): cf-cache-rules-apply.sh for BIT-21912 / BIT-21847' (#8) from feat/bit-21912-cf-cache-rules-script into main
Tests / writer-pipeline tests (push) Successful in 12s
Tests / bridge tests (push) Successful in 14s
Tests / frontend lib tests (push) Successful in 15s
2026-05-12 12:33:47 +01:00
Artur Moreira dbf2d342a7 feat: add Node.js CI workflow for bridge
Node.js CI / build-and-test (18) (pull_request) Failing after 11s
Node.js CI / build-and-test (20) (pull_request) Failing after 13s
2026-04-27 22:45:43 +00:00
29 changed files with 737 additions and 29 deletions

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
# Node.js CI for news-platform bridge
# Runs on: PR and push to main/develop
# Checks: TypeScript build and type checking
name: Node.js CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
CI: "true"
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
working-directory: bridge
- name: TypeScript build
run: npm run build
working-directory: bridge
if: always()
- name: TypeScript type checking
run: npm run typecheck
working-directory: bridge
if: always()
+162
View File
@@ -15,6 +15,7 @@
},
"devDependencies": {
"@types/node": "^20.14.0",
"pino-pretty": "^13.1.3",
"tsx": "^4.15.0",
"typescript": "^5.4.5"
}
@@ -631,6 +632,13 @@
"node": ">=0.10.0"
}
},
"node_modules/colorette": {
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
"integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
"dev": true,
"license": "MIT"
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
@@ -640,6 +648,16 @@
"node": ">= 0.6"
}
},
"node_modules/dateformat": {
"version": "4.6.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz",
"integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
@@ -666,6 +684,16 @@
"node": ">=0.10"
}
},
"node_modules/end-of-stream": {
"version": "1.4.5",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
"integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
"dev": true,
"license": "MIT",
"dependencies": {
"once": "^1.4.0"
}
},
"node_modules/esbuild": {
"version": "0.27.4",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.4.tgz",
@@ -714,6 +742,13 @@
"integrity": "sha512-fBHHqSTFLVnR61C+gltJuE5GkVQMV0S2nqUO8TJ+5Z3qAKG8vAx4FKai1s5jq/inV1+sREynIWSuQ6HgoSXpDQ==",
"license": "MIT"
},
"node_modules/fast-copy": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-4.0.3.tgz",
"integrity": "sha512-58apWr0GUiDFM8+3afrO6eYwJBn9ZAhDOzG3L+/9llab/haCARS2UIfffmOurYLwbgDRs8n0rfr6qAAPEAuAQw==",
"dev": true,
"license": "MIT"
},
"node_modules/fast-decode-uri-component": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz",
@@ -767,6 +802,13 @@
"fast-decode-uri-component": "^1.0.1"
}
},
"node_modules/fast-safe-stringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
"dev": true,
"license": "MIT"
},
"node_modules/fast-uri": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.4.0.tgz",
@@ -873,6 +915,13 @@
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
}
},
"node_modules/help-me": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz",
"integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==",
"dev": true,
"license": "MIT"
},
"node_modules/ioredis": {
"version": "5.10.1",
"resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.10.1.tgz",
@@ -906,6 +955,16 @@
"node": ">= 0.10"
}
},
"node_modules/joycon": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
"integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/json-schema-ref-resolver": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-schema-ref-resolver/-/json-schema-ref-resolver-1.0.1.tgz",
@@ -944,6 +1003,16 @@
"integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==",
"license": "MIT"
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/mnemonist": {
"version": "0.39.6",
"resolved": "https://registry.npmjs.org/mnemonist/-/mnemonist-0.39.6.tgz",
@@ -974,6 +1043,16 @@
"node": ">=14.0.0"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"dev": true,
"license": "ISC",
"dependencies": {
"wrappy": "1"
}
},
"node_modules/pino": {
"version": "9.14.0",
"resolved": "https://registry.npmjs.org/pino/-/pino-9.14.0.tgz",
@@ -1005,6 +1084,58 @@
"split2": "^4.0.0"
}
},
"node_modules/pino-pretty": {
"version": "13.1.3",
"resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.1.3.tgz",
"integrity": "sha512-ttXRkkOz6WWC95KeY9+xxWL6AtImwbyMHrL1mSwqwW9u+vLp/WIElvHvCSDg0xO/Dzrggz1zv3rN5ovTRVowKg==",
"dev": true,
"license": "MIT",
"dependencies": {
"colorette": "^2.0.7",
"dateformat": "^4.6.3",
"fast-copy": "^4.0.0",
"fast-safe-stringify": "^2.1.1",
"help-me": "^5.0.0",
"joycon": "^3.1.1",
"minimist": "^1.2.6",
"on-exit-leak-free": "^2.1.0",
"pino-abstract-transport": "^3.0.0",
"pump": "^3.0.0",
"secure-json-parse": "^4.0.0",
"sonic-boom": "^4.0.1",
"strip-json-comments": "^5.0.2"
},
"bin": {
"pino-pretty": "bin.js"
}
},
"node_modules/pino-pretty/node_modules/pino-abstract-transport": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz",
"integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==",
"dev": true,
"license": "MIT",
"dependencies": {
"split2": "^4.0.0"
}
},
"node_modules/pino-pretty/node_modules/secure-json-parse": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.1.0.tgz",
"integrity": "sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/pino-std-serializers": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz",
@@ -1046,6 +1177,17 @@
"node": ">= 0.10"
}
},
"node_modules/pump": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz",
"integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",
"dev": true,
"license": "MIT",
"dependencies": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
}
},
"node_modules/quick-format-unescaped": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
@@ -1192,6 +1334,19 @@
"integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==",
"license": "MIT"
},
"node_modules/strip-json-comments": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz",
"integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/thread-stream": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz",
@@ -1250,6 +1405,13 @@
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
"dev": true,
"license": "MIT"
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true,
"license": "ISC"
}
}
}
+1
View File
@@ -20,6 +20,7 @@
},
"devDependencies": {
"@types/node": "^20.14.0",
"pino-pretty": "^13.1.3",
"tsx": "^4.15.0",
"typescript": "^5.4.5"
}
+1 -1
View File
@@ -20,7 +20,7 @@
{ "id": "competicao", "label": "Competição", "slugs": ["clubes", "competicoes", "resultados"] }
],
"bridge_endpoint": "http://127.0.0.1:3200",
"wp_endpoint": "http://127.0.0.1:8081/wp-json",
"wp_endpoint": "https://andebol.net/wp-json",
"locale": "pt-PT",
"timezone": "Europe/Lisbon",
"ads_enabled": false,
+2 -2
View File
@@ -129,7 +129,7 @@ log "WordPress: http://localhost:8080/wp-json/wp/v2/"
log "Nginx: http://localhost/"
log ""
log "Remaining manual steps:"
log " 1. Add DHCP reservation for 10.10.50.140 on the router"
log " 2. Configure NPM proxy host: newsproject.bitreport.pt → http://10.10.50.140"
log " 1. IP 10.10.50.204 is static (BIT-24053: systemd-networkd + PVE config; MAC BC:24:11:77:5B:E6) — no DHCP reservation needed"
log " 2. Configure NPM proxy host: newsproject.bitreport.pt → http://10.10.50.204 (NPM proxy #20)"
log " 3. Enable HTTPS in NPM (Let's Encrypt)"
log " 4. Review $ENV_DIR/frontend.env and $ENV_DIR/bridge.env"
+9
View File
@@ -53,4 +53,13 @@ _c="$(code_for "$BASE_URL/wp-json/wp/v2/")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/wp-json/wp/v2/ expected 200, got $_c (WP andebol :8081)"
ok "GET /wp-json/wp/v2/ → $_c"
# Auth redirects — /entrar and /registar must NOT land on / (BIT-22298)
_final_entrar="$(curl -fsS -o /dev/null -w '%{url_effective}' --max-time 25 -L -H "Host: $HOST_HEADER" "$BASE_URL/entrar" 2>/dev/null || true)"
[[ "$_final_entrar" == *"wp-login"* ]] || fail "/entrar final URL must contain wp-login; got: $_final_entrar"
ok "GET /entrar → $_final_entrar"
_final_registar="$(curl -fsS -o /dev/null -w '%{url_effective}' --max-time 25 -L -H "Host: $HOST_HEADER" "$BASE_URL/registar" 2>/dev/null || true)"
[[ "$_final_registar" == *"wp-login"* ]] || fail "/registar final URL must contain wp-login; got: $_final_registar"
ok "GET /registar → $_final_registar"
echo "All smokes passed for BASE_URL=$BASE_URL (host: $HOST_HEADER)"
@@ -0,0 +1,17 @@
[Unit]
Description=News Platform — Writer Pipeline (newsproject.bitreport.pt) single cycle
After=network.target
[Service]
Type=oneshot
User=www-data
Group=www-data
WorkingDirectory=/opt/news-platform/writer-pipeline
EnvironmentFile=/etc/news-platform/writer-newsproject.env
ExecStart=/usr/bin/node dist/run-cycle.js --site newsproject.bitreport.pt --publish-max 2 --shortlist 8
StandardOutput=journal
StandardError=journal
SyslogIdentifier=news-writer-newsproject
NoNewPrivileges=true
PrivateTmp=true
@@ -0,0 +1,10 @@
[Unit]
Description=News Platform — Writer Pipeline (newsproject.bitreport.pt) daily timer
[Timer]
OnCalendar=*-*-* 06:45:00
RandomizedDelaySec=300
Persistent=true
[Install]
WantedBy=timers.target
@@ -0,0 +1,22 @@
# Writer Pipeline — newsproject.bitreport.pt environment
# Deploy to /etc/news-platform/writer-newsproject.env on the LXC
# Secrets (WP app password) must be kept out of version control.
NODE_ENV=production
# WordPress REST API base (Docker compose default stack — port 8080)
NEWSPROJECT_WP_BASE=http://127.0.0.1:8080/wp-json
# WordPress application credentials — generate in WP Users → Application Passwords
NEWSPROJECT_WP_USER=writer-bot
NEWSPROJECT_WP_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx
# Optional — public hostname for X-Site-Domain when the REST stack is multi-tenant
# NEWSPROJECT_WP_SITE_DOMAIN=https://newsproject.bitreport.pt
# Optional — same WebDAV federation archive as andebol when enabled on the host (BIT-22292)
# WRITER_WEBDAV_ENABLED=1
# WRITER_WEBDAV_BASE_URL=https://…/remote.php/dav/files/<user>/<folder>/
# WRITER_WEBDAV_USER=
# WRITER_WEBDAV_PASSWORD=
# WRITER_WEBDAV_DEFAULT_CREDIT=Foto: …
+1 -1
View File
@@ -29,7 +29,7 @@ See [`docs/ANDEBOL_EDITORIAL_BRIEF.md`](ANDEBOL_EDITORIAL_BRIEF.md) for detailed
- **Per feed:** a failing RSS URL is logged in `metrics.errors`; other feeds still run.
- **Per URL (legacy comparison):** failed HTML fetch does not block the cycle; aggregator metrics still apply for production reads.
- **WP publish:** if credentials are missing, the cycle completes with a clear error string and **no** draft creation.
- **Featured image (BIT-22288 / BIT-22292):** drafts require a rights-cleared image. The pipeline uses RSS enclosure / `og:image` / `twitter:image` first. If none are present, it can **list a WebDAV collection** (authenticated Basic auth) and pick the best-matching filename against the headline, then upload to WP with caption/alt. Configure with `WRITER_WEBDAV_*` env vars (see `deploy/systemd/writer-andebol.env.example`). If WebDAV is enabled but PROPFIND/GET fails, draft creation for that item fails with an explicit error (no silent fallback to a random web image).
- **Featured image (BIT-22288 / BIT-22292 / BIT-24388):** drafts require a rights-cleared image. The pipeline uses RSS enclosure / media:content / media:thumbnail / `og:image` / `twitter:image` first. If none are present, it can **list a WebDAV collection** (authenticated Basic auth) and pick the best-matching filename against the headline, then upload to WP with caption/alt. Configure with `WRITER_WEBDAV_*` env vars (see `deploy/systemd/writer-andebol.env.example`). When WebDAV is **not** enabled, the archive is never contacted (only RSS/HTML hints apply). If WebDAV is enabled but PROPFIND/GET fails, draft creation for that item fails with an explicit error (no silent fallback to a random web image) — operational fallback is to disable `WRITER_WEBDAV_ENABLED` or restore connectivity before retrying. **Note:** FPA RSS feed uses `<media:content>` for featured images (BIT-24388), which is now properly extracted and attached to WordPress posts.
## Commands
+56
View File
@@ -4,6 +4,22 @@
---
## `.env` preservation in deploy (BIT-25005)
> Canonical rule: **`docs/DEPLOY_STANDARD.md` §3.1** — meta-repo `paperclip`.
| Prohibited | Allowed |
|-----------|---------|
| `cp .env.example .env` over an **existing** `.env` in production | `git pull` / rsync **excluding** `.env` and `*.env` |
| Placeholder credentials (`changeme`, `secret`, `password`) in production | Vault values only; document new keys in `.env.example` **empty** |
| Changing `DB_*` / `DATABASE_*` without explicit issue, rollback plan, and log | Entry in `docs/PRODUCTION_ACCESS_SYNC_LOG.md` (meta-repo) before applying |
Deploy scripts must fail (`exit 1`) if they would overwrite an existing `.env` with example content.
> **Note:** any `cp .env.example .env` instructions in this document apply **only to initial server bootstrap** where no `.env` exists yet. On redeployments, the existing production `.env` must never be overwritten.
---
## Overview
The platform runs on a single LXC container on Proxmox for the initial test deployment. The container hosts all services: Nginx reverse proxy, Astro frontend (Node.js), Fastify bridge (Node.js), WordPress (Docker), MariaDB (Docker), and Redis.
@@ -288,6 +304,46 @@ Cycle output (metrics JSON) is also appended to `/opt/news-platform/writer-pipel
---
## Writer Pipeline — newsproject.bitreport.pt (systemd timer)
Same `run-cycle.js` binary as andebol.net, with **`--site newsproject.bitreport.pt`** and WordPress credentials from **`NEWSPROJECT_WP_*`** env vars (defaults to `http://127.0.0.1:8080/wp-json`). Source list: `writer-pipeline/config/newsproject.bitreport.pt.sources.json`.
The timer is offset from the andebol unit (**06:45** vs **06:00**) to reduce concurrent writes to the shared `var/aggregated-items.json` store.
### Files
| Repo path | CT destination |
|-----------|----------------|
| `deploy/systemd/news-writer-newsproject.service` | `/etc/systemd/system/news-writer-newsproject.service` |
| `deploy/systemd/news-writer-newsproject.timer` | `/etc/systemd/system/news-writer-newsproject.timer` |
| `deploy/systemd/writer-newsproject.env.example` | `/etc/news-platform/writer-newsproject.env` (fill secrets) |
### Install on the CT
```bash
sudo cp /opt/news-platform/deploy/systemd/writer-newsproject.env.example \
/etc/news-platform/writer-newsproject.env
sudo chmod 640 /etc/news-platform/writer-newsproject.env
sudo chown root:www-data /etc/news-platform/writer-newsproject.env
# Edit NEWSPROJECT_WP_USER and NEWSPROJECT_WP_APP_PASSWORD
sudo cp /opt/news-platform/deploy/systemd/news-writer-newsproject.service \
/etc/systemd/system/
sudo cp /opt/news-platform/deploy/systemd/news-writer-newsproject.timer \
/etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now news-writer-newsproject.timer
```
### Manual test run
```bash
sudo systemctl start news-writer-newsproject.service
journalctl -u news-writer-newsproject.service -n 50
```
---
## Future: Multi-Container
When the platform scales beyond a single test container, each service moves to its own LXC or VM:
+1 -1
View File
@@ -1,6 +1,6 @@
# Service Health Monitoring
Automated health monitoring and alerting for the news-platform services on **CT 222** (`news-project-test`, **10.10.50.140**).
Automated health monitoring and alerting for the news-platform services on **CT 222** (`news-project-test`, **10.10.50.204**).
**BIT-746** adds a **must-not-fail inventory**, optional **public URL** probing, optional **bridge deep** checks, and an **escalation runbook**: `docs/runbooks/NEWS_PLATFORM_MONITORING_ALERTS_BIT746.md`.
**BIT-3915** adds **pipeline incident** coverage (aggregator stall, lag signals, escalation): `docs/runbooks/NEWS_PLATFORM_INCIDENT_RUNBOOK_BIT3915.md`.
**Runbook index:** `docs/runbooks/README.md` (links deployment, smoke script, and company-wide **paperclip** runbooks).
@@ -1,6 +1,6 @@
# News platform — incident response (aggregator, lag, escalation) — BIT-3915
Operational incident guide for the **news-platform** stack (Astro SSR, Fastify bridge, headless WordPress, optional **writer-pipeline** aggregator). Default deployment context: **LXC CT 222** (`news-project-test`, **10.10.50.140**, VLAN 1050) — confirm VMID/IP against the current inventory in the **paperclip** meta-repo (`docs/environments/03-lxc.md`).
Operational incident guide for the **news-platform** stack (Astro SSR, Fastify bridge, headless WordPress, optional **writer-pipeline** aggregator). Default deployment context: **LXC CT 222** (`news-project-test`, **10.10.50.204**, VLAN 1050) — confirm VMID/IP against the current inventory in the **paperclip** meta-repo (`docs/environments/03-lxc.md`).
## How this runbook fits
@@ -1,6 +1,6 @@
# News platform — monitoring alerts and escalation (BIT-746)
Follow-up to incident **BIT-743** (public `/noticias` unavailable while internal checks looked fine). This runbook applies to **CT 222** (`news-project-test`, **10.10.50.140**) and the **news-platform** stack deployed under `/opt/news-platform`.
Follow-up to incident **BIT-743** (public `/noticias` unavailable while internal checks looked fine). This runbook applies to **CT 222** (`news-project-test`, **10.10.50.204**) and the **news-platform** stack deployed under `/opt/news-platform`.
## Must-not-fail inventory (MVP)
+2 -1
View File
@@ -2,8 +2,9 @@
import { getDomainConfig } from '../lib/domain.js';
const config = getDomainConfig(Astro.url.hostname);
if (!config.auth_links) {
if (config.auth_links === false) {
return Astro.redirect('/', 302);
}
Astro.response.headers.set('Cache-Control', 'no-store');
return Astro.redirect('/wp-login.php', 302);
---
+2 -1
View File
@@ -2,8 +2,9 @@
import { getDomainConfig } from '../lib/domain.js';
const config = getDomainConfig(Astro.url.hostname);
if (!config.auth_links) {
if (config.auth_links === false) {
return Astro.redirect('/', 302);
}
Astro.response.headers.set('Cache-Control', 'no-store');
return Astro.redirect('/wp-login.php?action=register', 302);
---
+3 -3
View File
@@ -36,8 +36,8 @@ WP_ADMIN_PASSWORD=your_password docker compose exec wordpress bash /var/www/html
After setup, the REST API is available at:
```
http://10.10.50.140:8080/wp-json/wp/v2/posts
http://10.10.50.140:8080/wp-json/wp/v2/categories
http://10.10.50.204:8080/wp-json/wp/v2/posts
http://10.10.50.204:8080/wp-json/wp/v2/categories
```
The Fastify bridge (port 3200) proxies these endpoints and adds Redis caching.
@@ -82,7 +82,7 @@ Credenciais: cofre da equipa (nunca em git). Se ainda não existir utilizador ad
Para **restringir** o `/wp-admin/` a utilizadores reais em redes privadas (ou a IPs conhecidos), é preciso outra camada ou `real_ip` bem configurado: `set_real_ip_from` **apenas** para IPs dos proxies de confiança, `real_ip_header X-Forwarded-For`, e depois ajustar `allow` ao resultado — ou controlar acesso no **NPM** / Cloudflare / VPN. Ver `docs/deployment.md` (secção homónima).
**Directo ao LXC:** `http://10.10.50.140:8080/wp-admin/` — o `docker compose` publica `8080` em todas as interfaces por omissão; se não abre, verifica **firewall do CT**, **Proxmox**, e rota VPN até `10.10.50.0/24`.
**Directo ao LXC:** `http://10.10.50.204:8080/wp-admin/` — o `docker compose` publica `8080` em todas as interfaces por omissão; se não abre, verifica **firewall do CT**, **Proxmox**, e rota VPN até `10.10.50.0/24`.
**Redirects do WordPress:** define `WORDPRESS_PUBLIC_URL` no `.env` para o URL público (HTTPS + host). Em produção atrás do Nginx do CT, se ainda estiver o default `http://localhost:8080`, o `WORDPRESS_CONFIG_EXTRA` infere o URL a partir de `Host` e `X-Forwarded-Proto` **desde que** o pedido traga pelo menos um cabeçalho típico de proxy (`X-Forwarded-Proto`, `X-Forwarded-For`, ou `X-Real-IP`). Garante que o Nginx preserva o `X-Forwarded-Proto` enviado pelo NPM (ficheiro `deploy/nginx/newsproject.bitreport.pt.conf`). Acesso directo ao contentor na porta `:8080` sem esses cabeçalhos continua a precisar de `WORDPRESS_PUBLIC_URL` correcto.
+1
View File
@@ -216,6 +216,7 @@ services:
- "8081:80"
volumes:
- wp_andebol_html:/var/www/html:ro
- wp_andebol_content:/var/www/html/wp-content:ro
- ./nginx/wordpress-andebol.conf:/etc/nginx/conf.d/default.conf:ro
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1/wp-json/wp/v2/"]
@@ -0,0 +1,32 @@
{
"site": "newsproject.bitreport.pt",
"sources": [
{
"id": "record_pt_main",
"kind": "rss",
"url": "https://www.record.pt/rss/",
"enabled": true,
"maxItems": 20,
"topics": ["pt", "sports", "media"],
"note": "newsproject.bitreport.pt — general PT sports demo; not the andebol-only policy (see andebol.net.sources.json)."
},
{
"id": "sapo_noticias",
"kind": "rss",
"url": "https://noticias.sapo.pt/rss",
"enabled": true,
"maxItems": 25,
"topics": ["pt", "national", "international", "media"],
"note": "SAPO highlights; editorial rewrite PT-PT when publishing."
},
{
"id": "bbc_football",
"kind": "rss",
"url": "https://feeds.bbci.co.uk/sport/football/rss.xml",
"enabled": true,
"maxItems": 15,
"topics": ["football", "international", "en"],
"note": "BBC Sport football (EN); site locale is pt-PT — translate in downstream writer."
}
]
}
+2 -1
View File
@@ -12,7 +12,8 @@
"aggregator": "node dist/aggregator-server.js",
"aggregator:dev": "tsx src/aggregator-server.ts",
"cycle": "node dist/run-cycle.js",
"cycle:dev": "tsx src/run-cycle.ts"
"cycle:dev": "tsx src/run-cycle.ts",
"backfill:featured": "node dist/backfill-featured-from-fpa.js"
},
"dependencies": {
"fastify": "^4.28.1",
@@ -0,0 +1,156 @@
/**
* Backfill featured images on andebol.net posts by matching FPA source slugs (BIT-24384).
*
* Usage:
* node dist/backfill-featured-from-fpa.js [--dry-run] [--limit N] [--slug one-slug]
*
* Requires ANDEBOL_WP_USER + ANDEBOL_WP_APP_PASSWORD (see wp-site-env.ts).
*/
import { attachFeaturedImageToPost, type WpPublishConfig } from './wp-publish.js';
import { wpCredentialsForSite } from './wp-site-env.js';
const FPA_WP_BASE = 'https://portal.fpa.pt/wp-json';
const SITE_DOMAIN = 'andebol.net';
function argFlag(name: string, argv: string[]): boolean {
return argv.includes(name);
}
function argValue(name: string, argv: string[]): string | undefined {
const i = argv.indexOf(name);
return i >= 0 ? argv[i + 1] : undefined;
}
function wpHeaders(cfg: WpPublishConfig): Record<string, string> {
const auth = Buffer.from(`${cfg.username}:${cfg.appPassword}`, 'utf8').toString('base64');
const h: Record<string, string> = {
Accept: 'application/json',
Authorization: `Basic ${auth}`,
};
if (cfg.siteDomain) h['X-Site-Domain'] = cfg.siteDomain;
return h;
}
function toPublishConfig(creds: ReturnType<typeof wpCredentialsForSite>): WpPublishConfig {
return {
wpBase: creds.wpBase,
username: creds.wpUser,
appPassword: creds.wpPass,
siteDomain: creds.siteDomain ?? SITE_DOMAIN,
};
}
interface WpPostRow {
id: number;
slug: string;
featured_media: number;
}
async function listPostsMissingFeatured(
cfg: WpPublishConfig,
limit: number,
slugFilter?: string,
): Promise<WpPostRow[]> {
const base = cfg.wpBase.replace(/\/$/, '');
const out: WpPostRow[] = [];
let page = 1;
while (out.length < limit) {
const qs = new URLSearchParams({
per_page: '100',
page: String(page),
_fields: 'id,slug,featured_media',
});
if (slugFilter) qs.set('slug', slugFilter);
const res = await fetch(`${base}/wp/v2/posts?${qs}`, {
headers: wpHeaders(cfg),
signal: AbortSignal.timeout(20_000),
});
if (!res.ok) throw new Error(`WP list posts ${res.status}`);
const rows = (await res.json()) as WpPostRow[];
if (rows.length === 0) break;
for (const row of rows) {
if (!row.featured_media) out.push(row);
if (out.length >= limit) break;
}
if (slugFilter || rows.length < 100) break;
page += 1;
}
return out;
}
async function fpaFeaturedForSlug(slug: string): Promise<{ url: string; credit?: string } | null> {
const qs = new URLSearchParams({ slug, _embed: 'wp:featuredmedia' });
const res = await fetch(`${FPA_WP_BASE}/wp/v2/posts?${qs}`, {
headers: { Accept: 'application/json' },
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) return null;
const rows = (await res.json()) as Array<{
title?: { rendered?: string };
_embedded?: { 'wp:featuredmedia'?: Array<{ source_url?: string; alt_text?: string }> };
}>;
const post = rows[0];
const media = post?._embedded?.['wp:featuredmedia']?.[0];
const url = media?.source_url?.trim();
if (!url) return null;
const credit = media?.alt_text?.trim() || undefined;
return { url, credit };
}
async function main(): Promise<void> {
const argv = process.argv.slice(2);
const dryRun = argFlag('--dry-run', argv);
const limit = Math.max(1, parseInt(argValue('--limit', argv) ?? '50', 10));
const slugFilter = argValue('--slug', argv)?.trim();
const creds = wpCredentialsForSite('andebol.net');
if (!creds.wpUser || !creds.wpPass) {
console.error(`Missing credentials: set ${creds.envHint}`);
process.exit(1);
}
const cfg = toPublishConfig(creds);
const posts = await listPostsMissingFeatured(cfg, limit, slugFilter);
console.log(`Posts without featured_media: ${posts.length}${dryRun ? ' (dry-run)' : ''}`);
let updated = 0;
let skipped = 0;
const errors: string[] = [];
for (const post of posts) {
const featured = await fpaFeaturedForSlug(post.slug);
if (!featured) {
skipped += 1;
console.log(`skip ${post.slug}: no FPA featured image`);
continue;
}
if (dryRun) {
console.log(`would attach ${post.slug} <- ${featured.url}`);
updated += 1;
continue;
}
try {
const mediaId = await attachFeaturedImageToPost(
post.id,
featured.url,
cfg,
featured.credit,
);
updated += 1;
console.log(`ok ${post.slug} post=${post.id} media=${mediaId}`);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
errors.push(`${post.slug}: ${msg}`);
console.error(`fail ${post.slug}: ${msg}`);
}
}
console.log(JSON.stringify({ updated, skipped, errors: errors.length, dryRun }, null, 2));
if (errors.length > 0) process.exit(1);
}
main().catch(e => {
console.error(e);
process.exit(1);
});
@@ -0,0 +1,60 @@
/**
* Tests for RSS media:content and media:thumbnail extraction (BIT-24388).
*/
import { describe, it } from 'node:test';
import assert from 'node:assert';
describe('RSS media extraction', () => {
it('should extract media:content URL from FPA feed items', async () => {
// This test verifies that the RSS parser is configured to extract media:content
// and that the ingestion logic properly handles it.
// The actual feed fetching is tested in integration tests.
// Sample media:content structure as returned by rss-parser
const sampleMediaContent = {
$: {
url: 'https://portal.fpa.pt/wp-content/uploads/2026/06/Banner_Convocatoria.jpg',
medium: 'image'
}
};
assert.strictEqual(sampleMediaContent.$.medium, 'image');
assert.ok(sampleMediaContent.$.url.startsWith('https://'));
});
it('should extract media:thumbnail URL from BBC feed items', async () => {
// Sample media:thumbnail structure as returned by rss-parser
const sampleMediaThumbnail = {
$: {
width: '240',
height: '134',
url: 'https://ichef.bbci.co.uk/ace/standard/240/cpsprodpb/ddc9/live/4a0b8080-5815-11ef-aebc-6de4d31bf5cd.jpg'
}
};
assert.ok(sampleMediaThumbnail.$.url.startsWith('https://'));
assert.strictEqual(sampleMediaThumbnail.$.width, '240');
assert.strictEqual(sampleMediaThumbnail.$.height, '134');
});
it('should prefer enclosure over media:content when both present', async () => {
// This documents the priority order: enclosure > media:content > media:thumbnail
// The implementation in ingest-sources.ts follows this order.
const enclosure = { url: 'https://example.com/enclosure.jpg', type: 'image/jpeg' };
const mediaContent = { $: { url: 'https://example.com/media.jpg', medium: 'image' } };
const mediaThumbnail = { $: { url: 'https://example.com/thumb.jpg' } };
// Priority: enclosure should be checked first
assert.ok(enclosure.url);
assert.ok(enclosure.type?.startsWith('image/'));
// Fallback to media:content
assert.ok(mediaContent.$.url);
assert.strictEqual(mediaContent.$.medium, 'image');
// Fallback to media:thumbnail
assert.ok(mediaThumbnail.$.url);
});
});
+15 -2
View File
@@ -11,7 +11,14 @@ import {
type SitemapUrlEntry,
} from './sitemap-parse.js';
const parser = new Parser();
const parser = new Parser({
customFields: {
item: [
['media:content', 'mediaContent'],
['media:thumbnail', 'mediaThumbnail'],
],
},
});
const SITEMAP_MAX_CHILD_SITEMAPS = 10;
const SITEMAP_LOOSE_CAP = 250;
@@ -191,11 +198,17 @@ export async function ingestAllSources(
if (!link) continue;
const title = (entry.title || 'Sem título').replace(/\s+/g, ' ').trim();
const summary = pickSummary(entry);
const publishedAt = entry.isoDate || entry.pubDate || entry.date || now;
const publishedAt = entry.isoDate || entry.pubDate || now;
const enc = (entry as { enclosure?: { url?: string; type?: string } }).enclosure;
const mediaContent = (entry as { mediaContent?: { $?: { url?: string; medium?: string } } }).mediaContent;
const mediaThumbnail = (entry as { mediaThumbnail?: { $?: { url?: string } } }).mediaThumbnail;
let featured: { url?: string; credit?: string } | undefined;
if (enc?.url && enc.type?.toLowerCase().startsWith('image/')) {
featured = { url: enc.url };
} else if (mediaContent?.$?.url && mediaContent?.$?.medium === 'image') {
featured = { url: mediaContent.$.url };
} else if (mediaThumbnail?.$?.url) {
featured = { url: mediaThumbnail.$.url };
}
const item = buildItem(
config.site,
+8 -11
View File
@@ -20,6 +20,7 @@ import {
} from './token-metrics.js';
import type { AggregatedItem, CycleMetrics } from './types.js';
import { createDraftFromAggregatedItem } from './wp-publish.js';
import { wpCredentialsForSite } from './wp-site-env.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const PKG_ROOT = path.resolve(__dirname, '..');
@@ -84,19 +85,17 @@ async function main(): Promise<void> {
const errors = [...ingest.errors];
let draftsCreated = 0;
const wpBase = process.env.ANDEBOL_WP_BASE ?? 'http://127.0.0.1:8081/wp-json';
const wpUser = process.env.ANDEBOL_WP_USER ?? '';
const wpPass = process.env.ANDEBOL_WP_APP_PASSWORD ?? '';
const wp = wpCredentialsForSite(site);
if (!dryRun && publishMax > 0 && wpUser && wpPass) {
if (!dryRun && publishMax > 0 && wp.wpUser && wp.wpPass) {
const toPublish = list.slice(0, publishMax);
for (const item of toPublish) {
try {
const { id } = await createDraftFromAggregatedItem(item, {
wpBase,
username: wpUser,
appPassword: wpPass,
siteDomain: process.env.ANDEBOL_WP_SITE_DOMAIN,
wpBase: wp.wpBase,
username: wp.wpUser,
appPassword: wp.wpPass,
siteDomain: wp.siteDomain,
});
draftsCreated += 1;
const updated: AggregatedItem = { ...item, wpDraftId: id };
@@ -107,9 +106,7 @@ async function main(): Promise<void> {
}
await saveStore(storePath, store);
} else if (!dryRun && publishMax > 0) {
errors.push(
'Skipping WP publish: set ANDEBOL_WP_USER and ANDEBOL_WP_APP_PASSWORD (optional ANDEBOL_WP_BASE)',
);
errors.push(`Skipping WP publish: set ${wp.envHint}`);
}
const finishedAt = new Date().toISOString();
@@ -24,6 +24,15 @@ test('parsePropfindImageHrefs skips collection root and lists image files', () =
assert.equal(rows[0].lastMod, 'Wed, 01 Jan 2025 12:00:00 GMT');
});
test('parsePropfindImageHrefs handles ns0: namespace prefix (WsgiDAV / Python ElementTree)', () => {
const xml = `<?xml version="1.0" encoding="utf-8" ?>
<ns0:multistatus xmlns:ns0="DAV:"><ns0:response><ns0:href>/</ns0:href><ns0:propstat><ns0:prop><ns0:getlastmodified>Thu, 14 May 2026 16:11:04 GMT</ns0:getlastmodified><ns0:resourcetype><ns0:collection /></ns0:resourcetype></ns0:prop><ns0:status>HTTP/1.1 200 OK</ns0:status></ns0:propstat></ns0:response><ns0:response><ns0:href>/Foto_FPA___duplo-embate-croacia-m20-euro.jpg</ns0:href><ns0:propstat><ns0:prop><ns0:getlastmodified>Thu, 14 May 2026 16:11:26 GMT</ns0:getlastmodified><ns0:resourcetype /></ns0:prop><ns0:status>HTTP/1.1 200 OK</ns0:status></ns0:propstat></ns0:response></ns0:multistatus>`;
const rows = parsePropfindImageHrefs(xml, 'http://127.0.0.1:8088/');
assert.equal(rows.length, 1);
assert.match(rows[0].href, /Foto_FPA___duplo-embate-croacia-m20-euro\.jpg$/);
assert.equal(rows[0].lastMod, 'Thu, 14 May 2026 16:11:26 GMT');
});
test('pickBestArchiveImage prefers hrefs whose path matches title tokens', () => {
const item: AggregatedItem = {
id: '1',
+3 -3
View File
@@ -29,14 +29,14 @@ function decodeXmlText(s: string): string {
export function parsePropfindImageHrefs(xml: string, collectionUrl: string): { href: string; lastMod?: string }[] {
const base = new URL(collectionUrl.endsWith('/') ? collectionUrl : `${collectionUrl}/`);
const out: { href: string; lastMod?: string }[] = [];
const reResponse = /<(?:[a-z]+:)?response[^>]*>([\s\S]*?)<\/(?:[a-z]+:)?response>/gi;
const reResponse = /<(?:[a-z][a-z0-9]*:)?response[^>]*>([\s\S]*?)<\/(?:[a-z][a-z0-9]*:)?response>/gi;
let m: RegExpExecArray | null;
while ((m = reResponse.exec(xml))) {
const block = m[1];
const hrefM = /<(?:[a-z]+:)?href>([^<]+)<\/(?:[a-z]+:)?href>/i.exec(block);
const hrefM = /<(?:[a-z][a-z0-9]*:)?href>([^<]+)<\/(?:[a-z][a-z0-9]*:)?href>/i.exec(block);
if (!hrefM) continue;
const hrefRaw = decodeXmlText(hrefM[1].trim());
const lmM = /<(?:[a-z]+:)?getlastmodified>([^<]+)<\/(?:[a-z]+:)?getlastmodified>/i.exec(block);
const lmM = /<(?:[a-z][a-z0-9]*:)?getlastmodified>([^<]+)<\/(?:[a-z][a-z0-9]*:)?getlastmodified>/i.exec(block);
const lastMod = lmM ? decodeXmlText(lmM[1].trim()) : undefined;
if (!IMAGE_EXT_RE.test(hrefRaw)) continue;
let abs: string;
+23
View File
@@ -235,6 +235,29 @@ async function resolveCategoryId(
return rows[0]?.id ?? null;
}
/** Attach a rights-cleared featured image to an existing WordPress post (BIT-24384 backfill). */
export async function attachFeaturedImageToPost(
postId: number,
imageUrl: string,
cfg: WpPublishConfig,
credit?: string,
fetchHeaders?: Record<string, string>,
): Promise<number> {
const base = cfg.wpBase.replace(/\/$/, '');
const mediaId = await uploadFeaturedMedia(cfg, base, imageUrl, credit, fetchHeaders);
const res = await fetch(`${base}/wp/v2/posts/${postId}`, {
method: 'POST',
headers: jsonHeaders(cfg),
body: JSON.stringify({ featured_media: mediaId }),
signal: AbortSignal.timeout(20_000),
});
if (!res.ok) {
const errText = await res.text().catch(() => '');
throw new Error(`WP post featured_media patch failed ${res.status}: ${errText.slice(0, 500)}`);
}
return mediaId;
}
export async function createDraftFromAggregatedItem(
item: AggregatedItem,
cfg: WpPublishConfig,
+54
View File
@@ -0,0 +1,54 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { wpCredentialsForSite } from './wp-site-env.js';
const keysNews = [
'NEWSPROJECT_WP_BASE',
'NEWSPROJECT_WP_USER',
'NEWSPROJECT_WP_APP_PASSWORD',
'NEWSPROJECT_WP_SITE_DOMAIN',
] as const;
const keysAndebol = ['ANDEBOL_WP_BASE', 'ANDEBOL_WP_USER', 'ANDEBOL_WP_APP_PASSWORD'] as const;
function snapshotEnv<K extends string>(keys: readonly K[]): Record<K, string | undefined> {
const o = {} as Record<K, string | undefined>;
for (const k of keys) o[k] = process.env[k];
return o;
}
function restoreEnv<K extends string>(snap: Record<K, string | undefined>) {
for (const k of Object.keys(snap) as K[]) {
const v = snap[k];
if (v === undefined) delete process.env[k];
else process.env[k] = v;
}
}
test('wpCredentialsForSite uses NEWSPROJECT_* for newsproject.bitreport.pt', () => {
const snap = snapshotEnv(keysNews);
try {
process.env.NEWSPROJECT_WP_BASE = 'http://example/wp-json';
process.env.NEWSPROJECT_WP_USER = 'u';
process.env.NEWSPROJECT_WP_APP_PASSWORD = 'p';
process.env.NEWSPROJECT_WP_SITE_DOMAIN = 'https://newsproject.bitreport.pt';
const c = wpCredentialsForSite('newsproject.bitreport.pt');
assert.equal(c.wpBase, 'http://example/wp-json');
assert.equal(c.wpUser, 'u');
assert.equal(c.wpPass, 'p');
assert.equal(c.siteDomain, 'https://newsproject.bitreport.pt');
} finally {
restoreEnv(snap);
}
});
test('wpCredentialsForSite defaults andebol WP base to 8081', () => {
const snap = snapshotEnv(keysAndebol);
try {
delete process.env.ANDEBOL_WP_BASE;
delete process.env.ANDEBOL_WP_USER;
const c = wpCredentialsForSite('andebol.net');
assert.equal(c.wpBase, 'http://127.0.0.1:8081/wp-json');
} finally {
restoreEnv(snap);
}
});
+41
View File
@@ -0,0 +1,41 @@
/**
* WordPress REST credentials per writer `--site` (BIT-22288: andebol.net + newsproject).
*/
export interface WpSiteCredentials {
wpBase: string;
wpUser: string;
wpPass: string;
siteDomain: string | undefined;
/** Shown when publish is skipped due to missing secrets */
envHint: string;
}
export function wpCredentialsForSite(site: string): WpSiteCredentials {
if (site === 'newsproject.bitreport.pt') {
const wpBase =
(process.env.NEWSPROJECT_WP_BASE ?? '').trim() || 'http://127.0.0.1:8080/wp-json';
const wpUser = (process.env.NEWSPROJECT_WP_USER ?? '').trim();
const wpPass = (process.env.NEWSPROJECT_WP_APP_PASSWORD ?? '').trim();
const siteDomain = (process.env.NEWSPROJECT_WP_SITE_DOMAIN ?? '').trim() || undefined;
return {
wpBase,
wpUser,
wpPass,
siteDomain,
envHint: 'NEWSPROJECT_WP_USER and NEWSPROJECT_WP_APP_PASSWORD (optional NEWSPROJECT_WP_BASE, NEWSPROJECT_WP_SITE_DOMAIN)',
};
}
const wpBase = (process.env.ANDEBOL_WP_BASE ?? '').trim() || 'http://127.0.0.1:8081/wp-json';
const wpUser = (process.env.ANDEBOL_WP_USER ?? '').trim();
const wpPass = (process.env.ANDEBOL_WP_APP_PASSWORD ?? '').trim();
const siteDomain = (process.env.ANDEBOL_WP_SITE_DOMAIN ?? '').trim() || undefined;
return {
wpBase,
wpUser,
wpPass,
siteDomain,
envHint: 'ANDEBOL_WP_USER and ANDEBOL_WP_APP_PASSWORD (optional ANDEBOL_WP_BASE, ANDEBOL_WP_SITE_DOMAIN)',
};
}