Commit Graph

75 Commits

Author SHA1 Message Date
peptiderepo
99ef0c9638 fix: add no-cache headers to REST API, include ai_summary in response
LiteSpeed Cache was serving stale REST API responses with 0 articles, causing the React frontend to show "No articles" despite 50+ articles in the DB.

- Add Cache-Control and X-LiteSpeed-Cache-Control: no-cache headers to /articles endpoint
- Include ai_summary and thumbnail_local columns in the REST API query (needed by React frontend)
2026-04-07 13:20:29 +07:00
peptiderepo
d86a259693 fix: add ssh-keyscan for GitHub host key verification 2026-04-07 12:46:45 +07:00
peptiderepo
ce05735544 Replace Hostinger GIT integration with SSH direct deploy
Hostinger GIT integration has a persistent backend bug that prevents using the correct plugin directory name. This replaces it with SSH-based deployment:

- Sync deploy branch with clean plugin runtime files
- SSH into Hostinger and git pull deploy branch directly
- Purge LiteSpeed cache after successful deploy
2026-04-07 12:43:09 +07:00
Terence Ong
1ae831e183 feat: remove AI thumbnails, rewrite frontend with React (v1.3.0)
Remove all AI thumbnail generation infrastructure (too expensive,
poor results) and rewrite the public-facing article feed as a React
SPA mounted via WordPress shortcode.

Changes:
- Remove thumbnail generation, OG scraping, and image download code
  from fetcher, LLM, and admin classes
- Replace server-rendered PHP templates with React component
  (PeptideNewsFeed.jsx) using WordPress-bundled React/ReactDOM
- Add Babel build pipeline for JSX transpilation
- Update REST API to serve ai_summary instead of thumbnail fields
- Redesign public CSS: clean card layout, loading skeletons,
  dark mode, responsive, no thumbnail imagery
- Remove dead admin settings (llm_image_model, thumbnail_fallback)
- Fix call_openrouter() visibility for Content Filter cross-class use
- Bump version to 1.3.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 09:45:12 +07:00
Terence Ong
cd8eee11b8 Replace broken DDG search with AI thumbnail generation fallback
DuckDuckGo's HTML search endpoint now requires vqd session tokens,
making server-side search-based URL resolution unreliable. Simplified
the thumbnail pipeline:

- OG scrape only for non-aggregator URLs (direct publisher pages)
- AI image generation via OpenRouter for aggregator articles (Google News)
- Added Image Model settings field in admin UI
- Added thumbnail_local column for AI-generated images
- Updated public/admin display to check thumbnail_local as fallback
- Removed all DuckDuckGo search code (find_article_url_via_search,
  extract_ddg_url, resolve_article_for_scraping)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 20:29:32 +07:00
Terence Ong
de35f2d684 Fix thumbnail scraping: use search-based URL resolution for Google News articles
Google News RSS stores encrypted article URLs that cannot be resolved
server-side (JS SPA, no HTTP redirects, encrypted base64 IDs). Replace
the failed decode/parse strategies with DuckDuckGo search-based lookup
using article title + publisher name to find actual article pages, then
scrape OG images from those pages.

- Add find_article_url_via_search() using DuckDuckGo HTML endpoint
- Add resolve_article_for_scraping() combining redirect + search fallback
- Mark failed lookups with '_no_image' sentinel to avoid repeated retries
- Backfill button resets sentinels to allow manual re-scraping
- Clean up verbose debug instrumentation from prior attempts
- Update frontend to handle '_no_image' sentinel gracefully

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 20:01:25 +07:00
Terence Ong
acf7e61b90 Switch to multi-strategy HTML parsing for Google News URL resolution
Replace batchexecute API with direct fetch + HTML parsing strategies:
data-n-au attributes, anchor href extraction, meta refresh, JS redirect.
Add verbose debug output to diagnose server-side response from Google News.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 19:47:10 +07:00
Terence Ong
f828cec229 Use Google batchexecute API to resolve Google News article URLs
Replace broken base64 decoding with Google's internal batchexecute API
endpoint to resolve encrypted article IDs to actual publisher URLs.
This is the approach used by known Google News decoder libraries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 19:42:22 +07:00
Terence Ong
2c09ee4664 Add diagnostic debug output to thumbnail backfill for troubleshooting
Temporary debug version that returns query counts, URL resolution results,
and OG scraping outcomes to identify why thumbnail scraping returns 0.
Also adds Google News URL decoder (base64/protobuf approach).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 19:39:26 +07:00
Terence Ong
5918a7d446 Fix missing thumbnails by resolving Google News redirect URLs before OG scraping
The OG image scraper was using Google News redirect URLs (source_url) directly,
which don't serve og:image tags. Added resolve_scrape_url() to follow redirects
(including meta-refresh and JS redirects) to reach the actual publisher page
before scraping. Also added a backfill AJAX endpoint and admin button to
re-scrape thumbnails for existing articles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 19:32:09 +07:00
Terence Ong
18158a3b81 fix: resolve actual article source instead of showing aggregator domain
Google News RSS feeds report every article as coming from
"news.google.com" because the source was extracted from the feed URL
rather than the individual article. This adds a multi-strategy
resolver that extracts the real publisher name via:

1. SimplePie <source> element (Google News provides this)
2. Title suffix parsing ("Headline - Source" format)
3. HTTP HEAD redirect resolution as a fallback

Also adds a one-click "Fix Article Sources" backfill button on the
settings page to correct existing articles in the database.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 19:11:14 +07:00
peptiderepo
9ec67591bd Merge pull request #1 from peptiderepo/feature/list-layout
feat: switch article display from grid to list layout
2026-04-06 18:58:58 +07:00
Peptide News Team
aad57424c9 fix: add focus states for keyboard a11y and guard empty excerpt
Addresses QA Agent 2 findings:
- Add :focus outline on title and thumbnail links for keyboard navigation
- Wrap excerpt paragraph in conditional to avoid empty <p> when both
  ai_summary and excerpt are missing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 18:55:22 +07:00
Peptide News Team
203aa46036 feat: switch article display from grid to list layout
Rewrites public CSS to match actual .pn-* class names from the PHP
template and changes the default shortcode layout from card/grid to a
horizontal list: fixed-width thumbnail on the left, title + summary on
the right.  Includes compact variant for widgets and responsive
stacking on small screens.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 18:43:16 +07:00
Peptide News Team
15306ade35 chore: bump version to 1.2.2 — pipeline verification test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 18:28:04 +07:00
Peptide News Team
d99c505d1c Add missing Loader class and public CSS
The Peptide_News_Loader class was referenced by class-peptide-news.php
but never committed, causing a fatal error on plugin activation.
Also adds public/css/public-style.css which is enqueued by the public
class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 16:32:42 +07:00
Terence Ong
0b29059463 fix: use linear history for deploy branch instead of orphan/force-push
Hostinger's git pull fails with divergent branches when force-pushing
orphan commits. Switch to a linear commit strategy: checkout the
existing deploy branch, sync plugin files from main, and push normally.
This keeps Hostinger's git pull fast-forward compatible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 15:14:19 +07:00
Terence Ong
1304d205fa refactor: switch deploy to Hostinger GIT pull-based strategy
Replace broken SCP/SSH deploy (blocked by Hostinger firewall) with a
deploy-branch strategy. After CI passes, GitHub Actions pushes only
plugin files to the 'deploy' branch. Hostinger's built-in GIT
integration watches this branch via webhook and auto-pulls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 15:06:18 +07:00
Terence Ong
61d06c10c4 Switch deploy from FTP to SSH/SCP for Hostinger compatibility
FTP deploy timed out due to Hostinger blocking FTPS from external CI
servers. Switched to appleboy/scp-action using SSH on port 65002,
which is more reliable for CI/CD pipelines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:48:50 +07:00
Terence Ong
b9d14cbb59 Add workflow_call trigger to CI for reusable workflow support
The deploy workflow references CI via `uses: ./.github/workflows/ci.yml`
which requires the CI workflow to have an `on: workflow_call` trigger.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:35:27 +07:00
Terence Ong
9f267342a0 Fix pre-existing PHPUnit test failures in CI
Add missing WordPress function stubs (current_user_can, esc_url_raw,
is_user_logged_in, get_current_user_id) and load LLM class in test
bootstrap so AdminTest model validation and RestApiTest permission
checks work correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:26:31 +07:00
Terence Ong
c9be4ceb39 Fix pre-existing syntax errors in analytics and REST API classes
- analytics.php line 38: mismatched quotes on session_id array key
- analytics.php line 246: invalid escape before concatenation operator
- analytics.php line 250: COuNT typo → COUNT
- analytics.php line 252: NULIF typo → NULLIF
- rest-api.php line 54: stray # commenting out foreach variable

These bugs predate the content filter feature but were caught by the
new CI pipeline's PHP lint job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:19:15 +07:00
Terence Ong
e6887e810f Add content filter to block ads, press releases, and promotional content
Two-tier filtering during article fetch: keyword/pattern rules as a fast
first pass, then optional LLM classification for borderline cases via
OpenRouter. Configurable sensitivity (strict/moderate/lenient), editable
keyword lists, blocked domain list, and admin stats display. Includes
30 unit tests covering domain blocking, title/body keywords, URL paths,
edge cases, and prompt structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:14:16 +07:00
Terence Ong
849ffa1260 Add CI/CD pipeline with automated testing and SFTP deployment
Introduces GitHub Actions workflows for continuous integration and
deployment. CI runs PHP linting (7.4, 8.1, 8.3), PHPCS with WordPress
coding standards, PHPUnit tests across PHP versions, and JS syntax
checks. Deployment to Hostinger via FTPS triggers on push to main
after all CI checks pass, with optional LiteSpeed cache purge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 13:41:47 +07:00
Terence Ong
6ed902394d Bump version to 1.2.1 for chart sizing fix deployment
The prepareCanvas wrapper fix (fee4f0f) required a version bump to
bust the LiteSpeed server cache that was serving the old admin-script.js
at the ?ver=1.2.0 URL. A Code Snippets filter on the live server now
rewrites the script version to 1.2.1-<timestamp>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 13:29:29 +07:00
Terence Ong
fee4f0f52a Fix chart sizing with prepareCanvas wrapper
Chart.js with responsive:true + maintainAspectRatio:false requires
the parent container to have an explicit height. Without it, charts
grow unbounded. The prepareCanvas() helper wraps each canvas in a
height-constrained div before Chart initialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 11:15:26 +07:00
Terence Ong
973fb1117a Fix chart sizing issue on analytics dashboard
Charts were not rendering properly because admin-script.js targeted a
non-existent canvas ID (peptide-analytics-chart) instead of the actual
IDs (pn-trends-chart, pn-devices-chart, pn-sources-chart). The script
also used hardcoded demo data instead of the peptideNewsDashboardData
object exported from PHP.

Changes:
- Rewrite admin-script.js to initialise all three dashboard charts
  (line, doughnut, bar) using the correct canvas IDs and PHP data
- Set maintainAspectRatio: false so explicit canvas heights are respected
- Add max-height CSS constraint on chart canvases to prevent unbounded
  vertical growth
- Sync JS/CSS to admin/ root directory to match PEPTIDE_NEWS_PLUGIN_URL
  asset path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 10:45:42 +07:00
Terence Ong
4367d68202 fix: security hardening for LLM thumbnail feature (QA-002,004,005,006)
- Use $wpdb->prepare() with esc_like() in clear_article_cache()
- Add strict base64_decode() validation with error handling
- Add isset()/is_array()/is_string() checks for nested array access
- Add wp_http_validate_url() SSRF prevention on all image downloads
- Add limit_response_size (5MB) on image URL downloads
- Set chmod 0644 after file_put_contents()
2026-04-06 10:19:53 +07:00
peptiderepo
01a794cd5f fix: security hardening for thumbnail feature (QA-001,003,004,006,008)
- Use $wpdb->prepare() with esc_like() in clear_article_cache()
- Add wp_http_validate_url() SSRF prevention in download_thumbnail()
- Add limit_response_size (5MB) on image downloads
- Set chmod 0644 after file_put_contents()
- Add transient-based concurrent fetch lock
2026-04-06 10:16:16 +07:00
peptiderepo
a58423990b fix(admin): add sanitize_callbacks, model ID validation, max articles per cycle setting 2026-04-06 01:08:36 +07:00
peptiderepo
17e8247d2a fix(llm): add 429 retry, timeout guard, model validation, XSS protection, batch cache clear 2026-04-06 01:01:19 +07:00
peptiderepo
07d11499b2 fix(fetcher): use admin batch size setting, validate fetch_log type 2026-04-06 00:56:23 +07:00
peptiderepo
98e9c8516e fix(activator): remove TEXT DEFAULT for MySQL strict mode, add llm_max_articles default 2026-04-06 00:49:06 +07:00
peptiderepo
b8a266e302 fix(v1.1.0): bump version, add DB upgrade migration on plugins_loaded 2026-04-06 00:36:07 +07:00
peptiderepo
c6079830f0 feat: display AI summary and keyword tags on frontend 2026-04-06 00:27:52 +07:00
peptiderepo
5bd6d7ec1a feat: add AI Keywords and AI Summary columns to articles list 2026-04-06 00:23:27 +07:00
peptiderepo
f753684a10 feat: integrate LLM processing into cron fetch cycle 2026-04-06 00:21:02 +07:00
peptiderepo
740d6026c4 feat: add OpenRouter settings section with model selection per function 2026-04-06 00:18:06 +07:00
peptiderepo
bdb4a17630 feat: add ai_summary column and LLM default options 2026-04-06 00:11:09 +07:00
peptiderepo
f672b4a670 feat: load LLM class dependency 2026-04-06 00:10:02 +07:00
peptiderepo
59b19b3c9e feat: add OpenRouter LLM integration for keyword extraction and summarization 2026-04-06 00:09:26 +07:00
peptiderepo
91103afcee feat: add default thumbnail placeholder image 2026-04-05 23:41:06 +07:00
peptiderepo
9d04f52c78 feat: add i18n POT file with all translatable strings 2026-04-05 23:40:26 +07:00
peptiderepo
6eeecb2d11 fix: add Secure flag to session cookie on HTTPS 2026-04-05 23:39:14 +07:00
peptiderepo
59bf17bcfb fix: conditional asset loading, rate limiting, session cookie 2026-04-05 23:38:42 +07:00
peptiderepo
05733ebcbd fix: add date validation and nonce to CSV export link 2026-04-05 23:36:36 +07:00
peptiderepo
67b802a38d fix: add CSRF on CSV export, article retention setting, correct cron defaults 2026-04-05 23:34:51 +07:00
peptiderepo
013a629ae1 fix: use article_retention option for pruning articles 2026-04-05 23:29:01 +07:00
peptiderepo
baa9794777 fix: guard division by zero in source performance SQL 2026-04-05 23:27:09 +07:00
peptiderepo
6332bab35a fix: rename NAMESPACE to API_NAMESPACE, add date validation 2026-04-05 23:25:10 +07:00