Skip to content

Playground: per-aggregator seeds, 30-post fixture, sideloaded Unsplash thumbnails (#35)#36

Merged
mt8 merged 1 commit intomainfrom
feature/35-playground-multi-seed
Apr 28, 2026
Merged

Playground: per-aggregator seeds, 30-post fixture, sideloaded Unsplash thumbnails (#35)#36
mt8 merged 1 commit intomainfrom
feature/35-playground-multi-seed

Conversation

@mt8
Copy link
Copy Markdown
Owner

@mt8 mt8 commented Apr 28, 2026

Closes #35.

Summary

Playground demo を 複数アグリゲータプリセットの showcase に再構成。30 件のリアルなサンプル投稿と Unsplash 画像を全自動でセットアップし、起動直後にフィード一覧から各仕様の出力を確認できる。

Changes

Layout

playground/
├── blueprint.json
├── assets/                       PNG ロゴ(SVG → Playwright で書き出し)
│   ├── icon.png
│   ├── logo.png
│   ├── logo-light.png
│   └── logo-horizontal.png       SmartNews snf:logo / snf:darkModeLogo で参照
└── seeds/
    ├── posts.xml                 30 投稿フィクスチャ
    ├── seed-helpers.php          ブロックマークアップ生成
    ├── seed-shared.php           options + terms + 投稿 + 画像 sideload
    ├── seed-goonews.php
    ├── seed-mediba.php
    └── seed-smartnews.php

playground/seed.php(単一 SmartNews demo)は削除。

blueprint.json

  • landingPage/wp-admin/edit.php?post_type=feedwright_feed(フィード一覧)に変更
  • 各 seed を writeFile + wp-cli で順次実行(helpers → shared → goonews → mediba → smartnews)

posts.xml の 30 投稿

  • 5 カテゴリ × 6 投稿 = 30 件、News / Tech / Lifestyle / Sports / Business のバランス配分
  • 各投稿に Unsplash の photo-{ID}image_id 属性で紐付け
  • 2 投稿を status="trash"(mediba <mdf:deleted/> のデモ用)
  • カテゴリ定義の <terms> ブロックに mediba カテゴリ ID も含めて 1 ファイルで完結

seed-shared.php

  • posts.xml を SimpleXML で解析
  • 各投稿に対し:
    • wp_insert_post
    • wp_set_post_terms(カテゴリ + タグ)
    • Unsplash 画像 (https://images.unsplash.com/{photo_id}?w=1200&q=80&fit=crop) を download_url + media_handle_sideload でメディアライブラリ取り込み
    • set_post_thumbnail(アイキャッチ)
    • <figure> を post_content の先頭に注入
  • 全投稿挿入後に対象投稿を wp_trash_post
  • _mediba_category_id を term meta として設定

SmartNews seed

  • snf:logo / snf:darkModeLogo の URL は playground/assets/logo-horizontal.pngraw.githubusercontent.com 経由で参照

mediba seed

  • <mdf:deleted/> を trash 投稿だけに、それ以外は通常要素を feedwright/when の negate で出し分け
  • <category>post_term_meta.category._mediba_category_id で解決
  • postStatus = ['publish', 'trash'] + trashWithinDays = 7 で削除窓を制御

goonews seed

  • <smp:relation>feedwright/sub-query(taxonomy mode、最大 3)で展開

Test plan

  • Playground 起動https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/mt8/feedwright/main/playground/blueprint.json を開いて、ランディングがフィード一覧、3 フィード(goonews / mediba / smartnews)が公開状態
  • 画像:各投稿にアイキャッチが付き、/wp-admin/edit.php の一覧で thumbnail 列に画像が見える
  • 本文:投稿本文の先頭に <figure> で同じ画像が表示される
  • goonews フィード:各 item に最大 3 件の <smp:relation>(同カテゴリ siblings)
  • mediba フィード:trash 投稿は <mdf:deleted/> のみ、publish は通常要素一式、<category> がカテゴリの mediba ID(91 / 101 / 201 / 202 / 503)に解決
  • smartnews フィード<snf:logo> / <snf:darkModeLogo> に Feedwright のロゴ PNG URL、<media:thumbnail> に sideload された画像 URL
  • PHP lint:全 seed が php -l 通過

影響範囲

playground/ 配下のみ。プラグイン本体・テスト・docs に影響なし。

…h thumbnails (#35)

Re-shape the Playground demo into a multi-feed showcase that exercises
the public spec primitives (sub-query, when-block, post_term_meta,
trash + N-day window) and produces a visually rich result.

Layout:
- playground/blueprint.json     orchestrates the seeds; landing page is
                                now /wp-admin/edit.php?post_type=feedwright_feed
                                (the feed list)
- playground/assets/*.png       PNG logos rendered from assets/*.svg via
                                Playwright/Chromium; used by SmartNews
                                snf:logo and snf:darkModeLogo
- playground/seeds/posts.xml    30-post fixture: 6 per category across
                                News / Tech / Lifestyle / Sports /
                                Business, 2 marked status='trash' to
                                demonstrate <mdf:deleted/> end-to-end.
                                Each post carries an Unsplash image_id
                                attribute used both as featured image
                                and as a top-of-body figure
- playground/seeds/seed-helpers.php  shared block-markup builders
- playground/seeds/seed-shared.php   parses posts.xml, sets up taxonomy
                                     terms (with mediba category-ID term
                                     meta), creates the admin profile,
                                     sideloads each Unsplash image, sets
                                     it as featured, and embeds it at
                                     the top of post_content
- playground/seeds/seed-{goonews,mediba,smartnews}.php
                                build the three feedwright_feed posts

Old single playground/seed.php deleted (was a one-off SmartNews demo).
@mt8 mt8 merged commit bf33961 into main Apr 28, 2026
7 checks passed
@mt8 mt8 deleted the feature/35-playground-multi-seed branch April 28, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playground demo を per-aggregator seed 構造に再編成し、3 ニュースフィード(goo / mediba / SmartNews)をプリセット

1 participant