{"skill":{"slug":"nexus-ciba-wechat","displayName":"词霸每日一句","summary":"generate shareable html and png cards from the ciba or iciba daily sentence api. use when the user asks for 词霸每日一句, iciba, ciba, open.iciba.com/dsapi, daily...","description":"---\nname: nexus-ciba-wechat\ndescription: generate shareable html and png cards from the ciba or iciba daily sentence api. use when the user asks for 词霸每日一句, iciba, ciba, open.iciba.com/dsapi, daily english sentence cards, magazine torn-paper cards, friends circle or moments poster layouts, postcard horizontal cards, qr codes for tts pronunciation audio, multi-template html customization, or playwright rendering of these cards to png.\n---\n\n# Nexus Ciba Wechat\n\n## Overview\n\nUse this skill to create polished HTML and PNG cards from the 词霸每日一句 API at `https://open.iciba.com/dsapi/`. The bundled renderer supports multiple HTML templates, including a vertical friends-circle card and a horizontal postcard-style card, with QR codes that encode the API `tts` audio URL.\n\n## Default workflow\n\n1. Use `scripts/render_iciba_card.py` unless the user explicitly asks for hand-written HTML only.\n2. Fetch the daily JSON from `https://open.iciba.com/dsapi/` by default.\n3. Prefer the API image fields for the hero image in this order: `picture`, `picture2`, `picture3`, `picture4`.\n4. Only generate the local fallback image if the API cannot be reached or all picture downloads fail.\n5. Encode `tts` into the QR code. Do not encode the page URL unless the user explicitly asks.\n6. Choose the template requested by the user, or use `moments_vertical` by default.\n7. Render the selected HTML template to PNG with Playwright.\n8. Return links to the generated PNG and HTML. Also mention whether the card used the API picture or the generated fallback.\n\n## Script usage\n\nRun from the skill directory or pass the script path directly:\n\n```bash\npython scripts/render_iciba_card.py --output-dir /mnt/data/iciba-card\n```\n\nList available templates:\n\n```bash\npython scripts/render_iciba_card.py --list-templates\n```\n\nRender the default vertical friends-circle card:\n\n```bash\npython scripts/render_iciba_card.py \\\n  --template moments_vertical \\\n  --output-dir /mnt/data/iciba-card\n```\n\nRender the horizontal postcard card:\n\n```bash\npython scripts/render_iciba_card.py \\\n  --template postcard_horizontal \\\n  --output-dir /mnt/data/iciba-postcard\n```\n\nUseful options:\n\n```bash\npython scripts/render_iciba_card.py \\\n  --template postcard_horizontal \\\n  --output-dir /mnt/data/iciba-postcard \\\n  --width 1200 \\\n  --height 760 \\\n  --api-url https://open.iciba.com/dsapi/\n```\n\nFor testing or reproducibility without live network access, pass a JSON file:\n\n```bash\npython scripts/render_iciba_card.py --input-json /mnt/data/iciba.json --output-dir /mnt/data/iciba-card\n```\n\nExpected outputs in the output directory:\n\n- `<output_stem>.html`\n- `<output_stem>.png`\n- `<output_stem>_data.json`\n- `hero_source.txt`\n\nDefault output stems:\n\n- `moments_vertical` -> `iciba_moments_card`\n- `postcard_horizontal` -> `iciba_postcard_horizontal`\n\n## Template system\n\nHTML is separated from Python and stored in `templates/`:\n\n- `templates/moments_vertical.html`: 9:16 friends-circle card, image above and text below.\n- `templates/postcard_horizontal.html`: horizontal postcard-style card, photo left and message/stamp area right.\n\nTemplates use simple replacement tokens rather than a templating dependency. Supported tokens include:\n\n- `[[WIDTH]]`, `[[HEIGHT]]`, `[[TEMPLATE_NAME]]`\n- `[[CAPTION]]`, `[[CONTENT]]`, `[[NOTE]]`, `[[TRANSLATION]]`, `[[DATELINE]]`\n- `[[ISSUE_DAY]]`, `[[ISSUE_TEXT]]`, `[[QUOTE_SIZE]]`\n- `[[HERO_URI]]`, `[[HERO_ALT]]`, `[[HERO_SOURCE]]`, `[[HERO_FIELD]]`, `[[HERO_URL]]`\n- `[[QR_URI]]`, `[[TTS_URL]]`, `[[STATUS]]`\n\nTo add a new template, create a new HTML file under `templates/`, add an entry to `TEMPLATE_CONFIG` in `scripts/render_iciba_card.py`, then test with `--template <name>`.\n\n## Layout rules\n\nFor `moments_vertical`:\n\n- Use a 9:16 canvas, default `540 x 960` CSS pixels.\n- Keep the image in the top section, not as a full-card background.\n- Keep the text in a separate lower paper section.\n- Put the QR code in the lower-right of the text section.\n\nFor `postcard_horizontal`:\n\n- Use a horizontal canvas, default `1200 x 760` CSS pixels.\n- Keep the hero image on the left and the postcard message area on the right.\n- Include a postcard cue such as `POST CARD`, address lines, a stamp area, and a QR voice stamp.\n- Keep the quote and translation readable; reduce quote size for long sentences.\n\nFor all templates:\n\n- Preserve the magazine or paper aesthetic through clipped edges, paper texture, subtle shadows, tape accents, and warm cream tones.\n- Keep text readable over decoration.\n- Put the QR code payload on `tts`, not on the HTML page URL, unless explicitly requested otherwise.\n\n## Data mapping\n\nUse these fields from the API:\n\n- `caption` -> label, default `词霸每日一句`\n- `content` -> main English quote\n- `note` -> Chinese translation\n- `translation` -> small source line, default `新版每日一句`\n- `dateline` -> displayed date and issue badge\n- `tts` -> QR code payload\n- `picture`, `picture2`, `picture3`, `picture4` -> image candidates, in that priority order\n\nSee `references/iciba-api-fields.md` for more details.\n\n## Path separator behavior\n\nThe Python renderer keeps `pathlib.Path` for real filesystem operations, but formats logged and serialized output paths with the native OS separator. Windows uses `\\`; Linux, macOS, and other POSIX-like systems use `/`. The generated data JSON includes `_path_separator` and `_output_dir` for debugging.\n\n## Handling failures\n\nIf the API fetch fails, use the built-in fallback data and clearly state that the run used fallback data. If the API returns text but image download fails, still use the API text and `tts`, but use the generated fallback image. Do not claim that the visible image came from an API picture unless `hero_source.txt` says `api_picture` and includes the selected picture field and URL.\n","topics":["WeChat","Playwright","Audio"],"tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":370,"installsAllTime":14,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1777951807699,"updatedAt":1778492850251},"latestVersion":{"version":"1.0.0","createdAt":1777951807699,"changelog":"Initial release of nexus-ciba-wechat skill.\n\n- Generates shareable HTML and PNG cards from the 词霸每日一句 (Ciba Daily Sentence) API.\n- Supports multiple magazine-style templates: vertical friends-circle and horizontal postcard layouts.\n- Embeds QR codes for pronunciation audio (tts field from API).\n- Automatically fetches daily sentences, prefers available API images, and falls back to generated images on failure.\n- Uses Playwright to render HTML templates to downloadable PNGs.\n- Simple template system enables customization; full documentation included on usage and output structure.","license":"MIT-0"},"metadata":null,"owner":{"handle":"lwter","userId":"s176d675ym6asee2mm13zz5c558652j6","displayName":"Neway Lau","image":"https://avatars.githubusercontent.com/u/5044960?v=4"},"moderation":null}