File size: 8,082 Bytes
aa09365 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | """Shared page chrome: global nav, footer, home page and product-line pages.
The nav, the home page's imagery and copy, and every product-line page's
title/heading outline are loaded from JSON captured off the source on
2026-08-29 (see each file's ``evidence`` field). Controls whose only source
destination was an external origin are omitted per EXTERNAL_ORIGIN_POLICY
rather than rendered as dead links.
"""
from __future__ import annotations
import json
from functools import lru_cache
from pathlib import Path
DATA = Path(__file__).resolve().parents[1] / "data"
CATEGORY_PATH = "/shop/accessories/all/cases-protection"
@lru_cache(maxsize=1)
def _navigation() -> list[dict]:
return json.loads((DATA / "navigation.json").read_text(encoding="utf-8"))["menus"]
@lru_cache(maxsize=1)
def home() -> dict:
return json.loads((DATA / "home.json").read_text(encoding="utf-8"))
@lru_cache(maxsize=1)
def product_lines() -> dict[str, dict]:
return json.loads((DATA / "product_lines.json").read_text(encoding="utf-8"))["pages"]
def nav(categories: list[dict]) -> list[dict]:
"""The source's eleven menus, with the accessory categories spliced in.
``Accessories`` is the one menu whose contents are data rather than
captured copy: it lists the categories this clone actually seeded.
"""
menus = [dict(menu) for menu in _navigation()]
for menu in menus:
if menu["id"] != "accessories":
continue
menu["groups"] = [
{
"title": "Shop by Category",
"links": [{"label": "Shop All Accessories", "href": "/shop/accessories/all"}]
+ [
{
"label": category["name"],
"href": f"/shop/accessories/all/{category['id']}",
}
for category in categories
],
}
] + [group for group in menu["groups"] if group["title"] != "Shop by Category"]
return menus
FOOTER = [
{
"title": "Shop and Learn",
"links": [
{"label": "Store", "href": "/shop/buy-mac"},
{"label": "Mac", "href": "/mac"},
{"label": "iPad", "href": "/ipad"},
{"label": "iPhone", "href": "/iphone"},
{"label": "Watch", "href": "/watch"},
{"label": "AirPods", "href": "/airpods"},
{"label": "TV & Home", "href": "/tv-home"},
{"label": "Accessories", "href": "/shop/accessories/all"},
],
},
{
"title": "Account",
"links": [
{"label": "Manage Your Apple Account", "href": "/shop/account"},
{"label": "Create Your Apple Account", "href": "/shop/register"},
{"label": "Sign In", "href": "/shop/signin"},
],
},
{
"title": "Apple Store",
"links": [
{"label": "Find a Store", "href": "/retail"},
{"label": "Genius Bar", "href": "/retail/geniusbar"},
{"label": "Order Status", "href": "/shop/order/list"},
{"label": "Apple Trade In", "href": "/shop/trade-in"},
{"label": "Financing", "href": "/shop/payment-plan"},
{"label": "Shopping Help", "href": "/shop/help"},
],
},
{
"title": "For Business",
"links": [
{"label": "Apple and Business", "href": "/business"},
{"label": "Mac for Business", "href": "/business/mac"},
{"label": "Education", "href": "/education"},
],
},
{
"title": "About Apple",
"links": [
{"label": "Newsroom", "href": "/newsroom"},
{"label": "Privacy", "href": "/privacy"},
{"label": "Contact Apple", "href": "/contact"},
],
},
]
BAG_FAQS = [
{
"question": "When will I get my items?",
"answer": "Delivery estimates appear at checkout for each item in your bag.",
},
{
"question": "Can I pick up my items at an Apple Store?",
"answer": "Eligible items can be reserved for pickup at a nearby store.",
},
{
"question": "What are my payment options?",
"answer": "You can pay by card, Apple Card Monthly Installments, or Apple Pay.",
},
{
"question": "What are my financing options?",
"answer": "Apple Card Monthly Installments spreads the cost over 12 months at 0% APR.",
},
{
"question": "When I buy from apple.com, does Apple offer support?",
"answer": "Every purchase includes complimentary support from Apple.",
},
]
BUY_MAC_MODELS = [
("MacBook Neo", "macbook-neo"),
("MacBook Air", "macbook-air"),
("MacBook Pro", "macbook-pro"),
("iMac", "imac"),
("Mac mini", "mac-mini"),
("Mac Studio", "mac-studio"),
("Studio Display", "studio-display"),
("Studio Display XDR", "studio-display-xdr"),
]
# Buy landings: the shop entry points the nav links to, and the catalogue
# search term each one uses to show real accessories for that product line.
BUY_LANDINGS = {
"/shop/buy-iphone": ("Shop iPhone", "iPhone"),
"/shop/buy-ipad": ("Shop iPad", "iPad"),
"/shop/buy-watch": ("Shop Apple Watch", "Apple Watch"),
"/shop/buy-vision": ("Shop Apple Vision Pro", "Vision"),
"/shop/buy-tv-home": ("Shop TV & Home", "HomePod"),
}
# Extra local routes the nav and footer reach that are not product-line pages.
EXTRA_PAGES = {
"/apple-events": ("Apple Events", "Watch a special Apple Event."),
"/apple-card": ("Apple Card", "Get up to 3% Daily Cash back with every purchase."),
"/shop/trade-in": (
"Apple Trade In",
"Get credit toward a new device when you trade in.",
),
"/shop/payment-plan": (
"Financing",
"Apple Card Monthly Installments at 0% APR.",
),
"/shop/help": ("Shopping Help", "Answers about buying from this store."),
"/retail": ("Find a Store", "Apple Store locations."),
"/newsroom": ("Newsroom", "Apple news and updates."),
"/contact": ("Contact Apple", "Ways to reach Apple."),
"/legal": ("Legal", "Legal information."),
"/legal/privacy": ("Privacy Policy", "How this offline clone handles data."),
"/legal/terms": ("Terms of Use", "Terms for this offline clone."),
"/legal/sales-and-refunds": ("Sales and Refunds", "Sales and refund policy."),
"/sitemap": ("Site Map", "All routes in the frozen scope."),
"/us/search/reseller": ("Other retailers", "Where else to buy."),
"/r/store/government": ("Government Store", "Purchasing for government."),
"/accessibility/assistive-technologies": (
"Assistive Technologies",
"Accessibility features built into every Apple product.",
),
}
# Which accessory search term backs each product-line page's shop rail.
LINE_SEARCH_TERMS = {
"mac": "Mac",
"macbook-air": "MacBook Air",
"macbook-pro": "MacBook Pro",
"macbook-neo": "MacBook",
"imac": "iMac",
"mac-mini": "Mac mini",
"mac-studio": "Mac Studio",
"displays": "Display",
"ipad": "iPad",
"ipad-pro": "iPad Pro",
"ipad-air": "iPad Air",
"ipad-mini": "iPad mini",
"ipad-11": "iPad",
"ipad-keyboards": "Keyboard",
"apple-pencil": "Apple Pencil",
"iphone": "iPhone",
"iphone-17": "iPhone 17",
"iphone-17-pro": "iPhone 17 Pro",
"iphone-17e": "iPhone 17e",
"iphone-air": "iPhone Air",
"watch": "Apple Watch",
"apple-watch-series-11": "Apple Watch",
"apple-watch-se-3": "Apple Watch",
"apple-watch-ultra-3": "Apple Watch",
"apple-watch-nike": "Apple Watch",
"apple-watch-hermes": "Apple Watch",
"apple-vision-pro": "Vision",
"airpods": "AirPods",
"airpods-4": "AirPods",
"airpods-pro": "AirPods Pro",
"airpods-max": "AirPods Max",
"tv-home": "HomePod",
"apple-tv-4k": "Apple TV",
"homepod-2nd-generation": "HomePod",
"homepod-mini": "HomePod mini",
"wallet": "MagSafe",
}
def line_search_term(route: str) -> str | None:
return LINE_SEARCH_TERMS.get(route.strip("/").split("/")[0])
|