trypost/lang/en/onboarding.php
Paulo Castellano bde10059e3 feat: add brand autofill from website URL in onboarding
Users on the Brand step can type their website URL and click
'Preencher' (Portuguese) / 'Autofill' (English). The backend fetches
their homepage, parses standard meta tags, and returns:

- name        ← og:site_name | title (suffix stripped at ' | ', ' - ')
- description ← meta[name=description] | og:description
- language    ← <html lang> mapped to en / pt-BR / es
- logo        ← apple-touch-icon | largest link[rel*=icon] | og:image

The logo is downloaded, validated (mime whitelist, 2MB max), and
attached to the workspace's 'logo' media collection so the avatar
updates immediately.

Zero LLM calls, zero external APIs. Uses symfony/dom-crawler +
symfony/css-selector (newly required) for meta extraction. Everything
else (Http client, workspace media, Intervention) was already in the
project.

Security:
- SSRF guardrail: resolves the host, rejects private / loopback /
  link-local ranges, enforces http(s) scheme on both the initial
  page fetch and the logo download.
- Rate limited at 10 req/min per user via the throttle middleware
  alias on the route.
- Logo content-type must be one of the allowed image mimes; wrong
  types are silently dropped so users never see broken images.

UX:
- 'Autofill' button next to the website input, disabled until there
  is a URL; shows a spinner while running.
- If a logo was captured, a small preview appears below the input
  so users can see what was pulled before saving.
- Success and error paths both surface as vue-sonner toasts, with
  translations in en / pt-BR / es.
- Failures leave the form untouched — nothing is destructively
  overwritten if parsing gave us nothing.

Tests (16 new): action-level coverage for happy path, title-suffix
fallback, language code normalization across 6 locales, scheme
rejection, private-range SSRF rejection, implicit https prefixing,
empty sites, upstream errors, and wrong-mime logo rejection. Plus
two controller-level tests for the autofill endpoint.
2026-04-16 11:13:54 -03:00

61 lines
2 KiB
PHP

<?php
declare(strict_types=1);
return [
'role' => [
'page_title' => 'Welcome - Tell us about yourself',
'title' => 'Tell us about yourself',
'description' => 'Help us personalize your experience',
'submit' => 'Continue',
],
'personas' => [
'founder' => [
'label' => 'Founder',
'description' => 'Building a startup or new venture',
],
'creator' => [
'label' => 'Creator',
'description' => 'Content creator or influencer',
],
'agency' => [
'label' => 'Agency',
'description' => 'Marketing or social media agency',
],
'enterprise' => [
'label' => 'Enterprise',
'description' => 'Large company or corporation',
],
'small_business' => [
'label' => 'Small Business',
'description' => 'Small to medium business',
],
'personal' => [
'label' => 'Personal',
'description' => 'Personal brand or hobby',
],
],
'brand' => [
'page_title' => 'Tell us about your brand',
'title' => 'Tell us about your brand',
'description' => 'These defaults power every AI-generated post in this workspace. You can change them later in Settings.',
'submit' => 'Continue',
'skip' => 'Skip for now',
'autofill' => 'Autofill',
'autofill_success' => 'We pulled what we could from your site. Review and adjust if needed.',
'autofill_error' => 'We could not read that site. Please fill in manually.',
'autofill_missing_url' => 'Add your website URL first.',
'logo_captured' => 'Logo captured from your site.',
],
'connect' => [
'page_title' => 'Connect your accounts',
'title' => 'Connect your accounts',
'description' => 'Connect at least one social network to get started',
'submit' => 'Continue',
'error' => 'Something went wrong. Please try again.',
'go_back' => 'Go Back',
],
];