Files
reverse-engineering-anything/scripts/prepare-website.py
T
morluto ca66ab63ba feat(website): improve search reach and complete 27 language editions (#16783)
* feat(website): lead search metadata with the REA tagline

Search results showed a generic homepage description, and rea.tools did not
rank for its own name, "Reverse Engineer Anything".

- Homepage title and description lead with "Reverse engineer anything,
  reimagine everything" in plain language, and the hero shows the tagline.
- Guide hub and first investigation titles match "how to reverse engineer
  an app with AI" searches.
- The English homepage publishes WebSite and SoftwareApplication structured
  data naming REA and "Reverse Engineer Anything", linked to GitHub, npm and X.
- The npm package homepage points to https://rea.tools.
- Translations of the changed messages keep 19 language homepages indexable.

* fix(website): match local search terms and list rea.tools in the MCP registry

Japanese and French coverage of REA uses なんでもリバースエンジニアリング and rétro-ingénierie, so the new titles and descriptions use the same terms. The MCP registry websiteUrl now points to https://rea.tools instead of the repository.

* fix(website): say the AI agent understands software, and repair blog descriptions

The homepage description now says REA lets your AI agent understand how any app, game or website works, translated for 19 editions. The blog index description had machine-translation errors in 8 languages, including Arabic rendering AI as Amnesty International; those are corrected.

* fix(website): rewrite Vietnamese translations for clarity

Replace machine-translated Vietnamese with natural wording across every
page: consistent terms for coding agent, case study, prompt and file,
correct breadcrumbs and number formats, and readable case studies, guides
and essays.

* fix(website): align translated titles and coding-agent terms

End translated titles with the same " — REA" separator as English, use
the established coding-agent term in German, Thai and Arabic, and fix the
French get-started title.

* feat(website): describe page breadcrumbs for search results

Search engines can show a page's place on the site (rea.tools > Guides > ...)
instead of a bare URL. The trail is read from each built page's visible
breadcrumb, so every language edition gets its own translated names.

* feat(website): add beginner and Ghidra/IDA guides and complete all 27 editions

New pages for people searching for reverse engineering itself:
"What is reverse engineering?", "Reverse engineering with AI" and
"Use Ghidra or IDA with an AI agent", linked from the homepage and guides.
The FAQ answers where to get REA safely, whether it is free, how it
differs from a Ghidra or IDA MCP server, whether it recovers source code
and whether reverse engineering is legal.

Case-study, browser and dinosaur pages get titles that match what people
search for, and the case-study index leads with "REA Examples".

Every translation was reviewed and largely rewritten where it was machine
translated, including wrong word senses, broken placeholders and, in Thai,
unrelated text. Malayalam, Roman Urdu, Romanian and Bulgarian are now
complete, and Hindi, Dutch and Bengali are new editions with READMEs. All
26 catalogs are fully translated, so no page falls back to English.

* fix(website): read breadcrumbs with an HTML parser and correct IDA support

Breadcrumb structured data now finds the trail by its class with an
HTML-aware parser, so extra classes, attribute order and line breaks no
longer drop a valid breadcrumb.

The Ghidra and IDA guide no longer promises callers or byte reads through
IDA, which no IDA profile provides; it suggests cross-references instead.
The example prompt is engine-neutral, the terminal example says how to
select IDA, and the ida-free-mcp choice warns that its 1.1.2 release
accepts connections from other computers until a firewall or a
local-only build restricts it.
2026-12-04 11:49:29 -05:00

206 lines
8.5 KiB
Python

"""Prepare downloads, the sitemap and the sharing image for the static website."""
from io import BytesIO
from pathlib import Path
import json
import sys
from urllib.parse import urljoin
import xml.etree.ElementTree as ET
from zipfile import ZipFile
from website import SOCIAL_FIGURES, SITE_ORIGIN, indexable_pages, page_url, write_download_member
from website_agents import prepare_discovery, prepare_markdown
EXAMPLE_FILES = (
"package.json",
"main.js",
"preload.js",
"renderer.js",
"csv.js",
"index.html",
)
def prepare_sitemap(site):
"""Discover HTML routes automatically, excluding pages marked noindex."""
namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"
ET.register_namespace("", namespace)
sitemap = ET.Element(f"{{{namespace}}}urlset")
for path, _, _ in indexable_pages(site):
entry = ET.SubElement(sitemap, f"{{{namespace}}}url")
ET.SubElement(
entry, f"{{{namespace}}}loc"
).text = page_url(site, path)
ET.indent(sitemap, space=" ")
ET.ElementTree(sitemap).write(
site / "sitemap.xml", encoding="utf-8", xml_declaration=True
)
print(f"Prepared sitemap.xml ({len(sitemap)} indexable pages).")
def prepare_images(site):
"""Render social previews and the conventional browser icon from their sources."""
try:
import cairosvg
except (ImportError, OSError) as error:
sys.exit(
f"Cannot prepare sharing image: {error}. Install website/requirements.txt and native Cairo; see website/README.md."
)
from PIL import Image, ImageOps
root = Path(__file__).resolve().parent.parent
artwork = root / "website/artwork"
def render(source, width):
png = cairosvg.svg2png(url=str(source), output_width=width)
with Image.open(BytesIO(png)) as image:
return image.convert("RGBA")
favicon = render(site / "assets/favicon.svg", 192)
favicon.save(site / "favicon.ico", sizes=[(n, n) for n in (16, 32, 48, 64, 192)])
with Image.open(artwork / "rea-social-preview.png") as original:
default = ImageOps.fit(original.convert("RGB"), (1200, 630), method=Image.Resampling.LANCZOS)
default.save(site / "assets/social-card.png", optimize=True)
directory = site / "assets/share"
directory.mkdir(exist_ok=True)
for source in sorted(set(SOCIAL_FIGURES.values())):
figure = ImageOps.contain(render(root / source, 1200), (1200, 630))
card = Image.new("RGB", (1200, 630), "white")
card.paste(figure, ((1200 - figure.width) // 2, (630 - figure.height) // 2), figure)
card.save(directory / (Path(source).stem + ".png"), optimize=True)
def prepare_notes_example(site):
"""Create a ZIP with public source only and reproducible metadata."""
source = site / "examples/notes-electron"
contents = BytesIO()
with ZipFile(contents, "w") as archive:
for name in EXAMPLE_FILES:
write_download_member(archive, f"notes-example/{name}", (source / name).read_bytes(), compresslevel=9)
destination = site / "examples/notes-example.zip"
destination.write_bytes(contents.getvalue())
print(f"Prepared examples/notes-example.zip ({len(EXAMPLE_FILES)} files).")
def site_identity(description):
"""Name the site and the product for search engines on the English homepage only."""
root = f"{SITE_ORIGIN}/"
return [
{
"@type": "WebSite", "url": root,
"name": "REA", "alternateName": ["Reverse Engineer Anything", "rea.tools"],
},
{
"@type": "SoftwareApplication", "url": root,
"name": "REA", "alternateName": "Reverse Engineer Anything",
"description": description,
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Linux, Windows",
"license": "https://opensource.org/license/mit",
"offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD"},
"sameAs": [
"https://github.com/morluto/rea",
"https://www.npmjs.com/package/rea-agents",
"https://x.com/reatools",
],
},
]
def breadcrumb_list(source, url):
"""Describe the page's visible breadcrumb trail, in its own language, for search results."""
from bs4 import BeautifulSoup, SoupStrainer
trail = BeautifulSoup(source, "html.parser", parse_only=SoupStrainer("p", class_=lambda value: value is not None and "breadcrumb" in str(value).split())).p
links = trail.find_all("a", href=True) if trail else []
if not links:
return None
following = "".join(
node.get_text() if hasattr(node, "get_text") else str(node) for node in links[-1].next_siblings
)
current = " ".join(following.split()).lstrip("/ ").strip()
if not current:
return None
items = [{"name": " ".join(link.get_text().split()), "item": urljoin(url, link["href"])} for link in links]
items.append({"name": current})
return {
"@type": "BreadcrumbList",
"itemListElement": [{"@type": "ListItem", "position": n, **item} for n, item in enumerate(items, 1)],
}
def prepare_search_images(site):
from bs4 import BeautifulSoup
for path in site.rglob("*.html"):
source = path.read_text(encoding="utf-8")
head = BeautifulSoup(source.partition("</head>")[0], "html.parser")
fields = {tag["property"]: tag["content"] for tag in head.select("meta[property][content]")}
if "og:image" not in fields:
continue
url = fields["og:url"]
data = {
"@type": "WebPage", "url": url,
"name": fields["og:title"], "inLanguage": head.html["lang"],
"primaryImageOfPage": fields["og:image"],
}
breadcrumb = breadcrumb_list(source, url)
if breadcrumb:
data["breadcrumb"] = breadcrumb
if fields["og:type"] == "article":
data["mainEntity"] = {
"@type": "BlogPosting", "headline": fields["og:title"],
"description": fields["og:description"], "image": fields["og:image"],
"mainEntityOfPage": url,
}
if url == f"{SITE_ORIGIN}/":
data = {"@graph": [data, *site_identity(fields["og:description"])]}
data = {"@context": "https://schema.org", **data}
payload = json.dumps(data, ensure_ascii=False).replace("<", "\\u003c")
path.write_text(source.replace("</head>", f'<script type="application/ld+json">{payload}</script>\n </head>', 1), encoding="utf-8")
def prepare_redirects(site):
"""Publish permanent Cloudflare redirects and equivalent static Pages links."""
routes = {
"showcases": ("showcase", "REA showcases"),
"environments": ("guides/rl-environments", "Build RL environments"),
}
from bs4 import BeautifulSoup
rules = []
for alias, (target, title) in routes.items():
rules.extend(f"/{alias}{suffix} /{target}/ 301" for suffix in ("", "/"))
directory = site / alias
directory.mkdir()
destination = BeautifulSoup((site / target / "index.html").read_text(encoding="utf-8").partition("</head>")[0], "html.parser")
sharing = "\n".join(str(tag) for tag in destination.select('meta[property^="og:"], meta[name^="twitter:"]'))
directory.joinpath("index.html").write_text(
f'<!doctype html><html lang="en"><head><meta charset="utf-8">\n'
f'<title>{title}</title><meta name="robots" content="noindex">\n'
f'<link rel="canonical" href="{SITE_ORIGIN}/{target}/">\n'
f'{sharing}\n<meta http-equiv="refresh" content="0; url=../{target}/"></head>\n'
f'<body><h1><a href="../{target}/">{title}</a></h1></body></html>\n',
encoding="utf-8",
)
(site / "_redirects").write_text("\n".join(rules) + "\n", encoding="utf-8")
def prepare_assets(site):
"""Finish the shared publish artifact before it replaces the current preview."""
from rcssmin import cssmin
stylesheet = site / "assets/styles.css"
stylesheet.write_text(cssmin(stylesheet.read_text(encoding="utf-8")), encoding="utf-8")
prepare_search_images(site)
prepare_redirects(site)
prepare_images(site)
prepare_sitemap(site)
prepare_notes_example(site)
prepare_discovery(Path(__file__).resolve().parent.parent, site)
prepare_markdown(site)
if __name__ == "__main__":
root = Path(__file__).resolve().parent.parent
from website_i18n import build_translations
build_translations(root, root / "website/_site", finalize=prepare_assets)